Changeset 5383


Ignore:
Timestamp:
Mar 30, 2017, 8:12:59 PM (2 years ago)
Author:
cameron
Message:

Lookahead support

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

Legend:

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

    r5370 r5383  
    4141    Var * crlf = builder.createVar("crlf", zero);
    4242    PabloBuilder crb = PabloBuilder::Create(builder);
    43     PabloAST * cr1 = crb.createAdvance(CR, 1, "cr1");
    44     crb.createAssign(crlf, crb.createAnd(cr1, LF));
     43    //PabloAST * cr1 = crb.createAdvance(CR, 1, "cr1");
     44    //crb.createAssign(crlf, crb.createAnd(cr1, LF));
     45    PabloAST * lookaheadLF = crb.createLookahead(LF, 1, "lookaheadLF");
     46    crb.createAssign(crlf, crb.createAnd(CR, lookaheadLF));
    4547    builder.createIf(CR, crb);
    4648   
     
    7375    PabloAST * LB_chars = builder.createOr(LF_VT_FF_CR, NEL_LS_PS);
    7476    PabloAST * UnicodeLineBreak = builder.createAnd(LB_chars, builder.createNot(crlf));  // count the CR, but not CRLF
    75    
     77
    7678    PabloAST * lb = UNICODE_LINE_BREAK ? UnicodeLineBreak : LF;
    7779    PabloAST * unterminatedLineAtEOF = builder.createAtEOF(builder.createAdvance(builder.createNot(LB_chars), 1));
     
    7981    PabloAST * const r = builder.createExtract(getOutput(0), builder.getInteger(0));
    8082    builder.createAssign(r, LineBreak);
     83    setLookAhead(1);
    8184}
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5371 r5383  
    506506            PabloAST * stream = l->getExpr();
    507507            Value * index = iBuilder->getInt32(0);
    508 
    509508            if (LLVM_UNLIKELY(isa<Extract>(stream))) {
    510                 stream = cast<Extract>(stream)->getArray();
     509                var = dyn_cast<Var>(cast<Extract>(stream)->getArray());
    511510                index = compileExpression(cast<Extract>(stream)->getIndex());
     511                if (!var->isKernelParameter() || var->isReadNone()) {
     512                    std::string tmp;
     513                    raw_string_ostream out(tmp);
     514                    out << "Lookahead operation cannot be applied to ";
     515                    stmt->print(out);
     516                    out << " - not an input stream";
     517                    report_fatal_error(out.str());
     518                }
    512519            }
    513520            if (LLVM_LIKELY(isa<Var>(stream))) {
     
    524531                }
    525532            }
    526 
    527533            const auto bit_shift = (l->getAmount() % iBuilder->getBitBlockWidth());
    528534            const auto block_shift = (l->getAmount() / iBuilder->getBitBlockWidth());
Note: See TracChangeset for help on using the changeset viewer.