From aa8bcd15ec1ba916f3e750f41697a65e06b3c2ac Mon Sep 17 00:00:00 2001 From: Jason Power Date: Wed, 12 Sep 2012 14:52:04 -0500 Subject: Ruby: Modify Scons so that we can put .sm files in extras Also allows for header files which are required in slicc generated code to be in a directory other than src/mem/ruby/slicc_interface. --- src/mem/slicc/symbols/Func.py | 2 +- src/mem/slicc/symbols/StateMachine.py | 24 +++++++++++++++++------- src/mem/slicc/symbols/SymbolTable.py | 12 ++++++------ src/mem/slicc/symbols/Type.py | 2 +- src/mem/slicc/symbols/Var.py | 2 +- 5 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/mem/slicc/symbols') diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py index 771144efd..ebbc5fe14 100644 --- a/src/mem/slicc/symbols/Func.py +++ b/src/mem/slicc/symbols/Func.py @@ -63,7 +63,7 @@ class Func(Symbol): return "%s %s(%s);" % (return_type, self.c_ident, ", ".join(self.param_strings)) - def writeCodeFiles(self, path): + def writeCodeFiles(self, path, includes): return def generateCode(self): diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py index 83ad88e8b..47f7daa00 100644 --- a/src/mem/slicc/symbols/StateMachine.py +++ b/src/mem/slicc/symbols/StateMachine.py @@ -162,12 +162,12 @@ class StateMachine(Symbol): action.warning(error_msg) self.table = table - def writeCodeFiles(self, path): + def writeCodeFiles(self, path, includes): self.printControllerPython(path) self.printControllerHH(path) - self.printControllerCC(path) + self.printControllerCC(path, includes) self.printCSwitch(path) - self.printCWakeup(path) + self.printCWakeup(path, includes) self.printProfilerCC(path) self.printProfilerHH(path) self.printProfileDumperCC(path) @@ -399,7 +399,7 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr); code('#endif // __${ident}_CONTROLLER_H__') code.write(path, '%s.hh' % c_ident) - def printControllerCC(self, path): + def printControllerCC(self, path, includes): '''Output the actions for performing the actions''' code = self.symtab.codeFormatter() @@ -429,8 +429,12 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr); #include "mem/protocol/${ident}_State.hh" #include "mem/protocol/Types.hh" #include "mem/ruby/common/Global.hh" -#include "mem/ruby/slicc_interface/RubySlicc_includes.hh" #include "mem/ruby/system/System.hh" +''') + for include_path in includes: + code('#include "${{include_path}}"') + + code(''' using namespace std; ''') @@ -988,7 +992,7 @@ $c_ident::${{action.ident}}(const Address& addr) code.write(path, "%s.cc" % c_ident) - def printCWakeup(self, path): + def printCWakeup(self, path, includes): '''Output the wakeup loop for the events''' code = self.symtab.codeFormatter() @@ -1020,8 +1024,14 @@ $c_ident::${{action.ident}}(const Address& addr) code(''' #include "mem/protocol/Types.hh" #include "mem/ruby/common/Global.hh" -#include "mem/ruby/slicc_interface/RubySlicc_includes.hh" #include "mem/ruby/system/System.hh" +''') + + + for include_path in includes: + code('#include "${{include_path}}"') + + code(''' using namespace std; diff --git a/src/mem/slicc/symbols/SymbolTable.py b/src/mem/slicc/symbols/SymbolTable.py index 81d0768f9..d2c9337f1 100644 --- a/src/mem/slicc/symbols/SymbolTable.py +++ b/src/mem/slicc/symbols/SymbolTable.py @@ -124,15 +124,15 @@ class SymbolTable(object): if isinstance(symbol, type): yield symbol - def writeCodeFiles(self, path): + def writeCodeFiles(self, path, includes): makeDir(path) code = self.codeFormatter() - code(''' -/** Auto generated C++ code started by $__file__:$__line__ */ + code('/** Auto generated C++ code started by $__file__:$__line__ */') + + for include_path in includes: + code('#include "${{include_path}}"') -#include "mem/ruby/slicc_interface/RubySlicc_includes.hh" -''') for symbol in self.sym_vec: if isinstance(symbol, Type) and not symbol.isPrimitive: code('#include "mem/protocol/${{symbol.c_ident}}.hh"') @@ -140,7 +140,7 @@ class SymbolTable(object): code.write(path, "Types.hh") for symbol in self.sym_vec: - symbol.writeCodeFiles(path) + symbol.writeCodeFiles(path, includes) def writeHTMLFiles(self, path): makeDir(path) diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py index 3285b767f..aec05a678 100644 --- a/src/mem/slicc/symbols/Type.py +++ b/src/mem/slicc/symbols/Type.py @@ -184,7 +184,7 @@ class Type(Symbol): return True - def writeCodeFiles(self, path): + def writeCodeFiles(self, path, includes): if self.isExternal: # Do nothing pass diff --git a/src/mem/slicc/symbols/Var.py b/src/mem/slicc/symbols/Var.py index 87a101f65..e16199a1e 100644 --- a/src/mem/slicc/symbols/Var.py +++ b/src/mem/slicc/symbols/Var.py @@ -44,7 +44,7 @@ class Var(Symbol): def __repr__(self): return "[Var id: %s]" % (self.c_ident) - def writeCodeFiles(self, path): + def writeCodeFiles(self, path, includes): pass __all__ = [ "Var" ] -- cgit v1.2.3