Skip to content

Commit 3e94eae

Browse files
rovkajasilvanus
andauthored
[AMDGPU] Add GFX12 S_ALLOC_VGPR instruction (#130018)
This patch only adds the instruction for disassembly support. We neither have an instrinsic nor codegen support, and it is unclear whether we actually want to ever have an intrinsic, given the fragile semantics. For now, it will be generated only by the backend in very specific circumstances. --------- Co-authored-by: Jannik Silvanus <[email protected]>
1 parent fa45bf4 commit 3e94eae

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

llvm/lib/Target/AMDGPU/SOPInstructions.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ let SubtargetPredicate = isGFX11Plus in {
423423
}
424424
} // End SubtargetPredicate = isGFX11Plus
425425

426+
let SubtargetPredicate = isGFX12Plus in {
427+
let hasSideEffects = 1, Defs = [SCC] in {
428+
def S_ALLOC_VGPR : SOP1_0_32 <"s_alloc_vgpr">;
429+
}
430+
} // End SubtargetPredicate = isGFX12Plus
431+
426432
class SOP1_F32_Inst<string opName, SDPatternOperator Op, ValueType vt0=f32,
427433
ValueType vt1=vt0> :
428434
SOP1_32<opName, [(set vt0:$sdst, (UniformUnaryFrag<Op> vt1:$src0))]>;
@@ -2048,6 +2054,7 @@ defm S_GET_BARRIER_STATE_M0 : SOP1_M0_Real_gfx12<0x050>;
20482054
defm S_BARRIER_SIGNAL_IMM : SOP1_IMM_Real_gfx12<0x04e>;
20492055
defm S_BARRIER_SIGNAL_ISFIRST_IMM : SOP1_IMM_Real_gfx12<0x04f>;
20502056
defm S_GET_BARRIER_STATE_IMM : SOP1_IMM_Real_gfx12<0x050>;
2057+
defm S_ALLOC_VGPR : SOP1_Real_gfx12<0x053>;
20512058
defm S_SLEEP_VAR : SOP1_IMM_Real_gfx12<0x058>;
20522059

20532060
//===----------------------------------------------------------------------===//

llvm/test/MC/AMDGPU/gfx11_unsupported.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ image_sample_cd_o v252, v[1:4], s[8:15], s[12:15] dmask:0x1
322322
image_sample_cd_o_g16 v[5:6], v[1:4], s[8:15], s[12:15] dmask:0x3
323323
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
324324

325+
s_alloc_vgpr s0
326+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
327+
325328
s_atomic_add flat_scratch_hi, s[2:3], s0
326329
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
327330

llvm/test/MC/AMDGPU/gfx12_asm_sop1.s

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
// RUN: llvm-mc -triple=amdgcn -show-encoding -mcpu=gfx1200 %s | FileCheck --check-prefix=GFX12 %s
22

3+
s_alloc_vgpr 0x1235
4+
// GFX12: encoding: [0xff,0x53,0x80,0xbe,0x35,0x12,0x00,0x00]
5+
6+
s_alloc_vgpr 18
7+
// GFX12: encoding: [0x92,0x53,0x80,0xbe]
8+
9+
s_alloc_vgpr s35
10+
// GFX12: encoding: [0x23,0x53,0x80,0xbe]
11+
12+
s_alloc_vgpr m0
13+
// GFX12: encoding: [0x7d,0x53,0x80,0xbe]
14+
15+
s_alloc_vgpr scc
16+
// GFX12: encoding: [0xfd,0x53,0x80,0xbe]
17+
318
s_sleep_var 0x1234
419
// GFX12: encoding: [0xff,0x58,0x80,0xbe,0x34,0x12,0x00,0x00]
520

llvm/test/MC/AMDGPU/gfx12_err.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,12 @@ s_prefetch_inst s[14:15], 0xffffff, m0, 7
116116

117117
s_endpgm_ordered_ps_done
118118
// GFX12-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
119+
120+
s_alloc_vgpr v0
121+
// GFX12-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
122+
123+
s_alloc_vgpr exec
124+
// GFX12-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
125+
126+
s_alloc_vgpr vcc
127+
// GFX12-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1200 -disassemble -show-encoding < %s | FileCheck -check-prefixes=GFX12 %s
22

3+
# GFX12: s_alloc_vgpr 0x1235 ; encoding: [0xff,0x53,0x80,0xbe,0x35,0x12,0x00,0x00]
4+
0xff,0x53,0x80,0xbe,0x35,0x12,0x00,0x00
5+
6+
# GFX12: s_alloc_vgpr 18 ; encoding: [0x92,0x53,0x80,0xbe]
7+
0x92,0x53,0x80,0xbe
8+
9+
# GFX12: s_alloc_vgpr s35 ; encoding: [0x23,0x53,0x80,0xbe]
10+
0x23,0x53,0x80,0xbe
11+
312
# GFX12: s_sleep_var 0x1234 ; encoding: [0xff,0x58,0x80,0xbe,0x34,0x12,0x00,0x00]
413
0xff,0x58,0x80,0xbe,0x34,0x12,0x00,0x00
514

0 commit comments

Comments
 (0)