Skip to content

Commit

Permalink
[AMDGPU][MC] Don't accept attr > 32 for param_load
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rovka committed May 15, 2023
1 parent 2f99932 commit bcbd9b0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 2 additions & 17 deletions llvm/test/MC/AMDGPU/gfx11_asm_ldsdir.s
Original file line number Diff line number Diff line change
Expand Up @@ -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]
20 changes: 20 additions & 0 deletions llvm/test/MC/AMDGPU/gfx11_asm_ldsdir_err.s
Original file line number Diff line number Diff line change
@@ -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

8 changes: 4 additions & 4 deletions llvm/test/MC/AMDGPU/vintrp-err.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/MC/AMDGPU/vintrp.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]

0 comments on commit bcbd9b0

Please sign in to comment.