Changeset 5436


Ignore:
Timestamp:
May 7, 2017, 4:34:48 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

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

Legend:

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

    r5435 r5436  
    746746}
    747747
    748 CBuilder::CBuilder(Module * const module, const unsigned GeneralRegisterWidthInBits)
    749 : IRBuilder<>(module->getContext())
    750 , mMod(module)
     748CBuilder::CBuilder(llvm::LLVMContext & C, const unsigned GeneralRegisterWidthInBits)
     749: IRBuilder<>(C)
     750, mMod(nullptr)
    751751, mCacheLineAlignment(64)
    752752, mSizeType(getIntNTy(GeneralRegisterWidthInBits))
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5435 r5436  
    2525public:
    2626
    27     CBuilder(llvm::Module * const module, const unsigned GeneralRegisterWidthInBits);
     27    CBuilder(llvm::LLVMContext & C, const unsigned GeneralRegisterWidthInBits);
    2828   
    2929    virtual ~CBuilder() {}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5374 r5436  
    99namespace IDISA {
    1010   
    11 std::string IDISA_AVX_Builder::getBuilderUniqueName() { return mBitBlockWidth != 256 ? "AVX_" + std::to_string(mBitBlockWidth) : "AVX";}
    12 std::string IDISA_AVX2_Builder::getBuilderUniqueName() { return mBitBlockWidth != 256 ? "AVX2_" + std::to_string(mBitBlockWidth) : "AVX2";}
     11std::string IDISA_AVX_Builder::getBuilderUniqueName() {
     12    return mBitBlockWidth != 256 ? "AVX_" + std::to_string(mBitBlockWidth) : "AVX";
     13}
    1314
    1415Value * IDISA_AVX_Builder::hsimd_signmask(unsigned fw, Value * a) {
     
    4344    // Otherwise use default SSE logic.
    4445    return IDISA_SSE_Builder::hsimd_signmask(fw, a);
     46}
     47
     48std::string IDISA_AVX2_Builder::getBuilderUniqueName() {
     49    return mBitBlockWidth != 256 ? "AVX2_" + std::to_string(mBitBlockWidth) : "AVX2";
    4550}
    4651   
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r5435 r5436  
    1616public:
    1717   
    18     IDISA_AVX_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    19     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    20     , IDISA_SSE2_Builder(module, archBitWidth, bitBlockWidth, stride)
     18    IDISA_AVX_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     19    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     20    , IDISA_SSE2_Builder(C, archBitWidth, bitBlockWidth, stride)
    2121    {
    2222
     
    3434public:
    3535   
    36     IDISA_AVX2_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    37     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    38     , IDISA_AVX_Builder(module, archBitWidth, bitBlockWidth, stride) {
     36    IDISA_AVX2_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     37    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     38    , IDISA_AVX_Builder(C, archBitWidth, bitBlockWidth, stride) {
    3939
    4040    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5435 r5436  
    2828    return CreateBitCast(a, ty);
    2929}
    30 
    31 std::string IDISA_Builder::getBitBlockTypeName() const {
    32     const auto type = getBitBlockType();
    33     if (type->isIntegerTy()) {
    34         return "i" + std::to_string(getBitBlockWidth());
    35     }
    36     assert("BitBlockType is neither integer nor vector" && type->isVectorTy());
    37     const auto fw = type->getScalarSizeInBits();
    38     return "v" + std::to_string(getBitBlockWidth() / fw) + "i" + std::to_string(fw);
    39 }
    40 
    4130
    4231void IDISA_Builder::CallPrintRegister(const std::string & name, Value * const value) {
     
    376365}
    377366
    378 void IDISA_Builder::initialize(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride) {
    379 
    380 }
    381 
    382 IDISA_Builder::IDISA_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    383 : CBuilder(module, archBitWidth)
     367IDISA_Builder::IDISA_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     368: CBuilder(C, archBitWidth)
    384369, mBitBlockWidth(bitBlockWidth)
    385370, mStride(stride)
    386 , mBitBlockType(VectorType::get(IntegerType::get(module->getContext(), 64), bitBlockWidth / 64))
     371, mBitBlockType(VectorType::get(IntegerType::get(C, 64), bitBlockWidth / 64))
    387372, mZeroInitializer(Constant::getNullValue(mBitBlockType))
    388373, mOneInitializer(Constant::getAllOnesValue(mBitBlockType))
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r5435 r5436  
    2020public:
    2121
    22     IDISA_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
     22    IDISA_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
    2323
    2424    virtual ~IDISA_Builder();
     
    2626    virtual std::string getBuilderUniqueName() = 0;  // A name uniquely identifying builder/bitBlockWidth/stride.
    2727   
    28     std::string getBitBlockTypeName() const;  // A short string such as v4i64 or i256.
    29 
    3028    llvm::Value * bitCast(llvm::Value * a) {
    3129        return CreateBitCast(a, mBitBlockType);
     
    129127
    130128    void CallPrintRegister(const std::string & regName, llvm::Value * const value);
    131    
    132 protected:
    133 
    134     void initialize(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
    135129
    136130protected:
    137     unsigned            mBitBlockWidth;
    138     unsigned            mStride;
     131    const unsigned              mBitBlockWidth;
     132    const unsigned              mStride;
     133    llvm::VectorType * const    mBitBlockType;
     134    llvm::Constant * const      mZeroInitializer;
     135    llvm::Constant * const      mOneInitializer;
    139136
    140     llvm::VectorType *  mBitBlockType;
    141     llvm::Constant *    mZeroInitializer;
    142     llvm::Constant *    mOneInitializer;
    143     llvm::Constant *    mPrintRegisterFunction;
     137    llvm::Constant *            mPrintRegisterFunction;
    144138};
    145139
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_i64_builder.h

    r5435 r5436  
    1616public:
    1717 
    18     IDISA_I64_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    19     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride) {
     18    IDISA_I64_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     19    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride) {
    2020
    2121    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.h

    r5435 r5436  
    1616public:
    1717   
    18     IDISA_NVPTX20_Builder(llvm::Module * const module, unsigned registerWidth, unsigned vectorWidth, unsigned groupSize)
    19     : IDISA_Builder(module, registerWidth, registerWidth, (vectorWidth * groupSize))
    20     , IDISA_I64_Builder(module, registerWidth, registerWidth, (vectorWidth * groupSize))
     18    IDISA_NVPTX20_Builder(llvm::LLVMContext & C, unsigned registerWidth, unsigned vectorWidth, unsigned groupSize)
     19    : IDISA_Builder(C, registerWidth, registerWidth, (vectorWidth * groupSize))
     20    , IDISA_I64_Builder(C, registerWidth, registerWidth, (vectorWidth * groupSize))
    2121    , groupThreads(groupSize) {
    2222        CreateGlobals();
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_sse_builder.h

    r5435 r5436  
    1717public:
    1818 
    19     IDISA_SSE_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    20     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride) {
     19    IDISA_SSE_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     20    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride) {
    2121
    2222    }
     
    3131public:
    3232 
    33     IDISA_SSE2_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    34     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    35     , IDISA_SSE_Builder(module, archBitWidth, bitBlockWidth, stride) {
     33    IDISA_SSE2_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     34    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     35    , IDISA_SSE_Builder(C, archBitWidth, bitBlockWidth, stride) {
    3636
    3737    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_target.cpp

    r5435 r5436  
    66#include "idisa_target.h"
    77#include <toolchain/toolchain.h>
     8#include <IR_Gen/idisa_sse_builder.h>
    89#include <IR_Gen/idisa_avx_builder.h>
    9 #include <IR_Gen/idisa_sse_builder.h>
    1010#include <IR_Gen/idisa_i64_builder.h>
    1111#include <IR_Gen/idisa_nvptx_builder.h>
     
    3535    if (codegen::BlockSize >= 256) {
    3636        if (hasAVX2) {
    37             return new KernelBuilderImpl<IDISA_AVX2_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     37            return new KernelBuilderImpl<IDISA_AVX2_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    3838        }
    3939    } else if (codegen::BlockSize == 64) {
    40         return new KernelBuilderImpl<IDISA_I64_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     40        return new KernelBuilderImpl<IDISA_I64_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    4141    }
    42     return new KernelBuilderImpl<IDISA_SSE2_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     42    return new KernelBuilderImpl<IDISA_SSE2_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    4343}
    4444
    4545KernelBuilder * GetIDISA_GPU_Builder(llvm::Module * const module) {
    46     return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(module, 64, 64, 64);
     46    return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(module->getContext(), 64, 64, 64);
    4747}
    4848
  • icGREP/icgrep-devel/icgrep/array-test.cpp

    r5435 r5436  
    55 */
    66
    7 #include <IR_Gen/idisa_builder.h>                  // for IDISA_Builder
    87#include <IR_Gen/idisa_target.h>                   // for GetIDISA_Builder
    98#include <kernels/source_kernel.h>
    109#include <kernels/s2p_kernel.h>                    // for S2PKernel
    1110#include <kernels/alignedprint.h>
     11#include <kernels/kernel_builder.h>
    1212#include <kernels/streamset.h>                     // for SingleBlockBuffer
    1313#include <llvm/ExecutionEngine/ExecutionEngine.h>  // for ExecutionEngine
     
    4646static cl::list<std::string> inputFiles(cl::Positional, cl::desc("<input file ...>"), cl::OneOrMore);
    4747
    48 void generate(PabloKernel * kernel) {
    49 
    50     PabloBuilder pb(kernel->getEntryBlock());
    51 
    52     Var * input = kernel->getInputStreamVar("input");
     48class ParenthesisMatchingKernel final: public pablo::PabloKernel {
     49public:
     50    ParenthesisMatchingKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned count);
     51    bool isCachable() const override { return true; }
     52    bool moduleIDisSignature() const override { return true; }
     53protected:
     54    void generatePabloMethod() override;
     55};
     56
     57ParenthesisMatchingKernel::ParenthesisMatchingKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const unsigned count)
     58: PabloKernel(b, "MatchParens",
     59    {Binding{b->getStreamSetTy(8), "input"}},
     60    {Binding{b->getStreamSetTy(count), "matches"}, Binding{b->getStreamTy(), "errors"}}) {
     61
     62}
     63
     64void ParenthesisMatchingKernel::generatePabloMethod() {
     65
     66    PabloBuilder pb(getEntryBlock());
     67
     68    Var * input = getInputStreamVar("input");
    5369
    5470    PabloAST * basis[8];
     
    7692    Var * const index = pb.createVar("i", pb.getInteger(0));
    7793
    78     Var * matches = kernel->getOutputStreamVar("matches");
     94    Var * matches = getOutputStreamVar("matches");
    7995
    8096//    PabloBuilder outer = PabloBuilder::Create(pb);
     
    119135    // Mark any closing paren that was not actually used to close an opener as an error.
    120136    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
    121     pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
     137    pb.createAssign(getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
    122138
    123139}
     
    128144    Module * const mod = iBuilder->getModule();
    129145
    130     Type * byteStreamTy = iBuilder->getStreamSetTy(1, 8);
    131 
    132     Function * const main = cast<Function>(mod->getOrInsertFunction("Main", iBuilder->getVoidTy(), byteStreamTy->getPointerTo(), iBuilder->getSizeTy(), nullptr));
     146    Type * const byteStreamTy = iBuilder->getStreamSetTy(1, 8);
     147
     148    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", iBuilder->getVoidTy(), iBuilder->getSizeTy(), nullptr));
    133149    main->setCallingConv(CallingConv::C);
    134     Function::arg_iterator args = main->arg_begin();
     150    auto args = main->arg_begin();
    135151   
    136     Value * const inputStream = &*(args++);
    137     inputStream->setName("input");
    138     Value * const fileSize = &*(args++);
    139     fileSize->setName("fileSize");
     152    Value * const fileDecriptor = &*(args++);
     153    fileDecriptor->setName("input");
    140154
    141155    const unsigned segmentSize = codegen::SegmentSize;
    142156    const unsigned bufferSegments = codegen::BufferSegments;
    143157   
    144     SourceBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    145 
    146     MMapSourceKernel mmapK(iBuilder, segmentSize);
    147     mmapK.setInitialArguments({fileSize});
    148 
    149     pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
    150 
    151     CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8), segmentSize * bufferSegments);
    152 
    153     S2PKernel s2pk(iBuilder);
    154     pxDriver.addKernelCall(s2pk, {&ByteStream}, {&BasisBits});
    155 
    156     PabloKernel bm(iBuilder, "MatchParens",
    157         {Binding{iBuilder->getStreamSetTy(8), "input"}},
    158         {Binding{iBuilder->getStreamSetTy(count), "matches"}, Binding{iBuilder->getStreamTy(), "errors"}});
    159 
    160     generate(&bm);
    161 
    162     ExpandableBuffer matches(iBuilder, iBuilder->getStreamSetTy(count), segmentSize * bufferSegments);
    163     SingleBlockBuffer errors(iBuilder, iBuilder->getStreamTy());
    164 
    165     pxDriver.addKernelCall(bm, {&BasisBits}, {&matches, &errors});
    166 
    167     PrintStreamSet printer(iBuilder, {"matches", "errors"});
    168     pxDriver.addKernelCall(printer, {&matches, &errors}, {});
     158    auto ByteStream = pxDriver.addBuffer(make_unique<SourceBuffer>(iBuilder, byteStreamTy));
     159
     160    auto mmapK = pxDriver.addKernelInstance(make_unique<MMapSourceKernel>(iBuilder, segmentSize));
     161    mmapK->setInitialArguments({fileDecriptor});
     162
     163    pxDriver.makeKernelCall(mmapK, {}, {ByteStream});
     164
     165    auto BasisBits = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, byteStreamTy, segmentSize * bufferSegments));
     166
     167    auto s2pk = pxDriver.addKernelInstance(make_unique<S2PKernel>(iBuilder));
     168    pxDriver.makeKernelCall(s2pk, {ByteStream}, {BasisBits});
     169
     170    auto bm = pxDriver.addKernelInstance(make_unique<ParenthesisMatchingKernel>(iBuilder, count));
     171
     172    auto matches = pxDriver.addBuffer(make_unique<ExpandableBuffer>(iBuilder, iBuilder->getStreamSetTy(count), segmentSize * bufferSegments));
     173
     174    auto errors = pxDriver.addBuffer(make_unique<SingleBlockBuffer>(iBuilder, iBuilder->getStreamTy()));
     175
     176    pxDriver.makeKernelCall(bm, {BasisBits}, {matches, errors});
     177
     178    auto printer = pxDriver.addKernelInstance(make_unique<PrintStreamSet>(iBuilder, std::vector<std::string>{"matches", "errors"}));
     179    pxDriver.makeKernelCall(printer, {&matches, &errors}, {});
    169180
    170181    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main, 0));
    171 
    172     BasisBits.allocateBuffer(iBuilder);
    173     matches.allocateBuffer(iBuilder);
    174     errors.allocateBuffer(iBuilder);
    175 
    176182    pxDriver.generatePipelineIR();
    177183    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/base64.cpp

    r5435 r5436  
    1212#include <llvm/Support/CommandLine.h>
    1313#include <toolchain/toolchain.h>
    14 #include <IR_Gen/idisa_builder.h>
    1514#include <IR_Gen/idisa_target.h>
    1615#include <kernels/source_kernel.h>
     
    1817#include <kernels/radix64.h>
    1918#include <kernels/stdout_kernel.h>
     19#include <kernels/kernel_builder.h>
    2020#include <boost/interprocess/mapped_region.hpp>
    2121#include <boost/interprocess/anonymous_shared_memory.hpp>
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5435 r5436  
    1616#include <pablo/pablo_compiler.h>
    1717#include <pablo/pablo_kernel.h>
    18 #include <IR_Gen/idisa_builder.h>
     18#include <kernels/kernel_builder.h>
    1919#include <IR_Gen/idisa_target.h>
    2020#include <kernels/streamset.h>
     
    158158}
    159159
    160 void buildPatternKernel(PabloKernel * const kernel, const std::vector<std::string> & patterns) {
    161     PabloBuilder entry(kernel->getEntryBlock());
    162 
    163     Var * pat = kernel->getInputStreamVar("pat");
    164 
     160class PatternKernel final: public pablo::PabloKernel {
     161public:
     162    PatternKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const std::vector<std::string> & patterns);
     163    bool isCachable() const override { return true; }
     164protected:
     165    void generatePabloMethod() override;
     166private:
     167    const std::vector<std::string> & mPatterns;
     168};
     169
     170PatternKernel::PatternKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const std::vector<std::string> & patterns)
     171: PabloKernel(b, "editd", {{b->getStreamSetTy(4), "pat"}}, {{b->getStreamSetTy(editDistance + 1), "E"}})
     172, mPatterns(patterns) {
     173}
     174
     175void PatternKernel::generatePabloMethod() {
     176    PabloBuilder entry(getEntryBlock());
     177    Var * const pat = getInputStreamVar("pat");
    165178    PabloAST * basisBits[4];
    166 
    167179    basisBits[0] = entry.createExtract(pat, 0, "A");
    168180    basisBits[1] = entry.createExtract(pat, 1, "C");
    169181    basisBits[2] = entry.createExtract(pat, 2, "T");
    170182    basisBits[3] = entry.createExtract(pat, 3, "G");
    171 
    172     re::Pattern_Compiler pattern_compiler(*kernel);
    173     pattern_compiler.compile(patterns, entry, basisBits, editDistance, optPosition, stepSize);
    174 
    175     pablo_function_passes(kernel);
     183    re::Pattern_Compiler pattern_compiler(*this);
     184    pattern_compiler.compile(mPatterns, entry, basisBits, editDistance, optPosition, stepSize);
    176185}
    177186
     
    217226    auto MatchResults = pxDriver.addBuffer(make_unique<SingleBlockBuffer>(idb, idb->getStreamSetTy(editDistance + 1)));
    218227
    219     auto editdk = pxDriver.addKernelInstance(make_unique<PabloKernel>(
    220         idb, "editd", std::vector<Binding>{{idb->getStreamSetTy(4), "pat"}}, std::vector<Binding>{{idb->getStreamSetTy(editDistance + 1), "E"}}
    221         ));
    222 
    223     editdk->setBuilder(idb.get());
    224     buildPatternKernel(reinterpret_cast<PabloKernel *>(editdk), patterns);
     228    auto editdk = pxDriver.addKernelInstance(make_unique<PatternKernel>(idb, patterns));
     229
    225230    pxDriver.makeKernelCall(editdk, {ChStream}, {MatchResults});
    226231
     
    235240}
    236241
    237 void buildPreprocessKernel(PabloKernel * const kernel) {
    238     assert (kernel->getBuilder());
    239     cc::CC_Compiler ccc(kernel, kernel->getInputStreamVar("basis"));
    240 
     242class PreprocessKernel final: public pablo::PabloKernel {
     243public:
     244    PreprocessKernel(const std::unique_ptr<kernel::KernelBuilder> & b);
     245    bool isCachable() const override { return true; }
     246protected:
     247    void generatePabloMethod() override;
     248};
     249
     250PreprocessKernel::PreprocessKernel(const std::unique_ptr<kernel::KernelBuilder> & b)
     251: PabloKernel(b, "ccc", {{b->getStreamSetTy(8), "basis"}}, {{b->getStreamSetTy(4), "pat"}}) {
     252
     253}
     254
     255void PreprocessKernel::generatePabloMethod() {
     256    cc::CC_Compiler ccc(this, getInputStreamVar("basis"));
    241257    PabloBuilder & pb = ccc.getBuilder();
    242 
    243258    PabloAST * A = ccc.compileCC(re::makeCC(re::makeCC(0x41), re::makeCC(0x61)), pb);
    244259    PabloAST * C = ccc.compileCC(re::makeCC(re::makeCC(0x43), re::makeCC(0x63)), pb);
    245260    PabloAST * T = ccc.compileCC(re::makeCC(re::makeCC(0x54), re::makeCC(0x74)), pb);
    246261    PabloAST * G = ccc.compileCC(re::makeCC(re::makeCC(0x47), re::makeCC(0x67)), pb);
    247 
    248     Var * const pat = kernel->getOutputStreamVar("pat");
    249 
     262    Var * const pat = getOutputStreamVar("pat");
    250263    pb.createAssign(pb.createExtract(pat, 0), A);
    251264    pb.createAssign(pb.createExtract(pat, 1), C);
    252265    pb.createAssign(pb.createExtract(pat, 2), T);
    253266    pb.createAssign(pb.createExtract(pat, 3), G);
    254 
    255     pablo_function_passes(kernel);
    256267}
    257268
     
    260271    auto & iBuilder = pxDriver.getBuilder();
    261272    Module * m = iBuilder->getModule();
    262     Type * mBitBlockType = iBuilder->getBitBlockType();
    263 
    264273
    265274    Type * const voidTy = iBuilder->getVoidTy();
    266275    Type * const int32Ty = iBuilder->getInt32Ty();
    267     Type * const outputType = PointerType::get(ArrayType::get(mBitBlockType, 4), 0);
     276    Type * const outputType = PointerType::get(ArrayType::get(iBuilder->getBitBlockType(), 4), 0);
    268277
    269278    Function * const main = cast<Function>(m->getOrInsertFunction("Main", voidTy, int32Ty, outputType, nullptr));
     
    286295    auto BasisBits = pxDriver.addBuffer(make_unique<SingleBlockBuffer>(iBuilder, iBuilder->getStreamSetTy(8)));
    287296    auto s2pk = pxDriver.addKernelInstance(make_unique<S2PKernel>(iBuilder));
     297
    288298    pxDriver.makeKernelCall(s2pk, {ByteStream}, {BasisBits});
    289299
    290300    auto CCResults = pxDriver.addExternalBuffer(make_unique<ExternalBuffer>(iBuilder, iBuilder->getStreamSetTy(4), outputStream));
    291301
    292     auto ccck = pxDriver.addKernelInstance(make_unique<PabloKernel>(
    293         iBuilder, "ccc", std::vector<Binding>{{iBuilder->getStreamSetTy(8), "basis"}}, std::vector<Binding>{{iBuilder->getStreamSetTy(4), "pat"}}
    294     ));
    295 
    296     ccck->setBuilder(iBuilder.get());
    297     buildPreprocessKernel(reinterpret_cast<PabloKernel *>(ccck));
     302    auto ccck = pxDriver.addKernelInstance(make_unique<PreprocessKernel>(iBuilder));
    298303
    299304    pxDriver.makeKernelCall(ccck, {BasisBits}, {CCResults});
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.cpp

    r5435 r5436  
    55
    66#include "editd_cpu_kernel.h"
    7 #include <IR_Gen/idisa_builder.h>
     7#include <kernels/kernel_builder.h>
    88#include <llvm/IR/Module.h>
    99
     
    8484}
    8585
    86 editdCPUKernel::editdCPUKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned dist, unsigned pattLen) :
     86editdCPUKernel::editdCPUKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned dist, unsigned pattLen) :
    8787BlockOrientedKernel("editd_cpu",
    8888             {Binding{b->getStreamSetTy(4), "CCStream"}},
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.h

    r5435 r5436  
    1717public:
    1818
    19     editdCPUKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned dist, unsigned pattLen);
     19    editdCPUKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned dist, unsigned pattLen);
    2020   
    2121
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.cpp

    r5435 r5436  
    44 */
    55#include "editd_gpu_kernel.h"
    6 #include <IR_Gen/idisa_builder.h>
     6#include <kernels/kernel_builder.h>
    77#include <llvm/IR/Module.h>
    88
     
    8080}
    8181
    82 editdGPUKernel::editdGPUKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned dist, unsigned pattLen) :
     82editdGPUKernel::editdGPUKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned dist, unsigned pattLen) :
    8383BlockOrientedKernel("editd_gpu",
    8484              {Binding{b->getStreamSetTy(4), "CCStream"}},
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.h

    r5435 r5436  
    1717public:
    1818   
    19     editdGPUKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned dist, unsigned pattLen);
     19    editdGPUKernel(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned dist, unsigned pattLen);
    2020   
    2121   
  • icGREP/icgrep-devel/icgrep/editd/editdscan_kernel.cpp

    r5435 r5436  
    66
    77#include "editdscan_kernel.h"
    8 #include <IR_Gen/idisa_builder.h>
     8#include <kernels/kernel_builder.h>
    99#include <llvm/IR/Module.h>
    1010
     
    8787}
    8888
    89 editdScanKernel::editdScanKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned dist) :
     89editdScanKernel::editdScanKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned dist) :
    9090BlockOrientedKernel("scanMatch",
    9191              {Binding{iBuilder->getStreamSetTy(dist + 1), "matchResults"}},
  • icGREP/icgrep-devel/icgrep/editd/editdscan_kernel.h

    r5435 r5436  
    1515class editdScanKernel : public BlockOrientedKernel {
    1616public:
    17     editdScanKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned dist);
     17    editdScanKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned dist);
    1818       
    1919private:
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5435 r5436  
    1111#include <llvm/Support/CommandLine.h>
    1212#include <boost/filesystem.hpp>
    13 #include <IR_Gen/idisa_builder.h>
    1413#include <UCD/UnicodeNameData.h>
    1514#include <UCD/resolve_properties.h>
     
    2322#include <kernels/scanmatchgen.h>
    2423#include <kernels/streamset.h>
     24#include <kernels/kernel_builder.h>
    2525#include <pablo/pablo_kernel.h>
    2626#include <re/re_cc.h>
  • icGREP/icgrep-devel/icgrep/kernels/alignedprint.cpp

    r5435 r5436  
    55
    66#include "alignedprint.h"
    7 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
    8 #include <llvm/IR/Module.h>
     7#include <kernels/kernel_builder.h>
    98
    109using namespace llvm;
     
    256255}
    257256
    258 PrintableBits::PrintableBits(const std::unique_ptr<IDISA::IDISA_Builder> & builder)
     257PrintableBits::PrintableBits(const std::unique_ptr<kernel::KernelBuilder> & builder)
    259258: BlockOrientedKernel("PrintableBits", {Binding{builder->getStreamSetTy(1), "bitStream"}}, {Binding{builder->getStreamSetTy(1, 8), "byteStream"}}, {}, {}, {}) {
    260259    setNoTerminateAttribute(true);
    261260}
    262261
    263 SelectStream::SelectStream(const std::unique_ptr<IDISA::IDISA_Builder> & builder, unsigned sizeInputStreamSet, unsigned streamIndex)
     262SelectStream::SelectStream(const std::unique_ptr<kernel::KernelBuilder> & builder, unsigned sizeInputStreamSet, unsigned streamIndex)
    264263: BlockOrientedKernel("SelectStream", {Binding{builder->getStreamSetTy(sizeInputStreamSet), "bitStreams"}}, {Binding{builder->getStreamSetTy(1, 1), "bitStream"}}, {}, {}, {}), mSizeInputStreamSet(sizeInputStreamSet), mStreamIndex(streamIndex) {
    265264    setNoTerminateAttribute(true);
     
    267266}
    268267
    269 PrintStreamSet::PrintStreamSet(const std::unique_ptr<IDISA::IDISA_Builder> & builder, std::vector<std::string> && names, const unsigned minWidth)
     268PrintStreamSet::PrintStreamSet(const std::unique_ptr<kernel::KernelBuilder> & builder, std::vector<std::string> && names, const unsigned minWidth)
    270269: BlockOrientedKernel("PrintableStreamSet", {}, {}, {}, {}, {})
    271270, mNames(names)
  • icGREP/icgrep-devel/icgrep/kernels/alignedprint.h

    r5435 r5436  
    1414class PrintableBits : public BlockOrientedKernel {
    1515public:
    16     PrintableBits(const std::unique_ptr<IDISA::IDISA_Builder> & builder);
     16    PrintableBits(const std::unique_ptr<kernel::KernelBuilder> & builder);
    1717    virtual ~PrintableBits() {}
    1818private:
     
    2222class SelectStream : public BlockOrientedKernel {
    2323public:
    24     SelectStream(const std::unique_ptr<IDISA::IDISA_Builder> & builder, unsigned sizeInputStreamSet, unsigned streamIndex);
     24    SelectStream(const std::unique_ptr<kernel::KernelBuilder> & builder, unsigned sizeInputStreamSet, unsigned streamIndex);
    2525    virtual ~SelectStream() {}
    2626private:
     
    3232class PrintStreamSet : public BlockOrientedKernel {
    3333public:
    34     PrintStreamSet(const std::unique_ptr<IDISA::IDISA_Builder> & builder, std::vector<std::string> && names, const unsigned minWidth = 16);
     34    PrintStreamSet(const std::unique_ptr<kernel::KernelBuilder> & builder, std::vector<std::string> && names, const unsigned minWidth = 16);
    3535    virtual ~PrintStreamSet() {}
    3636private:
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r5435 r5436  
    88#include <cc/cc_compiler.h>
    99#include <pablo/builder.hpp>
    10 #include <llvm/IR/Module.h>
     10#include <kernels/kernel_builder.h>
    1111
    1212using namespace cc;
     
    1717
    1818DirectCharacterClassKernelBuilder::DirectCharacterClassKernelBuilder(
    19         const std::unique_ptr<IDISA::IDISA_Builder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, unsigned codeUnitSize)
     19        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, unsigned codeUnitSize)
    2020: BlockOrientedKernel(std::move(ccSetName),
    2121              {Binding{b->getStreamSetTy(1, 8 * codeUnitSize), "codeUnitStream"}},
     
    7171
    7272ParabixCharacterClassKernelBuilder::ParabixCharacterClassKernelBuilder (
    73         const std::unique_ptr<IDISA::IDISA_Builder> & b, std::string ccSetName, const std::vector<CC *> & charClasses, unsigned codeUnitSize)
     73        const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, const std::vector<CC *> & charClasses, unsigned codeUnitSize)
    7474: PabloKernel(b, ccSetName +"_kernel", {Binding{b->getStreamSetTy(codeUnitSize), "basis"}})
    7575, mCharClasses(charClasses) {
     
    7979}
    8080
    81 void ParabixCharacterClassKernelBuilder::prepareKernel() {
     81void ParabixCharacterClassKernelBuilder::generatePabloMethod() {
    8282    CC_Compiler ccc(this, getInput(0));
    8383    auto & builder = ccc.getBuilder();
     
    8585        builder.createAssign(getOutput(i), ccc.compileCC("cc", mCharClasses[i], builder));
    8686    }
    87     PabloKernel::prepareKernel();
    8887}
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.h

    r5435 r5436  
    66#define CC_KERNEL_H
    77
    8 #include <pablo/pablo_kernel.h>  // for PabloKernel
    9 #include "kernel.h"              // for KernelBuilder
    10 #include <vector>                // for vector
    11 #include <string>                // for string
     8#include <pablo/pablo_kernel.h>
     9
    1210namespace IDISA { class IDISA_Builder; }
    1311namespace re { class CC; }
     
    1715class DirectCharacterClassKernelBuilder final : public BlockOrientedKernel {
    1816public:   
    19     DirectCharacterClassKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, unsigned codeUnitSize);
     17    DirectCharacterClassKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, std::vector<re::CC *> charClasses, unsigned codeUnitSize);
    2018    void generateDoBlockMethod() override;
    2119private:
     
    2725class ParabixCharacterClassKernelBuilder final : public pablo::PabloKernel {
    2826public:
    29     ParabixCharacterClassKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & b, std::string ccSetName, const std::vector<re::CC *> & charClasses, unsigned codeUnitSize);
     27    ParabixCharacterClassKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & b, std::string ccSetName, const std::vector<re::CC *> & charClasses, unsigned codeUnitSize);
    3028protected:
    31     void prepareKernel() override;
     29    void generatePabloMethod() override;
    3230private:
    3331    const std::vector<re::CC *> mCharClasses;
  • icGREP/icgrep-devel/icgrep/kernels/cc_scan_kernel.cpp

    r5435 r5436  
    66
    77#include "cc_scan_kernel.h"
    8 #include <IR_Gen/idisa_builder.h>
    98#include <llvm/IR/Module.h>
     9#include <kernels/kernel_builder.h>
     10
    1011
    1112using namespace llvm;
     
    9091}
    9192
    92 CCScanKernel::CCScanKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned streamNum) :
     93CCScanKernel::CCScanKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamNum) :
    9394BlockOrientedKernel("CCScan",
    9495              {Binding{iBuilder->getStreamSetTy(streamNum), "matchResults"}},
  • icGREP/icgrep-devel/icgrep/kernels/cc_scan_kernel.h

    r5435 r5436  
    1515class CCScanKernel : public BlockOrientedKernel {
    1616public:
    17     CCScanKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned streamNum);
     17    CCScanKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamNum);
    1818       
    1919private:
  • icGREP/icgrep-devel/icgrep/kernels/deletion.cpp

    r5435 r5436  
    55
    66#include "deletion.h"
    7 #include <IR_Gen/idisa_builder.h>
    8 #include <llvm/IR/Value.h>
    9 #include <llvm/IR/Module.h>
     7#include <kernels/kernel_builder.h>
    108#include <llvm/Support/raw_ostream.h>
    119
     
    8179}
    8280
    83 DeletionKernel::DeletionKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned fw, unsigned streamCount)
     81DeletionKernel::DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount)
    8482: BlockOrientedKernel("del" + std::to_string(fw) + "_" + std::to_string(streamCount),
    8583              {Binding{iBuilder->getStreamSetTy(streamCount), "inputStreamSet"},
     
    224222}
    225223
    226 DeleteByPEXTkernel::DeleteByPEXTkernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle)
     224DeleteByPEXTkernel::DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle)
    227225: BlockOrientedKernel("PEXTdel" + std::to_string(fw) + "_" + std::to_string(streamCount) + (shouldSwizzle ? "swiz" : "noswiz"),
    228226                  {Binding{iBuilder->getStreamSetTy(streamCount), "inputStreamSet"},
     
    262260//
    263261
    264 SwizzledBitstreamCompressByCount::SwizzledBitstreamCompressByCount(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth)
     262SwizzledBitstreamCompressByCount::SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth)
    265263: BlockOrientedKernel("swizzled_compress" + std::to_string(fieldWidth) + "_" + std::to_string(bitStreamCount),
    266264                     {Binding{iBuilder->getStreamSetTy(), "countsPerStride"}}, {}, {}, {}, {})
  • icGREP/icgrep-devel/icgrep/kernels/deletion.h

    r5435 r5436  
    2525class DeletionKernel final : public BlockOrientedKernel {
    2626public:
    27     DeletionKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned fw, unsigned streamCount);
     27    DeletionKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount);
    2828    bool isCachable() const override { return true; }
    2929    bool moduleIDisSignature() const override { return true; }
     
    3838class DeleteByPEXTkernel final : public BlockOrientedKernel {
    3939public:
    40     DeleteByPEXTkernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
     40    DeleteByPEXTkernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
    4141    bool isCachable() const override { return true; }
    4242    bool moduleIDisSignature() const override { return true; }
     
    5757class SwizzledBitstreamCompressByCount final : public BlockOrientedKernel {
    5858public:
    59     SwizzledBitstreamCompressByCount(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
     59    SwizzledBitstreamCompressByCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
    6060    bool isCachable() const override { return true; }
    6161    bool moduleIDisSignature() const override { return true; }
  • icGREP/icgrep-devel/icgrep/kernels/evenodd.cpp

    r5435 r5436  
    55
    66#include "evenodd.h"
    7 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
     7#include <kernels/kernel_builder.h>
    88
    99using namespace llvm;
     
    1818}
    1919
    20 EvenOddKernel::EvenOddKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder)
     20EvenOddKernel::EvenOddKernel(const std::unique_ptr<kernel::KernelBuilder> & builder)
    2121: BlockOrientedKernel("EvenOdd", {Binding{builder->getStreamSetTy(8, 1), "BasisBits"}}, {Binding{builder->getStreamSetTy(2, 1), "even_odd"}}, {}, {}, {}) {
    2222    setNoTerminateAttribute(true);
  • icGREP/icgrep-devel/icgrep/kernels/evenodd.h

    r5435 r5436  
    1414class EvenOddKernel : public BlockOrientedKernel {
    1515public:
    16     EvenOddKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder);
     16    EvenOddKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
    1717    virtual ~EvenOddKernel() {}
    1818private:
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5435 r5436  
    99#include <re/re_toolchain.h>
    1010#include <pablo/pablo_toolchain.h>
    11 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
    12 #include <pablo/builder.hpp>  // for PabloBuilder
     11#include <kernels/kernel_builder.h>
     12#include <pablo/builder.hpp>
    1313#include <pablo/pe_count.h>
    1414
     
    2929}
    3030
    31 ICgrepKernelBuilder::ICgrepKernelBuilder (const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, RE * const re)
     31ICgrepKernelBuilder::ICgrepKernelBuilder (const std::unique_ptr<kernel::KernelBuilder> & iBuilder, RE * const re)
    3232: PabloKernel(iBuilder, "",
    3333              {Binding{iBuilder->getStreamSetTy(8), "basis"}, Binding{iBuilder->getStreamSetTy(1, 1), "linebreak"}},
     
    4444}
    4545
    46 void ICgrepKernelBuilder::prepareKernel() {
     46void ICgrepKernelBuilder::generatePabloMethod() {
    4747    re2pablo_compiler(this, regular_expression_passes(mRE));
    48     pablo_function_passes(this);
    49     PabloKernel::prepareKernel();
    5048}
    5149
     
    5755}
    5856
    59 InvertMatchesKernel::InvertMatchesKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder)
     57InvertMatchesKernel::InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder)
    6058: BlockOrientedKernel("Invert", {Binding{builder->getStreamSetTy(1, 1), "matchedLines"}, Binding{builder->getStreamSetTy(1, 1), "lineBreaks"}}, {Binding{builder->getStreamSetTy(1, 1), "nonMatches"}}, {}, {}, {}) {
    6159    setNoTerminateAttribute(true);   
     
    6361
    6462
    65 PopcountKernel::PopcountKernel (const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     63PopcountKernel::PopcountKernel (const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    6664: PabloKernel(iBuilder, "Popcount",
    6765              {Binding{iBuilder->getStreamSetTy(1), "toCount"}},
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h

    r5435 r5436  
    1414class ICgrepKernelBuilder: public pablo::PabloKernel {
    1515public:
    16     ICgrepKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, re::RE * const re_ast);
    17    
     16    ICgrepKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast);   
    1817    std::string makeSignature() override;
    1918    bool isCachable() const override { return true; }
    20 
    21     void prepareKernel() override;
    22 
     19protected:
     20    void generatePabloMethod() override;
    2321private:
    2422    re::RE * const  mRE;
     
    2826class InvertMatchesKernel : public BlockOrientedKernel {
    2927public:
    30     InvertMatchesKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder);
     28    InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
    3129private:
    3230    void generateDoBlockMethod() override;
     
    3634class PopcountKernel : public pablo::PabloKernel {
    3735public:
    38     PopcountKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder);
     36    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
    3937};
    4038
  • icGREP/icgrep-devel/icgrep/kernels/interface.cpp

    r5435 r5436  
    1010#include <llvm/IR/Function.h>      // for Function, Function::arg_iterator
    1111#include <llvm/IR/Module.h>
    12 #include <IR_Gen/idisa_builder.h>
     12#include <kernels/kernel_builder.h>
    1313
    1414static const auto INIT_SUFFIX = "_Init";
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5435 r5436  
    1212
    1313namespace IDISA { class IDISA_Builder; }
     14namespace kernel { class KernelBuilder; }
    1415
    1516// Processing rate attributes are required for all stream set bindings for a kernel.
     
    137138        mInitialArguments.swap(args);
    138139    }
     140
    139141    llvm::Value * getInstance() const {
    140142        return mKernelInstance;
     
    149151    }
    150152
    151     IDISA::IDISA_Builder * getBuilder() const {
     153    kernel::KernelBuilder * getBuilder() const {
    152154        return iBuilder;
    153155    }
    154156
    155     void setBuilder(IDISA::IDISA_Builder * const builder) {
    156         iBuilder = builder;
     157    void setBuilder(const std::unique_ptr<kernel::KernelBuilder> & builder) {
     158        iBuilder = builder.get();
    157159    }
    158160
     
    210212protected:
    211213   
    212     IDISA::IDISA_Builder *                  iBuilder;
     214    kernel::KernelBuilder *                 iBuilder;
    213215    llvm::Module *                          mModule;
    214216
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5435 r5436  
    1717#include <kernels/streamset.h>
    1818#include <sstream>
     19#include <kernels/kernel_builder.h>
    1920
    2021using namespace llvm;
     
    5354    mKernelFields.push_back(type);
    5455    return index;
     56}
     57
     58// Get the value of a scalar field for the current instance.
     59llvm::Value * Kernel::getScalarFieldPtr(llvm::Value * index) const {
     60    return iBuilder->CreateGEP(getInstance(), {iBuilder->getInt32(0), index});
     61}
     62
     63llvm::Value * Kernel::getScalarFieldPtr(const std::string & fieldName) const {
     64    return getScalarFieldPtr(iBuilder->getInt32(getScalarIndex(fieldName)));
     65}
     66
     67llvm::Value * Kernel::getScalarField(const std::string & fieldName) const {
     68    return iBuilder->CreateLoad(getScalarFieldPtr(fieldName), fieldName);
     69}
     70
     71// Set the value of a scalar field for the current instance.
     72void Kernel::setScalarField(const std::string & fieldName, llvm::Value * value) const {
     73    iBuilder->CreateStore(value, getScalarFieldPtr(fieldName));
    5574}
    5675
     
    231250    setInstance(&*(args++));
    232251    iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), getInstance());
    233     for (auto binding : mScalarInputs) {
     252    for (const auto & binding : mScalarInputs) {
    234253        setScalarField(binding.name, &*(args++));
    235254    }
    236     for (auto binding : mStreamSetOutputs) {
     255    for (const auto & binding : mStreamSetOutputs) {
    237256        setConsumerLock(binding.name, &*(args++));
    238257    }
     
    550569}
    551570
    552 Argument * Kernel::getParameter(Function * const f, const std::string & name) const {
    553     for (auto & arg : f->getArgumentList()) {
    554         if (arg.getName().equals(name)) {
    555             return &arg;
    556         }
    557     }
    558     report_fatal_error(getName() + " does not have parameter " + name);
    559 }
     571//Argument * Kernel::getParameter(Function * const f, const std::string & name) const {
     572//    for (auto & arg : f->getArgumentList()) {
     573//        if (arg.getName().equals(name)) {
     574//            return &arg;
     575//        }
     576//    }
     577//    report_fatal_error(getName() + " does not have parameter " + name);
     578//}
    560579
    561580CallInst * Kernel::createDoSegmentCall(const std::vector<Value *> & args) const {
     
    650669            Kernel * const consumer = consumers[i];
    651670            assert ("all instances must be created prior to initialization of any instance" && consumer->getInstance());
    652             consumer->setBuilder(iBuilder);
    653671            Value * const segmentNoPtr = consumer->getScalarFieldPtr(LOGICAL_SEGMENT_NO_SCALAR);
    654672            iBuilder->CreateStore(segmentNoPtr, iBuilder->CreateGEP(consumerSegNoArray, { iBuilder->getInt32(0), iBuilder->getInt32(i) }));
     
    890908}
    891909
     910bool BlockOrientedKernel::useIndirectBr() const {
     911    return iBuilder->supportsIndirectBr();
     912}
     913
    892914void BlockOrientedKernel::CreateDoBlockMethodCall() {
    893915    if (useIndirectBr()) {
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5435 r5436  
    2222namespace kernel {
    2323   
     24class KernelBuilder;
     25
    2426class Kernel : public KernelInterface {
    2527protected:
     
    3234
    3335    friend class KernelBuilder;
    34     friend void ::generateSegmentParallelPipeline(IDISA::IDISA_Builder * const, const Kernels &);
    35     friend void ::generatePipelineLoop(IDISA::IDISA_Builder * const, const Kernels &);
    36     friend void ::generateParallelPipeline(IDISA::IDISA_Builder * const, const Kernels &);
     36    friend void ::generateSegmentParallelPipeline(const std::unique_ptr<kernel::KernelBuilder> &, const Kernels &);
     37    friend void ::generatePipelineLoop(const std::unique_ptr<kernel::KernelBuilder> &, const Kernels &);
     38    friend void ::generateParallelPipeline(const std::unique_ptr<kernel::KernelBuilder> &, const Kernels &);
    3739
    3840    static const std::string DO_BLOCK_SUFFIX;
     
    117119    void setTerminationSignal() const final;
    118120
    119     bool hasNoTerminateAttribute() const {
    120         return mNoTerminateAttribute;
    121     }
    122 
    123121    // Get the value of a scalar field for the current instance.
    124     llvm::Value * getScalarFieldPtr(llvm::Value * index) const {
    125         return iBuilder->CreateGEP(getInstance(), {iBuilder->getInt32(0), index});
    126     }
    127 
    128     llvm::Value * getScalarFieldPtr(const std::string & fieldName) const {
    129         return getScalarFieldPtr(iBuilder->getInt32(getScalarIndex(fieldName)));
    130     }
    131 
    132     llvm::Value * getScalarField(const std::string & fieldName) const {
    133         return iBuilder->CreateLoad(getScalarFieldPtr(fieldName), fieldName);
    134     }
     122    llvm::Value * getScalarFieldPtr(llvm::Value * index) const;
     123
     124    llvm::Value * getScalarFieldPtr(const std::string & fieldName) const;
     125
     126    llvm::Value * getScalarField(const std::string & fieldName) const;
    135127
    136128    // Set the value of a scalar field for the current instance.
    137     void setScalarField(const std::string & fieldName, llvm::Value * value) const {
    138         iBuilder->CreateStore(value, getScalarFieldPtr(fieldName));
    139     }
     129    void setScalarField(const std::string & fieldName, llvm::Value * value) const;
    140130
    141131    // Synchronization actions for executing a kernel for a particular logical segment.
     
    152142    void releaseLogicalSegmentNo(llvm::Value * nextSegNo) const;
    153143
    154     // Get a parameter by name.
    155     llvm::Argument * getParameter(llvm::Function * f, const std::string & name) const;
     144    bool hasNoTerminateAttribute() const {
     145        return mNoTerminateAttribute;
     146    }
    156147
    157148    const StreamSetBuffers & getStreamSetInputBuffers() const {
     
    378369private:
    379370
    380     virtual bool useIndirectBr() const {
    381         return iBuilder->supportsIndirectBr();
    382     }
     371    virtual bool useIndirectBr() const;
    383372
    384373    void writeDoBlockMethod();
  • icGREP/icgrep-devel/icgrep/kernels/kernel_builder.cpp

    r5435 r5436  
    5454            }
    5555        } else {
    56             Kernel::Port port; unsigned pfIndex;
    57             std::tie(port, pfIndex) = mKernel->getStreamPort(refSet);
     56            std::tie(port, index) = mKernel->getStreamPort(refSet);
    5857            if (port == Kernel::Port::Input) {
    5958               principalField = refSet + Kernel::PROCESSED_ITEM_COUNT_SUFFIX;
  • icGREP/icgrep-devel/icgrep/kernels/kernel_builder.h

    r5435 r5436  
    109109protected:
    110110
    111     KernelBuilder(llvm::Module * const module, unsigned registerWidth, unsigned blockWidth, unsigned stride)
    112     : IDISA::IDISA_Builder(module, registerWidth, blockWidth, stride) {
     111    KernelBuilder(llvm::LLVMContext & C, unsigned registerWidth, unsigned blockWidth, unsigned stride)
     112    : IDISA::IDISA_Builder(C, registerWidth, blockWidth, stride) {
    113113
    114114    }
     
    126126};
    127127
    128 template <class IBuilder>
    129 class KernelBuilderImpl final : public KernelBuilder, public IBuilder {
     128template <class SpecifiedArchitectureBuilder>
     129class KernelBuilderImpl final : public KernelBuilder, public SpecifiedArchitectureBuilder {
    130130public:
    131     KernelBuilderImpl(llvm::Module * const module, unsigned registerWidth, unsigned blockWidth, unsigned stride)
    132     : IDISA::IDISA_Builder(module, registerWidth, blockWidth, stride)
    133     , KernelBuilder(module, registerWidth, blockWidth, stride)
    134     , IBuilder(module, registerWidth, blockWidth, stride) {
     131    KernelBuilderImpl(llvm::LLVMContext & C, unsigned registerWidth, unsigned blockWidth, unsigned stride)
     132    : IDISA::IDISA_Builder(C, registerWidth, blockWidth, stride)
     133    , KernelBuilder(C, registerWidth, blockWidth, stride)
     134    , SpecifiedArchitectureBuilder(C, registerWidth, blockWidth, stride) {
    135135
    136136    }
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.cpp

    r5435 r5436  
    1212#include <cc/cc_compiler.h>
    1313#include <pablo/builder.hpp>
     14#include <kernels/kernel_builder.h>
    1415
    1516using namespace cc;
     
    1920using namespace llvm;
    2021
    21 #define UNICODE_LINE_BREAK (!AlgorithmOptionIsSet(DisableUnicodeLineBreak))
    22 
    23 LineBreakKernelBuilder::LineBreakKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned basisBitsCount)
     22LineBreakKernelBuilder::LineBreakKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & b, unsigned basisBitsCount)
    2423: PabloKernel(b, "lb", {Binding{b->getStreamSetTy(basisBitsCount), "basis"}}, {Binding{b->getStreamSetTy(1), "linebreak", Add1()}}) {
    2524
    2625}
    2726
    28 void LineBreakKernelBuilder::prepareKernel() {
     27void LineBreakKernelBuilder::generatePabloMethod() {
    2928
    3029    CC_Compiler ccc(this, getInput(0));
     
    7372
    7473    PabloAST * LB_chars = pb.createOr(LF_VT_FF_CR, NEL_LS_PS);
    75     PabloAST * UnicodeLineBreak = pb.createAnd(LB_chars, pb.createNot(crlf));  // count the CR, but not CRLF
     74    PabloAST * lb = nullptr;
     75    if (AlgorithmOptionIsSet(DisableUnicodeLineBreak)) {
     76        lb = LF;
     77    } else {
     78        lb = pb.createAnd(LB_chars, pb.createNot(crlf));  // count the CR, but not CRLF
     79    }
    7680
    77     PabloAST * lb = UNICODE_LINE_BREAK ? UnicodeLineBreak : LF;
    7881    PabloAST * unterminatedLineAtEOF = pb.createAtEOF(pb.createAdvance(pb.createNot(LB_chars), 1));
    7982    LineBreak = pb.createOr(lb, unterminatedLineAtEOF);
     
    8386    setLookAhead(1);
    8487#endif
    85 
    86     PabloKernel::prepareKernel();
    8788}
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.h

    r5435 r5436  
    88#include <pablo/pablo_kernel.h>  // for PabloKernel
    99
    10 namespace IDISA { class IDISA_Builder; }
     10namespace kernel { class KernelBuilder; }
    1111
    1212namespace kernel {
     
    1414class LineBreakKernelBuilder final : public pablo::PabloKernel {
    1515public:
    16     LineBreakKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned basisBitsCount);
     16    LineBreakKernelBuilder(const std::unique_ptr<KernelBuilder> & b, unsigned basisBitsCount);
    1717    bool isCachable() const override { return true; }
    1818    bool moduleIDisSignature() const override { return true; }
    1919protected:
    20     void prepareKernel() override;
     20    void generatePabloMethod() override;
    2121};
    2222
  • icGREP/icgrep-devel/icgrep/kernels/lz4_bytestream_decoder.cpp

    r5435 r5436  
    66
    77#include "lz4_bytestream_decoder.h"
     8#include <kernels/kernel_builder.h>
    89
    910using namespace llvm;
    1011using namespace kernel;
    11 
    12 
    13 namespace {
    1412
    1513Value * getInputPtr(IDISA::IDISA_Builder * const iBuilder, Value * blockStartPtr, Value * offset) {
     
    2321    return iBuilder->CreateSelect(iBuilder->CreateICmpULT(a, b), a, b);
    2422}
    25 
    26 }
    27 
    2823
    2924void LZ4ByteStreamDecoderKernel::generateDoBlockMethod() {
     
    192187
    193188
    194 LZ4ByteStreamDecoderKernel::LZ4ByteStreamDecoderKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, size_t bufferSize)
     189LZ4ByteStreamDecoderKernel::LZ4ByteStreamDecoderKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, size_t bufferSize)
    195190: BlockOrientedKernel("lz4ByteStreamDecoder",
    196191    // Inputs
  • icGREP/icgrep-devel/icgrep/kernels/lz4_bytestream_decoder.h

    r5435 r5436  
    1616class LZ4ByteStreamDecoderKernel : public BlockOrientedKernel {
    1717public:
    18     LZ4ByteStreamDecoderKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, size_t bufferSize);
     18    LZ4ByteStreamDecoderKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, size_t bufferSize);
    1919protected:
    2020    void generateDoBlockMethod() override;
  • icGREP/icgrep-devel/icgrep/kernels/lz4_index_decoder.cpp

    r5435 r5436  
    55 */
    66
    7 #include <llvm/IR/Constants.h>
    8 #include <llvm/IR/Function.h>
    9 #include <llvm/IR/Intrinsics.h>
    10 #include <llvm/IR/Instructions.h>
    11 #include <llvm/IR/Module.h>
    12 #include <IR_Gen/idisa_builder.h>
    13 
    14 #include <string>
    15 
    167#include "lz4_index_decoder.h"
     8#include <kernels/kernel_builder.h>
    179 
    1810using namespace llvm;
     
    714706}
    715707
    716 LZ4IndexDecoderKernel::LZ4IndexDecoderKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     708LZ4IndexDecoderKernel::LZ4IndexDecoderKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    717709: BlockOrientedKernel("lz4IndexDecoder",
    718710    // Inputs
  • icGREP/icgrep-devel/icgrep/kernels/lz4_index_decoder.h

    r5435 r5436  
    2424class LZ4IndexDecoderKernel : public BlockOrientedKernel {
    2525public:
    26     LZ4IndexDecoderKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     26    LZ4IndexDecoderKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    2727protected:
    2828    void generateDoBlockMethod() override;
  • icGREP/icgrep-devel/icgrep/kernels/match_count.cpp

    r5435 r5436  
    55
    66#include "match_count.h"
    7 #include <IR_Gen/idisa_builder.h>
    8 #include <llvm/IR/Value.h>
     7#include <kernels/kernel_builder.h>
    98
    109using namespace llvm;
     
    1211namespace kernel {
    1312
    14 MatchCount::MatchCount(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     13MatchCount::MatchCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    1514    : BlockOrientedKernel("matchCount",
    1615                        {Binding{iBuilder->getStreamSetTy(1, 1), "matches"}}, {}, {}, {Binding{iBuilder->getSizeTy(), "matchedLineCount"}}, {}) {
  • icGREP/icgrep-devel/icgrep/kernels/match_count.h

    r5435 r5436  
    1414public:
    1515   
    16     MatchCount(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     16    MatchCount(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    1717   
    1818protected:
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5435 r5436  
    11#include "p2s_kernel.h"
    2 #include "IR_Gen/idisa_builder.h"  // for IDISA_Builder
    3 #include "llvm/IR/Constant.h"      // for Constant
    4 #include "llvm/IR/Constants.h"     // for ConstantInt
    5 #include "llvm/IR/DerivedTypes.h"  // for PointerType, VectorType
    6 #include "llvm/IR/Function.h"      // for Function, Function::arg_iterator
    7 #include <llvm/IR/Module.h>
     2//#include "llvm/IR/Constant.h"      // for Constant
     3//#include "llvm/IR/Constants.h"     // for ConstantInt
     4//#include "llvm/IR/DerivedTypes.h"  // for PointerType, VectorType
     5//#include "llvm/IR/Function.h"      // for Function, Function::arg_iterator
     6//#include <llvm/IR/Module.h>
    87#include <kernels/streamset.h>
     8#include <kernels/kernel_builder.h>
     9
    910namespace llvm { class Value; }
    1011
     
    146147}
    147148
    148 P2SKernel::P2SKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     149P2SKernel::P2SKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    149150: BlockOrientedKernel("p2s",
    150151              {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}},
     
    153154}
    154155
    155 P2SKernelWithCompressedOutput::P2SKernelWithCompressedOutput(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     156P2SKernelWithCompressedOutput::P2SKernelWithCompressedOutput(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    156157: BlockOrientedKernel("p2s_compress",
    157158              {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
     
    160161}
    161162
    162 P2S16Kernel::P2S16Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     163P2S16Kernel::P2S16Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    163164: BlockOrientedKernel("p2s_16",
    164165              {Binding{iBuilder->getStreamSetTy(16, 1), "basisBits"}},
     
    168169
    169170
    170 P2S16KernelWithCompressedOutput::P2S16KernelWithCompressedOutput(const std::unique_ptr<IDISA::IDISA_Builder> & b)
     171P2S16KernelWithCompressedOutput::P2S16KernelWithCompressedOutput(const std::unique_ptr<kernel::KernelBuilder> & b)
    171172: BlockOrientedKernel("p2s_16_compress",
    172173              {Binding{b->getStreamSetTy(16, 1), "basisBits"}, Binding{b->getStreamSetTy(1, 1), "deletionCounts"}},
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.h

    r5435 r5436  
    1414class P2SKernel final : public BlockOrientedKernel {
    1515public:
    16     P2SKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     16    P2SKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    1717    bool isCachable() const override { return true; }
    1818    bool moduleIDisSignature() const override { return true; }
     
    2323class P2SKernelWithCompressedOutput final : public BlockOrientedKernel {
    2424public:
    25     P2SKernelWithCompressedOutput(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     25    P2SKernelWithCompressedOutput(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    2626    bool isCachable() const override { return true; }
    2727    bool moduleIDisSignature() const override { return true; }
     
    3232class P2S16Kernel final : public BlockOrientedKernel {
    3333public:
    34     P2S16Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     34    P2S16Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    3535    bool isCachable() const override { return true; }
    3636    bool moduleIDisSignature() const override { return true; }
     
    4141class P2S16KernelWithCompressedOutput final : public BlockOrientedKernel {
    4242public:
    43     P2S16KernelWithCompressedOutput(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     43    P2S16KernelWithCompressedOutput(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    4444    bool isCachable() const override { return true; }
    4545    bool moduleIDisSignature() const override { return true; }
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5435 r5436  
    55#include "radix64.h"
    66#include <kernels/streamset.h>
    7 #include <IR_Gen/idisa_builder.h>
    8 #include <llvm/IR/Module.h>
    9 #include <llvm/Support/raw_ostream.h>
     7#include <kernels/kernel_builder.h>
    108
    119using namespace llvm;
     
    450448}
    451449
    452 expand3_4Kernel::expand3_4Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     450expand3_4Kernel::expand3_4Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    453451: SegmentOrientedKernel("expand3_4",
    454452            {Binding{iBuilder->getStreamSetTy(1, 8), "sourceStream"}},
     
    457455}
    458456
    459 radix64Kernel::radix64Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     457radix64Kernel::radix64Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    460458: BlockOrientedKernel("radix64",
    461459            {Binding{iBuilder->getStreamSetTy(1, 8), "expandedStream"}},
     
    464462}
    465463
    466 base64Kernel::base64Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder)
     464base64Kernel::base64Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder)
    467465: BlockOrientedKernel("base64",
    468466            {Binding{iBuilder->getStreamSetTy(1, 8), "radix64stream"}},
  • icGREP/icgrep-devel/icgrep/kernels/radix64.h

    r5435 r5436  
    2121class expand3_4Kernel final : public SegmentOrientedKernel {
    2222public:   
    23     expand3_4Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     23    expand3_4Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    2424    bool isCachable() const override { return true; }
    2525    bool moduleIDisSignature() const override { return true; }
     
    3030class radix64Kernel final : public BlockOrientedKernel {
    3131public:
    32     radix64Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     32    radix64Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    3333    bool isCachable() const override { return true; }
    3434    bool moduleIDisSignature() const override { return true; }
     
    4141class base64Kernel final : public BlockOrientedKernel {
    4242public:
    43     base64Kernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     43    base64Kernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    4444    bool isCachable() const override { return true; }
    4545    bool moduleIDisSignature() const override { return true; }
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5435 r5436  
    55
    66#include "s2p_kernel.h"
    7 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
    8 #include <llvm/IR/Constant.h>      // for Constant
    9 #include <llvm/IR/Module.h>
     7#include <kernels/kernel_builder.h>
    108#include <llvm/Support/raw_ostream.h>
    11 namespace llvm { class BasicBlock; }
    12 namespace llvm { class Function; }
    13 namespace llvm { class Value; }
    149
    1510using namespace llvm;
     
    167162}
    168163
    169 S2PKernel::S2PKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, bool aligned)
     164S2PKernel::S2PKernel(const std::unique_ptr<KernelBuilder> & b, bool aligned)
    170165: BlockOrientedKernel(aligned ? "s2p" : "s2p_unaligned",
    171166    {Binding{b->getStreamSetTy(1, 8), "byteStream"}}, {Binding{b->getStreamSetTy(8, 1), "basisBits"}}, {}, {}, {}),
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.h

    r5435 r5436  
    1414class S2PKernel final : public BlockOrientedKernel {
    1515public:   
    16     S2PKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, bool aligned = true);
     16    S2PKernel(const std::unique_ptr<kernel::KernelBuilder> & b, bool aligned = true);
    1717    bool isCachable() const override { return true; }
    1818    bool moduleIDisSignature() const override { return true; }
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5435 r5436  
    66#include "scanmatchgen.h"
    77#include <llvm/IR/Intrinsics.h>
    8 #include <IR_Gen/idisa_builder.h>
    98#include <llvm/IR/Module.h>
     9#include <kernels/kernel_builder.h>
    1010
    1111using namespace llvm;
     
    189189}
    190190
    191 ScanMatchKernel::ScanMatchKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, GrepType grepType, const unsigned codeUnitWidth)
     191ScanMatchKernel::ScanMatchKernel(const std::unique_ptr<kernel::KernelBuilder> & b, GrepType grepType, const unsigned codeUnitWidth)
    192192: BlockOrientedKernel("scanMatch" + getGrepTypeId(grepType) + std::to_string(codeUnitWidth),
    193193    {Binding{b->getStreamSetTy(1, 1), "matchResult"}, Binding{b->getStreamSetTy(1, 1), "lineBreak"}, Binding{b->getStreamSetTy(1, 8), "InputStream", UnknownRate()}},
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.h

    r5435 r5436  
    1616class ScanMatchKernel final : public BlockOrientedKernel {
    1717public:
    18     ScanMatchKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b, const GrepType grepType, const unsigned codeUnitWidth);
     18    ScanMatchKernel(const std::unique_ptr<kernel::KernelBuilder> & b, const GrepType grepType, const unsigned codeUnitWidth);
    1919    bool isCachable() const override { return true; }
    2020    bool moduleIDisSignature() const override { return true; }
  • icGREP/icgrep-devel/icgrep/kernels/source_kernel.cpp

    r5435 r5436  
    44 */
    55#include "source_kernel.h"
    6 #include <llvm/IR/Module.h>
    7 #include <IR_Gen/idisa_builder.h>
     6#include <kernels/kernel_builder.h>
    87#include <kernels/streamset.h>
    98#include <sys/stat.h>
     
    141140}
    142141
    143 MMapSourceKernel::MMapSourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
     142MMapSourceKernel::MMapSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
    144143: SegmentOrientedKernel("mmap_source" + std::to_string(blocksPerSegment) + "@" + std::to_string(codeUnitWidth),
    145144{},
     
    281280}
    282281
    283 ReadSourceKernel::ReadSourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
     282ReadSourceKernel::ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
    284283: SegmentOrientedKernel("read_source"
    285284, {}
     
    326325}
    327326
    328 MemorySourceKernel::MemorySourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, Type * type, unsigned blocksPerSegment, unsigned codeUnitWidth)
     327MemorySourceKernel::MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, Type * type, unsigned blocksPerSegment, unsigned codeUnitWidth)
    329328: SegmentOrientedKernel("memory_source",
    330329    {},
  • icGREP/icgrep-devel/icgrep/kernels/source_kernel.h

    r5435 r5436  
    33
    44#include "kernel.h"
    5 namespace IDISA { class IDISA_Builder; }
     5namespace kernel { class KernelBuilder; }
    66
    77namespace kernel {
     
    1313class MMapSourceKernel final : public SegmentOrientedKernel {
    1414public:
    15     MMapSourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
     15    MMapSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
    1616    bool isCachable() const override { return true; }
    1717    bool moduleIDisSignature() const override { return true; }
     
    2929class ReadSourceKernel final : public SegmentOrientedKernel {
    3030public:
    31     ReadSourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
     31    ReadSourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
    3232    bool isCachable() const override { return true; }
    3333    bool moduleIDisSignature() const override { return true; }
     
    4343class MemorySourceKernel final : public SegmentOrientedKernel {
    4444public:
    45     MemorySourceKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, llvm::Type * type, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
     45    MemorySourceKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, llvm::Type * type, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8);
    4646    bool moduleIDisSignature() const override { return true; }
    4747protected:
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5435 r5436  
    55#include "stdout_kernel.h"
    66#include <llvm/IR/Module.h>
    7 #include <IR_Gen/idisa_builder.h>
     7#include <kernels/kernel_builder.h>
    88#include <kernels/streamset.h>
     9
    910namespace llvm { class Type; }
    1011
     
    6869}
    6970
    70 StdOutKernel::StdOutKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned codeUnitWidth)
     71StdOutKernel::StdOutKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned codeUnitWidth)
    7172: SegmentOrientedKernel("stdout", {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "codeUnitBuffer"}}, {}, {}, {}, {})
    7273, mCodeUnitWidth(codeUnitWidth) {
     
    165166}
    166167
    167 FileSink::FileSink(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned codeUnitWidth)
     168FileSink::FileSink(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned codeUnitWidth)
    168169: SegmentOrientedKernel("filesink", {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "codeUnitBuffer"}}, {},
    169170                {Binding{iBuilder->getInt8PtrTy(), "fileName"}}, {}, {Binding{iBuilder->getInt8PtrTy(), "tmpFileName"}, Binding{iBuilder->getInt32Ty(), "fileDes"}})
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.h

    r5435 r5436  
    1414class StdOutKernel : public SegmentOrientedKernel {
    1515public:
    16     StdOutKernel(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned codeUnitWidth);
     16    StdOutKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned codeUnitWidth);
    1717private:
    1818    void generateDoSegmentMethod() override final;
     
    2525class FileSink : public SegmentOrientedKernel {
    2626public: 
    27     FileSink(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned codeUnitWidth);
     27    FileSink(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned codeUnitWidth);
    2828protected:
    2929    void generateInitializeMethod() override final;
  • icGREP/icgrep-devel/icgrep/kernels/streams_merge.cpp

    r5435 r5436  
    55
    66#include "streams_merge.h"
    7 #include <IR_Gen/idisa_builder.h>
    8 #include <llvm/IR/Value.h>
     7#include <kernels/kernel_builder.h>
    98
    109using namespace llvm;
     
    1211namespace kernel {
    1312
    14 StreamsMerge::StreamsMerge(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned streamsPerSet, unsigned inputSets)
     13StreamsMerge::StreamsMerge(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamsPerSet, unsigned inputSets)
    1514: BlockOrientedKernel("streamsMerge", {}, {}, {}, {}, {})
    1615, mStreamsPerSet(streamsPerSet)
  • icGREP/icgrep-devel/icgrep/kernels/streams_merge.h

    r5435 r5436  
    1414public:
    1515   
    16     StreamsMerge(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned streamsPerSet=1, unsigned inputSets = 1);
     16    StreamsMerge(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamsPerSet=1, unsigned inputSets = 1);
    1717   
    1818protected:
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5435 r5436  
    55
    66#include "streamset.h"
    7 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
    8 #include <llvm/IR/BasicBlock.h>    // for BasicBlock
    9 #include <llvm/IR/Constants.h>     // for ConstantInt
    10 #include <llvm/IR/DataLayout.h>    // for DataLayout
    11 #include <llvm/IR/DerivedTypes.h>  // for IntegerType (ptr only), PointerType
    12 #include <llvm/IR/Module.h>        // for Module
    13 #include <llvm/IR/Value.h>         // for Value
     7#include <llvm/IR/Module.h>
    148#include <llvm/Support/raw_ostream.h>
    15 #include <llvm/IR/CFG.h>
    169#include <kernels/kernel.h>
     10#include <kernels/kernel_builder.h>
    1711#include <toolchain/toolchain.h>
    1812
     
    2418using namespace IDISA;
    2519
    26 ArrayType * resolveStreamSetType(const std::unique_ptr<IDISA_Builder> &b, Type * type);
    27 
    28 StructType * resolveExpandableStreamSetType(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type);
    29 
    30 void StreamSetBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     20ArrayType * resolveStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type);
     21
     22StructType * resolveExpandableStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type);
     23
     24void StreamSetBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    3125    if (LLVM_LIKELY(mStreamSetBufferPtr == nullptr)) {
    3226        Type * const ty = getType();
     
    139133}
    140134
    141 Value * StreamSetBuffer::getBaseAddress(IDISA::IDISA_Builder * const iBuilder, Value * self) const {
     135Value * StreamSetBuffer::getBaseAddress(IDISA::IDISA_Builder * const /* iBuilder */, Value * self) const {
    142136    return self;
    143137}
    144138
    145 void StreamSetBuffer::releaseBuffer(IDISA::IDISA_Builder * const iBuilder, Value * /* self */) const {
     139void StreamSetBuffer::releaseBuffer(IDISA::IDISA_Builder * const /* iBuilder */, Value * /* self */) const {
    146140    /* do nothing: memory is stack allocated */
    147141}
     
    220214
    221215// External File Buffer
    222 void ExternalBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> &) {
     216void ExternalBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> &) {
    223217    report_fatal_error("External buffers cannot be allocated.");
    224218}
     
    238232
    239233// CircularCopybackBuffer Buffer
    240 void CircularCopybackBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     234void CircularCopybackBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    241235    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType(), iBuilder->getSize(mBufferBlocks + mOverflowBlocks));
    242236}
     
    261255// SwizzledCopybackBuffer Buffer
    262256
    263 void SwizzledCopybackBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     257void SwizzledCopybackBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    264258    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType(), iBuilder->getSize(mBufferBlocks + mOverflowBlocks));
    265259}
     
    318312// Expandable Buffer
    319313
    320 void ExpandableBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     314void ExpandableBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    321315    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType());
    322316    Value * const capacityPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
     
    469463
    470464// Constructors
    471 SingleBlockBuffer::SingleBlockBuffer(const std::unique_ptr<IDISA::IDISA_Builder> &  b, Type * type)
     465SingleBlockBuffer::SingleBlockBuffer(const std::unique_ptr<kernel::KernelBuilder> &  b, Type * type)
    472466: StreamSetBuffer(BufferKind::BlockBuffer, type, resolveStreamSetType(b, type), 1, 0) {
    473467    mUniqueID = "S";
     
    475469}
    476470
    477 SourceBuffer::SourceBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, unsigned AddressSpace)
     471SourceBuffer::SourceBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, unsigned AddressSpace)
    478472: StreamSetBuffer(BufferKind::SourceBuffer, type, StructType::get(resolveStreamSetType(b, type)->getPointerTo(), b->getSizeTy(), nullptr), 0, AddressSpace) {
    479473    mUniqueID = "M"; // + std::to_string(bufferBlocks);
     
    481475}
    482476
    483 ExternalBuffer::ExternalBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, llvm::Value * addr, unsigned AddressSpace)
     477ExternalBuffer::ExternalBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, llvm::Value * addr, unsigned AddressSpace)
    484478: StreamSetBuffer(BufferKind::ExternalBuffer, type, resolveStreamSetType(b, type), 0, AddressSpace) {
    485479    mUniqueID = "E";
     
    488482}
    489483
    490 CircularBuffer::CircularBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
     484CircularBuffer::CircularBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
    491485: StreamSetBuffer(BufferKind::CircularBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace) {
    492486    mUniqueID = "C" + std::to_string(bufferBlocks);
     
    494488}
    495489
    496 CircularCopybackBuffer::CircularCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
     490CircularCopybackBuffer::CircularCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
    497491: StreamSetBuffer(BufferKind::CircularCopybackBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
    498492    mUniqueID = "CC" + std::to_string(bufferBlocks);
     
    501495}
    502496
    503 ExpandableBuffer::ExpandableBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
     497ExpandableBuffer::ExpandableBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
    504498: StreamSetBuffer(BufferKind::ExpandableBuffer, type, resolveExpandableStreamSetType(b, type), bufferBlocks, AddressSpace)
    505499, mInitialCapacity(type->getArrayNumElements()) {
     
    508502}
    509503
    510 SwizzledCopybackBuffer::SwizzledCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth, unsigned AddressSpace)
     504SwizzledCopybackBuffer::SwizzledCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth, unsigned AddressSpace)
    511505: StreamSetBuffer(BufferKind::SwizzledCopybackBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks), mFieldWidth(fieldwidth) {
    512506    mUniqueID = "SW" + std::to_string(fieldwidth) + ":" + std::to_string(bufferBlocks);
     
    533527
    534528// Helper routines
    535 ArrayType * resolveStreamSetType(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type) {
     529ArrayType * resolveStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type) {
    536530    unsigned numElements = 1;
    537531    if (LLVM_LIKELY(type->isArrayTy())) {
     
    557551}
    558552
    559 StructType * resolveExpandableStreamSetType(const std::unique_ptr<IDISA_Builder> & b, Type * type) {
     553StructType * resolveExpandableStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type) {
    560554    if (LLVM_LIKELY(type->isArrayTy())) {
    561555        type = type->getArrayElementType();
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5435 r5436  
    5858    }
    5959
    60     virtual void allocateBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder);
     60    virtual void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    6161
    6262    virtual void releaseBuffer(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const;
     
    121121
    122122protected:
    123     const BufferKind                        mBufferKind;
    124     llvm::Type * const                      mType;
    125     const size_t                            mBufferBlocks;
    126     const unsigned                          mAddressSpace;
    127     llvm::Value *                           mStreamSetBufferPtr;
    128     llvm::Type * const                      mBaseType;
    129     std::string                             mUniqueID;
     123    const BufferKind                 mBufferKind;
     124    llvm::Type * const               mType;
     125    const size_t                     mBufferBlocks;
     126    const unsigned                   mAddressSpace;
     127    llvm::Value *                    mStreamSetBufferPtr;
     128    llvm::Type * const               mBaseType;
     129    std::string                      mUniqueID;
    130130    kernel::Kernel *                 mProducer;
    131131    std::vector<kernel::Kernel *>    mConsumers;
     
    138138    }   
    139139
    140     SingleBlockBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type);
     140    SingleBlockBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type);
    141141
    142142protected:
     
    151151    }
    152152
    153     SourceBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, unsigned AddressSpace = 0);
     153    SourceBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, unsigned AddressSpace = 0);
    154154
    155155    void setBaseAddress(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * addr) const override;
     
    175175    }
    176176
    177     ExternalBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, llvm::Value * addr, unsigned AddressSpace = 0);
     177    ExternalBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, llvm::Value * addr, unsigned AddressSpace = 0);
    178178
    179179    // Can't allocate - raise an error. */
    180     void allocateBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder) override;
     180    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    181181
    182182    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * fromPosition, llvm::Value *) const override;
     
    192192    }
    193193   
    194     CircularBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
     194    CircularBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    195195
    196196protected:
     
    210210    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::CircularCopybackBuffer;}
    211211   
    212     CircularCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace = 0);
    213 
    214     void allocateBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder) override;
     212    CircularCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace = 0);
     213
     214    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    215215   
    216216    // Generate copyback code for the given number of overflowItems.
     
    232232    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::SwizzledCopybackBuffer;}
    233233   
    234     SwizzledCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth = 64, unsigned AddressSpace = 0);
    235    
    236     void allocateBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder) override;
     234    SwizzledCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth = 64, unsigned AddressSpace = 0);
     235   
     236    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    237237   
    238238    void createBlockAlignedCopy(IDISA::IDISA_Builder * const iBuilder, llvm::Value * targetBlockPtr, llvm::Value * sourceBlockPtr, llvm::Value * itemsToCopy) const override;
     
    260260    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::ExpandableBuffer;}
    261261
    262     ExpandableBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
     262    ExpandableBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    263263
    264264    llvm::Value * getStreamBlockPtr(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, const bool readOnly) const override;
     
    268268    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition) const override;
    269269
    270     void allocateBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder) override;
     270    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    271271
    272272    llvm::Value * getStreamSetCount(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const override;
  • icGREP/icgrep-devel/icgrep/kernels/swizzle.cpp

    r5435 r5436  
    55
    66#include "swizzle.h"
    7 #include <IR_Gen/idisa_builder.h>
    8 #include <llvm/IR/Value.h>
     7#include <kernels/kernel_builder.h>
    98
    109using namespace llvm;
     
    1211namespace kernel {
    1312
    14 SwizzleGenerator::SwizzleGenerator(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned bitStreamCount, unsigned outputSets, unsigned inputSets, unsigned fieldWidth)
     13SwizzleGenerator::SwizzleGenerator(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned outputSets, unsigned inputSets, unsigned fieldWidth)
    1514: BlockOrientedKernel("swizzle" + std::to_string(fieldWidth) + ":" + std::to_string(bitStreamCount), {}, {}, {}, {}, {})
    1615, mBitStreamCount(bitStreamCount)
  • icGREP/icgrep-devel/icgrep/kernels/swizzle.h

    r5435 r5436  
    5252public:
    5353   
    54     SwizzleGenerator(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder, unsigned bitStreamCount, unsigned outputSets = 1, unsigned inputSets = 1, unsigned fieldWidth = 64);
     54    SwizzleGenerator(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned bitStreamCount, unsigned outputSets = 1, unsigned inputSets = 1, unsigned fieldWidth = 64);
    5555   
    5656protected:
  • icGREP/icgrep-devel/icgrep/lz4d.cpp

    r5435 r5436  
    1313#include <llvm/Support/Signals.h>
    1414#include <llvm/Support/ManagedStatic.h>
    15 #include <IR_Gen/idisa_builder.h>
    1615#include <IR_Gen/idisa_target.h>
    1716#include <boost/filesystem.hpp>
     
    2827#include <kernels/lz4_index_decoder.h>
    2928#include <kernels/lz4_bytestream_decoder.h>
     29
     30#include <kernels/kernel_builder.h>
    3031
    3132#include <string>
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r5329 r5436  
    202202//    }
    203203   
    204     llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    205         return mPb->getStreamSetTy(NumElements, FieldWidth);
    206     }
     204//    llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
     205//        return mPb->getStreamSetTy(NumElements, FieldWidth);
     206//    }
    207207   
    208208    /// Statement Iterator Wrappers
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r5371 r5436  
    2424#include <pablo/ps_assign.h>
    2525#include <pablo/pablo_kernel.h>
     26#include <kernels/kernel_builder.h>
    2627#include <llvm/Support/raw_os_ostream.h>
    2728
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5435 r5436  
    277277    Phi * createPhi(llvm::Type * type);
    278278
    279     llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    280         return mParent->getBuilder()->getStreamSetTy(NumElements, FieldWidth);
    281     }
    282    
    283279    PabloBlock * getPredecessor() const;
    284280
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5435 r5436  
    1111#include <pablo/pe_ones.h>
    1212#include <pablo/pablo_toolchain.h>
     13#include <kernels/kernel_builder.h>
    1314#include "llvm/Support/Debug.h"
    1415
     
    119120
    120121void PabloKernel::prepareKernel() {
     122    if (DebugOptionIsSet(DumpTrace)) {
     123        setName(getName() + "_DumpTrace");
     124    }
     125    generatePabloMethod();
     126    pablo_function_passes(this);
    121127    mPabloCompiler->initializeKernelData(iBuilder);
    122128    BlockOrientedKernel::prepareKernel();
     
    127133}
    128134
    129 void PabloKernel::generateFinalBlockMethod(Value * remainingBytes) {
     135void PabloKernel::generateFinalBlockMethod(Value * const remainingBytes) {
    130136    // Standard Pablo convention for final block processing: set a bit marking
    131137    // the position just past EOF, as well as a mask marking all positions past EOF.
     
    135141}
    136142
    137 PabloKernel::PabloKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b,
     143String * PabloKernel::makeName(const llvm::StringRef & prefix) const {
     144    return mSymbolTable->makeString(iBuilder->getContext(), prefix);
     145}
     146
     147Integer * PabloKernel::getInteger(const int64_t value) const {
     148    return mSymbolTable->getInteger(iBuilder->getContext(), value);
     149}
     150
     151PabloKernel::PabloKernel(const std::unique_ptr<KernelBuilder> & b,
    138152                         std::string kernelName,
    139153                         std::vector<Binding> stream_inputs,
     
    170184        result->setScalar();
    171185    }
    172     if (DebugOptionIsSet(DumpTrace)) {
    173         setName(getName() + "_DumpTrace");
    174     }
    175186}
    176187
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5435 r5436  
    1414#include <boost/container/flat_map.hpp>
    1515
    16 namespace IDISA { class IDISA_Builder; }
    1716namespace llvm { class Type; }
    1817namespace pablo { class Integer; }
     
    4645    }
    4746
    48     PabloKernel(const std::unique_ptr<IDISA::IDISA_Builder> & builder, std::string kernelName,
     47    PabloKernel(const std::unique_ptr<kernel::KernelBuilder> & builder, std::string kernelName,
    4948                std::vector<Binding> stream_inputs = {},
    5049                std::vector<Binding> stream_outputs = {},
     
    126125protected:
    127126
     127    virtual void generatePabloMethod() = 0;
     128
     129    String * makeName(const llvm::StringRef & prefix) const;
     130
     131    Integer * getInteger(const int64_t value) const;
     132
    128133    // A custom method for preparing kernel declarations is needed,
    129134    // so that the carry data requirements may be accommodated before
    130135    // finalizing the KernelStateType.
    131     void prepareKernel()  override;
     136    void prepareKernel() final;
    132137
    133     void generateDoBlockMethod() override final;
     138    void generateDoBlockMethod() final;
    134139
    135140    // The default method for Pablo final block processing sets the
    136141    // EOFmark bit and then calls the standard DoBlock function.
    137142    // This may be overridden for specialized processing.
    138     virtual void generateFinalBlockMethod(llvm::Value * remainingBytes) override final;
    139 
    140     inline String * makeName(const llvm::StringRef & prefix) const {
    141         return mSymbolTable->makeString(iBuilder->getContext(), prefix);
    142     }
    143 
    144     inline Integer * getInteger(const int64_t value) const {
    145         return mSymbolTable->getInteger(iBuilder->getContext(), value);
    146     }
     143    void generateFinalBlockMethod(llvm::Value * remainingBytes) final;
    147144
    148145private:
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.cpp

    r5295 r5436  
    6464bool DebugOptionIsSet(PabloDebugFlags flag) {return DebugOptions.isSet(flag);}
    6565   
    66    
    67    
     66
     67
    6868#ifdef PRINT_TIMING_INFORMATION
    6969#define READ_CYCLE_COUNTER(name) name = read_cycle_counter();
     
    169169
    170170void pablo_function_passes(PabloKernel * kernel) {
    171    
     171
    172172    if (DebugOptions.isSet(ShowPablo)) {
    173173        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
     
    175175        PabloPrinter::print(kernel, errs());
    176176    }
    177    
     177
    178178    #ifndef NDEBUG
    179179    PabloVerifier::verify(kernel, "creation");
  • icGREP/icgrep-devel/icgrep/toolchain/pipeline.cpp

    r5435 r5436  
    1111#include <boost/container/flat_set.hpp>
    1212#include <boost/container/flat_map.hpp>
     13#include <kernels/kernel_builder.h>
    1314
    1415using namespace kernel;
     
    1617using namespace llvm;
    1718
     19
    1820template <typename Value>
    1921using StreamSetBufferMap = boost::container::flat_map<const StreamSetBuffer *, Value>;
     
    2224using FlatSet = boost::container::flat_set<Value>;
    2325
    24 Function * makeThreadFunction(IDISA::IDISA_Builder * const b, const std::string & name) {
     26Function * makeThreadFunction(const std::unique_ptr<kernel::KernelBuilder> & b, const std::string & name) {
    2527    Function * const f = Function::Create(FunctionType::get(b->getVoidTy(), {b->getVoidPtrTy()}, false), Function::InternalLinkage, name, b->getModule());
    2628    f->setCallingConv(CallingConv::C);
     
    3840 * fashion such that processing of segment S_i by the full pipeline is carried out by thread i mod T.
    3941 ** ------------------------------------------------------------------------------------------------------------- */
    40 void generateSegmentParallelPipeline(IDISA::IDISA_Builder * const iBuilder, const std::vector<Kernel *> & kernels) {
     42void generateSegmentParallelPipeline(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<Kernel *> & kernels) {
    4143
    4244    const unsigned n = kernels.size();
     
    256258 * @brief generateParallelPipeline
    257259 ** ------------------------------------------------------------------------------------------------------------- */
    258 void generateParallelPipeline(IDISA::IDISA_Builder * const iBuilder, const std::vector<Kernel *> &kernels) {
     260void generateParallelPipeline(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<Kernel *> &kernels) {
    259261
    260262    Module * const m = iBuilder->getModule();
     
    450452 * @brief generatePipelineLoop
    451453 ** ------------------------------------------------------------------------------------------------------------- */
    452 void generatePipelineLoop(IDISA::IDISA_Builder * const iBuilder, const std::vector<Kernel *> & kernels) {
     454void generatePipelineLoop(const std::unique_ptr<KernelBuilder> & iBuilder, const std::vector<Kernel *> & kernels) {
    453455
    454456    BasicBlock * entryBlock = iBuilder->GetInsertBlock();
  • icGREP/icgrep-devel/icgrep/toolchain/pipeline.h

    r5435 r5436  
    1111namespace IDISA { class IDISA_Builder; }
    1212namespace kernel { class Kernel; }
     13namespace kernel { class KernelBuilder; }
    1314
    14 void generateSegmentParallelPipeline(IDISA::IDISA_Builder * const iBuilder, const std::vector<kernel::Kernel *> & kernels);
    15 void generatePipelineLoop(IDISA::IDISA_Builder * const iBuilder, const std::vector<kernel::Kernel *> & kernels);
    16 void generateParallelPipeline(IDISA::IDISA_Builder * const iBuilder, const std::vector<kernel::Kernel *> & kernels);
     15void generateSegmentParallelPipeline(const std::unique_ptr<kernel::KernelBuilder> &iBuilder, const std::vector<kernel::Kernel *> & kernels);
     16void generateParallelPipeline(const std::unique_ptr<kernel::KernelBuilder> &iBuilder, const std::vector<kernel::Kernel *> & kernels);
     17void generatePipelineLoop(const std::unique_ptr<kernel::KernelBuilder> &iBuilder, const std::vector<kernel::Kernel *> & kernels);
    1718
    1819#endif // PIPELINE_H
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.cpp

    r5435 r5436  
    2929#include <toolchain/object_cache.h>
    3030#include <toolchain/pipeline.h>
     31#include <kernels/kernel_builder.h>
    3132#include <kernels/kernel.h>
    3233#include <sys/stat.h>
     
    181182    iBuilder.reset(IDISA::GetIDISA_Builder(mMainModule));
    182183    iBuilder->setDriver(this);
     184    iBuilder->setModule(mMainModule);
    183185}
    184186
     
    199201}
    200202
    201 void ParabixDriver::addKernelCall(kernel::Kernel & kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
     203void ParabixDriver::addKernelCall(kernel::Kernel & kb, const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    202204    assert ("addKernelCall or makeKernelCall was already run on this kernel." && (kb.getModule() == nullptr));
    203205    mPipeline.emplace_back(&kb);
    204     kb.setBuilder(iBuilder.get());
     206    assert (mMainModule);
     207    kb.setBuilder(iBuilder);
    205208    kb.createKernelStub(inputs, outputs);
    206209}
    207210
    208 void ParabixDriver::makeKernelCall(kernel::Kernel * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) {
     211void ParabixDriver::makeKernelCall(kernel::Kernel * kb, const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
    209212    assert ("addKernelCall or makeKernelCall was already run on this kernel." && (kb->getModule() == nullptr));
    210     mPipeline.emplace_back(kb);
    211     kb->setBuilder(iBuilder.get());
     213    mPipeline.emplace_back(kb);   
     214    kb->setBuilder(iBuilder);
    212215    kb->createKernelStub(inputs, outputs);
    213216}
     
    227230    // note: instantiation of all kernels must occur prior to initialization
    228231    for (const auto & k : mPipeline) {
    229         k->setBuilder(iBuilder.get());
    230232        k->addKernelDeclarations();
    231233    }
    232234    for (const auto & k : mPipeline) {
    233         k->setBuilder(iBuilder.get());
    234235        k->createInstance();
    235236    }
    236237    for (const auto & k : mPipeline) {
    237         k->setBuilder(iBuilder.get());
    238238        k->initializeInstance();
    239239    }
    240240    if (codegen::pipelineParallel) {
    241         generateParallelPipeline(iBuilder.get(), mPipeline);
     241        generateParallelPipeline(iBuilder, mPipeline);
    242242    } else if (codegen::segmentPipelineParallel) {
    243         generateSegmentParallelPipeline(iBuilder.get(), mPipeline);
     243        generateSegmentParallelPipeline(iBuilder, mPipeline);
    244244    } else {
    245245        codegen::ThreadNum = 1;
    246         generatePipelineLoop(iBuilder.get(), mPipeline);
     246        generatePipelineLoop(iBuilder, mPipeline);
    247247    }
    248248    for (const auto & k : mPipeline) {
    249         k->setBuilder(iBuilder.get());
     249        k->setBuilder(iBuilder);
    250250        k->finalizeInstance();
    251251    }
     
    310310        if (uncachedObject) {
    311311            iBuilder->setModule(m);
    312             k->setBuilder(iBuilder.get());
     312            k->setBuilder(iBuilder);
    313313            k->generateKernel();
    314314            PM.run(*m);
     
    327327    } catch (...) { m->dump(); throw; }
    328328    #endif
     329}
     330
     331const std::unique_ptr<kernel::KernelBuilder> & ParabixDriver::getBuilder() {
     332    return iBuilder;
    329333}
    330334
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.h

    r5435 r5436  
    1010#include <IR_Gen/FunctionTypeBuilder.h>
    1111#include <kernels/kernel.h>
    12 #include <kernels/kernel_builder.h>
    1312#include <kernels/streamset.h>
    1413
    1514namespace llvm { class ExecutionEngine; }
     15namespace llvm { class Function; }
    1616namespace llvm { class Module; }
    1717namespace llvm { class TargetMachine; }
    1818namespace llvm { class formatted_raw_ostream; }
    1919namespace llvm { namespace cl { class OptionCategory; } }
     20namespace kernel { class Kernel; }
     21namespace kernel { class KernelBuilder; }
    2022namespace IDISA { class IDISA_Builder; }
    21 namespace kernel { class Kernel; }
    2223
    2324class ParabixObjectCache;
     
    6768    ~ParabixDriver();
    6869   
    69     const std::unique_ptr<IDISA::IDISA_Builder> & getBuilder() { return iBuilder; }
     70    const std::unique_ptr<kernel::KernelBuilder> & getBuilder();
    7071   
    7172    parabix::ExternalBuffer * addExternalBuffer(std::unique_ptr<parabix::ExternalBuffer> b);
     
    9394
    9495private:
    95     std::unique_ptr<llvm::LLVMContext>      mContext;
    96     llvm::Module * const                    mMainModule;
    97     std::unique_ptr<IDISA::IDISA_Builder>   iBuilder;
    98     llvm::TargetMachine *                   mTarget;
    99     llvm::ExecutionEngine *                 mEngine;
    100     ParabixObjectCache *                    mCache;
     96    std::unique_ptr<llvm::LLVMContext>                      mContext;
     97    llvm::Module * const                                    mMainModule;
     98    std::unique_ptr<kernel::KernelBuilder>                  iBuilder;
     99    llvm::TargetMachine *                                   mTarget;
     100    llvm::ExecutionEngine *                                 mEngine;
     101    ParabixObjectCache *                                    mCache;
    101102
    102     std::vector<kernel::Kernel *>    mPipeline;
     103    std::vector<kernel::Kernel *>                           mPipeline;
    103104    // Owned kernels and buffers that will persist with this ParabixDriver instance.
    104     std::vector<std::unique_ptr<kernel::Kernel>> mOwnedKernels;
    105     std::vector<std::unique_ptr<parabix::StreamSetBuffer>> mOwnedBuffers;
     105    std::vector<std::unique_ptr<kernel::Kernel>>            mOwnedKernels;
     106    std::vector<std::unique_ptr<parabix::StreamSetBuffer>>  mOwnedBuffers;
    106107};
    107108
    108109template <typename ExternalFunctionType>
    109110llvm::Function * ParabixDriver::LinkFunction(kernel::Kernel & kb, llvm::StringRef name, ExternalFunctionType * functionPtr) const {
    110     llvm::FunctionType * const type = FunctionTypeBuilder<ExternalFunctionType>::get(iBuilder->getContext());
     111    llvm::FunctionType * const type = FunctionTypeBuilder<ExternalFunctionType>::get(*mContext.get());
    111112    assert ("FunctionTypeBuilder did not resolve a function type." && type);
    112113    return LinkFunction(kb.getModule(), name, type, reinterpret_cast<void *>(functionPtr));
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5435 r5436  
    55 */
    66
    7 #include <IR_Gen/idisa_builder.h>                  // for IDISA_Builder
    87#include <IR_Gen/idisa_target.h>                   // for GetIDISA_Builder
    98#include <cc/cc_compiler.h>                        // for CC_Compiler
     
    2221#include <pablo/pablo_kernel.h>                    // for PabloKernel
    2322#include <pablo/pablo_toolchain.h>                 // for pablo_function_passes
     23#include <kernels/kernel_builder.h>
    2424#include <pablo/pe_zeroes.h>
    2525#include <toolchain/toolchain.h>
     
    4848static cl::opt<bool> memAlignBuffering("memalign-buffering", cl::desc("Enable posix_memalign buffering."), cl::cat(u8u16Options));
    4949
    50 
    51 std::unique_ptr<PabloKernel> u8u16_pablo(const std::unique_ptr<IDISA::IDISA_Builder> & iBuilder) {
    52 
    53     auto kernel = std::unique_ptr<PabloKernel>(new PabloKernel(iBuilder, "u8u16",
    54                        {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}},
    55                        {Binding{iBuilder->getStreamSetTy(16, 1), "u16bit"},
    56                            Binding{iBuilder->getStreamSetTy(1, 1), "delMask"},
    57                            Binding{iBuilder->getStreamSetTy(1, 1), "errMask"}}, {}));
    58    
    59     kernel->setBuilder(iBuilder.get());
     50class U8U16Kernel final: public pablo::PabloKernel {
     51public:
     52    U8U16Kernel(const std::unique_ptr<kernel::KernelBuilder> & b);
     53    bool isCachable() const override { return true; }
     54    bool moduleIDisSignature() const override { return true; }
     55    void generatePabloMethod() override;
     56};
     57
     58U8U16Kernel::U8U16Kernel(const std::unique_ptr<kernel::KernelBuilder> & b)
     59: PabloKernel(b, "u8u16",
     60{Binding{b->getStreamSetTy(8, 1), "u8bit"}},
     61{Binding{b->getStreamSetTy(16, 1), "u16bit"}, Binding{b->getStreamSetTy(1, 1), "delMask"}, Binding{b->getStreamSetTy(1, 1), "errMask"}}) {
     62
     63}
     64
     65void U8U16Kernel::generatePabloMethod() {
    6066
    6167    //  input: 8 basis bit streams
    62    
    63     const auto u8bitSet = kernel->getInputStreamVar("u8bit");
    64    
     68
     69    const auto u8bitSet = getInputStreamVar("u8bit");
     70
    6571    //  output: 16 u8-indexed streams, + delmask stream + error stream
    66    
    67     cc::CC_Compiler ccc(kernel.get(), u8bitSet);
    68    
     72
     73    cc::CC_Compiler ccc(this, u8bitSet);
     74
    6975    PabloBuilder & main = ccc.getBuilder();
    7076    const auto u8_bits = ccc.getBasisBits();
    71    
     77
    7278    Zeroes * zeroes = main.createZeroes();
    7379
     
    8692    // The logic for processing non-ASCII bytes will be embedded within an if-hierarchy.
    8793    PabloAST * nonASCII = ccc.compileCC(re::makeCC(0x80, 0xFF));
    88    
     94
    8995    // Builder for the if statement handling all non-ASCII logic
    9096    PabloBuilder nAb = PabloBuilder::Create(main);
    9197    // Bits 3 through 7 of a 2-byte prefix are data bits, needed to
    92     // produce the UTF-16 code unit data ..., 
     98    // produce the UTF-16 code unit data ...,
    9399    PabloAST * bit3a1 = nAb.createAdvance(u8_bits[3], 1);
    94100    PabloAST * bit4a1 = nAb.createAdvance(u8_bits[4], 1);
     
    96102    PabloAST * bit6a1 = nAb.createAdvance(u8_bits[6], 1);
    97103    PabloAST * bit7a1 = nAb.createAdvance(u8_bits[7], 1);
    98    
     104
    99105    // Entry condition for 3 or 4 byte sequences: we have a prefix byte in the range 0xE0-0xFF.
    100106    PabloAST * pfx34 = ccc.compileCC(re::makeCC(0xE0, 0xFF), nAb);
     
    109115    PabloAST * bit7a2 = p34b.createAdvance(bit7a1, 1);
    110116
    111 
    112117    Var * const u8scope32 = nAb.createVar("u8scope32", zeroes);
    113118    Var * const u8scope33 = nAb.createVar("u8scope33", zeroes);
     
    140145    p4b.createAssign(u8scope44, p4b.createAdvance(u8scope43, 1));
    141146    //
    142    
     147
    143148    //  From the 4-byte sequence 11110abc 10defghi 10jklmno 10pqrstu,
    144149    //  we must calculate the value abcde - 1 to produce the bit values
     
    190195    // Two surrogate UTF-16 units are computed at the 3rd and 4th positions of 4-byte sequences.
    191196    PabloAST * surrogate = p34b.createOr(u8scope43, u8scope44);
    192    
     197
    193198    Var * p34del = nAb.createVar("p34del", zeroes);
    194199    p34b.createAssign(p34del, p34b.createOr(u8scope32, u8scope42));
     
    202207    p34b.createAssign(u16_hi[3], p34b.createOr(p34b.createAnd(u8scope33, bit7a2), surrogate));
    203208    p34b.createAssign(u16_hi[4], p34b.createOr(p34b.createAnd(u8scope33, bit2a1), surrogate));
    204    
     209
    205210    //
    206211    nAb.createIf(pfx34, p34b);
     
    220225    nAb.createAssign(error_mask, nAb.createOr(scope_suffix_mismatch, nAb.createOr(C0_C1_err, EX_FX_err)));
    221226    nAb.createAssign(delmask, nAb.createOr(p34del, ccc.compileCC(re::makeCC(0xC0, 0xFF), nAb)));
    222    
     227
    223228    // The low 3 bits of the high byte of the UTF-16 code unit as well as the high bit of the
    224229    // low byte are only nonzero for 2, 3 and 4 byte sequences.
     
    244249    main.createAssign(u16_lo[6], main.createOr(main.createAnd(last_byte, u8_bits[6]), s43_lo6));
    245250    main.createAssign(u16_lo[7], main.createOr(main.createAnd(last_byte, u8_bits[7]), s43_lo7));
    246    
    247     Var * output = kernel->getOutputStreamVar("u16bit");
    248     Var * delmask_out = kernel->getOutputStreamVar("delMask");
    249     Var * error_mask_out = kernel->getOutputStreamVar("errMask");
    250    
     251
     252    Var * output = getOutputStreamVar("u16bit");
     253    Var * delmask_out = getOutputStreamVar("delMask");
     254    Var * error_mask_out = getOutputStreamVar("errMask");
     255
    251256    for (unsigned i = 0; i < 8; i++) {
    252257        main.createAssign(main.createExtract(output, i), u16_hi[i]);
     
    257262    main.createAssign(main.createExtract(delmask_out, main.getInteger(0)), delmask);
    258263    main.createAssign(main.createExtract(error_mask_out,  main.getInteger(0)), error_mask);
    259 
    260     pablo_function_passes(kernel.get());
    261     return kernel;
    262264}
    263265
     
    304306    StreamSetBuffer * ErrorMask = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(), segmentSize * bufferSegments));
    305307   
    306     Kernel * u8u16k = pxDriver.addKernelInstance(u8u16_pablo(iBuilder));
     308    Kernel * u8u16k = pxDriver.addKernelInstance(make_unique<U8U16Kernel>(iBuilder));
    307309    pxDriver.makeKernelCall(u8u16k, {BasisBits}, {U8u16Bits, DelMask, ErrorMask});
    308310   
     
    397399    StreamSetBuffer * ErrorMask = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(), segmentSize * bufferSegments));
    398400   
    399     Kernel * u8u16k = pxDriver.addKernelInstance(u8u16_pablo(iBuilder));
     401    Kernel * u8u16k = pxDriver.addKernelInstance(make_unique<U8U16Kernel>(iBuilder));
    400402    pxDriver.makeKernelCall(u8u16k, {BasisBits}, {U8u16Bits, DelMask, ErrorMask});
    401403   
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5435 r5436  
    1717#include <cc/cc_compiler.h>
    1818#include <pablo/pablo_kernel.h>
    19 #include <IR_Gen/idisa_builder.h>
     19#include <kernels/kernel_builder.h>
    2020#include <IR_Gen/idisa_target.h>
    2121#include <kernels/streamset.h>
     
    8484class WordCountKernel final: public pablo::PabloKernel {
    8585public:
    86     WordCountKernel(const std::unique_ptr<IDISA::IDISA_Builder> & b);
     86    WordCountKernel(const std::unique_ptr<kernel::KernelBuilder> & b);
    8787    bool isCachable() const override { return true; }
    8888    bool moduleIDisSignature() const override { return true; }
    89     void prepareKernel() override;
     89protected:
     90    void generatePabloMethod() override;
    9091};
    9192
    92 WordCountKernel::WordCountKernel (const std::unique_ptr<IDISA::IDISA_Builder> & b)
     93WordCountKernel::WordCountKernel (const std::unique_ptr<kernel::KernelBuilder> & b)
    9394: PabloKernel(b, "wc",
    9495    {Binding{b->getStreamSetTy(8, 1), "u8bit"}},
     
    99100}
    100101
    101 void WordCountKernel::prepareKernel() {
     102void WordCountKernel::generatePabloMethod() {
    102103
    103104    //  input: 8 basis bit streams
     
    133134        pb.createAssign(cc, pb.createCount(u8Begin));
    134135    }
    135     pablo_function_passes(this);
    136     PabloKernel::prepareKernel();
    137136}
    138137
Note: See TracChangeset for help on using the changeset viewer.