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