1; RUN: llc -march=amdgcn -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=CI -check-prefix=GCN %s
2; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=VI-NOXNACK -check-prefix=GCN %s
3
4; RUN: llc -march=amdgcn -mcpu=carrizo -mattr=-xnack -verify-machineinstrs < %s | FileCheck -check-prefix=VI-NOXNACK  -check-prefix=GCN %s
5; RUN: llc -march=amdgcn -mcpu=stoney -mattr=-xnack -verify-machineinstrs < %s | FileCheck -check-prefix=VI-NOXNACK  -check-prefix=GCN %s
6
7; RUN: llc -march=amdgcn -mcpu=carrizo -verify-machineinstrs < %s | FileCheck -check-prefix=VI-XNACK  -check-prefix=GCN %s
8; RUN: llc -march=amdgcn -mcpu=stoney  -verify-machineinstrs < %s | FileCheck -check-prefix=VI-XNACK  -check-prefix=GCN %s
9
10; RUN: llc -march=amdgcn -mtriple=amdgcn--amdhsa -mcpu=kaveri --amdhsa-code-object-version=2 -verify-machineinstrs < %s | FileCheck -check-prefix=HSA-CI -check-prefix=GCN %s
11; RUN: llc -march=amdgcn -mtriple=amdgcn--amdhsa -mcpu=carrizo --amdhsa-code-object-version=2 -mattr=-xnack -verify-machineinstrs < %s | FileCheck -check-prefix=HSA-VI-NOXNACK -check-prefix=GCN %s
12; RUN: llc -march=amdgcn -mtriple=amdgcn--amdhsa -mcpu=carrizo --amdhsa-code-object-version=2 -mattr=+xnack -verify-machineinstrs < %s | FileCheck -check-prefix=HSA-VI-XNACK -check-prefix=GCN %s
13
14; GCN-LABEL: {{^}}no_vcc_no_flat:
15; HSA-CI: is_xnack_enabled = 0
16; HSA-VI-NOXNACK: is_xnack_enabled = 0
17; HSA-VI-XNACK: is_xnack_enabled = 1
18
19; CI: ; NumSgprs: 8
20; VI-NOXNACK: ; NumSgprs: 8
21; VI-XNACK: ; NumSgprs: 12
22define amdgpu_kernel void @no_vcc_no_flat() {
23entry:
24  call void asm sideeffect "", "~{s7}"()
25  ret void
26}
27
28; GCN-LABEL: {{^}}vcc_no_flat:
29; HSA-CI: is_xnack_enabled = 0
30; HSA-VI-NOXNACK: is_xnack_enabled = 0
31; HSA-VI-XNACK: is_xnack_enabled = 1
32
33; CI: ; NumSgprs: 10
34; VI-NOXNACK: ; NumSgprs: 10
35; VI-XNACK: ; NumSgprs: 12
36define amdgpu_kernel void @vcc_no_flat() {
37entry:
38  call void asm sideeffect "", "~{s7},~{vcc}"()
39  ret void
40}
41
42; GCN-LABEL: {{^}}no_vcc_flat:
43; HSA-CI: is_xnack_enabled = 0
44; HSA-VI-NOXNACK: is_xnack_enabled = 0
45; HSA-VI-XNACK: is_xnack_enabled = 1
46
47; CI: ; NumSgprs: 12
48; VI-NOXNACK: ; NumSgprs: 14
49; VI-XNACK: ; NumSgprs: 14
50; HSA-CI: ; NumSgprs: 12
51; HSA-VI-NOXNACK: ; NumSgprs: 14
52; HSA-VI-XNACK: ; NumSgprs: 14
53define amdgpu_kernel void @no_vcc_flat() {
54entry:
55  call void asm sideeffect "", "~{s7},~{flat_scratch}"()
56  ret void
57}
58
59; GCN-LABEL: {{^}}vcc_flat:
60; HSA-NOXNACK: is_xnack_enabled = 0
61; HSA-XNACK: is_xnack_enabled = 1
62
63; CI: ; NumSgprs: 12
64; VI-NOXNACK: ; NumSgprs: 14
65; VI-XNACK: ; NumSgprs: 14
66; HSA-CI: ; NumSgprs: 12
67; HSA-VI-NOXNACK: ; NumSgprs: 14
68; HSA-VI-XNACK: ; NumSgprs: 14
69define amdgpu_kernel void @vcc_flat() {
70entry:
71  call void asm sideeffect "", "~{s7},~{vcc},~{flat_scratch}"()
72  ret void
73}
74
75; Make sure used SGPR count for flat_scr is correct when there is no
76; scratch usage and implicit flat uses.
77
78; GCN-LABEL: {{^}}use_flat_scr:
79; CI: NumSgprs: 4
80; VI-NOXNACK: NumSgprs: 6
81; VI-XNACK: NumSgprs: 6
82define amdgpu_kernel void @use_flat_scr() #0 {
83entry:
84  call void asm sideeffect "; clobber ", "~{flat_scratch}"()
85  ret void
86}
87
88; GCN-LABEL: {{^}}use_flat_scr_lo:
89; CI: NumSgprs: 4
90; VI-NOXNACK: NumSgprs: 6
91; VI-XNACK: NumSgprs: 6
92define amdgpu_kernel void @use_flat_scr_lo() #0 {
93entry:
94  call void asm sideeffect "; clobber ", "~{flat_scratch_lo}"()
95  ret void
96}
97
98; GCN-LABEL: {{^}}use_flat_scr_hi:
99; CI: NumSgprs: 4
100; VI-NOXNACK: NumSgprs: 6
101; VI-XNACK: NumSgprs: 6
102define amdgpu_kernel void @use_flat_scr_hi() #0 {
103entry:
104  call void asm sideeffect "; clobber ", "~{flat_scratch_hi}"()
105  ret void
106}
107
108attributes #0 = { nounwind }
109