Chad Rosier | e72faf6 | 2012-10-23 23:42:25 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-64-registered-target |
Chad Rosier | b2e2157 | 2013-01-22 19:38:32 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fasm-blocks -emit-llvm -o - | FileCheck %s |
Chad Rosier | e72faf6 | 2012-10-23 23:42:25 +0000 | [diff] [blame] | 3 | |
| 4 | void t1() { |
| 5 | int var = 10; |
| 6 | __asm mov rax, offset var ; rax = address of myvar |
| 7 | // CHECK: t1 |
Chad Rosier | b55dd76 | 2013-04-10 18:08:17 +0000 | [diff] [blame] | 8 | // CHECK: call void asm sideeffect inteldialect "mov rax, $0", "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) |
Chad Rosier | e72faf6 | 2012-10-23 23:42:25 +0000 | [diff] [blame] | 9 | } |
Chad Rosier | 4224255 | 2012-10-24 17:23:06 +0000 | [diff] [blame] | 10 | |
| 11 | void t2() { |
| 12 | int var = 10; |
| 13 | __asm mov [eax], offset var |
| 14 | // CHECK: t2 |
Chad Rosier | b55dd76 | 2013-04-10 18:08:17 +0000 | [diff] [blame] | 15 | // CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) |
Chad Rosier | 4224255 | 2012-10-24 17:23:06 +0000 | [diff] [blame] | 16 | } |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 17 | |
Chad Rosier | b55dd76 | 2013-04-10 18:08:17 +0000 | [diff] [blame] | 18 | struct t3_type { int a, b; }; |
| 19 | |
| 20 | int 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 | |
| 34 | int 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 | } |