1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck %s
4 ; CHECK-LABEL: {{^}}inline_asm:
7 define void @inline_asm(i32 addrspace(1)* %out) {
9 store i32 5, i32 addrspace(1)* %out
10 call void asm sideeffect "s_endpgm", ""()
14 ; CHECK-LABEL: {{^}}inline_asm_shader:
17 define amdgpu_ps void @inline_asm_shader() {
19 call void asm sideeffect "s_endpgm", ""()
24 ; CHECK: {{^}}branch_on_asm:
25 ; Make sure inline assembly is treted as divergent.
26 ; CHECK: s_mov_b32 s{{[0-9]+}}, 0
27 ; CHECK: s_and_saveexec_b64
28 define void @branch_on_asm(i32 addrspace(1)* %out) {
29 %zero = call i32 asm "s_mov_b32 $0, 0", "=s"()
30 %cmp = icmp eq i32 %zero, 0
31 br i1 %cmp, label %if, label %endif
34 store i32 0, i32 addrspace(1)* %out
41 ; CHECK-LABEL: {{^}}v_cmp_asm:
42 ; CHECK: v_mov_b32_e32 [[SRC:v[0-9]+]], s{{[0-9]+}}
43 ; CHECK: v_cmp_ne_i32_e64 s{{\[}}[[MASK_LO:[0-9]+]]:[[MASK_HI:[0-9]+]]{{\]}}, 0, [[SRC]]
44 ; CHECK-DAG: v_mov_b32_e32 v[[V_LO:[0-9]+]], s[[MASK_LO]]
45 ; CHECK-DAG: v_mov_b32_e32 v[[V_HI:[0-9]+]], s[[MASK_HI]]
46 ; CHECK: buffer_store_dwordx2 v{{\[}}[[V_LO]]:[[V_HI]]{{\]}}
47 define void @v_cmp_asm(i64 addrspace(1)* %out, i32 %in) {
48 %sgpr = tail call i64 asm "v_cmp_ne_i32_e64 $0, 0, $1", "=s,v"(i32 %in)
49 store i64 %sgpr, i64 addrspace(1)* %out
53 ; CHECK-LABEL: {{^}}code_size_inline_asm:
54 ; CHECK: codeLenInByte = 12
55 define void @code_size_inline_asm(i32 addrspace(1)* %out) {
57 call void asm sideeffect "v_nop_e64", ""()
61 ; All inlineasm instructions are assumed to be the maximum size
62 ; CHECK-LABEL: {{^}}code_size_inline_asm_small_inst:
63 ; CHECK: codeLenInByte = 12
64 define void @code_size_inline_asm_small_inst(i32 addrspace(1)* %out) {
66 call void asm sideeffect "v_nop_e32", ""()
70 ; CHECK-LABEL: {{^}}code_size_inline_asm_2_inst:
71 ; CHECK: codeLenInByte = 20
72 define void @code_size_inline_asm_2_inst(i32 addrspace(1)* %out) {
74 call void asm sideeffect "
81 ; CHECK-LABEL: {{^}}code_size_inline_asm_2_inst_extra_newline:
82 ; CHECK: codeLenInByte = 20
83 define void @code_size_inline_asm_2_inst_extra_newline(i32 addrspace(1)* %out) {
85 call void asm sideeffect "
93 ; CHECK-LABEL: {{^}}code_size_inline_asm_0_inst:
94 ; CHECK: codeLenInByte = 4
95 define void @code_size_inline_asm_0_inst(i32 addrspace(1)* %out) {
97 call void asm sideeffect "", ""()
101 ; CHECK-LABEL: {{^}}code_size_inline_asm_1_comment:
102 ; CHECK: codeLenInByte = 4
103 define void @code_size_inline_asm_1_comment(i32 addrspace(1)* %out) {
105 call void asm sideeffect "; comment", ""()
109 ; CHECK-LABEL: {{^}}code_size_inline_asm_newline_1_comment:
110 ; CHECK: codeLenInByte = 4
111 define void @code_size_inline_asm_newline_1_comment(i32 addrspace(1)* %out) {
113 call void asm sideeffect "
118 ; CHECK-LABEL: {{^}}code_size_inline_asm_1_comment_newline:
119 ; CHECK: codeLenInByte = 4
120 define void @code_size_inline_asm_1_comment_newline(i32 addrspace(1)* %out) {
122 call void asm sideeffect "; comment
127 ; CHECK-LABEL: {{^}}code_size_inline_asm_2_comments_line:
128 ; CHECK: codeLenInByte = 4
129 define void @code_size_inline_asm_2_comments_line(i32 addrspace(1)* %out) {
131 call void asm sideeffect "; first comment ; second comment", ""()
135 ; CHECK-LABEL: {{^}}code_size_inline_asm_2_comments_line_nospace:
136 ; CHECK: codeLenInByte = 4
137 define void @code_size_inline_asm_2_comments_line_nospace(i32 addrspace(1)* %out) {
139 call void asm sideeffect "; first comment;second comment", ""()
143 ; CHECK-LABEL: {{^}}code_size_inline_asm_mixed_comments0:
144 ; CHECK: codeLenInByte = 20
145 define void @code_size_inline_asm_mixed_comments0(i32 addrspace(1)* %out) {
147 call void asm sideeffect "; comment
148 v_nop_e64 ; inline comment
158 ; CHECK-LABEL: {{^}}code_size_inline_asm_mixed_comments1:
159 ; CHECK: codeLenInByte = 20
160 define void @code_size_inline_asm_mixed_comments1(i32 addrspace(1)* %out) {
162 call void asm sideeffect "v_nop_e64 ; inline comment
172 ; CHECK-LABEL: {{^}}code_size_inline_asm_mixed_comments_operands:
173 ; CHECK: codeLenInByte = 20
174 define void @code_size_inline_asm_mixed_comments_operands(i32 addrspace(1)* %out) {
176 call void asm sideeffect "; comment
177 v_add_i32_e32 v0, vcc, v1, v2 ; inline comment
179 v_bfrev_b32_e32 v0, 1