Ignore:
Timestamp:
Nov 16, 2015, 10:01:04 PM (4 years ago)
Author:
nmedfort
Message:

First stage in making And/Or/Xor? statements n-ary statements.

File:
1 edited

Legend:

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

    r4870 r4873  
    242242        }
    243243    } else if (Or * or1 = dyn_cast<Or>(expr1)) {
    244         if (equals(or1->getExpr1(), expr2) || equals(or1->getExpr2(), expr2)) {
     244        if (equals(or1->getOperand(0), expr2) || equals(or1->getOperand(1), expr2)) {
    245245            return expr2;
    246246        }
    247247    } else if (Or * or2 = dyn_cast<Or>(expr2)) {
    248         if (equals(or2->getExpr1(), expr1) || equals(or2->getExpr2(), expr1)) {
     248        if (equals(or2->getOperand(0), expr1) || equals(or2->getOperand(1), expr1)) {
    249249            return expr1;
    250250        }
     
    275275        }
    276276    } else if (Or * or1 = dyn_cast<Or>(expr1)) {
    277         if (equals(or1->getExpr1(), expr2) || equals(or1->getExpr2(), expr2)) {
     277        if (equals(or1->getOperand(0), expr2) || equals(or1->getOperand(1), expr2)) {
    278278            return expr2;
    279279        }
    280280    } else if (Or * or2 = dyn_cast<Or>(expr2)) {
    281         if (equals(or2->getExpr1(), expr1) || equals(or2->getExpr2(), expr1)) {
     281        if (equals(or2->getOperand(0), expr1) || equals(or2->getOperand(1), expr1)) {
    282282            return expr1;
    283283        }
     
    306306    } else if (And * and1 = dyn_cast<And>(expr1)) {
    307307        if (And * and2 = dyn_cast<And>(expr2)) {
    308             PabloAST * const expr1a = and1->getExpr1();
    309             PabloAST * const expr1b = and1->getExpr2();
    310             PabloAST * const expr2a = and2->getExpr1();
    311             PabloAST * const expr2b = and2->getExpr2();
     308            PabloAST * const expr1a = and1->getOperand(0);
     309            PabloAST * const expr1b = and1->getOperand(1);
     310            PabloAST * const expr2a = and2->getOperand(0);
     311            PabloAST * const expr2b = and2->getOperand(1);
    312312            //These optimizations factor out common components that can occur when sets are formed by union
    313313            //(e.g., union of [a-z] and [A-Z].
     
    321321                return createAnd(expr1b, createOr(expr1a, expr2b));
    322322            }
    323         } else if (equals(and1->getExpr1(), expr2) || equals(and1->getExpr2(), expr2)){
     323        } else if (equals(and1->getOperand(0), expr2) || equals(and1->getOperand(1), expr2)){
    324324            // (a∧b) √ a = a
    325325            return expr2;
    326326        }
    327327    } else if (And * and2 = dyn_cast<And>(expr2)) {
    328         if (equals(and2->getExpr1(), expr1) || equals(and2->getExpr2(), expr1)) {
     328        if (equals(and2->getOperand(0), expr1) || equals(and2->getOperand(1), expr1)) {
    329329            return expr1;
    330330        }
     
    351351    } else if (And * and1 = dyn_cast<And>(expr1)) {
    352352        if (And * and2 = dyn_cast<And>(expr2)) {
    353             PabloAST * const expr1a = and1->getExpr1();
    354             PabloAST * const expr1b = and1->getExpr2();
    355             PabloAST * const expr2a = and2->getExpr1();
    356             PabloAST * const expr2b = and2->getExpr2();
     353            PabloAST * const expr1a = and1->getOperand(0);
     354            PabloAST * const expr1b = and1->getOperand(1);
     355            PabloAST * const expr2a = and2->getOperand(0);
     356            PabloAST * const expr2b = and2->getOperand(1);
    357357            //These optimizations factor out common components that can occur when sets are formed by union
    358358            //(e.g., union of [a-z] and [A-Z].
     
    366366                return createAnd(expr1b, createOr(expr1a, expr2b), prefix);
    367367            }
    368         } else if (equals(and1->getExpr1(), expr2) || equals(and1->getExpr2(), expr2)) {
     368        } else if (equals(and1->getOperand(0), expr2) || equals(and1->getOperand(1), expr2)) {
    369369            // (a∧b) √ a = a
    370370            return expr2;
    371371        }
    372372    } else if (And * and2 = dyn_cast<And>(expr2)) {
    373         if (equals(and2->getExpr1(), expr1) || equals(and2->getExpr2(), expr1)) {
     373        if (equals(and2->getOperand(0), expr1) || equals(and2->getOperand(1), expr1)) {
    374374            return expr1;
    375375        }
Note: See TracChangeset for help on using the changeset viewer.