Changeset 4252


Ignore:
Timestamp:
Oct 20, 2014, 10:49:33 AM (4 years ago)
Author:
nmedfort
Message:

Transitory check-in; initial integration of pablo Next nodes and enforcement of SSA form for all Assign nodes.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r4249 r4252  
    5858    else if (isa<Seq>(re)) {
    5959        return compile_re(cast<Seq>(re));
    60     }
    61     else if (isa<CC>(re)) {
    62 
    6360    }
    6461    throw std::runtime_error("Unexpected RE node given to CC_Compiler: " + Printer_RE::PrintRE(re));
     
    103100            break;
    104101        }
    105         assignment = mCG.createAssign(mCG.ssa("seq"), mCG.createAdvance(result));
     102        assignment = mCG.createAssign("seq", mCG.createAdvance(result));
    106103    }
    107104    return result;
     
    118115            break;
    119116        }
    120         assignment = mCG.createAssign(mCG.ssa("alt"), result);
     117        assignment = mCG.createAssign("alt", result);
    121118    }
    122119    return result;
     
    315312//        return cast<Var>(value);
    316313//    }
    317 //    return mCG.createVar(mCG.createAssign(mCG.ssa("t"), value));
     314//    return mCG.createVar(mCG.createAssign("t", value));
    318315    return value;
    319316}
  • icGREP/icgrep-devel/icgrep/cc/cc_namemap.cpp

    r4249 r4252  
    2121    insert(std::move(classname), name);
    2222    assert (name->getCC() == cc);
    23 }
    24 
    25 void CC_NameMap::clear() {
    26     mNameMap.clear();
    27     mNameVector.clear();
    2823}
    2924
  • icGREP/icgrep-devel/icgrep/cc/cc_namemap.hpp

    r4249 r4252  
    2222
    2323    CC_NameMap() {}
    24 
    25     void clear();
    2624
    2725    re::RE * process(re::RE * re);
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r4249 r4252  
    187187cc/cc_namemap.cpp
    188188cc/cc_namemap.hpp
     189pablo/codegenstate.cpp
     190pablo/codegenstate.h
     191pablo/pabloAST.cpp
     192pablo/pabloAST.h
     193pablo/pablo_compiler.cpp
     194pablo/pablo_compiler.h
     195pablo/pe_advance.h
     196pablo/pe_all.cpp
     197pablo/pe_all.h
     198pablo/pe_and.cpp
     199pablo/pe_and.h
     200pablo/pe_call.h
     201pablo/pe_matchstar.h
     202pablo/pe_next.h
     203pablo/pe_not.cpp
     204pablo/pe_not.h
     205pablo/pe_ones.h
     206pablo/pe_or.cpp
     207pablo/pe_or.h
     208pablo/pe_scanthru.h
     209pablo/pe_sel.cpp
     210pablo/pe_sel.h
     211pablo/pe_string.h
     212pablo/pe_var.h
     213pablo/pe_xor.cpp
     214pablo/pe_xor.h
     215pablo/pe_zeroes.h
     216pablo/printer_pablos.cpp
     217pablo/printer_pablos.h
     218pablo/ps_assign.h
     219pablo/ps_if.h
     220pablo/ps_while.h
     221pablo/symbol_generator.cpp
     222pablo/symbol_generator.h
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r4249 r4252  
    1616
    1717Call * PabloBlock::createCall(const std::string name) {
    18     return mUnary.findOrMake<Call>(PabloAST::ClassTypeId::Call, mSymbolGenerator[name]);
     18    return mUnary.findOrMake<Call>(PabloAST::ClassTypeId::Call, mSymbolGenerator.get(name));
    1919}
    2020
     
    2424
    2525Var * PabloBlock::createVar(const std::string name) {
    26     return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, mSymbolGenerator[name]);
     26    return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, mSymbolGenerator.get(name));
    2727}
    2828
    29 Var * PabloBlock::createVar(Assign * assign) {
    30     return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, const_cast<String *>(assign->mName));
     29Var * PabloBlock::createVar(String * name) {
     30    return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, name);
    3131}
    3232
    3333/// BINARY CREATE FUNCTIONS
     34
     35Next * PabloBlock::createNext(Assign * assign, PabloAST * expr) {
     36    Next * next = mBinary.findOrMake<Next>(PabloAST::ClassTypeId::Next, assign, expr);
     37    mStatements.push_back(next);
     38    return next;
     39}
     40
     41MatchStar * PabloBlock::createMatchStar(PabloAST * marker, PabloAST * charclass) {
     42    return mBinary.findOrMake<MatchStar>(PabloAST::ClassTypeId::MatchStar, marker, charclass);
     43}
     44
     45ScanThru * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru) {
     46    return mBinary.findOrMake<ScanThru>(PabloAST::ClassTypeId::ScanThru, from, thru);
     47}
    3448
    3549PabloAST * PabloBlock::createAnd(PabloAST * expr1, PabloAST * expr2) {
     
    4054}
    4155
    42 Assign * PabloBlock::createAssign(const std::string name, PabloAST * expr) {
    43     auto key = std::make_tuple(PabloAST::ClassTypeId::Assign, expr);
    44     Assign * assign = cast_or_null<Assign>(mUnary.find(key));
    45     if (assign == nullptr) {
    46         assign = new Assign(mSymbolGenerator[name], expr);
    47         mUnary.insert(std::move(key), assign);
    48     }
    49     else {
    50         assign = new Assign(mSymbolGenerator[name], createVar(assign));
    51     }
    52 //    Assign * assign = mBinary.findOrMake<Assign>(PabloAST::ClassTypeId::Assign, mSymbolGenerator[name], expr);
    53     mStatements.push_back(assign);
    54     return assign;
    55 }
    56 
    57 MatchStar * PabloBlock::createMatchStar(PabloAST * expr1, PabloAST * expr2) {
    58     return mBinary.findOrMake<MatchStar>(PabloAST::ClassTypeId::MatchStar, expr1, expr2);
    59 }
    60 
    6156PabloAST * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2) {
    6257    if (expr1 < expr2) {
     
    6459    }
    6560    return mBinary.findOrCall<OptimizeOr>(PabloAST::ClassTypeId::Or, expr1, expr2);
    66 }
    67 
    68 ScanThru * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru) {
    69     return mBinary.findOrMake<ScanThru>(PabloAST::ClassTypeId::ScanThru, from, thru);
    7061}
    7162
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4249 r4252  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <pablo/pe_string.h>
     11#include <pablo/pabloAST.h>
    1212#include <pablo/pe_advance.h>
    1313#include <pablo/pe_and.h>
    1414#include <pablo/pe_call.h>
    1515#include <pablo/pe_matchstar.h>
     16#include <pablo/pe_next.h>
    1617#include <pablo/pe_not.h>
     18#include <pablo/pe_ones.h>
    1719#include <pablo/pe_or.h>
    18 #include <pablo/pabloAST.h>
    1920#include <pablo/pe_scanthru.h>
    2021#include <pablo/pe_sel.h>
     22#include <pablo/pe_string.h>
    2123#include <pablo/pe_var.h>
    2224#include <pablo/pe_xor.h>
     25#include <pablo/pe_zeroes.h>
    2326#include <pablo/ps_assign.h>
    2427#include <pablo/ps_if.h>
    2528#include <pablo/ps_while.h>
    26 #include <pablo/pe_zeroes.h>
    27 #include <pablo/pe_ones.h>
    2829#include <pablo/symbol_generator.h>
    2930#include <map>
     
    5152    PabloBlock(PabloBlock & cg)
    5253    : mSymbolGenerator(cg.mSymbolGenerator)
    53     , mZeroes(cg.mZeroes) // inherit the original "All" variables for simplicity
    54     , mOnes(cg.mOnes) // inherit the original "All" variables for simplicity
     54    , mZeroes(cg.mZeroes) // inherit the original "Zeroes" variable for simplicity
     55    , mOnes(cg.mOnes) // inherit the original "Ones" variable for simplicity
    5556    , mUnary(&(cg.mUnary), this)
    5657    , mBinary(&(cg.mBinary), this)
     
    7071    }
    7172
    72     Assign * createAssign(const std::string name, PabloAST * expr);
    73 
    7473    Call * createCall(const std::string name);
    7574
     75    inline Assign * createAssign(const std::string prefix, PabloAST * expr) {
     76        Assign * assign = new Assign(mSymbolGenerator.get_ssa(prefix), expr);
     77        mStatements.push_back(assign);
     78        return assign;
     79    }
     80
    7681    Var * createVar(const std::string name);
    7782
    78     Var * createVar(Assign * assign);
    79 
    80     inline PabloAST * createVarIfAssign(PabloAST * const input) {
    81         return isa<Assign>(input) ? createVar(cast<Assign>(input)) : input;
    82     }
     83    Var * createVar(String * name);
     84
     85    inline Var * createVar(Assign * assign) {
     86        return createVar(assign->mName);
     87    }
     88
     89    inline Var * createVar(Next * next) {
     90        return createVar(next->mInitial->mName);
     91    }
     92
     93    inline PabloAST * createVar(PabloAST * const input) {
     94        switch (input->getClassTypeId()) {
     95            case PabloAST::ClassTypeId::Assign:
     96                return createVar(cast<Assign>(input));
     97            case PabloAST::ClassTypeId::Next:
     98                return createVar(cast<Next>(input));
     99            default:
     100                return input;
     101        }
     102    }
     103
     104    Next * createNext(Assign * assign, PabloAST * expr);
    83105
    84106    PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2);
     
    90112    PabloAST * createXor(PabloAST * expr1, PabloAST * expr2);
    91113
    92     MatchStar * createMatchStar(PabloAST * expr1, PabloAST * expr2);
     114    MatchStar * createMatchStar(PabloAST * marker, PabloAST * charclass);
    93115
    94116    ScanThru * createScanThru(PabloAST * from, PabloAST * thru);
     
    122144        template <class Type>
    123145        inline Type * findOrMake(const PabloAST::ClassTypeId type, Args... args) {
    124             auto key = std::make_tuple(type, args...);
     146            Key key = std::make_tuple(type, args...);
    125147            PabloAST * f = find(key);
    126148            if (f) {
     
    134156        template <class Functor>
    135157        inline PabloAST * findOrCall(const PabloAST::ClassTypeId type, Args... args) {
    136             auto key = std::make_tuple(type, args...);
     158            Key key = std::make_tuple(type, args...);
    137159            PabloAST * f = find(key);
    138160            if (f) {
     
    140162            }
    141163            Functor mf(mCodeGenState);
    142             PabloAST * expr = mf(args...);           
     164            PabloAST * expr = mf(args...);
    143165            insert(std::move(key), expr);
    144166            return expr;
     
    169191
    170192    private:
    171         MapType * const         mPredecessor;
    172         PabloBlock &            mCodeGenState;
    173         std::map<Key, PabloAST *> mMap;
     193        MapType * const             mPredecessor;
     194        PabloBlock &                mCodeGenState;
     195        std::map<Key, PabloAST *>   mMap;
    174196    };
    175 
    176     inline std::string ssa(std::string prefix) { // Static Single-Assignment
    177         return mSymbolGenerator.ssa(prefix);
    178     }
    179197
    180198    inline const ExpressionList & expressions() const {
     
    183201
    184202private:   
    185     SymbolGenerator &                               mSymbolGenerator;
    186     Zeroes *                                        mZeroes;
    187     Ones *                                  mOnes;
    188     ExpressionMap<PabloAST *>                         mUnary;
     203    SymbolGenerator &                                   mSymbolGenerator;
     204    Zeroes *                                            mZeroes;
     205    Ones *                                              mOnes;
     206    ExpressionMap<PabloAST *>                           mUnary;
    189207    ExpressionMap<PabloAST *, PabloAST *>               mBinary;
    190     ExpressionMap<PabloAST *, PabloAST *, PabloAST *>     mTernary;
    191     ExpressionList                                  mStatements;
     208    ExpressionMap<PabloAST *, PabloAST *, PabloAST *>   mTernary;
     209    ExpressionList                                      mStatements;
    192210};
    193211
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r4249 r4252  
    8888}
    8989
    90 
    91 
    92 PabloAST::~PabloAST(){ }
    93 
    94 
    95 
    9690}
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4247 r4252  
    1010#include <llvm/Support/Casting.h>
    1111#include <llvm/IR/Value.h>
    12 #include <list>
     12#include <vector>
    1313
    1414using namespace llvm;
     
    2121        Advance
    2222        , And
     23        , Assign
    2324        , Call
    2425        , CharClass
     26        , If
    2527        , MatchStar
     28        , Next
    2629        , Not
     30        , Ones
    2731        , Or
    2832        , ScanThru
    2933        , Sel
     34        , String
    3035        , Var
     36        , While
    3137        , Xor
    32         , Assign
    33         , If
    34         , While
    35         , String
    3638        , Zeroes
    37         , Ones
    3839    };
    3940    inline ClassTypeId getClassTypeId() const {
    4041        return mClassTypeId;
    4142    }
    42     virtual ~PabloAST() = 0;
    4343protected:
    4444    inline PabloAST(const ClassTypeId id)
     
    5252bool equals(const PabloAST * expr1, const PabloAST *expr2);
    5353
    54 typedef std::list<PabloAST *> ExpressionList;
     54typedef std::vector<PabloAST *> ExpressionList;
    5555
    5656}
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4250 r4252  
    183183    ReturnInst::Create(mMod->getContext(), mBasicBlock);
    184184
     185    //Un-comment this line in order to display the IR that has been generated by this module.
     186    #ifdef DUMP_GENERATED_IR
     187    mMod->dump();
     188    #endif
     189
    185190    //Create a verifier.  The verifier will print an error message if our module is malformed in any way.
    186191    #ifdef USE_LLVM_3_5
     
    189194    #ifdef USE_LLVM_3_4
    190195    verifyModule(*mMod, PrintMessageAction);
    191     #endif
    192 
    193     //Un-comment this line in order to display the IR that has been generated by this module.
    194     #ifdef DUMP_GENERATED_IR
    195     mMod->dump();
    196196    #endif
    197197
     
    508508    if (const Assign * assign = dyn_cast<const Assign>(stmt))
    509509    {
     510        Value * expr = compileExpression(assign->getExpr());
     511        Value * marker = nullptr;
    510512        IRBuilder<> b(mBasicBlock);
    511         Value * marker = GetMarker(assign->getName());
    512         Value * expr = compileExpression(assign->getExpr());
     513        auto f = mMarkerMap.find(assign->getName());
     514        if (f == mMarkerMap.end()) {
     515            marker = b.CreateAlloca(mXi64Vect, 0, assign->getName());
     516            mMarkerMap.insert(std::make_pair(assign->getName(), marker));
     517        }
     518        else {
     519            marker = f->second;
     520        }
     521        b.CreateStore(expr, marker);
     522        retVal = marker;
     523    }
     524    if (const Next * next = dyn_cast<const Next>(stmt))
     525    {
     526        IRBuilder<> b(mBasicBlock);
     527        auto f = mMarkerMap.find(next->getName());
     528        assert (f != mMarkerMap.end());
     529        Value * marker = f->second;
     530        Value * expr = compileExpression(next->getExpr());
    513531        b.CreateStore(expr, marker);
    514532        retVal = marker;
     
    624642    Value * retVal = nullptr;
    625643    IRBuilder<> b(mBasicBlock);
    626     if (isa<Ones>(expr))
    627     {
     644    if (isa<Ones>(expr)) {
    628645        retVal = mOneInitializer;
    629646    }
    630     else if (isa<Zeroes>(expr))
    631     {
     647    else if (isa<Zeroes>(expr)) {
    632648        retVal = mZeroInitializer;
    633649    }
    634     else if (const Call* call = dyn_cast<Call>(expr))
    635     {
     650    else if (const Call* call = dyn_cast<Call>(expr)) {
    636651        //Call the callee once and store the result in the marker map.
    637652        auto mi = mMarkerMap.find(call->getCallee());
     
    650665    else if (const Var * var = dyn_cast<Var>(expr))
    651666    {
    652         retVal = b.CreateLoad(GetMarker(var->getName()), false, var->getName());
     667        auto f = mMarkerMap.find(var->getName());
     668        assert (f != mMarkerMap.end());
     669        retVal = b.CreateLoad(f->second, false, var->getName());
    653670    }
    654671    else if (const And * pablo_and = dyn_cast<And>(expr))
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.cpp

    r4249 r4252  
    4545    strOut += "],[";
    4646
    47     strOut = Print_PB_PabloStmts(cg_state.expressions(), strOut);
     47    strOut += Print_PB_PabloStmts(cg_state.expressions());
    4848
    4949    strOut = strOut.substr(0, strOut.length() - 1);
     
    5353}
    5454
    55 std::string StatementPrinter::Print_PB_PabloStmts(const ExpressionList & stmts, std::string strOut) {
     55std::string StatementPrinter::Print_PB_PabloStmts(const ExpressionList & stmts) {
     56    std::string strOut = "";
    5657    for (const auto stmt : stmts) {
    5758        strOut += ShowPabloS(stmt);
     
    7071std::string StatementPrinter::ShowPabloS(const PabloAST * stmt)
    7172{
    72     std::string retVal = "";
    73 
    74     if (const Assign * an = dyn_cast<const Assign>(stmt))
    75     {
    76         retVal = "Assign('" + an->getName() + "', " + ShowPabloAST(an->getExpr()) + "),";
     73    if (const Assign * an = dyn_cast<const Assign>(stmt)) {
     74        return "Assign('" + an->getName() + "', " + ShowPabloAST(an->getExpr()) + "),";
    7775    }
    78     else if (const If * ifstmt = dyn_cast<const If>(stmt))
    79     {
    80         retVal = "If(" + ShowPabloAST(ifstmt->getCondition()) + ", " + Print_PB_PabloStmts(ifstmt->getBody(), retVal) + ")";
     76    else if (const Next * next = dyn_cast<const Next>(stmt)) {
     77        return "Next(" + next->getName() + ", " + ShowPabloAST(next->getExpr()) + ")";
    8178    }
    82     else if (const While * whl = dyn_cast<const While>(stmt))
    83     {
    84         retVal = "While(" + ShowPabloAST(whl->getCondition()) + ", " + Print_PB_PabloStmts(whl->getBody(), retVal) + ")";
     79    else if (const If * ifstmt = dyn_cast<const If>(stmt)) {
     80        return "If(" + ShowPabloAST(ifstmt->getCondition()) + ", " + Print_PB_PabloStmts(ifstmt->getBody()) + ")";
    8581    }
    86     else retVal = "UNKNOWN_STATEMENT_TYPE!!!";
    87     return retVal;
     82    else if (const While * whl = dyn_cast<const While>(stmt)) {
     83        return "While(" + ShowPabloAST(whl->getCondition()) + ", " + Print_PB_PabloStmts(whl->getBody()) + ")";
     84    }
     85    return "???";
    8886}
    8987
    90 std::string StatementPrinter::ShowPabloAST(const PabloAST *expr)
    91 {
    92     std::string retVal = "";
    93 
    94     if (isa<const Zeroes>(expr))
    95     {
    96         retVal = "Zeroes";
     88std::string StatementPrinter::ShowPabloAST(const PabloAST *expr) {
     89    if (isa<const Zeroes>(expr)) {
     90        return "Zeroes";
    9791    }
    98     else if (isa<const Ones>(expr))
    99     {
    100         retVal = "Ones";
     92    else if (isa<const Ones>(expr)) {
     93        return "Ones";
    10194    }
    102     else if (const Call * pablo_call = dyn_cast<const Call>(expr))
    103     {
    104         retVal = "Call '" + pablo_call->getCallee() + "'";
     95    else if (const Call * pablo_call = dyn_cast<const Call>(expr)) {
     96        return "Call '" + pablo_call->getCallee() + "'";
    10597    }
    106     else if (const Var * pablo_var = dyn_cast<const Var>(expr))
    107     {
    108         retVal = "Var '" + pablo_var->getName() + "' ";
     98    else if (const Var * pablo_var = dyn_cast<const Var>(expr)) {
     99        return "Var '" + pablo_var->getName() + "' ";
    109100    }
    110     else if (const And * pablo_and = dyn_cast<const And>(expr))
    111     {
    112         retVal = "And(" + ShowPabloAST(pablo_and->getExpr1()) +", " + ShowPabloAST(pablo_and->getExpr2()) + ")";
     101    else if (const And * pablo_and = dyn_cast<const And>(expr)) {
     102        return "And(" + ShowPabloAST(pablo_and->getExpr1()) +", " + ShowPabloAST(pablo_and->getExpr2()) + ")";
    113103    }
    114     else if (const Or * pablo_or = dyn_cast<const Or>(expr))
    115     {
    116         retVal = "Or(" + ShowPabloAST(pablo_or->getExpr1()) + ", " + ShowPabloAST(pablo_or->getExpr2()) + ")";
     104    else if (const Or * pablo_or = dyn_cast<const Or>(expr)) {
     105        return "Or(" + ShowPabloAST(pablo_or->getExpr1()) + ", " + ShowPabloAST(pablo_or->getExpr2()) + ")";
    117106    }
    118     else if (const Sel * pablo_sel = dyn_cast<const Sel>(expr))
    119     {
    120         retVal = "((" + ShowPabloAST(pablo_sel->getCondition()) + "And " + ShowPabloAST(pablo_sel->getTrueExpr()) +
     107    else if (const Sel * pablo_sel = dyn_cast<const Sel>(expr)) {
     108        return "((" + ShowPabloAST(pablo_sel->getCondition()) + "And " + ShowPabloAST(pablo_sel->getTrueExpr()) +
    121109                ")|(Not(" + ShowPabloAST(pablo_sel->getCondition()) + ") And " + ShowPabloAST(pablo_sel->getFalseExpr()) + ")";
    122110    }
    123     else if (const Not * pablo_not = dyn_cast<const Not>(expr))
    124     {
    125         retVal = "Not (" + ShowPabloAST(pablo_not->getExpr()) + ")";
     111    else if (const Not * pablo_not = dyn_cast<const Not>(expr)) {
     112        return "Not (" + ShowPabloAST(pablo_not->getExpr()) + ")";
    126113    }
    127     else if (const Advance * adv = dyn_cast<const Advance>(expr))
    128     {
    129         retVal = "Advance(" + ShowPabloAST(adv->getExpr()) + ")";
     114    else if (const Advance * adv = dyn_cast<const Advance>(expr)) {
     115        return "Advance(" + ShowPabloAST(adv->getExpr()) + ")";
    130116    }
    131     else if (const MatchStar * mstar = dyn_cast<const MatchStar>(expr))
    132     {
    133         retVal = "MatchStar (" + ShowPabloAST(mstar->getExpr1()) + ", " + ShowPabloAST(mstar->getExpr2()) + ")";
     117    else if (const MatchStar * mstar = dyn_cast<const MatchStar>(expr)) {
     118        return "MatchStar (" + ShowPabloAST(mstar->getExpr1()) + ", " + ShowPabloAST(mstar->getExpr2()) + ")";
    134119    }
    135     else if (const ScanThru * sthru = dyn_cast<const ScanThru>(expr))
    136     {
    137         retVal = "ScanThru (" + ShowPabloAST(sthru->getScanFrom()) + ", " + ShowPabloAST(sthru->getScanThru()) + ")";
     120    else if (const ScanThru * sthru = dyn_cast<const ScanThru>(expr)) {
     121        return "ScanThru (" + ShowPabloAST(sthru->getScanFrom()) + ", " + ShowPabloAST(sthru->getScanThru()) + ")";
    138122    }
    139     else retVal = "UNKNOWN_Pablo_EXPRESSION_TYPE!!!";
    140 
    141     return retVal;
     123    return "???";
    142124}
    143125
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.h

    r4244 r4252  
    1919    static std::string PrintStmts(const pablo::PabloBlock & cg_state);
    2020    static std::string Print_CC_PabloStmts(const pablo::ExpressionList & stmts);
    21     static std::string Print_PB_PabloStmts(const pablo::ExpressionList & stmts, std::string strOut);
     21    static std::string Print_PB_PabloStmts(const pablo::ExpressionList & stmts);
    2222    static std::string ShowPabloAST(const pablo::PabloAST * expr);
    2323    static std::string ShowPabloS(const pablo::PabloAST *stmt);
  • icGREP/icgrep-devel/icgrep/pablo/ps_assign.h

    r4244 r4252  
    88#define PS_SETMARKER_H
    99
    10 #include <pablo/pabloAST.h>
    1110#include <pablo/pe_string.h>
    1211
     
    1514class Assign : public PabloAST {
    1615    friend class PabloBlock;
     16    friend class Next;
    1717public:
    1818    static inline bool classof(const PabloAST * e) {
     
    3939    }
    4040private:
    41     const String * const    mName;
    42     PabloAST * const          mExpr;
     41    String * const          mName;
     42    PabloAST * const        mExpr;
    4343};
    4444
  • icGREP/icgrep-devel/icgrep/pablo/symbol_generator.cpp

    r4214 r4252  
    1313: mPrefixMap()
    1414{
     15
    1516}
    1617
    17 std::string SymbolGenerator::ssa(std::string prefix) {
    18     auto f = mPrefixMap.find(prefix);
    19     unsigned count = 0;
    20     if (f == mPrefixMap.end()) {
    21         mPrefixMap.insert(std::make_pair(prefix, 1));
    22     }
    23     else {
    24         count = f->second++;
    25     }
    26     return prefix + std::to_string(count);
    27 }
    28 
    29 String * SymbolGenerator::operator[](const std::string string) {
    30     auto f = mStringMap.find(string);
     18String * SymbolGenerator::get(const std::string name) {
     19    auto f = mStringMap.find(name);
    3120    String * result;
    3221    if (f == mStringMap.end()) {
    33         result = makeString(string);
    34         mStringMap.insert(std::make_pair(*result, result));
     22        result = makeString(name);
     23        mStringMap.insert(std::make_pair(name, result));
    3524    }
    3625    else {
     
    4029}
    4130
     31String * SymbolGenerator::get_ssa(const std::string prefix) {
     32    auto f = mPrefixMap.find(prefix);
     33    unsigned count = 0;
     34    if (f == mPrefixMap.end()) {
     35        mPrefixMap.insert(std::make_pair(prefix, 1));
     36        return get(prefix);
     37    }
     38    else {
     39        count = f->second++;
     40        return get(prefix + std::to_string(count));
     41    }
    4242}
     43
     44
     45}
  • icGREP/icgrep-devel/icgrep/pablo/symbol_generator.h

    r4227 r4252  
    2020    SymbolGenerator();
    2121
    22     std::string ssa(std::string prefix);
     22    String * get(const std::string name);
    2323
    24     String * operator[](const std::string string);
     24    String * get_ssa(const std::string prefix);
    2525
    2626private:
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4249 r4252  
    7676
    7777    //These three lines are specifically for grep.
    78     cg.createAssign(cg.ssa("matches"), cg.createAnd(cg.createMatchStar(cg.createVarIfAssign(result), cg.createNot(mLineFeed)), mLineFeed));
     78    cg.createAssign("matches", cg.createAnd(cg.createMatchStar(cg.createVar(result), cg.createNot(mLineFeed)), mLineFeed));
    7979}
    8080
     
    9999        marker = cg.createScanThru(marker, mNonFinal);
    100100        PabloAST * dot = cg.createNot(mLineFeed);
    101         target = cg.createAssign(cg.ssa("dot"), cg.createAdvance(cg.createAnd(marker, dot)));
     101        target = cg.createAssign("dot", cg.createAdvance(cg.createAnd(marker, dot)));
    102102    }
    103103    else if (isa<Start>(re)) {
    104104        PabloAST * sol = cg.createNot(cg.createAdvance(cg.createNot(mLineFeed)));
    105         target = cg.createAssign(cg.ssa("sol"), cg.createAnd(cg.createVarIfAssign(target), sol));
     105        target = cg.createAssign("sol", cg.createAnd(cg.createVar(target), sol));
    106106    }
    107107    else if (isa<End>(re)) {
    108108        PabloAST * eol = mLineFeed;
    109         target = cg.createAssign(cg.ssa("eol"), cg.createAnd(cg.createVarIfAssign(target), eol));
     109        target = cg.createAssign("eol", cg.createAnd(cg.createVar(target), eol));
    110110    }
    111111
     
    130130        cc = cg.createNot(cg.createOr(cg.createOr(cc, mLineFeed), mNonFinal));
    131131    }
    132     return cg.createAssign(cg.ssa("marker"), cg.createAdvance(cg.createAnd(cc, marker)));
     132    return cg.createAssign("m", cg.createAdvance(cg.createAnd(cc, marker)));
    133133}
    134134
     
    142142inline Assign * RE_Compiler::process(Alt * alt, Assign * target, PabloBlock & cg) {
    143143    if (alt->empty()) {
    144         target = cg.createAssign(cg.ssa("fail"), cg.createZeroes()); // always fail (note: I'm not sure this ever occurs. How do I create a 0-element alternation?)
     144        target = cg.createAssign("fail", cg.createZeroes()); // always fail (note: I'm not sure this ever occurs. How do I create a 0-element alternation?)
    145145    }
    146146    else {
     
    150150        while (++i != alt->end()) {
    151151            Assign * other = process(*i, base, cg);
    152             target = cg.createAssign(cg.ssa("alt"), cg.createOr(cg.createVar(target), cg.createVar(other)));
     152            target = cg.createAssign("alt", cg.createOr(cg.createVar(target), cg.createVar(other)));
    153153        }
    154154    }   
     
    167167
    168168inline Assign * RE_Compiler::processUnboundedRep(RE * repeated, int lb, Assign * target, PabloBlock & cg) {
     169
     170    PabloAST * unbounded = nullptr;
     171
    169172    while (lb-- != 0) {
    170173        target = process(repeated, target, cg);
     
    172175
    173176    if (isa<Name>(repeated)) {
    174         Name * rep_name = dyn_cast<Name>(repeated);
     177        Name * rep_name = cast<Name>(repeated);
    175178
    176179        PabloAST * cc;
     
    183186
    184187        if (rep_name->isNegated()) {
    185             cc = cg.createNot(cg.createOr(cg.createOr(cc, mLineFeed), mNonFinal));
    186         }
    187 
    188         PabloAST * unbounded = cg.createVar(target);
     188            cc = cg.createNot(cg.createOr(cc, cg.createOr(mLineFeed, mNonFinal)));
     189        }
     190
     191        unbounded = cg.createVar(target);
    189192        if (rep_name->getType() == Name::Type::FixedLength) {
    190193            unbounded = cg.createMatchStar(unbounded, cc);
     
    192195        else { // Name::Unicode and Name::UnicodeCategory
    193196            unbounded = cg.createAnd(cg.createMatchStar(unbounded, cg.createOr(mNonFinal, cc)), mInitial);
    194         }
    195         target = cg.createAssign(cg.ssa("marker"), unbounded);
     197        }       
    196198    }
    197199    else if (isa<Any>(repeated)) {
    198200        PabloAST * dot = cg.createNot(mLineFeed);
    199         PabloAST * unbounded = cg.createVar(target);
     201        unbounded = cg.createVar(target);
    200202        unbounded = cg.createAnd(cg.createMatchStar(unbounded, cg.createOr(mNonFinal, dot)), mInitial);
    201         target = cg.createAssign(cg.ssa("marker"), unbounded);
    202     }
    203 
     203    }
    204204    else {
    205205
    206206        Var * targetVar = cg.createVar(target);
    207207
    208         Assign * while_test = cg.createAssign(cg.ssa("while_test"), targetVar);
    209         Assign * while_accum = cg.createAssign(cg.ssa("while_accum"), targetVar);
     208        Assign * whileTest = cg.createAssign("test", targetVar);
     209        Assign * whileAccum = cg.createAssign("accum", targetVar);
    210210
    211211        PabloBlock wt(cg);
    212         PabloAST * accum = cg.createVarIfAssign(process(repeated, while_test, wt));
    213         Var * var_while_test = cg.createVar(while_accum);
    214         wt.createAssign(while_test->getName(), wt.createAnd(accum, wt.createNot(var_while_test)));
    215         target = wt.createAssign(while_accum->getName(), wt.createOr(var_while_test, accum));
    216         cg.createWhile(cg.createVar(while_test), std::move(wt));
     212
     213        Var * loopComputation = wt.createVar(process(repeated, whileTest, wt));
     214
     215        Var * whileAccumVar = wt.createVar(whileAccum);
     216
     217        wt.createNext(whileTest, wt.createAnd(loopComputation, wt.createNot(whileAccumVar)));
     218
     219        wt.createNext(whileAccum, wt.createOr(loopComputation, whileAccumVar));
     220
     221        cg.createWhile(cg.createVar(whileTest), std::move(wt));
     222
     223        unbounded = whileAccumVar;
    217224    }   
    218     return target;
     225    return cg.createAssign("unbounded", unbounded);
    219226}
    220227
     
    226233    while (ub-- != 0) {
    227234        Assign * alt = process(repeated, target, cg);
    228         target = cg.createAssign(cg.ssa("alt"), cg.createOr(cg.createVar(target), cg.createVar(alt)));
     235        target = cg.createAssign("alt", cg.createOr(cg.createVar(target), cg.createVar(alt)));
    229236    }
    230237    return target;
Note: See TracChangeset for help on using the changeset viewer.