From 2ebeb965606db0b7d9acf5577722abbb2960dc19 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 11 Jul 2022 12:55:51 +0100 Subject: [PATCH] fix issue in SelectableInt using slices involving SelectableInts --- src/openpower/decoder/selectable_int.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 1e7458ee..a3eca3d4 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -333,14 +333,19 @@ class SelectableInt: mask = 1 << key self.value = (self.value & ~mask) | (value & mask) elif isinstance(key, slice): - assert key.step is None or key.step == 1 - assert key.start < key.stop - assert key.start >= 0 - assert key.stop <= self.bits, \ - "key stop %d bits %d" % (key.stop, self.bits) - - stop = self.bits - key.start - start = self.bits - key.stop + kstart, kstop, kstep = key.start, key.stop, key.step + if isinstance(kstart, SelectableInt): kstart = kstart.asint() + if isinstance(kstop, SelectableInt): kstop = kstop.asint() + if isinstance(kstep, SelectableInt): kstep = kstep.asint() + log ("__setitem__ slice ", kstart, kstop, kstep) + assert kstep is None or kstep == 1 + assert kstart < kstop + assert kstart >= 0 + assert kstop <= self.bits, \ + "key stop %d bits %d" % (kstop, self.bits) + + stop = self.bits - kstart + start = self.bits - kstop bits = stop - start #log ("__setitem__ slice num bits", bits) -- 2.30.2