Ignore:
Timestamp:
May 6, 2016, 3:28:07 PM (3 years ago)
Author:
cameron
Message:

Refactor: move grep-specific code out of toolchain

File:
1 edited

Legend:

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

    r5030 r5033  
    1111#include <sstream>
    1212
     13
     14#include <toolchain.h>
    1315#include <llvm/IR/Function.h>
    1416#include <llvm/IR/Module.h>
    1517#include <llvm/ExecutionEngine/ExecutionEngine.h>
    1618#include <llvm/ExecutionEngine/MCJIT.h>
    17 #include <llvm/IRReader/IRReader.h>
    18 #include <llvm/IR/Verifier.h>
    19 #include <llvm/Support/Debug.h>
    2019
    2120#include <llvm/Support/CommandLine.h>
    22 #include <llvm/CodeGen/CommandFlags.h>
    23 #include <llvm/Support/SourceMgr.h>
    24 #include <llvm/Support/TargetSelect.h>
    25 #include <llvm/Support/Host.h>
    2621#include <llvm/Support/raw_ostream.h>
    2722
     
    3934#include <pablo/pablo_toolchain.h>
    4035
    41 // Dynamic processor detection
    42 #define ISPC_LLVM_VERSION ISPC_LLVM_3_6
    43 #include <util/ispc.cpp>
    4436
    4537#include <utf_encoding.h>
     
    115107//
    116108
    117 ExecutionEngine * wcJIT_to_ExecutionEngine (Module * m) {
    118 
    119     InitializeNativeTarget();
    120     InitializeNativeTargetAsmPrinter();
    121     InitializeNativeTargetAsmParser();
    122 
    123     PassRegistry * Registry = PassRegistry::getPassRegistry();
    124     initializeCore(*Registry);
    125     initializeCodeGen(*Registry);
    126     initializeLowerIntrinsicsPass(*Registry);
    127 
    128     std::string errMessage;
    129     EngineBuilder builder(std::move(std::unique_ptr<Module>(m)));
    130     builder.setErrorStr(&errMessage);
    131     builder.setMCPU(sys::getHostCPUName());
    132     CodeGenOpt::Level optLevel = CodeGenOpt::Level::None;
    133     switch (OptLevel) {
    134         case '0': optLevel = CodeGenOpt::None; break;
    135         case '1': optLevel = CodeGenOpt::Less; break;
    136         case '2': optLevel = CodeGenOpt::Default; break;
    137         case '3': optLevel = CodeGenOpt::Aggressive; break;
    138         default: errs() << OptLevel << " is an invalid optimization level.\n";
    139     }
    140     builder.setOptLevel(optLevel);
    141 
    142     if ((strncmp(lGetSystemISA(), "avx2", 4) == 0)) {
    143             std::vector<std::string> attrs;
    144             attrs.push_back("avx2");
    145             builder.setMAttrs(attrs);
    146     }
    147 
    148     // builder.selectTarget();
    149 
    150     //builder.setOptLevel(mMaxWhileDepth ? CodeGenOpt::Level::Less : CodeGenOpt::Level::None);
    151     ExecutionEngine * engine = builder.create();
    152     if (engine == nullptr) {
    153         throw std::runtime_error("Could not create ExecutionEngine: " + errMessage);
    154     }
    155     return engine;
    156 }
    157 
    158 
    159109pablo::PabloFunction * wc_gen(Encoding encoding) {
    160110    //  input: 8 basis bit streams
     
    382332    Module * M = new Module("wc", getGlobalContext());
    383333   
    384     IDISA::IDISA_Builder * idb = GetIDISA_Builder(M);
     334    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    385335
    386336    wcPipelineBuilder pipelineBuilder(M, idb);
     
    401351    //verifyModule(*M, &dbgs());
    402352    //std::cerr << "ExecuteKernels(); done\n";
    403     wcEngine = wcJIT_to_ExecutionEngine(M);
     353    wcEngine = JIT_to_ExecutionEngine(M);
    404354   
    405355    wcEngine->finalizeObject();
Note: See TracChangeset for help on using the changeset viewer.