Ignore:
Timestamp:
Dec 15, 2017, 12:44:01 PM (14 months ago)
Author:
nmedfort
Message:

Initial check-in of LookAhead? support; modified LineBreakKernel? to compute CR+LF using LookAhead?(1) + misc. fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5706 r5782  
    8282            const Lookahead * const la = cast<Lookahead>(stmt);
    8383            PabloAST * input = la->getExpression();
    84             if (LLVM_UNLIKELY(isa<Extract>(input))) {
     84            if (isa<Extract>(input)) {
    8585                input = cast<Extract>(input)->getArray();
    8686            }
     
    8989                for (unsigned i = 0; i < mKernel->getNumOfInputs(); ++i) {
    9090                    if (input == mKernel->getInput(i)) {
    91                         if (LLVM_LIKELY(mKernel->getLookAhead(i) < la->getAmount())) {
    92                             mKernel->setLookAhead(i, la->getAmount());
     91                        const auto & binding = mKernel->getStreamInput(i);
     92                        if (LLVM_UNLIKELY(!binding.hasLookahead() || binding.getLookahead() < la->getAmount())) {
     93                            std::string tmp;
     94                            raw_string_ostream out(tmp);
     95                            input->print(out);
     96                            out << " must have a lookahead attribute of at least " << la->getAmount();
     97                            report_fatal_error(out.str());
    9398                        }
    9499                        notFound = false;
     
    566571            PabloAST * stream = l->getExpression();
    567572            Value * index = nullptr;
    568             if (LLVM_UNLIKELY(isa<Extract>(stream))) {
     573            if (LLVM_UNLIKELY(isa<Extract>(stream))) {               
     574                index = compileExpression(iBuilder, cast<Extract>(stream)->getIndex(), true);
    569575                stream = cast<Extract>(stream)->getArray();
    570                 index = compileExpression(iBuilder, cast<Extract>(stream)->getIndex());
    571576            } else {
    572577                index = iBuilder->getInt32(0);
     
    574579            const auto bit_shift = (l->getAmount() % iBuilder->getBitBlockWidth());
    575580            const auto block_shift = (l->getAmount() / iBuilder->getBitBlockWidth());
    576             Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift), cast<Var>(stream)->getName(), index);
     581            Value * ptr = iBuilder->getInputStreamBlockPtr(cast<Var>(stream)->getName(), index, iBuilder->getSize(block_shift));
    577582            Value * lookAhead = iBuilder->CreateBlockAlignedLoad(ptr);
    578583            if (bit_shift == 0) {  // Simple case with no intra-block shifting.
    579584                value = lookAhead;
    580585            } else { // Need to form shift result from two adjacent blocks.
    581                 Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift + 1), cast<Var>(stream)->getName(), index);
     586                Value * ptr = iBuilder->getInputStreamBlockPtr(cast<Var>(stream)->getName(), index, iBuilder->getSize(block_shift + 1));
    582587                Value * lookAhead1 = iBuilder->CreateBlockAlignedLoad(ptr);
    583588                if (LLVM_UNLIKELY((bit_shift % 8) == 0)) { // Use a single whole-byte shift, if possible.
Note: See TracChangeset for help on using the changeset viewer.