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