Changeset 3995 in CLRX


Ignore:
Timestamp:
Apr 13, 2018, 3:09:16 PM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Move the rest of typedefs and classes from AsmRegAllocSSAData into AsmRegAlloc?.h.
Use size_t block indices in the part that resolving SSA conflicts.

Location:
CLRadeonExtender/trunk/amdasm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmRegAlloc.h

    r3993 r3995  
    190190struct CLRX_INTERNAL FlowStackEntry2
    191191{
    192     BlockIndex blockIndex;
     192    size_t blockIndex;
    193193    size_t nextIndex;
    194194};
     
    212212typedef std::unordered_map<BlockIndex, RoutineData> RoutineMap;
    213213
     214typedef std::unordered_map<size_t, std::pair<size_t, size_t> > PrevWaysIndexMap;
     215
     216class CLRX_INTERNAL ResSecondPointsToCache: public CBlockBitPool
     217{
     218public:
     219    explicit ResSecondPointsToCache(size_t n) : CBlockBitPool(n<<1, false)
     220    { }
     221   
     222    void increase(BlockIndex ip)
     223    {
     224        const size_t i = ip.index + (ip.pass ? (size()>>2) : 0);
     225        if ((*this)[i<<1])
     226            (*this)[(i<<1)+1] = true;
     227        else
     228            (*this)[i<<1] = true;
     229    }
     230   
     231    cxuint count(BlockIndex ip) const
     232    {
     233        const size_t i = ip.index + (ip.pass ? (size()>>2) : 0);
     234        return cxuint((*this)[i<<1]) + (*this)[(i<<1)+1];
     235    }
     236};
     237
     238typedef AsmRegAllocator::SSAReplace SSAReplace; // first - orig ssaid, second - dest ssaid
     239typedef AsmRegAllocator::SSAReplacesMap SSAReplacesMap;
     240
    214241#if ASMREGALLOC_DEBUGDUMP
    215242#define ARDOut std::cout
  • CLRadeonExtender/trunk/amdasm/AsmRegAllocSSAData.cpp

    r3994 r3995  
    3535using namespace CLRX;
    3636
    37 
    38 class CLRX_INTERNAL ResSecondPointsToCache: public CBlockBitPool
    39 {
    40 public:
    41     explicit ResSecondPointsToCache(size_t n) : CBlockBitPool(n<<1, false)
    42     { }
    43    
    44     void increase(BlockIndex ip)
    45     {
    46         const size_t i = ip.index + (ip.pass ? (size()>>2) : 0);
    47         if ((*this)[i<<1])
    48             (*this)[(i<<1)+1] = true;
    49         else
    50             (*this)[i<<1] = true;
    51     }
    52    
    53     cxuint count(BlockIndex ip) const
    54     {
    55         const size_t i = ip.index + (ip.pass ? (size()>>2) : 0);
    56         return cxuint((*this)[i<<1]) + (*this)[(i<<1)+1];
    57     }
    58 };
    59 
    60 typedef AsmRegAllocator::SSAReplace SSAReplace; // first - orig ssaid, second - dest ssaid
    61 typedef AsmRegAllocator::SSAReplacesMap SSAReplacesMap;
    62 
    6337static inline void insertReplace(SSAReplacesMap& rmap, const AsmSingleVReg& vreg,
    6438              size_t origId, size_t destId)
     
    12195}
    12296
    123 typedef std::unordered_map<BlockIndex, std::pair<BlockIndex, size_t> > PrevWaysIndexMap;
    124 
    12597// use res second point cache entry to resolve conflict with SSAIds.
    12698// it emits SSA replaces from these conflicts
     
    169141static void addResSecCacheEntry(const RoutineMap& routineMap,
    170142                const std::vector<CodeBlock>& codeBlocks,
    171                 SimpleCache<BlockIndex, RBWSSAIdMap>& resSecondPointsCache,
    172                 BlockIndex nextBlock)
     143                SimpleCache<size_t, RBWSSAIdMap>& resSecondPointsCache,
     144                size_t nextBlock)
    173145{
    174146    ARDOut << "addResSecCacheEntry: " << nextBlock << "\n";
     
    186158    {
    187159        FlowStackEntry2& entry = flowStack.back();
    188         const CodeBlock& cblock = codeBlocks[entry.blockIndex.index];
     160        const CodeBlock& cblock = codeBlocks[entry.blockIndex];
    189161       
    190162        if (entry.nextIndex == 0)
     
    222194        if (entry.nextIndex < cblock.nexts.size())
    223195        {
    224             flowStack.push_back({ { cblock.nexts[entry.nextIndex].block,
    225                     entry.blockIndex.pass }, 0 });
     196            flowStack.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
    226197            entry.nextIndex++;
    227198        }
     
    316287        const PrevWaysIndexMap& prevWaysIndexMap,
    317288        const CBlockBitPool& waysToCache, ResSecondPointsToCache& cblocksToCache,
    318         SimpleCache<BlockIndex, LastSSAIdMap>& resFirstPointsCache,
    319         SimpleCache<BlockIndex, RBWSSAIdMap>& resSecondPointsCache,
     289        SimpleCache<size_t, LastSSAIdMap>& resFirstPointsCache,
     290        SimpleCache<size_t, RBWSSAIdMap>& resSecondPointsCache,
    320291        SSAReplacesMap& replacesMap)
    321292{
    322     BlockIndex nextBlock = prevFlowStack.back().blockIndex;
     293    size_t nextBlock = prevFlowStack.back().blockIndex;
    323294    auto pfEnd = prevFlowStack.end();
    324295    --pfEnd;
     
    342313               
    343314                // apply missing calls at end of the cached
    344                 const CodeBlock& cblock = codeBlocks[it->second.first.index];
     315                const CodeBlock& cblock = codeBlocks[it->second.first];
    345316               
    346317                const FlowStackEntry2& entry = *(prevFlowStack.begin()+pfStartIndex-1);
     
    355326        const FlowStackEntry2& entry = *pfit;
    356327        ARDOut << "  apply: " << entry.blockIndex << "\n";
    357         const CodeBlock& cblock = codeBlocks[entry.blockIndex.index];
     328        const CodeBlock& cblock = codeBlocks[entry.blockIndex];
    358329        for (const auto& sentry: cblock.ssaInfoMap)
    359330        {
     
    392363    {
    393364        FlowStackEntry2& entry = flowStack.back();
    394         const CodeBlock& cblock = codeBlocks[entry.blockIndex.index];
     365        const CodeBlock& cblock = codeBlocks[entry.blockIndex];
    395366       
    396367        if (entry.nextIndex == 0)
     
    432403        if (entry.nextIndex < cblock.nexts.size())
    433404        {
    434             flowStack.push_back({ { cblock.nexts[entry.nextIndex].block,
    435                         entry.blockIndex.pass }, 0 });
     405            flowStack.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
    436406            entry.nextIndex++;
    437407        }
     
    14961466    PrevWaysIndexMap prevWaysIndexMap;
    14971467    // to track ways last block indices pair: block index, flowStackPos)
    1498     std::pair<BlockIndex, size_t> lastCommonCacheWayPoint{ SIZE_MAX, SIZE_MAX };
     1468    std::pair<size_t, size_t> lastCommonCacheWayPoint{ SIZE_MAX, SIZE_MAX };
    14991469    CBlockBitPool isRoutineGen(codeBlocks.size(), false);
    15001470   
     
    15901560            else
    15911561            {
     1562                size_t pass = entry.blockIndex.pass;
    15921563                cblocksToCache.increase(entry.blockIndex);
    15931564                ARDOut << "cblockToCache: " << entry.blockIndex << "=" <<
     
    15971568                flowStack.pop_back();
    15981569               
    1599                 BlockIndex curWayBIndex = flowStack.back().blockIndex;
     1570                if (pass != 0)
     1571                    continue;
     1572                size_t curWayBIndex = flowStack.back().blockIndex.index;
    16001573                if (lastCommonCacheWayPoint.first != SIZE_MAX)
    16011574                {
     
    17721745           
    17731746            if (!flowStack.empty() && lastCommonCacheWayPoint.first != SIZE_MAX &&
    1774                     lastCommonCacheWayPoint.second >= flowStack.size())
     1747                    lastCommonCacheWayPoint.second >= flowStack.size() &&
     1748                    flowStack.back().blockIndex.pass == 0)
    17751749            {
    17761750                lastCommonCacheWayPoint =
    1777                         { flowStack.back().blockIndex, flowStack.size()-1 };
     1751                        { flowStack.back().blockIndex.index, flowStack.size()-1 };
    17781752                ARDOut << "POPlastCcwP: " << lastCommonCacheWayPoint.first << "\n";
    17791753            }
     
    17901764    flowStack2.push_back({ 0, 0 });
    17911765   
    1792     SimpleCache<BlockIndex, LastSSAIdMap> resFirstPointsCache(wrCount<<1);
    1793     SimpleCache<BlockIndex, RBWSSAIdMap> resSecondPointsCache(rbwCount<<1);
     1766    SimpleCache<size_t, LastSSAIdMap> resFirstPointsCache(wrCount<<1);
     1767    SimpleCache<size_t, RBWSSAIdMap> resSecondPointsCache(rbwCount<<1);
    17941768   
    17951769    while (!flowStack2.empty())
    17961770    {
    17971771        FlowStackEntry2& entry = flowStack2.back();
    1798         CodeBlock& cblock = codeBlocks[entry.blockIndex.index];
     1772        CodeBlock& cblock = codeBlocks[entry.blockIndex];
    17991773       
    18001774        if (entry.nextIndex == 0)
     
    18171791        if (entry.nextIndex < cblock.nexts.size())
    18181792        {
    1819             flowStack2.push_back({
    1820                 { cblock.nexts[entry.nextIndex].block, entry.blockIndex.pass }, 0 });
     1793            flowStack2.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
    18211794            entry.nextIndex++;
    18221795        }
Note: See TracChangeset for help on using the changeset viewer.