Changeset 4109 in CLRX


Ignore:
Timestamp:
May 8, 2018, 9:06:14 AM (3 weeks ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Add callLiveTime to liveness of svreg used between callLiveTime only if this svreg is not present in called routine.

File:
1 edited

Legend:

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

    r4107 r4109  
    698698}
    699699
    700 static Liveness& getLiveness(const AsmSingleVReg& svreg, size_t ssaIdIdx,
    701         const AsmRegAllocator::SSAInfo& ssaInfo, std::vector<Liveness>* livenesses,
    702         const VarIndexMap* vregIndexMaps, size_t regTypesNum, const cxuint* regRanges)
     700static void getLivenessIndex(const AsmSingleVReg& svreg, size_t ssaIdIdx,
     701        const AsmRegAllocator::SSAInfo& ssaInfo,
     702        const VarIndexMap* vregIndexMaps, size_t regTypesNum, const cxuint* regRanges,
     703        cxuint& regType, size_t& lvIndex)
    703704{
    704705    size_t ssaId;
     
    714715        ssaId = ssaInfo.ssaIdLast;
    715716   
    716     cxuint regType = getRegType(regTypesNum, regRanges, svreg); // regtype
     717    regType = getRegType(regTypesNum, regRanges, svreg); // regtype
    717718    const VarIndexMap& vregIndexMap = vregIndexMaps[regType];
    718719    const std::vector<size_t>& ssaIdIndices = vregIndexMap.find(svreg)->second;
    719     ARDOut << "lvn[" << regType << "][" << ssaIdIndices[ssaId] << "]. ssaIdIdx: " <<
     720    /*ARDOut << "lvn[" << regType << "][" << ssaIdIndices[ssaId] << "]. ssaIdIdx: " <<
    720721            ssaIdIdx << ". ssaId: " << ssaId << ". svreg: " << svreg.regVar << ":" <<
    721             svreg.index << "\n";
    722     return livenesses[regType][ssaIdIndices[ssaId]];
    723 }
    724 
    725 static Liveness& getLiveness2(const AsmSingleVReg& svreg,
    726         size_t ssaId, std::vector<Liveness>* livenesses,
     722            svreg.index << "\n";*/
     723    //return livenesses[regType][ssaIdIndices[ssaId]];
     724    lvIndex = ssaIdIndices[ssaId];
     725}
     726
     727static inline Liveness& getLiveness(const AsmSingleVReg& svreg, size_t ssaIdIdx,
     728        const AsmRegAllocator::SSAInfo& ssaInfo, std::vector<Liveness>* livenesses,
    727729        const VarIndexMap* vregIndexMaps, size_t regTypesNum, const cxuint* regRanges)
    728730{
    729     cxuint regType = getRegType(regTypesNum, regRanges, svreg); // regtype
     731    cxuint regType;
     732    size_t lvIndex;
     733    getLivenessIndex(svreg, ssaIdIdx, ssaInfo, vregIndexMaps, regTypesNum, regRanges,
     734            regType, lvIndex);
     735    return livenesses[regType][lvIndex];
     736}
     737
     738static void getLiveness2Index(const AsmSingleVReg& svreg, size_t ssaId,
     739        const VarIndexMap* vregIndexMaps, size_t regTypesNum, const cxuint* regRanges,
     740        cxuint& regType, size_t& lvIndex)
     741{
     742    regType = getRegType(regTypesNum, regRanges, svreg); // regtype
    730743    const VarIndexMap& vregIndexMap = vregIndexMaps[regType];
    731744    const std::vector<size_t>& ssaIdIndices = vregIndexMap.find(svreg)->second;
    732     ARDOut << "lvn[" << regType << "][" << ssaIdIndices[ssaId] << "]. ssaId: " <<
    733             ssaId << ". svreg: " << svreg.regVar << ":" << svreg.index << "\n";
    734     return livenesses[regType][ssaIdIndices[ssaId]];
    735 }
    736 
     745    /*ARDOut << "lvn[" << regType << "][" << ssaIdIndices[ssaId] << "]. ssaId: " <<
     746            ssaId << ". svreg: " << svreg.regVar << ":" << svreg.index << "\n";*/
     747    lvIndex = ssaIdIndices[ssaId];
     748}
    737749
    738750static void applyToLiveCallTime(size_t block, Liveness& lv,
    739             const std::vector<CodeBlock>& codeBlocks,
     751            cxuint lvRType /* lv register type */, size_t lvIndex,
     752            const std::vector<CodeBlock>& codeBlocks, const RoutineLvMap& routineMap,
    740753            const std::unordered_map<size_t, size_t>& callLiveTimesMap)
    741754{
     
    748761            if (next.isCall)
    749762            {
    750                 lv.insert(callLiveTime, callLiveTime+1);
     763                const RoutineDataLv& rdata = routineMap.find(next.block)->second;
     764                if (rdata.allSSAs[lvRType].find(lvIndex) == rdata.allSSAs[lvRType].end())
     765                    // add only if vreg not present in routine
     766                    lv.insert(callLiveTime, callLiveTime+1);
    751767                callLiveTime--;
    752768            }
     
    755771
    756772static void fillUpInsideRoutine(std::vector<bool>& visited,
    757             const std::vector<CodeBlock>& codeBlocks,
     773            const std::vector<CodeBlock>& codeBlocks, const RoutineLvMap& routineMap,
    758774            const std::unordered_map<size_t, size_t>& callLiveTimesMap,
    759             size_t startBlock, const AsmSingleVReg& svreg, Liveness& lv)
     775            size_t startBlock, const AsmSingleVReg& svreg, Liveness& lv,
     776            cxuint lvRType /* lv register type */, size_t lvIndex)
    760777{
    761778    std::deque<FlowStackEntry3> flowStack;
     
    787804                lv.insert(cbStart, cblock.end);
    788805               
    789                 applyToLiveCallTime(entry.blockIndex, lv, codeBlocks, callLiveTimesMap);
     806                applyToLiveCallTime(entry.blockIndex, lv, lvRType, lvIndex,
     807                        codeBlocks, routineMap, callLiveTimesMap);
    790808            }
    791809            else
     
    832850    if (skipLastBlock)
    833851        --flitEnd; // before last element
    834     Liveness& lv = getLiveness2(svreg, ssaId, livenesses, vregIndexMaps,
    835                     regTypesNum, regRanges);
     852    cxuint lvRegType;
     853    size_t lvIndex;
     854    getLiveness2Index(svreg, ssaId, vregIndexMaps, regTypesNum, regRanges,
     855                      lvRegType, lvIndex);
     856    Liveness& lv = livenesses[lvRegType][lvIndex];
    836857   
    837858    if (flitEnd != flowStack.begin())
     
    892913            size_t blockStart = entry.blockIndex;
    893914            if (!entry.inSubroutines)
    894                 fillUpInsideRoutine(visited, codeBlocks, callLiveTimesMap,
    895                             blockStart, svreg, lv);
     915                fillUpInsideRoutine(visited, codeBlocks, routineMap, callLiveTimesMap,
     916                            blockStart, svreg, lv, lvRegType, lvIndex);
    896917            else
    897918                // fill up next block in path (do not fill start block)
    898                 fillUpInsideRoutine(visited, codeBlocks, callLiveTimesMap,
    899                         blockStart+1, svreg, lv);
     919                fillUpInsideRoutine(visited, codeBlocks, routineMap, callLiveTimesMap,
     920                        blockStart+1, svreg, lv, lvRegType, lvIndex);
    900921            rjStack.pop();
    901922        }
     
    905926    const CodeBlock& lastBlk = codeBlocks[flit->blockIndex];
    906927   
    907     applyToLiveCallTime(flit->blockIndex, lv, codeBlocks, callLiveTimesMap);
     928    applyToLiveCallTime(flit->blockIndex, lv, lvRegType, lvIndex,
     929                codeBlocks, routineMap, callLiveTimesMap);
    908930   
    909931    auto sinfoIt = lastBlk.ssaInfoMap.find(svreg);
     
    920942    {
    921943        const CodeBlock& cblock = codeBlocks[flit->blockIndex];
    922         applyToLiveCallTime(flit->blockIndex, lv, codeBlocks, callLiveTimesMap);
     944        applyToLiveCallTime(flit->blockIndex, lv, lvRegType, lvIndex, codeBlocks,
     945                        routineMap, callLiveTimesMap);
    923946        lv.insert(cblock.start, cblock.end);
    924947    }
Note: See TracChangeset for help on using the changeset viewer.