[llvm] bcbd9b0 - [AMDGPU][MC] Don't accept attr > 32 for param_load
Diana Picus via llvm-commits
llvm-commits at lists.llvm.org
Sun May 14 23:43:20 PDT 2023
Author: Diana Picus
Date: 2023-05-15T08:32:11+02:00
New Revision: bcbd9b021a2feadc8c2c2560f533dda76f7be26d
URL: https://github.com/llvm/llvm-project/commit/bcbd9b021a2feadc8c2c2560f533dda76f7be26d
DIFF: https://github.com/llvm/llvm-project/commit/bcbd9b021a2feadc8c2c2560f533dda76f7be26d.diff
LOG: [AMDGPU][MC] Don't accept attr > 32 for param_load
The docs say the interpolation attribute should be between 0..32 [1][2],
but we currently accept values all the way up to 63.
This patch makes the ASMParser error out for values > 32. It does not
touch codegen though because we're currently not checking anything at
all for codegen (llvm.amdgcn.lds.param.load will happily accept even 128
as an attr, although that won't fit in the encoding).
[1] https://llvm.org/docs/AMDGPU/gfx8_attr.html#amdgpu-synid-gfx8-attr
[2] https://llvm.org/docs/AMDGPU/gfx11_attr.html#amdgpu-synid-gfx11-attr
Differential Revision: https://reviews.llvm.org/D150261
Added:
llvm/test/MC/AMDGPU/gfx11_asm_ldsdir_err.s
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s
llvm/test/MC/AMDGPU/vintrp-err.s
llvm/test/MC/AMDGPU/vintrp.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 2f1c070649bfb..bf3955a0a47b6 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -7073,7 +7073,7 @@ OperandMatchResultTy AMDGPUAsmParser::parseInterpAttr(OperandVector &Operands) {
return MatchOperand_ParseFail;
}
- if (Attr > 63) {
+ if (Attr > 32) {
Error(S, "out of bounds interpolation attribute number");
return MatchOperand_ParseFail;
}
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s b/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s
index 1655281ddfa55..d01557865ad4d 100644
--- a/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s
@@ -84,20 +84,5 @@ lds_param_load v10, attr11.x wait_vdst:6
lds_param_load v11, attr22.y wait_vdst:5
// GFX11: lds_param_load v11, attr22.y wait_vdst:5 ; encoding: [0x0b,0x59,0x05,0xce]
-lds_param_load v12, attr33.z wait_vdst:4
-// GFX11: lds_param_load v12, attr33.z wait_vdst:4 ; encoding: [0x0c,0x86,0x04,0xce]
-
-lds_param_load v13, attr63.x wait_vdst:3
-// GFX11: lds_param_load v13, attr63.x wait_vdst:3 ; encoding: [0x0d,0xfc,0x03,0xce]
-
-lds_param_load v14, attr63.y wait_vdst:2
-// GFX11: lds_param_load v14, attr63.y wait_vdst:2 ; encoding: [0x0e,0xfd,0x02,0xce]
-
-lds_param_load v15, attr63.z wait_vdst:1
-// GFX11: lds_param_load v15, attr63.z wait_vdst:1 ; encoding: [0x0f,0xfe,0x01,0xce]
-
-lds_param_load v16, attr63.w wait_vdst:0
-// GFX11: lds_param_load v16, attr63.w ; encoding: [0x10,0xff,0x00,0xce]
-
-lds_param_load v17, attr63.w
-// GFX11: lds_param_load v17, attr63.w ; encoding: [0x11,0xff,0x00,0xce]
+lds_param_load v12, attr32.z wait_vdst:4
+// GFX11: lds_param_load v12, attr32.z wait_vdst:4 ; encoding: [0x0c,0x82,0x04,0xce]
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir_err.s b/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir_err.s
new file mode 100644
index 0000000000000..b4318a05767bb
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_ldsdir_err.s
@@ -0,0 +1,20 @@
+// RUN: not llvm-mc -arch=amdgcn -mcpu=gfx1100 -show-encoding %s 2>&1 | FileCheck -check-prefix=GFX11 %s
+
+lds_param_load v17, attr33.x
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
+lds_param_load v17, attr33.y
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
+lds_param_load v17, attr33.z
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
+lds_param_load v17, attr33.w
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
+lds_param_load v12, attr33.z wait_va_vdst:4
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
+lds_param_load v12, attr33.w wait_va_vdst:2 wait_vm_vsrc:1
+// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
+
diff --git a/llvm/test/MC/AMDGPU/vintrp-err.s b/llvm/test/MC/AMDGPU/vintrp-err.s
index 9171567945507..05c26d5ae9419 100644
--- a/llvm/test/MC/AMDGPU/vintrp-err.s
+++ b/llvm/test/MC/AMDGPU/vintrp-err.s
@@ -4,16 +4,16 @@
v_interp_p1_f32 v0, v1
// GCN: :[[@LINE-1]]:{{[0-9]+}}: error: too few operands for instruction
-v_interp_p1_f32 v0, v1, attr64.w
+v_interp_p1_f32 v0, v1, attr33.w
// GCN: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
-v_interp_p1_f32 v0, v1, attr64.x
+v_interp_p1_f32 v0, v1, attr33.x
// GCN: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
-v_interp_p2_f32 v9, v1, attr64.x
+v_interp_p2_f32 v9, v1, attr33.x
// GCN: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
-v_interp_p2_f32 v0, v1, attr64.x
+v_interp_p2_f32 v0, v1, attr33.x
// GCN: :[[@LINE-1]]:{{[0-9]+}}: error: out of bounds interpolation attribute number
v_interp_p2_f32 v0, v1, attr0.q
diff --git a/llvm/test/MC/AMDGPU/vintrp.s b/llvm/test/MC/AMDGPU/vintrp.s
index 79344a79c1c32..fbeb540b71286 100644
--- a/llvm/test/MC/AMDGPU/vintrp.s
+++ b/llvm/test/MC/AMDGPU/vintrp.s
@@ -37,9 +37,9 @@ v_interp_p1_f32 v9, v0, attr4.w
// SI: v_interp_p1_f32 v9, v0, attr4.w ; encoding: [0x00,0x13,0x24,0xc8]
// VI: v_interp_p1_f32_e32 v9, v0, attr4.w ; encoding: [0x00,0x13,0x24,0xd4]
-v_interp_p1_f32 v10, v0, attr63.w
-// SI: v_interp_p1_f32 v10, v0, attr63.w ; encoding: [0x00,0xff,0x28,0xc8]
-// VI: v_interp_p1_f32_e32 v10, v0, attr63.w ; encoding: [0x00,0xff,0x28,0xd4]
+v_interp_p1_f32 v10, v0, attr32.w
+// SI: v_interp_p1_f32 v10, v0, attr32.w ; encoding: [0x00,0x83,0x28,0xc8]
+// VI: v_interp_p1_f32_e32 v10, v0, attr32.w ; encoding: [0x00,0x83,0x28,0xd4]
v_interp_p2_f32 v2, v1, attr0.x
@@ -66,9 +66,9 @@ v_interp_p2_f32 v7, v1, attr1.x
// SI: v_interp_p2_f32 v7, v1, attr1.x ; encoding: [0x01,0x04,0x1d,0xc8]
// VI: v_interp_p2_f32_e32 v7, v1, attr1.x ; encoding: [0x01,0x04,0x1d,0xd4]
-v_interp_p2_f32 v8, v1, attr63.x
-// SI: v_interp_p2_f32 v8, v1, attr63.x ; encoding: [0x01,0xfc,0x21,0xc8]
-// VI: v_interp_p2_f32_e32 v8, v1, attr63.x ; encoding: [0x01,0xfc,0x21,0xd4]
+v_interp_p2_f32 v8, v1, attr32.x
+// SI: v_interp_p2_f32 v8, v1, attr32.x ; encoding: [0x01,0x80,0x21,0xc8]
+// VI: v_interp_p2_f32_e32 v8, v1, attr32.x ; encoding: [0x01,0x80,0x21,0xd4]
v_interp_mov_f32 v0, p10, attr0.x
@@ -99,7 +99,7 @@ v_interp_mov_f32 v7, p10, attr0.x
// SI: v_interp_mov_f32 v7, p10, attr0.x ; encoding: [0x00,0x00,0x1e,0xc8]
// VI: v_interp_mov_f32_e32 v7, p10, attr0.x ; encoding: [0x00,0x00,0x1e,0xd4]
-v_interp_mov_f32 v9, p10, attr63.y
-// SI: v_interp_mov_f32 v9, p10, attr63.y ; encoding: [0x00,0xfd,0x26,0xc8]
-// VI: v_interp_mov_f32_e32 v9, p10, attr63.y ; encoding: [0x00,0xfd,0x26,0xd4]
+v_interp_mov_f32 v9, p10, attr32.y
+// SI: v_interp_mov_f32 v9, p10, attr32.y ; encoding: [0x00,0x81,0x26,0xc8]
+// VI: v_interp_mov_f32_e32 v9, p10, attr32.y ; encoding: [0x00,0x81,0x26,0xd4]
More information about the llvm-commits
mailing list