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

Change subject: arch-x86: Separate c++ generation out for the media microops.
......................................................................

arch-x86: Separate c++ generation out for the media microops.

Change-Id: Ibebb7e93928f3f35e3dd991851b636d49f1697d1
---
M src/arch/x86/isa/microops/mediaop.isa
1 file changed, 75 insertions(+), 67 deletions(-)



diff --git a/src/arch/x86/isa/microops/mediaop.isa b/src/arch/x86/isa/microops/mediaop.isa
index 7d765b2..7cb743e 100644
--- a/src/arch/x86/isa/microops/mediaop.isa
+++ b/src/arch/x86/isa/microops/mediaop.isa
@@ -69,84 +69,29 @@
 }};

 let {{
-    # Make these empty strings so that concatenating onto
-    # them will always work.
-    header_output = ""
-    decoder_output = ""
-    exec_output = ""
+    microopClasses.mediaops = []

     class MediaOpMeta(type):
-        def buildCppClasses(self, name, Name, suffix, code, operand_types):
-
-            # Globals to stick the output in
-            global header_output
-            global exec_output
-
- imm_operand_types = list([op if not op.isDual() else op.ImmType for
-                                      op in operand_types])
- operand_types = list([op if not op.isDual() else op.FloatType for
-                                  op in operand_types])
-
-            # If op2 is used anywhere, make register and immediate versions
-            # of this code.
-            matcher = \
- re.compile(r"(?<!\w)(?P<prefix>s?)op2(?P<typeQual>_[^\W_]+)?")
-            match = matcher.search(code)
-            if match:
-                typeQual = ""
-                if match.group("typeQual"):
-                    typeQual = match.group("typeQual")
- src2_name = "%sFpSrcReg2%s" % (match.group("prefix"), typeQual)
-                self.buildCppClasses(name, Name, suffix,
-                        matcher.sub(src2_name, code), operand_types)
-                self.buildCppClasses(name + "i", Name, suffix + "Imm",
-                        matcher.sub("imm8", code), imm_operand_types)
-                return
-
-            base = "X86ISA::InstOperands<" + \
-                    ", ".join(["X86ISA::MediaOpBase"] +
- [op.cxx_class() for op in operand_types]) + ">"
-
-            # Get everything ready for the substitution
-            opt_args = []
-            if self.op_class:
-                opt_args.append(self.op_class)
-            iop = InstObjParams(name, Name + suffix, base, {"code" : code},
-                                opt_args)
-
-            # Generate the actual code (finally!)
-            header_output += MediaOpDeclare.subst(iop)
-            exec_output += MediaOpExecute.subst(iop)
-
-
         def __new__(mcls, Name, bases, dict):
-            abstract = False
-            name = Name.lower()
-            if "abstract" in dict:
-                abstract = dict['abstract']
-                del dict['abstract']
-            if not "op_class" in dict:
-                dict["op_class"] = None
+            dict.setdefault('abstract', False)
+            dict.setdefault('op_class', None)
+
+            dict['className'] = Name
+            dict['base_mnemonic'] = Name.lower()

             cls = super().__new__(mcls, Name, bases, dict)
-            if not abstract:
-                cls.className = Name
-                cls.base_mnemonic = name
-                code = cls.code
-                operand_types = cls.operand_types

-                # Set up the C++ classes
- mcls.buildCppClasses(cls, name, Name, "", code, operand_types)
-
+            if not cls.abstract:
                 # Hook into the microassembler dict
                 global microopClasses
-                microopClasses[name] = cls
+                microopClasses[cls.base_mnemonic] = cls
+                microopClasses.mediaops.append(cls)

# If op2 is used anywhere, make register and immediate versions
                 # of this code.
-                matcher = re.compile(r"op2(?P<typeQual>_[^\W_]+)?")
-                if matcher.search(code):
-                    microopClasses[name + 'i'] = cls
+                matcher = re.compile(r'op2(?P<typeQual>_[^\W_]+)?')
+                if matcher.search(cls.code):
+                    microopClasses[cls.base_mnemonic + 'i'] = cls
             return cls


@@ -1554,4 +1499,58 @@
             super().__init__(size=2)
         op_class = 'FloatMiscOp'
         code = 'FTW = 0xFFFF;'
+
+
+    def buildCppClasses(cls, name=None, suffix="", code=None,
+            operand_types=None):
+
+        if name is None:
+            name = cls.base_mnemonic
+        if code is None:
+            code = cls.code
+        if operand_types is None:
+            operand_types = cls.operand_types
+
+        # Globals to stick the output in
+        global header_output
+        global exec_output
+
+        imm_operand_types = list([op if not op.isDual() else op.ImmType for
+                                  op in operand_types])
+        operand_types = list([op if not op.isDual() else op.FloatType for
+                              op in operand_types])
+
+        # If op2 is used anywhere, make register and immediate versions
+        # of this code.
+        matcher = \
+            re.compile(r"(?<!\w)(?P<prefix>s?)op2(?P<typeQual>_[^\W_]+)?")
+        match = matcher.search(code)
+        if match:
+            type_qual = match.group("typeQual")
+            if not type_qual:
+                typeQual = ""
+ src2_name = "%sFpSrcReg2%s" % (match.group("prefix"), type_qual)
+            buildCppClasses(cls, name, suffix,
+                    matcher.sub(src2_name, code), operand_types)
+            buildCppClasses(cls, name + "i", suffix + "Imm",
+                    matcher.sub("imm8", code), imm_operand_types)
+            return
+
+        base = "X86ISA::InstOperands<" + \
+                ", ".join(["X86ISA::MediaOpBase"] +
+                          [op.cxx_class() for op in operand_types]) + ">"
+
+        # Get everything ready for the substitution
+        opt_args = []
+        if cls.op_class:
+            opt_args.append(cls.op_class)
+        iop = InstObjParams(name, cls.className + suffix, base,
+                            {"code" : code}, opt_args)
+
+        # Generate the actual code (finally!)
+        header_output += MediaOpDeclare.subst(iop)
+        exec_output += MediaOpExecute.subst(iop)
+
+    for cls in microopClasses.mediaops:
+        buildCppClasses(cls)
 }};

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56493
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: Ibebb7e93928f3f35e3dd991851b636d49f1697d1
Gerrit-Change-Number: 56493
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