Changeset 3936 in CLRX


Ignore:
Timestamp:
Mar 25, 2018, 6:38:12 PM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Next preppings to recursion support. Comment internal routines.

File:
1 edited

Legend:

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

    r3935 r3936  
    678678}
    679679
     680/* caching concepts:
     681 * resfirstPointsCache - cache of the ways that goes to conflict which should be resolved
     682 *               from first code block of the code. The entries holds a stackVarMap state
     683 *               to first point the conflict (first visited already code block)
     684 * resSecondPointsCache - cache of the tree traversing, starting at the first conflict
     685 *               point (first visited code block). Entries holds a
     686 *               regvars SSAId read before write (that should resolved)
     687 */
     688
    680689static void handleSSAEntryWhileResolving(SSAReplacesMap* replacesMap,
    681690            const LastSSAIdMap* stackVarMap,
     
    736745typedef std::unordered_map<size_t, std::pair<size_t, size_t> > PrevWaysIndexMap;
    737746
     747// use res second point cache entry to resolve conflict with SSAIds.
     748// it emits SSA replaces from these conflicts
    738749static void useResSecPointCache(SSAReplacesMap* replacesMap,
    739750        const LastSSAIdMap* stackVarMap,
     
    792803}
    793804
     805// add new res second cache entry with readBeforeWrite for all encountered regvars
    794806static void addResSecCacheEntry(const std::unordered_map<size_t, RoutineData>& routineMap,
    795807                const std::vector<CodeBlock>& codeBlocks,
     
    907919}
    908920
     921// apply calls (changes from these calls) from code blocks to stack var map
    909922static void applyCallToStackVarMap(const CodeBlock& cblock,
    910923        const std::unordered_map<size_t, RoutineData>& routineMap,
     
    934947
    935948
     949// main routine to resilve SSA conflicts in code
     950// it emits SSA replaces from these conflicts
    936951static void resolveSSAConflicts(const std::deque<FlowStackEntry2>& prevFlowStack,
    937952        const std::unordered_map<size_t, RoutineData>& routineMap,
     
    11221137}
    11231138
     1139// join ret SSAId Map - src - last SSAIdMap from called routine
    11241140static void joinRetSSAIdMap(RetSSAIdMap& dest, const LastSSAIdMap& src,
    11251141                size_t routineBlock)
     
    11481164}
    11491165
     1166// simple join last ssaid map
    11501167static void joinLastSSAIdMap(LastSSAIdMap& dest, const LastSSAIdMap& src)
    11511168{
     
    11711188}
    11721189
     1190// join last SSAIdMap of the routine including later routine call
     1191// dest - dest last SSAId map, src - source lastSSAIdMap
     1192// laterRdatas - data of subroutine/routine exeuted after src lastSSAIdMap state
    11731193static void joinLastSSAIdMapInt(LastSSAIdMap& dest, const LastSSAIdMap& src,
    11741194                    const LastSSAIdMap& laterRdataCurSSAIdMap,
     
    12181238
    12191239
     1240// join routine data from child call with data from parent routine
     1241// (just join child call from parent)
    12201242static void joinRoutineData(RoutineData& dest, const RoutineData& src)
    12211243{
     
    12531275}
    12541276
     1277// reduce retSSAIds for calls (for all read before write SSAIds for current code block)
    12551278static void reduceSSAIdsForCalls(FlowStackEntry& entry,
    12561279            const std::vector<CodeBlock>& codeBlocks,
     
    13341357}
    13351358
     1359// reduce retSSAIds (last SSAIds for regvar) while passing by code block
     1360// and emits SSA replaces for these ssaids
    13361361static bool reduceSSAIds(std::unordered_map<AsmSingleVReg, size_t>& curSSAIdMap,
    13371362            RetSSAIdMap& retSSAIdMap, std::unordered_map<size_t, RoutineData>& routineMap,
     
    13821407}
    13831408
     1409// update single current SSAId for routine and optionally lastSSAIdMap if returns
     1410// has been encountered but not regvar
    13841411static void updateRoutineData(RoutineData& rdata, const SSAEntry& ssaEntry,
    13851412                size_t prevSSAId)
     
    14501477}
    14511478
     1479// revert retSSAIdMap while leaving from code block
    14521480static void revertRetSSAIdMap(std::unordered_map<AsmSingleVReg, size_t>& curSSAIdMap,
    14531481            RetSSAIdMap& retSSAIdMap, FlowStackEntry& entry, RoutineData* rdata)
     
    14961524}
    14971525
     1526// update current SSAId in curSSAIdMap for routine while leaving from code block
    14981527static void updateRoutineCurSSAIdMap(RoutineData* rdata, const SSAEntry& ssaEntry,
    14991528            const FlowStackEntry& entry, size_t curSSAId, size_t nextSSAId)
     
    15421571}
    15431572
     1573static inline const RoutineData* findRoutine(
     1574        const std::unordered_map<size_t, RoutineData>& routineMap,
     1575        const std::unordered_map<size_t, RoutineData>* routineMapRecur, size_t block)
     1576{
     1577    if (routineMapRecur != nullptr)
     1578    {
     1579        auto rit = routineMapRecur->find(block);
     1580        if (rit != routineMapRecur->end())
     1581            return &rit->second;
     1582    }
     1583    auto rit = routineMap.find(block);
     1584    return rit!=routineMap.end() ? &rit->second : nullptr;
     1585}
     1586
    15441587
    15451588static void createRoutineData(const std::vector<CodeBlock>& codeBlocks,
     
    15481591        const ResSecondPointsToCache& subroutToCache,
    15491592        SimpleCache<size_t, RoutineData>& subroutinesCache,
    1550         const std::unordered_map<size_t, RoutineData>& routineMap, RoutineData& rdata,
    1551         size_t routineBlock, bool noMainLoop = false,
     1593        const std::unordered_map<size_t, RoutineData>& routineMap,
     1594        const std::unordered_map<size_t, RoutineData>* routineMapRecur,
     1595        RoutineData& rdata, size_t routineBlock, bool noMainLoop = false,
    15521596        const std::vector<bool>& prevFlowStackBlocks = {})
    15531597{
     
    15951639            flowStackBlocks[entry.blockIndex] = !oldFB;
    15961640            createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, subroutToCache,
    1597                 subroutinesCache, routineMap, subrData, entry.blockIndex, true,
    1598                 flowStackBlocks);
     1641                    subroutinesCache, routineMap, routineMapRecur, subrData,
     1642                    entry.blockIndex, true, flowStackBlocks);
    15991643            RoutineData subrDataCopy;
    16001644            flowStackBlocks[entry.blockIndex] = oldFB;
     
    16881732                {
    16891733                    // try in routine map
    1690                     auto rit = routineMap.find(entry.blockIndex);
     1734                    /*rit = routineMap.find(entry.blockIndex);
    16911735                    if (rit != routineMap.end())
    1692                         cachedRdata = &rit->second;
     1736                        cachedRdata = &rit->second;*/
     1737                    cachedRdata = findRoutine(routineMap, routineMapRecur,
     1738                                entry.blockIndex);
    16931739                }
    16941740                if (!isLoop && visited[entry.blockIndex] && cachedRdata == nullptr &&
     
    17791825        for (; entry.nextIndex < cblock.nexts.size() &&
    17801826                    cblock.nexts[entry.nextIndex].isCall; entry.nextIndex++)
    1781             joinRoutineData(rdata, routineMap.find(
    1782                             cblock.nexts[entry.nextIndex].block)->second);
     1827            //joinRoutineData(rdata, routineMap.find(
     1828            //                cblock.nexts[entry.nextIndex].block)->second);
     1829            joinRoutineData(rdata, *findRoutine(routineMap, routineMapRecur,
     1830                            cblock.nexts[entry.nextIndex].block));
    17831831       
    17841832        if (entry.nextIndex < cblock.nexts.size())
     
    18011849                    {
    18021850                        //std::cout << "joincall:"<< next.block << std::endl;
    1803                         auto it = routineMap.find(next.block); // must find
     1851                        const RoutineData* callRdata = findRoutine(routineMap,
     1852                                routineMapRecur, next.block); // must find
    18041853                        initializePrevRetSSAIds(cblock, curSSAIdMap, retSSAIdMap,
    1805                                     it->second, entry);
    1806                         joinRetSSAIdMap(retSSAIdMap, it->second.lastSSAIdMap, next.block);
     1854                                    *callRdata, entry);
     1855                        joinRetSSAIdMap(retSSAIdMap, callRdata->lastSSAIdMap, next.block);
    18071856                    }
    18081857            }
     
    20622111            if (!isRoutineGen[routineBlock])
    20632112            {
    2064                 createRoutineData(codeBlocks, curSSAIdMap, loopBlocks,
    2065                             cblocksToCache, subroutinesCache, routineMap, prevRdata,
    2066                             routineBlock);
     2113                createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, cblocksToCache,
     2114                        subroutinesCache, routineMap, nullptr, prevRdata, routineBlock);
    20672115                //prevRdata.compare(myRoutineData);
    20682116                isRoutineGen[routineBlock] = true;
     
    21552203                            ":" << ssaEntry.first.index << ": " <<
    21562204                            nextSSAId << ", " << curSSAId << std::endl;
    2157                
    2158                 /*if (rdata!=nullptr)
    2159                     updateRoutineCurSSAIdMap(rdata, ssaEntry, entry, curSSAId, nextSSAId);
    2160                 */
    21612205            }
    21622206           
Note: See TracChangeset for help on using the changeset viewer.