summaryrefslogtreecommitdiff
path: root/src/mem/slicc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/slicc')
-rw-r--r--src/mem/slicc/ast/FormalParamAST.py1
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.py3
-rw-r--r--src/mem/slicc/ast/StallAndWaitStatementAST.py2
-rw-r--r--src/mem/slicc/parser.py30
-rw-r--r--src/mem/slicc/symbols/StateMachine.py35
5 files changed, 45 insertions, 26 deletions
diff --git a/src/mem/slicc/ast/FormalParamAST.py b/src/mem/slicc/ast/FormalParamAST.py
index 6ed5bca0a..ce73304f1 100644
--- a/src/mem/slicc/ast/FormalParamAST.py
+++ b/src/mem/slicc/ast/FormalParamAST.py
@@ -51,6 +51,7 @@ class FormalParamAST(AST):
v = Var(self.symtab, self.ident, self.location, type, param,
self.pairs)
self.symtab.newSymbol(v)
+
if self.pointer or str(type) == "TBE" or (
"interface" in type and (
type["interface"] == "AbstractCacheEntry" or
diff --git a/src/mem/slicc/ast/ObjDeclAST.py b/src/mem/slicc/ast/ObjDeclAST.py
index ffd71bbb1..92ff15d52 100644
--- a/src/mem/slicc/ast/ObjDeclAST.py
+++ b/src/mem/slicc/ast/ObjDeclAST.py
@@ -29,12 +29,13 @@ from slicc.ast.DeclAST import DeclAST
from slicc.symbols import Var
class ObjDeclAST(DeclAST):
- def __init__(self, slicc, type_ast, ident, pairs, rvalue):
+ def __init__(self, slicc, type_ast, ident, pairs, rvalue, pointer):
super(ObjDeclAST, self).__init__(slicc, pairs)
self.type_ast = type_ast
self.ident = ident
self.rvalue = rvalue
+ self.pointer = pointer
def __repr__(self):
return "[ObjDecl: %r]" % self.ident
diff --git a/src/mem/slicc/ast/StallAndWaitStatementAST.py b/src/mem/slicc/ast/StallAndWaitStatementAST.py
index b87726c6a..08b0e340c 100644
--- a/src/mem/slicc/ast/StallAndWaitStatementAST.py
+++ b/src/mem/slicc/ast/StallAndWaitStatementAST.py
@@ -35,7 +35,7 @@ class StallAndWaitStatementAST(StatementAST):
self.address = address
def __repr__(self):
- return "[StallAndWaitStatementAst: %r]" % self.variable
+ return "[StallAndWaitStatementAst: %r]" % self.in_port
def generate(self, code, return_type):
self.in_port.assertType("InPort")
diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py
index 04ba4640c..10dd99ece 100644
--- a/src/mem/slicc/parser.py
+++ b/src/mem/slicc/parser.py
@@ -258,11 +258,11 @@ class SLICC(Grammar):
p[0] = self.parse_file(filename)
def p_decl__machine0(self, p):
- "decl : MACHINE '(' idents ')' ':' params '{' decls '}'"
+ "decl : MACHINE '(' idents ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], [], p[7], p[9])
def p_decl__machine1(self, p):
- "decl : MACHINE '(' idents pairs ')' ':' params '{' decls '}'"
+ "decl : MACHINE '(' idents pairs ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9])
def p_decl__action(self, p):
@@ -319,6 +319,14 @@ class SLICC(Grammar):
p[0] = ast.StateDeclAST(self, p[3], p[4], p[7])
# Type fields
+ def p_obj_decls__list(self, p):
+ "obj_decls : obj_decl obj_decls"
+ p[0] = [ p[1] ] + p[2]
+
+ def p_obj_decls__empty(self, p):
+ "obj_decls : empty"
+ p[0] = []
+
def p_type_members__list(self, p):
"type_members : type_member type_members"
p[0] = [ p[1] ] + p[2]
@@ -340,19 +348,21 @@ class SLICC(Grammar):
def p_obj_decl__0(self, p):
"obj_decl : type ident pairs SEMI"
- p[0] = ast.ObjDeclAST(self, p[1], p[2], p[3], None)
+ p[0] = ast.ObjDeclAST(self, p[1], p[2], p[3], None, False)
def p_obj_decl__1(self, p):
"obj_decl : type STAR ident pairs SEMI"
- p[0] = ast.ObjDeclAST(self, p[1], p[3], p[4], None)
+ p[0] = ast.ObjDeclAST(self, p[1], p[3], p[4], None, True)
def p_obj_decl__2(self, p):
"obj_decl : type ident ASSIGN expr SEMI"
- p[0] = ast.ObjDeclAST(self, p[1], p[2], ast.PairListAST(self), p[4])
+ p[0] = ast.ObjDeclAST(self, p[1], p[2], ast.PairListAST(self), p[4],
+ False)
def p_obj_decl__3(self, p):
"obj_decl : type STAR ident ASSIGN expr SEMI"
- p[0] = ast.ObjDeclAST(self, p[1], p[3], ast.PairListAST(self), p[5])
+ p[0] = ast.ObjDeclAST(self, p[1], p[3], ast.PairListAST(self), p[5],
+ True)
# Function definition and declaration
def p_decl__func_decl(self, p):
@@ -426,19 +436,19 @@ class SLICC(Grammar):
p[0] = ast.FormalParamAST(self, p[1], p[3], None, True)
def p_param__pointer_default(self, p):
- "param : type STAR ident '=' STRING"
+ "param : type STAR ident ASSIGN STRING"
p[0] = ast.FormalParamAST(self, p[1], p[3], p[5], True)
def p_param__default_number(self, p):
- "param : type ident '=' NUMBER"
+ "param : type ident ASSIGN NUMBER"
p[0] = ast.FormalParamAST(self, p[1], p[2], p[4])
def p_param__default_bool(self, p):
- "param : type ident '=' LIT_BOOL"
+ "param : type ident ASSIGN LIT_BOOL"
p[0] = ast.FormalParamAST(self, p[1], p[2], p[4])
def p_param__default_string(self, p):
- "param : type ident '=' STRING"
+ "param : type ident ASSIGN STRING"
p[0] = ast.FormalParamAST(self, p[1], p[2], p[4])
# Type
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 2cda3a49d..71fcc053f 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -56,12 +56,14 @@ class StateMachine(Symbol):
for param in config_parameters:
if param.pointer:
- var = Var(symtab, param.name, location, param.type_ast.type,
- "(*m_%s_ptr)" % param.name, {}, self)
+ var = Var(symtab, param.ident, location, param.type_ast.type,
+ "(*m_%s_ptr)" % param.ident, {}, self)
else:
- var = Var(symtab, param.name, location, param.type_ast.type,
- "m_%s" % param.name, {}, self)
- self.symtab.registerSym(param.name, var)
+ var = Var(symtab, param.ident, location, param.type_ast.type,
+ "m_%s" % param.ident, {}, self)
+
+ self.symtab.registerSym(param.ident, var)
+
if str(param.type_ast.type) == "Prefetcher":
self.prefetchers.append(var)
@@ -178,8 +180,10 @@ class StateMachine(Symbol):
def printControllerPython(self, path):
code = self.symtab.codeFormatter()
ident = self.ident
+
py_ident = "%s_Controller" % ident
c_ident = "%s_Controller" % self.ident
+
code('''
from m5.params import *
from m5.SimObject import SimObject
@@ -192,11 +196,14 @@ class $py_ident(RubyController):
code.indent()
for param in self.config_parameters:
dflt_str = ''
- if param.default is not None:
- dflt_str = str(param.default) + ', '
+
+ if param.rvalue is not None:
+ dflt_str = str(param.rvalue.inline()) + ', '
+
if python_class_map.has_key(param.type_ast.type.c_ident):
python_type = python_class_map[param.type_ast.type.c_ident]
- code('${{param.name}} = Param.${{python_type}}(${dflt_str}"")')
+ code('${{param.ident}} = Param.${{python_type}}(${dflt_str}"")')
+
else:
self.error("Unknown c++ to python class conversion for c++ " \
"type: '%s'. Please update the python_class_map " \
@@ -480,11 +487,11 @@ $c_ident::$c_ident(const Params *p)
#
for param in self.config_parameters:
if param.pointer:
- code('m_${{param.name}}_ptr = p->${{param.name}};')
+ code('m_${{param.ident}}_ptr = p->${{param.ident}};')
else:
- code('m_${{param.name}} = p->${{param.name}};')
- if re.compile("sequencer").search(param.name):
- code('m_${{param.name}}_ptr->setController(this);')
+ code('m_${{param.ident}} = p->${{param.ident}};')
+ if re.compile("sequencer").search(param.ident):
+ code('m_${{param.ident}}_ptr->setController(this);')
for var in self.objects:
if var.ident.find("mandatoryQueue") >= 0:
@@ -679,9 +686,9 @@ $vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{v
seq_ident = "NULL"
for param in self.config_parameters:
- if param.name == "sequencer":
+ if param.ident == "sequencer":
assert(param.pointer)
- seq_ident = "m_%s_ptr" % param.name
+ seq_ident = "m_%s_ptr" % param.ident
code('''