[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / ms-inline-asm-64.c
blobc7e4c1b603bd76c1542e00f0c4983e98fc4de8d5
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -Wno-strict-prototypes -fasm-blocks -emit-llvm -o - | FileCheck %s
4 void t1(void) {
5 int var = 10;
6 __asm mov rax, offset var ; rax = address of myvar
7 // CHECK: t1
8 // CHECK: call void asm sideeffect inteldialect
9 // CHECK-SAME: mov rax, $0
10 // CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(ptr %{{.*}})
13 void t2(void) {
14 int var = 10;
15 __asm mov qword ptr [eax], offset var
16 // CHECK: t2
17 // CHECK: call void asm sideeffect inteldialect
18 // CHECK-SAME: mov qword ptr [eax], $0
19 // CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(ptr %{{.*}})
22 struct t3_type { int a, b; };
24 int t3(void) {
25 struct t3_type foo;
26 foo.a = 1;
27 foo.b = 2;
28 __asm {
29 lea ebx, foo
30 mov eax, [ebx].0
31 mov [ebx].4, ecx
33 return foo.b;
34 // CHECK: t3
35 // CHECK: call void asm sideeffect inteldialect
36 // CHECK-SAME: lea ebx, $0
37 // CHECK-SAME: mov eax, [ebx]
38 // CHECK-SAME: mov [ebx + $$4], ecx
39 // CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(%struct.t3_type) %{{.*}})
42 int t4(void) {
43 struct t3_type foo;
44 foo.a = 1;
45 foo.b = 2;
46 __asm {
47 lea ebx, foo
49 mov eax, [ebx].foo.a
51 mov [ebx].foo.b, ecx
53 return foo.b;
54 // CHECK: t4
55 // CHECK: call void asm sideeffect inteldialect
56 // CHECK-SAME: lea ebx, $0
57 // CHECK-SAME: mov eax, [ebx]
58 // CHECK-SAME: mov [ebx + $$4], ecx
59 // CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(%struct.t3_type) %{{.*}})
62 void bar() {}
63 static void (*fptr)();
65 void t5(void) {
66 __asm {
67 call bar
68 jmp bar
69 call fptr
70 jmp fptr
72 // CHECK: t5
73 // CHECK: call void asm sideeffect inteldialect
74 // CHECK-SAME: call ${0:P}
75 // CHECK-SAME: jmp ${1:P}
76 // CHECK-SAME: call $2
77 // CHECK-SAME: jmp $3
78 // CHECK-SAME: "*m,*m,*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void (...)) @bar, ptr elementtype(void (...)) @bar, ptr elementtype(ptr) @fptr, ptr elementtype(ptr) @fptr)
81 void t47(void) {
82 // CHECK-LABEL: define{{.*}} void @t47
83 int arr[1000];
84 __asm movdir64b rax, zmmword ptr [arr]
85 // CHECK: call void asm sideeffect inteldialect "movdir64b rax, zmmword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)