22 jok1 = m2_expr.ExprId(
"jok1")
23 jok2 = m2_expr.ExprId(
"jok2")
24 jok3 = m2_expr.ExprId(
"jok3")
25 jok_small = m2_expr.ExprId(
"jok_small", 1)
31 "Return an ExprOp standing for arg1 op arg2 with size to 1"
32 ec = m2_expr.ExprOp(op, arg1, arg2)
37 "Return an ExprOp standing for arg1 <s arg2"
42 "Return an ExprOp standing for arg1 <s arg2"
46 "Return an ExprOp standing for arg1 == arg2"
53 """If @e stand for the most significant bit of its arg, return the arg;
56 if not isinstance(e, m2_expr.ExprSlice):
60 if e.start != (arg.size - 1)
or e.stop != arg.size:
66 "Wrapper around MatchExpr to canonize pattern"
68 to_match = to_match.canonize()
70 r = m2_expr.MatchExpr(e, to_match, jok_list)
80 "((x - y) ^ ((x ^ y) & ((x - y) ^ x))) [31:32] == x <s y"
87 to_match = jok3 ^ ((jok1 ^ jok2) & (jok3 ^ jok1))
104 "((x - y) ^ ((x ^ y) & ((x - y) ^ x))) ^ x ^ y [31:32] == x <u y"
111 to_match = jok3 ^ ((jok1 ^ jok2) & (jok3 ^ jok1)) ^ jok1 ^ jok2
128 """(x <u y) ^ ((x ^ y) [31:32]) == x <s y,
129 (x <s y) ^ ((x ^ y) [31:32]) == x <u y"""
134 [jok1, jok2, jok_small])
141 [jok1, jok2, jok_small])
145 cur_sig = m2_expr.TOK_INF_SIGNED
147 cur_sig = m2_expr.TOK_INF_UNSIGNED
154 if not isinstance(arg, m2_expr.ExprOp)
or arg.op !=
"^":
158 if len(op_args) != 2:
161 if r[jok1]
not in op_args
or r[jok2]
not in op_args:
164 if cur_sig == m2_expr.TOK_INF_UNSIGNED:
170 """(x - y)?(0:1) == (x == y)"""
172 to_match = m2_expr.ExprCond(jok1 + jok2, m2_expr.ExprInt1(0), m2_expr.ExprInt1(1))
185 if e.op != m2_expr.TOK_INF_UNSIGNED:
190 if isinstance(arg1, m2_expr.ExprInt)
and isinstance(arg2, m2_expr.ExprInt):
191 return m2_expr.ExprInt1(1)
if (arg1.arg < arg2.arg)
else m2_expr.ExprInt1(0)
197 """Return ExprInt1(1) if arg1 <s arg2 else ExprInt1(0)
198 @arg1, @arg2: ExprInt"""
201 if val1 >> (arg1.size - 1) == 1:
202 val1 = - (arg1.mask.arg ^ val1 + 1)
205 if val2 >> (arg2.size - 1) == 1:
206 val2 = - (arg2.mask.arg ^ val2 + 1)
208 return m2_expr.ExprInt1(1)
if (val1 < val2)
else m2_expr.ExprInt1(0)
213 if e.op != m2_expr.TOK_INF_SIGNED:
218 if isinstance(arg1, m2_expr.ExprInt)
and isinstance(arg2, m2_expr.ExprInt):
226 if e.op != m2_expr.TOK_EQUAL:
230 if isinstance(arg1, m2_expr.ExprInt)
and isinstance(arg2, m2_expr.ExprInt):
231 return m2_expr.ExprInt1(1)
if (arg1.arg == arg2.arg)
else m2_expr.ExprInt1(0)
def expr_simp_inf_unsigned_inversed