1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
3
4 struct A {
5 int a1;
6 int a2;
7 struct B {
8 int b1;
9 int b2;
10 } a3;
11 };
12
13 namespace asdf {
14 A a_global;
15 }
16
test_param_field(A p)17 extern "C" int test_param_field(A p) {
18 // CHECK: define i32 @test_param_field(%struct.A* byval(%struct.A) align 4 %p)
19 // CHECK: getelementptr inbounds %struct.A, %struct.A* %p, i32 0, i32 0
20 // CHECK: call i32 asm sideeffect inteldialect "mov eax, $1"
21 // CHECK: ret i32
22 __asm mov eax, p.a1
23 }
24
test_namespace_global()25 extern "C" int test_namespace_global() {
26 // CHECK: define i32 @test_namespace_global()
27 // CHECK: call i32 asm sideeffect inteldialect "mov eax, $1", "{{.*}}"(i32* getelementptr inbounds (%struct.A, %struct.A* @_ZN4asdf8a_globalE, i32 0, i32 2, i32 1))
28 // CHECK: ret i32
29 __asm mov eax, asdf::a_global.a3.b2
30 }
31
32 template <bool Signed>
33 struct make_storage_type {
34 struct type {
35 struct B {
36 int a;
37 int x;
38 } b;
39 };
40 };
41
42 template <bool Signed>
43 struct msvc_dcas_x86 {
44 typedef typename make_storage_type<Signed>::type storage_type;
storemsvc_dcas_x8645 void store() __asm("PR26001") {
46 storage_type p;
47 __asm mov edx, p.b.x;
48 }
49 };
50
51 template void msvc_dcas_x86<false>::store();
52 // CHECK: define weak_odr void @"\01PR26001"(
53 // CHECK: %[[P:.*]] = alloca %"struct.make_storage_type<false>::type", align 4
54 // CHECK: %[[B:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type", %"struct.make_storage_type<false>::type"* %[[P]], i32 0, i32 0
55 // CHECK: %[[X:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type::B", %"struct.make_storage_type<false>::type::B"* %[[B]], i32 0, i32 1
56 // CHECK: call void asm sideeffect inteldialect "mov edx, dword ptr $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(i32* %[[X]])
57