Changeset 4731 for icGREP


Ignore:
Timestamp:
Aug 18, 2015, 2:17:33 PM (4 years ago)
Author:
cameron
Message:

Link in print_register as needed

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

Legend:

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

    r4730 r4731  
    5858    builder.setErrorStr(&errMessage);
    5959    builder.setMCPU(sys::getHostCPUName());
    60 
     60    builder.setOptLevel(CodeGenOpt::Level::None);
    6161    //builder.setOptLevel(mMaxWhileDepth ? CodeGenOpt::Level::Less : CodeGenOpt::Level::None);
    6262    ExecutionEngine * engine = builder.create();
     
    6767    // engine->addGlobalMapping(externalFunction, proto->getFunctionPtr());
    6868
    69     engine->finalizeObject();
    7069    return engine;
     70}
     71
     72
     73extern "C" {
     74  void wrapped_print_register(char * regName, BitBlock bit_block) {
     75      print_register<BitBlock>(regName, bit_block);
     76  }
     77}
     78
     79void icgrep_Linking(Module * m, ExecutionEngine * e) {
     80    Function * printRegFn = m->getFunction("wrapped_print_register");
     81    if (printRegFn) {
     82        e->addGlobalMapping(cast<GlobalValue>(printRegFn), (void *)&wrapped_print_register);
     83    }
    7184}
    7285
     
    112125
    113126   
     127   
     128   
    114129    //std::vector<std::string> regexVector;
    115130    if (RegexFilename != "") {
     
    138153    if (CaseInsensitive) globalFlags |= re::CASE_INSENSITIVE_MODE_FLAG;
    139154   
     155    llvm::Function * icgrep_IR = icgrep::compile(encoding, regexVector, globalFlags);
    140156   
    141     llvm::Function * llvm_codegen = icgrep::compile(encoding, regexVector, globalFlags);
     157    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(icgrep_IR);
    142158   
    143     llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(llvm_codegen);
     159    icgrep_Linking(icgrep_IR->getParent(), engine);
    144160   
    145     void * functionPointer = engine->getPointerToFunction(llvm_codegen);
     161    // Ensure everything is ready to go.
     162    engine->finalizeObject();
    146163   
    147     if (functionPointer) {
    148         GrepExecutor grepEngine = GrepExecutor(functionPointer);
     164    void * icgrep_MCptr = engine->getPointerToFunction(icgrep_IR);
     165   
     166    if (icgrep_MCptr) {
     167        GrepExecutor grepEngine = GrepExecutor(icgrep_MCptr);
    149168        grepEngine.setCountOnlyOption(CountOnly);
    150169        grepEngine.setNormalizeLineBreaksOption(NormalizeLineBreaks);
     
    158177    }
    159178   
    160     //engine->freeMachineCodeForFunction(llvm_codegen); // This function only prints a "not supported" message. Reevaluate with LLVM 3.6.
     179    //engine->freeMachineCodeForFunction(icgrep_IR); // This function only prints a "not supported" message. Reevaluate with LLVM 3.6.
    161180    delete engine;
    162181
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4730 r4731  
    5555static cl::opt<bool> DumpTrace("dump-trace", cl::init(false), cl::desc("Generate dynamic traces of executed assignments."), cl::cat(fTracingOptions));
    5656
    57 extern "C" {
    58   void wrapped_print_register(char * regName, BitBlock bit_block) {
    59       print_register<BitBlock>(regName, bit_block);
    60   }
    61 }
    62 
    6357namespace pablo {
    6458
     
    130124    mCarryManager = new CarryManager(mBuilder, mBitBlockType, mZeroInitializer, mOneInitializer, &iBuilder);
    131125   
     126    if (DumpTrace) DeclareDebugFunctions();
    132127       
    133128    GenerateFunction(function);
    134 
     129   
    135130    mBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", mFunction,0));
    136131
     
    312307
    313308inline void PabloCompiler::DeclareDebugFunctions() {
    314     if (DumpTrace) {
    315309        //This function can be used for testing to print the contents of a register from JIT'd code to the terminal window.
    316310        mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, NULL);
    317     }
    318311}
    319312
Note: See TracChangeset for help on using the changeset viewer.