1 // RUN: %clang_cc1 -triple i686 %s -emit-llvm -o - | FileCheck %s 2 // RUN: %clang_cc1 -triple x86_64 %s -emit-llvm -o - | FileCheck %s 3 // RUN: %clang_cc1 -triple arm %s -emit-llvm -o - | FileCheck %s 4 // RUN: %clang_cc1 -triple bfin %s -emit-llvm -o - | FileCheck %s 5 // RUN: %clang_cc1 -triple cellspu %s -emit-llvm -o - | FileCheck %s 6 // RUN: %clang_cc1 -triple mblaze %s -emit-llvm -o - | FileCheck %s 7 // RUN: %clang_cc1 -triple mips %s -emit-llvm -o - | FileCheck %s 8 // RUN: %clang_cc1 -triple mipsel %s -emit-llvm -o - | FileCheck %s 9 // RUN: %clang_cc1 -triple powerpc %s -emit-llvm -o - | FileCheck %s 10 // RUN: %clang_cc1 -triple powerpc64 %s -emit-llvm -o - | FileCheck %s 11 // RUN: %clang_cc1 -triple s390x %s -emit-llvm -o - | FileCheck %s 12 // RUN: %clang_cc1 -triple sparc %s -emit-llvm -o - | FileCheck %s 13 // RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s 14 15 int mout0; 16 int min1; 17 int marray[2]; 18 19 // CHECK: @single_m 20 void single_m() 21 { 22 // CHECK: call void asm "foo $1,$0", "=*m,*m[[CLOBBERS:[a-zA-Z0-9@%{},~_ ]*\"]](i32* {{[a-zA-Z0-9@%]+}}, i32* {{[a-zA-Z0-9@%]+}}) 23 asm("foo %1,%0" : "=m" (mout0) : "m" (min1)); 24 } 25 26 // CHECK: @single_o 27 void single_o() 28 { 29 register int out0 = 0; 30 register int index = 1; 31 // Doesn't really do an offset... 32 //asm("foo %1, %2,%0" : "=r" (out0) : "o" (min1)); 33 } 34 35 // CHECK: @single_V 36 void single_V() 37 { 38 // asm("foo %1,%0" : "=m" (mout0) : "V" (min1)); 39 } 40 41 // CHECK: @single_lt 42 void single_lt() 43 { 44 register int out0 = 0; 45 register int in1 = 1; 46 // CHECK: call i32 asm "foo $1,$0", "=r,<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 47 asm("foo %1,%0" : "=r" (out0) : "<r" (in1)); 48 // CHECK: call i32 asm "foo $1,$0", "=r,r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 49 asm("foo %1,%0" : "=r" (out0) : "r<" (in1)); 50 } 51 52 // CHECK: @single_gt 53 void single_gt() 54 { 55 register int out0 = 0; 56 register int in1 = 1; 57 // CHECK: call i32 asm "foo $1,$0", "=r,>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 58 asm("foo %1,%0" : "=r" (out0) : ">r" (in1)); 59 // CHECK: call i32 asm "foo $1,$0", "=r,r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 60 asm("foo %1,%0" : "=r" (out0) : "r>" (in1)); 61 } 62 63 // CHECK: @single_r 64 void single_r() 65 { 66 register int out0 = 0; 67 register int in1 = 1; 68 // CHECK: call i32 asm "foo $1,$0", "=r,r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 69 asm("foo %1,%0" : "=r" (out0) : "r" (in1)); 70 } 71 72 // CHECK: @single_i 73 void single_i() 74 { 75 register int out0 = 0; 76 // CHECK: call i32 asm "foo $1,$0", "=r,i[[CLOBBERS]](i32 1) 77 asm("foo %1,%0" : "=r" (out0) : "i" (1)); 78 } 79 80 // CHECK: @single_n 81 void single_n() 82 { 83 register int out0 = 0; 84 // CHECK: call i32 asm "foo $1,$0", "=r,n[[CLOBBERS]](i32 1) 85 asm("foo %1,%0" : "=r" (out0) : "n" (1)); 86 } 87 88 // CHECK: @single_E 89 void single_E() 90 { 91 register double out0 = 0.0; 92 // CHECK: call double asm "foo $1,$0", "=r,E[[CLOBBERS]](double {{[0-9.eE+-]+}}) 93 asm("foo %1,%0" : "=r" (out0) : "E" (1.0e+01)); 94 } 95 96 // CHECK: @single_F 97 void single_F() 98 { 99 register double out0 = 0.0; 100 // CHECK: call double asm "foo $1,$0", "=r,F[[CLOBBERS]](double {{[0-9.eE+-]+}}) 101 asm("foo %1,%0" : "=r" (out0) : "F" (1.0)); 102 } 103 104 // CHECK: @single_s 105 void single_s() 106 { 107 register int out0 = 0; 108 //asm("foo %1,%0" : "=r" (out0) : "s" (single_s)); 109 } 110 111 // CHECK: @single_g 112 void single_g() 113 { 114 register int out0 = 0; 115 register int in1 = 1; 116 // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 117 asm("foo %1,%0" : "=r" (out0) : "g" (in1)); 118 // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 119 asm("foo %1,%0" : "=r" (out0) : "g" (min1)); 120 // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 1) 121 asm("foo %1,%0" : "=r" (out0) : "g" (1)); 122 } 123 124 // CHECK: @single_X 125 void single_X() 126 { 127 register int out0 = 0; 128 register int in1 = 1; 129 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 130 asm("foo %1,%0" : "=r" (out0) : "X" (in1)); 131 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 132 asm("foo %1,%0" : "=r" (out0) : "X" (min1)); 133 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 1) 134 asm("foo %1,%0" : "=r" (out0) : "X" (1)); 135 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0)) 136 asm("foo %1,%0" : "=r" (out0) : "X" (marray)); 137 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}}) 138 asm("foo %1,%0" : "=r" (out0) : "X" (1.0e+01)); 139 // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}}) 140 asm("foo %1,%0" : "=r" (out0) : "X" (1.0)); 141 } 142 143 // CHECK: @single_p 144 void single_p() 145 { 146 register int out0 = 0; 147 // Constraint converted differently on different platforms moved to platform-specific. 148 // : call i32 asm "foo $1,$0", "=r,im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0)) 149 asm("foo %1,%0" : "=r" (out0) : "p" (marray)); 150 } 151 152 // CHECK: @multi_m 153 void multi_m() 154 { 155 // CHECK: call void asm "foo $1,$0", "=*m|r,m|r[[CLOBBERS]](i32* {{[a-zA-Z0-9@%]+}}, i32 {{[a-zA-Z0-9@%]+}}) 156 asm("foo %1,%0" : "=m,r" (mout0) : "m,r" (min1)); 157 } 158 159 // CHECK: @multi_o 160 void multi_o() 161 { 162 register int out0 = 0; 163 register int index = 1; 164 // Doesn't really do an offset... 165 //asm("foo %1, %2,%0" : "=r,r" (out0) : "r,o" (min1)); 166 } 167 168 // CHECK: @multi_V 169 void multi_V() 170 { 171 // asm("foo %1,%0" : "=m,r" (mout0) : "r,V" (min1)); 172 } 173 174 // CHECK: @multi_lt 175 void multi_lt() 176 { 177 register int out0 = 0; 178 register int in1 = 1; 179 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 180 asm("foo %1,%0" : "=r,r" (out0) : "r,<r" (in1)); 181 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 182 asm("foo %1,%0" : "=r,r" (out0) : "r,r<" (in1)); 183 } 184 185 // CHECK: @multi_gt 186 void multi_gt() 187 { 188 register int out0 = 0; 189 register int in1 = 1; 190 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 191 asm("foo %1,%0" : "=r,r" (out0) : "r,>r" (in1)); 192 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 193 asm("foo %1,%0" : "=r,r" (out0) : "r,r>" (in1)); 194 } 195 196 // CHECK: @multi_r 197 void multi_r() 198 { 199 register int out0 = 0; 200 register int in1 = 1; 201 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|m[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 202 asm("foo %1,%0" : "=r,r" (out0) : "r,m" (in1)); 203 } 204 205 // CHECK: @multi_i 206 void multi_i() 207 { 208 register int out0 = 0; 209 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|i[[CLOBBERS]](i32 1) 210 asm("foo %1,%0" : "=r,r" (out0) : "r,i" (1)); 211 } 212 213 // CHECK: @multi_n 214 void multi_n() 215 { 216 register int out0 = 0; 217 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|n[[CLOBBERS]](i32 1) 218 asm("foo %1,%0" : "=r,r" (out0) : "r,n" (1)); 219 } 220 221 // CHECK: @multi_E 222 void multi_E() 223 { 224 register double out0 = 0.0; 225 // CHECK: call double asm "foo $1,$0", "=r|r,r|E[[CLOBBERS]](double {{[0-9.eE+-]+}}) 226 asm("foo %1,%0" : "=r,r" (out0) : "r,E" (1.0e+01)); 227 } 228 229 // CHECK: @multi_F 230 void multi_F() 231 { 232 register double out0 = 0.0; 233 // CHECK: call double asm "foo $1,$0", "=r|r,r|F[[CLOBBERS]](double {{[0-9.eE+-]+}}) 234 asm("foo %1,%0" : "=r,r" (out0) : "r,F" (1.0)); 235 } 236 237 // CHECK: @multi_s 238 void multi_s() 239 { 240 register int out0 = 0; 241 //asm("foo %1,%0" : "=r,r" (out0) : "r,s" (multi_s)); 242 } 243 244 // CHECK: @multi_g 245 void multi_g() 246 { 247 register int out0 = 0; 248 register int in1 = 1; 249 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 250 asm("foo %1,%0" : "=r,r" (out0) : "r,g" (in1)); 251 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 252 asm("foo %1,%0" : "=r,r" (out0) : "r,g" (min1)); 253 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 1) 254 asm("foo %1,%0" : "=r,r" (out0) : "r,g" (1)); 255 } 256 257 // CHECK: @multi_X 258 void multi_X() 259 { 260 register int out0 = 0; 261 register int in1 = 1; 262 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 263 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (in1)); 264 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}}) 265 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (min1)); 266 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 1) 267 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1)); 268 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0)) 269 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (marray)); 270 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}}) 271 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0e+01)); 272 // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}}) 273 asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0)); 274 } 275 276 // CHECK: @multi_p 277 void multi_p() 278 { 279 register int out0 = 0; 280 // Constraint converted differently on different platforms moved to platform-specific. 281 // : call i32 asm "foo $1,$0", "=r|r,r|im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0)) 282 asm("foo %1,%0" : "=r,r" (out0) : "r,p" (marray)); 283 } 284