Changeset 4511


Ignore:
Timestamp:
Feb 19, 2015, 1:53:09 PM (4 years ago)
Author:
nmedfort
Message:

Added vector support for If defined vars back.

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

Legend:

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

    r4437 r4511  
    167167    }
    168168
    169     //Reduce the list so that all of the expressions are contained within a single expression.
    170     while (bit_terms.size() > 1)
    171     {
    172         std::vector<PabloAST*> new_terms;
    173         for (auto i = 0; i < (bit_terms.size()/2); i++)
    174         {
    175             new_terms.push_back(pb.createAnd(bit_terms[(2 * i) + 1], bit_terms[2 * i]));
    176         }
    177         if (bit_terms.size() % 2 == 1)
    178         {
    179             new_terms.push_back(bit_terms[bit_terms.size() -1]);
    180         }
    181         bit_terms.swap(new_terms);
     169    if (bit_terms.size() > 1) {
     170        //Reduce the list so that all of the expressions are contained within a single expression.
     171        std::vector<PabloAST*> new_terms(bit_terms.size() / 2);
     172        do
     173        {
     174            new_terms.clear();
     175            for (auto i = 0; i < (bit_terms.size() / 2); i++) {
     176                new_terms.push_back(pb.createAnd(bit_terms[(2 * i) + 1], bit_terms[2 * i]));
     177            }
     178            if (bit_terms.size() % 2 == 1) {
     179                new_terms.push_back(bit_terms[bit_terms.size() - 1]);
     180            }
     181            bit_terms.swap(new_terms);
     182        }
     183        while (bit_terms.size() > 1);
    182184    }
    183185    return bit_terms[0];
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r4432 r4511  
    1919
    2020class CC_Compiler{
    21     typedef std::vector<std::pair<const re::CC*, pablo::Assign*>> ConstraintVector;
    2221public:
    2322
     
    4544    std::vector<pablo::Var *>   mBasisBit;
    4645    const Encoding              mEncoding;
    47     ConstraintVector            mVariableVector;
    4846};
    4947
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r4433 r4511  
    287287pablo/symbol_generator.cpp
    288288pablo/symbol_generator.h
     289pablo/builder.cpp
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r4443 r4511  
    1010public:
    1111
    12     inline static PabloBlock & Create() {
    13         return *(new PabloBlock());
     12    inline static PabloBuilder Create(PabloBuilder & predecessor) {
     13        return *(new PabloBlock(predecessor->mPb));
    1414    }
    15 
    16     inline static PabloBlock & Create(PabloBlock & predecessor) {
    17         return *(new PabloBlock(&predecessor));
    18     }
    19 
    2015
    2116    inline Zeroes * createZeroes() const {
     
    4540    Assign * createAssign(const std::string prefix, PabloAST * expr, const int outputIndex = -1);
    4641
    47     inline PabloAST * createAdvance(PabloAST * expr, const int shiftAmount) {
     42    inline PabloAST * createAdvance(PabloAST * expr, const Integer::integer_t shiftAmount) {
    4843        if (shiftAmount == 0) {
    4944            return expr;
     
    7065    PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr);
    7166
    72     inline If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
     67    inline If * createIf(PabloAST * condition, std::initializer_list<Assign *> definedVars, PabloBlock & body) {
    7368        mPb->createIf(condition, std::move(definedVars), body);
    7469    }
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r4510 r4511  
    3838}
    3939
    40 PabloAST * PabloBlock::createAdvance(PabloAST * expr, const int shiftAmount) {
     40PabloAST * PabloBlock::createAdvance(PabloAST * expr, const Integer::integer_t shiftAmount) {
    4141    if (isa<Zeroes>(expr) || shiftAmount == 0) {
    4242        return expr;
     
    4545}
    4646
    47 PabloAST * PabloBlock::createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix) {
     47PabloAST * PabloBlock::createAdvance(PabloAST * expr, const Integer::integer_t shiftAmount, const std::string prefix) {
    4848    if (isa<Zeroes>(expr) || shiftAmount == 0) {
    4949        return renameNonNamedNode(expr, std::move(prefix));
     
    383383}
    384384
     385If * PabloBlock::createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body) {
     386    assert (condition);
     387    return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     388}
     389
     390If * PabloBlock::createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
     391    assert (condition);
     392    return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     393}
     394
    385395While * PabloBlock::createWhile(PabloAST * condition, PabloBlock & body) {
    386396    assert (condition);
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4510 r4511  
    7878    }
    7979
    80     PabloAST * createAdvance(PabloAST * expr, const int shiftAmount);
     80    PabloAST * createAdvance(PabloAST * expr, const Integer::integer_t shiftAmount);
    8181
    8282    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount);
    8383
    84     PabloAST * createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix);
     84    PabloAST * createAdvance(PabloAST * expr, const Integer::integer_t shiftAmount, const std::string prefix);
    8585
    8686    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount, const std::string prefix);
     
    144144    If * createIf(PabloAST * condition, std::initializer_list<Assign *> definedVars, PabloBlock & body);
    145145
     146    If * createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body);
     147
     148    If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body);
     149
    146150    While * createWhile(PabloAST * condition, PabloBlock & body);
    147151
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.cpp

    r4510 r4511  
    2929}
    3030
     31If::If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent)
     32: Statement(ClassTypeId::If, {expr}, nullptr, parent)
     33, mBody(body)
     34, mDefined(definedVars.begin(), definedVars.end(), mVectorAllocator)
     35, mCarryCount(0)
     36, mAdvanceCount(0)
     37{
     38    for (PabloAST * assign : mDefined) {
     39        assign->addUser(this);
     40        addUser(assign);
     41    }
     42}
    3143
    3244
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.h

    r4510 r4511  
    5555protected:
    5656    If(PabloAST * expr, std::initializer_list<Assign *> && definedVars, PabloBlock & body, PabloBlock * parent);
     57
     58    If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent);
    5759private:
    5860    PabloBlock &    mBody;
Note: See TracChangeset for help on using the changeset viewer.