Changeset 3936 in CLRX
- Timestamp:
- Mar 25, 2018, 6:38:12 PM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CLRadeonExtender/trunk/amdasm/AsmRegAlloc.cpp
r3935 r3936 678 678 } 679 679 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 680 689 static void handleSSAEntryWhileResolving(SSAReplacesMap* replacesMap, 681 690 const LastSSAIdMap* stackVarMap, … … 736 745 typedef std::unordered_map<size_t, std::pair<size_t, size_t> > PrevWaysIndexMap; 737 746 747 // use res second point cache entry to resolve conflict with SSAIds. 748 // it emits SSA replaces from these conflicts 738 749 static void useResSecPointCache(SSAReplacesMap* replacesMap, 739 750 const LastSSAIdMap* stackVarMap, … … 792 803 } 793 804 805 // add new res second cache entry with readBeforeWrite for all encountered regvars 794 806 static void addResSecCacheEntry(const std::unordered_map<size_t, RoutineData>& routineMap, 795 807 const std::vector<CodeBlock>& codeBlocks, … … 907 919 } 908 920 921 // apply calls (changes from these calls) from code blocks to stack var map 909 922 static void applyCallToStackVarMap(const CodeBlock& cblock, 910 923 const std::unordered_map<size_t, RoutineData>& routineMap, … … 934 947 935 948 949 // main routine to resilve SSA conflicts in code 950 // it emits SSA replaces from these conflicts 936 951 static void resolveSSAConflicts(const std::deque<FlowStackEntry2>& prevFlowStack, 937 952 const std::unordered_map<size_t, RoutineData>& routineMap, … … 1122 1137 } 1123 1138 1139 // join ret SSAId Map - src - last SSAIdMap from called routine 1124 1140 static void joinRetSSAIdMap(RetSSAIdMap& dest, const LastSSAIdMap& src, 1125 1141 size_t routineBlock) … … 1148 1164 } 1149 1165 1166 // simple join last ssaid map 1150 1167 static void joinLastSSAIdMap(LastSSAIdMap& dest, const LastSSAIdMap& src) 1151 1168 { … … 1171 1188 } 1172 1189 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 1173 1193 static void joinLastSSAIdMapInt(LastSSAIdMap& dest, const LastSSAIdMap& src, 1174 1194 const LastSSAIdMap& laterRdataCurSSAIdMap, … … 1218 1238 1219 1239 1240 // join routine data from child call with data from parent routine 1241 // (just join child call from parent) 1220 1242 static void joinRoutineData(RoutineData& dest, const RoutineData& src) 1221 1243 { … … 1253 1275 } 1254 1276 1277 // reduce retSSAIds for calls (for all read before write SSAIds for current code block) 1255 1278 static void reduceSSAIdsForCalls(FlowStackEntry& entry, 1256 1279 const std::vector<CodeBlock>& codeBlocks, … … 1334 1357 } 1335 1358 1359 // reduce retSSAIds (last SSAIds for regvar) while passing by code block 1360 // and emits SSA replaces for these ssaids 1336 1361 static bool reduceSSAIds(std::unordered_map<AsmSingleVReg, size_t>& curSSAIdMap, 1337 1362 RetSSAIdMap& retSSAIdMap, std::unordered_map<size_t, RoutineData>& routineMap, … … 1382 1407 } 1383 1408 1409 // update single current SSAId for routine and optionally lastSSAIdMap if returns 1410 // has been encountered but not regvar 1384 1411 static void updateRoutineData(RoutineData& rdata, const SSAEntry& ssaEntry, 1385 1412 size_t prevSSAId) … … 1450 1477 } 1451 1478 1479 // revert retSSAIdMap while leaving from code block 1452 1480 static void revertRetSSAIdMap(std::unordered_map<AsmSingleVReg, size_t>& curSSAIdMap, 1453 1481 RetSSAIdMap& retSSAIdMap, FlowStackEntry& entry, RoutineData* rdata) … … 1496 1524 } 1497 1525 1526 // update current SSAId in curSSAIdMap for routine while leaving from code block 1498 1527 static void updateRoutineCurSSAIdMap(RoutineData* rdata, const SSAEntry& ssaEntry, 1499 1528 const FlowStackEntry& entry, size_t curSSAId, size_t nextSSAId) … … 1542 1571 } 1543 1572 1573 static 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 1544 1587 1545 1588 static void createRoutineData(const std::vector<CodeBlock>& codeBlocks, … … 1548 1591 const ResSecondPointsToCache& subroutToCache, 1549 1592 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, 1552 1596 const std::vector<bool>& prevFlowStackBlocks = {}) 1553 1597 { … … 1595 1639 flowStackBlocks[entry.blockIndex] = !oldFB; 1596 1640 createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, subroutToCache, 1597 subroutinesCache, routineMap, subrData, entry.blockIndex, true,1598 flowStackBlocks);1641 subroutinesCache, routineMap, routineMapRecur, subrData, 1642 entry.blockIndex, true, flowStackBlocks); 1599 1643 RoutineData subrDataCopy; 1600 1644 flowStackBlocks[entry.blockIndex] = oldFB; … … 1688 1732 { 1689 1733 // try in routine map 1690 autorit = routineMap.find(entry.blockIndex);1734 /*rit = routineMap.find(entry.blockIndex); 1691 1735 if (rit != routineMap.end()) 1692 cachedRdata = &rit->second; 1736 cachedRdata = &rit->second;*/ 1737 cachedRdata = findRoutine(routineMap, routineMapRecur, 1738 entry.blockIndex); 1693 1739 } 1694 1740 if (!isLoop && visited[entry.blockIndex] && cachedRdata == nullptr && … … 1779 1825 for (; entry.nextIndex < cblock.nexts.size() && 1780 1826 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)); 1783 1831 1784 1832 if (entry.nextIndex < cblock.nexts.size()) … … 1801 1849 { 1802 1850 //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 1804 1853 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); 1807 1856 } 1808 1857 } … … 2062 2111 if (!isRoutineGen[routineBlock]) 2063 2112 { 2064 createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, 2065 cblocksToCache, subroutinesCache, routineMap, prevRdata, 2066 routineBlock); 2113 createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, cblocksToCache, 2114 subroutinesCache, routineMap, nullptr, prevRdata, routineBlock); 2067 2115 //prevRdata.compare(myRoutineData); 2068 2116 isRoutineGen[routineBlock] = true; … … 2155 2203 ":" << ssaEntry.first.index << ": " << 2156 2204 nextSSAId << ", " << curSSAId << std::endl; 2157 2158 /*if (rdata!=nullptr)2159 updateRoutineCurSSAIdMap(rdata, ssaEntry, entry, curSSAId, nextSSAId);2160 */2161 2205 } 2162 2206
Note: See TracChangeset
for help on using the changeset viewer.