From 6c80ed2c209a8c89d94be2077d21a427e921c09a Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 23 Apr 2021 17:47:24 +0100 Subject: [PATCH] add a MASK32 function which offsets by 32 on the inputs also fix ROTL32 so it selects value from its input --- src/openpower/decoder/helpers.py | 8 ++++++++ src/openpower/decoder/pseudo/pywriter.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index c8d0044d..70e05d97 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -78,10 +78,18 @@ def ROTL64(value, bits): def ROTL32(value, bits): + if isinstance(bits, SelectableInt): + bits = bits.value if isinstance(value, SelectableInt): value = SelectableInt(value.value, 64) return rotl(value | (value << 32), bits, 64) +def MASK32(x, y): + if isinstance(x, SelectableInt): + x = x.value + if isinstance(y, SelectableInt): + y = y.value + return MASK(x+32, y+32) def MASK(x, y): if isinstance(x, SelectableInt): diff --git a/src/openpower/decoder/pseudo/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index d2b6882a..b61d7bf2 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -21,7 +21,8 @@ header = """\ from openpower.decoder.isa.caller import inject, instruction_info from openpower.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32, - MASK, ne, eq, gt, ge, lt, le, ltu, gtu, length, + MASK, MASK32, + ne, eq, gt, ge, lt, le, ltu, gtu, length, trunc_divs, trunc_rems, MULS, DIVS, MODS, EXTS128, undefined) from openpower.decoder.selectable_int import SelectableInt -- 2.30.2