use of org.mapleir.ir.code.stmt.ConditionalJumpStmt.ComparisonType in project maple-ir by LLVM-but-worse.
the class GenerationPass method _jump_null.
protected void _jump_null(BasicBlock target, boolean invert) {
save_stack(false);
Expr left = pop();
ConstantExpr right = new ConstantExpr(null, TypeUtils.OBJECT_TYPE);
ComparisonType type = invert ? ComparisonType.NE : ComparisonType.EQ;
_jump_cmp(target, type, left, right);
}
use of org.mapleir.ir.code.stmt.ConditionalJumpStmt.ComparisonType in project maple-ir by LLVM-but-worse.
the class ConstantExpressionReorderPass method transform.
private int transform(ControlFlowGraph ir) {
int i = 0;
for (BasicBlock b : ir.vertices()) {
for (Stmt stmt : b) {
if (stmt.getOpcode() == COND_JUMP) {
ConditionalJumpStmt cjs = (ConditionalJumpStmt) stmt;
Expr r = cjs.getRight();
Expr l = cjs.getLeft();
ComparisonType type = cjs.getComparisonType();
if (type == ComparisonType.EQ || type == ComparisonType.NE) {
if (shouldReorder(r, l)) {
cjs.setRight(null);
cjs.setLeft(null);
cjs.setLeft(r);
cjs.setRight(l);
i++;
}
}
}
for (Expr e : stmt.enumerateOnlyChildren()) {
if (e.getOpcode() == ARITHMETIC) {
ArithmeticExpr arith = (ArithmeticExpr) e;
Expr r = arith.getRight();
Expr l = arith.getLeft();
Operator op = arith.getOperator();
if (!op.doesOrderMatter()) {
if (shouldReorder(r, l)) {
arith.setRight(null);
arith.setLeft(null);
arith.setLeft(r);
arith.setRight(l);
i++;
}
}
}
}
}
}
return i;
}
Aggregations