From: Luke Kenneth Casson Leighton Date: Sun, 5 Apr 2020 11:52:01 +0000 (+0100) Subject: allow [s] * 64 to be detected and turned into a repeat-list pattern X-Git-Tag: div_pipeline~1494 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9365b567632b28836b0eb8a8c7a277d3de29335c;p=soc.git allow [s] * 64 to be detected and turned into a repeat-list pattern --- diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index 51c21a3a..4fb7bba9 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -146,17 +146,20 @@ def check_concat(node): # checks if the comparison is already a concat return node.args -# identify SelectableInt pattern +# identify SelectableInt pattern [something] * N +# must return concat(something, repeat=N) def identify_sint_mul_pattern(p): - if not isinstance(p[3], ast.Constant): + if p[2] != '*': # multiply return False - if not isinstance(p[1], ast.List): + if not isinstance(p[3], ast.Constant): # rhs = Num + return False + if not isinstance(p[1], ast.List): # lhs is a list return False l = p[1].elts - if len(l) != 1: + if len(l) != 1: # lhs is a list of length 1 return False - elt = l[0] - return isinstance(elt, ast.Constant) + return True # yippee! + def apply_trailer(atom, trailer): if trailer[0] == "TLIST":