mask_b = (~((1 << y) - 1)) & ((1 << 64) - 1)
return mask_a ^ mask_b
+def ne(a, b):
+ return SelectableInt((a != b), bits=1)
+def eq(a, b):
+ return SelectableInt((a == b), bits=1)
+
+def gt(a, b):
+ return SelectableInt((a > b), bits=1)
+
+def ge(a, b):
+ return SelectableInt((a >= b), bits=1)
+
+def lt(a, b):
+ return SelectableInt((a < b), bits=1)
+
+def le(a, b):
+ return SelectableInt((a <= b), bits=1)
# For these tests I tried to find power instructions that would let me
# isolate each of these helper operations. So for instance, when I was
# testing the MASK() function, I chose rlwinm and rldicl because if I
+++ /dev/null
---- branch.py.orig 2020-05-06 10:27:17.096835546 -0400
-+++ branch.py 2020-05-06 10:27:40.353752508 -0400
-@@ -141,7 +141,7 @@
- M = 32
- if ~BO[2]:
- CTR = CTR - 1
-- ctr_ok = BO[2] | (CTR[M:64] != 0) ^ BO[3]
-+ ctr_ok = BO[2] | SelectableInt((CTR[M:64] != 0), bits=1) ^ BO[3]
- cond_ok = BO[0] | ~(CR[BI + 32] ^ BO[1])
- if ctr_ok & cond_ok:
- NIA = concat(LR[0:62], SelectableInt(value=0x0, bits=2))
---- sprset.py.orig 2020-05-06 11:36:45.228253359 -0400
-+++ sprset.py 2020-05-06 11:20:17.627640518 -0400
-@@ -18,7 +18,7 @@
+--- sprset.py.orig 2020-05-06 14:15:08.236887767 -0400
++++ sprset.py 2020-05-06 14:15:51.757083567 -0400
+@@ -15,11 +15,11 @@
+ if n in [13]:
+ see(Book_III_p974)
+ elif n in [808, 809, 810, 811]:
+- if eq(length(SPR(n)), 64):
++ if eq(len(SPR(n)), 64):
SPR[n] = RS
else:
SPR[n] = RS[32:64]
-- elif length(SPR(n)) == 64:
-+ elif len(SPR(n)) == 64:
+- elif eq(length(SPR(n)), 64):
++ elif eq(len(SPR(n)), 64):
SPR[n] = RS
else:
SPR[n] = RS[32:64]
def make_le_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.LtE()], [right])
+ return ast.Call(ast.Name("le", ast.Load()), (left, right), [])
def make_ge_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.GtE()], [right])
+ return ast.Call(ast.Name("ge", ast.Load()), (left, right), [])
def make_lt_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.Lt()], [right])
+ return ast.Call(ast.Name("lt", ast.Load()), (left, right), [])
def make_gt_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.Gt()], [right])
+ return ast.Call(ast.Name("gt", ast.Load()), (left, right), [])
def make_eq_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.Eq()], [right])
+ return ast.Call(ast.Name("eq", ast.Load()), (left, right), [])
def make_ne_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.NotEq()], [right])
+ return ast.Call(ast.Name("ne", ast.Load()), (left, right), [])
binary_ops = {
# auto-generated by pywriter.py, do not edit or commit
from soc.decoder.isa.caller import inject, instruction_info
-from soc.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32, MASK,)
+from soc.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32, MASK,
+ ne, eq, gt, ge, lt, le)
from soc.decoder.selectable_int import SelectableInt
from soc.decoder.selectable_int import selectconcat as concat
from soc.decoder.orderedset import OrderedSet
def check_extsign(a, b):
if isinstance(b, FieldSelectableInt):
b = b.get_range()
+ if isinstance(b, int):
+ return SelectableInt(b, a.bits)
if b.bits != 256:
return b
return SelectableInt(b.value, a.bits)