Changeset 5842


Ignore:
Timestamp:
Jan 21, 2018, 6:57:46 AM (13 months ago)
Author:
cameron
Message:

Decoupling PabloKernels? from CC_compiler

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.cpp

    r5836 r5842  
    240240 ** ------------------------------------------------------------------------------------------------------------- */
    241241PabloAST * UCDCompiler::sequenceGenerator(const RangeList && ranges, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix) {
    242         bool isUTF_16 = mCharacterClassCompiler.isUTF_16();
     242    bool isUTF_16 = false;
    243243
    244244    if (LLVM_LIKELY(ranges.size() > 0)) {
     
    322322PabloAST * UCDCompiler::ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target) {
    323323
    324         bool isUTF_16 = mCharacterClassCompiler.isUTF_16();
     324        bool isUTF_16 = false;
    325325    codepoint_t lo_byte = encodingByte(lo, byte_no, isUTF_16);
    326326    codepoint_t hi_byte = encodingByte(hi, byte_no, isUTF_16);
     
    366366    assert (byte_no >= 1 && byte_no <= 4);
    367367    assert (byte_no == 1 || prefix != nullptr);
    368     bool isUTF_16 = mCharacterClassCompiler.isUTF_16();
     368    bool isUTF_16 = false;
    369369    for (unsigned i = 1; i != byte_no; ++i) {
    370370        const CC * const cc = makeByte(encodingByte(cp, i, isUTF_16));
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r5823 r5842  
    3636    pablo::PabloAST * compileCC(const std::string & canonicalName, const re::CC *cc, pablo::PabloBuilder & builder);
    3737
    38     pablo::PabloBuilder & getBuilder();
    39 
    40     const std::vector<pablo::PabloAST *> & getBasisBits() const {
    41         return mBasisBit;
    42     }
    43 
    44     bool isUTF_16() const {
    45         return mEncodingBits == 16;
    46     }
    47 
    4838private:
    4939    pablo::PabloAST * getBasisVar(const unsigned n) const;
     
    8171}
    8272
    83 inline pablo::PabloBuilder & CC_Compiler::getBuilder() {
    84     return mBuilder;
    85 }
    86 
    8773pablo::PabloAST * compileCCfromCodeUnitStream(const re::CC *cc, pablo::PabloAST * codeUnitStream, pablo::PabloBuilder & pb);
    8874   
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5836 r5842  
    291291
    292292void PreprocessKernel::generatePabloMethod() {
     293    PabloBuilder pb(getEntryScope());
    293294    cc::CC_Compiler ccc(this, getInputStreamVar("basis"));
    294     PabloBuilder & pb = ccc.getBuilder();
    295295    PabloAST * A = ccc.compileCC(re::makeCC(re::makeCC(0x41), re::makeCC(0x61)), pb);
    296296    PabloAST * C = ccc.compileCC(re::makeCC(re::makeCC(0x43), re::makeCC(0x63)), pb);
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r5828 r5842  
    110110
    111111void ParabixCharacterClassKernelBuilder::generatePabloMethod() {
     112    PabloBuilder pb(getEntryScope());
    112113    CC_Compiler ccc(this, getInput(0));
    113     auto & builder = ccc.getBuilder();
    114114    for (unsigned i = 0; i < mCharClasses.size(); ++i) {
    115         builder.createAssign(getOutput(i), ccc.compileCC("cc", mCharClasses[i], builder));
     115        pb.createAssign(getOutput(i), ccc.compileCC("cc", mCharClasses[i], pb));
    116116    }
    117117}
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r5805 r5842  
    7373
    7474void CharClassesKernel::generatePabloMethod() {
     75    PabloBuilder pb(getEntryScope());
     76
    7577    CC_Compiler ccc(this, getInput(0));
    76     auto & pb = ccc.getBuilder();
    7778    unsigned n = mCCs.size();
    7879
  • icGREP/icgrep-devel/icgrep/kernels/delmask_kernel.cpp

    r5836 r5842  
    1919
    2020void DelMaskKernelBuilder::generatePabloMethod() {
     21    PabloBuilder main(getEntryScope());
    2122    //  input: 8 basis bit streams
    2223   
    2324    const auto u8bitSet = this->getInputStreamVar("u8bit");
    24    
     25    PabloAST * u8_bits[8];
     26    for (int i = 0; i < 8; ++i) {
     27        u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
     28    }
    2529    //  output: delmask stream + error stream
    2630   
    2731    cc::CC_Compiler ccc(this, u8bitSet);
    2832   
    29     PabloBuilder & main = ccc.getBuilder();
    30     const auto u8_bits = ccc.getBasisBits();
    3133    Zeroes * zeroes = main.createZeroes();
    3234
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5836 r5842  
    4141
    4242void RequiredStreams_UTF8::generatePabloMethod() {
    43    
     43    PabloBuilder pb(getEntryScope());
    4444    cc::CC_Compiler ccc(this, getInput(0));
    45     auto & pb = ccc.getBuilder();
    4645    Zeroes * const ZEROES = pb.createZeroes();
    4746    PabloAST * const u8pfx = ccc.compileCC(makeByte(0xC0, 0xFF));
     
    135134
    136135void RequiredStreams_UTF16::generatePabloMethod() {
    137    
     136    PabloBuilder pb(getEntryScope());
    138137    cc::CC_Compiler ccc(this, getInput(0));
    139     auto & pb = ccc.getBuilder();
    140138   
    141139    PabloAST * u16hi_hi_surrogate = ccc.compileCC(makeCC(0xD800, 0xDBFF, &cc::UTF16));    //u16hi_hi_surrogate = [\xD8-\xDB]
     
    209207
    210208void ICGrepKernel::generatePabloMethod() {
     209    PabloBuilder pb(getEntryScope());
    211210    Var * const basis = getInputStreamVar("basis");
    212211    cc::CC_Compiler cc_compiler(this, basis);
     
    217216    }
    218217    PabloAST * const matches = re_compiler.compile(mRE);
    219     PabloBlock * const pb = getEntryScope();
    220218    Var * const output = getOutputStreamVar("matches");
    221     pb->createAssign(pb->createExtract(output, pb->getInteger(0)), matches);
     219    pb.createAssign(pb.createExtract(output, pb.getInteger(0)), matches);
    222220}
    223221
    224222void MatchedLinesKernel::generatePabloMethod() {
    225     auto pb = this->getEntryScope();
    226     PabloAST * matchResults = pb->createExtract(getInputStreamVar("matchResults"), pb->getInteger(0));
    227     PabloAST * lineBreaks = pb->createExtract(getInputStreamVar("lineBreaks"), pb->getInteger(0));
    228     PabloAST * notLB = pb->createNot(lineBreaks);
    229     PabloAST * match_follow = pb->createMatchStar(matchResults, notLB);
     223    PabloBuilder pb(getEntryScope());
     224    PabloAST * matchResults = pb.createExtract(getInputStreamVar("matchResults"), pb.getInteger(0));
     225    PabloAST * lineBreaks = pb.createExtract(getInputStreamVar("lineBreaks"), pb.getInteger(0));
     226    PabloAST * notLB = pb.createNot(lineBreaks);
     227    PabloAST * match_follow = pb.createMatchStar(matchResults, notLB);
    230228    Var * const matchedLines = getOutputStreamVar("matchedLines");
    231     pb->createAssign(pb->createExtract(matchedLines, pb->getInteger(0)), pb->createAnd(match_follow, lineBreaks));
     229    pb.createAssign(pb.createExtract(matchedLines, pb.getInteger(0)), pb.createAnd(match_follow, lineBreaks));
    232230}
    233231
  • icGREP/icgrep-devel/icgrep/kernels/linebreak_kernel.cpp

    r5836 r5842  
    3636
    3737void LineFeedKernelBuilder::generatePabloMethod() {
     38    PabloBuilder pb(getEntryScope());
    3839    #ifdef USE_DIRECT_LF_BUILDER
    39     PabloBuilder pb(getEntryScope());
    4040    PabloAST * LF = compileCCfromCodeUnitStream(makeByte(0x0A), getInput(0), pb);
    4141    #else
    4242    CC_Compiler ccc(this, getInput(0));
    43     auto & pb = ccc.getBuilder();
    4443    PabloAST * LF = ccc.compileCC("LF", makeByte(0x0A), pb);
    4544    #endif
     
    5958
    6059void LineBreakKernelBuilder::generatePabloMethod() {
     60    PabloBuilder pb(getEntryScope());
    6161    CC_Compiler ccc(this, getInput(0));
    62     auto & pb = ccc.getBuilder();
    6362
    6463    Integer * const ZERO = pb.getInteger(0);
  • icGREP/icgrep-devel/icgrep/kernels/u8u32_kernel.cpp

    r5836 r5842  
    1919
    2020void U8U32KernelBuilder::generatePabloMethod() {
     21    PabloBuilder main(getEntryScope());
     22   
    2123    //  input: 8 basis bit streams
    22    
    2324    const auto u8bitSet = this->getInputStreamVar("u8bit");
    24    
     25    PabloAST * u8_bits[8];
     26    for (int i = 0; i < 8; ++i) {
     27        u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
     28    }
    2529    //  output: 32 u8-indexed streams, + delmask stream + error stream
    2630   
    2731    cc::CC_Compiler ccc(this, u8bitSet);
    28    
    29     PabloBuilder & main = ccc.getBuilder();
    30     const auto u8_bits = ccc.getBasisBits();
    3132   
    3233    Zeroes * zeroes = main.createZeroes();
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5836 r5842  
    11/*
    2  *  Copyright (c) 2014 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 *  icgrep is a trademark of International Characters.
     
    5959
    6060PabloAST * RE_Compiler::compile(RE * const re, PabloAST * const initialCursors) {
     61    pablo::PabloBuilder mPB(mKernel->getEntryScope());
    6162    const auto markers = initialCursors ? compile(re, initialCursors, mPB) : compile(re, mPB);
    6263    return markerVar(AdvanceMarker(markers, FinalPostPositionUnit, mPB));
     
    582583, mWhileTest(nullptr)
    583584, mStarDepth(0)
    584 , mPB(ccCompiler.getBuilder())
    585585, mCompiledName(&mBaseMap) {
     586    PabloBuilder mPB(kernel->getEntryScope());
    586587    Var * const linebreak = mKernel->getInputStreamVar("linebreak");
    587588    mLineBreak = mPB.createExtract(linebreak, 0);
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5821 r5842  
    143143    pablo::PabloAST *                               mWhileTest;
    144144    int                                             mStarDepth;
    145     pablo::PabloBuilder &                           mPB;
    146145    NameMap *                                       mCompiledName;
    147146    NameMap                                         mBaseMap;
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5836 r5842  
    6565
    6666void U8U16Kernel::generatePabloMethod() {
    67 
     67    PabloBuilder main(getEntryScope());
     68    Zeroes * zeroes = main.createZeroes();
     69   
    6870    //  input: 8 basis bit streams
    69 
    7071    const auto u8bitSet = getInputStreamVar("u8bit");
     72    PabloAST * u8_bits[8];
     73    for (int i = 0; i < 8; ++i) {
     74        u8_bits[i] = main.createExtract(u8bitSet, main.getInteger(i));
     75    }
    7176
    7277    //  output: 16 u8-indexed streams, + delmask stream + error stream
    73 
    74     cc::CC_Compiler ccc(this, u8bitSet);
    75 
    76     PabloBuilder & main = ccc.getBuilder();
    77     const auto u8_bits = ccc.getBasisBits();
    78 
    79     Zeroes * zeroes = main.createZeroes();
    80 
    81     // Outputs
    8278    Var * u16_hi[8];
    8379    for (int i = 0; i < 8; ++i) {
     
    8884        u16_lo[i] = main.createVar("u16_lo" + std::to_string(i), zeroes);
    8985    }
     86   
    9087    Var * delmask = main.createVar("delmask", zeroes);
    9188    Var * error_mask = main.createVar("error_mask", zeroes);
     89
     90    cc::CC_Compiler ccc(this, u8bitSet);
    9291
    9392    // The logic for processing non-ASCII bytes will be embedded within an if-hierarchy.
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5815 r5842  
    100100
    101101void WordCountKernel::generatePabloMethod() {
    102 
     102    PabloBuilder pb(getEntryScope());
    103103    //  input: 8 basis bit streams
    104104    const auto u8bitSet = getInputStreamVar("u8bit");
     
    106106
    107107    cc::CC_Compiler ccc(this, u8bitSet);
    108 
    109     PabloBuilder & pb = ccc.getBuilder();
    110108
    111109    Var * lc = getOutputScalarVar("lineCount");
Note: See TracChangeset for help on using the changeset viewer.