Changeset 3945 in CLRX


Ignore:
Timestamp:
Mar 28, 2018, 2:51:31 PM (4 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Yet another update 2 (next prepping to recursion support).

File:
1 edited

Legend:

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

    r3942 r3945  
    605605struct CLRX_INTERNAL RoutineData
    606606{
     607    // TODO: check whether rbwSSAIdMap should be updated after retSSAId reduction
     608    // beyond first read of the regvars inside routine
    607609    // rbwSSAIdMap - read before write SSAId's map
    608610    std::unordered_map<AsmSingleVReg, size_t> rbwSSAIdMap;
     
    15851587}
    15861588
     1589struct CLRX_INTERNAL RetRecurState
     1590{
     1591    std::unordered_map<AsmSingleVReg, size_t> curSSAIdMap;
     1592    RetSSAIdMap retSSAIdMap;
     1593    std::deque<FlowStackEntry> flowStack;
     1594    std::vector<bool> flowStackBlocks;
     1595    std::deque<CallStackEntry> callStack;
     1596};
     1597
     1598typedef std::unordered_map<size_t, RetRecurState> RetRecurStateMap;
     1599
     1600typedef std::unordered_map<size_t, std::unordered_map<size_t, RetRecurState> >
     1601            RetRecurStateMapMap;
    15871602
    15881603static void createRoutineData(const std::vector<CodeBlock>& codeBlocks,
     
    15941609        const std::unordered_map<size_t, RoutineData>& routineMap,
    15951610        const std::unordered_map<size_t, RoutineData>* routineMapRecur,
     1611        RetRecurStateMapMap& retRecurStateMapMap,
    15961612        RoutineData& rdata, size_t routineBlock, bool noMainLoop = false,
    1597         const std::vector<bool>& prevFlowStackBlocks = {})
     1613        const std::vector<bool>& prevFlowStackBlocks = {},
     1614        const std::deque<CallStackEntry>& callStack = {})
    15981615{
    15991616    std::cout << "--------- createRoutineData ----------------\n";
     
    16411658            createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, recurBlocks,
    16421659                    subroutToCache, subroutinesCache, routineMap, routineMapRecur,
    1643                     subrData, entry.blockIndex, true, flowStackBlocks);
     1660                    retRecurStateMapMap, subrData, entry.blockIndex,
     1661                    true, flowStackBlocks);
    16441662            RoutineData subrDataCopy;
    16451663            flowStackBlocks[entry.blockIndex] = oldFB;
     
    18631881                        initializePrevRetSSAIds(cblock, curSSAIdMap, retSSAIdMap,
    18641882                                    *callRdata, entry);
    1865                         joinRetSSAIdMap(retSSAIdMap, callRdata->lastSSAIdMap, next.block);
     1883                       
     1884                        if (recurBlocks.find(next.block) == recurBlocks.end())
     1885                            joinRetSSAIdMap(retSSAIdMap, callRdata->lastSSAIdMap,
     1886                                            next.block);
     1887                        else
     1888                        {   // put retRecurState
     1889                            std::cout << "-- store retrecurstate: " <<
     1890                                    next.block << ": " << entry.blockIndex << std::endl;
     1891                            retRecurStateMapMap[next.block].insert({ entry.blockIndex, {
     1892                                    curSSAIdMap, retSSAIdMap,
     1893                                    flowStack, flowStackBlocks, callStack } });
     1894                        }
    18661895                    }
    18671896            }
     
    19231952                subroutToCache.count(entry.blockIndex)!=0 &&
    19241953                recurBlocks.find(entry.blockIndex) == recurBlocks.end())
    1925             { //put to cache
     1954            {   //put to cache
    19261955                std::cout << "-- subrcache for " << entry.blockIndex << std::endl;
    19271956                addSubroutine(loopsit2, true);
     
    19441973            std::unordered_map<size_t, RoutineData>& routineMap,
    19451974            RetSSAIdMap& retSSAIdMap, SSAReplacesMap& ssaReplacesMap,
     1975            RetRecurStateMapMap& retRecurStateMapMap,
    19461976            size_t recurBlock)
    19471977{
     
    19952025                createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, recurseBlocks,
    19962026                        cblocksToCache, subroutinesCache, routineMap, &routineMapSP,
    1997                         prevRdata, routineBlock);
     2027                        retRecurStateMapMap, prevRdata, routineBlock,
     2028                        false, {}, callStack);
    19982029                //prevRdata.compare(myRoutineData);
    19992030                isRoutineGen[routineBlock] = true;
     
    20762107    RoutineData& prevRdata = routineMapSP.find(recurBlock)->second;
    20772108    createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, recurseBlocks, cblocksToCache,
    2078                         subroutinesCache, routineMap, &routineMapSP, prevRdata,
    2079                         recurBlock);
     2109                subroutinesCache, routineMap, &routineMapSP,
     2110                retRecurStateMapMap, prevRdata, recurBlock);
    20802111   
    20812112    // replace routineMap entries by routineMapSP entries
     
    21862217    flowStackBlocks[0] = true;
    21872218   
     2219    RetRecurStateMapMap retRecurStateMapMap;
    21882220    std::unordered_map<size_t, RecurStateEntry> recurStateMap;
    21892221    std::unordered_set<size_t> callBlocks;
     
    22892321                createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, recurseBlocks,
    22902322                        cblocksToCache, subroutinesCache, routineMap, nullptr,
    2291                         prevRdata, routineBlock);
     2323                        retRecurStateMapMap, prevRdata, routineBlock);
    22922324                //prevRdata.compare(myRoutineData);
    22932325                isRoutineGen[routineBlock] = true;
     
    23682400                    passSecondRecurPass(codeBlocks, rsit->second.curSSAIdMap,
    23692401                            cblocksToCache, loopBlocks, recurseBlocks, routineMap,
    2370                             rsit->second.retSSAIdMap, ssaReplacesMap, entry.blockIndex);
     2402                            rsit->second.retSSAIdMap, ssaReplacesMap,
     2403                            retRecurStateMapMap, entry.blockIndex);
    23712404                    recurseBlocks.erase(entry.blockIndex);
     2405                    // join retRecurStates
     2406                    for (const auto& entry: retRecurStateMapMap[entry.blockIndex])
     2407                        std::cout << "join retrecState: " << entry.first << std::endl;
    23722408                }
    23732409            }
Note: See TracChangeset for help on using the changeset viewer.