Changeset 4576 for icGREP/icgrep-devel


Ignore:
Timestamp:
May 24, 2015, 8:42:12 AM (4 years ago)
Author:
cameron
Message:

Decouple phi processing for while carries vs. next nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4572 r4576  
    528528
    529529        SmallVector<const Next*, 4> nextNodes;
     530        SmallVector<PHINode *, 4> nextPhis;
    530531        for (const PabloAST * node : whileStatement->getBody()) {
    531532            if (isa<Next>(node)) {
     
    542543
    543544        compileBlock(whileStatement->getBody());
    544 
    545545        // Reset the carry queue index. Note: this ought to be changed in the future. Currently this assumes
    546546        // that compiling the while body twice will generate the equivalent IR. This is not necessarily true
     
    554554        // may not be same one that we entered the function with.
    555555        IRBuilder<> bEntry(mBasicBlock);
     556#ifdef WHILE_MULTI_CARRY
     557        Value * secondCarryFramePtr = bEntry.CreateGEP(mCarryFramePtr, bEntry.getInt64(WHILEBODYCARRYTOTALSIZE));
     558        mCarryFramePtr = secondCarryFramePtr;
     559#endif       
     560
    556561        bEntry.CreateBr(whileCondBlock);
    557562
     
    559564        IRBuilder<> bCond(whileCondBlock);
    560565        // generate phi nodes for any carry propogating instruction
    561         std::vector<PHINode*> phiNodes(carryDataSize + nextNodes.size());
     566        std::vector<PHINode*> phiNodes(carryDataSize);
    562567        unsigned index = 0;
    563568        for (index = 0; index < carryDataSize; ++index) {
     
    574579            phi->addIncoming(f->second, mBasicBlock);
    575580            mMarkerMap[n->getInitial()] = phi;
    576             phiNodes[index++] = phi;
    577         }
    578 
     581            nextPhis.push_back(phi);
     582        }
     583#ifdef WHILE_MULTI_CARRY
     584        //  CarryFramePtr
     585        PHINode * carryFramePtrPhi = bCond.CreatePHI(mBitBlockType, 2, "CarryFramePtr");
     586        carryFramePtrPhi->addIncoming(mCarryFramePtr, mBasicBlock);
     587        mCarryFramePtr = carryFramePtrPhi;
     588#endif       
    579589        mBasicBlock = whileCondBlock;
    580590        bCond.CreateCondBr(genBitBlockAny(compileExpression(whileStatement->getCondition())), whileEndBlock, whileBodyBlock);
     
    584594        mBasicBlock = whileBodyBlock;
    585595        compileBlock(whileStatement->getBody());
     596       
    586597        // update phi nodes for any carry propogating instruction
    587598        IRBuilder<> bWhileBody(mBasicBlock);
     
    594605       
    595606        // and for any Next nodes in the loop body
    596         for (const Next * n : nextNodes) {
     607        for (int i = 0; i < nextNodes.size(); i++) {
     608            const Next * n = nextNodes[i];
    597609            auto f = mMarkerMap.find(n->getInitial());
    598610            assert (f != mMarkerMap.end());
    599             PHINode * phi = phiNodes[index++];
     611            PHINode * phi = nextPhis[i];
    600612            phi->addIncoming(f->second, mBasicBlock);
    601613            mMarkerMap[n->getInitial()] = phi;
    602614        }
    603 
     615#ifdef WHILE_MULTI_CARRY
     616        Value * nextCarryFramePtr = bWhileBody.CreateGEP(mCarryFramePtr, bWhileBody.getInt64(WHILEBODYCARRYTOTALSIZE));
     617        carryFramePtrPhi->addIncoming(nextCarryFramePtr, mBasicBlock);
     618#endif       
    604619        bWhileBody.CreateBr(whileCondBlock);
    605620
Note: See TracChangeset for help on using the changeset viewer.