Chad Rosier | 148bab2 | 2013-04-02 20:03:29 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-64-registered-target |
| 2 | // RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -O0 -fasm-blocks -emit-llvm -o - | FileCheck %s |
| 3 | |
| 4 | struct Foo { |
| 5 | static int *ptr; |
| 6 | static int a, b; |
Chad Rosier | 5e768ca | 2013-04-11 23:57:29 +0000 | [diff] [blame^] | 7 | int arr[4]; |
Chad Rosier | 148bab2 | 2013-04-02 20:03:29 +0000 | [diff] [blame] | 8 | struct Bar { |
| 9 | static int *ptr; |
Chad Rosier | 5e768ca | 2013-04-11 23:57:29 +0000 | [diff] [blame^] | 10 | char arr[2]; |
Chad Rosier | 148bab2 | 2013-04-02 20:03:29 +0000 | [diff] [blame] | 11 | }; |
| 12 | }; |
| 13 | |
| 14 | void t1() { |
| 15 | Foo::ptr = (int *)0xDEADBEEF; |
| 16 | Foo::Bar::ptr = (int *)0xDEADBEEF; |
| 17 | __asm mov eax, Foo::ptr |
| 18 | __asm mov eax, Foo::Bar::ptr |
| 19 | __asm mov eax, [Foo::ptr] |
| 20 | __asm mov eax, dword ptr [Foo::ptr] |
| 21 | __asm mov eax, dword ptr [Foo::ptr] |
| 22 | // CHECK: @_Z2t1v |
| 23 | // CHECK: call void asm sideeffect inteldialect "mov eax, Foo::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
| 24 | // CHECK: call void asm sideeffect inteldialect "mov eax, Foo::Bar::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
Chad Rosier | 0f9790b | 2013-04-11 21:49:48 +0000 | [diff] [blame] | 25 | // CHECK: call void asm sideeffect inteldialect "mov eax, Foo::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
| 26 | // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr Foo::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
| 27 | // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr Foo::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
Chad Rosier | 148bab2 | 2013-04-02 20:03:29 +0000 | [diff] [blame] | 28 | } |
Chad Rosier | dbcfa8b | 2013-04-11 23:37:53 +0000 | [diff] [blame] | 29 | |
| 30 | int gvar = 10; |
| 31 | void t2() { |
| 32 | int lvar = 10; |
| 33 | __asm mov eax, offset Foo::ptr |
| 34 | __asm mov eax, offset Foo::Bar::ptr |
| 35 | // CHECK: t2 |
| 36 | // CHECK: call void asm sideeffect inteldialect "mov eax, Foo::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
| 37 | // CHECK: call void asm sideeffect inteldialect "mov eax, Foo::Bar::ptr", "~{eax},~{dirflag},~{fpsr},~{flags}"() |
| 38 | } |
Chad Rosier | 5e768ca | 2013-04-11 23:57:29 +0000 | [diff] [blame^] | 39 | |
| 40 | void t3() { |
| 41 | __asm mov eax, LENGTH Foo::ptr |
| 42 | __asm mov eax, LENGTH Foo::Bar::ptr |
| 43 | __asm mov eax, LENGTH Foo::arr |
| 44 | __asm mov eax, LENGTH Foo::Bar::arr |
| 45 | |
| 46 | __asm mov eax, TYPE Foo::ptr |
| 47 | __asm mov eax, TYPE Foo::Bar::ptr |
| 48 | __asm mov eax, TYPE Foo::arr |
| 49 | __asm mov eax, TYPE Foo::Bar::arr |
| 50 | |
| 51 | __asm mov eax, SIZE Foo::ptr |
| 52 | __asm mov eax, SIZE Foo::Bar::ptr |
| 53 | __asm mov eax, SIZE Foo::arr |
| 54 | __asm mov eax, SIZE Foo::Bar::arr |
| 55 | // CHECK: t3 |
| 56 | // FIXME: These tests just make sure we can parse things properly. |
| 57 | // Additional work needs to be done in Sema to perform the lookup. |
| 58 | } |