Changeset 4843


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

Move genPrintRegister into IDISA builder; fix GCB defs

Location:
icGREP/icgrep-devel/icgrep
Files:
5 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);
  • 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
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4841 r4843  
    331331    RE * GCB_CR = makeName("gcb", "cr", Name::Type::UnicodeProperty);
    332332    RE * GCB_LF = makeName("gcb", "lf", Name::Type::UnicodeProperty);
     333    RE * GCB_Control_CR_LF = makeAlt({GCB_CR, GCB_LF, GCB_Control});
    333334
    334335    // Break at the start and end of text.
     
    338339    RE * GCB_3 = makeSeq({Behind(GCB_CR), Ahead(GCB_LF)});
    339340    // Otherwise, break before and after controls.
    340     RE * GCB_4 = Behind(GCB_Control);
    341     RE * GCB_5 = Ahead(GCB_Control);
    342     RE * GCB_1_5 = makeAlt({GCB_1, GCB_2, makeDiff(makeSeq({GCB_4, GCB_5}), GCB_3)});
     341    RE * GCB_4 = Behind(GCB_Control_CR_LF);
     342    RE * GCB_5 = Ahead(GCB_Control_CR_LF);
     343    RE * GCB_1_5 = makeAlt({GCB_1, GCB_2, makeDiff(makeAlt({GCB_4, GCB_5}), GCB_3)});
    343344
    344345    RE * GCB_L = makeName("gcb", "l", Name::Type::UnicodeProperty);
Note: See TracChangeset for help on using the changeset viewer.