Changeset 4821


Ignore:
Timestamp:
Oct 5, 2015, 8:30:12 AM (2 years ago)
Author:
cameron
Message:

Encapsulating all-zeroes and all-ones initializers within IDISA builder

Location:
icGREP/icgrep-devel/icgrep
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4720 r4821  
    88 */
    99#include <llvm/IR/Module.h>
     10#include <llvm/IR/Constant.h>
    1011#include <llvm/IR/Type.h>
    1112#include <llvm/IR/Value.h>
     
    2324    , mLLVMBuilder(nullptr)
    2425    , mBitBlockType(bitBlockType)
    25     , mBitBlockSize(bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth()) {
     26    , mBitBlockSize(bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth())
     27    , mZeroInitializer(Constant::getNullValue(bitBlockType))
     28    , mOneInitializer(Constant::getAllOnesValue(bitBlockType)) {
    2629
    2730    }
     
    3134        mLLVMBuilder = b;
    3235    }
     36   
     37    Type * getBitBlockType() { return mBitBlockType;}
     38    int getBitBlockSize() { return mBitBlockSize;}
     39    Constant * allZeroes() {return mZeroInitializer;}
     40    Constant * allOnes() {return mOneInitializer;}
    3341       
    3442    Value * simd_add(unsigned fw, Value * a, Value * b);
     
    7179    Type * mBitBlockType;
    7280    unsigned mBitBlockSize;
     81    Constant * mZeroInitializer;
     82    Constant * mOneInitializer;
    7383   
    7484    Value * bitBlockCast(Value * a);
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4813 r4821  
    5151        mITEMS_PER_PACK = 64;
    5252        mCarryPackType = mBuilder->getIntNTy(mPACK_SIZE);
    53         mZeroInitializer = mBuilder->getInt64(0);
    54         mOneInitializer = mBuilder->getInt64(-1);
     53        mPackBuilder = new IDISA::IDISA_Builder(mCarryPackType);
     54        mPackBuilder->initialize(m, mBuilder);
    5555    }
    5656    else {
     
    521521    if (blockHasCarries()) {
    522522        if (mCarryOutPack[scopeBasePack()] == nullptr) {
    523             mCarryInfo->ifEntryPack = mZeroInitializer;
     523            mCarryInfo->ifEntryPack = mPackBuilder->allZeroes();
    524524        }
    525525        else {
     
    536536        for (unsigned index = currentScopeBase; index < currentScopeBase + scopeCarryPacks; ++index) {
    537537            PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
    538             phi_out->addIncoming(mZeroInitializer,ifEntryBlock);
     538            phi_out->addIncoming(mPackBuilder->allZeroes(),ifEntryBlock);
    539539            phi_out->addIncoming(mCarryOutPack[index],ifBodyFinalBlock);
    540540            mCarryOutPack[index] = phi_out;
     
    562562        const unsigned summaryIndex = summaryPackIndex();
    563563        PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    564         summary_phi->addIncoming(mZeroInitializer, ifEntryBlock);
     564        summary_phi->addIncoming(mPackBuilder->allZeroes(), ifEntryBlock);
    565565        summary_phi->addIncoming(mCarryOutPack[summaryIndex], ifBodyFinalBlock);
    566566        mCarryOutPack[summaryIndex] = summary_phi;
     
    576576    const unsigned carrySummaryIndex = summaryPackIndex();
    577577    PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    578     summary_phi->addIncoming(mZeroInitializer, ifEntryBlock);
     578    summary_phi->addIncoming(mPackBuilder->allZeroes(), ifEntryBlock);
    579579    summary_phi->addIncoming(mCarryOutPack[carrySummaryIndex], ifBodyFinalBlock);
    580580    mCarryOutPack[carrySummaryIndex] = summary_phi;
     
    592592    const unsigned carrySummaryIndex = summaryPackIndex();
    593593   
    594     Value * carry_summary = mZeroInitializer;
     594    Value * carry_summary = mPackBuilder->allZeroes();
    595595    if (mCarryInfo->blockHasLongAdvances()) { // Force if entry
    596         carry_summary = mOneInitializer;
     596        carry_summary = mPackBuilder->allOnes();
    597597    }
    598598    else {
     
    655655#endif
    656656        PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
    657         phi_out->addIncoming(mZeroInitializer, whileEntryBlock);
     657        phi_out->addIncoming(mPackBuilder->allZeroes(), whileEntryBlock);
    658658        mCarryOutAccumPhis[index] = phi_out;
    659659    }
     
    666666    for (unsigned index = 0; index < scopeCarryPacks; ++index) {
    667667#ifdef SET_WHILE_CARRY_IN_TO_ZERO_AFTER_FIRST_ITERATION
    668         mCarryInPhis[index]->addIncoming(mZeroInitializer, whileBodyFinalBlock);
     668        mCarryInPhis[index]->addIncoming(mPackBuilder->allZeroes(), whileBodyFinalBlock);
    669669#endif
    670670        PHINode * phi = mCarryOutAccumPhis[index];
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4816 r4821  
    4040public:
    4141 
    42     CarryManager(IRBuilder <> * b, VectorType * bitBlockType, ConstantAggregateZero * zero, IDISA::IDISA_Builder * idb)
     42    CarryManager(IRBuilder <> * b, IDISA::IDISA_Builder * idb)
    4343    : mPACK_SIZE(BLOCK_SIZE)
    4444    , mITEMS_PER_PACK(1)
    4545    , mBuilder(b)
    46     , mBitBlockType(bitBlockType)
    47     , mZeroInitializer(zero)
    48     , mOneInitializer(ConstantVector::getAllOnesValue(bitBlockType))
    4946    , iBuilder(idb)
     47    , mPackBuilder(idb)
     48    , mBitBlockType(idb->getBitBlockType())
    5049    , mPabloRoot(nullptr)
    5150    , mCurrentScope(nullptr)
     
    122121    unsigned mITEMS_PER_PACK;
    123122    IRBuilder <> * mBuilder;
    124     VectorType * mBitBlockType;
    125     Constant * mZeroInitializer;
    126     Constant * mOneInitializer;
    127123    IDISA::IDISA_Builder * iBuilder;
     124    IDISA::IDISA_Builder * mPackBuilder;
     125    Type * mBitBlockType;
    128126    PabloBlock * mPabloRoot;
    129127    PabloBlock * mCurrentScope;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4820 r4821  
    6464, mWhileDepth(0)
    6565, mIfDepth(0)
    66 , mZeroInitializer(ConstantAggregateZero::get(mBitBlockType))
    67 , mOneInitializer(ConstantVector::getAllOnesValue(mBitBlockType))
    6866, mFunction(nullptr)
    6967, mInputAddressPtr(nullptr)
     
    119117    iBuilder.initialize(mMod, mBuilder);
    120118
    121     mCarryManager = new CarryManager(mBuilder, mBitBlockType, mZeroInitializer, &iBuilder);
     119    mCarryManager = new CarryManager(mBuilder, &iBuilder);
    122120   
    123121    if (DumpTrace) DeclareDebugFunctions();
     
    310308        auto f = mMarkerMap.find(assign);
    311309        assert (f != mMarkerMap.end());
    312         phi->addIncoming(mZeroInitializer, ifEntryBlock);
     310        phi->addIncoming(iBuilder.allZeroes(), ifEntryBlock);
    313311        phi->addIncoming(f->second, ifBodyFinalBlock);
    314312        mMarkerMap[assign] = phi;
     
    516514Value * PabloCompiler::compileExpression(const PabloAST * expr) {
    517515    if (isa<Ones>(expr)) {
    518         return mOneInitializer;
     516        return iBuilder.allOnes();
    519517    }
    520518    else if (isa<Zeroes>(expr)) {
    521         return mZeroInitializer;
     519        return iBuilder.allZeroes();
    522520    }
    523521    auto f = mMarkerMap.find(expr);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4816 r4821  
    124124    unsigned                            mIfDepth;
    125125
    126     ConstantAggregateZero* const        mZeroInitializer;
    127     Constant* const                     mOneInitializer;
    128 
    129126    Function *                          mFunction;
    130127    Value *                             mInputAddressPtr;
Note: See TracChangeset for help on using the changeset viewer.