Changeset 4518


Ignore:
Timestamp:
Feb 25, 2015, 7:53:59 PM (4 years ago)
Author:
cameron
Message:

Modify -print-pablo output for python pablo compiler

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

Legend:

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

    r4511 r4518  
    6868        return not1->getExpr();
    6969    }
    70     return insertAtInsertionPoint(new Not(expr, makeName("not"), this));
     70    return insertAtInsertionPoint(new Not(expr, makeName("not_"), this));
    7171}
    7272
     
    153153        std::swap(expr1, expr2);
    154154    }
    155     return insertAtInsertionPoint(new And(expr1, expr2, makeName("and"), this));
     155    return insertAtInsertionPoint(new And(expr1, expr2, makeName("and_"), this));
    156156}
    157157
     
    225225        }
    226226    }
    227     return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or"), this));
     227    return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or_"), this));
    228228}
    229229
     
    288288        }
    289289    }
    290     return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor"), this));
     290    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor_"), this));
    291291}
    292292
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.cpp

    r4510 r4518  
    4141void PabloPrinter::print(const PabloBlock & block, std::ostream & strm)
    4242{
    43     print(block.statements(), "", strm);
     43    print(block.statements(), "  ", strm);
    4444}
    4545
    4646void PabloPrinter::print(const StatementList & stmts, std::ostream & strm) {
    47     print(stmts, "", strm);
     47    print(stmts, "  ", strm);
    4848}
    4949
     
    5252        print(stmt, indent, strm);
    5353        strm << std::endl;
     54    }
     55}
     56
     57void PabloPrinter::print_vars(const DefinedVars & vars, std::string indent, std::ostream & strm) {
     58    for (const PabloAST * v : vars) {
     59        strm << indent << dyn_cast<Assign>(v)->getName() << " = 0" << std::endl;
    5460    }
    5561}
     
    6268    else if (const Assign * an = dyn_cast<const Assign>(stmt)) {
    6369        if (an->isOutputAssignment()) {
    64             strm << "Output[" << std::to_string(an->getOutputIndex()) << "].";
     70            strm << "output.";
    6571        }
    6672        strm << an->getName() << " = ";
     
    7682        strm << ":" << std::endl;
    7783        print(ifstmt->getBody(), indent + "  ", strm);
     84        strm << indent << "else:" << std::endl;
     85        print_vars(ifstmt->getDefined(), indent + "  ", strm);
    7886    }
    7987    else if (const While * whl = dyn_cast<const While>(stmt)) {
     
    165173    }
    166174    else if (const Var * var = dyn_cast<const Var>(expr)) {
    167         strm << var->getName();
     175        strm  << var->getName();
    168176    }
    169177    else if (const Statement * stmt = dyn_cast<Statement>(expr)) {
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.h

    r4346 r4518  
    99
    1010#include <pablo/pabloAST.h>
     11#include <pablo/ps_if.h>
    1112#include <string>
    1213
     
    1718class PabloPrinter {
    1819public:
     20    using DefinedVars = std::vector<pablo::PabloAST *, pablo::PabloAST::VectorAllocator>;
    1921    static void print(const pablo::PabloBlock & block, std::ostream & strm);
    2022    static void print(const pablo::StatementList & stmts, std::ostream & strm);
    2123    static void print(const pablo::StatementList & stmts, std::string indent, std::ostream & strm);
     24    static void print_vars(const DefinedVars & vars, std::string indent, std::ostream & strm);
    2225    static void print(const pablo::PabloAST * expr, std::ostream & strm);
    2326    static void print(const pablo::Statement *stmt, std::string indent, std::ostream & strm);
  • icGREP/icgrep-devel/icgrep/re/re_cc.cpp

    r4510 r4518  
    3636        name << "CC";
    3737    }
    38     char separator = '_';
     38    char separator = '__';
    3939    for (const CharSetItem & i : mSparseCharSet) {
    4040        name << separator;
     
    4343        }
    4444        else {
    45             name << i.lo_codepoint << '-' << i.hi_codepoint;
     45            name << i.lo_codepoint << '_' << i.hi_codepoint;
    4646        }
    47         separator = ',';
    4847    }
    4948    return name.str();
Note: See TracChangeset for help on using the changeset viewer.