arch-gcn3: Fix s_getpc operand information
authorTony Gutierrez <anthony.gutierrez@amd.com>
Wed, 7 Nov 2018 18:46:12 +0000 (13:46 -0500)
committerAnthony Gutierrez <anthony.gutierrez@amd.com>
Thu, 16 Jul 2020 20:37:22 +0000 (20:37 +0000)
s_getpc was currently reporting only a single operand,
and was only considering the SSRC operand. However,
this instruction' source is implicitly the PC.
Because its destination register was never tracked for
dependence checking purposes, dependence violations
are possible.

Change-Id: Ia80b8b3e24d5885f646a9ee41212a2cb35b9ffe6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29954
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
src/arch/gcn3/insts/instructions.hh
src/arch/gcn3/insts/op_encodings.cc

index b0cc37e8f1a0d8d7af2a260edf4add202e6617fb..f561043de59e93cb0732093e86d4391cb76b5b54 100644 (file)
@@ -5846,9 +5846,7 @@ namespace Gcn3ISA
         getOperandSize(int opIdx) override
         {
             switch (opIdx) {
-              case 0: //ssrc
-                return 8;
-              case 1: //sdst
+              case 0: //sdst
                 return 8;
               default:
                 fatal("op idx %i out of bounds\n", opIdx);
@@ -5860,9 +5858,7 @@ namespace Gcn3ISA
         isSrcOperand(int opIdx) override
         {
             switch (opIdx) {
-              case 0: //ssrc
-                return true;
-              case 1: //sdst
+              case 0: //sdst
                 return false;
               default:
                 fatal("op idx %i out of bounds\n", opIdx);
@@ -5874,9 +5870,7 @@ namespace Gcn3ISA
         isDstOperand(int opIdx) override
         {
             switch (opIdx) {
-              case 0: //ssrc
-                return false;
-              case 1: //sdst
+              case 0: //sdst
                 return true;
               default:
                 fatal("op idx %i out of bounds\n", opIdx);
index 22d0f4898ad1adc4d0ba11874808c6829c41d1af..997b22f2276169ba1c59589da9678c7248f9fbb7 100644 (file)
@@ -326,7 +326,12 @@ namespace Gcn3ISA
 
         switch (opIdx) {
           case 0:
-              return isScalarReg(instData.SSRC0);
+            if (instData.OP == 0x1C) {
+                // Special case for s_getpc, which has no source reg.
+                // Instead, it implicitly reads the PC.
+                return isScalarReg(instData.SDST);
+            }
+            return isScalarReg(instData.SSRC0);
           case 1:
               return isScalarReg(instData.SDST);
           default:
@@ -353,6 +358,12 @@ namespace Gcn3ISA
 
         switch (opIdx) {
           case 0:
+            if (instData.OP == 0x1C) {
+                // Special case for s_getpc, which has no source reg.
+                // Instead, it implicitly reads the PC.
+                return opSelectorToRegIdx(instData.SDST,
+                        gpuDynInst->wavefront()->reservedScalarRegs);
+            }
             return opSelectorToRegIdx(instData.SSRC0,
                     gpuDynInst->wavefront()->reservedScalarRegs);
           case 1: