fix issue with subscript uninitialised detection
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Apr 2020 12:07:00 +0000 (13:07 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Apr 2020 12:07:00 +0000 (13:07 +0100)
src/soc/decoder/power_pseudo.py
src/soc/decoder/pseudo/parser.py
src/soc/decoder/pseudo/pywriter.py

index 2e0c2e33b7658b6728391b8746426cde0f508b6d..2de3f5b83167476e5a953dd317e7a2c463caaa08 100644 (file)
@@ -144,7 +144,30 @@ ctr_ok <- BO[2] | ((CTR[M:63] != 0) ^ BO[3])
 cond_ok <- BO[0] | ¬(CR[BI+32] ^  BO[1])
 """
 
-code = testcond
+lswx = """
+if RA = 0 then EA <- 0
+else           EA <- (RA)
+if NB = 0 then n <-  32
+else           n <-  NB
+r <- RT - 1
+i <- 32
+do while n > 0
+    if i = 32 then
+        r <- (r + 1) % 32
+        GPR(r) <- 0
+    GPR(r)[i:i+7] <- MEM(EA, 1)
+    i <- i + 8
+    if i = 64 then i <- 32
+    EA <- EA + 1
+    n <- n - 1
+"""
+
+_lswx = """
+GPR(r)[x] <- 1
+"""
+
+code = lswx
+#code = testcond
 #code = testdo
 #code = _bpermd
 #code = testmul
index 4fb7bba95a6b22f02456c86d21a192a0c75142da..a65581d5e68c64550d091e50884ce452a050150e 100644 (file)
@@ -343,10 +343,11 @@ class PowerParser:
             if isinstance(p[1], ast.Name):
                 name = p[1].id
             elif isinstance(p[1], ast.Subscript):
-                name = p[1].value.id
-                if name in self.gprs:
-                    # add to list of uninitialised
-                    self.uninit_regs.add(name)
+                if isinstance(p[1].value, ast.Name):
+                    name = p[1].value.id
+                    if name in self.gprs:
+                        # add to list of uninitialised
+                        self.uninit_regs.add(name)
             elif isinstance(p[1], ast.Call) and p[1].func.id == 'GPR':
                 print(astor.dump_tree(p[1]))
                 # replace GPR(x) with GPR[x]
index 0dc41784ccde4a6a9a8a79c1832b48e555a6f718..d8e60686904ba53e9a9bc4f298bb3ad5b730a458 100644 (file)
@@ -72,8 +72,9 @@ class PyISAWriter(ISA):
 
 if __name__ == '__main__':
     isa = PyISAWriter()
-    isa.write_pysource('fixedshift')
+    isa.write_pysource('stringldst')
     exit(0)
+    isa.write_pysource('fixedshift')
     isa.write_pysource('condition')
     isa.write_pysource('fixedtrap')
     isa.write_pysource('branch')