[llvm] 365d827 - [AMDGPU][MC][GFX11] Correct ds_swizzle_b32
Dmitry Preobrazhensky via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 14 02:58:26 PDT 2022
Author: Dmitry Preobrazhensky
Date: 2022-06-14T12:58:03+03:00
New Revision: 365d827f659767201a5bba32162a44ad47205393
URL: https://github.com/llvm/llvm-project/commit/365d827f659767201a5bba32162a44ad47205393
DIFF: https://github.com/llvm/llvm-project/commit/365d827f659767201a5bba32162a44ad47205393.diff
LOG: [AMDGPU][MC][GFX11] Correct ds_swizzle_b32
Enable offset parsing.
Differential Revision: https://reviews.llvm.org/D127404
Added:
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/gfx11_ds.s
llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index c9eaa140dd222..5e86ea30e1d9a 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -6291,6 +6291,7 @@ void AMDGPUAsmParser::cvtDSOffset01(MCInst &Inst,
void AMDGPUAsmParser::cvtDSImpl(MCInst &Inst, const OperandVector &Operands,
bool IsGdsHardcoded) {
OptionalImmIndexMap OptionalIdx;
+ AMDGPUOperand::ImmTy OffsetType = AMDGPUOperand::ImmTyOffset;
for (unsigned i = 1, e = Operands.size(); i != e; ++i) {
AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[i]);
@@ -6308,13 +6309,10 @@ void AMDGPUAsmParser::cvtDSImpl(MCInst &Inst, const OperandVector &Operands,
// Handle optional arguments
OptionalIdx[Op.getImmTy()] = i;
- }
- AMDGPUOperand::ImmTy OffsetType =
- (Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_gfx10 ||
- Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_gfx6_gfx7 ||
- Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_vi) ? AMDGPUOperand::ImmTySwizzle :
- AMDGPUOperand::ImmTyOffset;
+ if (Op.getImmTy() == AMDGPUOperand::ImmTySwizzle)
+ OffsetType = AMDGPUOperand::ImmTySwizzle;
+ }
addOptionalImmOperand(Inst, Operands, OptionalIdx, OffsetType);
diff --git a/llvm/test/MC/AMDGPU/gfx11_ds.s b/llvm/test/MC/AMDGPU/gfx11_ds.s
index 2e5bd512a6d90..1577a8defdb3c 100644
--- a/llvm/test/MC/AMDGPU/gfx11_ds.s
+++ b/llvm/test/MC/AMDGPU/gfx11_ds.s
@@ -125,3 +125,30 @@ ds_sub_gs_reg_rtn v[5:6], v255 offset:127 gds
ds_sub_gs_reg_rtn v[5:6], v255 gds
// GFX11: encoding: [0x00,0x00,0xee,0xd9,0x00,0xff,0x00,0x05]
+
+ds_swizzle_b32 v8, v2
+// GFX11: encoding: [0x00,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:0
+// GFX11: encoding: [0x00,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:0xFFFF
+// GFX11: encoding: [0xff,0xff,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(QUAD_PERM, 0, 1, 2, 3)
+// GFX11: encoding: [0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(SWAP,16)
+// GFX11: encoding: [0x1f,0x40,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(REVERSE,8)
+// GFX11: encoding: [0x1f,0x1c,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,4,1)
+// GFX11: encoding: [0x3c,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,8,7)
+// GFX11: encoding: [0xf8,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08]
+
+ds_swizzle_b32 v8, v2 offset:swizzle(BITMASK_PERM, "01pip")
+// GFX11: encoding: [0x07,0x09,0xd4,0xd8,0x02,0x00,0x00,0x08]
diff --git a/llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt b/llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt
index bb319e22ec2e1..2debd902ce207 100644
--- a/llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt
+++ b/llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt
@@ -3817,6 +3817,18 @@
# GFX11: ds_swizzle_b32 v5, v1 offset:swizzle(BITMASK_PERM,"00p00") ; encoding: [0x04,0x00,0xd4,0xd8,0x01,0x00,0x00,0x05]
0x04,0x00,0xd4,0xd8,0x01,0x00,0x00,0x05
+# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(QUAD_PERM,0,1,2,3) ; encoding: [0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08]
+0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08
+
+# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(SWAP,4) ; encoding: [0x1f,0x10,0xd4,0xd8,0x02,0x00,0x00,0x08]
+0x1f,0x10,0xd4,0xd8,0x02,0x00,0x00,0x08
+
+# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(REVERSE,16) ; encoding: [0x1f,0x3c,0xd4,0xd8,0x02,0x00,0x00,0x08]
+0x1f,0x3c,0xd4,0xd8,0x02,0x00,0x00,0x08
+
+# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,32,1) ; encoding: [0x20,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08]
+0x20,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08
+
# GFX11: ds_swizzle_b32 v5, v255 offset:65535 ; encoding: [0xff,0xff,0xd4,0xd8,0xff,0x00,0x00,0x05]
0xff,0xff,0xd4,0xd8,0xff,0x00,0x00,0x05
More information about the llvm-commits
mailing list