Ignore:
Timestamp:
Jul 14, 2015, 6:29:35 PM (4 years ago)
Author:
cameron
Message:

Carry Manager progress

File:
1 edited

Legend:

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

    r4668 r4670  
    385385
    386386void PabloCompiler::compileBlock(PabloBlock & block) {
    387     mCarryManager->ensureCarriesLoadedLocal(block);
    388387    mPabloBlock = & block;
    389388    for (const Statement * statement : block) {
     
    391390    }
    392391    mPabloBlock = block.getParent();
    393     mCarryManager->ensureCarriesStoredLocal(block);
    394392}
    395393
     
    441439   
    442440    Value * if_test_value = compileExpression(ifStatement->getCondition());
    443     if (mCarryManager->blockHasCarries(ifBody)) {
     441   
     442    mCarryManager->enterScope(&ifBody);
     443    if (mCarryManager->blockHasCarries()) {
    444444        // load the summary variable
    445         Value* last_if_pending_data = mCarryManager->getCarrySummaryExpr(ifBody);
     445        Value* last_if_pending_data = mCarryManager->getCarrySummaryExpr();
    446446        mBuilder->CreateCondBr(genBitTest2(if_test_value, last_if_pending_data), ifBodyBlock, ifEndBlock);
    447447
     
    452452    // Entry processing is complete, now handle the body of the if.
    453453    mBuilder->SetInsertPoint(ifBodyBlock);
     454   
    454455   
    455456    ++mIfDepth;
    456457    compileBlock(ifBody);
    457458    --mIfDepth;
    458     if (mCarryManager->blockHasCarries(ifBody)) {
    459         mCarryManager->generateCarryOutSummaryCode(ifBody);
     459    if (mCarryManager->blockHasCarries()) {
     460        mCarryManager->generateCarryOutSummaryCode();
    460461    }
    461462    BasicBlock * ifBodyFinalBlock = mBuilder->GetInsertBlock();
     
    473474    }
    474475    // Create the phi Node for the summary variable, if needed.
    475     if (mCarryManager->summaryNeededInParentBlock(ifBody)) {
    476         mCarryManager->addSummaryPhi(ifBody, ifEntryBlock, ifBodyFinalBlock);
    477     }
     476    if (mCarryManager->summaryNeededInParentBlock()) {
     477        mCarryManager->addSummaryPhi(ifEntryBlock, ifBodyFinalBlock);
     478    }
     479    mCarryManager->leaveScope();
    478480}
    479481
     
    486488    BasicBlock * whileEndBlock = BasicBlock::Create(mMod->getContext(), "while.end", mFunction, 0);
    487489
    488     mCarryManager->ensureCarriesLoadedRecursive(whileBody);
     490    mCarryManager->enterScope(&whileBody);
     491    mCarryManager->ensureCarriesLoadedRecursive();
    489492
    490493    const auto & nextNodes = whileStatement->getVariants();
     
    505508    // (3) Next nodes: (a) values set up before loop, (b) modified values calculated in loop.
    506509
    507     mCarryManager->initializeCarryDataPhisAtWhileEntry(whileBody, whileEntryBlock);
     510    mCarryManager->initializeCarryDataPhisAtWhileEntry(whileEntryBlock);
    508511
    509512    // for any Next nodes in the loop body, initialize to (a) pre-loop value.
     
    525528    BasicBlock * whileBodyFinalBlock = mBuilder->GetInsertBlock();
    526529
    527     mCarryManager->extendCarryDataPhisAtWhileBodyFinalBlock(whileBody, whileBodyFinalBlock);
     530    mCarryManager->extendCarryDataPhisAtWhileBodyFinalBlock(whileBodyFinalBlock);
    528531
    529532    // Terminate the while loop body with a conditional branch back.
     
    543546    --mWhileDepth;
    544547
    545     mCarryManager->ensureCarriesStoredRecursive(whileBody);
     548    mCarryManager->ensureCarriesStoredRecursive();
     549    mCarryManager->leaveScope();
    546550}
    547551
     
    599603        int shift = adv->getAdvanceAmount();
    600604        unsigned advance_index = adv->getLocalAdvanceIndex();
    601         expr = mCarryManager->advanceCarryInCarryOut(mPabloBlock, advance_index, shift, strm_value);
     605        expr = mCarryManager->advanceCarryInCarryOut(advance_index, shift, strm_value);
    602606    }
    603607    else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
     
    699703
    700704Value* PabloCompiler::genAddWithCarry(Value* e1, Value* e2, unsigned localIndex) {
    701     Value * carryq_value = mCarryManager->getCarryOpCarryIn(mPabloBlock, localIndex);
     705    Value * carryq_value = mCarryManager->getCarryOpCarryIn(localIndex);
    702706#ifdef USE_TWO_UADD_OVERFLOW
    703707    //This is the ideal implementation, which uses two uadd.with.overflow
     
    756760#endif //USE_TWO_UADD_OVERFLOW
    757761
    758     mCarryManager->setCarryOpCarryOut(mPabloBlock, localIndex, carry_out);
     762    mCarryManager->setCarryOpCarryOut(localIndex, carry_out);
    759763    return sum;
    760764}
Note: See TracChangeset for help on using the changeset viewer.