coby created this revision.
Herald added a subscriber: eraman.

Repository:
  rL LLVM

https://reviews.llvm.org/D37466

Files:
  test/CodeGen/ms-inline-asm-64.c
  test/CodeGen/ms-inline-asm-offset-err.cpp
  test/CodeGen/ms-inline-asm-offset.c
  test/CodeGen/ms-inline-asm.c
  test/CodeGen/ms-inline-asm.cpp

Index: test/CodeGen/ms-inline-asm.c
===================================================================
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -180,25 +180,14 @@
 // CHECK: call void asm sideeffect inteldialect ".if 1\0A\09mov eax, $0\0A\09.else\0A\09mov ebx, j\0A\09.endif", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
-int gvar = 10;
 void t15() {
 // CHECK: t15
   int lvar = 10;
   __asm mov eax, lvar        ; eax = 10
 // CHECK: mov eax, $0
-  __asm mov eax, offset lvar ; eax = address of lvar
-// CHECK: mov eax, $1
-  __asm mov eax, offset gvar ; eax = address of gvar
-// CHECK: mov eax, $2
-// CHECK: "*m,r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* @{{.*}})
+// CHECK-SAME: "*m,~{eax},~{dirflag},~{fpsr},~{flags}"
 }
 
-void t16() {
-  int var = 10;
-  __asm mov [eax], offset var
-// CHECK: t16
-// CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
 
 void t17() {
 // CHECK: t17
Index: test/CodeGen/ms-inline-asm-64.c
===================================================================
--- test/CodeGen/ms-inline-asm-64.c
+++ test/CodeGen/ms-inline-asm-64.c
@@ -1,46 +1,28 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
 
-void t1() {
-  int var = 10;
-  __asm mov rax, offset var ; rax = address of myvar
-// CHECK: t1
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov rax, $0
-// CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
-
-void t2() {
-  int var = 10;
-  __asm mov [eax], offset var
-// CHECK: t2
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov [eax], $0
-// CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
-
-struct t3_type { int a, b; };
+struct t1_type { int a, b; };
 
-int t3() {
-  struct t3_type foo;
+int t1() {
+  struct t1_type foo;
   foo.a = 1;
   foo.b = 2;
   __asm {
      lea ebx, foo
      mov eax, [ebx].0
      mov [ebx].4, ecx
   }
   return foo.b;
-// CHECK: t3
+// CHECK: t1
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: lea ebx, $0
 // CHECK-SAME: mov eax, [ebx]
 // CHECK-SAME: mov [ebx + $$4], ecx
-// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t1_type* %{{.*}})
 }
 
-int t4() {
-  struct t3_type foo;
+int t2() {
+  struct t1_type foo;
   foo.a = 1;
   foo.b = 2;
   __asm {
@@ -51,10 +33,10 @@
      mov [ebx].foo.b, ecx
   }
   return foo.b;
-// CHECK: t4
+// CHECK: t2
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: lea ebx, $0
 // CHECK-SAME: mov eax, [ebx]
 // CHECK-SAME: mov [ebx + $$4], ecx
-// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t1_type* %{{.*}})
 }
Index: test/CodeGen/ms-inline-asm.cpp
===================================================================
--- test/CodeGen/ms-inline-asm.cpp
+++ test/CodeGen/ms-inline-asm.cpp
@@ -31,18 +31,6 @@
   __asm mov eax, dword ptr [Foo :: ptr]
 }
 
-int gvar = 10;
-void t2() {
-  int lvar = 10;
-  __asm mov eax, offset Foo::ptr
-  __asm mov eax, offset Foo::Bar::ptr
-// CHECK-LABEL: define void @_Z2t2v()
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov eax, $0
-// CHECK-SAME: mov eax, $1
-// CHECK-SAME: "r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3Bar3ptrE)
-}
-
 // CHECK-LABEL: define void @_Z2t3v()
 void t3() {
   __asm mov eax, LENGTH Foo::ptr
Index: test/CodeGen/ms-inline-asm-offset.c
===================================================================
--- test/CodeGen/ms-inline-asm-offset.c
+++ test/CodeGen/ms-inline-asm-offset.c
@@ -0,0 +1,29 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
+
+int gVar;
+void t1() {
+  __asm mov rax, 0xFF + offset gVar - 0xFE * 1
+  // CHECK: t1
+  // CHECK: mov rax, offset gVar + $$1
+}
+
+void t2() {
+  __asm mov edx, offset t2
+  // CHECK: t2
+  // CHECK: mov edx, offset t2
+}
+
+void t3() {
+  __asm _t3: mov eax, offset _t3
+  // CHECK: t3
+  // CHECK: {{.*}}__MSASMLABEL_.${:uid}___t3:
+  // CHECK: mov eax, offset {{.*}}__MSASMLABEL_.${:uid}___t3
+}
+
+void t4() {
+  __asm mov rbx, qword ptr 0x128[rax + offset t4 + rcx * 2]
+  // CHECK: t4
+  // CHECK: mov rbx, qword ptr [rax + rcx * $$2 + offset t4 + $$296]
+}
+
Index: test/CodeGen/ms-inline-asm-offset-err.cpp
===================================================================
--- test/CodeGen/ms-inline-asm-offset-err.cpp
+++ test/CodeGen/ms-inline-asm-offset-err.cpp
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -verify
+
+void t1() {
+  int lVar;
+  __asm mov rax, offset lVar    // expected-error {{illegal operand for offset operator}}
+}
+
+void t2() {
+  enum { A };
+  __asm mov eax, offset A       // expected-error {{offset operator cannot yet handle constants}}
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to