Kyle Roarty has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/57209 )

Change subject: arch-vega: Handle signed offsets in Global/Scratch instructions
......................................................................

arch-vega: Handle signed offsets in Global/Scratch instructions

The offset field in Flat-style instructions is treated differently
based on if the instruction is Flat or Global/Scratch.

In Flat insts, the offset is treated as a 12-bit unsigned number.

In Global/Scratch insts, the offset is treated as a 13-bit signed number.

This patch updates the calcAddr function for Flat-style instructions
to properly sign-extend the offset on Global/Scratch instructions

Change-Id: I57f10258c23d900da9bf6ded6717c6e8abd177b7
---
M src/arch/amdgpu/vega/insts/op_encodings.hh
1 file changed, 30 insertions(+), 3 deletions(-)



diff --git a/src/arch/amdgpu/vega/insts/op_encodings.hh b/src/arch/amdgpu/vega/insts/op_encodings.hh
index 2642cd7..e9ce4cc 100644
--- a/src/arch/amdgpu/vega/insts/op_encodings.hh
+++ b/src/arch/amdgpu/vega/insts/op_encodings.hh
@@ -905,8 +905,16 @@

         void
         calcAddr(GPUDynInstPtr gpuDynInst, ConstVecOperandU64 &vaddr,
-                 ScalarRegU32 saddr, ScalarRegU32 offset)
+                 ScalarRegU32 saddr, ScalarRegI32 offset)
         {
+            // Offset is a 13-bit field w/the following meanings:
+            // In Flat instructions, offset is a 12-bit unsigned number
+ // In Global/Scratch instructions, offset is a 13-bit signed number
+            if (isFlat()) {
+                offset = offset & 0xfff;
+            } else {
+                offset = (ScalarRegI32)sext<13>(offset);
+            }
// If saddr = 0x7f there is no scalar reg to read and address will
             // be a 64-bit address. Otherwise, saddr is the reg index for a
             // scalar reg used as the base address for a 32-bit address.
@@ -956,7 +964,7 @@

         void
         calcAddrSgpr(GPUDynInstPtr gpuDynInst, ConstVecOperandU64 &vaddr,
-                     ConstScalarOperandU64 &saddr, ScalarRegU32 offset)
+                     ConstScalarOperandU64 &saddr, ScalarRegI32 offset)
         {
             // Use SGPR pair as a base address and add VGPR-offset and
             // instruction offset. The VGPR-offset is always 32-bits so we
@@ -971,7 +979,7 @@

         void
         calcAddrVgpr(GPUDynInstPtr gpuDynInst, ConstVecOperandU64 &addr,
-                     ScalarRegU32 offset)
+                     ScalarRegI32 offset)
         {
             for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
                 if (gpuDynInst->exec_mask[lane]) {

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57209
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: I57f10258c23d900da9bf6ded6717c6e8abd177b7
Gerrit-Change-Number: 57209
Gerrit-PatchSet: 1
Gerrit-Owner: Kyle Roarty <kyleroarty1...@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