Skip to content

Commit 0611cf6

Browse files
committed
fixup! [AMDGPU] Check vector sizes for physical register constraints in inline asm
1 parent 888bb39 commit 0611cf6

File tree

2 files changed

+287
-112
lines changed

2 files changed

+287
-112
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
; RUN: not llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s 2>&1 | FileCheck -check-prefix=ERR %s
2+
3+
; Diagnose register constraints that are not wide enough.
4+
5+
; ERR: error: couldn't allocate output register for constraint '{v[8:15]}'
6+
define <9 x i32> @inline_asm_9xi32_in_8v_def() {
7+
%asm = call <9 x i32> asm sideeffect "; def $0", "={v[8:15]}"()
8+
ret <9 x i32> %asm
9+
}
10+
11+
; ERR: error: couldn't allocate input reg for constraint '{v[8:15]}'
12+
define void @inline_asm_9xi32_in_8v_use(<9 x i32> %val) {
13+
call void asm sideeffect "; use $0", "{v[8:15]}"(<9 x i32> %val)
14+
ret void
15+
}
16+
17+
; ERR: error: couldn't allocate output register for constraint '{s[8:15]}'
18+
define <9 x i32> @inline_asm_9xi32_in_8s_def() {
19+
%asm = call <9 x i32> asm sideeffect "; def $0", "={s[8:15]}"()
20+
ret <9 x i32> %asm
21+
}
22+
23+
24+
; Diagnose register constraints that are too wide.
25+
26+
; ERR: error: couldn't allocate output register for constraint '{v[8:16]}'
27+
define <8 x i32> @inline_asm_8xi32_in_9v_def() {
28+
%asm = call <8 x i32> asm sideeffect "; def $0", "={v[8:16]}"()
29+
ret <8 x i32> %asm
30+
}
31+
32+
; ERR: error: couldn't allocate input reg for constraint '{v[8:16]}'
33+
define void @inline_asm_8xi32_in_9v_use(<8 x i32> %val) {
34+
call void asm sideeffect "; use $0", "{v[8:16]}"(<8 x i32> %val)
35+
ret void
36+
}
37+
38+
; ERR: error: couldn't allocate output register for constraint '{s[8:16]}'
39+
define <8 x i32> @inline_asm_8xi32_in_9s_def() {
40+
%asm = call <8 x i32> asm sideeffect "; def $0", "={s[8:16]}"()
41+
ret <8 x i32> %asm
42+
}
43+
44+
45+
; Diagnose mismatched scalars with register ranges
46+
47+
; ERR: error: couldn't allocate output register for constraint '{s[4:5]}'
48+
define void @inline_asm_scalar_read_too_wide() {
49+
%asm = call i32 asm sideeffect "; def $0 ", "={s[4:5]}"()
50+
ret void
51+
}
52+
53+
; ERR: error: couldn't allocate output register for constraint '{s[4:4]}'
54+
define void @inline_asm_scalar_read_too_narrow() {
55+
%asm = call i64 asm sideeffect "; def $0 ", "={s[4:4]}"()
56+
ret void
57+
}
58+
59+
; Single registers for vector types that are too wide or too narrow should be
60+
; diagnosed.
61+
62+
; ERR: error: couldn't allocate input reg for constraint '{v8}'
63+
define void @inline_asm_4xi32_in_v_use(<4 x i32> %val) {
64+
call void asm sideeffect "; use $0", "{v8}"(<4 x i32> %val)
65+
ret void
66+
}
67+
68+
; ERR: error: couldn't allocate output register for constraint '{v8}'
69+
define <4 x i32> @inline_asm_4xi32_in_v_def() {
70+
%asm = call <4 x i32> asm sideeffect "; def $0", "={v8}"()
71+
ret <4 x i32> %asm
72+
}
73+
74+
; ERR: error: couldn't allocate output register for constraint '{s8}'
75+
define <4 x i32> @inline_asm_4xi32_in_s_def() {
76+
%asm = call <4 x i32> asm sideeffect "; def $0", "={s8}"()
77+
ret <4 x i32> %asm
78+
}
79+
80+
; ERR: error: couldn't allocate input reg for constraint '{v8}'
81+
define void @inline_asm_2xi8_in_v_use(<2 x i8> %val) {
82+
call void asm sideeffect "; use $0", "{v8}"(<2 x i8> %val)
83+
ret void
84+
}
85+
86+
; ERR: error: couldn't allocate input reg for constraint 'v'
87+
define void @inline_asm_2xi8_in_vvirt_use(<2 x i8> %val) {
88+
call void asm sideeffect "; use $0", "v"(<2 x i8> %val)
89+
ret void
90+
}
91+
92+
; ERR: error: couldn't allocate output register for constraint '{v8}'
93+
define <2 x i8> @inline_asm_2xi8_in_v_def() {
94+
%asm = call <2 x i8> asm sideeffect "; def $0", "={v8}"()
95+
ret <2 x i8> %asm
96+
}
97+
98+
; ERR: error: couldn't allocate output register for constraint 'v'
99+
define <2 x i8> @inline_asm_2xi8_in_vvirt_def() {
100+
%asm = call <2 x i8> asm sideeffect "; def $0", "=v"()
101+
ret <2 x i8> %asm
102+
}
103+
104+
; ERR: error: couldn't allocate output register for constraint '{s8}'
105+
define <2 x i8> @inline_asm_2xi8_in_s_def() {
106+
%asm = call <2 x i8> asm sideeffect "; def $0", "={s8}"()
107+
ret <2 x i8> %asm
108+
}
109+
110+
; ERR: error: couldn't allocate output register for constraint 's'
111+
define <2 x i8> @inline_asm_2xi8_in_svirt_def() {
112+
%asm = call <2 x i8> asm sideeffect "; def $0", "=s"()
113+
ret <2 x i8> %asm
114+
}

0 commit comments

Comments
 (0)