blob: dd7b9b3349ebb0b314ad2ee2189e7250eb0a3738 [file] [log] [blame]
Chad Rosiere72faf62012-10-23 23:42:25 +00001// REQUIRES: x86-64-registered-target
Chad Rosierb2e21572013-01-22 19:38:32 +00002// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fasm-blocks -emit-llvm -o - | FileCheck %s
Chad Rosiere72faf62012-10-23 23:42:25 +00003
4void t1() {
5 int var = 10;
6 __asm mov rax, offset var ; rax = address of myvar
7// CHECK: t1
Chad Rosierb55dd762013-04-10 18:08:17 +00008// CHECK: call void asm sideeffect inteldialect "mov rax, $0", "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
Chad Rosiere72faf62012-10-23 23:42:25 +00009}
Chad Rosier42242552012-10-24 17:23:06 +000010
11void t2() {
12 int var = 10;
13 __asm mov [eax], offset var
14// CHECK: t2
Chad Rosierb55dd762013-04-10 18:08:17 +000015// CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
Chad Rosier42242552012-10-24 17:23:06 +000016}
Bill Wendling4e1125f2013-02-22 09:10:20 +000017
Chad Rosierb55dd762013-04-10 18:08:17 +000018struct t3_type { int a, b; };
19
20int t3() {
21 struct t3_type foo;
22 foo.a = 1;
23 foo.b = 2;
24 __asm {
25 lea ebx, foo
26 mov eax, [ebx].0
27 mov [ebx].4, ecx
28 }
29 return foo.b;
30// CHECK: t3
31// 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}
33
34int t4() {
35 struct t3_type foo;
36 foo.a = 1;
37 foo.b = 2;
38 __asm {
39 lea ebx, foo
40 mov eax, [ebx].foo.a
41 mov [ebx].foo.b, ecx
42 }
43 return foo.b;
44// CHECK: t4
45// 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}