ad fnmadd and fnmsubs to ISA pseudocode
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 16 Jun 2021 12:07:34 +0000 (13:07 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 16 Jun 2021 12:07:34 +0000 (13:07 +0100)
openpower/isa/fparith.mdwn
src/openpower/decoder/helpers.py

index 1c80d0e16330e720ebebb1623e975ea28832203c..a6a5e91a487504d11aab76e3bf1e807c9a8bb60c 100644 (file)
@@ -155,7 +155,7 @@ A-Form
 
 Pseudo-code:
 
-    FRT <- FPMULADD32(FRA, FRC, FRB, 1)
+    FRT <- FPMULADD32(FRA, FRC, FRB, 1, 1)
 
 Special Registers Altered:
 
@@ -173,7 +173,43 @@ A-Form
 
 Pseudo-code:
 
-    FRT <- FPMULADD32(FRA, FRC, FRB, -1)
+    FRT <- FPMULADD32(FRA, FRC, FRB, 1, -1)
+
+Special Registers Altered:
+
+    FPRF FR FI
+    FX OX UX XX
+    VXSNAN VXISI VXIMZ
+    CR1          (if Rc=1)
+
+# Floating Negative Multiply-Add [Single]
+
+A-Form
+
+* fnmadds FRT,FRA,FRC,FRB (Rc=0)
+* fnmadds. FRT,FRA,FRC,FRB (Rc=0)
+
+Pseudo-code:
+
+    FRT <- FPMULADD32(FRA, FRC, FRB, -1, 1)
+
+Special Registers Altered:
+
+    FPRF FR FI
+    FX OX UX XX
+    VXSNAN VXISI VXIMZ
+    CR1          (if Rc=1)
+
+# Floating Negative Multiply-Sub [Single]
+
+A-Form
+
+* fnmsubs FRT,FRA,FRC,FRB (Rc=0)
+* fnmsubs. FRT,FRA,FRC,FRB (Rc=0)
+
+Pseudo-code:
+
+    FRT <- FPMULADD32(FRA, FRC, FRB, -1, -1)
 
 Special Registers Altered:
 
index faef2d9a3481dc23bad4ebf732469ac45a4bcfaa..7188f6cc74356b2e46e6f9a4d117ee710e3d33d4 100644 (file)
@@ -289,17 +289,21 @@ def FPMUL32(FRA, FRB):
     return cvt
 
 
-def FPMULADD32(FRA, FRB, FRC, sign):
+def FPMULADD32(FRA, FRB, FRC, addsign, mulsign):
     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)
+    if addsign == 1:
+        result = float(FRC)
+    elif addsign == -1:
+        result = -float(FRC)
+    elif addsign == 0:
+        result = 0.0
+    if mulsign == 1:
+        result += float(FRA) * float(FRB)
+    elif mulsign == -1:
+        result -= float(FRA) * float(FRB)
     log ("FPMULADD32", FRA, FRB, FRC,
                        float(FRA), float(FRB), float(FRC),
                        result)