1 from openpower
.simulator
.program
import Program
2 from openpower
.sv
.trans
.pysvp64dis
import load
, dump
3 from openpower
.insndb
.asm
import SVP64Asm
4 from openpower
.insndb
.types
import Database
, Style
5 from openpower
.decoder
.power_enums
import find_wiki_dir
6 from openpower
.sv
import sv_binutils_fptrans
11 class SVSTATETestCase(unittest
.TestCase
):
13 def _do_tst(self
, expected
):
14 isa
= SVP64Asm(expected
)
16 with
Program(lst
, bigendian
=False) as program
:
17 print ("ops", program
._instructions
)
18 program
.binfile
.seek(0)
19 insns
= load(program
.binfile
)
23 print ("insns", insns
)
24 for i
, line
in enumerate(dump(insns
, style
=Style
.SHORT
)):
25 name
= expected
[i
].split(" ")[0]
26 with self
.subTest("%d:%s" % (i
, name
)):
27 print("instruction", repr(line
), repr(expected
[i
]))
28 self
.assertEqual(expected
[i
], line
,
29 "instruction does not match "
30 "'%s' expected '%s'" % (line
, expected
[i
]))
34 # hilarious. this should be autogenerated from a sequence
35 # of lists of options. it's a lot of frickin options.
36 lists
= [[None, 'all'],
37 [None, 'm=r3', 'sz', 'snz'], # see below on this one...
38 [None, 'vs', 'vsi', 'vsb', 'vsbi'],
45 for options
in itertools
.product(*lists
): # permutations of list-options
46 options
= list(filter(lambda x
:x
, options
)) # filter Nones
47 # /sz or /snz must have /m=r3 added but then sorted
48 if 'sz' in options
or 'snz' in options
:
49 options
.append("m=r3")
50 options
.sort() # otherwise chaos!
52 options
= [''] + options
# trick to make a "/" at the front
53 print ("option", options
)
54 # ahhhhhahahaha and sv.bcctr and sv.bcl ahahahahaah....
55 option
= "sv.bc%s 12,*1,0xc" % "/".join(options
)
56 expected
.append(option
)
58 self
._do
_tst
(expected
)
60 if __name__
== "__main__":