Changeset 3956 in CLRX


Ignore:
Timestamp:
Mar 31, 2018, 9:05:23 PM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Prepping to recursion support (passing by second pass in recursion traversing and skipping in next pass).

File:
1 edited

Legend:

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

    r3955 r3956  
    934934        if (entry.nextIndex < cblock.nexts.size())
    935935        {
    936             flowStack.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
     936            flowStack.push_back({ { cblock.nexts[entry.nextIndex].block,
     937                    entry.blockIndex.pass }, 0 });
    937938            entry.nextIndex++;
    938939        }
     
    11431144        if (entry.nextIndex < cblock.nexts.size())
    11441145        {
    1145             flowStack.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
     1146            flowStack.push_back({ { cblock.nexts[entry.nextIndex].block,
     1147                        entry.blockIndex.pass }, 0 });
    11461148            entry.nextIndex++;
    11471149        }
     
    14311433}
    14321434
     1435// TODO: correct reduction for recursion support
    14331436// reduce retSSAIds (last SSAIds for regvar) while passing by code block
    14341437// and emits SSA replaces for these ssaids
     
    18871890        if (entry.nextIndex < cblock.nexts.size())
    18881891        {
    1889             const BlockIndex nextBlock = cblock.nexts[entry.nextIndex].block;
     1892            const BlockIndex nextBlock = { cblock.nexts[entry.nextIndex].block,
     1893                        entry.blockIndex.pass };
    18901894            flowStack.push_back({ nextBlock, 0 });
    18911895            // negate - if true (already in flowstack, then popping keep this state)
     
    20922096                for (auto& ssaEntry: cblock.ssaInfoMap)
    20932097                {
     2098                    // TODO: correct pass by second pass in recursion
    20942099                    SSAInfo& sinfo = ssaEntry.second;
    20952100                    if (ssaEntry.first.regVar==nullptr)
     
    21792184        {
    21802185            bool isCall = false;
    2181             const size_t nextBlock = cblock.nexts[entry.nextIndex].block;
     2186            BlockIndex nextBlock = cblock.nexts[entry.nextIndex].block;
     2187            nextBlock.pass = entry.blockIndex.pass;
    21822188            if (cblock.nexts[entry.nextIndex].isCall)
    21832189            {
    2184                 std::cout << " call: " << entry.blockIndex << std::endl;
     2190                bool nextRecursion = false;
    21852191                if (!callBlocks.insert(nextBlock).second)
    21862192                {
    21872193                    // if already called (then it is recursion)
    2188                     recurseBlocks.insert(nextBlock);
    2189                     std::cout << "   -- recursion: " << nextBlock << std::endl;
     2194                    nextRecursion = recurseBlocks.insert(nextBlock.index).second;
     2195                    if (nextRecursion)
     2196                    {
     2197                        std::cout << "   -- recursion: " << nextBlock << std::endl;
     2198                        nextBlock.pass = 1;
     2199                    }
     2200                    else
     2201                    {
     2202                        entry.nextIndex++;
     2203                        std::cout << " NO call (rec): " << entry.blockIndex << std::endl;
     2204                        continue;
     2205                    }
    21902206                }
     2207                else if (entry.blockIndex.pass==1 &&
     2208                    recurseBlocks.find(nextBlock.index) != recurseBlocks.end())
     2209                {
     2210                    entry.nextIndex++;
     2211                    std::cout << " NO call (rec)2: " << entry.blockIndex << std::endl;
     2212                    continue;
     2213                }
     2214                std::cout << " call: " << entry.blockIndex << std::endl;
    21912215               
    21922216                callStack.push_back({ entry.blockIndex, entry.nextIndex, nextBlock });
     
    23112335        if (entry.nextIndex < cblock.nexts.size())
    23122336        {
    2313             flowStack2.push_back({ cblock.nexts[entry.nextIndex].block, 0 });
     2337            flowStack2.push_back({
     2338                { cblock.nexts[entry.nextIndex].block, entry.blockIndex.pass }, 0 });
    23142339            entry.nextIndex++;
    23152340        }
Note: See TracChangeset for help on using the changeset viewer.