about summary refs log tree commit diff stats
path: root/test/expression/simplifications.py
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2018-11-12 08:59:27 +0100
committerGitHub <noreply@github.com>2018-11-12 08:59:27 +0100
commitb7e9a819ef2f25e7a4186b0e9468bcaf33103bda (patch)
tree248457914ac2410e3cb84a9f31895a7248c385e1 /test/expression/simplifications.py
parentea9faf29639542b219b0343e2a87de3a81c9df4b (diff)
parent5e9ef3b5c45f0f384519a3784f62ac2a758781d4 (diff)
downloadmiasm-b7e9a819ef2f25e7a4186b0e9468bcaf33103bda.tar.gz
miasm-b7e9a819ef2f25e7a4186b0e9468bcaf33103bda.zip
Merge pull request #871 from serpilliere/simp_mult
Simple: add multiplication simplification
Diffstat (limited to '')
-rw-r--r--test/expression/simplifications.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py
index 741d6adb..57895510 100644
--- a/test/expression/simplifications.py
+++ b/test/expression/simplifications.py
@@ -97,7 +97,10 @@ s = a[:8]
 i0 = ExprInt(0, 32)
 i1 = ExprInt(1, 32)
 i2 = ExprInt(2, 32)
+i3 = ExprInt(3, 32)
 im1 = ExprInt(-1, 32)
+im2 = ExprInt(-2, 32)
+
 icustom = ExprInt(0x12345678, 32)
 cc = ExprCond(a, b, c)
 
@@ -242,7 +245,7 @@ to_test = [(ExprInt(1, 32) - ExprInt(1, 32), ExprInt(0, 32)),
     (ExprOp('*', -a, -b, c, ExprInt(0x12, 32)),
      ExprOp('*', a, b, c, ExprInt(0x12, 32))),
     (ExprOp('*', -a, -b, -c, ExprInt(0x12, 32)),
-     - ExprOp('*', a, b, c, ExprInt(0x12, 32))),
+     ExprOp('*', a, b, c, ExprInt(-0x12, 32))),
     (a | ExprInt(0xffffffff, 32),
      ExprInt(0xffffffff, 32)),
     (ExprCond(a, ExprInt(1, 32), ExprInt(2, 32)) * ExprInt(4, 32),
@@ -443,6 +446,21 @@ to_test = [(ExprInt(1, 32) - ExprInt(1, 32), ExprInt(0, 32)),
     (ExprOp("signExt_16", ExprInt(0x8, 8)), ExprInt(0x8, 16)),
     (ExprOp("signExt_16", ExprInt(-0x8, 8)), ExprInt(-0x8, 16)),
 
+    (- (i2*a), a * im2),
+    (a + a, a * i2),
+    (ExprOp('+', a, a), a * i2),
+    (ExprOp('+', a, a, a), a * i3),
+    ((a<<i1) - a, a),
+    ((a<<i1) - (a<<i2), a*im2),
+    ((a<<i1) - a - a, i0),
+    ((a<<i2) - (a<<i1) - (a<<i1), i0),
+    ((a<<i2) - a*i3, a),
+    (((a+b) * i3) - (a + b), (a+b) * i2),
+    (((a+b) * i2) + a + b, (a+b) * i3),
+    (((a+b) * i3) - a - b, (a+b) * i2),
+    (((a+b) * i2) - a - b, a+b),
+    (((a+b) * i2) - i2 * a - i2 * b, i0),
+
 
 ]