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

Continued work on eliminating BlockNo?

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r5285 r5307  
    194194    }
    195195
    196     llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
    197         return mPb->getStreamTy(FieldWidth);
    198     }
     196//    llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
     197//        return mPb->getStreamTy(FieldWidth);
     198//    }
    199199   
    200200    llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
  • 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
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r5292 r5307  
    4747
    4848    void initializeCodeGen();
     49
     50    void finalizeCodeGen();
    4951
    5052    /* Entering and leaving loops. */
     
    117119    unsigned                                        mIfDepth;
    118120
     121    bool                                            mHasLoop;
    119122    unsigned                                        mLoopDepth;
    120123    llvm::Value *                                   mLoopSelector;
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5285 r5307  
    242242    While * createWhile(PabloAST * condition, PabloBlock * body);
    243243
    244     llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
    245         return mParent->getStreamTy(FieldWidth);
    246     }
     244//    llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
     245//        return mParent->getStreamTy(FieldWidth);
     246//    }
    247247   
    248248    llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5297 r5307  
    5656    mMarker.emplace(entryBlock->createOnes(), iBuilder->allOnes());
    5757
    58     Value * const blockNo =  mKernel->getBlockNo();
    59 
    6058    for (unsigned i = 0; i < mKernel->getNumOfInputs(); ++i) {
    6159        Var * var = mKernel->getInput(i);
     
    6563            input = mKernel->getScalarFieldPtr(name);
    6664        } else {
    67             input = mKernel->getStreamSetPtr(name, blockNo);
     65            input = mKernel->getInputStream(name, iBuilder->getInt32(0));
    6866        }
    6967        mMarker.emplace(var, input);
     
    7775            output = mKernel->getScalarFieldPtr(name);
    7876        } else {
    79             output = mKernel->getStreamSetPtr(name, blockNo);
     77            output = mKernel->getOutputStream(name, iBuilder->getInt32(0));
    8078        }
    8179        mMarker.emplace(var, output);
     
    8381
    8482    compileBlock(entryBlock);
     83
     84    mCarryManager->finalizeCodeGen();
    8585
    8686}
     
    388388            Value * array = compileExpression(extract->getArray(), false);
    389389            Value * index = compileExpression(extract->getIndex());
    390             value = iBuilder->CreateGEP(array, {ConstantInt::getNullValue(index->getType()), index}, stmt->getName());
     390            value = iBuilder->CreateGEP(array, index, stmt->getName());
    391391        } else if (isa<And>(stmt)) {
    392392            value = compileExpression(stmt->getOperand(0));
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5300 r5307  
    4949    return f->second;
    5050}
    51 
    52 
    5351
    5452Var * PabloKernel::addInput(const std::string & name, Type * const type) {
Note: See TracChangeset for help on using the changeset viewer.