Changeset 6248


Ignore:
Timestamp:
Dec 21, 2018, 10:22:42 AM (3 months ago)
Author:
cameron
Message:

RequiredStreams? kernel input flexibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r6218 r6248  
    4848    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
    4949    UCD::UCDCompiler ucdCompiler(ccc);
    50    
    5150    Name * breakChars = re::makeName("breakChars", makeCC(makeCC(makeCC(0x0A, 0x0D), makeCC(0x85)), makeCC(0x2028,0x2029)));
    5251    UCD::UCDCompiler::NameMap nameMap;
     
    5857    PabloAST * const LF = pb.createExtract(getInput(1), pb.getInteger(0), "LF");
    5958    PabloAST * const CR = ccc.compileCC(makeByte(0x0D));
    60     Var * const CR_before_LF = pb.createVar("CR_before_LFCR_before_LF", pb.createZeroes());
     59    Var * const CR_before_LF = pb.createVar("CR_before_LF", pb.createZeroes());
    6160    auto crb = pb.createScope();
    6261    pb.createIf(CR, crb);
     
    7069void RequiredStreams_UTF8::generatePabloMethod() {
    7170    PabloBuilder pb(getEntryScope());
    72     cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
    73    
     71    std::unique_ptr<cc::CC_Compiler> ccc;
     72    bool useDirectCC = getInput(0)->getType()->getArrayNumElements() == 1;
     73    if (useDirectCC) {
     74        ccc = make_unique<cc::Direct_CC_Compiler>(getEntryScope(), pb.createExtract(getInput(0), pb.getInteger(0)));
     75    } else {
     76        ccc = make_unique<cc::Parabix_CC_Compiler>(getEntryScope(), getInputStreamSet("source"));
     77    }
     78
    7479    PabloAST * const LF = pb.createExtract(getInput(1), pb.getInteger(0), "LF");
    75     PabloAST * const CR = ccc.compileCC(makeByte(0x0D));
    76     PabloAST * const LF_VT_FF_CR = ccc.compileCC("LF,VT,FF,CR", makeByte(0x0A, 0x0D), pb);
     80    PabloAST * const CR = ccc->compileCC(makeByte(0x0D));
     81    PabloAST * const LF_VT_FF_CR = ccc->compileCC("LF,VT,FF,CR", makeByte(0x0A, 0x0D), pb);
    7782    Var * const LineBreak = pb.createVar("LineBreak", LF_VT_FF_CR);
    7883   
     
    8994   
    9095    Zeroes * const ZEROES = pb.createZeroes();
    91     PabloAST * const u8pfx = ccc.compileCC(makeByte(0xC0, 0xFF));
     96    PabloAST * const u8pfx = ccc->compileCC(makeByte(0xC0, 0xFF));
    9297
    9398
     
    98103    auto it = pb.createScope();
    99104    pb.createIf(u8pfx, it);
    100     PabloAST * const u8pfx2 = ccc.compileCC(makeByte(0xC2, 0xDF), it);
    101     PabloAST * const u8pfx3 = ccc.compileCC(makeByte(0xE0, 0xEF), it);
    102     PabloAST * const u8pfx4 = ccc.compileCC(makeByte(0xF0, 0xF4), it);
    103     PabloAST * const u8suffix = ccc.compileCC("u8suffix", makeByte(0x80, 0xBF), it);
     105    PabloAST * const u8pfx2 = ccc->compileCC(makeByte(0xC2, 0xDF), it);
     106    PabloAST * const u8pfx3 = ccc->compileCC(makeByte(0xE0, 0xEF), it);
     107    PabloAST * const u8pfx4 = ccc->compileCC(makeByte(0xF0, 0xF4), it);
     108    PabloAST * const u8suffix = ccc->compileCC("u8suffix", makeByte(0x80, 0xBF), it);
    104109   
    105110    //
     
    109114    it.createIf(u8pfx2, it2);
    110115    it2.createAssign(anyscope, it2.createAdvance(u8pfx2, 1));
    111     PabloAST * NEL = it2.createAnd(it2.createAdvance(ccc.compileCC(makeByte(0xC2), it2), 1), ccc.compileCC(makeByte(0x85), it2), "NEL");
     116    PabloAST * NEL = it2.createAnd(it2.createAdvance(ccc->compileCC(makeByte(0xC2), it2), 1), ccc->compileCC(makeByte(0x85), it2), "NEL");
    112117    it2.createAssign(LineBreak, it2.createOr(LineBreak, NEL));
    113118
     
    123128    PabloAST * const u8scope3X = it3.createOr(u8scope32, u8scope33);
    124129    it3.createAssign(anyscope, it3.createOr(anyscope, u8scope3X));
    125     PabloAST * const E0_invalid = it3.createAnd(it3.createAdvance(ccc.compileCC(makeByte(0xE0), it3), 1), ccc.compileCC(makeByte(0x80, 0x9F), it3));
    126     PabloAST * const ED_invalid = it3.createAnd(it3.createAdvance(ccc.compileCC(makeByte(0xED), it3), 1), ccc.compileCC(makeByte(0xA0, 0xBF), it3));
     130    PabloAST * const E0_invalid = it3.createAnd(it3.createAdvance(ccc->compileCC(makeByte(0xE0), it3), 1), ccc->compileCC(makeByte(0x80, 0x9F), it3));
     131    PabloAST * const ED_invalid = it3.createAnd(it3.createAdvance(ccc->compileCC(makeByte(0xED), it3), 1), ccc->compileCC(makeByte(0xA0, 0xBF), it3));
    127132    PabloAST * const EX_invalid = it3.createOr(E0_invalid, ED_invalid);
    128133    it3.createAssign(EF_invalid, EX_invalid);
    129     PabloAST * E2_80 = it3.createAnd(it3.createAdvance(ccc.compileCC(makeByte(0xE2), it3), 1), ccc.compileCC(makeByte(0x80), it3));
    130     PabloAST * LS_PS = it3.createAnd(it3.createAdvance(E2_80, 1), ccc.compileCC(makeByte(0xA8,0xA9), it3), "LS_PS");
     134    PabloAST * E2_80 = it3.createAnd(it3.createAdvance(ccc->compileCC(makeByte(0xE2), it3), 1), ccc->compileCC(makeByte(0x80), it3));
     135    PabloAST * LS_PS = it3.createAnd(it3.createAdvance(E2_80, 1), ccc->compileCC(makeByte(0xA8,0xA9), it3), "LS_PS");
    131136    it3.createAssign(LineBreak, it3.createOr(LineBreak, LS_PS));
    132137
     
    142147    PabloAST * const u8scope4X = it4.createOr(u8scope4nonfinal, u8scope44);
    143148    it4.createAssign(anyscope, it4.createOr(anyscope, u8scope4X));
    144     PabloAST * const F0_invalid = it4.createAnd(it4.createAdvance(ccc.compileCC(makeByte(0xF0), it4), 1), ccc.compileCC(makeByte(0x80, 0x8F), it4));
    145     PabloAST * const F4_invalid = it4.createAnd(it4.createAdvance(ccc.compileCC(makeByte(0xF4), it4), 1), ccc.compileCC(makeByte(0x90, 0xBF), it4));
     149    PabloAST * const F0_invalid = it4.createAnd(it4.createAdvance(ccc->compileCC(makeByte(0xF0), it4), 1), ccc->compileCC(makeByte(0x80, 0x8F), it4));
     150    PabloAST * const F4_invalid = it4.createAnd(it4.createAdvance(ccc->compileCC(makeByte(0xF4), it4), 1), ccc->compileCC(makeByte(0x90, 0xBF), it4));
    146151    PabloAST * const FX_invalid = it4.createOr(F0_invalid, F4_invalid);
    147152    it4.createAssign(EF_invalid, it4.createOr(EF_invalid, FX_invalid));
     
    168173}
    169174
    170 RequiredStreams_UTF8::RequiredStreams_UTF8(const std::unique_ptr<kernel::KernelBuilder> & kb, StreamSet * BasisBits, StreamSet * LineFeedStream, StreamSet * RequiredStreams, StreamSet * UnicodeLB)
    171 : PabloKernel(kb, "RequiredStreams_UTF8",
     175RequiredStreams_UTF8::RequiredStreams_UTF8(const std::unique_ptr<kernel::KernelBuilder> & kb, StreamSet * Source, StreamSet * LineFeedStream, StreamSet * RequiredStreams, StreamSet * UnicodeLB)
     176: PabloKernel(kb, "RequiredStreams_UTF8" + std::to_string(Source->getNumElements()) + "x" + std::to_string(Source->getFieldWidth()),
    172177// input
    173 {Binding{"basis", BasisBits},
     178{Binding{"source", Source},
    174179 Binding{"lf", LineFeedStream, FixedRate(), LookAhead(1)}},
    175180// output
Note: See TracChangeset for help on using the changeset viewer.