0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 ; Positive test for inline register constraints
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 ;
|
100
|
3 ; RUN: llc -no-integrated-as -march=mipsel < %s | \
|
|
4 ; RUN: FileCheck -check-prefix=ALL -check-prefix=LE32 -check-prefix=GAS %s
|
|
5 ; RUN: llc -no-integrated-as -march=mips < %s | \
|
|
6 ; RUN: FileCheck -check-prefix=ALL -check-prefix=BE32 -check-prefix=GAS %s
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 %union.u_tag = type { i64 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 %struct.anon = type { i32, i32 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 @uval = common global %union.u_tag zeroinitializer, align 8
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 ; X with -3
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 define i32 @constraint_X() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 entry:
|
100
|
15 ; ALL-LABEL: constraint_X:
|
|
16 ; ALL: #APP
|
|
17 ; GAS: addiu ${{[0-9]+}}, ${{[0-9]+}}, 0xfffffffffffffffd
|
|
18 ; ALL: #NO_APP
|
|
19 tail call i32 asm sideeffect "addiu $0, $1, ${2:X}", "=r,r,I"(i32 7, i32 -3) ;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 ; x with -3
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 define i32 @constraint_x() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 entry:
|
100
|
26 ; ALL-LABEL: constraint_x:
|
|
27 ; ALL: #APP
|
|
28 ; GAS: addiu ${{[0-9]+}}, ${{[0-9]+}}, 0xfffd
|
|
29 ; ALL: #NO_APP
|
|
30 tail call i32 asm sideeffect "addiu $0, $1, ${2:x}", "=r,r,I"(i32 7, i32 -3) ;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 ; d with -3
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 define i32 @constraint_d() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 entry:
|
100
|
37 ; ALL-LABEL: constraint_d:
|
|
38 ; ALL: #APP
|
|
39 ; ALL: addiu ${{[0-9]+}}, ${{[0-9]+}}, -3
|
|
40 ; ALL: #NO_APP
|
|
41 tail call i32 asm sideeffect "addiu $0, $1, ${2:d}", "=r,r,I"(i32 7, i32 -3) ;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 ; m with -3
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 define i32 @constraint_m() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 entry:
|
100
|
48 ; ALL-LABEL: constraint_m:
|
|
49 ; ALL: #APP
|
|
50 ; ALL: addiu ${{[0-9]+}}, ${{[0-9]+}}, -4
|
|
51 ; ALL: #NO_APP
|
|
52 tail call i32 asm sideeffect "addiu $0, $1, ${2:m}", "=r,r,I"(i32 7, i32 -3) ;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 ; z with -3
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 define i32 @constraint_z() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 entry:
|
100
|
59 ; ALL-LABEL: constraint_z:
|
|
60 ; ALL: #APP
|
|
61 ; ALL: addiu ${{[0-9]+}}, ${{[0-9]+}}, -3
|
|
62 ; ALL: #NO_APP
|
|
63 tail call i32 asm sideeffect "addiu $0, $1, ${2:z}", "=r,r,I"(i32 7, i32 -3) ;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 ; z with 0
|
100
|
66 ; ALL: #APP
|
|
67 ; GAS: addiu ${{[0-9]+}}, ${{[0-9]+}}, $0
|
|
68 ; ALL: #NO_APP
|
|
69 tail call i32 asm sideeffect "addiu $0, $1, ${2:z}", "=r,r,I"(i32 7, i32 0) nounwind
|
83
|
70
|
|
71 ; z with non-zero and the "r"(register) and "J"(integer zero) constraints
|
100
|
72 ; ALL: #APP
|
|
73 ; ALL: mtc0 ${{[1-9][0-9]?}}, ${{[0-9]+}}
|
|
74 ; ALL: #NO_APP
|
83
|
75 call void asm sideeffect "mtc0 ${0:z}, $$12", "Jr"(i32 7) nounwind
|
|
76
|
|
77 ; z with zero and the "r"(register) and "J"(integer zero) constraints
|
100
|
78 ; ALL: #APP
|
|
79 ; ALL: mtc0 $0, ${{[0-9]+}}
|
|
80 ; ALL: #NO_APP
|
83
|
81 call void asm sideeffect "mtc0 ${0:z}, $$12", "Jr"(i32 0) nounwind
|
|
82
|
|
83 ; z with non-zero and just the "r"(register) constraint
|
100
|
84 ; ALL: #APP
|
|
85 ; ALL: mtc0 ${{[1-9][0-9]?}}, ${{[0-9]+}}
|
|
86 ; ALL: #NO_APP
|
83
|
87 call void asm sideeffect "mtc0 ${0:z}, $$12", "r"(i32 7) nounwind
|
|
88
|
|
89 ; z with zero and just the "r"(register) constraint
|
|
90 ; FIXME: Check for $0, instead of other registers.
|
|
91 ; We should be using $0 directly in this case, not real registers.
|
|
92 ; When the materialization of 0 gets fixed, this test will fail.
|
100
|
93 ; ALL: #APP
|
|
94 ; ALL: mtc0 ${{[1-9][0-9]?}}, ${{[0-9]+}}
|
|
95 ; ALL: #NO_APP
|
83
|
96 call void asm sideeffect "mtc0 ${0:z}, $$12", "r"(i32 0) nounwind
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99
|
100
|
100 ; A long long in 32 bit mode (use to assert)
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 define i32 @constraint_longlong() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 entry:
|
100
|
103 ; ALL-LABEL: constraint_longlong:
|
|
104 ; ALL: #APP
|
|
105 ; ALL: addiu ${{[0-9]+}}, ${{[0-9]+}}, 3
|
|
106 ; ALL: #NO_APP
|
|
107 tail call i64 asm sideeffect "addiu $0, $1, $2 \0A\09", "=r,r,X"(i64 1229801703532086340, i64 3) nounwind
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110
|
100
|
111 ; In little endian the source reg will be 4 bytes into the long long
|
|
112 ; In big endian the source reg will also be 4 bytes into the long long
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 define i32 @constraint_D() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 entry:
|
100
|
115 ; ALL-LABEL: constraint_D:
|
|
116 ; ALL: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
|
|
117 ; ALL: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
|
|
118 ; ALL: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
|
|
119 ; ALL: #APP
|
|
120 ; LE32: or ${{[0-9]+}}, $[[SECOND]], ${{[0-9]+}}
|
|
121 ; BE32: or ${{[0-9]+}}, $[[SECOND]], ${{[0-9]+}}
|
|
122 ; ALL: #NO_APP
|
95
|
123 %bosco = load i64, i64* getelementptr inbounds (%union.u_tag, %union.u_tag* @uval, i32 0, i32 0), align 8
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 %trunc1 = trunc i64 %bosco to i32
|
100
|
125 tail call i32 asm sideeffect "or $0, ${1:D}, $2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128
|
100
|
129 ; In little endian the source reg will be 0 bytes into the long long
|
|
130 ; In big endian the source reg will be 4 bytes into the long long
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 define i32 @constraint_L() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 entry:
|
100
|
133 ; ALL-LABEL: constraint_L:
|
|
134 ; ALL: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
|
|
135 ; ALL: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
|
|
136 ; ALL: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
|
|
137 ; ALL: #APP
|
|
138 ; LE32: or ${{[0-9]+}}, $[[FIRST]], ${{[0-9]+}}
|
|
139 ; BE32: or ${{[0-9]+}}, $[[SECOND]], ${{[0-9]+}}
|
|
140 ; ALL: #NO_APP
|
95
|
141 %bosco = load i64, i64* getelementptr inbounds (%union.u_tag, %union.u_tag* @uval, i32 0, i32 0), align 8
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 %trunc1 = trunc i64 %bosco to i32
|
100
|
143 tail call i32 asm sideeffect "or $0, ${1:L}, $2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146
|
100
|
147 ; In little endian the source reg will be 4 bytes into the long long
|
|
148 ; In big endian the source reg will be 0 bytes into the long long
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 define i32 @constraint_M() nounwind {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 entry:
|
100
|
151 ; ALL-LABEL: constraint_M:
|
|
152 ; ALL: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
|
|
153 ; ALL: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
|
|
154 ; ALL: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
|
|
155 ; ALL: #APP
|
|
156 ; LE32: or ${{[0-9]+}}, $[[SECOND]], ${{[0-9]+}}
|
|
157 ; BE32: or ${{[0-9]+}}, $[[FIRST]], ${{[0-9]+}}
|
|
158 ; ALL: #NO_APP
|
95
|
159 %bosco = load i64, i64* getelementptr inbounds (%union.u_tag, %union.u_tag* @uval, i32 0, i32 0), align 8
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 %trunc1 = trunc i64 %bosco to i32
|
100
|
161 tail call i32 asm sideeffect "or $0, ${1:M}, $2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 ret i32 0
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 }
|