From: Luke Kenneth Casson Leighton Date: Mon, 30 Aug 2021 12:03:53 +0000 (+0100) Subject: fix pattern-match for an expression such as "XLEN-16" when looking X-Git-Tag: xlen-bcd~103 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=39a0dc7397c592b4b53631b2284d142fd20ac485;p=openpower-isa.git fix pattern-match for an expression such as "XLEN-16" when looking for concat substitutions [item] * NUMBER was replaced with concat(item, repeat=NUMBER) but [item] * (XLEN-16) was not matching by adding a HACK which spots ast.Binop then [item]*(XLEN-16) can be recognised --- diff --git a/src/openpower/decoder/power_pseudo.py b/src/openpower/decoder/power_pseudo.py index 99f3ca47..ec9bf085 100644 --- a/src/openpower/decoder/power_pseudo.py +++ b/src/openpower/decoder/power_pseudo.py @@ -194,7 +194,17 @@ XLEN_test = """ RA[XLEN:XLEN - 1] """ -code = XLEN_test +concat_test1 = """ +[0]*16 +""" + +concat_test2 = """ +[0]*(XLEN-16) +""" + +code = concat_test2 +#code = concat_test1 +#code = XLEN_test #code = logictest #code = SVSTATE_next #code = hextest diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index 03d0fd5e..b9779b0d 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -176,10 +176,21 @@ def check_concat(node): # checks if the comparison is already a concat # identify SelectableInt pattern [something] * N # must return concat(something, repeat=N) +# here is a TEMPORARY hack to support minimal expressions +# such as (XLEN-16), looking for ast.BinOp +# have to keep an eye on this def identify_sint_mul_pattern(p): + """here we are looking for patterns of this type: + [item] * something + these must specifically be returned as concat(item, repeat=something) + """ + #print ("identify_sint_mul_pattern") + #for pat in p: + # print(" ", astor.dump_tree(pat)) if p[2] != '*': # multiply return False - if not isinstance(p[3], ast.Constant): # rhs = Num + if (not isinstance(p[3], ast.Constant) and # rhs = Num + not isinstance(p[3], ast.BinOp)): # rhs = (XLEN-something) return False if not isinstance(p[1], ast.List): # lhs is a list return False