add comment/header on ld/st shift instructions
[openpower-isa.git] / openpower / isa / av.mdwn
index 64bde71f7e12f9eae9dfddf2013814fe441a2b5f..94c3e1c898820c962f27877edd6996f35f3a07a3 100644 (file)
@@ -2,69 +2,91 @@
 <!-- https://libre-soc.org/openpower/sv/bitmanip/ -->
 <!-- https://libre-soc.org/openpower/sv/av_opcodes/ -->
 
-# DRAFT Fixed Point Signed Max
+# DRAFT Minimum/Maximum (Rc=1)
 
-X-Form
-
-* maxs  RT,RA,RB (Rc=0)
-* maxs. RT,RA,RB (Rc=1)
-
-Pseudo-code:
-
-    if   (RA) > (RB) then RT <- (RA)
-    else                  RT <- (RB)
-
-Special Registers Altered:
-
-    CR0                     (if Rc=1)
-
-# DRAFT Fixed Point Unsigned Max
+MM-Form
 
-X-Form
-
-* maxu  RT,RA,RB (Rc=0)
-* maxu. RT,RA,RB (Rc=1)
+* minmax. RT,RA,RB,MMM (Rc=1)
 
 Pseudo-code:
 
-    if   (RA) >u (RB) then RT <- (RA)
-    else                   RT <- (RB)
+    a <- (RA|0)
+    b <- (RB)
+    if MMM[0] then  # word mode
+        # shift left by XLEN/2 to make the dword comparison
+        # do word comparison of the original inputs
+        a <- a[XLEN/2:XLEN-1] || [0] * XLEN/2
+        b <- b[XLEN/2:XLEN-1] || [0] * XLEN/2
+    if MMM[1] then  # signed mode
+        # invert sign bits to make the unsigned comparison
+        # do signed comparison of the original inputs
+        a[0] <- ¬a[0]
+        b[0] <- ¬b[0]
+    # if Rc = 1 then store the result of comparing a and b to CR0
+    if Rc = 1 then
+        if a <u b then
+            CR0 <- 0b100 || XER[SO]
+        if a = b then
+            CR0 <- 0b001 || XER[SO]
+        if a >u b then
+            CR0 <- 0b010 || XER[SO]
+    if MMM[2] then  # max mode
+        # swap a and b to make the less than comparison do
+        # greater than comparison of the original inputs
+        t <- a
+        a <- b
+        b <- t
+    # store the entire selected source (even in word mode)
+    # if Rc = 1 then store the result of comparing a and b to CR0
+    if a <u b then RT <- (RA|0)
+    else RT <- (RB)
 
 Special Registers Altered:
 
     CR0                     (if Rc=1)
 
-# DRAFT Fixed Point Signed Min
+# DRAFT Minimum/Maximum
 
-X-Form
+MM-Form
 
-* mins  RT,RA,RB (Rc=0)
-* mins. RT,RA,RB (Rc=1)
+* minmax RT,RA,RB,MMM (Rc=0)
 
 Pseudo-code:
 
-    if   (RA) < (RB) then RT <- (RA)
-    else                  RT <- (RB)
+    a <- (RA|0)
+    b <- (RB)
+    if MMM[0] then  # word mode
+        # shift left by XLEN/2 to make the dword comparison
+        # do word comparison of the original inputs
+        a <- a[XLEN/2:XLEN-1] || [0] * XLEN/2
+        b <- b[XLEN/2:XLEN-1] || [0] * XLEN/2
+    if MMM[1] then  # signed mode
+        # invert sign bits to make the unsigned comparison
+        # do signed comparison of the original inputs
+        a[0] <- ¬a[0]
+        b[0] <- ¬b[0]
+    # if Rc = 1 then store the result of comparing a and b to CR0
+    # if Rc = 1 then
+    #     if a <u b then
+    #         CR0 <- 0b100 || XER[SO]
+    #     if a = b then
+    #         CR0 <- 0b001 || XER[SO]
+    #     if a >u b then
+    #         CR0 <- 0b010 || XER[SO]
+    if MMM[2] then  # max mode
+        # swap a and b to make the less than comparison do
+        # greater than comparison of the original inputs
+        t <- a
+        a <- b
+        b <- t
+    # store the entire selected source (even in word mode)
+    # if Rc = 1 then store the result of comparing a and b to CR0
+    if a <u b then RT <- (RA|0)
+    else RT <- (RB)
 
 Special Registers Altered:
 
-    CR0                     (if Rc=1)
-
-# DRAFT Fixed Point Unsigned Min
-
-X-Form
-
-* minu  RT,RA,RB (Rc=0)
-* minu. RT,RA,RB (Rc=1)
-
-Pseudo-code:
-
-    if   (RA) <u (RB) then RT <- (RA)
-    else                   RT <- (RB)
-
-Special Registers Altered:
-
-    CR0                     (if Rc=1)
+    None
 
 # DRAFT Average Add
 
@@ -157,24 +179,24 @@ Special Registers Altered:
 X-Form
 
 * cprop RT,RA,RB (Rc=0)
-* cprop RT,RA,RB (Rc=1)
+* cprop. RT,RA,RB (Rc=1)
 
 Pseudo-code:
 
     P <- (RA)
     G <- (RB)
     temp <- (P|G)+G
-    RT <- temp^P 
+    RT <- temp^P
 
 Special Registers Altered:
 
     CR0                    (if Rc=1)
 
 # DRAFT Bitmanip Masked
+
 BM2-Form
-* bmask  RT,RA,RB,bm
+
+* bmask  RT,RA,RB,bm,L
 
 Pseudo-code:
 
@@ -206,15 +228,33 @@ Special Registers Altered:
 
     None
 
-# Load Floating-Point Immediate 
+# Load Floating-Point Immediate
 
-X-Form
+DX-Form
+
+* fmvis FRS,D
+
+Pseudo-code:
+
+    bf16 <- d0 || d1 || d2
+    fp32 <- bf16 || [0]*16
+    FRS  <- DOUBLE(fp32)
+
+Special Registers Altered:
+
+    None
+
+# Float Replace Lower-Half Single, Immediate
+
+DX-Form
 
-* fmvis FRS,FRS,SI
+* fishmv FRS,D
 
 Pseudo-code:
 
-    FRS <- EXTS(SI)
+    fp32 <- SINGLE((FRS))
+    fp32[16:31] <- d0 || d1 || d2
+    FRS <- DOUBLE(fp32)
 
 Special Registers Altered: