VirtualBox

Changeset 101557 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Oct 23, 2023 2:39:59 PM (15 months ago)
Author:
vboxsync
Message:

VMM/IEM: Got conditional jumps working, currently only those testing for a single EFLAGS bit. The fun with branching code is how to handle the register allocation and variable state. bugref:10371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r101547 r101557  
    264264    kIemNativeLabelType_Invalid = 0,
    265265    kIemNativeLabelType_Return,
     266#ifdef IEMNATIVE_WITH_TB_DEBUG_INFO
     267    kIemNativeLabelType_If,
     268#endif
    266269    kIemNativeLabelType_Else,
    267270    kIemNativeLabelType_Endif,
     
    477480
    478481/**
     482 * Core state for the native recompiler, that is, things that needs careful
     483 * handling when dealing with branches.
     484 */
     485typedef struct IEMNATIVECORESTATE
     486{
     487    /** Allocation bitmap for aHstRegs. */
     488    uint32_t                    bmHstRegs;
     489
     490    /** Bitmap marking which host register contains guest register shadow copies.
     491     * This is used during register allocation to try preserve copies.  */
     492    uint32_t                    bmHstRegsWithGstShadow;
     493    /** Bitmap marking valid entries in aidxGstRegShadows. */
     494    uint64_t                    bmGstRegShadows;
     495
     496    union
     497    {
     498        /** Index of variable arguments, UINT8_MAX if not valid. */
     499        uint8_t                 aidxArgVars[8];
     500        /** For more efficient resetting. */
     501        uint64_t                u64ArgVars;
     502    };
     503
     504    /** Allocation bitmap for aVars. */
     505    uint32_t                    bmVars;
     506
     507    /** Maps a guest register to a host GPR (index by IEMNATIVEGSTREG).
     508     * Entries are only valid if the corresponding bit in bmGstRegShadows is set.
     509     * (A shadow copy of a guest register can only be held in a one host register,
     510     * there are no duplicate copies or ambiguities like that). */
     511    uint8_t                     aidxGstRegShadows[kIemNativeGstReg_End];
     512
     513    /** Host register allocation tracking. */
     514    IEMNATIVEHSTREG             aHstRegs[IEMNATIVE_HST_GREG_COUNT];
     515
     516    /** Variables and arguments. */
     517    IEMNATIVEVAR                aVars[9];
     518} IEMNATIVECORESTATE;
     519/** Pointer to core state. */
     520typedef IEMNATIVECORESTATE *PIEMNATIVECORESTATE;
     521/** Pointer to const core state. */
     522typedef IEMNATIVECORESTATE const *PCIEMNATIVECORESTATE;
     523
     524
     525/**
    479526 * Conditional stack entry.
    480527 */
     
    482529{
    483530    /** Set if we're in the "else" part, clear if we're in the "if" before it. */
    484     bool     fInElse;
     531    bool                        fInElse;
    485532    /** The label for the IEM_MC_ELSE. */
    486     uint32_t idxLabelElse;
     533    uint32_t                    idxLabelElse;
    487534    /** The label for the IEM_MC_ENDIF. */
    488     uint32_t idxLabelEndIf;
     535    uint32_t                    idxLabelEndIf;
     536    /** The initial state snapshot as the if-block starts executing. */
     537    IEMNATIVECORESTATE          InitialState;
     538    /** The state snapshot at the end of the if-block. */
     539    IEMNATIVECORESTATE          IfFinalState;
    489540} IEMNATIVECOND;
    490541/** Pointer to a condition stack entry. */
     
    504555    uint32_t                    offInstrBufChecked;
    505556#else
    506     uint32_t                    uPadding; /* We don't keep track of the size here... */
     557    uint32_t                    uPadding1; /* We don't keep track of the size here... */
    507558#endif
    508559    /** Fixed temporary code buffer for native recompilation. */
     
    531582    /** Debug info. */
    532583    PIEMTBDBG                   pDbgInfo;
    533 #else
    534     uint32_t                    abPadding1[2];
    535     uintptr_t                   uPtrPadding2;
    536584#endif
    537585
     
    539587    PCIEMTB                     pTbOrg;
    540588
    541     /** Allocation bitmap fro aHstRegs. */
    542     uint32_t                    bmHstRegs;
    543 
    544     /** Bitmap marking which host register contains guest register shadow copies.
    545      * This is used during register allocation to try preserve copies.  */
    546     uint32_t                    bmHstRegsWithGstShadow;
    547     /** Bitmap marking valid entries in aidxGstRegShadows. */
    548     uint64_t                    bmGstRegShadows;
    549 
    550589    /** The current condition stack depth (aCondStack). */
    551590    uint8_t                     cCondDepth;
    552     uint8_t                     bPadding;
     591    uint8_t                     bPadding2;
    553592    /** Condition sequence number (for generating unique labels). */
    554593    uint16_t                    uCondSeqNo;
    555 
    556     /** Allocation bitmap for aVars. */
    557     uint32_t                    bmVars;
    558     union
    559     {
    560         /** Index of variable arguments, UINT8_MAX if not valid. */
    561         uint8_t                 aidxArgVars[8];
    562         /** For more efficient resetting. */
    563         uint64_t                u64ArgVars;
    564     };
    565 
    566     /** Host register allocation tracking. */
    567     IEMNATIVEHSTREG             aHstRegs[IEMNATIVE_HST_GREG_COUNT];
    568     /** Maps a guest register to a host GPR (index by IEMNATIVEGSTREG).
    569      * Entries are only valid if the corresponding bit in bmGstRegShadows is set.
    570      * (A shadow copy of a guest register can only be held in a one host register,
    571      * there are no duplicate copies or ambiguities like that). */
    572     uint8_t                     aidxGstRegShadows[kIemNativeGstReg_End];
     594    uint32_t                    uPadding3;
     595
     596    /** Core state requiring care with branches. */
     597    IEMNATIVECORESTATE          Core;
    573598
    574599    /** The condition nesting stack. */
    575     IEMNATIVECOND               aCondStack[4];
    576 
    577     /** Variables and arguments. */
    578     IEMNATIVEVAR                aVars[16];
     600    IEMNATIVECOND               aCondStack[2];
    579601} IEMRECOMPILERSTATE;
    580602/** Pointer to a native recompiler state. */
     
    15211543        /* Best to use a temporary register to deal with this in the simplest way: */
    15221544        uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, (uint64_t)iAddend);
    1523         AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->aHstRegs), UINT32_MAX);
     1545        AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->Core.aHstRegs), UINT32_MAX);
    15241546
    15251547        /* add dst, tmpreg  */
     
    15481570        /* Use temporary register for the immediate. */
    15491571        uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, (uint64_t)iAddend);
    1550         AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->aHstRegs), UINT32_MAX);
     1572        AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->Core.aHstRegs), UINT32_MAX);
    15511573
    15521574        /* add gprdst, gprdst, tmpreg */
     
    16021624        /* Use temporary register for the immediate. */
    16031625        uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, (uint32_t)iAddend);
    1604         AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->aHstRegs), UINT32_MAX);
     1626        AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->Core.aHstRegs), UINT32_MAX);
    16051627
    16061628        /* add gprdst, gprdst, tmpreg */
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