From: Andrey Miroshnikov Date: Mon, 24 Oct 2022 12:24:49 +0000 (+0100) Subject: bitmanip: Adding draft pseudo-code for shadd and shadduw X-Git-Tag: opf_rfc_ls005_v1~46 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1fed7949ef5dba45b1a3c378137a3fecb57aa7bf;p=libreriscv.git bitmanip: Adding draft pseudo-code for shadd and shadduw --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 1f91d90d3..11bf89447 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -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;