summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/ms-inline-asm.c18
-rw-r--r--clang/test/CodeGenCXX/ms-inline-asm-fields.cpp31
-rw-r--r--clang/test/SemaCXX/ms-inline-asm.cpp54
3 files changed, 103 insertions, 0 deletions
diff --git a/clang/test/CodeGen/ms-inline-asm.c b/clang/test/CodeGen/ms-inline-asm.c
index 4f04a8bb502..cc0fb06dd03 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -563,3 +563,21 @@ void label4() {
// CHECK-LABEL: define void @label4
// CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
}
+
+typedef union _LARGE_INTEGER {
+ struct {
+ unsigned int LowPart;
+ unsigned int HighPart;
+ };
+ struct {
+ unsigned int LowPart;
+ unsigned int HighPart;
+ } u;
+ unsigned long long QuadPart;
+} LARGE_INTEGER, *PLARGE_INTEGER;
+
+int test_indirect_field(LARGE_INTEGER LargeInteger) {
+ __asm mov eax, LargeInteger.LowPart
+}
+// CHECK-LABEL: define i32 @test_indirect_field(
+// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $1",
diff --git a/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp b/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
new file mode 100644
index 00000000000..a78d511485a
--- /dev/null
+++ b/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
@@ -0,0 +1,31 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
+
+struct A {
+ int a1;
+ int a2;
+ struct B {
+ int b1;
+ int b2;
+ } a3;
+};
+
+namespace asdf {
+A a_global;
+}
+
+extern "C" int test_param_field(A p) {
+// CHECK: define i32 @test_param_field(%struct.A* byval align 4 %p)
+// CHECK: getelementptr inbounds %struct.A, %struct.A* %p, i32 0, i32 0
+// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $1"
+// CHECK: ret i32
+ __asm mov eax, p.a1
+}
+
+extern "C" int test_namespace_global() {
+// CHECK: define i32 @test_namespace_global()
+// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $1", "{{.*}}"(i32* getelementptr inbounds (%struct.A, %struct.A* @_ZN4asdf8a_globalE, i32 0, i32 2, i32 1))
+// CHECK: ret i32
+ __asm mov eax, asdf::a_global.a3.b2
+}
+
diff --git a/clang/test/SemaCXX/ms-inline-asm.cpp b/clang/test/SemaCXX/ms-inline-asm.cpp
new file mode 100644
index 00000000000..3e445b80f88
--- /dev/null
+++ b/clang/test/SemaCXX/ms-inline-asm.cpp
@@ -0,0 +1,54 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -verify
+
+struct A {
+ int a1;
+ int a2;
+ struct B {
+ int b1;
+ int b2;
+ enum { kValue = 42 };
+ } a3;
+ struct {
+ int indirect_field;
+ };
+};
+
+namespace asdf {
+A a_global;
+}
+
+// The parser combines adjacent __asm blocks into one. Avoid that by calling
+// this.
+void split_inline_asm_call();
+
+void test_field_lookup() {
+ __asm mov eax, asdf::a_global.a3.b2
+ split_inline_asm_call();
+
+ // FIXME: These diagnostics are crap.
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.not_a_field.b2
+ split_inline_asm_call();
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.a3.not_a_field
+ split_inline_asm_call();
+
+ __asm mov eax, A::B::kValue
+ split_inline_asm_call();
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.a3.kValue
+ split_inline_asm_call();
+
+ __asm mov eax, asdf :: a_global.a3.b2
+ split_inline_asm_call();
+
+ __asm mov eax, asdf::a_global . a3 . b2
+ split_inline_asm_call();
+
+ __asm mov eax, asdf::a_global.indirect_field
+ split_inline_asm_call();
+}
OpenPOWER on IntegriCloud