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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.