SLICC: Remove machine name as prefix to functions

Currently, the machine name is appended before any of the functions
defined with in the sm files. This is not necessary and it also
means that these functions cannot be used outside the sm files.
This patch does away with the prefixes. Note that the generated
C++ files in which the code for these functions is present are
still named such that the machine name is the prefix.
This commit is contained in:
Nilay Vaish 2011-06-03 13:52:18 -05:00
parent 5a78c2d001
commit 3a083edc30
2 changed files with 15 additions and 15 deletions

View file

@ -37,15 +37,12 @@ class Func(Symbol):
self.param_strings = param_strings self.param_strings = param_strings
self.body = body self.body = body
self.isInternalMachineFunc = False self.isInternalMachineFunc = False
self.c_ident = ident
if machine is None: if machine is None or "external" in self or "primitive" in self:
self.c_ident = ident pass
elif "external" in self or "primitive" in self:
self.c_ident = ident
else: else:
self.machineStr = str(machine) self.machineStr = str(machine)
# Append with machine name
self.c_ident = "%s_%s" % (self.machineStr, ident)
self.isInternalMachineFunc = True self.isInternalMachineFunc = True
def __repr__(self): def __repr__(self):
@ -107,6 +104,9 @@ ${klass}::${{self.c_ident}}($params)
${{self.body}} ${{self.body}}
} }
''') ''')
code.write(path, "%s.cc" % self.c_ident) if self.isInternalMachineFunc:
code.write(path, "%s_%s.cc" % (self.machineStr,self.c_ident))
else:
code.write(path, "%s.cc" % self.c_ident)
__all__ = [ "Func" ] __all__ = [ "Func" ]

View file

@ -1071,13 +1071,13 @@ ${ident}_Controller::doTransition(${ident}_Event event,
{ {
''') ''')
if self.TBEType != None and self.EntryType != None: if self.TBEType != None and self.EntryType != None:
code('${ident}_State state = ${ident}_getState(m_tbe_ptr, m_cache_entry_ptr, addr);') code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);')
elif self.TBEType != None: elif self.TBEType != None:
code('${ident}_State state = ${ident}_getState(m_tbe_ptr, addr);') code('${ident}_State state = getState(m_tbe_ptr, addr);')
elif self.EntryType != None: elif self.EntryType != None:
code('${ident}_State state = ${ident}_getState(m_cache_entry_ptr, addr);') code('${ident}_State state = getState(m_cache_entry_ptr, addr);')
else: else:
code('${ident}_State state = ${ident}_getState(addr);') code('${ident}_State state = getState(addr);')
code(''' code('''
${ident}_State next_state = state; ${ident}_State next_state = state;
@ -1115,15 +1115,15 @@ ${ident}_Controller::doTransition(${ident}_Event event,
CLEAR_TRANSITION_COMMENT(); CLEAR_TRANSITION_COMMENT();
''') ''')
if self.TBEType != None and self.EntryType != None: if self.TBEType != None and self.EntryType != None:
code('${ident}_setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);') code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);')
code('set_permission(m_cache_entry_ptr, ${ident}_State_to_permission(next_state));') code('set_permission(m_cache_entry_ptr, ${ident}_State_to_permission(next_state));')
elif self.TBEType != None: elif self.TBEType != None:
code('${ident}_setState(m_tbe_ptr, addr, next_state);') code('setState(m_tbe_ptr, addr, next_state);')
elif self.EntryType != None: elif self.EntryType != None:
code('${ident}_setState(m_cache_entry_ptr, addr, next_state);') code('setState(m_cache_entry_ptr, addr, next_state);')
code('set_permission(m_cache_entry_ptr, ${ident}_State_to_permission(next_state));') code('set_permission(m_cache_entry_ptr, ${ident}_State_to_permission(next_state));')
else: else:
code('${ident}_setState(addr, next_state);') code('setState(addr, next_state);')
code(''' code('''
} else if (result == TransitionResult_ResourceStall) { } else if (result == TransitionResult_ResourceStall) {