Changeset 99288 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Apr 4, 2023 11:55:49 PM (21 months ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsPython.py
r99226 r99288 529 529 530 530 ## \@ophints values. 531 # pylint: disable=line-too-long 531 532 g_kdHints = { 532 533 'invalid': 'DISOPTYPE_INVALID', ##< … … 568 569 'lock_allowed': '', ##< Lock prefix allowed. 569 570 }; 571 # pylint: enable=line-too-long 570 572 571 573 ## \@opxcpttype values (see SDMv2 2.4, 2.7). … … 1741 1743 1742 1744 # 1745 # Decoder functions. 1746 # 1747 1748 class DecoderFunction(object): 1749 """ 1750 Decoder function. 1751 1752 This is mainly for searching for scoping searches for variables used in 1753 microcode blocks. 1754 """ 1755 def __init__(self, sSrcFile, iBeginLine, sName, asDefArgs): 1756 self.sName = sName; ##< The function name. 1757 self.asDefArgs = asDefArgs; ##< The FNIEMOP*DEF/STUB* macro argument list, 0th element is the macro name. 1758 self.sSrcFile = sSrcFile; ##< The source file the function is defined in. 1759 self.iBeginLine = iBeginLine; ##< The start line. 1760 self.iEndLine = -1; ##< The line the function (probably) ends on. 1761 self.asLines = [] # type: list(str) ##< The raw lines the function is made up of. 1762 1763 def complete(self, iEndLine, asLines): 1764 """ 1765 Completes the function. 1766 """ 1767 assert self.iEndLine == -1; 1768 self.iEndLine = iEndLine; 1769 self.asLines = asLines; 1770 1771 1772 # 1743 1773 # "Microcode" statements and blocks 1744 1774 # … … 1887 1917 """ 1888 1918 1889 def __init__(self, sSrcFile, iBeginLine, offBeginLine, sFunction, iInFunction, cchIndent = None):1919 def __init__(self, sSrcFile, iBeginLine, offBeginLine, oFunction, iInFunction, cchIndent = None): 1890 1920 self.sSrcFile = sSrcFile; ##< The source file containing the block. 1891 1921 self.iBeginLine = iBeginLine; ##< The line with the IEM_MC_BEGIN statement. … … 1893 1923 self.iEndLine = -1; ##< The line with the IEM_MC_END statement. 1894 1924 self.offEndLine = 0; ##< The offset of the IEM_MC_END statement within the line. 1895 self.sFunction = sFunction; ##< The function the block resides in. 1925 self.oFunction = oFunction; ##< The function the block resides in. 1926 self.sFunction = oFunction.sName; ##< The name of the function the block resides in. DEPRECATED. 1896 1927 self.iInFunction = iInFunction; ##< The block number wihtin the function. 1897 1928 self.cchIndent = cchIndent if cchIndent else offBeginLine; … … 2860 2891 self.iCommentLine = 0; 2861 2892 self.aoCurInstrs = [] # type: list(Instruction) 2862 self. sCurFunction = None # type: str2893 self.oCurFunction = None # type: DecoderFunction 2863 2894 self.iMcBlockInFunc = 0; 2864 2895 self.oCurMcBlock = None # type: McBlock … … 3252 3283 self.aoCurInstrs = []; 3253 3284 if fEndOfFunction: 3254 #self.debug('%s: sCurFunction=None' % (self.iLine, )); 3255 self.sCurFunction = None; 3285 #self.debug('%s: oCurFunction=None' % (self.iLine, )); 3286 if self.oCurFunction: 3287 self.oCurFunction.complete(self.iLine, self.asLines[self.oCurFunction.iBeginLine - 1 : self.iLine]); 3288 self.oCurFunction = None; 3256 3289 self.iMcBlockInFunc = 0; 3257 3290 return True; … … 4510 4543 4511 4544 # Check preconditions. 4512 if not self. sCurFunction:4545 if not self.oCurFunction: 4513 4546 self.raiseError('IEM_MC_BEGIN w/o current function (%s)' % (sCode,)); 4514 4547 if self.oCurMcBlock: … … 4520 4553 if offPrevNewline >= 0: 4521 4554 cchIndent -= offPrevNewline + 1; 4522 #self.debug('cchIndent=%s offPrevNewline=%s sFunc=%s' % (cchIndent, offPrevNewline, self. sCurFunction));4555 #self.debug('cchIndent=%s offPrevNewline=%s sFunc=%s' % (cchIndent, offPrevNewline, self.oCurFunction.sName)); 4523 4556 4524 4557 # Start a new block. 4525 4558 self.oCurMcBlock = McBlock(self.sSrcFile, self.iLine, offBeginStatementInLine, 4526 self. sCurFunction, self.iMcBlockInFunc, cchIndent);4559 self.oCurFunction, self.iMcBlockInFunc, cchIndent); 4527 4560 g_aoMcBlocks.append(self.oCurMcBlock); 4528 4561 self.cTotalMcBlocks += 1; … … 4570 4603 self.oCurMcBlock.complete(self.iLine, offEndStatementInLine, asLines); 4571 4604 self.oCurMcBlock = None; 4605 return True; 4606 4607 def workerStartFunction(self, asArgs): 4608 """ 4609 Deals with the start of a decoder function. 4610 4611 These are all defined using one of the FNIEMOP*_DEF* and FNIEMOP_*STUB* 4612 macros, so we get a argument list for these where the 0th argument is the 4613 macro name. 4614 """ 4615 # Complete any existing function. 4616 if self.oCurFunction: 4617 self.oCurFunction.complete(self.iLine - 1, self.asLines[self.oCurFunction.iBeginLine - 1 : self.iLine - 1]); 4618 4619 # Create the new function. 4620 self.oCurFunction = DecoderFunction(self.sSrcFile, self.iLine, asArgs[1], asArgs); 4572 4621 return True; 4573 4622 … … 4590 4639 'FNIEMOP_UD_STUB_1' ]); 4591 4640 if asArgs is not None: 4592 self. sCurFunction = asArgs[1];4593 #self.debug('%s: sCurFunction=%s' % (self.iLine, self.sCurFunction,));4641 self.workerStartFunction(asArgs); 4642 #self.debug('%s: oCurFunction=%s' % (self.iLine, self.oCurFunction.sName,)); 4594 4643 4595 4644 if not self.aoCurInstrs: … … 4612 4661 'FNIEMOP_DEF_2', ]); 4613 4662 if asArgs is not None: 4614 self. sCurFunction = asArgs[1];4615 #self.debug('%s: sCurFunction=%s (%s)' % (self.iLine, self.sCurFunction, asArgs[0]));4663 self.workerStartFunction(asArgs); 4664 #self.debug('%s: oCurFunction=%s (%s)' % (self.iLine, self.oCurFunction.sName, asArgs[0])); 4616 4665 return True; 4617 4666 -
trunk/src/VBox/VMM/VMMAll/IEMAllThreadedPython.py
r98969 r99288 38 38 import datetime; 39 39 import os; 40 import re; 40 41 import sys; 41 42 import argparse; … … 222 223 return None; # Shut up pylint 2.16.2. 223 224 225 def analyzeCallToType(self, sFnRef): 226 """ 227 Determins the type of an indirect function call. 228 """ 229 assert sFnRef[0] == 'p'; 230 231 # 232 # Simple? 233 # 234 if sFnRef.find('-') < 0: 235 oDecoderFunction = self.oParent.oMcBlock.oFunction; 236 237 # Try the argument list of the function defintion macro invocation first. 238 iArg = 2; 239 while iArg < len(oDecoderFunction.asDefArgs): 240 if sFnRef == oDecoderFunction.asDefArgs[iArg]: 241 return oDecoderFunction.asDefArgs[iArg - 1]; 242 iArg += 1; 243 244 # Then check out line that includes the word and looks like a variable declaration. 245 oRe = re.compile(' +(P[A-Z0-9_]+|const +IEMOP[A-Z0-9_]+ *[*]) +(const |) *' + sFnRef + ' *(;|=)'); 246 for sLine in oDecoderFunction.asLines: 247 oMatch = oRe.match(sLine); 248 if oMatch: 249 if not oMatch.group(1).startswith('const'): 250 return oMatch.group(1); 251 return 'PC' + oMatch.group(1)[len('const ') : -1].strip(); 252 253 # 254 # Deal with the pImpl->pfnXxx: 255 # 256 elif sFnRef.startswith('pImpl->pfn'): 257 sMember = sFnRef[len('pImpl->') : ]; 258 sBaseType = self.analyzeCallToType('pImpl'); 259 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:]; 263 if sBaseType == 'PCIEMOPSHIFTDBLSIZES': return 'PFNIEMAIMPLSHIFTDBLU' + sMember[offBits:]; 264 if sBaseType == 'PCIEMOPMULDIVSIZES': return 'PFNIEMAIMPLMULDIVU' + sMember[offBits:]; 265 if sBaseType == 'PCIEMOPMEDIAF3': return 'PFNIEMAIMPLMEDIAF3U' + sMember[offBits:]; 266 if sBaseType == 'PCIEMOPMEDIAOPTF3': return 'PFNIEMAIMPLMEDIAOPTF3U' + sMember[offBits:]; 267 if sBaseType == 'PCIEMOPMEDIAOPTF2': return 'PFNIEMAIMPLMEDIAOPTF2U' + sMember[offBits:]; 268 if sBaseType == 'PCIEMOPMEDIAOPTF3IMM8': return 'PFNIEMAIMPLMEDIAOPTF3U' + sMember[offBits:] + 'IMM8'; 269 if sBaseType == 'PCIEMOPBLENDOP': return 'PFNIEMAIMPLAVXBLENDU' + sMember[offBits:]; 270 271 self.raiseProblem('Unknown call reference: %s::%s (%s)' % (sBaseType, sMember, sFnRef,)); 272 273 self.raiseProblem('Unknown call reference: %s' % (sFnRef,)); 274 return None; # Shut up pylint 2.16.2. 275 224 276 def analyzeMorphStmtForThreaded(self, aoStmts, iParamRef = 0): 225 277 """ … … 430 482 if isinstance(oStmt, iai.McStmtCall): 431 483 if oStmt.sFn[0] == 'p': 432 self.aoParamRefs.append(ThreadedParamRef(oStmt.sFn, 'uintptr_t', oStmt, oStmt.idxFn));484 self.aoParamRefs.append(ThreadedParamRef(oStmt.sFn, self.analyzeCallToType(oStmt.sFn), oStmt, oStmt.idxFn)); 433 485 elif ( oStmt.sFn[0] != 'i' 434 486 and not oStmt.sFn.startswith('IEMTARGETCPU_EFL_BEHAVIOR_SELECT') … … 588 640 def dummyInstance(): 589 641 """ Gets a dummy instance. """ 590 return ThreadedFunction(iai.McBlock('null', 999999999, 999999999, 'nil', 999999999)); 642 return ThreadedFunction(iai.McBlock('null', 999999999, 999999999, 643 iai.DecoderFunction('null', 999999999, 'nil', ('','')), 999999999)); 591 644 592 645 def raiseProblem(self, sMessage):
Note:
See TracChangeset
for help on using the changeset viewer.