Ignore:
Timestamp:
Feb 18, 2017, 4:13:44 PM (3 years ago)
Author:
nmedfort
Message:

Continued work on parenthesis matching; addition of Pablo ScanTo? and AdvanceThenScanTo/Thru? statements. Bug fix for Pablo Compiler for escaping variables.

File:
1 edited

Legend:

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

    r5267 r5329  
    1616#include <pablo/analysis/pabloverifier.hpp>
    1717#endif
     18#include <llvm/Support/raw_ostream.h>
     19
    1820
    1921using namespace boost;
     
    614616 ** ------------------------------------------------------------------------------------------------------------- */
    615617void Simplifier::strengthReduction(PabloBlock * const block) {
     618
    616619    Statement * stmt = block->front();
    617620    while (stmt) {
     
    636639                Advance * adv = cast<Advance>(scanThru->getScanFrom());
    637640                if (LLVM_UNLIKELY(adv->getNumUses() == 1)) {
    638                     block->setInsertPoint(scanThru->getPrevNode());
    639                     PabloAST * expr = block->createAdvance(adv->getOperand(0), block->getInteger(adv->getAmount() - 1));
    640                     scanThru->setOperand(0, expr);
    641                     scanThru->setOperand(1, block->createOr(scanThru->getOperand(1), expr));
     641                    PabloAST * stream = adv->getExpression();
     642                    block->setInsertPoint(stmt);
     643                    if (LLVM_UNLIKELY(adv->getAmount() != 1)) {
     644                        stream = block->createAdvance(stream, block->getInteger(adv->getAmount() - 1));
     645                    }
     646                    stmt = scanThru->replaceWith(block->createAdvanceThenScanThru(stream, scanThru->getScanThru()));
    642647                    adv->eraseFromParent(false);
     648                    continue;
    643649                }
    644650            } else if (LLVM_UNLIKELY(isa<And>(scanThru->getScanFrom()))) {
     
    651657
    652658
     659            }
     660        } else if (LLVM_UNLIKELY(isa<ScanTo>(stmt))) {
     661            ScanTo * scanTo = cast<ScanTo>(stmt);
     662            if (LLVM_UNLIKELY(isa<Advance>(scanTo->getScanFrom()))) {
     663                // Replace a ScanTo(Advance(x,n),y) with an ScanTo(Advance(x, n - 1), Advance(x, n - 1) | y), where Advance(x, 0) = x
     664                Advance * adv = cast<Advance>(scanTo->getScanFrom());
     665                if (LLVM_UNLIKELY(adv->getNumUses() == 1)) {
     666                    PabloAST * stream = adv->getExpression();
     667                    block->setInsertPoint(stmt);
     668                    if (LLVM_UNLIKELY(adv->getAmount() != 1)) {
     669                        stream = block->createAdvance(stream, block->getInteger(adv->getAmount() - 1));
     670                    }
     671                    stmt = scanTo->replaceWith(block->createAdvanceThenScanTo(stream, scanTo->getScanTo()));
     672                    adv->eraseFromParent(false);
     673                    continue;
     674                }
    653675            }
    654676        }
Note: See TracChangeset for help on using the changeset viewer.