From 9365b567632b28836b0eb8a8c7a277d3de29335c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 5 Apr 2020 12:52:01 +0100 Subject: [PATCH] allow [s] * 64 to be detected and turned into a repeat-list pattern --- src/soc/decoder/pseudo/parser.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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": -- 2.30.2