Ignore:
Timestamp:
Oct 18, 2015, 8:03:54 AM (4 years ago)
Author:
cameron
Message:

Move genPrintRegister into IDISA builder; fix GCB defs

Location:
icGREP/icgrep-devel/icgrep/IDISA
Files:
2 edited

Legend:

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

    r4837 r4843  
    2626}
    2727
     28void IDISA_Builder::genPrintRegister(std::string regName, Value * bitblockValue) {
     29    if (mPrintRegisterFunction == nullptr) {
     30        mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, NULL);
     31    }
     32    Constant * regNameData = ConstantDataArray::getString(mMod->getContext(), regName);
     33    GlobalVariable *regStrVar = new GlobalVariable(*mMod,
     34                                                   ArrayType::get(IntegerType::get(mMod->getContext(), 8), regName.length()+1),
     35                                                   /*isConstant=*/ true,
     36                                                   /*Linkage=*/ GlobalValue::PrivateLinkage,
     37                                                   /*Initializer=*/ regNameData);
     38    Value * regStrPtr = mLLVMBuilder->CreateGEP(regStrVar, std::vector<Value *>({mLLVMBuilder->getInt64(0), mLLVMBuilder->getInt32(0)}));
     39    mLLVMBuilder->CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitblockValue}));
     40}
     41
     42   
    2843Value * IDISA_Builder::simd_add(unsigned fw, Value * a, Value * b) {
    2944    return mLLVMBuilder->CreateAdd(fwCast(fw, a), fwCast(fw, b));
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4837 r4843  
    2626    , mBitBlockWidth(bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth())
    2727    , mZeroInitializer(Constant::getNullValue(bitBlockType))
    28     , mOneInitializer(Constant::getAllOnesValue(bitBlockType)) {
     28    , mOneInitializer(Constant::getAllOnesValue(bitBlockType))
     29    , mPrintRegisterFunction(nullptr) {
    2930
    3031    }
     
    3839    Value * bitCast(Value * a) {return a->getType() == mBitBlockType ? a : mLLVMBuilder->CreateBitCast(a, mBitBlockType);}
    3940    int getBitBlockWidth() { return mBitBlockWidth;}
     41    void genPrintRegister(std::string regName, Value * bitblockValue);
    4042   
    4143   
     
    8789    Constant * mZeroInitializer;
    8890    Constant * mOneInitializer;
     91    Constant * mPrintRegisterFunction;
    8992   
    9093    Value * bitBlockCast(Value * a);
Note: See TracChangeset for help on using the changeset viewer.