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

Change subject: arch: Make it possible for force operands to be sources or dests.
......................................................................

arch: Make it possible for force operands to be sources or dests.

Add either Src or Dest as a suffix to force an operand to be purely a
source or destination. This helps avoid situations where a calculated
value in a destination operand is used to find additional values. The
parser would assume the destination is a source, even when it's not.

Also, in the future, this will make it possible to keep track of all
inputs and outputs from instructions automatically for tracing purposes.

Change-Id: Ife805e8bc312f1dd0e4aebccb37a6165389d2edc
---
M src/arch/isa_parser/operand_types.py
1 file changed, 71 insertions(+), 0 deletions(-)



diff --git a/src/arch/isa_parser/operand_types.py b/src/arch/isa_parser/operand_types.py
index 0ea2f2d..2d9889f 100755
--- a/src/arch/isa_parser/operand_types.py
+++ b/src/arch/isa_parser/operand_types.py
@@ -44,6 +44,9 @@
     derived classes encapsulates the traits of a particular operand
     type (e.g., "32-bit integer register").'''

+    IsForcedSource = False
+    IsForcedDest = False
+
     src_reg_constructor = '\n\tsetSrcRegIdx(_numSrcRegs++, RegId(%s, %s));'
dst_reg_constructor = '\n\tsetDestRegIdx(_numDestRegs++, RegId(%s, %s));'

@@ -97,6 +100,15 @@
     # by predicated register reads/writes. Hence, we forward the flags
     # that indicate whether or not predication is in use.
     def finalize(self, predRead, predWrite):
+        if self.IsForcedSource:
+            assert not self.IsForcedDest
+            self.is_src = True
+            self.is_dest = False
+        elif self.IsForcedDest:
+            assert not self.IsForcedSource
+            self.is_src = False
+            self.is_dest = True
+
         self.flags = self.getFlags()
         self.constructor = self.makeConstructor(predRead, predWrite)
         self.op_decl = self.makeDecl()
@@ -167,6 +179,11 @@
     def makeDecl(self):
         return self.ctype + ' ' + self.base_name + ';\n';

+class SrcOperand(object):
+    IsForcedSource = True
+
+class DestOperand(object):
+    IsForcedDest = True

 class IntRegOperand(Operand):
     reg_class = 'IntRegClass'
@@ -240,6 +257,12 @@

         return wb

+class IntRegSrcOperand(SrcOperand, IntRegOperand):
+    pass
+
+class IntRegDestOperand(DestOperand, IntRegOperand):
+    pass
+
 class FloatRegOperand(Operand):
     reg_class = 'FloatRegClass'

@@ -303,6 +326,12 @@
         }''' % (self.ctype, self.base_name, wp)
         return wb

+class FloatRegSrcOperand(SrcOperand, FloatRegOperand):
+    pass
+
+class FloatRegDestOperand(DestOperand, FloatRegOperand):
+    pass
+
 class VecRegOperand(Operand):
     reg_class = 'VecRegClass'

@@ -451,6 +480,12 @@
         if self.is_dest:
             self.op_rd = self.makeReadW(predWrite) + self.op_rd

+class VecRegSrcOperand(SrcOperand, VecRegOperand):
+    pass
+
+class VecRegDestOperand(DestOperand, VecRegOperand):
+    pass
+
 class VecElemOperand(Operand):
     reg_class = 'VecElemClass'

@@ -505,6 +540,12 @@

         return c_write

+class VecElemSrcOperand(SrcOperand, VecElemOperand):
+    pass
+
+class VecElemDestOperand(DestOperand, VecElemOperand):
+    pass
+
 class VecPredRegOperand(Operand):
     reg_class = 'VecPredRegClass'

@@ -587,6 +628,12 @@
         if self.is_dest:
             self.op_rd = self.makeReadW(predWrite) + self.op_rd

+class VecPredSrcOperand(SrcOperand, VecPredRegOperand):
+    pass
+
+class VecPredDestOperand(DestOperand, VecPredRegOperand):
+    pass
+
 class CCRegOperand(Operand):
     reg_class = 'CCRegClass'

@@ -659,6 +706,12 @@

         return wb

+class CCRegSrcOperand(SrcOperand, CCRegOperand):
+    pass
+
+class CCRegDestOperand(DestOperand, CCRegOperand):
+    pass
+
 class ControlRegOperand(Operand):
     reg_class = 'MiscRegClass'

@@ -713,6 +766,12 @@

         return wb

+class ControlRegSrcOperand(SrcOperand, ControlRegOperand):
+    pass
+
+class ControlRegDestOperand(DestOperand, ControlRegOperand):
+    pass
+
 class MemOperand(Operand):
     def isMem(self):
         return 1
@@ -734,6 +793,12 @@
             return self.buildWriteCode(predWrite)
         return ''

+class MemSrcOperand(SrcOperand, MemOperand):
+    pass
+
+class MemDestOperand(DestOperand, MemOperand):
+    pass
+
 class PCStateOperand(Operand):
     def makeConstructor(self, predRead, predWrite):
         return ''
@@ -766,3 +831,9 @@

     def isPCState(self):
         return 1
+
+class PCStateSrcOperand(SrcOperand, PCStateOperand):
+    pass
+
+class PCStateDestOperand(DestOperand, PCStateOperand):
+    pass

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42974
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: Ife805e8bc312f1dd0e4aebccb37a6165389d2edc
Gerrit-Change-Number: 42974
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to