bitmanip: Adding draft pseudo-code for shadd and shadduw
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Mon, 24 Oct 2022 12:24:49 +0000 (13:24 +0100)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Mon, 24 Oct 2022 12:24:49 +0000 (13:24 +0100)
openpower/sv/bitmanip.mdwn

index 1f91d90d33b282ac00b676350ff2dadda93f3a3c..11bf894472e2c6a703af65cd6685c337091ae4de 100644 (file)
@@ -249,6 +249,24 @@ Replaces a pair of explicit instructions in hot-loops.
     | PO   |  RT  |   RA     |   RB  |sm |   XO |Rc |
 ```
 
+```
+Pseudo-code (shadd):
+    shift <- sm & 0x3                  # Ensure sm is 2-bit
+    shift <- shift + 1                 # Shift is between 1-4
+    sum[0:63] <- ((RB) << shift) + (RA) # Shift RB, add RA
+    RT <- sum                          # Result stored in RT
+```
+
+Is Rc used to indicate the two modes?
+```
+Pseudo-code (shadduw):
+    shift <- sm & 0x3                  # Ensure sm is 2-bit
+    shift <- shift + 1                 # Shift is between 1-4
+    n <- (RB) & 0xFFFFFFFF             # Limit RB to upper word (32-bits)
+    sum[0:63] <- (n << shift) + (RA)    # Shift n, add RA
+    RT <- sum                          # Result stored in RT
+```
+
 ```
 uint_xlen_t shadd(uint_xlen_t RA, uint_xlen_t RB, uint8_t sm) {
     sm = sm & 0x3;