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/kernels
Files:
44 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.