From: Luke Kenneth Casson Leighton Date: Sun, 5 Apr 2020 12:07:00 +0000 (+0100) Subject: fix issue with subscript uninitialised detection X-Git-Tag: div_pipeline~1493 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=552aec6faf03322c9b7cb28f900a3b41a93116dd;p=soc.git fix issue with subscript uninitialised detection --- diff --git a/src/soc/decoder/power_pseudo.py b/src/soc/decoder/power_pseudo.py index 2e0c2e33..2de3f5b8 100644 --- a/src/soc/decoder/power_pseudo.py +++ b/src/soc/decoder/power_pseudo.py @@ -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 diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index 4fb7bba9..a65581d5 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -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] diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 0dc41784..d8e60686 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -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')