Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/56469 )

Change subject: arch-x86: Add an arch/x86 subpackage to the ucasmlib namespace.
......................................................................

arch-x86: Add an arch/x86 subpackage to the ucasmlib namespace.

This currently only has the ROM class specialization for x86.

Change-Id: Ic9e071109fa5b4d2f0e29502b7811ef777c0c4af
---
M src/arch/x86/isa/microasm.isa
D src/arch/x86/isa/rom.isa
A src/arch/x86/ucasmlib/arch/x86/__init__.py
A src/arch/x86/ucasmlib/arch/x86/rom.py
4 files changed, 92 insertions(+), 55 deletions(-)



diff --git a/src/arch/x86/isa/microasm.isa b/src/arch/x86/isa/microasm.isa
index ec9ed5a..5293410 100644
--- a/src/arch/x86/isa/microasm.isa
+++ b/src/arch/x86/isa/microasm.isa
@@ -44,16 +44,18 @@
 //Include code to build macroops in both C++ and python.
 ##include "macroop.isa"

-//Include code to fill out the microcode ROM in both C++ and python.
-##include "rom.isa"
-
 let {{
     import sys
+
+    old_path = sys.path
     sys.path[0:0] = ["src/arch/x86/isa/"]
     from insts import microcode
-    # print microcode
+    sys.path[0:0] = ["src/arch/x86/"]
     from ucasmlib.assembler import MicroAssembler
-    mainRom = X86MicrocodeRom('main ROM')
+    from ucasmlib.arch.x86 import Rom
+    sys.path = old_path
+
+    mainRom = Rom('main ROM')
     assembler = MicroAssembler(X86Macroop, microopClasses, mainRom)

     def gpRegIdx(idx):
diff --git a/src/arch/x86/isa/rom.isa b/src/arch/x86/isa/rom.isa
deleted file mode 100644
index 58fd83c..0000000
--- a/src/arch/x86/isa/rom.isa
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2008 The Regents of The University of Michigan
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met: redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer;
-// redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution;
-// neither the name of the copyright holders nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-let {{
-    from ucasmlib.containers import Rom
-
-    class X86MicrocodeRom(Rom):
-        def getDeclaration(self):
-            declareLabels = "namespace rom_labels\n{\n"
-            for (label, micropc) in self.labels.items():
-                declareLabels += "const static uint64_t label_%s = %d;\n" \
-                                  % (label, micropc)
-            for (label, micropc) in self.externs.items():
-                declareLabels += \
-                    "const static MicroPC extern_label_%s = %d;\n" \
-                        % (label, micropc)
-            declareLabels += "}\n"
-            return declareLabels;
-
-        def getDefinition(self):
-            elements = map(lambda op: op.getGenerator(), self.microops)
-            allocator = "{" + ',\n'.join(elements) + "}"
-
-            return '''
-    X86ISA::MicrocodeRom::MicrocodeRom() : genFuncs(%s) {}
-    ''' % allocator
-}};
diff --git a/src/arch/x86/ucasmlib/arch/x86/__init__.py b/src/arch/x86/ucasmlib/arch/x86/__init__.py
new file mode 100644
index 0000000..6a1bdd7
--- /dev/null
+++ b/src/arch/x86/ucasmlib/arch/x86/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2022 Google, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from .rom import Rom
diff --git a/src/arch/x86/ucasmlib/arch/x86/rom.py b/src/arch/x86/ucasmlib/arch/x86/rom.py
new file mode 100644
index 0000000..d24b9ac
--- /dev/null
+++ b/src/arch/x86/ucasmlib/arch/x86/rom.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2008 The Regents of The University of Michigan
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import ucasmlib.containers
+
+class Rom(ucasmlib.containers.Rom):
+    def getDeclaration(self):
+        declareLabels = "namespace rom_labels\n{\n"
+        for (label, micropc) in self.labels.items():
+            declareLabels += "const static uint64_t label_%s = %d;\n" \
+                              % (label, micropc)
+        for (label, micropc) in self.externs.items():
+            declareLabels += \
+                "const static MicroPC extern_label_%s = %d;\n" \
+                    % (label, micropc)
+        declareLabels += "}\n"
+        return declareLabels;
+
+    def getDefinition(self):
+        elements = map(lambda op: op.getGenerator(), self.microops)
+        allocator = "{" + ',\n'.join(elements) + "}"
+
+        return '''
+X86ISA::MicrocodeRom::MicrocodeRom() : genFuncs(%s) {}
+''' % allocator

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56469
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: Ic9e071109fa5b4d2f0e29502b7811ef777c0c4af
Gerrit-Change-Number: 56469
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@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