add <-iea operator
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 21:13:03 +0000 (22:13 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 21:13:03 +0000 (22:13 +0100)
src/soc/decoder/pseudo/lexer.py
src/soc/decoder/pseudo/parser.py

index f8952470b0ef86b099b5699f4964db67f011165f..3f666c4be189cdcc23a0bbe4f84e501fa89852ef 100644 (file)
@@ -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'
     t_GTU = r'>u'
index 8613d2a460fed4d954e3b7775d611369b711fb62..bd05b4e9e8c2f11d7014e5c1fa36f044b5f8a8df 100644 (file)
@@ -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"