File: inline-asm.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (108 lines) | stat: -rw-r--r-- 4,438 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
; RUN: opt -mtriple amdgcn-unknown-amdhsa -mcpu=tahiti -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s
; RUN: opt -mtriple amdgcn-unknown-amdhsa -mcpu=gfx908 -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s
; Make sure nothing crashes on targets with or without AGPRs

; CHECK-LABEL: for function 'inline_asm_1_sgpr_virtreg_output':
; CHECK-NOT: DIVERGENT
define i32 @inline_asm_1_sgpr_virtreg_output() {
  %sgpr = call i32 asm "s_mov_b32 $0, 0", "=s"()
  ret i32 %sgpr
}

; CHECK-LABEL: for function 'inline_asm_1_sgpr_physreg_output':
; CHECK-NOT: DIVERGENT
define i32 @inline_asm_1_sgpr_physreg_output() {
  %sgpr = call i32 asm "s_mov_b32 s0, 0", "={s0}"()
  ret i32 %sgpr
}

; CHECK-LABEL: for function 'inline_asm_1_vgpr_virtreg_output':
; CHECK: DIVERGENT: %vgpr = call i32 asm "v_mov_b32 $0, 0", "=v"()
define i32 @inline_asm_1_vgpr_virtreg_output() {
  %vgpr = call i32 asm "v_mov_b32 $0, 0", "=v"()
  ret i32 %vgpr
}

; CHECK-LABEL: for function 'inline_asm_1_vgpr_physreg_output':
; CHECK: DIVERGENT: %vgpr = call i32 asm "v_mov_b32 v0, 0", "={v0}"()
define i32 @inline_asm_1_vgpr_physreg_output() {
  %vgpr = call i32 asm "v_mov_b32 v0, 0", "={v0}"()
  ret i32 %vgpr
}

; CHECK-LABEL: for function 'inline_asm_1_agpr_virtreg_output':
; CHECK: DIVERGENT: %vgpr = call i32 asm "; def $0", "=a"()
define i32 @inline_asm_1_agpr_virtreg_output() {
  %vgpr = call i32 asm "; def $0", "=a"()
  ret i32 %vgpr
}

; CHECK-LABEL: for function 'inline_asm_1_agpr_physreg_output':
; CHECK: DIVERGENT: %vgpr = call i32 asm "; def a0", "={a0}"()
define i32 @inline_asm_1_agpr_physreg_output() {
  %vgpr = call i32 asm "; def a0", "={a0}"()
  ret i32 %vgpr
}

; CHECK-LABEL: for function 'inline_asm_2_sgpr_virtreg_output':
; CHECK-NOT: DIVERGENT
define void @inline_asm_2_sgpr_virtreg_output() {
  %asm = call { i32, i32 } asm "; def $0, $1", "=s,=s"()
  %sgpr0 = extractvalue { i32, i32 } %asm, 0
  %sgpr1 = extractvalue { i32, i32 } %asm, 1
  store i32 %sgpr0, ptr addrspace(1) undef
  store i32 %sgpr1, ptr addrspace(1) undef
  ret void
}

; One output is SGPR, one is VGPR. Infer divergent for the aggregate, but uniform on the SGPR extract
; CHECK-LABEL: for function 'inline_asm_sgpr_vgpr_virtreg_output':
; CHECK: DIVERGENT:       %asm = call { i32, i32 } asm "; def $0, $1", "=s,=v"()
; CHECK-NEXT: {{^[ \t]+}}%sgpr = extractvalue { i32, i32 } %asm, 0
; CHECK-NEXT: DIVERGENT:       %vgpr = extractvalue { i32, i32 } %asm, 1
define void @inline_asm_sgpr_vgpr_virtreg_output() {
  %asm = call { i32, i32 } asm "; def $0, $1", "=s,=v"()
  %sgpr = extractvalue { i32, i32 } %asm, 0
  %vgpr = extractvalue { i32, i32 } %asm, 1
  store i32 %sgpr, ptr addrspace(1) undef
  store i32 %vgpr, ptr addrspace(1) undef
  ret void
}

; CHECK-LABEL: for function 'inline_asm_vgpr_sgpr_virtreg_output':
; CHECK: DIVERGENT:       %asm = call { i32, i32 } asm "; def $0, $1", "=v,=s"()
; CHECK-NEXT: DIVERGENT:       %vgpr = extractvalue { i32, i32 } %asm, 0
; CHECK-NEXT: {{^[ \t]+}}%sgpr = extractvalue { i32, i32 } %asm, 1
define void @inline_asm_vgpr_sgpr_virtreg_output() {
  %asm = call { i32, i32 } asm "; def $0, $1", "=v,=s"()
  %vgpr = extractvalue { i32, i32 } %asm, 0
  %sgpr = extractvalue { i32, i32 } %asm, 1
  store i32 %vgpr, ptr addrspace(1) undef
  store i32 %sgpr, ptr addrspace(1) undef
  ret void
}

; Have an extra output constraint
; CHECK-LABEL: for function 'multi_sgpr_inline_asm_output_input_constraint':
; CHECK-NOT: DIVERGENT
define void @multi_sgpr_inline_asm_output_input_constraint() {
  %asm = call { i32, i32 } asm "; def $0, $1", "=s,=s,s"(i32 1234)
  %sgpr0 = extractvalue { i32, i32 } %asm, 0
  %sgpr1 = extractvalue { i32, i32 } %asm, 1
  store i32 %sgpr0, ptr addrspace(1) undef
  store i32 %sgpr1, ptr addrspace(1) undef
  ret void
}

; CHECK-LABEL: for function 'inline_asm_vgpr_sgpr_virtreg_output_input_constraint':
; CHECK: DIVERGENT:       %asm = call { i32, i32 } asm "; def $0, $1", "=v,=s,v"(i32 1234)
; CHECK-NEXT: DIVERGENT:       %vgpr = extractvalue { i32, i32 } %asm, 0
; CHECK-NEXT: {{^[ \t]+}}%sgpr = extractvalue { i32, i32 } %asm, 1
define void @inline_asm_vgpr_sgpr_virtreg_output_input_constraint() {
  %asm = call { i32, i32 } asm "; def $0, $1", "=v,=s,v"(i32 1234)
  %vgpr = extractvalue { i32, i32 } %asm, 0
  %sgpr = extractvalue { i32, i32 } %asm, 1
  store i32 %vgpr, ptr addrspace(1) undef
  store i32 %sgpr, ptr addrspace(1) undef
  ret void
}