VirtualBox

Changeset 106036 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 12, 2024 1:40:36 PM (3 months ago)
Author:
vboxsync
Message:

VMM/IEM: Changed the IEMNATIVEMITEFLOP/enmOp argument to iemNativeEmitModifyEFlagsBit into a template argument to encourage compile time resolution. bugref:10720

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompFuncs.h

    r106006 r106036  
    59595959typedef enum IEMNATIVEMITEFLOP
    59605960{
    5961     kIemNativeEmitEflOp_Invalid = 0,
    59625961    kIemNativeEmitEflOp_Set,
    59635962    kIemNativeEmitEflOp_Clear,
     
    59665965
    59675966#define IEM_MC_SET_EFL_BIT(a_fBit) \
    5968     off = iemNativeEmitModifyEFlagsBit(pReNative, off, a_fBit, kIemNativeEmitEflOp_Set);
     5967    off = iemNativeEmitModifyEFlagsBit<kIemNativeEmitEflOp_Set>(pReNative, off, a_fBit)
    59695968
    59705969#define IEM_MC_CLEAR_EFL_BIT(a_fBit) \
    5971     off = iemNativeEmitModifyEFlagsBit(pReNative, off, a_fBit, kIemNativeEmitEflOp_Clear);
     5970    off = iemNativeEmitModifyEFlagsBit<kIemNativeEmitEflOp_Clear>(pReNative, off, a_fBit)
    59725971
    59735972#define IEM_MC_FLIP_EFL_BIT(a_fBit) \
    5974     off = iemNativeEmitModifyEFlagsBit(pReNative, off, a_fBit, kIemNativeEmitEflOp_Flip);
     5973    off = iemNativeEmitModifyEFlagsBit<kIemNativeEmitEflOp_Flip>(pReNative, off, a_fBit)
    59755974
    59765975/** Handles IEM_MC_SET_EFL_BIT/IEM_MC_CLEAR_EFL_BIT/IEM_MC_FLIP_EFL_BIT. */
    5977 DECL_INLINE_THROW(uint32_t)
    5978 iemNativeEmitModifyEFlagsBit(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t fEflBit, IEMNATIVEMITEFLOP enmOp)
     5976template<IEMNATIVEMITEFLOP const a_enmOp>
     5977DECL_INLINE_THROW(uint32_t) iemNativeEmitModifyEFlagsBit(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t fEflBit)
    59795978{
    59805979    uint8_t const idxEflReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_EFlags,
    59815980                                                              kIemNativeGstRegUse_ForUpdate, false /*fNoVolatileRegs*/);
    59825981
    5983     switch (enmOp)
    5984     {
    5985         case kIemNativeEmitEflOp_Set:
    5986             off = iemNativeEmitOrGpr32ByImm(pReNative, off, idxEflReg, fEflBit);
    5987             break;
    5988         case kIemNativeEmitEflOp_Clear:
    5989             off = iemNativeEmitAndGpr32ByImm(pReNative, off, idxEflReg, ~fEflBit);
    5990             break;
    5991         case kIemNativeEmitEflOp_Flip:
    5992             off = iemNativeEmitXorGpr32ByImm(pReNative, off, idxEflReg, fEflBit);
    5993             break;
    5994         default:
    5995             AssertFailed();
    5996             break;
    5997     }
     5982    /* Using 'if constexpr' forces code elimination in debug builds with VC. */
     5983    if RT_CONSTEXPR_IF(a_enmOp == kIemNativeEmitEflOp_Set)
     5984        off = iemNativeEmitOrGpr32ByImm(pReNative, off, idxEflReg, fEflBit);
     5985    else if RT_CONSTEXPR_IF(a_enmOp == kIemNativeEmitEflOp_Clear)
     5986        off = iemNativeEmitAndGpr32ByImm(pReNative, off, idxEflReg, ~fEflBit);
     5987    else if RT_CONSTEXPR_IF(a_enmOp == kIemNativeEmitEflOp_Flip)
     5988        off = iemNativeEmitXorGpr32ByImm(pReNative, off, idxEflReg, fEflBit);
     5989    else
     5990        AssertCompile(   a_enmOp == kIemNativeEmitEflOp_Set /* AssertCompile(false) works with VC 2019 but not clang 15. */
     5991                      || a_enmOp == kIemNativeEmitEflOp_Clear
     5992                      || a_enmOp == kIemNativeEmitEflOp_Flip);
    59985993
    59995994    /** @todo No delayed writeback for EFLAGS right now. */
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