From 796d46c1d594fe406ae649aab11de8b36ead0340 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 23 Jun 2021 16:29:54 +0100 Subject: [PATCH] add SHL64 helper function --- src/openpower/decoder/helpers.py | 8 ++++++++ src/openpower/decoder/pseudo/pywriter.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 4e0a1c16..dfbd0d1f 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -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) diff --git a/src/openpower/decoder/pseudo/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index 58b29052..67a4cbc6 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -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 -- 2.30.2