Changeset 4900


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

Dynamic generation of s2p code

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4896 r4900  
    6262
    6363SET(PABLO_SRC pablo/pabloAST.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/function.cpp pablo/codegenstate.cpp pablo/builder.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp)
    64 SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp IDISA/idisa_builder.cpp IDISA/idisa_avx_builder.cpp)
     64SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_compiler.cpp pablo/carry_manager.cpp pablo/carry_data.cpp IDISA/idisa_builder.cpp IDISA/idisa_avx_builder.cpp IDISA/idisa_sse_builder.cpp IDISA/s2p_gen.cpp)
    6565SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
    6666SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/optimizers/distributivepass.cpp pablo/passes/flattenassociativedfg.cpp pablo/passes/factorizedfg.cpp)
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.cpp

    r4898 r4900  
    125125
    126126Value * IDISA_Builder::simd_if(unsigned fw, Value * cond, Value * a, Value * b) {
    127     Value * aVec = fwCast(fw, a);
    128     Value * bVec = fwCast(fw, b);
    129     return CreateSelect(CreateICmpSLT(cond, mZeroInitializer), aVec, bVec);
     127    if (fw == 1) {
     128        Value * c = bitCast(cond);
     129        return CreateOr(CreateAnd(c, bitCast(a)), CreateAnd(CreateNot(c), bitCast(b)));
     130    }
     131    else {
     132        Value * aVec = fwCast(fw, a);
     133        Value * bVec = fwCast(fw, b);
     134        return CreateSelect(CreateICmpSLT(cond, mZeroInitializer), aVec, bVec);
     135    }
    130136}
    131137
     
    184190    std::vector<Constant*> Idxs;
    185191    for (unsigned i = 0; i < field_count; i++) {
    186         Idxs.push_back(getInt32(2*i));
     192        Idxs.push_back(getInt32(2*i+1));
    187193    }
    188194    return CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs));
     
    195201    std::vector<Constant*> Idxs;
    196202    for (unsigned i = 0; i < field_count; i++) {
    197         Idxs.push_back(getInt32(2*i+1));
     203        Idxs.push_back(getInt32(2*i));
    198204    }
    199205    return CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs));
  • icGREP/icgrep-devel/icgrep/IDISA/s2p_gen.cpp

    r4895 r4900  
    77#include "s2p_gen.h"
    88
    9 void * s2p_step(IDISA_Builder * iBuilder, Value * s0, Value * s1, Value * hi_mask, unsigned shift, Value * p0, Value * p1) {
     9void s2p_step(IDISA::IDISA_Builder * iBuilder, Value * s0, Value * s1, Value * hi_mask, unsigned shift, Value * &p0, Value * &p1) {
    1010    Value * t0 = iBuilder->hsimd_packh(16, s0, s1);
    1111    Value * t1 = iBuilder->hsimd_packl(16, s0, s1);
    12     Value * p0 = iBuilder->simd_if(1, hi_mask, t0, iBuilder->simd_srli(16, t1, shift));
    13     Value * p1 = iBuilder->simd_if(1, hi_mask, iBuilder->simd_slli(16, t0, shift), t1);
     12    p0 = iBuilder->simd_if(1, hi_mask, t0, iBuilder->simd_srli(16, t1, shift));
     13    p1 = iBuilder->simd_if(1, hi_mask, iBuilder->simd_slli(16, t0, shift), t1);
    1414}
    1515
    16 void * s2p(IDISA_Builder * iBuilder,
    17            Value * s0, Value * s1, Value * s2, Value * s3, Value * s4, Value * s5, Value * s6, Value * s7,
    18            Value * p0, Value * p1, Value * p2, Value * p3, Value * p4, Value * p5, Value * p6, Value * p7) {
    19     Value * bit00224466_0,bit00224466_1,bit00224466_2,bit00224466_3;
    20     Value * bit11335577_0,bit11335577_1,bit11335577_2,bit11335577_3;
    21     Value * bit00004444_0,bit22226666_0,bit00004444_1,bit22226666_1;
    22     Value * bit11115555_0,bit33337777_0,bit11115555_1,bit33337777_1;
    23     Value * hi_mask2 = iBuilder->simd_himask(2);
    24     Value * hi_mask4 = iBuilder->simd_himask(4);
    25     Value * hi_mask8 = iBuilder->simd_himask(8);
    26     s2p_step(iBuilder, s0,s1,hi_mask2,1,bit00224466_0,bit11335577_0);
    27     s2p_step(iBuilder, s2,s3,hi_mask2,1,bit00224466_1,bit11335577_1);
    28     s2p_step(iBuilder, s4,s5,hi_mask2,1,bit00224466_2,bit11335577_2);
    29     s2p_step(iBuilder, s6,s7,hi_mask2,1,bit00224466_3,bit11335577_3);
    30     s2p_step(iBuilder, bit00224466_0,bit00224466_1,hi_mask4,2,bit00004444_0,bit22226666_0);
    31     s2p_step(iBuilder, bit00224466_2,bit00224466_3,hi_mask4,2,bit00004444_1,bit22226666_1);
    32     s2p_step(iBuilder, bit11335577_0,bit11335577_1,hi_mask4,2,bit11115555_0,bit33337777_0);
    33     s2p_step(iBuilder, bit11335577_2,bit11335577_3,hi_mask4,2,bit11115555_1,bit33337777_1);
    34     s2p_step(iBuilder, bit00004444_0,bit00004444_1,hi_mask8,4,p0,p4);
    35     s2p_step(iBuilder, bit11115555_0,bit11115555_1,hi_mask8,4,p1,p5);
    36     s2p_step(iBuilder, bit22226666_0,bit22226666_1,hi_mask8,4,p2,p6);
    37     s2p_step(iBuilder, bit33337777_0,bit33337777_1,hi_mask8,4,p3,p7);
     16void s2p(IDISA::IDISA_Builder * iBuilder, Value * s[], Value * p[]) {
     17    Value * bit00224466[4];
     18    Value * bit11335577[4];
     19    for (unsigned i = 0; i<4; i++) {
     20        s2p_step(iBuilder, s[2*i], s[2*i+1], iBuilder->simd_himask(2), 1, bit00224466[i], bit11335577[i]);
     21    }
     22    Value * bit00004444[2];
     23    Value * bit22226666[2];
     24    Value * bit11115555[2];
     25    Value * bit33337777[2];
     26    for (unsigned j = 0; j<2; j++) {
     27        s2p_step(iBuilder, bit00224466[2*j], bit00224466[2*j+1],
     28                 iBuilder->simd_himask(4), 2, bit00004444[j], bit22226666[j]);
     29        s2p_step(iBuilder, bit11335577[2*j], bit11335577[2*j+1],
     30                 iBuilder->simd_himask(4), 2, bit11115555[j], bit33337777[j]);
     31    }
     32    s2p_step(iBuilder, bit00004444[0], bit00004444[1], iBuilder->simd_himask(8), 4, p[0], p[4]);
     33    s2p_step(iBuilder, bit11115555[0], bit11115555[1], iBuilder->simd_himask(8), 4, p[1], p[5]);
     34    s2p_step(iBuilder, bit22226666[0], bit22226666[1], iBuilder->simd_himask(8), 4, p[2], p[6]);
     35    s2p_step(iBuilder, bit33337777[0], bit33337777[1], iBuilder->simd_himask(8), 4, p[3], p[7]);
    3836}
     37
     38
     39void gen_s2p_function(Module * m, IDISA::IDISA_Builder * iBuilder) {
     40    Type * inputType = PointerType::get(iBuilder->getBitBlockType(), 0);
     41    Type * outputType = PointerType::get(StructType::get(m->getContext(), std::vector<Type *>(8, iBuilder->getBitBlockType())), 0);
     42    FunctionType * functionType = FunctionType::get(Type::getVoidTy(m->getContext()), std::vector<Type *>({inputType, outputType}), false);
     43   
     44    Function * sFunction;
     45   
     46    SmallVector<AttributeSet, 3> Attrs;
     47    Attrs.push_back(AttributeSet::get(m->getContext(), ~0U, std::vector<Attribute::AttrKind>({ Attribute::NoUnwind, Attribute::UWTable })));
     48    Attrs.push_back(AttributeSet::get(m->getContext(), 1U, std::vector<Attribute::AttrKind>({ Attribute::ReadOnly, Attribute::NoCapture })));
     49    Attrs.push_back(AttributeSet::get(m->getContext(), 2U, std::vector<Attribute::AttrKind>({ Attribute::ReadNone, Attribute::NoCapture })));
     50    AttributeSet AttrSet = AttributeSet::get(m->getContext(), Attrs);
     51   
     52    // Create the function that will be generated.
     53    sFunction = Function::Create(functionType, GlobalValue::ExternalLinkage, "s2p_block", m);
     54    sFunction->setCallingConv(CallingConv::C);
     55    sFunction->setAttributes(AttrSet);
     56   
     57    Function::arg_iterator args = sFunction->arg_begin();
     58    Value * inputAddressPtr = args++;
     59    inputAddressPtr->setName("byte_data");
     60    Value * outputAddressPtr = args++;
     61    outputAddressPtr->setName("basis_bits");
     62   
     63   
     64    iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", sFunction,0));
     65    Value * byte_pack[8];
     66    Value * basis_bit[8];
     67   
     68    for (unsigned i = 0; i < 8; ++i) {
     69        Value* indices[] = {iBuilder->getInt64(i)};
     70        Value * gep = iBuilder->CreateGEP(inputAddressPtr, indices);
     71        byte_pack[i] = iBuilder->CreateAlignedLoad(gep, iBuilder->getBitBlockWidth()/8, false, "byte_pack");
     72    }
     73
     74    s2p(iBuilder, byte_pack, basis_bit);
     75
     76    //The basis bits structure (output)
     77    for (unsigned i = 0; i < 8; ++i) {
     78        Value* indices[] = {iBuilder->getInt64(0), iBuilder->getInt32(i)};
     79        Value * gep = iBuilder->CreateGEP(outputAddressPtr, indices);
     80        iBuilder->CreateAlignedStore(basis_bit[i], gep, iBuilder->getBitBlockWidth()/8, false);
     81    }
     82    iBuilder->CreateRetVoid();
     83}
  • icGREP/icgrep-devel/icgrep/IDISA/s2p_gen.h

    r4894 r4900  
    99
    1010#include <stdio.h>
    11 #include "idisa_builder.h"
     11#include <IDISA/idisa_builder.h>
     12#include <llvm/IR/Module.h>
    1213
    13 void * s2p_step(IDISA_Builder * iBuilder,
    14                 Value * s0, Value * s1, Value * hi_mask, unsigned shift, Value * p0, Value * p1);
    15 
    16 void * s2p(IDISA_Builder * iBuilder,
    17            Value * s0, Value * s1, Value * s2, Value * s3, Value * s4, Value * s5, Value * s6, Value * s7,
    18            Value * p0, Value * p1, Value * p2, Value * p3, Value * p4, Value * p5, Value * p6, Value * p7);
     14void gen_s2p_function(Module * m, IDISA::IDISA_Builder * iBuilder);
    1915
    2016#endif
  • icGREP/icgrep-devel/icgrep/do_grep.cpp

    r4883 r4900  
    273273
    274274        for (size_t blk = 0; blk != SEGMENT_BLOCKS; ++blk) {
    275             s2p_do_block(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits);
     275            mTransposeFcn(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits);
    276276            Output output;
    277277            mProcessBlockFcn(basis_bits, output);
     
    315315    /* Full Blocks */
    316316    for (; remaining >= BLOCK_SIZE; remaining -= BLOCK_SIZE, ++blk) {
    317         s2p_do_block(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits);
     317        mTransposeFcn(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits);
    318318        Output output;
    319319        mProcessBlockFcn(basis_bits, output);
     
    348348    }
    349349    else { // At least 1 byte, so we are not at a page boundary yet, safe to access a full block.
    350         s2p_do_final_block(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits, EOF_mask);
     350        mTransposeFcn(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits);
    351351    }
    352352
  • icGREP/icgrep-devel/icgrep/do_grep.h

    r4826 r4900  
    3939#endif
    4040
     41typedef void (*transpose_fcn_T)(BytePack * byte_data, Basis_bits & basis_bits);
    4142typedef void (*process_block_initialize_carries_fcn)();
    4243typedef void (*process_block_fcn)(const Basis_bits & basis_bits, Output & output);
     
    5354    , mShowLineNumberingOption(false)
    5455    , mParsedCodePointSet(nullptr)
     56    , mTransposeFcn(reinterpret_cast<transpose_fcn_T>(&s2p_do_block))
    5557    , mInitializeCarriesFcn(reinterpret_cast<process_block_initialize_carries_fcn>(process_block_initialize_carries))
    5658    , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
    57 
     59       
    5860    }
    59          
     61    GrepExecutor(void * s2p_fnptr, void * process_block_initialize_carries, void * process_block)
     62    : mCountOnlyOption(false)
     63    , mGetCodePointsOption(false)
     64    , mShowFileNameOption(false)
     65    , mShowLineNumberingOption(false)
     66    , mParsedCodePointSet(nullptr)
     67    , mTransposeFcn(reinterpret_cast<transpose_fcn_T>(s2p_fnptr))
     68    , mInitializeCarriesFcn(reinterpret_cast<process_block_initialize_carries_fcn>(process_block_initialize_carries))
     69    , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
     70       
     71    }
     72   
    6073    void setCountOnlyOption(bool doCount = true) {mCountOnlyOption = doCount;}
    6174    void setParseCodepointsOption() {
     
    8396    re::CC * mParsedCodePointSet;
    8497
     98    transpose_fcn_T mTransposeFcn;
    8599    process_block_initialize_carries_fcn mInitializeCarriesFcn;
    86100    process_block_fcn mProcessBlockFcn;
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r4871 r4900  
    2121#include <llvm/Support/SourceMgr.h>
    2222#include <llvm/Support/CommandLine.h>
     23#include <llvm/Support/Debug.h>
    2324#include <llvm/Support/TargetSelect.h>
    2425#include <llvm/Support/Host.h>
     26#include <llvm/IR/Verifier.h>
     27
     28#include <IDISA/s2p_gen.h>
    2529
    2630#include <re/re_re.h>
     
    136140    llvm::Function * icgrep_IR = nullptr;
    137141   
     142    Module * M = new Module("grepcode", getGlobalContext());
     143   
     144    IDISA::IDISA_Builder * idb = GetNativeIDISA_Builder(M, VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     145   
     146    gen_s2p_function(M, idb);
     147
     148   
    138149    if (IRFileName == "") {       
    139150        re::RE * re_ast = get_icgrep_RE();
     
    143154
    144155        pablo_function_passes(function);
    145         pablo::PabloCompiler pablo_compiler(VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     156       
     157       
     158        pablo::PabloCompiler pablo_compiler(M, idb);
    146159        try {
    147160            icgrep_IR = pablo_compiler.compile(function);
     
    157170        firstInputFile = 0;  // No regexp arguments; first positional argument is a file to process.
    158171        SMDiagnostic ParseErr;
    159         Module * M = parseIRFile(IRFileName, ParseErr, getGlobalContext()).release();
     172        M = parseIRFile(IRFileName, ParseErr, getGlobalContext()).release();
    160173        if (!M) {
    161174            throw std::runtime_error("Error in Parsing IR File " + IRFileName);
     
    163176        icgrep_IR = M->getFunction("process_block");
    164177    }
    165    
    166     llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(icgrep_IR);
    167    
    168     icgrep_Linking(icgrep_IR->getParent(), engine);
     178    llvm::Function * s2p_IR = M->getFunction("s2p_block");
     179
     180    if (s2p_IR == nullptr) {
     181        std::cerr << "No s2p_IR!\n";
     182        exit(1);
     183    }
     184   
     185    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(M);
     186   
     187    icgrep_Linking(M, engine);
     188    verifyModule(*M, &dbgs());
    169189   
    170190    // Ensure everything is ready to go.
     
    172192   
    173193    // TODO getPointerToFunction() is deprecated. Investigate getFunctionAddress(string name) instead.
    174     void * icgrep_init_carry_ptr = engine->getPointerToFunction(icgrep_IR->getParent()->getFunction("process_block_initialize_carries"));
     194    void * icgrep_init_carry_ptr = engine->getPointerToFunction(M->getFunction("process_block_initialize_carries"));
    175195    void * icgrep_MCptr = engine->getPointerToFunction(icgrep_IR);
     196    void * s2p_MCptr = engine->getPointerToFunction(s2p_IR);
     197    if (s2p_MCptr == nullptr) {
     198        std::cerr << "No s2p_MCptr!\n";
     199        exit(1);
     200    }
    176201   
    177202    if (icgrep_MCptr) {
    178         GrepExecutor grepEngine(icgrep_init_carry_ptr, icgrep_MCptr);
     203        GrepExecutor grepEngine(s2p_MCptr, icgrep_init_carry_ptr, icgrep_MCptr);
    179204        grepEngine.setCountOnlyOption(CountOnly);
    180205        grepEngine.setNormalizeLineBreaksOption(NormalizeLineBreaks);
  • 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;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4898 r4900  
    7171
    7272    typedef std::unordered_map<const pablo::PabloAST *, Value *>   ASTToValueMap;
    73     typedef std::vector<Value*>                                    CarryQueueVector;
    7473
    7574public:
    76     PabloCompiler(Type * bitBlockType);
     75    PabloCompiler(Module * m, IDISA::IDISA_Builder * b);
    7776    ~PabloCompiler();
    7877    Function * compile(pablo::PabloFunction * function);
    79     Function * compile(pablo::PabloFunction * function, Module *module);
    80     Module *getModule();
    8178private:
    8279    void GenerateFunction(PabloFunction & function);
     
    9390
    9491    ASTToValueMap                       mMarkerMap;
    95     CarryQueueVector                    mCarryInVector;
    96     CarryQueueVector                    mCarryOutVector;
    97 
    9892
    9993    Module *                            mMod;
     94    IDISA::IDISA_Builder *              iBuilder;
     95    Type* const                         mBitBlockType;
    10096
    10197    CarryManager *                      mCarryManager;
    10298
    103     Type* const                   mBitBlockType;
    104     IDISA::IDISA_Builder *              iBuilder;
    10599    PointerType*                        mInputType;
    106100
     
    118112};
    119113
    120 inline Module * PabloCompiler::getModule() {
    121     return mMod;
    122 }
    123 
    124114}
    125115
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4860 r4900  
    533533    pablo::PabloFunction * const nameSearchFunction = re2pablo_compiler(encoding, embedded);
    534534    pablo_function_passes(nameSearchFunction);
    535     pablo::PabloCompiler pablo_compiler(VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     535   
     536    Module * M = new Module("NamePattern", getGlobalContext());
     537    IDISA::IDISA_Builder * idb = GetNativeIDISA_Builder(M, VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     538    pablo::PabloCompiler pablo_compiler(M, idb);
    536539    llvm::Function * const nameSearchIR = pablo_compiler.compile(nameSearchFunction); // <- may throw error if parsing exception occurs.
    537540
    538     llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(nameSearchIR);   
    539     icgrep_Linking(nameSearchIR->getParent(), engine);
     541    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(M);   
     542    icgrep_Linking(M, engine);
    540543   
    541544    // Ensure everything is ready to go.
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r4899 r4900  
    2323#include <llvm/Support/Host.h>
    2424
     25#include <IDISA/idisa_avx_builder.h>
     26#include <IDISA/idisa_sse_builder.h>
    2527#ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    2628#include <UCD/precompiled_properties.h>
     
    202204
    203205
    204 ExecutionEngine * JIT_to_ExecutionEngine (llvm::Function * f) {
     206IDISA::IDISA_Builder * GetNativeIDISA_Builder(Module * mod, Type * bitBlockType) {
     207
     208#if (BLOCK_SIZE == 256)
     209    if ((strncmp(lGetSystemISA(), "avx2", 4) == 0)) {
     210        return new IDISA::IDISA_AVX2_Builder(mod, bitBlockType);
     211        //std::cerr << "IDISA_AVX2_Builder selected\n";
     212    }
     213    else{
     214        return new IDISA::IDISA_SSE2_Builder(mod, bitBlockType);
     215        //std::cerr << "Generic IDISA_Builder selected\n";
     216    }
     217#else   
     218    return new IDISA::IDISA_SSE2_Builder(mod, bitBlockType);
     219#endif
     220}
     221
     222
     223
     224ExecutionEngine * JIT_to_ExecutionEngine (Module * m) {
    205225
    206226    InitializeNativeTarget();
     
    209229
    210230    std::string errMessage;
    211     EngineBuilder builder(std::move(std::unique_ptr<Module>(f->getParent())));
     231    EngineBuilder builder(std::move(std::unique_ptr<Module>(m)));
    212232    builder.setErrorStr(&errMessage);
    213233    builder.setMCPU(sys::getHostCPUName());
     
    244264    for (Module::FunctionListType::iterator it = fns.begin(), it_end = fns.end(); it != it_end; ++it) {
    245265        std::string fnName = it->getName().str();
     266        if (fnName == "s2p_block") continue;
    246267        if (fnName == "process_block") continue;
    247268        if (fnName == "process_block_initialize_carries") continue;
  • icGREP/icgrep-devel/icgrep/toolchain.h

    r4801 r4900  
    1111#include <llvm/IR/Function.h>
    1212#include <llvm/IR/Module.h>
     13#include <llvm/IR/Type.h>
    1314#include <llvm/ExecutionEngine/ExecutionEngine.h>
    1415
    1516#include <re/re_re.h>
    1617#include <pablo/function.h>
     18#include <IDISA/idisa_builder.h>
    1719
     20IDISA::IDISA_Builder * GetNativeIDISA_Builder(Module * m, Type * bitBlockType);
    1821
    1922re::RE * regular_expression_passes(const Encoding encoding, re::RE * re_ast);
     
    2326void pablo_function_passes(pablo::PabloFunction * function);
    2427
    25 ExecutionEngine * JIT_to_ExecutionEngine (llvm::Function * f);
     28
     29
     30ExecutionEngine * JIT_to_ExecutionEngine (Module * m);
    2631
    2732void icgrep_Linking(Module * m, ExecutionEngine * e);
Note: See TracChangeset for help on using the changeset viewer.