| 1 |
// RUN: %clang_cc1 -O2 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu | FileCheck %s |
| 2 |
|
| 3 |
int test_cca(long nr, volatile long *addr) { |
| 4 |
//CHECK-LABEL: @test_cca |
| 5 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@cca},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 6 |
int x; |
| 7 |
asm("cmp %2,%1" |
| 8 |
: "=@cca"(x), "=m"(*(volatile long *)(addr)) |
| 9 |
: "r"(nr) |
| 10 |
: "cc"); |
| 11 |
if (x) |
| 12 |
return 0; |
| 13 |
return 1; |
| 14 |
} |
| 15 |
|
| 16 |
int test_ccae(long nr, volatile long *addr) { |
| 17 |
//CHECK-LABEL: @test_ccae |
| 18 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccae},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 19 |
int x; |
| 20 |
asm("cmp %2,%1" |
| 21 |
: "=@ccae"(x), "=m"(*(volatile long *)(addr)) |
| 22 |
: "r"(nr) |
| 23 |
: "cc"); |
| 24 |
if (x) |
| 25 |
return 0; |
| 26 |
return 1; |
| 27 |
} |
| 28 |
|
| 29 |
int test_ccb(long nr, volatile long *addr) { |
| 30 |
//CHECK-LABEL: @test_ccb |
| 31 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccb},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 32 |
int x; |
| 33 |
asm("cmp %2,%1" |
| 34 |
: "=@ccb"(x), "=m"(*(volatile long *)(addr)) |
| 35 |
: "r"(nr) |
| 36 |
: "cc"); |
| 37 |
if (x) |
| 38 |
return 0; |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
int test_ccbe(long nr, volatile long *addr) { |
| 43 |
//CHECK-LABEL: @test_ccbe |
| 44 |
//CHECK: tail call i32 asm "cmp $2,$1", "={@ccbe},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 45 |
int x; |
| 46 |
asm("cmp %2,%1" |
| 47 |
: "=@ccbe"(x), "=m"(*(volatile long *)(addr)) |
| 48 |
: "r"(nr) |
| 49 |
: "cc"); |
| 50 |
if (x) |
| 51 |
return 0; |
| 52 |
return 1; |
| 53 |
} |
| 54 |
|
| 55 |
int test_ccc(long nr, volatile long *addr) { |
| 56 |
//CHECK-LABEL: @test_ccc |
| 57 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccc},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 58 |
int x; |
| 59 |
asm("cmp %2,%1" |
| 60 |
: "=@ccc"(x), "=m"(*(volatile long *)(addr)) |
| 61 |
: "r"(nr) |
| 62 |
: "cc"); |
| 63 |
if (x) |
| 64 |
return 0; |
| 65 |
return 1; |
| 66 |
} |
| 67 |
|
| 68 |
int test_cce(long nr, volatile long *addr) { |
| 69 |
//CHECK-LABEL: @test_cce |
| 70 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@cce},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 71 |
int x; |
| 72 |
asm("cmp %2,%1" |
| 73 |
: "=@cce"(x), "=m"(*(volatile long *)(addr)) |
| 74 |
: "r"(nr) |
| 75 |
: "cc"); |
| 76 |
if (x) |
| 77 |
return 0; |
| 78 |
return 1; |
| 79 |
} |
| 80 |
|
| 81 |
int test_ccz(long nr, volatile long *addr) { |
| 82 |
//CHECK-LABEL: @test_ccz |
| 83 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccz},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 84 |
int x; |
| 85 |
asm("cmp %2,%1" |
| 86 |
: "=@ccz"(x), "=m"(*(volatile long *)(addr)) |
| 87 |
: "r"(nr) |
| 88 |
: "cc"); |
| 89 |
if (x) |
| 90 |
return 0; |
| 91 |
return 1; |
| 92 |
} |
| 93 |
|
| 94 |
int test_ccg(long nr, volatile long *addr) { |
| 95 |
//CHECK-LABEL: @test_ccg |
| 96 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccg},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 97 |
int x; |
| 98 |
asm("cmp %2,%1" |
| 99 |
: "=@ccg"(x), "=m"(*(volatile long *)(addr)) |
| 100 |
: "r"(nr) |
| 101 |
: "cc"); |
| 102 |
if (x) |
| 103 |
return 0; |
| 104 |
return 1; |
| 105 |
} |
| 106 |
|
| 107 |
int test_ccge(long nr, volatile long *addr) { |
| 108 |
//CHECK-LABEL: @test_ccge |
| 109 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccge},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 110 |
int x; |
| 111 |
asm("cmp %2,%1" |
| 112 |
: "=@ccge"(x), "=m"(*(volatile long *)(addr)) |
| 113 |
: "r"(nr) |
| 114 |
: "cc"); |
| 115 |
if (x) |
| 116 |
return 0; |
| 117 |
return 1; |
| 118 |
} |
| 119 |
|
| 120 |
int test_ccl(long nr, volatile long *addr) { |
| 121 |
//CHECK-LABEL: @test_ccl |
| 122 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccl},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 123 |
int x; |
| 124 |
asm("cmp %2,%1" |
| 125 |
: "=@ccl"(x), "=m"(*(volatile long *)(addr)) |
| 126 |
: "r"(nr) |
| 127 |
: "cc"); |
| 128 |
if (x) |
| 129 |
return 0; |
| 130 |
return 1; |
| 131 |
} |
| 132 |
|
| 133 |
int test_ccle(long nr, volatile long *addr) { |
| 134 |
//CHECK-LABEL: @test_ccle |
| 135 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccle},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 136 |
int x; |
| 137 |
asm("cmp %2,%1" |
| 138 |
: "=@ccle"(x), "=m"(*(volatile long *)(addr)) |
| 139 |
: "r"(nr) |
| 140 |
: "cc"); |
| 141 |
if (x) |
| 142 |
return 0; |
| 143 |
return 1; |
| 144 |
} |
| 145 |
|
| 146 |
int test_ccna(long nr, volatile long *addr) { |
| 147 |
//CHECK-LABEL: @test_ccna |
| 148 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccna},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 149 |
int x; |
| 150 |
asm("cmp %2,%1" |
| 151 |
: "=@ccna"(x), "=m"(*(volatile long *)(addr)) |
| 152 |
: "r"(nr) |
| 153 |
: "cc"); |
| 154 |
if (x) |
| 155 |
return 0; |
| 156 |
return 1; |
| 157 |
} |
| 158 |
|
| 159 |
int test_ccnae(long nr, volatile long *addr) { |
| 160 |
//CHECK-LABEL: @test_ccnae |
| 161 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnae},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 162 |
int x; |
| 163 |
asm("cmp %2,%1" |
| 164 |
: "=@ccnae"(x), "=m"(*(volatile long *)(addr)) |
| 165 |
: "r"(nr) |
| 166 |
: "cc"); |
| 167 |
if (x) |
| 168 |
return 0; |
| 169 |
return 1; |
| 170 |
} |
| 171 |
|
| 172 |
int test_ccnb(long nr, volatile long *addr) { |
| 173 |
//CHECK-LABEL: @test_ccnb |
| 174 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnb},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 175 |
int x; |
| 176 |
asm("cmp %2,%1" |
| 177 |
: "=@ccnb"(x), "=m"(*(volatile long *)(addr)) |
| 178 |
: "r"(nr) |
| 179 |
: "cc"); |
| 180 |
if (x) |
| 181 |
return 0; |
| 182 |
return 1; |
| 183 |
} |
| 184 |
|
| 185 |
int test_ccnbe(long nr, volatile long *addr) { |
| 186 |
//CHECK-LABEL: @test_ccnbe |
| 187 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnbe},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 188 |
int x; |
| 189 |
asm("cmp %2,%1" |
| 190 |
: "=@ccnbe"(x), "=m"(*(volatile long *)(addr)) |
| 191 |
: "r"(nr) |
| 192 |
: "cc"); |
| 193 |
if (x) |
| 194 |
return 0; |
| 195 |
return 1; |
| 196 |
} |
| 197 |
|
| 198 |
int test_ccnc(long nr, volatile long *addr) { |
| 199 |
//CHECK-LABEL: @test_ccnc |
| 200 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnc},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 201 |
int x; |
| 202 |
asm("cmp %2,%1" |
| 203 |
: "=@ccnc"(x), "=m"(*(volatile long *)(addr)) |
| 204 |
: "r"(nr) |
| 205 |
: "cc"); |
| 206 |
if (x) |
| 207 |
return 0; |
| 208 |
return 1; |
| 209 |
} |
| 210 |
|
| 211 |
int test_ccne(long nr, volatile long *addr) { |
| 212 |
//CHECK-LABEL: @test_ccne |
| 213 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccne},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 214 |
int x; |
| 215 |
asm("cmp %2,%1" |
| 216 |
: "=@ccne"(x), "=m"(*(volatile long *)(addr)) |
| 217 |
: "r"(nr) |
| 218 |
: "cc"); |
| 219 |
if (x) |
| 220 |
return 0; |
| 221 |
return 1; |
| 222 |
} |
| 223 |
|
| 224 |
int test_ccnz(long nr, volatile long *addr) { |
| 225 |
//CHECK-LABEL: @test_ccnz |
| 226 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnz},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 227 |
int x; |
| 228 |
asm("cmp %2,%1" |
| 229 |
: "=@ccnz"(x), "=m"(*(volatile long *)(addr)) |
| 230 |
: "r"(nr) |
| 231 |
: "cc"); |
| 232 |
if (x) |
| 233 |
return 0; |
| 234 |
return 1; |
| 235 |
} |
| 236 |
|
| 237 |
int test_ccng(long nr, volatile long *addr) { |
| 238 |
//CHECK-LABEL: @test_ccng |
| 239 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccng},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 240 |
int x; |
| 241 |
asm("cmp %2,%1" |
| 242 |
: "=@ccng"(x), "=m"(*(volatile long *)(addr)) |
| 243 |
: "r"(nr) |
| 244 |
: "cc"); |
| 245 |
if (x) |
| 246 |
return 0; |
| 247 |
return 1; |
| 248 |
} |
| 249 |
|
| 250 |
int test_ccnge(long nr, volatile long *addr) { |
| 251 |
//CHECK-LABEL: @test_ccnge |
| 252 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnge},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 253 |
int x; |
| 254 |
asm("cmp %2,%1" |
| 255 |
: "=@ccnge"(x), "=m"(*(volatile long *)(addr)) |
| 256 |
: "r"(nr) |
| 257 |
: "cc"); |
| 258 |
if (x) |
| 259 |
return 0; |
| 260 |
return 1; |
| 261 |
} |
| 262 |
|
| 263 |
int test_ccnl(long nr, volatile long *addr) { |
| 264 |
//CHECK-LABEL: @test_ccnl |
| 265 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnl},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 266 |
int x; |
| 267 |
asm("cmp %2,%1" |
| 268 |
: "=@ccnl"(x), "=m"(*(volatile long *)(addr)) |
| 269 |
: "r"(nr) |
| 270 |
: "cc"); |
| 271 |
if (x) |
| 272 |
return 0; |
| 273 |
return 1; |
| 274 |
} |
| 275 |
|
| 276 |
int test_ccnle(long nr, volatile long *addr) { |
| 277 |
//CHECK-LABEL: @test_ccnle |
| 278 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnle},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 279 |
int x; |
| 280 |
asm("cmp %2,%1" |
| 281 |
: "=@ccnle"(x), "=m"(*(volatile long *)(addr)) |
| 282 |
: "r"(nr) |
| 283 |
: "cc"); |
| 284 |
if (x) |
| 285 |
return 0; |
| 286 |
return 1; |
| 287 |
} |
| 288 |
|
| 289 |
int test_ccno(long nr, volatile long *addr) { |
| 290 |
//CHECK-LABEL: @test_ccno |
| 291 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccno},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 292 |
int x; |
| 293 |
asm("cmp %2,%1" |
| 294 |
: "=@ccno"(x), "=m"(*(volatile long *)(addr)) |
| 295 |
: "r"(nr) |
| 296 |
: "cc"); |
| 297 |
if (x) |
| 298 |
return 0; |
| 299 |
return 1; |
| 300 |
} |
| 301 |
|
| 302 |
int test_ccnp(long nr, volatile long *addr) { |
| 303 |
//CHECK-LABEL: @test_ccnp |
| 304 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccnp},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 305 |
int x; |
| 306 |
asm("cmp %2,%1" |
| 307 |
: "=@ccnp"(x), "=m"(*(volatile long *)(addr)) |
| 308 |
: "r"(nr) |
| 309 |
: "cc"); |
| 310 |
if (x) |
| 311 |
return 0; |
| 312 |
return 1; |
| 313 |
} |
| 314 |
|
| 315 |
int test_ccns(long nr, volatile long *addr) { |
| 316 |
//CHECK-LABEL: @test_ccns |
| 317 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccns},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 318 |
int x; |
| 319 |
asm("cmp %2,%1" |
| 320 |
: "=@ccns"(x), "=m"(*(volatile long *)(addr)) |
| 321 |
: "r"(nr) |
| 322 |
: "cc"); |
| 323 |
if (x) |
| 324 |
return 0; |
| 325 |
return 1; |
| 326 |
} |
| 327 |
|
| 328 |
int test_cco(long nr, volatile long *addr) { |
| 329 |
//CHECK-LABEL: @test_cco |
| 330 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@cco},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 331 |
int x; |
| 332 |
asm("cmp %2,%1" |
| 333 |
: "=@cco"(x), "=m"(*(volatile long *)(addr)) |
| 334 |
: "r"(nr) |
| 335 |
: "cc"); |
| 336 |
if (x) |
| 337 |
return 0; |
| 338 |
return 1; |
| 339 |
} |
| 340 |
|
| 341 |
int test_ccp(long nr, volatile long *addr) { |
| 342 |
//CHECK-LABEL: @test_ccp |
| 343 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccp},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 344 |
int x; |
| 345 |
asm("cmp %2,%1" |
| 346 |
: "=@ccp"(x), "=m"(*(volatile long *)(addr)) |
| 347 |
: "r"(nr) |
| 348 |
: "cc"); |
| 349 |
if (x) |
| 350 |
return 0; |
| 351 |
return 1; |
| 352 |
} |
| 353 |
|
| 354 |
int test_ccs(long nr, volatile long *addr) { |
| 355 |
//CHECK-LABEL: @test_ccs |
| 356 |
//CHECK: = tail call i32 asm "cmp $2,$1", "={@ccs},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 357 |
int x; |
| 358 |
asm("cmp %2,%1" |
| 359 |
: "=@ccs"(x), "=m"(*(volatile long *)(addr)) |
| 360 |
: "r"(nr) |
| 361 |
: "cc"); |
| 362 |
if (x) |
| 363 |
return 0; |
| 364 |
return 1; |
| 365 |
} |
| 366 |
|
| 367 |
_Bool check_no_clobber_conflicts(void) { |
| 368 |
//CHECK-LABEL: @check_no_clobber_conflicts |
| 369 |
//CHECK: = tail call i8 asm "", "={@cce},~{cx},~{dirflag},~{fpsr},~{flags}"() |
| 370 |
_Bool b; |
| 371 |
asm("" |
| 372 |
: "=@cce"(b) |
| 373 |
: |
| 374 |
: "cx"); |
| 375 |
return b; |
| 376 |
} |
| 377 |
|
| 378 |
int test_assume_boolean_flag(long nr, volatile long *addr) { |
| 379 |
//CHECK-LABEL: @test_assume_boolean_flag |
| 380 |
//CHECK: %0 = tail call { i32, i32 } asm "cmp $2,$1", "={@cca},={@ccae},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) |
| 381 |
//CHECK: [[RES1:%.*]] = extractvalue { i32, i32 } %0, 0 |
| 382 |
//CHECK: [[RES2:%.*]] = extractvalue { i32, i32 } %0, 1 |
| 383 |
//CHECK: %1 = icmp ult i32 [[RES1]], 2 |
| 384 |
//CHECK: tail call void @llvm.assume(i1 %1) |
| 385 |
//CHECK: %2 = icmp ult i32 [[RES2]], 2 |
| 386 |
//CHECK: tail call void @llvm.assume(i1 %2) |
| 387 |
int x,y; |
| 388 |
asm("cmp %2,%1" |
| 389 |
: "=@cca"(x), "=@ccae"(y), "=m"(*(volatile long *)(addr)) |
| 390 |
: "r"(nr) |
| 391 |
: "cc"); |
| 392 |
if (x && y) |
| 393 |
return 0; |
| 394 |
return 1; |
| 395 |
} |