Changeset 4438


Ignore:
Timestamp:
Jan 23, 2015, 1:52:33 PM (4 years ago)
Author:
nmedfort
Message:

Preliminary steps for removal of superfluous Assigns.

Location:
icGREP/icgrep-devel/icgrep
Files:
5 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4436 r4438  
    5353find_package(Boost)
    5454
    55 add_library(PabloADT pablo/pe_and.cpp pablo/pe_not.cpp pablo/pe_or.cpp pablo/pabloAST.cpp pablo/pe_sel.cpp pablo/pe_xor.cpp pablo/ps_assign.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/codegenstate.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp pablo/optimizers/pablo_simplifier.cpp)
     55add_library(PabloADT pablo/pabloAST.cpp pablo/ps_assign.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/codegenstate.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp pablo/optimizers/pablo_simplifier.cpp)
    5656add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_parser.cpp re/re_rep.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/printer_re.cpp re/re_diff.cpp re/re_intersect.cpp re/re_analysis.cpp)
    5757add_library(CCADT cc/cc_namemap.cpp cc/cc_compiler.cpp utf8_encoder.cpp UCD/CaseFolding_txt.cpp)
  • icGREP/icgrep-devel/icgrep/compiler.cpp

    r4431 r4438  
    130130    }
    131131   
    132     RE_Compiler re_compiler(main, nameMap);
     132    RE_Compiler re_compiler(main);
    133133    re_compiler.initializeRequiredStreams(cc_compiler);
    134134    re_compiler.finalizeMatchResult(re_compiler.compile(re_ast));
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r4437 r4438  
    99namespace pablo {
    1010
     11inline PabloAST * PabloBlock::renameNonNamedNode(PabloAST * expr, const std::string && prefix) {
     12    if (Statement * stmt = dyn_cast<Statement>(expr)) {
     13        if (stmt->getName()->isGenerated()) {
     14            stmt->setName(makeName(prefix, false));
     15        }
     16    }
     17    return expr;
     18}
     19
    1120/// UNARY CREATE FUNCTIONS
    1221
     
    1928        return expr;
    2029    }
    21     return insertAtInsertionPoint(new Advance(expr, shiftAmount, mSymbolGenerator, this));
     30    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance"), this));
     31}
     32
     33PabloAST * PabloBlock::createAdvance(PabloAST * expr, PabloAST * shiftAmount, const std::string prefix) {
     34    if (isa<Zeroes>(expr) || cast<Integer>(shiftAmount)->value() == 0) {
     35        return expr;
     36    }
     37    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false), this));
    2238}
    2339
     
    2541    if (isa<Zeroes>(expr) || shiftAmount == 0) {
    2642        return expr;
     43    }
     44    return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), makeName("advance"), this));
     45}
     46
     47PabloAST * PabloBlock::createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix) {
     48    if (isa<Zeroes>(expr) || shiftAmount == 0) {
     49        return renameNonNamedNode(expr, std::move(prefix));
    2750    }   
    28     return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), mSymbolGenerator, this));
     51    return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), makeName(prefix, false), this));
    2952}
    3053
     
    4568        return not1->getExpr();
    4669    }
    47     return insertAtInsertionPoint(new Not(expr, this));
     70    return insertAtInsertionPoint(new Not(expr, makeName("not"), this));
     71}
     72
     73PabloAST * PabloBlock::createNot(PabloAST * expr, const std::string prefix) {
     74    assert (expr);
     75    if (isa<Ones>(expr)) {
     76        return createZeroes();
     77    }
     78    else if (isa<Zeroes>(expr)){
     79        return createOnes();
     80    }
     81    else if (Not * not1 = dyn_cast<Not>(expr)) {       
     82        return renameNonNamedNode(not1->getExpr(), std::move(prefix));
     83    }
     84    return insertAtInsertionPoint(new Not(expr, makeName(prefix, false), this));
    4885}
    4986
     
    65102        return marker;
    66103    }
    67     return insertAtInsertionPoint(new MatchStar(marker, charclass, mSymbolGenerator, this));
     104    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar"), this));
     105}
     106
     107PabloAST * PabloBlock::createMatchStar(PabloAST * marker, PabloAST * charclass, const std::string prefix) {
     108    assert (marker && charclass);
     109    if (isa<Zeroes>(marker) || isa<Zeroes>(charclass)) {
     110        return renameNonNamedNode(marker, std::move(prefix));
     111    }
     112    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false), this));
    68113}
    69114
     
    73118        return from;
    74119    }
    75     return insertAtInsertionPoint(new ScanThru(from, thru, mSymbolGenerator, this));
     120    return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru"), this));
     121}
     122
     123PabloAST * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru, const std::string prefix) {
     124    assert (from && thru);
     125    if (isa<Zeroes>(from) || isa<Zeroes>(thru)) {       
     126        return renameNonNamedNode(from, std::move(prefix));
     127    }
     128    return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false), this));
    76129}
    77130
     
    81134        return expr2;
    82135    }
    83     else if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){
    84         return expr1;
    85     }
    86     else if (equals(expr1, expr2)) {
     136    else if (isa<Zeroes>(expr1) || isa<Ones>(expr2) || equals(expr1, expr2)){
    87137        return expr1;
    88138    }
     
    103153        std::swap(expr1, expr2);
    104154    }
    105     return insertAtInsertionPoint(new And(expr1, expr2, this));
    106 }
    107 
     155    return insertAtInsertionPoint(new And(expr1, expr2, makeName("and"), this));
     156}
     157
     158
     159PabloAST * PabloBlock::createAnd(PabloAST * expr1, PabloAST * expr2, const std::string prefix) {
     160    assert (expr1 && expr2);
     161    if (isa<Zeroes>(expr2) || isa<Ones>(expr1)) {
     162        return renameNonNamedNode(expr2, std::move(prefix));
     163    }
     164    else if (isa<Zeroes>(expr1) || isa<Ones>(expr2) || equals(expr1, expr2)){
     165        return renameNonNamedNode(expr1, std::move(prefix));
     166    }
     167    else if (Not * not1 = dyn_cast<Not>(expr1)) {
     168        if (Not * not2 = dyn_cast<Not>(expr2)) {
     169            return createNot(createOr(not1->getExpr(), not2->getExpr()), prefix);
     170        }
     171        else if (equals(not1->getExpr(), expr2)) {
     172            return createZeroes();
     173        }
     174    }
     175    else if (Not * not2 = dyn_cast<Not>(expr2)) {
     176        if (equals(expr1, not2->getExpr())) {
     177            return createZeroes();
     178        }
     179    }
     180    if (isa<Not>(expr1)) {
     181        std::swap(expr1, expr2);
     182    }
     183    return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false), this));
     184}
    108185
    109186PabloAST * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2) {
    110187    assert (expr1 && expr2);
    111     if (isa<Zeroes>(expr2) || isa<Ones>(expr1)) {
    112         return expr1;
    113     }
    114     else if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){
     188    if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){
    115189        return expr2;
    116190    }
    117     else if (equals(expr1, expr2)) {
     191    if (isa<Zeroes>(expr2) || isa<Ones>(expr1) || equals(expr1, expr2)) {
    118192        return expr1;
    119193    }
     
    151225        }
    152226    }
    153     return insertAtInsertionPoint(new Or(expr1, expr2, this));
     227    return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or"), this));
     228}
     229
     230PabloAST * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2, const std::string prefix) {
     231    assert (expr1 && expr2);
     232    if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){
     233        return renameNonNamedNode(expr2, std::move(prefix));
     234    }
     235    if (isa<Zeroes>(expr2) || isa<Ones>(expr1) || equals(expr1, expr2)) {
     236        return renameNonNamedNode(expr1, std::move(prefix));
     237    }
     238    else if (Not * not1 = dyn_cast<Not>(expr1)) {
     239        // ¬a√b = ¬¬(¬a√b) = ¬(a ∧ ¬b)
     240        return createNot(createAnd(not1->getExpr(), createNot(expr2)), prefix);
     241    }
     242    else if (Not * not2 = dyn_cast<Not>(expr2)) {
     243        // a√¬b = ¬¬(¬b√a) = ¬(b ∧ ¬a)
     244        return createNot(createAnd(not2->getExpr(), createNot(expr1)), prefix);
     245    }
     246    else if (And * and_expr1 = dyn_cast<And>(expr1)) {
     247        if (And * and_expr2 = dyn_cast<And>(expr2)) {
     248            PabloAST * const expr1a = and_expr1->getExpr1();
     249            PabloAST * const expr1b = and_expr1->getExpr2();
     250            PabloAST * const expr2a = and_expr2->getExpr1();
     251            PabloAST * const expr2b = and_expr2->getExpr2();
     252            //These optimizations factor out common components that can occur when sets are formed by union
     253            //(e.g., union of [a-z] and [A-Z].
     254            if (equals(expr1a, expr2a)) {
     255                return createAnd(expr1a, createOr(expr1b, expr2b), prefix);
     256            }
     257            else if (equals(expr1b, expr2b)) {
     258                return createAnd(expr1b, createOr(expr1a, expr2a), prefix);
     259            }
     260            else if (equals(expr1a, expr2b)) {
     261                return createAnd(expr1a, createOr(expr1b, expr2a), prefix);
     262            }
     263            else if (equals(expr1b, expr2a)) {
     264                return createAnd(expr1b, createOr(expr1a, expr2b), prefix);
     265            }
     266        }
     267    }
     268    return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false), this));
    154269}
    155270
     
    173288        }
    174289    }
    175     return insertAtInsertionPoint(new Xor(expr1, expr2,  this));
     290    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor"), this));
     291}
     292
     293PabloAST * PabloBlock::createXor(PabloAST * expr1, PabloAST * expr2, const std::string prefix) {
     294    assert (expr1 && expr2);
     295    if (isa<Ones>(expr1)) {
     296        return createNot(expr2, prefix);
     297    }
     298    else if (isa<Zeroes>(expr1)){
     299        return expr2;
     300    }
     301    else if (isa<Ones>(expr2)) {
     302        return createNot(expr1, prefix);
     303    }
     304    else if (isa<Zeroes>(expr2)){
     305        return expr1;
     306    }
     307    else if (Not * not1 = dyn_cast<Not>(expr1)) {
     308        if (Not * not2 = dyn_cast<Not>(expr2)) {
     309            return createXor(not1->getExpr(), not2->getExpr(), prefix);
     310        }
     311    }
     312    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false), this));
    176313}
    177314
     
    208345        return createXor(condition, falseExpr);
    209346    }
    210     return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, this));
     347    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel"), this));
     348}
     349
     350PabloAST * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, const std::string prefix) {
     351    assert (condition && trueExpr && falseExpr);
     352
     353    if (isa<Zeroes>(condition)){
     354        return renameNonNamedNode(falseExpr, std::move(prefix));
     355    }
     356    else if (isa<Ones>(condition) || equals(trueExpr, falseExpr)) {
     357        return renameNonNamedNode(trueExpr, std::move(prefix));
     358    }
     359    else if (isa<Ones>(trueExpr)) {
     360        return createOr(condition, falseExpr, prefix);
     361    }
     362    else if (isa<Zeroes>(trueExpr)){
     363        return createAnd(createNot(condition), falseExpr, prefix);
     364    }
     365    else if (isa<Ones>(falseExpr)) {
     366        return createOr(createNot(condition), trueExpr, prefix);
     367    }
     368    else if (isa<Zeroes>(falseExpr)){
     369        return createAnd(condition, trueExpr, prefix);
     370    }
     371    else if (isa<Not>(trueExpr) && equals(cast<Not>(trueExpr)->getExpr(), falseExpr)) {
     372        return createXor(condition, falseExpr, prefix);
     373    }
     374    else if (isa<Not>(falseExpr) && equals(trueExpr, cast<Not>(falseExpr)->getExpr())){
     375        return createXor(condition, falseExpr, prefix);
     376    }
     377    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false), this));
    211378}
    212379
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4433 r4438  
    8282    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount);
    8383
     84    PabloAST * createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix);
     85
     86    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount, const std::string prefix);
     87
    8488    inline Zeroes * createZeroes() const {
    8589        return mZeroes;
     
    112116    PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2);
    113117
     118    PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2, const std::string prefix);
     119
    114120    PabloAST * createNot(PabloAST * expr);
     121
     122    PabloAST * createNot(PabloAST * expr, const std::string prefix);
    115123
    116124    PabloAST * createOr(PabloAST * expr1, PabloAST * expr2);
    117125
     126    PabloAST * createOr(PabloAST * expr1, PabloAST * expr2, const std::string prefix);
     127
    118128    PabloAST * createXor(PabloAST * expr1, PabloAST * expr2);
     129
     130    PabloAST * createXor(PabloAST * expr1, PabloAST * expr2, const std::string prefix);
    119131
    120132    PabloAST * createMatchStar(PabloAST * marker, PabloAST * charclass);
    121133
     134    PabloAST * createMatchStar(PabloAST * marker, PabloAST * charclass, const std::string prefix);
     135
    122136    PabloAST * createScanThru(PabloAST * from, PabloAST * thru);
    123137
     138    PabloAST * createScanThru(PabloAST * from, PabloAST * thru, const std::string prefix);
     139
    124140    PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr);
     141
     142    PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, const std::string prefix);
    125143
    126144    If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body);
     
    151169    PabloBlock(PabloBlock * predecessor);
    152170
     171    PabloAST * renameNonNamedNode(PabloAST * expr, const std::string && prefix);
     172
    153173    template<typename Type>
    154174    inline Type * insertAtInsertionPoint(Type * expr) {
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4433 r4438  
    2020
    2121class PabloBlock;
     22class String;
    2223
    2324class PabloAST {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4433 r4438  
    5858#include <llvm/Support/MemoryBuffer.h>
    5959#include <llvm/IR/IRBuilder.h>
    60 
    6160#include "llvm/Support/CommandLine.h"
    62 
     61#include <iostream>
    6362
    6463cl::OptionCategory eIRDumpOptions("LLVM IR Dump Options", "These options control dumping of LLVM IR.");
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r4432 r4438  
    3232    }
    3333protected:
    34     Advance(PabloAST * expr, PabloAST * shiftAmount, SymbolGenerator * sg, PabloBlock * parent)
    35     : Statement(ClassTypeId::Advance, {expr, shiftAmount}, sg->make("advance"), parent)
     34    Advance(PabloAST * expr, PabloAST * shiftAmount, String * name, PabloBlock * parent)
     35    : Statement(ClassTypeId::Advance, {expr, shiftAmount}, name, parent)
    3636    {
    3737        assert(isa<Integer>(shiftAmount));
  • icGREP/icgrep-devel/icgrep/pablo/pe_and.h

    r4432 r4438  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <array>
    1211
    1312namespace pablo {
    14 
    15 class PabloBlock;
    1613
    1714class And : public Statement {
     
    3330    }
    3431protected:
    35     And(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent);
     32    And(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
     33    : Statement(ClassTypeId::And, {expr1, expr2}, name, parent)
     34    {
     35
     36    }
    3637};
    3738
  • icGREP/icgrep-devel/icgrep/pablo/pe_call.h

    r4432 r4438  
    44#include <pablo/pabloAST.h>
    55#include <pablo/pe_string.h>
    6 #include <iostream>
    76
    87namespace pablo {
  • icGREP/icgrep-devel/icgrep/pablo/pe_matchstar.h

    r4432 r4438  
    88#define PE_MATCHSTAR_H
    99
    10 #include "pabloAST.h"
    11 #include <pablo/symbol_generator.h>
    12 #include <array>
     10#include <pablo/pabloAST.h>
    1311
    1412namespace pablo {
     
    3129    virtual ~MatchStar() {}
    3230protected:
    33     MatchStar(PabloAST * marker, PabloAST * cc, SymbolGenerator * sg, PabloBlock * parent)
    34     : Statement(ClassTypeId::MatchStar, {marker, cc}, sg->make("matchstar"), parent)
     31    MatchStar(PabloAST * marker, PabloAST * cc, String * name, PabloBlock * parent)
     32    : Statement(ClassTypeId::MatchStar, {marker, cc}, name, parent)
    3533    {
    3634
  • icGREP/icgrep-devel/icgrep/pablo/pe_not.h

    r4432 r4438  
    1111
    1212namespace pablo {
    13 
    14 class PabloBlock;
    1513
    1614class Not : public Statement {
     
    2927    }
    3028protected:
    31     Not(PabloAST * expr, PabloBlock * parent);
     29    Not(PabloAST * expr, String * name, PabloBlock * parent)
     30    : Statement(ClassTypeId::Not, {expr}, name, parent)
     31    {
     32
     33    }
    3234};
    3335
  • icGREP/icgrep-devel/icgrep/pablo/pe_or.h

    r4419 r4438  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <array>
    1211
    1312namespace pablo {
    14 
    15 class PabloBlock;
    1613
    1714class Or : public Statement {
     
    3330    }
    3431protected:
    35     Or(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent);
     32    Or(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
     33    : Statement(ClassTypeId::Or, {expr1, expr2}, name, parent)
     34    {
     35
     36    }
    3637};
    3738
  • icGREP/icgrep-devel/icgrep/pablo/pe_scanthru.h

    r4432 r4438  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <pablo/symbol_generator.h>
    12 #include <array>
    1311
    1412namespace pablo {
     
    3230    }
    3331protected:
    34     ScanThru(PabloAST * from, PabloAST * thru, SymbolGenerator * sg, PabloBlock * parent)
    35     : Statement(ClassTypeId::ScanThru, {from, thru}, sg->make("scanthru"), parent)
     32    ScanThru(PabloAST * from, PabloAST * thru, String * name, PabloBlock * parent)
     33    : Statement(ClassTypeId::ScanThru, {from, thru}, name, parent)
    3634    {
    3735
  • icGREP/icgrep-devel/icgrep/pablo/pe_sel.h

    r4432 r4438  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <array>
    1211
    1312namespace pablo {
    14 
    15 class PabloBlock;
    1613
    1714class Sel : public Statement {
     
    3633    }
    3734protected:
    38     Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, PabloBlock * parent);
     35    Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, String * name, PabloBlock * parent)
     36    : Statement(ClassTypeId::Sel, {if_expr, t_expr, f_expr}, name, parent)
     37    {
     38
     39    }
    3940};
    4041
  • icGREP/icgrep-devel/icgrep/pablo/pe_xor.h

    r4432 r4438  
    1212
    1313namespace pablo {
    14 
    15 class PabloBlock;
    1614
    1715class Xor : public Statement {
     
    3331    }
    3432protected:
    35     Xor(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent);
     33    Xor(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
     34    : Statement(ClassTypeId::Xor, {expr1, expr2}, name, parent)
     35    {
     36
     37    }
    3638};
    3739
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4437 r4438  
    3030
    3131
    32 RE_Compiler::RE_Compiler(PabloBlock & baseCG, const cc::CC_NameMap & nameMap)
    33 : mCG(baseCG)
     32RE_Compiler::RE_Compiler(PabloBlock & baseCG)
     33: mPB(baseCG)
    3434, mLineFeed(nullptr)
    3535, mInitial(nullptr)
     
    4343    if (m.pos == newpos) return m;
    4444    if (m.pos > newpos) throw std::runtime_error("icgrep internal error: attempt to AdvanceMarker backwards");
    45     Assign * a = m.stream;
     45    PabloAST * a = m.stream;
    4646    if (m.pos == FinalMatchByte) {
    4747        // Must advance at least to InitialPostPositionByte
     
    7777    const std::string nonfinal = "nonfinal";
    7878
    79     Assign * LF = mCG.createAssign("LF", ccc.compileCC(makeCC(0x0A)));
     79    Assign * LF = mPB.createAssign("LF", ccc.compileCC(makeCC(0x0A)));
    8080    mLineFeed = LF;
    8181    PabloAST * CR = ccc.compileCC(makeCC(0x0D));
     
    8484    mCRLF = mCG.createAnd(mCG.createAdvance(CR, 1), mLineFeed);
    8585#else
    86     PabloBlock & crb = PabloBlock::Create(mCG);
     86    PabloBlock & crb = PabloBlock::Create(mPB);
    8787    Assign * cr1 = crb.createAssign("cr1", crb.createAdvance(CR, 1));
    8888    Assign * acrlf = crb.createAssign("crlf", crb.createAnd(cr1, LF));
    89     mCG.createIf(CR, std::move(std::vector<Assign *>{acrlf}), crb);
     89    mPB.createIf(CR, std::move(std::vector<Assign *>{acrlf}), crb);
    9090    mCRLF = acrlf;
    9191#endif
     
    112112#ifdef USE_IF_FOR_NONFINAL
    113113    PabloAST * u8pfx = ccc.compileCC(makeCC(0xC0, 0xFF));
    114     PabloBlock & it = PabloBlock::Create(mCG);
     114    PabloBlock & it = PabloBlock::Create(mPB);
    115115    PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF), it);
    116116    PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF), it);
     
    125125    PabloAST * LS_PS = it.createAnd(it.createAdvance(E2_80, 1), ccc.compileCC(makeCC(0xA8,0xA9), it));
    126126    Assign * NEL_LS_PS = it.createAssign("NEL_LS_PS", it.createOr(NEL, LS_PS));
    127     mCG.createIf(u8pfx, std::move(std::vector<Assign *>{valid_pfx, mNonFinal, NEL_LS_PS}), it);
    128     PabloAST * LB_chars = mCG.createOr(LF_VT_FF_CR, NEL_LS_PS);
     127    mPB.createIf(u8pfx, std::move(std::vector<Assign *>{valid_pfx, mNonFinal, NEL_LS_PS}), it);
     128    PabloAST * LB_chars = mPB.createOr(LF_VT_FF_CR, NEL_LS_PS);
    129129
    130130    PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
    131     mInitial = mCG.createAssign(initial, mCG.createOr(u8single, valid_pfx));
    132     mUnicodeLineBreak = mCG.createAnd(LB_chars, mCG.createNot(mCRLF));  // count the CR, but not CRLF
     131    mInitial = mPB.createAssign(initial, mPB.createOr(u8single, valid_pfx));
     132    mUnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF));  // count the CR, but not CRLF
    133133    #endif
    134134}
     
    137137    //These three lines are specifically for grep.
    138138    PabloAST * lb = UNICODE_LINE_BREAK ? mUnicodeLineBreak : mLineFeed;
    139     Assign * v = markerVar(match_result);
    140     mCG.createAssign("matches", mCG.createAnd(mCG.createMatchStar(v, mCG.createNot(lb)), lb), 0);
    141     mCG.createAssign("lf", mCG.createAnd(lb, mCG.createNot(mCRLF)), 1);
     139    PabloAST * v = markerVar(match_result);
     140    mPB.createAssign("matches", mPB.createAnd(mPB.createMatchStar(v, mPB.createNot(lb)), lb), 0);
     141    mPB.createAssign("lf", mPB.createAnd(lb, mPB.createNot(mCRLF)), 1);
    142142}
    143143
     
    147147
    148148PabloAST * RE_Compiler::character_class_strm(Name * name, PabloBlock & pb) {
    149     Assign * var = name->getCompiled();
     149    PabloAST * var = name->getCompiled();
    150150    if (var) {
    151151        return var;
     
    154154        RE * def = name->getDefinition();
    155155        if (def != nullptr) {
    156             MarkerType m = compile(def, mCG);
     156            MarkerType m = compile(def, mPB);
    157157            assert(markerPos(m) == FinalMatchByte);
    158             Assign * v = markerVar(m);
     158            PabloAST * v = markerVar(m);
    159159            name->setCompiled(v);
    160160            return v;
     
    177177    }
    178178    else {
    179         //return pb.createAdvanceThenScanThru(pb.createVar(markerVar(m), pb), mNonFinal);
    180179        return pb.createScanThru(pb.createAnd(mInitial, pb.createAdvance(markerVar(m), 1)), mNonFinal);
    181180    }
     
    212211        MarkerType m = AdvanceMarker(marker, InitialPostPositionByte, pb);
    213212        if (UNICODE_LINE_BREAK) {
    214             PabloAST * line_end = mCG.createOr(mUnicodeLineBreak, mCRLF);
     213            PabloAST * line_end = mPB.createOr(mUnicodeLineBreak, mCRLF);
    215214            PabloAST * sol = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF));
    216215            return makeMarker(InitialPostPositionByte, pb.createAssign("sol", pb.createAnd(markerVar(m), sol)));
     
    279278        MarkerType lookback = compile(asserted, pb);
    280279        AlignMarkers(m, lookback, pb);
    281         Assign * lb = markerVar(lookback);
     280        PabloAST * lb = markerVar(lookback);
    282281        if (a->getSense() == Assertion::Sense::Negative) {
    283282            lb = pb.createAssign("not", pb.createNot(lb));
     
    288287        MarkerType lookahead = compile(asserted, pb);
    289288        assert(markerPos(lookahead) == FinalMatchByte);
    290         Assign * la = markerVar(lookahead);
     289        PabloAST * la = markerVar(lookahead);
    291290        if (a->getSense() == Assertion::Sense::Negative) {
    292291            la = pb.createAssign("not", pb.createNot(la));
     
    347346*/
    348347
    349 inline Assign * RE_Compiler::consecutive1(Assign * repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {
     348inline PabloAST * RE_Compiler::consecutive1(PabloAST * repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {
    350349        int i = repeated_lgth;
    351350        int total_lgth = repeat_count * repeated_lgth;
    352         Assign * consecutive_i = repeated;
     351        PabloAST * consecutive_i = repeated;
    353352        while (i * 2 <= total_lgth) {
    354353            PabloAST * v = consecutive_i;
     
    364363}
    365364
    366 inline Assign * RE_Compiler::reachable(Assign * repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {
     365inline PabloAST * RE_Compiler::reachable(PabloAST *repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {
    367366        int i = repeated_lgth;
    368367        int total_lgth = repeat_count * repeated_lgth;
     
    370369            return repeated;
    371370        }
    372         Assign * reachable_i = pb.createAssign("within1", pb.createOr(repeated, pb.createAdvance(repeated, 1)));
     371        PabloAST * reachable_i = pb.createAssign("within1", pb.createOr(repeated, pb.createAdvance(repeated, 1)));
    373372        while (i * 2 < total_lgth) {
    374373            PabloAST * v = reachable_i;
     
    386385MarkerType RE_Compiler::processLowerBound(RE * repeated, int lb, MarkerType marker, PabloBlock & pb) {
    387386    if (isByteLength(repeated)) {
    388         Assign * cc = markerVar(compile(repeated, pb));
    389         Assign * cc_lb = consecutive1(cc, 1, lb, pb);
     387        PabloAST * cc = markerVar(compile(repeated, pb));
     388        PabloAST * cc_lb = consecutive1(cc, 1, lb, pb);
    390389        PabloAST * marker_fwd = pb.createAdvance(markerVar(marker), markerPos(marker) == FinalMatchByte ? lb : lb-1);
    391390        return makeMarker(FinalMatchByte, pb.createAssign("lowerbound", pb.createAnd(marker_fwd, cc_lb)));
     
    403402        // Create a mask of positions reachable within ub from current marker.
    404403        // Use matchstar, then apply filter.
    405         Assign * match = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));
    406         Assign * upperLimitMask = reachable(match, 1, ub, pb);
     404        PabloAST * match = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));
     405        PabloAST * upperLimitMask = reachable(match, 1, ub, pb);
    407406        PabloAST * cursor = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));
    408407        PabloAST * rep_class_var = markerVar(compile(repeated, pb));
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4437 r4438  
    4444struct MarkerType {
    4545    MarkerPosition pos;
    46     pablo::Assign * stream;
     46    pablo::PabloAST * stream;
    4747};
    4848
    4949inline MarkerPosition markerPos(MarkerType m) {return m.pos;}
    5050
    51 inline pablo::Assign * markerVar(MarkerType m) {return m.stream;}
     51inline pablo::PabloAST * markerVar(MarkerType m) {return m.stream;}
    5252   
    5353inline MarkerType makeMarker(MarkerPosition newpos, pablo::Assign * strm) {return {newpos, strm};}
     
    5757public:
    5858
    59     RE_Compiler(pablo::PabloBlock & baseCG, const cc::CC_NameMap & nameMap);
     59    RE_Compiler(pablo::PabloBlock & baseCG);
    6060    void initializeRequiredStreams(cc::CC_Compiler & ccc);
    6161    void finalizeMatchResult(MarkerType match_result);
    6262    MarkerType compile(RE * re) {
    63         return compile(re, mCG);
     63        return compile(re, mPB);
    6464    }
    6565
     
    8181    MarkerType process(Diff * diff, MarkerType marker, pablo::PabloBlock & cg);
    8282    MarkerType process(Intersect * x, MarkerType marker, pablo::PabloBlock & cg);
    83     pablo::Assign * consecutive1(pablo::Assign * repeated,  int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);
    84     pablo::Assign * reachable(pablo::Assign * repeated,  int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);
     83    pablo::PabloAST *consecutive1(pablo::PabloAST *repeated,  int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);
     84    pablo::PabloAST * reachable(pablo::PabloAST * repeated,  int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);
    8585    static bool isFixedLength(RE * regexp);
    8686    MarkerType processLowerBound(RE * repeated,  int lb, MarkerType marker, pablo::PabloBlock & pb);
     
    8888    MarkerType processBoundedRep(RE * repeated, int ub, MarkerType marker, pablo::PabloBlock & pb);
    8989
    90     pablo::PabloBlock &                             mCG;
     90    pablo::PabloBlock &                             mPB;
    9191    pablo::Assign *                                 mLineFeed;
    9292    pablo::PabloAST *                               mCRLF;
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4410 r4438  
    55#include <re/re_cc.h>
    66#include <string>
    7 #include <iostream>
    87#include <re/printer_re.h>
    98
    109namespace pablo {
    11     class Assign;
     10    class PabloAST;
    1211}
    1312
     
    3433    Type getType() const;
    3534    RE *getDefinition() const;
    36     pablo::Assign * getCompiled() const {
     35    pablo::PabloAST * getCompiled() const {
    3736        return mCompiled;
    3837    }
    39     void setCompiled(pablo::Assign * var) {
     38    void setCompiled(pablo::PabloAST * var) {
    4039        mCompiled = var;
    4140    }
     
    6261
    6362private:
    64     std::string     mNamespace;
    65     std::string     mName;
    66     const Type      mType;
    67     RE *            mDefiningRE;
    68     pablo::Assign * mCompiled;
     63    std::string         mNamespace;
     64    std::string         mName;
     65    const Type          mType;
     66    RE *                mDefiningRE;
     67    pablo::PabloAST *  mCompiled;
    6968};
    7069
Note: See TracChangeset for help on using the changeset viewer.