Ignore:
Timestamp:
Dec 26, 2015, 12:09:11 PM (3 years ago)
Author:
cameron
Message:

Dynamic generation of s2p code

File:
1 edited

Legend:

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

    r4898 r4900  
    5656namespace pablo {
    5757
    58 PabloCompiler::PabloCompiler(Type * bitBlockType)
    59 : mMod(nullptr)
     58PabloCompiler::PabloCompiler(Module * m, IDISA::IDISA_Builder * b)
     59: mMod(m)
     60, iBuilder(b)
     61, mBitBlockType(b->getBitBlockType())
    6062, mCarryManager(nullptr)
    61 , mBitBlockType(bitBlockType)
    62 , iBuilder(nullptr)
    6363, mInputType(nullptr)
    6464, mWhileDepth(0)
     
    6969, mMaxWhileDepth(0) {
    7070   
    71    
    72 
    7371}
    7472
    7573PabloCompiler::~PabloCompiler() {
    7674}
    77    
    78 
     75       
    7976llvm::Function * PabloCompiler::compile(PabloFunction * function) {
    80     Module * module = new Module("", getGlobalContext());
    81    
    82     auto func = compile(function, module);
    83    
    84     //Display the IR that has been generated by this module.
    85     if (LLVM_UNLIKELY(DumpGeneratedIR)) {
    86         module->dump();
    87     }
    88     //Create a verifier.  The verifier will print an error message if our module is malformed in any way.
    89     verifyModule(*module, &dbgs());
    90 
    91     return func;
    92 }
    93 
    94 // Dynamic AVX2 confirmation
    95 #if (BLOCK_SIZE == 256)
    96 #define ISPC_LLVM_VERSION ISPC_LLVM_3_6
    97 #include <ispc.cpp>
    98 #endif
    99    
    100 llvm::Function * PabloCompiler::compile(PabloFunction * function, Module * module) {
    10177
    10278 
     
    10682   
    10783    Examine(*function);
    108 
    109     mMod = module;
    110 
    111 #if (BLOCK_SIZE == 256)
    112     if ((strncmp(lGetSystemISA(), "avx2", 4) == 0)) {
    113         iBuilder = new IDISA::IDISA_AVX2_Builder(mMod, mBitBlockType);
    114         //std::cerr << "IDISA_AVX2_Builder selected\n";
    115     }
    116     else{
    117         iBuilder = new IDISA::IDISA_Builder(mMod, mBitBlockType);
    118         //std::cerr << "Generic IDISA_Builder selected\n";
    119     }
    120 #else   
    121     iBuilder = new IDISA::IDISA_Builder(mMod, mBitBlockType);
    122 #endif
    12384
    12485    mCarryManager = new CarryManager(iBuilder);
     
    166127    // Clean up
    167128    delete mCarryManager; mCarryManager = nullptr;
    168     delete iBuilder; iBuilder = nullptr;
    169     delete iBuilder; iBuilder = nullptr;
    170     mMod = nullptr; // don't delete this. It's either owned by the ExecutionEngine or the calling function.
     129   
     130    if (LLVM_UNLIKELY(DumpGeneratedIR)) {
     131        mMod->dump();
     132    }
    171133
    172134    return mFunction;
Note: See TracChangeset for help on using the changeset viewer.