From aafcdcf51621d7533e96742119757c70d628b438 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 22:13:03 +0100 Subject: [PATCH] add <-iea operator --- src/soc/decoder/pseudo/lexer.py | 2 ++ src/soc/decoder/pseudo/parser.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/soc/decoder/pseudo/lexer.py b/src/soc/decoder/pseudo/lexer.py index f8952470..3f666c4b 100644 --- a/src/soc/decoder/pseudo/lexer.py +++ b/src/soc/decoder/pseudo/lexer.py @@ -240,6 +240,7 @@ class PowerLexer: 'RBRACK', 'COLON', 'EQ', + 'ASSIGNEA', 'ASSIGN', 'LTU', 'GTU', @@ -291,6 +292,7 @@ class PowerLexer: t_COLON = r':' t_EQ = r'=' + t_ASSIGNEA = r'<-iea' t_ASSIGN = r'<-' t_LTU = r'u' diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index 8613d2a4..bd05b4e9 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -23,7 +23,7 @@ import ast # Helper function -def Assign(left, right): +def Assign(left, right, iea_mode): names = [] print("Assign", left, right) if isinstance(left, ast.Name): @@ -320,7 +320,8 @@ class PowerParser: # augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | # '<<=' | '>>=' | '**=' | '//=') def p_expr_stmt(self, p): - """expr_stmt : testlist ASSIGN testlist + """expr_stmt : testlist ASSIGNEA testlist + | testlist ASSIGN testlist | testlist """ print("expr_stmt", p) if len(p) == 2: @@ -328,6 +329,7 @@ class PowerParser: #p[0] = ast.Discard(p[1]) p[0] = p[1] else: + iea_mode = p[2] == '<-iea' name = None if isinstance(p[1], ast.Name): name = p[1].id @@ -356,7 +358,7 @@ class PowerParser: print("expr assign", name, p[1]) if name and name in self.gprs: self.write_regs.add(name) # add to list of regs to write - p[0] = Assign(p[1], p[3]) + p[0] = Assign(p[1], p[3], iea_mode) def p_flow_stmt(self, p): "flow_stmt : return_stmt" -- 2.30.2