Ignore:
Timestamp:
Feb 7, 2017, 3:23:42 PM (3 years ago)
Author:
nmedfort
Message:

Continued work on eliminating BlockNo?

File:
1 edited

Legend:

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

    r5292 r5307  
    1616#include <pablo/pe_matchstar.h>
    1717#include <pablo/pe_var.h>
    18 
     18#include <llvm/Support/raw_ostream.h>
    1919using namespace llvm;
    2020
     
    5858
    5959    mKernel->addScalar(analyse(kernel->getEntryBlock()), "carries");
     60
     61    if (mHasLoop) {
     62        mKernel->addScalar(iBuilder->getInt32Ty(), "loopSelector");
     63    }
    6064}
    6165
     
    7680    assert (mCarryFrame.empty());
    7781    assert (mCarrySummary.empty());
     82
     83    if (mHasLoop) {
     84        mLoopSelector = mKernel->getScalarField("loopSelector");
     85    }
     86}
     87
     88/** ------------------------------------------------------------------------------------------------------------- *
     89 * @brief finalizeCodeGen
     90 ** ------------------------------------------------------------------------------------------------------------- */
     91void CarryManager::finalizeCodeGen() {
     92    if (mHasLoop) {
     93        mKernel->setScalarField("loopSelector", iBuilder->CreateXor(mLoopSelector, iBuilder->getInt32(1)));
     94    }
    7895}
    7996
     
    83100void CarryManager::enterLoopScope(const PabloBlock * const scope) {
    84101    assert (scope);
    85     if (mLoopDepth++ == 0) {
    86         Value * const blockNo = mKernel->getBlockNo();
    87         mLoopSelector = iBuilder->CreateAnd(blockNo, ConstantInt::get(blockNo->getType(), 1));
    88     }
     102    ++mLoopDepth;
    89103    enterScope(scope);
    90104}
     
    178192void CarryManager::leaveLoopScope(BasicBlock * const entryBlock, BasicBlock * const exitBlock) {
    179193    assert (mLoopDepth > 0);
    180     if (--mLoopDepth == 0) {
    181         mLoopSelector = nullptr;
    182     }
     194    --mLoopDepth;
    183195    leaveScope();
    184196}
     
    418430    mCarryPackPtr = carryInPtr;
    419431    if (mLoopDepth > 0) {
    420         carryInPtr = iBuilder->CreateGEP(carryInPtr, {iBuilder->getInt32(0), mLoopSelector});
     432        carryInPtr = iBuilder->CreateGEP(carryInPtr, {iBuilder->getInt32(0), mLoopSelector});       
    421433    }
    422434    assert (carryInPtr->getType()->getPointerElementType() == mCarryPackType);
     
    558570            state.push_back(analyse(cast<If>(stmt)->getBody(), ifDepth + 1, loopDepth));
    559571        } else if (LLVM_UNLIKELY(isa<While>(stmt))) {
     572            mHasLoop = true;
    560573            state.push_back(analyse(cast<While>(stmt)->getBody(), ifDepth, loopDepth + 1));
    561574        }
     
    604617: iBuilder(idb)
    605618, mKernel(nullptr)
     619, mSelf(nullptr)
    606620, mBitBlockType(idb->getBitBlockType())
    607621, mBitBlockWidth(idb->getBitBlockWidth())
     622, mCurrentFrame(nullptr)
    608623, mCurrentFrameIndex(0)
    609624, mCurrentScope(nullptr)
     
    612627, mCarryPackPtr(nullptr)
    613628, mIfDepth(0)
    614 , mLoopDepth(0) {
    615 
    616 }
    617 
    618 
    619 }
    620 
     629, mHasLoop(false)
     630, mLoopDepth(0)
     631, mLoopSelector(nullptr) {
     632
     633}
     634
     635}
     636
Note: See TracChangeset for help on using the changeset viewer.