from openpower.sv.trans.svp64 import SVP64Asm
from openpower.test.state import ExpectedState
from openpower.simulator.program import Program
+from openpower.decoder.isa.caller import SVP64State
+import struct
# FIXME: output values are just what my computer produces for the current
e.fpregs[3] = 0x0
e.crregs[1] = 0x2
self.add_case(Program(lst, False), gprs, fpregs=fprs, expected=e)
+
+
+class SVP64FPTransCases(TestAccumulatorBase):
+ def case_sv_fatan2pi(self):
+ lst = list(SVP64Asm(["sv.fatan2pi *32,*64,*96"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ r = range(svstate.vl)
+ for i, rev_i in zip(r, reversed(r)):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i))[0]
+ fprs[96 + i] = struct.unpack("<Q", struct.pack("<d", rev_i))[0]
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x0
+ e.fpregs[33] = 0x3f85b8cf3bae0f6f
+ e.fpregs[34] = 0x3f96719808aca26c
+ e.fpregs[35] = 0x3fa1652c7df3f5c4
+ e.fpregs[36] = 0x3fa7f854e2212de9
+ e.fpregs[37] = 0x3faef699518cc00c
+ e.fpregs[38] = 0x3fb331a583506fb4
+ e.fpregs[39] = 0x3fb72028ecef9844
+ e.fpregs[40] = 0x3fbb46dd1ce460e0
+ e.fpregs[41] = 0x3fbfa49f4f32b679
+ e.fpregs[42] = 0x3fc21b75e3b0004e
+ e.fpregs[43] = 0x3fc47cd84e0cb544
+ e.fpregs[44] = 0x3fc6f39a0b860052
+ e.fpregs[45] = 0x3fc97c0bade66a98
+ e.fpregs[46] = 0x3fcc11bdf5480ae5
+ e.fpregs[47] = 0x3fceafa71eebf23b
+ e.fpregs[48] = 0x3fd0a82c708a06e3
+ e.fpregs[49] = 0x3fd1f721055bfa8d
+ e.fpregs[50] = 0x3fd341fa290ccab4
+ e.fpregs[51] = 0x3fd48632fa3cffd8
+ e.fpregs[52] = 0x3fd5c193d8f9a55f
+ e.fpregs[53] = 0x3fd6f2450e27ffd9
+ e.fpregs[54] = 0x3fd816d82c335262
+ e.fpregs[55] = 0x3fd92e48b8c6e7c8
+ e.fpregs[56] = 0x3fda37f5c4c419ef
+ e.fpregs[57] = 0x3fdb33969f2be413
+ e.fpregs[58] = 0x3fdc212cd5ce67ff
+ e.fpregs[59] = 0x3fdd00f563bbda43
+ e.fpregs[60] = 0x3fddd35a70418148
+ e.fpregs[61] = 0x3fde98e67f7535d9
+ e.fpregs[62] = 0x3fdf523986228f84
+ e.fpregs[63] = 0x3fe0000000000000
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)
+
+ def case_sv_fpown(self):
+ lst = list(SVP64Asm(["sv.fpown *32,*64,*96"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ r = range(svstate.vl)
+ for i, rev_i in zip(r, reversed(r)):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i))[0]
+ gprs[96 + i] = rev_i
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x0
+ e.fpregs[33] = 0x3ff0000000000000
+ e.fpregs[34] = 0x41c0000000000000
+ e.fpregs[35] = 0x42b4ce6b167f3100
+ e.fpregs[36] = 0x4350000000000000
+ e.fpregs[37] = 0x43b4adf4b7320335
+ e.fpregs[38] = 0x43f8a8cac5546000
+ e.fpregs[39] = 0x4424c57285ccad29
+ e.fpregs[40] = 0x4440000000000000
+ e.fpregs[41] = 0x444ab13886ff818c
+ e.fpregs[42] = 0x444b1ae4d6e2ef50
+ e.fpregs[43] = 0x44423c240e01248b
+ e.fpregs[44] = 0x443151acf6c00000
+ e.fpregs[45] = 0x44186287733beda8
+ e.fpregs[46] = 0x43fa727064cdd0e0
+ e.fpregs[47] = 0x43d6c9eb264f7e5e
+ e.fpregs[48] = 0x43b0000000000000
+ e.fpregs[49] = 0x4382b195ede100df
+ e.fpregs[50] = 0x43527e9813ff4800
+ e.fpregs[51] = 0x431f73fe261ba8c4
+ e.fpregs[52] = 0x42e74876e8000000
+ e.fpregs[53] = 0x42ae572cc2de3200
+ e.fpregs[54] = 0x4271916da5600000
+ e.fpregs[55] = 0x42323bb2ce410000
+ e.fpregs[56] = 0x41f1160000000000
+ e.fpregs[57] = 0x41ad1a94a2000000
+ e.fpregs[58] = 0x4166a97400000000
+ e.fpregs[59] = 0x412037e200000000
+ e.fpregs[60] = 0x40d5700000000000
+ e.fpregs[61] = 0x408a480000000000
+ e.fpregs[62] = 0x403e000000000000
+ e.fpregs[63] = 0x3ff0000000000000
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)
+
+ def case_sv_frootn(self):
+ lst = list(SVP64Asm(["sv.frootn *32,*64,*96"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ r = range(svstate.vl)
+ for i, rev_i in zip(r, reversed(r)):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i))[0]
+ gprs[96 + i] = rev_i + 1
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x0
+ e.fpregs[33] = 0x3ff0000000000000
+ e.fpregs[34] = 0x3ff05fbd4d5b4d5a
+ e.fpregs[35] = 0x3ff09e2569889351
+ e.fpregs[36] = 0x3ff0cfe6317120a2
+ e.fpregs[37] = 0x3ff0fb94d925b492
+ e.fpregs[38] = 0x3ff124397bbd71d1
+ e.fpregs[39] = 0x3ff14b8dd4dbe8ef
+ e.fpregs[40] = 0x3ff172b83c7d517b
+ e.fpregs[41] = 0x3ff19a98e90823cd
+ e.fpregs[42] = 0x3ff1c3f003e174f7
+ e.fpregs[43] = 0x3ff1ef73c93abb21
+ e.fpregs[44] = 0x3ff21ddfeba4e8fd
+ e.fpregs[45] = 0x3ff250029ab74d74
+ e.fpregs[46] = 0x3ff286c9c55d5e76
+ e.fpregs[47] = 0x3ff2c352ac749326
+ e.fpregs[48] = 0x3ff306fe0a31b715
+ e.fpregs[49] = 0x3ff3538be101623e
+ e.fpregs[50] = 0x3ff3ab43a7d494dc
+ e.fpregs[51] = 0x3ff41130952e3b5e
+ e.fpregs[52] = 0x3ff4897f7b709b03
+ e.fpregs[53] = 0x3ff51a16addd4cea
+ e.fpregs[54] = 0x3ff5cb96ce4d114c
+ e.fpregs[55] = 0x3ff6ab23d0cbc00b
+ e.fpregs[56] = 0x3ff7cdc62dc660be
+ e.fpregs[57] = 0x3ff957533ae6a7d2
+ e.fpregs[58] = 0x3ffb89fed8923714
+ e.fpregs[59] = 0x3ffeee504bc32425
+ e.fpregs[60] = 0x40026711a672020b
+ e.fpregs[61] = 0x4008941ad80a2b83
+ e.fpregs[62] = 0x4015e8add236a58f
+ e.fpregs[63] = 0x403f000000000000
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)
+
+ def case_sv_fsinpi(self):
+ lst = list(SVP64Asm(["sv.fsinpi *32,*64"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ for i in range(svstate.vl):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i / 4))[0]
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x0
+ e.fpregs[33] = 0x3fe6a09e667f3bcc
+ e.fpregs[34] = 0x3ff0000000000000
+ e.fpregs[35] = 0x3fe6a09e667f3bcd
+ e.fpregs[36] = 0x3ca1a62633145c07
+ e.fpregs[37] = 0xbfe6a09e667f3bcc
+ e.fpregs[38] = 0xbff0000000000000
+ e.fpregs[39] = 0xbfe6a09e667f3bce
+ e.fpregs[40] = 0xbcb1a62633145c07
+ e.fpregs[41] = 0x3fe6a09e667f3bcb
+ e.fpregs[42] = 0x3ff0000000000000
+ e.fpregs[43] = 0x3fe6a09e667f3bd4
+ e.fpregs[44] = 0x3cba79394c9e8a0a
+ e.fpregs[45] = 0xbfe6a09e667f3bd0
+ e.fpregs[46] = 0xbff0000000000000
+ e.fpregs[47] = 0xbfe6a09e667f3bd5
+ e.fpregs[48] = 0xbcc1a62633145c07
+ e.fpregs[49] = 0x3fe6a09e667f3bcf
+ e.fpregs[50] = 0x3ff0000000000000
+ e.fpregs[51] = 0x3fe6a09e667f3bd6
+ e.fpregs[52] = 0x3cc60fafbfd97309
+ e.fpregs[53] = 0xbfe6a09e667f3bce
+ e.fpregs[54] = 0xbff0000000000000
+ e.fpregs[55] = 0xbfe6a09e667f3bd7
+ e.fpregs[56] = 0xbcca79394c9e8a0a
+ e.fpregs[57] = 0x3fe6a09e667f3bcd
+ e.fpregs[58] = 0x3ff0000000000000
+ e.fpregs[59] = 0x3fe6a09e667f3bd7
+ e.fpregs[60] = 0x3ccee2c2d963a10c
+ e.fpregs[61] = 0xbfe6a09e667f3bcd
+ e.fpregs[62] = 0xbff0000000000000
+ e.fpregs[63] = 0xbfe6a09e667f3bd8
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)
+
+ def case_sv_fminc(self):
+ lst = list(SVP64Asm(["sv.fminc *32,*64,*96"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ r = range(svstate.vl)
+ for i, rev_i in zip(r, reversed(r)):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i))[0]
+ fprs[96 + i] = struct.unpack("<Q", struct.pack("<d", rev_i))[0]
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x0
+ e.fpregs[33] = 0x3ff0000000000000
+ e.fpregs[34] = 0x4000000000000000
+ e.fpregs[35] = 0x4008000000000000
+ e.fpregs[36] = 0x4010000000000000
+ e.fpregs[37] = 0x4014000000000000
+ e.fpregs[38] = 0x4018000000000000
+ e.fpregs[39] = 0x401c000000000000
+ e.fpregs[40] = 0x4020000000000000
+ e.fpregs[41] = 0x4022000000000000
+ e.fpregs[42] = 0x4024000000000000
+ e.fpregs[43] = 0x4026000000000000
+ e.fpregs[44] = 0x4028000000000000
+ e.fpregs[45] = 0x402a000000000000
+ e.fpregs[46] = 0x402c000000000000
+ e.fpregs[47] = 0x402e000000000000
+ e.fpregs[48] = 0x402e000000000000
+ e.fpregs[49] = 0x402c000000000000
+ e.fpregs[50] = 0x402a000000000000
+ e.fpregs[51] = 0x4028000000000000
+ e.fpregs[52] = 0x4026000000000000
+ e.fpregs[53] = 0x4024000000000000
+ e.fpregs[54] = 0x4022000000000000
+ e.fpregs[55] = 0x4020000000000000
+ e.fpregs[56] = 0x401c000000000000
+ e.fpregs[57] = 0x4018000000000000
+ e.fpregs[58] = 0x4014000000000000
+ e.fpregs[59] = 0x4010000000000000
+ e.fpregs[60] = 0x4008000000000000
+ e.fpregs[61] = 0x4000000000000000
+ e.fpregs[62] = 0x3ff0000000000000
+ e.fpregs[63] = 0x0
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)
+
+ def case_sv_fmaxmag19(self):
+ lst = list(SVP64Asm(["sv.fmaxmag19 *32,*64,*96"]))
+ gprs = [0] * 128
+ fprs = [0] * 128
+ svstate = SVP64State()
+ svstate.vl = 32
+ svstate.maxvl = 32
+ r = range(svstate.vl)
+ for i, rev_i in zip(r, reversed(r)):
+ fprs[64 + i] = struct.unpack("<Q", struct.pack("<d", i))[0]
+ fprs[96 + i] = struct.unpack("<Q", struct.pack("<d", rev_i))[0]
+ e = ExpectedState(pc=8, int_regs=gprs, fp_regs=fprs)
+ e.fpregs[32] = 0x403f000000000000
+ e.fpregs[33] = 0x403e000000000000
+ e.fpregs[34] = 0x403d000000000000
+ e.fpregs[35] = 0x403c000000000000
+ e.fpregs[36] = 0x403b000000000000
+ e.fpregs[37] = 0x403a000000000000
+ e.fpregs[38] = 0x4039000000000000
+ e.fpregs[39] = 0x4038000000000000
+ e.fpregs[40] = 0x4037000000000000
+ e.fpregs[41] = 0x4036000000000000
+ e.fpregs[42] = 0x4035000000000000
+ e.fpregs[43] = 0x4034000000000000
+ e.fpregs[44] = 0x4033000000000000
+ e.fpregs[45] = 0x4032000000000000
+ e.fpregs[46] = 0x4031000000000000
+ e.fpregs[47] = 0x4030000000000000
+ e.fpregs[48] = 0x4030000000000000
+ e.fpregs[49] = 0x4031000000000000
+ e.fpregs[50] = 0x4032000000000000
+ e.fpregs[51] = 0x4033000000000000
+ e.fpregs[52] = 0x4034000000000000
+ e.fpregs[53] = 0x4035000000000000
+ e.fpregs[54] = 0x4036000000000000
+ e.fpregs[55] = 0x4037000000000000
+ e.fpregs[56] = 0x4038000000000000
+ e.fpregs[57] = 0x4039000000000000
+ e.fpregs[58] = 0x403a000000000000
+ e.fpregs[59] = 0x403b000000000000
+ e.fpregs[60] = 0x403c000000000000
+ e.fpregs[61] = 0x403d000000000000
+ e.fpregs[62] = 0x403e000000000000
+ e.fpregs[63] = 0x403f000000000000
+ self.add_case(Program(lst, False), gprs, fpregs=fprs,
+ initial_svstate=svstate, expected=e)