Ignore:
Timestamp:
Jan 7, 2015, 3:40:23 PM (5 years ago)
Author:
nmedfort
Message:

Changes to support 3-operand form for all instructions. CSE disabled but partially redundant now.

File:
1 edited

Legend:

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

    r4404 r4410  
    1616        return expr;
    1717    }
    18     return mUnaryWithInt.findOrMake<Advance>(PabloAST::ClassTypeId::Advance, expr, shiftAmount).first;
    19 }
    20 
    21 PabloAST * PabloBlock::createCall(const std::string name) {
    22     return mUnary.findOrMake<Call>(PabloAST::ClassTypeId::Call, mSymbolGenerator->get(name)).first;
     18    return appendIfNew(mUnaryWithInt.findOrMake<Advance>(PabloAST::ClassTypeId::Advance, expr, shiftAmount, mSymbolGenerator, this));
     19}
     20
     21Call * PabloBlock::createCall(const std::string name) {
     22    return appendIfNew(mUnary.findOrMake<Call>(PabloAST::ClassTypeId::Call, mSymbolGenerator->get(name), this));
    2323}
    2424
    2525PabloAST * PabloBlock::createNot(PabloAST * expr) {
    26     return mUnary.findOrCall<OptimizeNot>(PabloAST::ClassTypeId::Not, expr).first;
    27 }
     26    return mUnary.findOrCall<OptimizeNot>(PabloAST::ClassTypeId::Not, expr, this);
     27}
     28
     29Not * PabloBlock::createNotImm(PabloAST * expr) {
     30    return appendIfNew(mUnary.findOrMake<Not>(PabloAST::ClassTypeId::Not, expr, this));
     31}
     32
    2833
    2934Var * PabloBlock::createVar(const std::string name) {
    30     return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, mSymbolGenerator->get(name)).first;
    31 }
    32 
    33 Var * PabloBlock::createVar(Assign * assign) {
    34     return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, assign).first;
    35 }
    36 
    37 Var * PabloBlock::createVar(Next * next) {
    38     return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, next).first;
     35    return mUnary.findOrMake<Var>(PabloAST::ClassTypeId::Var, mSymbolGenerator->get(name), this).first;
    3936}
    4037
     
    4239
    4340Next * PabloBlock::createNext(Assign * assign, PabloAST * expr) {
    44     Next * next;
    45     bool added;
    46     std::tie(next, added) = mBinary.findOrMake<Next>(PabloAST::ClassTypeId::Next, assign, expr, this);
    47     if (LLVM_LIKELY(added)) {
    48         push_back(next);
    49     }
    50     return next;
     41    return appendIfNew(mBinary.findOrMake<Next>(PabloAST::ClassTypeId::Next, assign, expr, this));
    5142}
    5243
     
    5546        return marker;
    5647    }
    57     return mBinary.findOrMake<MatchStar>(PabloAST::ClassTypeId::MatchStar, marker, charclass).first;
     48    return appendIfNew(mBinary.findOrMake<MatchStar>(PabloAST::ClassTypeId::MatchStar, marker, charclass, mSymbolGenerator, this));
    5849}
    5950
     
    6253        return from;
    6354    }
    64     return mBinary.findOrMake<ScanThru>(PabloAST::ClassTypeId::ScanThru, from, thru).first;
     55    return appendIfNew(mBinary.findOrMake<ScanThru>(PabloAST::ClassTypeId::ScanThru, from, thru, mSymbolGenerator, this));
    6556}
    6657
     
    6960        std::swap(expr1, expr2);
    7061    }
    71     return mBinary.findOrCall<OptimizeAnd>(PabloAST::ClassTypeId::And, expr1, expr2).first;
     62    return mBinary.findOrCall<OptimizeAnd>(PabloAST::ClassTypeId::And, expr1, expr2, this);
     63}
     64
     65And * PabloBlock::createAndImm(PabloAST * expr1, PabloAST * expr2) {
     66    return appendIfNew(mBinary.findOrMake<And>(PabloAST::ClassTypeId::And, expr1, expr2, this));
    7267}
    7368
     
    7671        std::swap(expr1, expr2);
    7772    }
    78     return mBinary.findOrCall<OptimizeOr>(PabloAST::ClassTypeId::Or, expr1, expr2).first;
     73    return mBinary.findOrCall<OptimizeOr>(PabloAST::ClassTypeId::Or, expr1, expr2, this);
     74}
     75
     76Or * PabloBlock::createOrImm(PabloAST * expr1, PabloAST * expr2) {
     77    return appendIfNew(mBinary.findOrMake<Or>(PabloAST::ClassTypeId::Or, expr1, expr2, this));
    7978}
    8079
     
    8382        std::swap(expr1, expr2);
    8483    }
    85     return mBinary.findOrCall<OptimizeXor>(PabloAST::ClassTypeId::Xor, expr1, expr2).first;
     84    return mBinary.findOrCall<OptimizeXor>(PabloAST::ClassTypeId::Xor, expr1, expr2, this);
     85}
     86
     87Xor * PabloBlock::createXorImm(PabloAST * expr1, PabloAST * expr2) {
     88    return appendIfNew(mBinary.findOrMake<Xor>(PabloAST::ClassTypeId::Xor, expr1, expr2,  this));
    8689}
    8790
     
    8992
    9093PabloAST * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr) {
    91     return mTernary.findOrCall<OptimizeSel>(PabloAST::ClassTypeId::Sel, condition, trueExpr, falseExpr).first;
    92 }
     94    return mTernary.findOrCall<OptimizeSel>(PabloAST::ClassTypeId::Sel, condition, trueExpr, falseExpr, this);
     95}
     96
     97Sel * PabloBlock::createSelImm(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr) {
     98    return appendIfNew(mTernary.findOrMake<Sel>(PabloAST::ClassTypeId::Sel, condition, trueExpr, falseExpr, this));
     99}
     100
    93101
    94102//PabloAST * PabloBlock::replaceUsesOfWith(PabloAST * inst, PabloAST * from, PabloAST * to) {
Note: See TracChangeset for help on using the changeset viewer.