xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/ms-inline-asm-64.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // REQUIRES: x86-64-registered-target
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc void t1() {
5*f4a2713aSLionel Sambuc   int var = 10;
6*f4a2713aSLionel Sambuc   __asm mov rax, offset var ; rax = address of myvar
7*f4a2713aSLionel Sambuc // CHECK: t1
8*f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect inteldialect "mov rax, $0", "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc void t2() {
12*f4a2713aSLionel Sambuc   int var = 10;
13*f4a2713aSLionel Sambuc   __asm mov [eax], offset var
14*f4a2713aSLionel Sambuc // CHECK: t2
15*f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc struct t3_type { int a, b; };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc int t3() {
21*f4a2713aSLionel Sambuc   struct t3_type foo;
22*f4a2713aSLionel Sambuc   foo.a = 1;
23*f4a2713aSLionel Sambuc   foo.b = 2;
24*f4a2713aSLionel Sambuc   __asm {
25*f4a2713aSLionel Sambuc      lea ebx, foo
26*f4a2713aSLionel Sambuc      mov eax, [ebx].0
27*f4a2713aSLionel Sambuc      mov [ebx].4, ecx
28*f4a2713aSLionel Sambuc   }
29*f4a2713aSLionel Sambuc   return foo.b;
30*f4a2713aSLionel Sambuc // CHECK: t3
31*f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr $0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
32*f4a2713aSLionel Sambuc }
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc int t4() {
35*f4a2713aSLionel Sambuc   struct t3_type foo;
36*f4a2713aSLionel Sambuc   foo.a = 1;
37*f4a2713aSLionel Sambuc   foo.b = 2;
38*f4a2713aSLionel Sambuc   __asm {
39*f4a2713aSLionel Sambuc      lea ebx, foo
40*f4a2713aSLionel Sambuc      mov eax, [ebx].foo.a
41*f4a2713aSLionel Sambuc      mov [ebx].foo.b, ecx
42*f4a2713aSLionel Sambuc   }
43*f4a2713aSLionel Sambuc   return foo.b;
44*f4a2713aSLionel Sambuc // CHECK: t4
45*f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr $0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
46*f4a2713aSLionel Sambuc }
47