SetFX is not a normal function -- it can assign to its input
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 9 May 2023 07:27:19 +0000 (00:27 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 9 May 2023 07:27:19 +0000 (00:27 -0700)
src/openpower/decoder/pseudo/parser.py

index 1e30b5749f4eceaa18b1050157765892bd101b20..a88f993400951b619a236a475774d410e0c7632b 100644 (file)
@@ -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())