From bd3b54e83101217dc32da09083c6a3858fd7c600 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 18 Oct 2023 21:24:04 +0100 Subject: [PATCH] Revert "fix bug where pseudo-code assignments modify more than just the variable being assigned to" This reverts commit 4e701a851536bba6648779c183293ba75e7ea7b8. adding copy_assign_rhs was added without authorization or discussion and is damaging the simulator --- src/openpower/decoder/helpers.py | 29 ---------------------- src/openpower/decoder/pseudo/parser.py | 8 +----- src/openpower/decoder/pseudo/pyfnwriter.py | 2 +- src/openpower/decoder/pseudo/pywriter.py | 2 +- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 2c937134..99131c7f 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -72,35 +72,6 @@ def EXTS128(value): return SelectableInt(exts(value.value, value.bits) & ((1 << 128)-1), 128) -def copy_assign_rhs(inp): - """ implicitly added function call to all assignment RHSes. - This copies the passed-in value so later assignments to parts of the - LHS don't modify the RHS if it's a SelectableInt. - - Example: - ``` - # this needs to copy the SelectableInt instance in RA - # not just assign a reference to it to A - A <- RA - A[0] <- 1 # if the copy wasn't performed, we just modified RA too! - ``` - """ - if isinstance(inp, (str, int)): - return inp - if isinstance(inp, (SelectableInt, FieldSelectableInt)): - return SelectableInt(inp) - if isinstance(inp, BFPState): - return BFPState(inp) - if isinstance(inp, SelectableMSB0Fraction): - return SelectableMSB0Fraction(inp) - if isinstance(inp, tuple): - return tuple(map(copy_assign_rhs, inp)) - if isinstance(inp, dict): - return {copy_assign_rhs(k): copy_assign_rhs(v) for k, v in inp.items()} - raise TypeError("tried to assign an unsupported type in pseudo-code", - repr(type(inp))) - - # signed version of MUL def MULS(a, b): if isinstance(b, int): diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index a618aec1..00d49247 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -401,13 +401,7 @@ class PowerParser: self.read_regs.add(toname) if name and name in self.gprs: self.write_regs.add(name) # add to list of regs to write - - # copy rhs -- see openpower.decoder.helpers.copy_assign_rhs()'s - # documentation for why we need this - copy_fn = ast.Name("copy_assign_rhs", ast.Load()) - rhs = ast.Call(copy_fn, (p[3],), []) - p[0] = self.Assign(autoassign, name, p[1], rhs, iea_mode, - p.slice[2]) + p[0] = Assign(autoassign, name, p[1], p[3], iea_mode) if name: self.declared_vars.add(name) diff --git a/src/openpower/decoder/pseudo/pyfnwriter.py b/src/openpower/decoder/pseudo/pyfnwriter.py index 417706a4..448b3e34 100644 --- a/src/openpower/decoder/pseudo/pyfnwriter.py +++ b/src/openpower/decoder/pseudo/pyfnwriter.py @@ -21,7 +21,7 @@ header = """\ from openpower.decoder.isa.caller import inject from openpower.decoder.helpers import (ISACallerHelper, ne, eq, gt, ge, lt, le, ltu, gtu, length, - trunc_divs, trunc_rems, copy_assign_rhs, + trunc_divs, trunc_rems, ) from openpower.decoder.selectable_int import SelectableInt from openpower.decoder.selectable_int import selectconcat as concat diff --git a/src/openpower/decoder/pseudo/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index 6d436eef..b0772935 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -23,7 +23,7 @@ header = """\ from openpower.decoder.isa.caller import inject, instruction_info from openpower.decoder.helpers import ( ne, eq, gt, ge, lt, le, ltu, gtu, length, - RANGE, copy_assign_rhs, + RANGE, ISACallerHelper, ) from openpower.decoder.selectable_int import SelectableInt -- 2.30.2