From b04ec1880b731b71362cb3787a998aaf59eedb54 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 9 May 2023 00:27:19 -0700 Subject: [PATCH] SetFX is not a normal function -- it can assign to its input --- src/openpower/decoder/pseudo/parser.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index 1e30b574..a88f9934 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -927,6 +927,19 @@ class PowerParser: name = arg.id if name in regs + fregs: read_regs.add(name) + if atom.id == "SetFX": + if len(trailer[1]) != 1 or \ + not isinstance(trailer[1][0], ast.Attribute): + raise_syntax_error( + "SetFX call must have only one argument that is an " + "attribute access -- like `SetFX(FPSCR.VXSNAN)`", + self.filename, trailer[2].lineno, trailer[2].lexpos, + self.input_text) + arg = trailer[1][0] + args = [arg.value, ast.Str(arg.attr)] + name = ast.Name("self", ast.Load()) + atom = ast.Attribute(name, atom, ast.Load()) + return ast.Call(atom, args, []) # special-case, these functions must NOT be made "self.xxxx" if atom.id not in SPECIAL_HELPERS: name = ast.Name("self", ast.Load()) -- 2.30.2