Changeset 4063 in CLRX


Ignore:
Timestamp:
May 2, 2018, 11:01:37 PM (3 weeks ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Yet another prepping to better joinRegVarLivenesses.

File:
1 edited

Legend:

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

    r4062 r4063  
    777777}
    778778
    779 static void handleSSAEntryWhileJoining(
    780             const std::unordered_map<AsmSingleVReg, size_t>* stackVarMap,
    781             std::unordered_map<AsmSingleVReg, size_t>& alreadyReadMap,
    782             FlowStackEntry3& entry, const SSAEntry& sentry,
     779static void joinSVregWithVisited(const SVRegMap* stackVarMap, const SSAEntry& sentry,
     780            const std::deque<FlowStackEntry3>& prevFlowStack,
     781            const std::vector<CodeBlock>& codeBlocks, const VarIndexMap* vregIndexMaps,
     782            std::vector<Liveness>* livenesses, size_t regTypesNum, const cxuint* regRanges)
     783{
     784    auto pfEnd = prevFlowStack.end();
     785    --pfEnd;
     786    const SSAInfo& sinfo = sentry.second;
     787   
     788    // join liveness for this variable ssaId>.
     789    // only if in previous block previous SSAID is
     790    // read before all writes
     791    auto it = stackVarMap->find(sentry.first);
     792   
     793    const size_t pfStart = (it != stackVarMap->end() ? it->second : 0);
     794    //if (it == stackVarMap.end())
     795        //continue;
     796    // fill up previous part
     797    Liveness& lv = getLiveness(sentry.first, 0, sinfo,
     798            livenesses, vregIndexMaps, regTypesNum, regRanges);
     799    auto flit = prevFlowStack.begin() + pfStart;
     800    {
     801        // fill up liveness for first code block
     802        const CodeBlock& cblock = codeBlocks[flit->blockIndex];
     803        auto ssaInfoIt = cblock.ssaInfoMap.find(sentry.first);
     804        size_t prevLastPos = (ssaInfoIt != cblock.ssaInfoMap.end()) ?
     805                ssaInfoIt->second.lastPos+1 : cblock.start;
     806        lv.insert(prevLastPos, cblock.end);
     807    }
     808   
     809    for (++flit; flit != pfEnd; ++flit)
     810    {
     811        const CodeBlock& cblock = codeBlocks[flit->blockIndex];
     812        lv.insert(cblock.start, cblock.end);
     813    }
     814}
     815
     816static void handleSSAEntryWhileJoining(const SVRegMap* stackVarMap,
     817            SVRegMap& alreadyReadMap, FlowStackEntry3& entry, const SSAEntry& sentry,
    783818            const std::deque<FlowStackEntry3>& prevFlowStack,
    784819            const std::vector<CodeBlock>& codeBlocks, const VarIndexMap* vregIndexMaps,
     
    801836       
    802837        if (stackVarMap != nullptr)
    803         {
    804             // join liveness for this variable ssaId>.
    805             // only if in previous block previous SSAID is
    806             // read before all writes
    807             auto it = stackVarMap->find(sentry.first);
    808            
    809             const size_t pfStart = (it != stackVarMap->end() ? it->second : 0);
    810             //if (it == stackVarMap.end())
    811                 //continue;
    812             // fill up previous part
    813             Liveness& lv = getLiveness(sentry.first, 0, sinfo,
    814                     livenesses, vregIndexMaps, regTypesNum, regRanges);
    815             auto flit = prevFlowStack.begin() + pfStart;
    816             {
    817                 // fill up liveness for first code block
    818                 const CodeBlock& cblock = codeBlocks[flit->blockIndex];
    819                 auto ssaInfoIt = cblock.ssaInfoMap.find(sentry.first);
    820                 size_t prevLastPos = (ssaInfoIt != cblock.ssaInfoMap.end()) ?
    821                         ssaInfoIt->second.lastPos+1 : cblock.start;
    822                 lv.insert(prevLastPos, cblock.end);
    823             }
    824            
    825             for (++flit; flit != pfEnd; ++flit)
    826             {
    827                 const CodeBlock& cblock = codeBlocks[flit->blockIndex];
    828                 lv.insert(cblock.start, cblock.end);
    829             }
     838            joinSVregWithVisited(stackVarMap, sentry, prevFlowStack,
     839                    codeBlocks, vregIndexMaps, livenesses, regTypesNum, regRanges);
     840    }
     841}
     842
     843static void useJoinSecPointCache(const SVRegMap* stackVarMap,
     844        const SVRegBlockMap& alreadyReadMap,
     845        const SVRegMap* resSecondPoints, size_t nextBlock,
     846        SVRegMap* destCacheSecPoints,
     847        const std::deque<FlowStackEntry3>& prevFlowStack,
     848        const std::vector<CodeBlock>& codeBlocks, const VarIndexMap* vregIndexMaps,
     849        std::vector<Liveness>* livenesses, size_t regTypesNum, const cxuint* regRanges)
     850{
     851    ARDOut << "use joinSecPointCache for " << nextBlock <<
     852            ", alreadyRMapSize: " << alreadyReadMap.size() << "\n";
     853    for (const auto& sentry: *resSecondPoints)
     854    {
     855        const bool alreadyRead = alreadyReadMap.find(sentry.first) != alreadyReadMap.end();
     856        if (destCacheSecPoints != nullptr && !alreadyRead)
     857        {
     858            auto res = destCacheSecPoints->insert(sentry);
     859            if (!res.second)
     860                res.first->second = sentry.second;
     861        }
     862       
     863        if (stackVarMap != nullptr)
     864        {
     865            if (!alreadyRead)
     866                joinSVregWithVisited(stackVarMap, sentry, prevFlowStack,
     867                    codeBlocks, vregIndexMaps, livenesses, regTypesNum, regRanges);
    830868        }
    831869    }
     
    841879    ARDOut << "startJoinLv: " << (pfEnd-1)->blockIndex << "," << nextBlock << "\n";
    842880    // key - varreg, value - last position in previous flowStack
    843     std::unordered_map<AsmSingleVReg, size_t> stackVarMap;
     881    SVRegMap stackVarMap;
    844882   
    845883    for (auto pfit = prevFlowStack.begin(); pfit != pfEnd; ++pfit)
     
    858896    // already read in current path
    859897    // key - vreg, value - source block where vreg of conflict found
    860     std::unordered_map<AsmSingleVReg, size_t> alreadyReadMap;
     898    SVRegMap alreadyReadMap;
    861899   
    862900    while (!flowStack.empty())
     
    954992static void addUsageDeps(const cxbyte* ldeps, cxuint rvusNum,
    955993            const AsmRegVarUsage* rvus, LinearDepMap* ldepsOut,
    956             const VarIndexMap* vregIndexMaps,
    957             const std::unordered_map<AsmSingleVReg, size_t>& ssaIdIdxMap,
     994            const VarIndexMap* vregIndexMaps, const SVRegMap& ssaIdIdxMap,
    958995            size_t regTypesNum, const cxuint* regRanges)
    959996{
     
    11461183                // main routine to handle ssaInfos
    11471184                visited[entry.blockIndex] = true;
    1148                 std::unordered_map<AsmSingleVReg, size_t> ssaIdIdxMap;
     1185                SVRegMap ssaIdIdxMap;
    11491186                AsmRegVarUsage instrRVUs[8];
    11501187                cxuint instrRVUsCount = 0;
Note: See TracChangeset for help on using the changeset viewer.