| 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 |
|
| 17 |
extern "C" int test_param_field(A p) { |
| 18 |
// CHECK: define{{.*}} i32 @test_param_field(ptr noundef byval(%struct.A) align 4 %p) |
| 19 |
// CHECK: getelementptr inbounds nuw %struct.A, ptr %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 |
|
| 25 |
extern "C" int test_namespace_global() { |
| 26 |
// CHECK: define{{.*}} i32 @test_namespace_global() |
| 27 |
// CHECK: call i32 asm sideeffect inteldialect "mov eax, $1", "{{.*}}"(ptr elementtype(i32) getelementptr inbounds nuw (%"struct.A::B", ptr getelementptr inbounds nuw (%struct.A, ptr @_ZN4asdf8a_globalE, i32 0, i32 2), i32 0, 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; |
| 45 |
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 nuw %"struct.make_storage_type<false>::type", ptr %[[P]], i32 0, i32 0 |
| 55 |
// CHECK: %[[X:.*]] = getelementptr inbounds nuw %"struct.make_storage_type<false>::type::B", ptr %[[B]], i32 0, i32 1 |
| 56 |
// CHECK: call void asm sideeffect inteldialect "mov edx, $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]]) |