FX OX UX XX
VXSNAN VXISI
CR1 (if Rc=1)
+
+# Floating Multiply-Add [Single]
+
+A-Form
+
+* fmadds FRT,FRA,FRC,FRB (Rc=0)
+* fmadds. FRT,FRA,FRC,FRB (Rc=0)
+
+Pseudo-code:
+
+ FRT <- FPMULADD32(FRA, FRC, FRB, 1)
+
+Special Registers Altered:
+
+ FPRF FR FI
+ FX OX UX XX
+ VXSNAN VXISI VXIMZ
+ CR1 (if Rc=1)
+
+# Floating Multiply-Sub [Single]
+
+A-Form
+
+* fmsubs FRT,FRA,FRC,FRB (Rc=0)
+* fmsubs. FRT,FRA,FRC,FRB (Rc=0)
+
+Pseudo-code:
+
+ FRT <- FPMULADD32(FRA, FRC, FRB, -1)
+
+Special Registers Altered:
+
+ FPRF FR FI
+ FX OX UX XX
+ VXSNAN VXISI VXIMZ
+ CR1 (if Rc=1)
+
return cvt
+def FPMULADD32(FRA, FRB, FRC, sign):
+ from openpower.decoder.isafunctions.double2single import DOUBLE2SINGLE
+ #return FPMUL64(FRA, FRB)
+ #FRA = DOUBLE(SINGLE(FRA))
+ #FRB = DOUBLE(SINGLE(FRB))
+ if sign == 1:
+ result = float(FRA) * float(FRB) + float(FRC)
+ elif sign == -1:
+ result = float(FRA) * float(FRB) - float(FRC)
+ elif sign == 0:
+ result = float(FRA) * float(FRB)
+ log ("FPMULADD32", FRA, FRB, FRC,
+ float(FRA), float(FRB), float(FRC),
+ result)
+ cvt = fp64toselectable(result)
+ cvt = DOUBLE2SINGLE(cvt)
+ log (" cvt", cvt)
+ return cvt
+
+
def FPDIV32(FRA, FRB):
#return FPDIV64(FRA, FRB)
#FRA = DOUBLE(SINGLE(FRA))
self.assertEqual(sim.fpr(2), SelectableInt(0xC02399999999999A, 64))
self.assertEqual(sim.fpr(3), SelectableInt(0xc051266640000000, 64))
- def test_fp_muls2(self):
- """>>> lst = ["fmuls 3, 1, 2",
- ]
- """
- lst = ["fmuls 3, 1, 2", #
- ]
-
- fprs = [0] * 32
- fprs[1] = 0xbfc4e9d700000000
- fprs[2] = 0xbdc5000000000000
-
- with Program(lst, bigendian=False) as program:
- sim = self.run_tst_program(program, initial_fprs=fprs)
- self.assertEqual(sim.fpr(3), SelectableInt(0x3d9b72ea40000000, 64))
-
def test_fp_muls3(self):
""">>> lst = ["fmuls 3, 1, 2",
]
self.assertEqual(sim.fpr(2), SelectableInt(0xC02399999999999A, 64))
self.assertEqual(sim.fpr(3), SelectableInt(0xC051266666666667, 64))
+ def test_fp_madd1(self):
+ """>>> lst = ["fmadds 3, 1, 2, 4",
+ ]
+ """
+ lst = ["fmadds 3, 1, 2, 4", # 7.0 * -9.8 + 2 = -66.6
+ ]
+
+ fprs = [0] * 32
+ fprs[1] = 0x401C000000000000 # 7.0
+ fprs[2] = 0xC02399999999999A # -9.8
+ fprs[4] = 0x4000000000000000 # 2.0
+
+ with Program(lst, bigendian=False) as program:
+ sim = self.run_tst_program(program, initial_fprs=fprs)
+ self.assertEqual(sim.fpr(3), SelectableInt(0xC050A66660000000, 64))
+
+ def test_fp_msub1(self):
+ """>>> lst = ["fmsubs 3, 1, 2, 4",
+ ]
+ """
+ lst = ["fmsubs 3, 1, 2, 4", # 7.0 * -9.8 + 2 = -70.6
+ ]
+
+ fprs = [0] * 32
+ fprs[1] = 0x401C000000000000 # 7.0
+ fprs[2] = 0xC02399999999999A # -9.8
+ fprs[4] = 0x4000000000000000 # 2.0
+
+ with Program(lst, bigendian=False) as program:
+ sim = self.run_tst_program(program, initial_fprs=fprs)
+ self.assertEqual(sim.fpr(3), SelectableInt(0xc051a66660000000, 64))
+
def test_fp_fcfids(self):
""">>> lst = ["fcfids 1, 2",
lst = ["fcfids 3, 4",