ruby: slicc: remove support for single machine, multiple types

This patch is imported from reviewboard patch 2550 by Nilay.
It was possible to specify multiple machine types with a single state machine.
This seems unnecessary and is being removed.
This commit is contained in:
Tony Gutierrez 2015-07-20 09:15:18 -05:00
parent 3840a72f37
commit 3f68884c0e
3 changed files with 11 additions and 18 deletions

View file

@ -33,7 +33,7 @@
* Brad Beckmann * Brad Beckmann
*/ */
machine({L1Cache, L2Cache}, "AMD Hammer-like protocol") machine(L1Cache, "AMD Hammer-like protocol")
: Sequencer * sequencer; : Sequencer * sequencer;
CacheMemory * L1Icache; CacheMemory * L1Icache;
CacheMemory * L1Dcache; CacheMemory * L1Dcache;

View file

@ -29,11 +29,10 @@ from slicc.ast.DeclAST import DeclAST
from slicc.symbols import StateMachine, Type from slicc.symbols import StateMachine, Type
class MachineAST(DeclAST): class MachineAST(DeclAST):
def __init__(self, slicc, idents, pairs_ast, config_parameters, decls): def __init__(self, slicc, ident, pairs_ast, config_parameters, decls):
super(MachineAST, self).__init__(slicc, pairs_ast) super(MachineAST, self).__init__(slicc, pairs_ast)
self.ident = idents[0] self.ident = ident
self.machine_types = idents
self.pairs_ast = pairs_ast self.pairs_ast = pairs_ast
self.config_parameters = config_parameters self.config_parameters = config_parameters
self.decls = decls self.decls = decls
@ -71,19 +70,13 @@ class MachineAST(DeclAST):
self.symtab.popFrame() self.symtab.popFrame()
def findMachines(self): def findMachines(self):
# Add to MachineType enumeration mtype = self.ident
for mtype in self.machine_types: machine_type = self.symtab.find("MachineType", Type)
machine_type = self.symtab.find("MachineType", Type) pairs = self.pairs_ast.pairs
pairs = self.pairs_ast.pairs
if mtype == self.ident: pairs["Primary"] = True
pairs["Primary"] = True if not machine_type.addEnum(mtype, pairs):
else: self.error("Duplicate machine name: %s:%s" % (machine_type, mtype))
pairs["Primary"] = False
if not machine_type.addEnum(mtype, pairs):
self.error("Duplicate machine name: %s:%s" % (
machine_type, mtype))
# Generate code for all the internal decls # Generate code for all the internal decls
self.decls.findMachines() self.decls.findMachines()

View file

@ -259,11 +259,11 @@ class SLICC(Grammar):
p[0] = self.parse_file(filename) p[0] = self.parse_file(filename)
def p_decl__machine0(self, p): def p_decl__machine0(self, p):
"decl : MACHINE '(' idents ')' ':' obj_decls '{' decls '}'" "decl : MACHINE '(' ident ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], [], p[7], p[9]) p[0] = ast.MachineAST(self, p[3], [], p[7], p[9])
def p_decl__machine1(self, p): def p_decl__machine1(self, p):
"decl : MACHINE '(' idents pairs ')' ':' obj_decls '{' decls '}'" "decl : MACHINE '(' ident pairs ')' ':' obj_decls '{' decls '}'"
p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9]) p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9])
def p_decl__action(self, p): def p_decl__action(self, p):