[llvm] [AMDGPU][GFX12] Support disassembling MUBUF instructions with arbitrary FORMAT values. (PR #95243)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 06:04:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-backend-amdgpu
Author: Ivan Kosarev (kosarev)
<details>
<summary>Changes</summary>
Some tools generate such instructions with the FORMAT field set to 0, which corresponds to buf_fmt_invalid, but that should not prevent them from being recognised on decoding.
---
Full diff: https://github.com/llvm/llvm-project/pull/95243.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/BUFInstructions.td (+7-1)
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vbuffer_mubuf.txt (+4)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/BUFInstructions.td b/llvm/lib/Target/AMDGPU/BUFInstructions.td
index b05834e5803a2..cccd1e8906079 100644
--- a/llvm/lib/Target/AMDGPU/BUFInstructions.td
+++ b/llvm/lib/Target/AMDGPU/BUFInstructions.td
@@ -2447,7 +2447,13 @@ multiclass VBUFFER_MUBUF_Real_gfx12<bits<8> op, string real_name> {
def _gfx12 : VBUFFER_Real_gfx12<op, ps, real_name> {
// Set the last bit of format to 1 to avoid round-trip issues, as some tools
// print BUF_FMT_INVALID for format 0.
- let Inst{55} = 0b1;
+ let Inst{61-55} = 1;
+ }
+ // Have a version of the instruction to disassemble to for any other
+ // FORMAT field values.
+ def _gfx12_format : VBUFFER_Real<op, ps, real_name> {
+ let AsmVariantName = "NonParsable";
+ let DecoderNamespace = "GFX12";
}
}
diff --git a/llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vbuffer_mubuf.txt b/llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vbuffer_mubuf.txt
index cb3b125041b9f..f2363e774cb9e 100644
--- a/llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vbuffer_mubuf.txt
+++ b/llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vbuffer_mubuf.txt
@@ -1131,6 +1131,10 @@
# GFX12: buffer_store_b128 v[1:4], off, s[12:15], s4 offset:8388607 th:TH_STORE_BYPASS scope:SCOPE_SYS ; encoding: [0x04,0x40,0x07,0xc4,0x01,0x18,0xbc,0x00,0x00,0xff,0xff,0x7f]
0x04,0x40,0x07,0xc4,0x01,0x18,0xbc,0x00,0x00,0xff,0xff,0x7f
+# GFX12: buffer_store_b128 v[5:8], v0, s[20:23], s2 idxen th:TH_STORE_NT_WB scope:SCOPE_DEV ; encoding: [0x02,0x40,0x07,0xc4,0x05,0x28,0x78,0x80,0x00,0x00,0x00,0x00]
+# Check that we can still disassemble the instruction when the FORMAT field is not 1.
+0x02,0x40,0x07,0xc4,0x05,0x28,0x78,0x80,0x00,0x00,0x00,0x00
+
# GFX12: buffer_store_d16_format_x v1, off, s[12:15], s4 offset:8388607 ; encoding: [0x04,0x00,0x03,0xc4,0x01,0x18,0x80,0x00,0x00,0xff,0xff,0x7f]
0x04,0x00,0x03,0xc4,0x01,0x18,0x80,0x00,0x00,0xff,0xff,0x7f
``````````
</details>
https://github.com/llvm/llvm-project/pull/95243
More information about the llvm-commits
mailing list