Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/58434 )

Change subject: mem-ruby: Rename SLICC SimObjs with compatibility
......................................................................

mem-ruby: Rename SLICC SimObjs with compatibility

Rename all SLICC generated SimObjects to have the protocol in their
name. This will allow for two different protocols to have the same
machine names (e.g., L1Cache). For compatiblity, we check to see if the
current protocol that is built matches the SimObject's protocol and
export the backwards-compatible name.

Change-Id: I2f1b2a541778de5b6316348386927141485c19b6
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
---
M src/mem/ruby/protocol/SConscript
M src/mem/slicc/ast/MachineAST.py
M src/mem/slicc/symbols/StateMachine.py
3 files changed, 50 insertions(+), 8 deletions(-)



diff --git a/src/mem/ruby/protocol/SConscript b/src/mem/ruby/protocol/SConscript
index 62e3e10..162c0db 100644
--- a/src/mem/ruby/protocol/SConscript
+++ b/src/mem/ruby/protocol/SConscript
@@ -124,7 +124,7 @@
     elif s.endswith('.py'):
         filename = os.path.basename(s)
# We currently only expect ${ident}_Controller.py to be generated, and
-        # for it to contain a single SimObject with the same name.
+ # for it to contain a single SimObject with the same name + protocol.
         assert(filename.endswith('_Controller.py'))
-        SimObject(f, sim_objects=[os.path.splitext(filename)[0]])
+ SimObject(f, sim_objects=[protocol+'_'+os.path.splitext(filename)[0]])

diff --git a/src/mem/slicc/ast/MachineAST.py b/src/mem/slicc/ast/MachineAST.py
index 4114f01..17116da 100644
--- a/src/mem/slicc/ast/MachineAST.py
+++ b/src/mem/slicc/ast/MachineAST.py
@@ -43,9 +43,15 @@
     def files(self, parent=None):
         import os
         file_prefix = os.path.join(self.slicc.protocol, self.ident)
+        # Can't have multiple python simobject files with the same name
+        # So, we have to prepend the protocol name to the .py file
+        py_prefix = os.path.join(
+            self.slicc.protocol,
+            self.slicc.protocol + '_' + self.ident
+        )
         s = set(('%s_Controller.cc' % file_prefix,
                  '%s_Controller.hh' % file_prefix,
-                 '%s_Controller.py' % file_prefix,
+                 '%s_Controller.py' % py_prefix,
                  '%s_Transitions.cc' % file_prefix,
                  '%s_Wakeup.cc' % file_prefix))

diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 2540b0d..3ef6b5b 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -236,7 +236,7 @@
         ident = self.ident

         protocol = self.symtab.slicc.protocol
-        py_ident = "%s_Controller" % ident
+        py_ident = f"{protocol}_{ident}_Controller"
         c_ident = "%s_Controller" % self.ident
         gen_filename = f"{protocol}/{py_ident}"

@@ -267,6 +267,23 @@
"in StateMachine.py", param.type_ast.type.c_ident)

         code.dedent()
+
+ # Needed for backwards compatibility while there is only one protocol + # compiled. When moving to multiple protocols in the gem5 binary, this
+        # will need to change.
+        code('''
+
+from m5.defines import buildEnv
+from m5.util import warn
+
+if getRubyProtocol() == "${protocol}":
+    warn(
+        "${c_indent} is deprecated. Use %s_${c_indent} instead",
+        getRubyProtocol()
+    )
+    ${c_ident} = ${py_ident}
+''')
+
         code.write(path, '%s.py' % gen_filename)


@@ -275,8 +292,11 @@
         code = self.symtab.codeFormatter()
         ident = self.ident
         c_ident = "%s_Controller" % self.ident
-        header_string = self.symtab.slicc.protocol + '_' + self.ident
-        gen_filename = f"{self.symtab.slicc.protocol}/{c_ident}"
+
+        protocol = self.symtab.slicc.protocol
+        header_string = protocol + '_' + self.ident
+        gen_filename = f"{protocol}/{c_ident}"
+        py_ident = f"{protocol}_{ident}_Controller"

         code('''
 // Created by slicc definition of Module "${{self.short}}"
@@ -292,7 +312,7 @@
 #include "mem/ruby/protocol/TransitionResult.hh"
 #include "mem/ruby/protocol/${protocol}/Types.hh"
 #include "mem/ruby/slicc_interface/AbstractController.hh"
-#include "params/$c_ident.hh"
+#include "params/$py_ident.hh"

 ''')

@@ -325,7 +345,7 @@
 class $c_ident : public AbstractController
 {
   public:
-    typedef ${c_ident}Params Params;
+    typedef ${py_ident}Params Params;
     $c_ident(const Params &p);
     static int getNumControllers();
     void init();

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58434
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2f1b2a541778de5b6316348386927141485c19b6
Gerrit-Change-Number: 58434
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to