diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-01-25 17:30:54 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-01-26 23:01:17 +0100 |
| commit | 58ac3fc02639c2d14b641dc692d09831c78694da (patch) | |
| tree | b7ba020643a576d4d9428435534d14120869a9bb /miasm2/expression/simplifications_common.py | |
| parent | 0a44cf232f2d13ba2b472086c8f007378d6b9023 (diff) | |
| download | miasm-58ac3fc02639c2d14b641dc692d09831c78694da.tar.gz miasm-58ac3fc02639c2d14b641dc692d09831c78694da.zip | |
Simplifications: simplify slice of op
Diffstat (limited to 'miasm2/expression/simplifications_common.py')
| -rw-r--r-- | miasm2/expression/simplifications_common.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index f7171091..00b14554 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -1300,11 +1300,17 @@ def simp_slice_of_ext(_, expr): return expr def simp_slice_of_op_ext(expr_s, expr): - """(X.zeroExt() + ... + Int)[0:8] => X + ... + int[:]""" + """ + (X.zeroExt() + {Z, } + ... + Int)[0:8] => X + ... + int[:] + (X.zeroExt() | ... | Int)[0:8] => X | ... | int[:] + ... + """ if expr.start != 0: return expr src = expr.arg - if not src.is_op("+"): + if not src.is_op(): + return expr + if src.op not in ['+', '|', '^', '&']: return expr is_ok = True for arg in src.args: @@ -1314,12 +1320,14 @@ def simp_slice_of_op_ext(expr_s, expr): arg.op.startswith("zeroExt") and arg.args[0].size == expr.stop): continue + if arg.is_compose(): + continue is_ok = False break if not is_ok: return expr args = [expr_s(arg[:expr.stop]) for arg in src.args] - return ExprOp("+", *args) + return ExprOp(src.op, *args) def simp_cond_logic_ext(expr_s, expr): |