VirtualBox

Ignore:
Timestamp:
Apr 8, 2025 1:04:50 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168326
Message:

VMM/IEM: Working on the ARM bsd/opensource spec reader & decoder generator. Work in progress. Basic construction algo should be there now. jiraref:VBP-1598

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/target-armv8/bsd-spec-analyze.py

    r108875 r108876  
    11441144        cInstructions = len(self.aoInstructions)
    11451145        if cInstructions <= 4:
    1146             #assert len(self.dChildren) == 0;
     1146            assert not self.dChildren;
    11471147            uCost = 0;
    11481148            # Special case: 1 instruction - leaf.
     
    11571157            else:
    11581158                self.fChildMask = DecoderNode.kChildMaskMultipleOpcodeValueIfs;
    1159                 for i, oInstr in enumerate(self.aoInstructions):
    1160                     self.dChildren[i] = DecoderNode([oInstr], oInstr.fFixedMask, oInstr.fFixedMask);
    11611159                uCost = 32 * cInstructions * 2;                                         # 32 = kCostMultipleOpcodeValueIfs
    1162             return uCost #<< uDepth;
     1160            return uCost;
    11631161
    11641162        #
     
    12411239                    uCostTmp    = 256;                                                  # 256 = kCostIndirectCall
    12421240                    uCostTmp   += (len(aaiMaskToIdxAlgo) - 1) * 2;                      #   2 = kCostPerExtraIndexStep
    1243                     #uCostTmp  <<= uDepth;   # Make the cost exponentially higher with depth. (?)
    12441241                    if uCostTmp >= uCostBest:
    12451242                        #if uDepth <= 2:
     
    12751272                    cNominalFill = 1 << (cMaskBits - 1); # 50% full or better is great.
    12761273                    if len(daoTmp) < cNominalFill:
    1277                         uCostTmp += ((cNominalFill - len(daoTmp)) * 2) #<< uDepth;  # 2 = kCostUnusedTabEntry
     1274                        uCostTmp += ((cNominalFill - len(daoTmp)) * 2);                 # 2 = kCostUnusedTabEntry
    12781275                        if uCostTmp >= uCostBest:
    12791276                            #if uDepth <= 2:
     
    15021499        Handles a leaf node.
    15031500        """
    1504         assert not oNode.dChildren;
     1501        assert not oNode.dChildren, \
     1502               'fChildMask=%#x dChildren=%s aoInstr=%s' % (oNode.fChildMask, oNode.dChildren, oNode.aoInstructions,);
    15051503
    15061504        asLines = [
     
    15271525        Recursively generates the decoder code.
    15281526        """
    1529         assert oNode.fChildMask != 0 and oNode.fChildMask < (1 << 24), \
     1527        assert oNode.fChildMask != 0 and oNode.fChildMask not in (0x7fffffff, 0xffffffff, 0x4fffffff), \
    15301528            'fChildMask=%s #dChildren=%s aoInstr=%s' % (oNode.fChildMask, len(oNode.dChildren), oNode.aoInstructions,);
    15311529        asLines = [];
     
    15331531        # First recurse.
    15341532        for oChildNode in oNode.dChildren.values():
    1535             if oChildNode.fChildMask == DecoderNode.kChildMaskMultipleOpcodeValueIfs:
     1533            if oChildNode.dChildren:
     1534                asLines += self.generateDecoderCode(oChildNode, uDepth + 1);
     1535            elif oChildNode.fChildMask == DecoderNode.kChildMaskMultipleOpcodeValueIfs:
     1536                assert len(oChildNode.aoInstructions) > 1;
    15361537                asLines += self.generateDecoderCodeMultiIfFunc(oChildNode, uDepth + 1);
    1537             elif oChildNode.fChildMask != DecoderNode.kChildMaskOpcodeValueIf:
    1538                 assert oChildNode.dChildren;
    1539                 asLines += self.generateDecoderCode(oChildNode, uDepth + 1);
    15401538            else:
    1541                 assert not oChildNode.dChildren;
     1539                assert len(oChildNode.aoInstructions) == 1;
     1540                assert oChildNode.fChildMask in [DecoderNode.kChildMaskOpcodeValueIf, 0];
    15421541
    15431542        # Generate the function.
     
    15701569        assert aaiAlgo, 'fChildMask=%s #children=%s instrs=%s' % (oNode.fChildMask, len(oNode.dChildren), oNode.aoInstructions,);
    15711570        asIdx = [
    1572             '    uintptr_t const idx = ((uOpcode >> %2u) & %#010x) /* bit %u L %u -> 0 */'
     1571            '    uintptr_t const idx = ((uOpcode >> %2u) & %#010x) /* bit %2u L %u -> 0 */'
    15731572            % (aaiAlgo[0][0], aaiAlgo[0][2], aaiAlgo[0][0], aaiAlgo[0][2].bit_count(), ),
    15741573        ];
    15751574        for iSrcBit, iDstBit, fMask in aaiAlgo[1:]:
    1576             asIdx.append('                        | ((uOpcode >> %2u) & %#010x) /* bit %u L %u -> %u */'
     1575            asIdx.append('                        | ((uOpcode >> %2u) & %#010x) /* bit %2u L %u -> %u */'
    15771576                         % (iSrcBit - iDstBit, fMask << iDstBit, iSrcBit, fMask.bit_count(), iDstBit));
    15781577        asIdx[-1] += ';';
Note: See TracChangeset for help on using the changeset viewer.

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