Ignore:
Timestamp:
May 6, 2017, 4:05:05 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work.

File:
1 edited

Legend:

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

    r5431 r5435  
    2121#define UNICODE_LINE_BREAK (!AlgorithmOptionIsSet(DisableUnicodeLineBreak))
    2222
    23 LineBreakKernelBuilder::LineBreakKernelBuilder (IDISA::IDISA_Builder * iBuilder, unsigned basisBitsCount)
    24 : PabloKernel(iBuilder, "lb", {Binding{iBuilder->getStreamSetTy(basisBitsCount), "basis"}}, {Binding{iBuilder->getStreamSetTy(1), "linebreak", Add1()}}) {
     23LineBreakKernelBuilder::LineBreakKernelBuilder(const std::unique_ptr<IDISA::IDISA_Builder> & b, unsigned basisBitsCount)
     24: PabloKernel(b, "lb", {Binding{b->getStreamSetTy(basisBitsCount), "basis"}}, {Binding{b->getStreamSetTy(1), "linebreak", Add1()}}) {
     25
     26}
     27
     28void LineBreakKernelBuilder::prepareKernel() {
    2529
    2630    CC_Compiler ccc(this, getInput(0));
    27     auto & builder = ccc.getBuilder();
    28    
     31    auto & pb = ccc.getBuilder();
     32
    2933    PabloAST * LineBreak = nullptr;
    30     PabloAST * LF = ccc.compileCC("LF", makeCC(0x0A), builder);
     34    PabloAST * LF = ccc.compileCC("LF", makeCC(0x0A), pb);
    3135    PabloAST * CR = ccc.compileCC(makeCC(0x0D));
    3236    PabloAST * LF_VT_FF_CR = ccc.compileCC(makeCC(0x0A, 0x0D));
    3337
    34     Zeroes * const zero = builder.createZeroes();
    35     Var * crlf = builder.createVar("crlf", zero);
    36     PabloBuilder crb = PabloBuilder::Create(builder);
     38    Zeroes * const zero = pb.createZeroes();
     39    Var * crlf = pb.createVar("crlf", zero);
     40    PabloBuilder crb = PabloBuilder::Create(pb);
    3741#ifndef USE_LOOKAHEAD_CRLF
    3842    PabloAST * cr1 = crb.createAdvance(CR, 1, "cr1");
     
    4246    crb.createAssign(crlf, crb.createAnd(CR, lookaheadLF));
    4347#endif
    44     builder.createIf(CR, crb);
    45    
    46     Var * NEL_LS_PS = builder.createVar("NEL_LS_PS", zero);
     48    pb.createIf(CR, crb);
     49
     50    Var * NEL_LS_PS = pb.createVar("NEL_LS_PS", zero);
    4751
    4852    PabloAST * u8pfx = ccc.compileCC(makeCC(0xC0, 0xFF));
    49     PabloBuilder it = PabloBuilder::Create(builder);
    50     builder.createIf(u8pfx, it);
     53    PabloBuilder it = PabloBuilder::Create(pb);
     54    pb.createIf(u8pfx, it);
    5155    PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF), it);
    5256    PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF), it);
     
    6165    //
    6266    // Three-byte sequences
    63 
    6467    Var * LS_PS = it.createVar("LS_PS", zero);
    6568    PabloBuilder it3 = PabloBuilder::Create(it);
     
    6972    it.createAssign(NEL_LS_PS, it.createOr(NEL, LS_PS));
    7073
    71 
    72     PabloAST * LB_chars = builder.createOr(LF_VT_FF_CR, NEL_LS_PS);
    73     PabloAST * UnicodeLineBreak = builder.createAnd(LB_chars, builder.createNot(crlf));  // count the CR, but not CRLF
     74    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
    7476
    7577    PabloAST * lb = UNICODE_LINE_BREAK ? UnicodeLineBreak : LF;
    76     PabloAST * unterminatedLineAtEOF = builder.createAtEOF(builder.createAdvance(builder.createNot(LB_chars), 1));
    77     LineBreak = builder.createOr(lb, unterminatedLineAtEOF);
    78     PabloAST * const r = builder.createExtract(getOutput(0), builder.getInteger(0));
    79     builder.createAssign(r, LineBreak);
     78    PabloAST * unterminatedLineAtEOF = pb.createAtEOF(pb.createAdvance(pb.createNot(LB_chars), 1));
     79    LineBreak = pb.createOr(lb, unterminatedLineAtEOF);
     80    PabloAST * const r = pb.createExtract(getOutput(0), pb.getInteger(0));
     81    pb.createAssign(r, LineBreak);
    8082#ifdef USE_LOOKAHEAD_CRLF
    8183    setLookAhead(1);
    8284#endif
     85
     86    PabloKernel::prepareKernel();
    8387}
Note: See TracChangeset for help on using the changeset viewer.