Ignore:
Timestamp:
Jan 31, 2017, 4:08:11 PM (2 years ago)
Author:
nmedfort
Message:

Removed 'function' and 'self' parameters from generateXXXMethod() functions.

File:
1 edited

Legend:

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

    r5285 r5292  
    5555    mCurrentScope = kernel->getEntryBlock();
    5656
    57     mCarryMetadata.resize(enumerate(mCurrentScope));
    58 
    59     mKernel->addScalar(analyse(mCurrentScope), "carries");
     57    mCarryMetadata.resize(enumerate(kernel->getEntryBlock()));
     58
     59    mKernel->addScalar(analyse(kernel->getEntryBlock()), "carries");
    6060}
    6161
     
    6363 * @brief initializeCodeGen
    6464 ** ------------------------------------------------------------------------------------------------------------- */
    65 void CarryManager::initializeCodeGen(Value * self, Function * function) {
     65void CarryManager::initializeCodeGen() {
    6666    // TODO: need to look into abstracting the Initialize creation function in KernelBuilder::generateKernel
    6767    // so that we can allocate the variable length buffers if needed.
    6868
    69     mSelf = self;
    70     mFunction = function;
    71 
    72     assert(mCarryMetadata.size() > 0);
     69    assert(!mCarryMetadata.empty());
    7370    mCarryInfo = &mCarryMetadata[0];
    7471    assert (!mCarryInfo->hasSummary());
    7572
    76     mCurrentFrame = iBuilder->CreateGEP(mSelf, {iBuilder->getInt32(0), mKernel->getScalarIndex("carries")}, "carries");
     73    mCurrentFrame = mKernel->getScalarFieldPtr("carries");
    7774    mCurrentFrameIndex = 0;
    7875
     
    8481 * @brief enterLoopScope
    8582 ** ------------------------------------------------------------------------------------------------------------- */
    86 void CarryManager::enterLoopScope(PabloBlock * const scope) {
     83void CarryManager::enterLoopScope(const PabloBlock * const scope) {
    8784    assert (scope);
    8885    if (mLoopDepth++ == 0) {
    89         Value * const blockNo = mKernel->getBlockNo(mSelf);
     86        Value * const blockNo = mKernel->getBlockNo();
    9087        mLoopSelector = iBuilder->CreateAnd(blockNo, ConstantInt::get(blockNo->getType(), 1));
    9188    }
     
    10097    if (mCarryInfo->hasSummary()) {
    10198        PHINode * carrySummary = iBuilder->CreatePHI(mCarryPackType, 2, "summary");
    102         assert (mCarrySummary.size() > 0);
     99        assert (!mCarrySummary.empty());
    103100        carrySummary->addIncoming(mCarrySummary.back(), entryBlock);
    104101        // Replace the incoming carry summary with the phi node and add the phi node to the stack
     
    118115        Value * array = iBuilder->CreateLoad(arrayPtr, false, "array");
    119116
    120         LLVMContext & C = iBuilder->getContext();
    121 
    122         BasicBlock * resizeBlock = BasicBlock::Create(C, "", mFunction);
    123         BasicBlock * cleanUpBlock = BasicBlock::Create(C, "", mFunction);
    124         BasicBlock * zeroBlock = BasicBlock::Create(C, "", mFunction);
    125         BasicBlock * codeBlock = BasicBlock::Create(C, "", mFunction);
     117        BasicBlock * resizeBlock = mKernel->CreateBasicBlock("");
     118        BasicBlock * cleanUpBlock = mKernel->CreateBasicBlock("");
     119        BasicBlock * zeroBlock = mKernel->CreateBasicBlock("");
     120        BasicBlock * codeBlock = mKernel->CreateBasicBlock("");
    126121
    127122        Value * cond = iBuilder->CreateICmpULT(index, capacity);
     
    171166    }
    172167    if (LLVM_UNLIKELY(mCarryInfo->variableLength)) {
    173         assert (mLoopIndicies.size() > 0);
     168        assert (!mLoopIndicies.empty());
    174169        PHINode * index = mLoopIndicies.back();
    175170        index->addIncoming(iBuilder->CreateAdd(index, iBuilder->getSize(1)), exitBlock);
     
    192187 * @brief enterIfScope
    193188 ** ------------------------------------------------------------------------------------------------------------- */
    194 void CarryManager::enterIfScope(PabloBlock * const scope) {
     189void CarryManager::enterIfScope(const PabloBlock * const scope) {
    195190    ++mIfDepth;
    196191    enterScope(scope);
     
    242237    const auto n = mCarrySummary.size();
    243238    if (LLVM_LIKELY(mCarryInfo->hasExplicitSummary())) {
    244         assert (mCarrySummary.size() > 0);
     239        assert (!mCarrySummary.empty());
    245240        Value * ptr = iBuilder->CreateGEP(mCurrentFrame, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    246241        Value * const value = iBuilder->CreateBitCast(mCarrySummary.back(), mBitBlockType);
     
    281276 * @brief enterScope
    282277 ** ------------------------------------------------------------------------------------------------------------- */
    283 void CarryManager::enterScope(PabloBlock * const scope) {
     278void CarryManager::enterScope(const PabloBlock * const scope) {
    284279    assert (scope);
    285280    // Store the state of the current frame and update the scope state
     
    305300    assert (mCurrentFrameIndex == mCurrentFrame->getType()->getPointerElementType()->getStructNumElements());
    306301    // Sanity test: are there remaining carry frames?
    307     assert (mCarryFrame.size() > 0);
     302    assert (!mCarryFrame.empty());
    308303
    309304    std::tie(mCurrentFrame, mCurrentFrameIndex) = mCarryFrame.back();
     
    393388    // Create a mask to implement circular buffer indexing
    394389    Value * indexMask = iBuilder->getSize(nearest_pow2(entries) - 1);
    395     Value * blockIndex = mKernel->getBlockNo(mSelf);
     390    Value * blockIndex = mKernel->getBlockNo();
    396391    Value * carryIndex0 = iBuilder->CreateSub(blockIndex, iBuilder->getSize(entries));
    397392    Value * loadIndex0 = iBuilder->CreateAnd(carryIndex0, indexMask);
     
    458453 ** ------------------------------------------------------------------------------------------------------------- */
    459454void CarryManager::addToSummary(Value * value) { assert (value);
    460     assert (mIfDepth > 0 && mCarrySummary.size() > 0);
     455    assert (mIfDepth > 0 && !mCarrySummary.empty());
    461456    Value * const summary = mCarrySummary.back(); assert (summary);
    462457    if (LLVM_UNLIKELY(summary == value)) {
     
    609604: iBuilder(idb)
    610605, mKernel(nullptr)
    611 , mSelf(nullptr)
    612 , mFunction(nullptr)
    613606, mBitBlockType(idb->getBitBlockType())
    614607, mBitBlockWidth(idb->getBitBlockWidth())
Note: See TracChangeset for help on using the changeset viewer.