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/pablo
Files:
2 edited

Legend:

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

    r4839 r4843  
    6767, mInputAddressPtr(nullptr)
    6868, mOutputAddressPtr(nullptr)
    69 , mMaxWhileDepth(0)
    70 , mPrintRegisterFunction(nullptr) {
     69, mMaxWhileDepth(0) {
    7170
    7271}
     
    7574}
    7675   
    77 
    78 void PabloCompiler::genPrintRegister(std::string regName, Value * bitblockValue) {
    79     Constant * regNameData = ConstantDataArray::getString(mMod->getContext(), regName);
    80     GlobalVariable *regStrVar = new GlobalVariable(*mMod,
    81                                                    ArrayType::get(IntegerType::get(mMod->getContext(), 8), regName.length()+1),
    82                                                    /*isConstant=*/ true,
    83                                                    /*Linkage=*/ GlobalValue::PrivateLinkage,
    84                                                    /*Initializer=*/ regNameData);
    85     Value * regStrPtr = mBuilder->CreateGEP(regStrVar, std::vector<Value *>({mBuilder->getInt64(0), mBuilder->getInt32(0)}));
    86     mBuilder->CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitblockValue}));
    87 }
    8876
    8977llvm::Function * PabloCompiler::compile(PabloFunction * function) {
     
    119107    mCarryManager = new CarryManager(mBuilder, &iBuilder);
    120108   
    121     if (DumpTrace) DeclareDebugFunctions();
    122        
    123109    GenerateFunction(*function);
    124110   
     
    132118        mMarkerMap[function->getParameter(i)] = basisBit;
    133119        if (DumpTrace) {
    134             genPrintRegister(function->getParameter(i)->getName()->to_string(), basisBit);
     120            iBuilder.genPrintRegister(function->getParameter(i)->getName()->to_string(), basisBit);
    135121        }
    136122    }
     
    149135
    150136    if (DumpTrace) {
    151         genPrintRegister("mBlockNo", mBuilder->CreateAlignedLoad(mBuilder->CreateBitCast(mCarryManager->getBlockNoPtr(), PointerType::get(mBitBlockType, 0)), iBuilder.getBitBlockWidth()/8, false));
     137        iBuilder.genPrintRegister("mBlockNo", mBuilder->CreateAlignedLoad(mBuilder->CreateBitCast(mCarryManager->getBlockNoPtr(), PointerType::get(mBitBlockType, 0)), iBuilder.getBitBlockWidth()/8, false));
    152138    }
    153139   
     
    216202        }
    217203    }
    218 }
    219 
    220 inline void PabloCompiler::DeclareDebugFunctions() {
    221         //This function can be used for testing to print the contents of a register from JIT'd code to the terminal window.
    222         mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, NULL);
    223204}
    224205
     
    478459    mMarkerMap[stmt] = expr;
    479460    if (DumpTrace) {
    480         genPrintRegister(stmt->getName()->to_string(), expr);
     461        iBuilder.genPrintRegister(stmt->getName()->to_string(), expr);
    481462    }
    482463   
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4839 r4843  
    8181private:
    8282    void GenerateFunction(PabloFunction & function);
    83     void DeclareDebugFunctions();
    8483    void Examine(PabloFunction & function);
    8584    void Examine(PabloBlock & block);
     
    8786    void SetOutputValue(Value * marker, const unsigned index);
    8887
    89     void genPrintRegister(std::string regName, Value * bitblockValue);
    9088    void compileBlock(PabloBlock & block);
    9189    void compileStatement(const Statement * stmt);
     
    119117    unsigned                            mMaxWhileDepth;
    120118
    121     Constant *                          mPrintRegisterFunction;
    122119};
    123120
Note: See TracChangeset for help on using the changeset viewer.