SLICC: Put functions of a controller in its .cc file
authorNilay Vaish <nilay@cs.wisc.edu>
Thu, 28 Jul 2011 01:20:53 +0000 (20:20 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Thu, 28 Jul 2011 01:20:53 +0000 (20:20 -0500)
Currently, functions associated with a controller go into separate files.
This patch puts all the functions in the controller's .cc file. This should
hopefully take away some time from compilation.

src/mem/slicc/ast/FuncDeclAST.py
src/mem/slicc/symbols/Func.py
src/mem/slicc/symbols/StateMachine.py

index a87d61119efc24de4750ec6d3bb0551fd0fd500a..54b0f2c5951339faeb89e53397c976602d14340b 100644 (file)
@@ -41,14 +41,7 @@ class FuncDeclAST(DeclAST):
         return "[FuncDecl: %s]" % self.ident
 
     def files(self, parent=None):
-        if "external" in self or self.statements is None:
-            return set()
-
-        if parent:
-            ident = "%s_%s" % (parent, self.ident)
-        else:
-            ident = self.ident
-        return set(("%s.cc" % ident,))
+        return set()
 
     def generate(self):
         types = []
index f0b92cdc984e6ac2e7085873eef9e7ab2248992a..771144efd8e965dd08d5f800aab371fb6bf91535 100644 (file)
@@ -64,24 +64,15 @@ class Func(Symbol):
                                ", ".join(self.param_strings))
 
     def writeCodeFiles(self, path):
+        return
+
+    def generateCode(self):
         '''This write a function of object Chip'''
         if "external" in self:
-            return
+            return ""
 
         code = self.symtab.codeFormatter()
 
-        # Header
-        code('''
-/** Auto generated C++ code started by $__file__:$__line__ */
-
-#include "debug/RubySlicc.hh"
-#include "mem/protocol/Types.hh"
-''')
-
-        if self.isInternalMachineFunc:
-            code('#include "mem/protocol/${{self.machineStr}}_Controller.hh"')
-
-        code('using namespace std;')
         # Generate function header
         void_type = self.symtab.find("void", Type)
         return_type = self.return_type.c_ident
@@ -104,9 +95,6 @@ ${klass}::${{self.c_ident}}($params)
 ${{self.body}}
 }
 ''')
-        if self.isInternalMachineFunc:
-            code.write(path, "%s_%s.cc" % (self.machineStr,self.c_ident))
-        else:
-            code.write(path, "%s.cc" % self.c_ident)
+        return str(code)
 
 __all__ = [ "Func" ]
index a3a95002d8208f493435a379e4456205e92e1561..42249ab7a08c6187770c808dfc94fe8affbee388 100644 (file)
@@ -168,9 +168,6 @@ class StateMachine(Symbol):
         self.printProfileDumperCC(path)
         self.printProfileDumperHH(path)
 
-        for func in self.functions:
-            func.writeCodeFiles(path)
-
     def printControllerPython(self, path):
         code = self.symtab.codeFormatter()
         ident = self.ident
@@ -945,6 +942,9 @@ $c_ident::${{action.ident}}(const Address& addr)
 }
 
 ''')
+        for func in self.functions:
+            code(func.generateCode())
+
         code.write(path, "%s.cc" % c_ident)
 
     def printCWakeup(self, path):