Ignore:
Timestamp:
Jul 8, 2015, 2:59:03 PM (4 years ago)
Author:
nmedfort
Message:

Partial roll back of Trie structure. Seemed to introduce the potential of generating a cycle in the AST. More analysis is needed here before mixing together multiple Advance DAG traversals.

File:
1 edited

Legend:

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

    r4643 r4650  
    1818}
    1919
     20void PabloBlock::insert(Statement * const statement) {
     21    assert (statement);
     22    if (LLVM_UNLIKELY(mInsertionPoint == nullptr)) {
     23        if (mFirst) {
     24            statement->insertBefore(mFirst);
     25        }
     26        else {
     27            statement->removeFromParent();
     28            statement->mParent = this;
     29            mFirst = mLast = statement;
     30        }
     31    }
     32    else {
     33        statement->insertAfter(mInsertionPoint);
     34        mLast = (mLast == mInsertionPoint) ? statement : mLast;
     35        assert (statement->mPrev == mInsertionPoint);
     36    }
     37    mInsertionPoint = statement;
     38}
     39
    2040/// UNARY CREATE FUNCTIONS
    2141
    2242Assign * PabloBlock::createAssign(const std::string && prefix, PabloAST * expr, const int outputIndex)  {
    23     return insertAtInsertionPoint(new Assign(expr, outputIndex, makeName(prefix, false), this));
     43    return insertAtInsertionPoint(new Assign(expr, outputIndex, makeName(prefix, false)));
    2444}
    2545
     
    2848        return expr;
    2949    }
    30     return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance"), this));
     50    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance")));
    3151}
    3252
     
    3555        return expr;
    3656    }
    37     return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false), this));
     57    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false)));
    3858}
    3959
     
    4262        return expr;
    4363    }
    44     return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName("advance"), this));
     64    return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName("advance")));
    4565}
    4666
     
    4969        return renameNonNamedNode(expr, std::move(prefix));
    5070    }   
    51     return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName(prefix, false), this));
     71    return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName(prefix, false)));
    5272}
    5373
    5474Call * PabloBlock::createCall(PabloAST * name) {
    5575    assert (name);
    56     return insertAtInsertionPoint(new Call(name, this));
     76    return insertAtInsertionPoint(new Call(name));
    5777}
    5878
     
    6888        return not1->getExpr();
    6989    }
    70     return insertAtInsertionPoint(new Not(expr, makeName("not_"), this));
     90    return insertAtInsertionPoint(new Not(expr, makeName("not_")));
    7191}
    7292
     
    82102        return renameNonNamedNode(not1->getExpr(), std::move(prefix));
    83103    }
    84     return insertAtInsertionPoint(new Not(expr, makeName(prefix, false), this));
     104    return insertAtInsertionPoint(new Not(expr, makeName(prefix, false)));
    85105}
    86106
    87107Var * PabloBlock::createVar(PabloAST * name) {
    88108    assert (name);
    89     return new Var(name, this);
     109    return new Var(name);
    90110}
    91111
     
    94114Next * PabloBlock::createNext(Assign * assign, PabloAST * expr) {
    95115    assert (assign && expr);
    96     return insertAtInsertionPoint(new Next(assign, expr, this));
     116    return insertAtInsertionPoint(new Next(assign, expr));
    97117}
    98118
     
    102122        return marker;
    103123    }
    104     return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar"), this));
     124    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar")));
    105125}
    106126
     
    110130        return renameNonNamedNode(marker, std::move(prefix));
    111131    }
    112     return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false), this));
     132    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false)));
    113133}
    114134
     
    118138        return from;
    119139    }
    120     return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru"), this));
     140    return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru")));
    121141}
    122142
     
    126146        return renameNonNamedNode(from, std::move(prefix));
    127147    }
    128     return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false), this));
     148    return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false)));
    129149}
    130150
     
    153173        std::swap(expr1, expr2);
    154174    }
    155     return insertAtInsertionPoint(new And(expr1, expr2, makeName("and_"), this));
     175    return insertAtInsertionPoint(new And(expr1, expr2, makeName("and_")));
    156176}
    157177
     
    181201        std::swap(expr1, expr2);
    182202    }
    183     return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false), this));
     203    return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false)));
    184204}
    185205
     
    225245        }
    226246    }
    227     return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or_"), this));
     247    return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or_")));
    228248}
    229249
     
    266286        }
    267287    }
    268     return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false), this));
     288    return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false)));
    269289}
    270290
     
    288308        }
    289309    }
    290     return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor_"), this));
     310    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor_")));
    291311}
    292312
     
    310330        }
    311331    }
    312     return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false), this));
     332    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false)));
    313333}
    314334
     
    345365        return createXor(condition, falseExpr);
    346366    }
    347     return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel"), this));
     367    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel")));
    348368}
    349369
     
    375395        return createXor(condition, falseExpr, prefix);
    376396    }
    377     return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false), this));
     397    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false)));
    378398}
    379399
    380400If * PabloBlock::createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock & body) {
    381401    assert (condition);
    382     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     402    return insertAtInsertionPoint(new If(condition, definedVars, body));
    383403}
    384404
    385405If * PabloBlock::createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body) {
    386406    assert (condition);
    387     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     407    return insertAtInsertionPoint(new If(condition, definedVars, body));
    388408}
    389409
    390410If * PabloBlock::createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
    391411    assert (condition);
    392     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     412    return insertAtInsertionPoint(new If(condition, definedVars, body));
    393413}
    394414
    395415While * PabloBlock::createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock & body) {
    396416    assert (condition);
    397     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     417    return insertAtInsertionPoint(new While(condition, nextVars, body));
    398418}
    399419
    400420While * PabloBlock::createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock & body) {
    401421    assert (condition);
    402     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     422    return insertAtInsertionPoint(new While(condition, nextVars, body));
    403423}
    404424
    405425While * PabloBlock::createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock & body) {
    406426    assert (condition);
    407     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     427    return insertAtInsertionPoint(new While(condition, nextVars, body));
    408428}
    409429
Note: See TracChangeset for help on using the changeset viewer.