mem-ruby: added %(mod) operator to SLICC
authorTiago Mück <tiago.muck@arm.com>
Fri, 13 Sep 2019 20:55:15 +0000 (15:55 -0500)
committerTiago Mück <tiago.muck@arm.com>
Mon, 12 Oct 2020 14:09:55 +0000 (14:09 +0000)
Change-Id: I9d1a10824ced3723d13e2843ad739ced72e476ce
Signed-off-by: Tiago Mück <tiago.muck@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31260
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: John Alsop <johnathan.alsop@amd.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/slicc/ast/OperatorExprAST.py
src/mem/slicc/parser.py

index 7752e9c07acbc921f326f121be88997dce9c184d..cab13692c03d2bbafca90df666e0a74be5450f7b 100644 (file)
@@ -64,7 +64,7 @@ class InfixOperatorExprAST(ExprAST):
             elif self.op in ("<<", ">>"):
                 expected_types = [("int", "int", "int"),
                                   ("Cycles", "int", "Cycles")]
-            elif self.op in ("+", "-", "*", "/"):
+            elif self.op in ("+", "-", "*", "/", "%"):
                 expected_types = [("int", "int", "int"),
                                   ("Cycles", "Cycles", "Cycles"),
                                   ("Tick", "Tick", "Tick"),
index 643eec65de749244bebdf41b8c0aae91e16ade49..13dde9ab404df4aaf925fbb2a2a134b8361308ee 100644 (file)
@@ -128,7 +128,7 @@ class SLICC(Grammar):
     tokens = [ 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE',
                'LEFTSHIFT', 'RIGHTSHIFT',
                'NOT', 'AND', 'OR',
-               'PLUS', 'DASH', 'STAR', 'SLASH',
+               'PLUS', 'DASH', 'STAR', 'SLASH', 'MOD',
                'INCR', 'DECR',
                'DOUBLE_COLON', 'SEMI',
                'ASSIGN', 'DOT',
@@ -150,6 +150,7 @@ class SLICC(Grammar):
     t_DASH = r'-'
     t_STAR = r'\*'
     t_SLASH = r'/'
+    t_MOD = r'%'
     t_DOUBLE_COLON = r'::'
     t_SEMI = r';'
     t_ASSIGN = r':='
@@ -165,7 +166,7 @@ class SLICC(Grammar):
         ('left', 'LT', 'GT', 'LE', 'GE'),
         ('left', 'RIGHTSHIFT', 'LEFTSHIFT'),
         ('left', 'PLUS', 'DASH'),
-        ('left', 'STAR', 'SLASH'),
+        ('left', 'STAR', 'SLASH', 'MOD'),
         ('right', 'NOT', 'UMINUS'),
     )
 
@@ -695,6 +696,7 @@ class SLICC(Grammar):
     def p_expr__binary_op(self, p):
         """expr : expr STAR  expr
                 | expr SLASH expr
+                | expr MOD   expr
                 | expr PLUS  expr
                 | expr DASH  expr
                 | expr LT    expr