summaryrefslogtreecommitdiff
path: root/src/mem/slicc
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2015-08-19 10:02:01 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2015-08-19 10:02:01 -0500
commit2f44dada688ace9c24f085a8422b3054c3edb72e (patch)
tree372bb043430552b0f4424eaa5571933883fcaaae /src/mem/slicc
parent2d9f3f8582e2de60850852c803a8c8ba0d6b91b5 (diff)
downloadgem5-2f44dada688ace9c24f085a8422b3054c3edb72e.tar.xz
ruby: reverts to changeset: bf82f1f7b040
Diffstat (limited to 'src/mem/slicc')
-rw-r--r--src/mem/slicc/ast/EnumDeclAST.py2
-rw-r--r--src/mem/slicc/ast/FormalParamAST.py22
-rw-r--r--src/mem/slicc/ast/FuncCallExprAST.py17
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.py17
-rw-r--r--src/mem/slicc/ast/InPortDeclAST.py4
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.py21
-rw-r--r--src/mem/slicc/ast/StateDeclAST.py4
-rw-r--r--src/mem/slicc/parser.py10
-rw-r--r--src/mem/slicc/symbols/Func.py35
-rw-r--r--src/mem/slicc/symbols/StateMachine.py10
10 files changed, 62 insertions, 80 deletions
diff --git a/src/mem/slicc/ast/EnumDeclAST.py b/src/mem/slicc/ast/EnumDeclAST.py
index bc0c1c224..d97c13483 100644
--- a/src/mem/slicc/ast/EnumDeclAST.py
+++ b/src/mem/slicc/ast/EnumDeclAST.py
@@ -67,6 +67,6 @@ class EnumDeclAST(DeclAST):
pairs = { "external" : "yes" }
func = Func(self.symtab, func_id + "_" + t.c_ident,
func_id, self.location,
- self.symtab.find("std::string", Type), [ t ], [], [], "",
+ self.symtab.find("std::string", Type), [ t ], [], "",
pairs)
self.symtab.newSymbol(func)
diff --git a/src/mem/slicc/ast/FormalParamAST.py b/src/mem/slicc/ast/FormalParamAST.py
index ef39b40f0..ce73304f1 100644
--- a/src/mem/slicc/ast/FormalParamAST.py
+++ b/src/mem/slicc/ast/FormalParamAST.py
@@ -46,9 +46,6 @@ class FormalParamAST(AST):
def generate(self):
type = self.type_ast.type
param = "param_%s" % self.ident
- proto = ""
- body = ""
- default = False
# Add to symbol table
v = Var(self.symtab, self.ident, self.location, type, param,
@@ -59,21 +56,6 @@ class FormalParamAST(AST):
"interface" in type and (
type["interface"] == "AbstractCacheEntry" or
type["interface"] == "AbstractEntry")):
- proto = "%s* %s" % (type.c_ident, param)
- body = proto
- elif self.default != None:
- value = ""
- if self.default == True:
- value = "true"
- elif self.default == False:
- value = "false"
- else:
- value = "%s" % self.default
- proto = "const %s& %s = %s" % (type.c_ident, param, value)
- body = "const %s& %s" % (type.c_ident, param)
- default = True
+ return type, "%s* %s" % (type.c_ident, param)
else:
- proto = "const %s& %s" % (type.c_ident, param)
- body = proto
-
- return type, proto, body, default
+ return type, "const %s& %s" % (type.c_ident, param)
diff --git a/src/mem/slicc/ast/FuncCallExprAST.py b/src/mem/slicc/ast/FuncCallExprAST.py
index 0c9880d6d..9336a2297 100644
--- a/src/mem/slicc/ast/FuncCallExprAST.py
+++ b/src/mem/slicc/ast/FuncCallExprAST.py
@@ -93,7 +93,22 @@ class FuncCallExprAST(ExprAST):
if func is None:
self.error("Unrecognized function name: '%s'", func_name_args)
- cvec, type_vec = func.checkArguments(self.exprs)
+ if len(self.exprs) != len(func.param_types):
+ self.error("Wrong number of arguments passed to function : '%s'" +\
+ " Expected %d, got %d", self.proc_name,
+ len(func.param_types), len(self.exprs))
+
+ cvec = []
+ type_vec = []
+ for expr,expected_type in zip(self.exprs, func.param_types):
+ # Check the types of the parameter
+ actual_type,param_code = expr.inline(True)
+ if str(actual_type) != 'OOD' and \
+ str(actual_type) != str(expected_type):
+ expr.error("Type mismatch: expected: %s actual: %s" % \
+ (expected_type, actual_type))
+ cvec.append(param_code)
+ type_vec.append(expected_type)
# OK, the semantics of "trigger" here is that, ports in the
# machine have different priorities. We always check the first
diff --git a/src/mem/slicc/ast/FuncDeclAST.py b/src/mem/slicc/ast/FuncDeclAST.py
index 4e64c0ba5..47ae7076e 100644
--- a/src/mem/slicc/ast/FuncDeclAST.py
+++ b/src/mem/slicc/ast/FuncDeclAST.py
@@ -45,9 +45,7 @@ class FuncDeclAST(DeclAST):
def generate(self, parent = None):
types = []
- proto_params = []
- body_params = []
- default_count = 0
+ params = []
void_type = self.symtab.find("void", Type)
# Generate definition code
@@ -60,17 +58,13 @@ class FuncDeclAST(DeclAST):
for formal in self.formals:
# Lookup parameter types
try:
- type, proto, body, default = formal.generate()
+ type, ident = formal.generate()
types.append(type)
- proto_params.append(proto)
- body_params.append(body)
- if default:
- default_count += 1
+ params.append(ident)
except AttributeError:
types.append(formal.type)
- proto_params.append(None)
- body_params.append(None)
+ params.append(None)
body = self.slicc.codeFormatter()
if self.statements is None:
@@ -93,8 +87,7 @@ class FuncDeclAST(DeclAST):
machine = self.state_machine
func = Func(self.symtab, func_name_args, self.ident, self.location,
- return_type, types, proto_params,
- body_params, str(body), self.pairs, default_count)
+ return_type, types, params, str(body), self.pairs)
if parent is not None:
if not parent.addFunc(func):
diff --git a/src/mem/slicc/ast/InPortDeclAST.py b/src/mem/slicc/ast/InPortDeclAST.py
index 2ef043151..7a019a0e0 100644
--- a/src/mem/slicc/ast/InPortDeclAST.py
+++ b/src/mem/slicc/ast/InPortDeclAST.py
@@ -89,13 +89,13 @@ class InPortDeclAST(DeclAST):
for param in param_types:
trigger_func_name += "_" + param.ident
func = Func(self.symtab, trigger_func_name, "trigger", self.location,
- void_type, param_types, [], [], "", pairs)
+ void_type, param_types, [], "", pairs)
symtab.newSymbol(func)
# Add the stallPort method - this hacks reschedules the controller
# for stalled messages that don't trigger events
func = Func(self.symtab, "stallPort", "stallPort", self.location,
- void_type, [], [], [], "", pairs)
+ void_type, [], [], "", pairs)
symtab.newSymbol(func)
param_types = []
diff --git a/src/mem/slicc/ast/MethodCallExprAST.py b/src/mem/slicc/ast/MethodCallExprAST.py
index 104d6f8df..8be319a40 100644
--- a/src/mem/slicc/ast/MethodCallExprAST.py
+++ b/src/mem/slicc/ast/MethodCallExprAST.py
@@ -56,8 +56,20 @@ class MethodCallExprAST(ExprAST):
self.error("Invalid method call: Type '%s' does not have a method '%s'",
obj_type, methodId)
- func = obj_type.methods[methodId]
- func.checkArguments(self.expr_ast_vec)
+ if len(self.expr_ast_vec) != \
+ len(obj_type.methods[methodId].param_types):
+ # Right number of parameters
+ self.error("Wrong number of parameters for function name: '%s', " + \
+ "expected: , actual: ", proc_name,
+ len(obj_type.methods[methodId].param_types),
+ len(self.expr_ast_vec))
+
+ for actual_type, expected_type in \
+ zip(paramTypes, obj_type.methods[methodId].param_types):
+ if actual_type != expected_type and \
+ str(actual_type["interface"]) != str(expected_type):
+ self.error("Type mismatch: expected: %s actual: %s",
+ expected_type, actual_type)
# Return the return type of the method
return obj_type.methods[methodId].return_type
@@ -66,9 +78,10 @@ class MethodCallExprAST(ExprAST):
pass
class MemberMethodCallExprAST(MethodCallExprAST):
- def __init__(self, slicc, obj_expr_ast, func_call):
+ def __init__(self, slicc, obj_expr_ast, proc_name, expr_ast_vec):
s = super(MemberMethodCallExprAST, self)
- s.__init__(slicc, func_call.proc_name, func_call.exprs)
+ s.__init__(slicc, proc_name, expr_ast_vec)
+
self.obj_expr_ast = obj_expr_ast
def __repr__(self):
diff --git a/src/mem/slicc/ast/StateDeclAST.py b/src/mem/slicc/ast/StateDeclAST.py
index a33ea9245..f0a0b97d3 100644
--- a/src/mem/slicc/ast/StateDeclAST.py
+++ b/src/mem/slicc/ast/StateDeclAST.py
@@ -66,7 +66,7 @@ class StateDeclAST(DeclAST):
pairs = { "external" : "yes" }
func = Func(self.symtab, func_id + "_" +
t.ident, func_id, self.location,
- self.symtab.find("std::string", Type), [ t ], [], [], "",
+ self.symtab.find("std::string", Type), [ t ], [], "",
pairs)
self.symtab.newSymbol(func)
@@ -76,6 +76,6 @@ class StateDeclAST(DeclAST):
pairs = { "external" : "yes" }
func = Func(self.symtab, func_id + "_" +
t.ident, func_id, self.location,
- self.symtab.find("AccessPermission", Type), [ t ], [], [], "",
+ self.symtab.find("AccessPermission", Type), [ t ], [], "",
pairs)
self.symtab.newSymbol(func)
diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py
index 07c067f68..0cbe9ea63 100644
--- a/src/mem/slicc/parser.py
+++ b/src/mem/slicc/parser.py
@@ -669,13 +669,15 @@ class SLICC(Grammar):
def p_expr__member_method_call(self, p):
"aexpr : aexpr DOT ident '(' exprs ')'"
- p[0] = ast.MemberMethodCallExprAST(self, p[1],
- ast.FuncCallExprAST(self, p[3], p[5]))
+ p[0] = ast.MemberMethodCallExprAST(self, p[1], p[3], p[5])
+
+ def p_expr__member_method_call_lookup(self, p):
+ "aexpr : aexpr '[' exprs ']'"
+ p[0] = ast.MemberMethodCallExprAST(self, p[1], "lookup", p[3])
def p_expr__class_method_call(self, p):
"aexpr : type DOUBLE_COLON ident '(' exprs ')'"
- p[0] = ast.ClassMethodCallExprAST(self, p[1],
- ast.FuncCallExprAST(self, p[3], p[5]))
+ p[0] = ast.ClassMethodCallExprAST(self, p[1], p[3], p[5])
def p_expr__aexpr(self, p):
"expr : aexpr"
diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py
index 695450b9c..d50d0309f 100644
--- a/src/mem/slicc/symbols/Func.py
+++ b/src/mem/slicc/symbols/Func.py
@@ -30,19 +30,16 @@ from slicc.symbols.Type import Type
class Func(Symbol):
def __init__(self, table, ident, name, location, return_type, param_types,
- proto_param_strings, body_param_strings, body,
- pairs, default_count = 0):
+ param_strings, body, pairs):
super(Func, self).__init__(table, ident, location, pairs)
self.return_type = return_type
self.param_types = param_types
- self.proto_param_strings = proto_param_strings
- self.body_param_strings = body_param_strings
+ self.param_strings = param_strings
self.body = body
self.isInternalMachineFunc = False
self.c_ident = ident
self.c_name = name
self.class_name = ""
- self.default_count = default_count
def __repr__(self):
return ""
@@ -60,33 +57,11 @@ class Func(Symbol):
return_type += "*"
return "%s %s(%s);" % (return_type, self.c_name,
- ", ".join(self.proto_param_strings))
+ ", ".join(self.param_strings))
def writeCodeFiles(self, path, includes):
return
- def checkArguments(self, args):
- if len(args) + self.default_count < len(self.param_types) or \
- len(args) > len(self.param_types):
- self.error("Wrong number of arguments passed to function: '%s'" + \
- " Expected at least: %d, got: %d", self.c_ident,
- len(self.param_types) - self.default_count, len(args))
-
- cvec = []
- type_vec = []
- for expr,expected_type in zip(args, self.param_types):
- # Check the types of the parameter
- actual_type,param_code = expr.inline(True)
- if str(actual_type) != 'OOD' and \
- str(actual_type) != str(expected_type) and \
- str(actual_type["interface"]) != str(expected_type):
- expr.error("Type mismatch: expected: %s actual: %s" % \
- (expected_type, actual_type))
- cvec.append(param_code)
- type_vec.append(expected_type)
-
- return cvec, type_vec
-
def generateCode(self):
'''This write a function of object Chip'''
if "external" in self:
@@ -95,14 +70,14 @@ class Func(Symbol):
code = self.symtab.codeFormatter()
# Generate function header
- return_type = self.return_type.c_ident
void_type = self.symtab.find("void", Type)
+ return_type = self.return_type.c_ident
if "return_by_ref" in self and self.return_type != void_type:
return_type += "&"
if "return_by_pointer" in self and self.return_type != void_type:
return_type += "*"
- params = ', '.join(self.body_param_strings)
+ params = ', '.join(self.param_strings)
code('''
$return_type
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 3dce3c3f2..03c78c8bf 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -320,9 +320,9 @@ class $c_ident : public AbstractController
void countTransition(${ident}_State state, ${ident}_Event event);
void possibleTransition(${ident}_State state, ${ident}_Event event);
- uint64_t getEventCount(${ident}_Event event);
+ uint64 getEventCount(${ident}_Event event);
bool isPossible(${ident}_State state, ${ident}_Event event);
- uint64_t getTransitionCount(${ident}_State state, ${ident}_Event event);
+ uint64 getTransitionCount(${ident}_State state, ${ident}_Event event);
private:
''')
@@ -802,7 +802,7 @@ $c_ident::possibleTransition(${ident}_State state,
m_possible[state][event] = true;
}
-uint64_t
+uint64
$c_ident::getEventCount(${ident}_Event event)
{
return m_event_counters[event];
@@ -814,7 +814,7 @@ $c_ident::isPossible(${ident}_State state, ${ident}_Event event)
return m_possible[state][event];
}
-uint64_t
+uint64
$c_ident::getTransitionCount(${ident}_State state,
${ident}_Event event)
{
@@ -1213,6 +1213,8 @@ TransitionResult result =
else:
code('doTransitionWorker(event, state, next_state, addr);')
+ port_to_buf_map, in_msg_bufs, msg_bufs = self.getBufferMaps(ident)
+
code('''
if (result == TransitionResult_Valid) {