Skip to content

Commit de1ff3e

Browse files
authored
[AMDGPU] Allow null operands in VImage tensor instructions (#200911)
NULL is equivalent to passing a block of SGPRs that are set to zero, and is allowed for 3+ opnds.
1 parent 383e5d2 commit de1ff3e

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

llvm/lib/Target/AMDGPU/MIMGInstructions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,8 +2183,8 @@ class VIMAGE_TENSOR_Pseudo<string opName, bit _UpTo2D = 0> :
21832183

21842184
bit UpTo2D = _UpTo2D;
21852185
let InOperandList = !if(UpTo2D, (ins SReg_128_XNULL:$vaddr0, SReg_256_XNULL:$vaddr1, R128A16:$r128, CPol:$cpol),
2186-
(ins SReg_128_XNULL:$vaddr0, SReg_256_XNULL:$vaddr1, SReg_128_XNULL:$vaddr2,
2187-
SReg_128_XNULL:$vaddr3, R128A16:$r128, CPol:$cpol));
2186+
(ins SReg_128_XNULL:$vaddr0, SReg_256_XNULL:$vaddr1, SReg_128:$vaddr2,
2187+
SReg_128:$vaddr3, R128A16:$r128, CPol:$cpol));
21882188
string AsmOperands = " $vaddr0, $vaddr1"#!if(UpTo2D, "", ", $vaddr2, $vaddr3")#"$r128$cpol";
21892189
}
21902190

llvm/test/MC/AMDGPU/gfx1250_asm_vimage.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ tensor_store_from_lds s[0:3], s[4:11] th:TH_STORE_BYPASS scope:SCOPE_SYS
2626
// GFX12-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1200): tensor_store_from_lds
2727
// GFX1250: tensor_store_from_lds s[0:3], s[4:11] th:TH_STORE_BYPASS scope:SCOPE_SYS ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x3c,0x7c,0x00,0x04,0x7c,0x7c]
2828

29+
tensor_store_from_lds s[0:3], s[4:11], null, null th:TH_STORE_NT_HT scope:SCOPE_DEV
30+
// GFX12-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1200): tensor_store_from_lds
31+
// GFX1250: tensor_store_from_lds s[0:3], s[4:11], null, null th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x7c]
32+
33+
tensor_store_from_lds s[0:3], s[4:11], null, s[16:19] th:TH_STORE_NT_HT scope:SCOPE_DEV
34+
// GFX12-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1200): tensor_store_from_lds
35+
// GFX1250: tensor_store_from_lds s[0:3], s[4:11], null, s[16:19] th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x10]
36+
37+
tensor_store_from_lds s[0:3], s[4:11], s[12:15], null th:TH_STORE_NT_HT scope:SCOPE_DEV
38+
// GFX12-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1200): tensor_store_from_lds
39+
// GFX1250: tensor_store_from_lds s[0:3], s[4:11], s[12:15], null th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x0c,0x7c]
40+
2941
tensor_store_from_lds s[0:3], s[4:11], s[12:15], s[16:19]
3042
// GFX12-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1200): tensor_store_from_lds
3143
// GFX1250: tensor_store_from_lds s[0:3], s[4:11], s[12:15], s[16:19] ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x00,0x7c,0x00,0x04,0x0c,0x10]

llvm/test/MC/AMDGPU/gfx1250_asm_vimage_err.s

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ tensor_load_to_lds null, s[4:11], s[12:15], s[16:19]
3737
tensor_load_to_lds s[0:3], null, s[12:15], s[16:19]
3838
// GFX1250-ERR: :[[@LINE-1]]:28: error: invalid operand for instruction
3939

40-
tensor_load_to_lds s[0:3], s[4:11], null, s[16:19]
41-
// GFX1250-ERR: :[[@LINE-1]]:37: error: invalid operand for instruction
42-
43-
tensor_load_to_lds s[0:3], s[4:11], s[12:15], null
44-
// GFX1250-ERR: :[[@LINE-1]]:47: error: invalid operand for instruction
45-
4640
tensor_store_from_lds null, s[4:11]
4741
// GFX1250-ERR: :[[@LINE-1]]:23: error: invalid operand for instruction
4842

@@ -55,12 +49,6 @@ tensor_store_from_lds null, s[4:11], s[12:15], s[16:19]
5549
tensor_store_from_lds s[0:3], null, s[12:15], s[16:19]
5650
// GFX1250-ERR: :[[@LINE-1]]:31: error: invalid operand for instruction
5751

58-
tensor_store_from_lds s[0:3], s[4:11], null, s[16:19]
59-
// GFX1250-ERR: :[[@LINE-1]]:40: error: invalid operand for instruction
60-
61-
tensor_store_from_lds s[0:3], s[4:11], s[12:15], null
62-
// GFX1250-ERR: :[[@LINE-1]]:50: error: invalid operand for instruction
63-
6452
tensor_load_to_lds s[14:17], s[4:11]
6553
// GFX1250-ERR: :[[@LINE-1]]:20: error: invalid register alignment
6654

llvm/test/MC/Disassembler/AMDGPU/gfx1250_dasm_vimage.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
0x01,0x40,0x71,0xd0,0x00,0x00,0x3c,0x7c,0x00,0x04,0x7c,0x7c
2020
# GFX1250: tensor_store_from_lds s[0:3], s[4:11] th:TH_STORE_BYPASS scope:SCOPE_SYS ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x3c,0x7c,0x00,0x04,0x7c,0x7c]
2121

22+
0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x7c
23+
# GFX1250: tensor_store_from_lds s[0:3], s[4:11] th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x7c]
24+
25+
0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x10
26+
# GFX1250: tensor_store_from_lds s[0:3], s[4:11], null, s[16:19] th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x7c,0x10]
27+
28+
0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x0c,0x7c
29+
# GFX1250: tensor_store_from_lds s[0:3], s[4:11], s[12:15], null th:TH_STORE_NT_HT scope:SCOPE_DEV ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x68,0x7c,0x00,0x04,0x0c,0x7c]
30+
2231
0x01,0x40,0x71,0xd0,0x00,0x00,0x00,0x7c,0x00,0x04,0x0c,0x10
2332
# GFX1250: tensor_store_from_lds s[0:3], s[4:11], s[12:15], s[16:19] ; encoding: [0x01,0x40,0x71,0xd0,0x00,0x00,0x00,0x7c,0x00,0x04,0x0c,0x10]
2433

0 commit comments

Comments
 (0)