From 69c1f44388226d1fde2e6aa70ce2fd5bc660bd87 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 30 Aug 2021 16:03:07 +0100 Subject: [PATCH] quite a big intrusive change in auto-assignment variables that do not exist get auto-created based on the bit-width at which they are first encountered prod[0:31] creates a variable with prod = concat(0, repeat=32) however this needs to be more complicated rather than just assume it is a pair of constants expressions can now be prod[0:XLEN-1] which gets an ast.BinOp expression created on the RHS. therefore allow the assignment "var = concat(...., repeat=xxxx)" to accept computed expressions by returning an ast.BinOp(UPPER, "-", LOWER) so that the resultant python code performs the subtract calculation --- src/openpower/decoder/power_pseudo.py | 8 +++++++- src/openpower/decoder/pseudo/parser.py | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/openpower/decoder/power_pseudo.py b/src/openpower/decoder/power_pseudo.py index 4c5f36fd..a18d6a5f 100644 --- a/src/openpower/decoder/power_pseudo.py +++ b/src/openpower/decoder/power_pseudo.py @@ -215,7 +215,13 @@ assign_test2 = """ prod[0:XLEN-1] <- 5 """ -code = assign_test2 +assign_test = """ +prod[0:XLEN-1] <- MULS((RA)[XLEN/2:XLEN-1], (RB)[XLEN/2:XLEN-1]) +RT[XLEN/2:XLEN-1] <- prod[0:(XLEN/2)-1] +RT[0:(XLEN/2)-1] <- undefined(prod[0:(XLEN/2)-1]) +""" + +code = assign_test #code = concat_test3 #code = concat_test1 #code = XLEN_test diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index c93b74cd..94090281 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -28,7 +28,7 @@ fregs = ['FRA', 'FRS', 'FRB', 'FRC', 'FRT', 'FRS'] def Assign(autoassign, assignname, left, right, iea_mode): names = [] - print("Assign", assignname, left, right) + print("Assign", autoassign, assignname, left, right) if isinstance(left, ast.Name): # Single assignment on left # XXX when doing IntClass, which will have an "eq" function, @@ -62,10 +62,12 @@ def Assign(autoassign, assignname, left, right, iea_mode): # the declaration makes the slice-assignment "work" lower, upper, step = ls.lower, ls.upper, ls.step print("lower, upper, step", repr(lower), repr(upper), step) - if not isinstance(lower, ast.Constant) or \ - not isinstance(upper, ast.Constant): - return res - qty = ast.Num(upper.value-lower.value) + # XXX relax constraint that indices on auto-assign have + # to be constants x[0:32] + #if not isinstance(lower, ast.Constant) or \ + # not isinstance(upper, ast.Constant): + # return res + qty = ast.BinOp(upper, binary_ops['-'], lower) keywords = [ast.keyword(arg='repeat', value=qty)] l = [ast.Num(0)] right = ast.Call(ast.Name("concat", ast.Load()), l, keywords) @@ -438,8 +440,14 @@ class PowerParser: if isinstance(p[1], ast.Name): name = p[1].id elif isinstance(p[1], ast.Subscript): + print ("assign subscript", p[1].value, + self.declared_vars, + self.fnparm_vars, + self.special_regs) + print(astor.dump_tree(p[1])) if isinstance(p[1].value, ast.Name): name = p[1].value.id + print ("assign subscript value to name", name) if name in self.gprs: # add to list of uninitialised self.uninit_regs.add(name) -- 2.30.2