From: Luke Kenneth Casson Leighton Date: Wed, 23 Jun 2021 15:23:56 +0000 (+0100) Subject: add bitrev function to be used in LD-ST-bitrev FFT/DCT X-Git-Tag: xlen-bcd~412 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e84559bed6550abc8b336969882a6312ba971368;p=openpower-isa.git add bitrev function to be used in LD-ST-bitrev FFT/DCT --- diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 6b270a96..ed8679d6 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -364,6 +364,19 @@ def FPDIV64(FRA, FRB, sign=1): return cvt + +def bitrev(val, VL): + """Returns the integer whose value is the reverse of the lowest + 'width' bits of the integer 'val' + """ + result = 0 + width = VL.bit_length() + for _ in range(width): + result = (result << 1) | (val & 1) + val >>= 1 + return result + + # For these tests I tried to find power instructions that would let me # isolate each of these helper operations. So for instance, when I was # testing the MASK() function, I chose rlwinm and rldicl because if I