Changeset 3853 in CLRX


Ignore:
Timestamp:
Feb 26, 2018, 8:46:01 PM (14 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Prepping to real res second caching algorithm.

File:
1 edited

Legend:

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

    r3852 r3853  
    619619
    620620
    621 struct CallStackEntry
     621struct CLRX_INTERNAL CallStackEntry
    622622{
    623623    size_t callBlock; // index
     
    626626};
    627627
     628struct CLRX_INTERNAL ResSecCacheConNode
     629{
     630    size_t next; // block index
     631    // already read in path to next Cache construction node
     632    std::vector<AsmSingleVReg> alreadyRead;
     633};
     634
     635// hold all readBeforeWrite SSAIds for whole subtree for cache block point
     636// does not hold readBeforeWrite SSAIds for next subtrees
     637struct CLRX_INTERNAL ResSecCacheConEntry
     638{
     639    LastSSAIdMap rbwSSAIdMap;
     640    std::vector<ResSecCacheConNode> nodes;
     641};
     642
    628643typedef AsmRegAllocator::SSAReplace SSAReplace; // first - orig ssaid, second - dest ssaid
    629644typedef AsmRegAllocator::SSAReplacesMap SSAReplacesMap;
     
    638653static void handleSSAEntryWhileResolving(SSAReplacesMap& replacesMap,
    639654            const LastSSAIdMap& stackVarMap,
    640             std::unordered_map<AsmSingleVReg, size_t>& toResolveMap,
     655            std::unordered_map<AsmSingleVReg, size_t>& alreadyReadMap,
    641656            FlowStackEntry2& entry, const SSAEntry& sentry,
    642657            RBWSSAIdMap* cacheSecPoints)
    643658{
    644659    const SSAInfo& sinfo = sentry.second;
    645     auto res = toResolveMap.insert({ sentry.first, entry.blockIndex });
     660    auto res = alreadyReadMap.insert({ sentry.first, entry.blockIndex });
    646661   
    647662    if (res.second && sinfo.readBeforeWrite)
     
    806821    std::vector<bool> visited(codeBlocks.size(), false);
    807822   
     823    // holds second point in resolving construction entries
     824    // key - first block index, value - cache con entry
     825    std::unordered_map<size_t, ResSecCacheConEntry> resSecCacheConstrBlocks;
     826    // already read in current path
    808827    // key - vreg, value - source block where vreg of conflict found
    809     std::unordered_map<AsmSingleVReg, size_t> toResolveMap;
     828    std::unordered_map<AsmSingleVReg, size_t> alreadyReadMap;
    810829   
    811830    while (!flowStack.empty())
     
    823842               
    824843                for (auto& sentry: cblock.ssaInfoMap)
    825                     handleSSAEntryWhileResolving(replacesMap, stackVarMap, toResolveMap,
     844                    handleSSAEntryWhileResolving(replacesMap, stackVarMap, alreadyReadMap,
    826845                                    entry, sentry, toCache ? &cacheSecPoints : nullptr);
    827846            }
     
    860879                    const RoutineData& rdata = routineMap.find(next.block)->second;
    861880                    for (const auto& v: rdata.rbwSSAIdMap)
    862                         toResolveMap.insert({v.first, entry.blockIndex });
     881                        alreadyReadMap.insert({v.first, entry.blockIndex });
    863882                    for (const auto& v: rdata.lastSSAIdMap)
    864                         toResolveMap.insert({v.first, entry.blockIndex });
     883                        alreadyReadMap.insert({v.first, entry.blockIndex });
    865884                }
    866885           
     
    878897                    for (const auto& v: rdata.rbwSSAIdMap)
    879898                    {
    880                         auto it = toResolveMap.find(v.first);
    881                         if (it != toResolveMap.end() && it->second == entry.blockIndex)
    882                             toResolveMap.erase(it);
     899                        auto it = alreadyReadMap.find(v.first);
     900                        if (it != alreadyReadMap.end() && it->second == entry.blockIndex)
     901                            alreadyReadMap.erase(it);
    883902                    }
    884903                    for (const auto& v: rdata.lastSSAIdMap)
    885904                    {
    886                         auto it = toResolveMap.find(v.first);
    887                         if (it != toResolveMap.end() && it->second == entry.blockIndex)
    888                             toResolveMap.erase(it);
     905                        auto it = alreadyReadMap.find(v.first);
     906                        if (it != alreadyReadMap.end() && it->second == entry.blockIndex)
     907                            alreadyReadMap.erase(it);
    889908                    }
    890909                }
     
    892911            for (const auto& sentry: cblock.ssaInfoMap)
    893912            {
    894                 auto it = toResolveMap.find(sentry.first);
    895                 if (it != toResolveMap.end() && it->second == entry.blockIndex)
     913                auto it = alreadyReadMap.find(sentry.first);
     914                if (it != alreadyReadMap.end() && it->second == entry.blockIndex)
    896915                    // remove old to resolve in leaved way to allow collecting next ssaId
    897916                    // before write (can be different due to earlier visit)
    898                     toResolveMap.erase(it);
     917                    alreadyReadMap.erase(it);
    899918            }
    900919            std::cout << "  popresolv" << std::endl;
Note: See TracChangeset for help on using the changeset viewer.