2 from openpower
.simulator
.program
import Program
3 from openpower
.endian
import bigendian
4 from openpower
.test
.common
import TestAccumulatorBase
8 class MulTestCases2Arg(TestAccumulatorBase
):
24 0xFFFF_FFFF_FFFF_FFFF,
25 0xFFFF_FFFF_FFFF_FFFE,
26 0x7FFF_FFFF_FFFF_FFFF,
27 0x8000_0000_0000_0000,
28 0x1234_5678_0000_0000,
29 0x1234_5678_8000_0000,
30 0x1234_5678_FFFF_FFFF,
31 0x1234_5678_7FFF_FFFF,
40 l
= [f
"{instr} 3, 1, 2"]
41 # use "with" so as to close the files used
42 with
Program(l
, bigendian
) as prog
:
43 for ra
in test_values
:
44 for rb
in test_values
:
45 initial_regs
= [0] * 32
48 self
.add_case(prog
, initial_regs
)
50 def case_all_rb_randint(self
):
65 0xFFFF_FFFF_FFFF_FFFF,
66 0xFFFF_FFFF_FFFF_FFFE,
67 0x7FFF_FFFF_FFFF_FFFF,
68 0x8000_0000_0000_0000,
69 0x1234_5678_0000_0000,
70 0x1234_5678_8000_0000,
71 0x1234_5678_FFFF_FFFF,
72 0x1234_5678_7FFF_FFFF,
81 l
= [f
"{instr} 3, 1, 2"]
82 # use "with" so as to close the files used
83 with
Program(l
, bigendian
) as prog
:
84 for ra
in test_values
:
85 initial_regs
= [0] * 32
87 initial_regs
[2] = random
.randint(0, (1 << 64)-1)
88 self
.add_case(prog
, initial_regs
)
90 def case_all_rb_close_to_ov(self
):
105 0xFFFF_FFFF_FFFF_FFFF,
106 0xFFFF_FFFF_FFFF_FFFE,
107 0x7FFF_FFFF_FFFF_FFFF,
108 0x8000_0000_0000_0000,
109 0x1234_5678_0000_0000,
110 0x1234_5678_8000_0000,
111 0x1234_5678_FFFF_FFFF,
112 0x1234_5678_7FFF_FFFF,
121 l
= [f
"{instr} 3, 1, 2"]
122 # use "with" so as to close the files used
123 with
Program(l
, bigendian
) as prog
:
125 x
= 0x7fffffff + random
.randint((-1 << 31), (1 << 31) - 1)
126 ra
= random
.randint(0, (1 << 32)-1)
129 initial_regs
= [0] * 32
132 self
.add_case(prog
, initial_regs
)
134 def case_mulli(self
):
136 imm_values
= [-32768, -32767, -32766, -2, -1, 0, 1, 2, 32766, 32767]
142 0xFFFF_FFFF_FFFF_FFFF,
143 0xFFFF_FFFF_FFFF_FFFE,
144 0x7FFF_FFFF_FFFF_FFFF,
145 0x8000_0000_0000_0000,
146 0x1234_5678_0000_0000,
147 0x1234_5678_8000_0000,
148 0x1234_5678_FFFF_FFFF,
149 0x1234_5678_7FFF_FFFF,
158 imm_values
.append(random
.randint(-1 << 15, (1 << 15) - 1))
161 ra_values
.append(random
.randint(0, (1 << 64) - 1))
163 for imm
in imm_values
:
164 l
= [f
"mulli 0, 1, {imm}"]
165 # use "with" so as to close the files used
166 with
Program(l
, bigendian
) as prog
:
168 initial_regs
= [0] * 32
170 self
.add_case(prog
, initial_regs
)
173 MUL_3_ARG_TEST_VALUES
= [
177 0xFFFF_FFFF_FFFF_FFFF,
178 0xFFFF_FFFF_FFFF_FFFE,
179 0x7FFF_FFFF_FFFF_FFFF,
180 0x8000_0000_0000_0000,
181 0x1234_5678_0000_0000,
182 0x1234_5678_8000_0000,
183 0x1234_5678_FFFF_FFFF,
184 0x1234_5678_7FFF_FFFF,
193 class MulTestCases3Arg(TestAccumulatorBase
):
194 def __init__(self
, subtest_index
):
195 self
.subtest_index
= subtest_index
199 instrs
= ["maddhd", "maddhdu", "maddld"]
202 l
= [f
"{instr} 1, 2, 3, 4"]
203 ra
= MUL_3_ARG_TEST_VALUES
[self
.subtest_index
]
204 for rb
in MUL_3_ARG_TEST_VALUES
:
205 for rc
in MUL_3_ARG_TEST_VALUES
:
206 initial_regs
= [0] * 32
210 # use "with" so as to close the files used
211 with
Program(l
, bigendian
) as prog
:
212 self
.add_case(prog
, initial_regs
)