From: Luke Kenneth Casson Leighton Date: Thu, 2 Apr 2020 17:23:18 +0000 (+0100) Subject: add test of if elif X-Git-Tag: div_pipeline~1562 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=757533a1e751f9804563cbf17878d83c4a8cae76;p=soc.git add test of if elif --- diff --git a/src/soc/decoder/power_pseudo.py b/src/soc/decoder/power_pseudo.py index 76e50906..317ab5da 100644 --- a/src/soc/decoder/power_pseudo.py +++ b/src/soc/decoder/power_pseudo.py @@ -62,8 +62,16 @@ RA <- EXTZ64(n) print (RA) """ +cmpi = """ +if a < EXTS(SI) then + c <- 0b100 +else if a > EXTS(SI) then + c <- 0b010 +""" + #code = testreg -code = cnttzd +#code = cnttzd +code = cmpi #code = bpermd def tolist(num): diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index 8f76f327..a4663ab4 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -265,10 +265,13 @@ class PowerParser: p[0] = ast.While(p[3], p[5], p[8]) def p_if_stmt(self, p): - """if_stmt : IF test COLON suite ELSE COLON suite + """if_stmt : IF test COLON suite ELSE COLON if_stmt + | IF test COLON suite ELSE COLON suite | IF test COLON suite """ - if len(p) == 5: + if len(p) == 8 and isinstance(p[7], ast.If): + p[0] = ast.If(p[2], p[4], [p[7]]) + elif len(p) == 5: p[0] = ast.If(p[2], p[4], []) else: p[0] = ast.If(p[2], p[4], p[7])