add SHL64 helper function
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 23 Jun 2021 15:29:54 +0000 (16:29 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 23 Jun 2021 15:29:54 +0000 (16:29 +0100)
src/openpower/decoder/helpers.py
src/openpower/decoder/pseudo/pywriter.py

index 4e0a1c16c487b3ec8208b13c615f5fcf57dc88f6..dfbd0d1f9d1215eb2a6f8283f4ef75d1e10d6886 100644 (file)
@@ -77,6 +77,14 @@ def rotl(value, bits, wordlen):
     return ((value << bits) | (value >> (wordlen-bits))) & mask
 
 
+def SHL64(value, bits, wordlen=64):
+    if isinstance(bits, SelectableInt):
+        bits = bits.value
+    mask = (1 << wordlen) - 1
+    bits = bits & (wordlen - 1)
+    return (value << bits) & mask
+
+
 def ROTL64(value, bits):
     return rotl(value, bits, 64)
 
index 58b290522dd61ec59553d7337d080a2c2bac4051..67a4cbc67f9c37a367f22165e91f9cf16a796550 100644 (file)
@@ -25,7 +25,7 @@ from openpower.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32,
                                  ne, eq, gt, ge, lt, le, ltu, gtu, length,
                                  trunc_divs, trunc_rems, MULS, DIVS, MODS,
                                  EXTS128, undefined,
-                                 bitrev,
+                                 bitrev, SHL64,
                                 )
 from openpower.decoder.selectable_int import SelectableInt
 from openpower.decoder.selectable_int import selectconcat as concat