VirtualBox

Ignore:
Timestamp:
Apr 5, 2023 10:15:47 AM (21 months ago)
Author:
vboxsync
Message:

VMM/IEM: More work on processing MC blocks and generating threaded functions from them. bugref:10369

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllThreadedPython.py

    r99291 r99296  
    5050
    5151## Number of generic parameters for the thread functions.
    52 g_kcThreadedParams = 3;
     52g_kcThreadedParams = 4; ## @todo 3
    5353
    5454g_kdTypeInfo = {
     
    101101    """
    102102
    103     def __init__(self, sOrgRef, sType, oStmt, iParam = None, offParam = 0):
    104         self.sOrgRef  = sOrgRef;                    ##< The name / reference in the original code.
    105         self.sStdRef  = ''.join(sOrgRef.split());   ##< Normalized name to deal with spaces in macro invocations and such.
    106         self.sType    = sType;                      ##< The type (typically derived).
    107         self.oStmt    = oStmt;                      ##< The statement making the reference.
    108         self.iParam   = iParam;                     ##< The parameter containing the references. None if implicit.
    109         self.offParam = offParam;                   ##< The offset in the parameter of the reference.
    110 
    111         self.sNewName     = 'x';                    ##< The variable name in the threaded function.
    112         self.iNewParam    = 99;                     ##< The this is packed into.
    113         self.offNewParam  = 1024                    ##< The bit offset in iNewParam.
     103    def __init__(self, sOrgRef, sType, oStmt, iParam = None, offParam = 0, sStdRef = None):
     104        ## The name / reference in the original code.
     105        self.sOrgRef    = sOrgRef;
     106        ## Normalized name to deal with spaces in macro invocations and such.
     107        self.sStdRef    = sStdRef if sStdRef else ''.join(sOrgRef.split());
     108        ## Indicates that sOrgRef may not match the parameter.
     109        self.fCustomRef = sStdRef is not None;
     110        ## The type (typically derived).
     111        self.sType      = sType;
     112        ## The statement making the reference.
     113        self.oStmt      = oStmt;
     114        ## The parameter containing the references. None if implicit.
     115        self.iParam     = iParam;
     116        ## The offset in the parameter of the reference.
     117        self.offParam   = offParam;
     118
     119        ## The variable name in the threaded function.
     120        self.sNewName     = 'x';
     121        ## The this is packed into.
     122        self.iNewParam    = 99;
     123        ## The bit offset in iNewParam.
     124        self.offNewParam  = 1024
    114125
    115126
     
    258269            sBaseType = self.analyzeCallToType('pImpl');
    259270            offBits   = sMember.rfind('U') + 1;
    260             if sBaseType == 'PCIEMOPBINSIZES':          return 'PFNIEMAIMPLBIN'         + sMember[offBits:];
    261             if sBaseType == 'PCIEMOPUNARYSIZES':        return 'PFNIEMAIMPLBIN'         + sMember[offBits:];
    262             if sBaseType == 'PCIEMOPSHIFTSIZES':        return 'PFNIEMAIMPLSHIFT'       + sMember[offBits:];
     271            if sBaseType == 'PCIEMOPBINSIZES':          return 'PFNIEMAIMPLBINU'        + sMember[offBits:];
     272            if sBaseType == 'PCIEMOPUNARYSIZES':        return 'PFNIEMAIMPLBINU'        + sMember[offBits:];
     273            if sBaseType == 'PCIEMOPSHIFTSIZES':        return 'PFNIEMAIMPLSHIFTU'      + sMember[offBits:];
    263274            if sBaseType == 'PCIEMOPSHIFTDBLSIZES':     return 'PFNIEMAIMPLSHIFTDBLU'   + sMember[offBits:];
    264275            if sBaseType == 'PCIEMOPMULDIVSIZES':       return 'PFNIEMAIMPLMULDIVU'     + sMember[offBits:];
     
    273284        self.raiseProblem('Unknown call reference: %s' % (sFnRef,));
    274285        return None; # Shut up pylint 2.16.2.
     286
     287    def analyze8BitGRegStmt(self, oStmt):
     288        """
     289        Gets the 8-bit general purpose register access details of the given statement.
     290        ASSUMES the statement is one accessing an 8-bit GREG.
     291        """
     292        idxReg = 0;
     293        if (   oStmt.sName.find('_STORE_') > 0
     294            or oStmt.sName.find('_REF_') > 0
     295            or oStmt.sName.find('_TO_LOCAL') > 0):
     296            idxReg = 1;
     297
     298        sRegRef = oStmt.asParams[idxReg];
     299        sOrgExpr = '((%s) < 4 || (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) ? (%s) : (%s) | 16)' % (sRegRef, sRegRef, sRegRef);
     300
     301        if sRegRef.find('IEM_GET_MODRM_RM') > 0:    sStdRef = 'bRmRm8Ex';
     302        elif sRegRef.find('IEM_GET_MODRM_REG') > 0: sStdRef = 'bRmReg8Ex';
     303        else:                                       sStdRef = 'bOther8Ex';
     304
     305        return (idxReg, sOrgExpr, sStdRef);
     306
    275307
    276308    def analyzeMorphStmtForThreaded(self, aoStmts, iParamRef = 0):
     
    312344                            #print('iCurRef=%s iParam=%s sOrgRef=%s' % (iCurRef, oCurRef.iParam, oCurRef.sOrgRef));
    313345                            sSrcParam = oNewStmt.asParams[oCurRef.iParam];
    314                             assert sSrcParam[oCurRef.offParam : oCurRef.offParam + len(oCurRef.sOrgRef)] == oCurRef.sOrgRef, \
     346                            assert (   sSrcParam[oCurRef.offParam : oCurRef.offParam + len(oCurRef.sOrgRef)] == oCurRef.sOrgRef
     347                                    or oCurRef.fCustomRef), \
    315348                                   'offParam=%s sOrgRef=%s sSrcParam=%s<eos>' % (oCurRef.offParam, oCurRef.sOrgRef, sSrcParam);
    316349                            oNewStmt.asParams[oCurRef.iParam] = sSrcParam[0 : oCurRef.offParam] \
     
    345378                    oNewStmt.sName += '_THREADED';
    346379
     380                # ... and IEM_MC_*_GREG_U8 into *_THREADED w/ reworked index taking REX into account
     381                elif oNewStmt.sName.startswith('IEM_MC_') and oNewStmt.sName.find('_GREG_U8') > 0:
     382                    (idxReg, sOrgRef, sStdRef) = self.analyze8BitGRegStmt(oNewStmt);
     383                    oNewStmt.asParams[idxReg] = self.dParamRefs[sStdRef][0].sNewName;
     384                    oNewStmt.sName += '_THREADED';
     385
    347386                # ... and IEM_MC_CALL_CIMPL_[0-5] into *_THREADED ...
    348387                elif oNewStmt.sName.startswith('IEM_MC_CALL_CIMPL_'):
     
    483522                    self.aoParamRefs.append(ThreadedParamRef('u32Disp', 'uint32_t', oStmt));
    484523                    self.aoParamRefs.append(ThreadedParamRef('cbInstr', 'uint4_t',  oStmt));
     524
     525            # 8-bit register accesses needs to have their index argument reworked to take REX into account.
     526                # ... and IEM_MC_*_GREG_U8 into *_THREADED w/ reworked index taking REX into account
     527            if oStmt.sName.startswith('IEM_MC_') and oStmt.sName.find('_GREG_U8') > 0:
     528                (idxReg, sOrgRef, sStdRef) = self.analyze8BitGRegStmt(oStmt);
     529                self.aoParamRefs.append(ThreadedParamRef(sOrgRef, 'uint4_t', oStmt, idxReg, sStdRef = sStdRef));
    485530
    486531            # Inspect the target of calls to see if we need to pass down a
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