add GPR-underscore read of regs
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 14 May 2021 20:19:15 +0000 (21:19 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 14 May 2021 20:19:15 +0000 (21:19 +0100)
openpower/isa/comparefixed.mdwn
src/openpower/decoder/pseudo/parser.py

index e1a365f2a2af11244e8263405398e2ca1109651f..a4f6d61734172b3779b07ab2248e7a6264bb4aed 100644 (file)
@@ -126,7 +126,7 @@ X-Form
 
 Pseudo-code:
 
-    src1 <- GPR[RA]
+    src1 <- (RA)
     src1 <- src1[56:63]
     match <- ((src1 = (RB)[00:07]) |
               (src1 = (RB)[08:15]) |
index 39b6485c02a94bbfcb754a5906ce12bde7b81a18..ba99749341cb95934f402a99af02075647e4c893 100644 (file)
@@ -207,6 +207,9 @@ def apply_trailer(atom, trailer):
         subs = trailer[1]
         if len(subs) == 1:
             idx = subs[0]
+            if isinstance(idx, ast.Name) and idx.id in regs:
+                print ("single atom subscript, underscored", idx.id)
+                idx = ast.Name("_%s" % idx.id, ast.Load())
         else:
             idx = ast.Slice(subs[0], subs[1], None)
         # if isinstance(atom, ast.Name) and atom.id == 'CR':
@@ -408,8 +411,10 @@ class PowerParser:
                             ['GPR', 'FPR', 'SPR']:
                 print(astor.dump_tree(p[1]))
                 # replace GPR(x) with GPR[x]
-                idx = p[1].args[0]
-                p[1] = ast.Subscript(p[1].func, idx, ast.Load())
+                idx = p[1].args[0].id
+                ridx = ast.Name("_%s" % idx, ast.Load())
+                p[1] = ast.Subscript(p[1].func, ridx, ast.Load())
+                self.read_regs.add(idx)  # add to list of regs to read
             elif isinstance(p[1], ast.Call) and p[1].func.id == 'MEM':
                 print("mem assign")
                 print(astor.dump_tree(p[1]))