(no commit message)
authorlkcl <lkcl@web>
Wed, 4 May 2022 11:27:02 +0000 (12:27 +0100)
committerIkiWiki <ikiwiki.info>
Wed, 4 May 2022 11:27:02 +0000 (12:27 +0100)
openpower/sv/bitmanip.mdwn

index 0a2b37c75ab139032f64e2863f8bd30bb61c1819..8322aa8d710c225f3f44602ecd0a4fb83e15a141 100644 (file)
@@ -253,6 +253,23 @@ uint_xlen_t intabs(uint_xlen_t rs1, uint_xlen_t rs2) {
 }
 ```
 
+# shift-and-add
+
+Power ISA is missing LD/ST with shift, which is present in both ARM and x86.
+Too complex to add more LD/ST, a compromise is to add shift-and-add.
+Replaces a pair of explicit instructions in hot-loops.
+
+```
+uint_xlen_t shadd(uint_xlen_t rs1, uint_xlen_t rs2, uint8_t sh) {
+    return (rs1 << sh) + rs2;
+}
+
+uint_xlen_t shadduw(uint_xlen_t rs1, uint_xlen_t rs2, uint8_t sh) {
+    uint_xlen_t rs1z = rs1 & 0xFFFFFFFF;
+    return (rs1z << sh) + rs2;
+}
+```
+
 # cmix
 
 based on RV bitmanip, covered by ternlog bitops