VirtualBox

Changeset 104240 in vbox


Ignore:
Timestamp:
Apr 8, 2024 10:48:08 PM (8 months ago)
Author:
vboxsync
Message:

VMM/IEM: ARM assembly rendition of ROR. bugref:10376

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImpl-arm64.S

    r104239 r104240  
    741741         * Calculate EFLAGS - only CF and OF.
    742742         */
    743         bfi     w0, w9, #0, #1                  /* CF = last bit rotated around */
     743        bfi     w0, w9, #0, #1                  /* CF = last bit rotated around (new bottom bit) */
    744744
    745745.ifne \a_fIntelFlags
     
    815815ROL_64 iemAImpl_rol_u64_amd,   0
    816816
     817
     818/*
     819 * Rotate Right.
     820 */
     821
     822/* uint32_t iemAImpl_ror_u8( uint32_t fEFlagsIn, uint8_t *pu8Dst, uint8_t cShift); */
     823/* uint32_t iemAImpl_ror_u16(uint32_t fEFlagsIn, uint16_t *pu16Dst, uint8_t cShift); */
     824/* uint32_t iemAImpl_ror_u32(uint32_t fEFlagsIn, uint16_t *pu32Dst, uint8_t cShift); */
     825.macro ROR_8_16_32, a_Name, a_cBits, a_fIntelFlags, a_LdStSuff
     826ALIGNCODE(IEM_AIMPL_FUNCTION_ALIGNMENT)
     827BEGINPROC_HIDDEN \a_Name
     828        .cfi_startproc
     829
     830        /* Do we need to rotate anything at all? */
     831        and     w2, w2, #0x1f
     832        cbz     w2, 99f
     833
     834        /*
     835         * Do the shifting
     836         */
     837.ifne \a_cBits < 32
     838        and     w2, w2, #(\a_cBits - 1)
     839        neg     w3, w2
     840        and     w3, w3, #(\a_cBits - 1)
     841        ldr\a_LdStSuff  w8, [x1]
     842        lsrv    w9, w8, w2
     843        lslv    w10, w8, w3
     844        orr     w9, w9, w10
     845        str\a_LdStSuff  w9, [x1]
     846        and     w9, w9, #(RT_BIT_32(\a_cBits) - 1)
     847.else
     848        ldr\a_LdStSuff  w8, [x1]
     849        rorv    w9, w8, w2
     850        str\a_LdStSuff  w9, [x1]
     851.endif
     852
     853        /*
     854         * Calculate EFLAGS - only CF and OF.
     855         */
     856        bfxil   w0, w9, #(\a_cBits - 1), #1     /* CF = last bit rotated around (new top bit) */
     857
     858.ifne \a_fIntelFlags
     859        /* Intel: OF = first rotate step: X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uDst << (a_cBitsWidth - 1))); */
     860        eor     w11, w8, w8, LSR #(\a_cBits - 1)
     861        bfi     w0, w11, #X86_EFL_OF_BIT, #1
     862.else
     863        /* AMD: OF = last rotate step: fEFlags |= (((uResult >> ((a_cBitsWidth) - 2)) ^ fCarry) & 1) << X86_EFL_OF_BIT; */
     864        eor     w11, w0, w9, LSR #(\a_cBits - 2)
     865        bfi     w0, w11, #X86_EFL_OF_BIT, #1
     866.endif
     867
     86899:
     869        ret
     870        .cfi_endproc
     871.endm
     872
     873ROR_8_16_32 iemAImpl_ror_u8,         8, 1, b
     874ROR_8_16_32 iemAImpl_ror_u8_intel,   8, 1, b
     875ROR_8_16_32 iemAImpl_ror_u8_amd,     8, 0, b
     876
     877ROR_8_16_32 iemAImpl_ror_u16,       16, 1, h
     878ROR_8_16_32 iemAImpl_ror_u16_intel, 16, 1, h
     879ROR_8_16_32 iemAImpl_ror_u16_amd,   16, 0, h
     880
     881ROR_8_16_32 iemAImpl_ror_u32,       32, 1,
     882ROR_8_16_32 iemAImpl_ror_u32_intel, 32, 1,
     883ROR_8_16_32 iemAImpl_ror_u32_amd,   32, 0,
     884
     885/** @todo this is slightly slower than the C version (release) on an M2. Investigate why. */
     886/* uint32_t iemAImpl_ror_u64(uint32_t fEFlagsIn, uint16_t *pu64Dst, uint8_t cShift); */
     887.macro ROR_64, a_Name, a_fIntelFlags
     888ALIGNCODE(IEM_AIMPL_FUNCTION_ALIGNMENT)
     889BEGINPROC_HIDDEN \a_Name
     890        .cfi_startproc
     891
     892        /* Do we need to shift anything at all? */
     893        and     w2, w2, #0x3f
     894        cbz     w2, 99f
     895
     896        /*
     897         * Do the shifting
     898         */
     899        ldr     x8, [x1]
     900        rorv    x9, x8, x2
     901        str     x9, [x1]
     902
     903        /*
     904         * Calculate EFLAGS - only CF and OF.
     905         */
     906        bfxil   x0, x9, #(64 - 1), #1           /* CF = last bit rotated around (new top bit) */
     907
     908.ifne \a_fIntelFlags
     909        /* Intel: OF = first rotate step: X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uDst << (a_cBitsWidth - 1))); */
     910        eor     x11, x8, x8, LSR #(64 - 1)
     911        bfi     w0, w11, #X86_EFL_OF_BIT, #1
     912.else
     913        /* AMD: OF = last rotate step: fEFlags |= (((uResult >> ((a_cBitsWidth) - 2)) ^ fCarry) & 1) << X86_EFL_OF_BIT; */
     914        eor     x11, x0, x9, LSR #(64 - 2)
     915        bfi     w0, w11, #X86_EFL_OF_BIT, #1
     916.endif
     917
     91899:
     919        ret
     920        .cfi_endproc
     921.endm
     922
     923ROR_64 iemAImpl_ror_u64,       1
     924ROR_64 iemAImpl_ror_u64_intel, 1
     925ROR_64 iemAImpl_ror_u64_amd,   0
     926
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp

    r104239 r104240  
    31803180}
    31813181
    3182 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY)
     3182#ifndef RT_ARCH_ARM64
     3183
     3184# if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY)
    31833185EMIT_ROR(64, uint64_t, RT_NOTHING, 1, ASMRotateRightU64)
    3184 #endif
     3186# endif
    31853187EMIT_ROR(64, uint64_t, _intel,     1, ASMRotateRightU64)
    31863188EMIT_ROR(64, uint64_t, _amd,       0, ASMRotateRightU64)
    31873189
    3188 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
     3190# if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
    31893191EMIT_ROR(32, uint32_t, RT_NOTHING, 1, ASMRotateRightU32)
    3190 #endif
     3192# endif
    31913193EMIT_ROR(32, uint32_t, _intel,     1, ASMRotateRightU32)
    31923194EMIT_ROR(32, uint32_t, _amd,       0, ASMRotateRightU32)
     
    31963198    return (uValue >> cShift) | (uValue << (16 - cShift));
    31973199}
    3198 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
     3200# if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
    31993201EMIT_ROR(16, uint16_t, RT_NOTHING, 1, iemAImpl_ror_u16_hlp)
    3200 #endif
     3202# endif
    32013203EMIT_ROR(16, uint16_t, _intel,     1, iemAImpl_ror_u16_hlp)
    32023204EMIT_ROR(16, uint16_t, _amd,       0, iemAImpl_ror_u16_hlp)
     
    32063208    return (uValue >> cShift) | (uValue << (8 - cShift));
    32073209}
    3208 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
     3210# if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY)
    32093211EMIT_ROR(8,  uint8_t,  RT_NOTHING, 1, iemAImpl_ror_u8_hlp)
    3210 #endif
     3212# endif
    32113213EMIT_ROR(8,  uint8_t,  _intel,     1, iemAImpl_ror_u8_hlp)
    32123214EMIT_ROR(8,  uint8_t,  _amd,       0, iemAImpl_ror_u8_hlp)
    32133215
     3216#endif /* !RT_ARCH_ARM64 */
    32143217
    32153218/*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette