diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2014-04-08 13:26:30 -0500 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2014-04-08 13:26:30 -0500 |
commit | d805e42b81de580342a615ea99491401943a14d4 (patch) | |
tree | 07eb196006be4e010a0b5d9dbe2bd4d8de46b76e /src/mem/slicc | |
parent | e689c00b16d40f52210cd185f668a351435c7af9 (diff) | |
download | gem5-d805e42b81de580342a615ea99491401943a14d4.tar.xz |
ruby: slicc: change enqueue statement
As of now, the enqueue statement can take in any number of 'pairs' as
argument. But we only use the pair in which latency is the key. This
latency is allowed to be either a fixed integer or a member variable of
controller in which the expression appears. This patch drops the use of pairs
in an enqueue statement. Instead, an expression is allowed which will be
interpreted to be the latency of the enqueue. This expression can anything
allowed by slicc including a constant integer or a member variable.
Diffstat (limited to 'src/mem/slicc')
-rw-r--r-- | src/mem/slicc/ast/EnqueueStatementAST.py | 26 | ||||
-rw-r--r-- | src/mem/slicc/parser.py | 24 |
2 files changed, 23 insertions, 27 deletions
diff --git a/src/mem/slicc/ast/EnqueueStatementAST.py b/src/mem/slicc/ast/EnqueueStatementAST.py index 7ad6f00a0..c4f2ac06c 100644 --- a/src/mem/slicc/ast/EnqueueStatementAST.py +++ b/src/mem/slicc/ast/EnqueueStatementAST.py @@ -29,11 +29,12 @@ from slicc.ast.StatementAST import StatementAST from slicc.symbols import Var class EnqueueStatementAST(StatementAST): - def __init__(self, slicc, queue_name, type_ast, pairs, statements): - super(EnqueueStatementAST, self).__init__(slicc, pairs) + def __init__(self, slicc, queue_name, type_ast, lexpr, statements): + super(EnqueueStatementAST, self).__init__(slicc) self.queue_name = queue_name self.type_ast = type_ast + self.latexpr = lexpr self.statements = statements def __repr__(self): @@ -58,23 +59,14 @@ class EnqueueStatementAST(StatementAST): # The other statements t = self.statements.generate(code, None) - self.queue_name.assertType("OutPort") - args = [ "out_msg" ] - if "latency" in self: - latency = self["latency"] - try: - # see if this is an integer - latency = int(latency) - args.append("Cycles(%s)" % latency) - except ValueError: - # if not, it should be a member - args.append("m_%s" % latency) - - args = ", ".join(args) - code('(${{self.queue_name.var.code}}).enqueue($args);') - + if self.latexpr != None: + ret_type, rcode = self.latexpr.inline(True) + code("(${{self.queue_name.var.code}}).enqueue(" \ + "out_msg, Cycles($rcode));") + else: + code("(${{self.queue_name.var.code}}).enqueue(out_msg);") # End scope self.symtab.popFrame() diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py index dbf939a9e..d0d26afe8 100644 --- a/src/mem/slicc/parser.py +++ b/src/mem/slicc/parser.py @@ -557,8 +557,12 @@ class SLICC(Grammar): p[0] = ast.AssignStatementAST(self, p[1], p[3]) def p_statement__enqueue(self, p): - "statement : ENQUEUE '(' var ',' type pairs ')' statements" - p[0] = ast.EnqueueStatementAST(self, p[3], p[5], p[6], p[8]) + "statement : ENQUEUE '(' var ',' type ')' statements" + p[0] = ast.EnqueueStatementAST(self, p[3], p[5], None, p[7]) + + def p_statement__enqueue_latency(self, p): + "statement : ENQUEUE '(' var ',' type ',' expr ')' statements" + p[0] = ast.EnqueueStatementAST(self, p[3], p[5], p[7], p[9]) def p_statement__stall_and_wait(self, p): "statement : STALL_AND_WAIT '(' var ',' var ')' SEMI" @@ -576,14 +580,6 @@ class SLICC(Grammar): "statement : CHECK_STOP_SLOTS '(' var ',' STRING ',' STRING ')' SEMI" p[0] = ast.CheckStopStatementAST(self, p[3], p[5], p[7]) - def p_statement__static_cast(self, p): - "aexpr : STATIC_CAST '(' type ',' expr ')'" - p[0] = ast.StaticCastAST(self, p[3], "ref", p[5]) - - def p_statement__static_cast_ptr(self, p): - "aexpr : STATIC_CAST '(' type ',' STRING ',' expr ')'" - p[0] = ast.StaticCastAST(self, p[3], p[5], p[7]) - def p_statement__return(self, p): "statement : RETURN expr SEMI" p[0] = ast.ReturnStatementAST(self, p[2]) @@ -605,6 +601,14 @@ class SLICC(Grammar): p[0] = ast.IfStatementAST(self, p[3], p[5], ast.StatementListAST(self, p[7])) + def p_expr__static_cast(self, p): + "aexpr : STATIC_CAST '(' type ',' expr ')'" + p[0] = ast.StaticCastAST(self, p[3], "ref", p[5]) + + def p_expr__static_cast_ptr(self, p): + "aexpr : STATIC_CAST '(' type ',' STRING ',' expr ')'" + p[0] = ast.StaticCastAST(self, p[3], p[5], p[7]) + def p_expr__var(self, p): "aexpr : var" p[0] = p[1] |