[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / asm-variable.c
blob144e5f3551717448dce51524d9b331fd77dc429b
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 unsigned long long foo(unsigned long long addr, unsigned long long a0,
4 unsigned long long a1, unsigned long long a2,
5 unsigned long long a3, unsigned long long a4,
6 unsigned long long a5) {
7 register unsigned long long result asm("rax");
8 register unsigned long long b0 asm("rdi");
9 register unsigned long long b1 asm("rsi");
10 register unsigned long long b2 asm("rdx");
11 register unsigned long long b3 asm("rcx");
12 register unsigned long long b4 asm("r8");
13 register unsigned long long b5 asm("r9");
15 b0 = a0;
16 b1 = a1;
17 b2 = a2;
18 b3 = a3;
19 b4 = a4;
20 b5 = a5;
22 asm("call *%1" : "=r" (result)
23 : "r"(addr), "r" (b0), "r" (b1), "r" (b2), "r" (b3), "r" (b4), "r" (b5));
24 return result;
27 // CHECK: call i64 asm "call *$1", "={rax},r,{rdi},{rsi},{rdx},{rcx},{r8},{r9},~{dirflag},~{fpsr},~{flags}"
29 unsigned long long foo2(unsigned long long addr, double a0,
30 double a1, double a2,
31 double a3, double a4,
32 double a5, double a6, double a7) {
33 register double b0 asm("xmm0");
34 register double b1 asm("xmm1");
35 register double b2 asm("xmm2");
36 register double b3 asm("xmm3");
37 register double b4 asm("xmm4");
38 register double b5 asm("xmm5");
39 register double b6 asm("xmm6");
40 register double b7 asm("xmm7");
42 register unsigned long long result asm("rax");
44 b0 = a0;
45 b1 = a1;
46 b2 = a2;
47 b3 = a3;
48 b4 = a4;
49 b5 = a5;
50 b6 = a6;
51 b7 = a7;
53 asm("call *%1" : "=r" (result)
54 : "r"(addr), "x" (b0), "x" (b1), "x" (b2), "x" (b3), "x" (b4), "x" (b5), "x" (b6),
55 "x" (b7));
56 return result;
59 // CHECK: call i64 asm "call *$1", "={rax},r,{xmm0},{xmm1},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},~{dirflag},~{fpsr},~{flags}
61 int randomvar asm("randomvar");
62 void foo3(void) {
63 asm("vartest %0" : : "r"(randomvar));
65 // CHECK: call void asm sideeffect "vartest $0", "r,~{dirflag},~{fpsr},~{flags}"