[PATCH] Create android x86_32 and x86_64 target info

Tamas Berghammer tberghammer at google.com
Wed Mar 25 03:41:31 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8357

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Sema/i386-linux-android.c
  cfe/trunk/test/Sema/x86_64-linux-android.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===================================================================
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6506,6 +6506,30 @@
 };
 } // end anonymous namespace.
 
+namespace {
+// x86_32 Android target
+class AndroidX86_32TargetInfo : public LinuxTargetInfo<X86_32TargetInfo> {
+public:
+  AndroidX86_32TargetInfo(const llvm::Triple &Triple)
+      : LinuxTargetInfo<X86_32TargetInfo>(Triple) {
+    SuitableAlign = 32;
+    LongDoubleWidth = 64;
+    LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+  }
+};
+} // end anonymous namespace
+
+namespace {
+// x86_64 Android target
+class AndroidX86_64TargetInfo : public LinuxTargetInfo<X86_64TargetInfo> {
+public:
+  AndroidX86_64TargetInfo(const llvm::Triple &Triple)
+      : LinuxTargetInfo<X86_64TargetInfo>(Triple) {
+    LongDoubleFormat = &llvm::APFloat::IEEEquad;
+  }
+};
+} // end anonymous namespace
+
 
 //===----------------------------------------------------------------------===//
 // Driver code
@@ -6783,8 +6807,14 @@
       return new DarwinI386TargetInfo(Triple);
 
     switch (os) {
-    case llvm::Triple::Linux:
-      return new LinuxTargetInfo<X86_32TargetInfo>(Triple);
+    case llvm::Triple::Linux: {
+      switch (Triple.getEnvironment()) {
+      default:
+        return new LinuxTargetInfo<X86_32TargetInfo>(Triple);
+      case llvm::Triple::Android:
+        return new AndroidX86_32TargetInfo(Triple);
+      }
+    }
     case llvm::Triple::DragonFly:
       return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(Triple);
     case llvm::Triple::NetBSD:
@@ -6831,8 +6861,14 @@
     switch (os) {
     case llvm::Triple::CloudABI:
       return new CloudABITargetInfo<X86_64TargetInfo>(Triple);
-    case llvm::Triple::Linux:
-      return new LinuxTargetInfo<X86_64TargetInfo>(Triple);
+    case llvm::Triple::Linux: {
+      switch (Triple.getEnvironment()) {
+      default:
+        return new LinuxTargetInfo<X86_64TargetInfo>(Triple);
+      case llvm::Triple::Android:
+        return new AndroidX86_64TargetInfo(Triple);
+      }
+    }
     case llvm::Triple::DragonFly:
       return new DragonFlyBSDTargetInfo<X86_64TargetInfo>(Triple);
     case llvm::Triple::NetBSD:
Index: cfe/trunk/test/Sema/x86_64-linux-android.c
===================================================================
--- cfe/trunk/test/Sema/x86_64-linux-android.c
+++ cfe/trunk/test/Sema/x86_64-linux-android.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-android -emit-pch -o %t %s
+// RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
+
+extern int a1_0[sizeof(long double) == 16 ? 1 : -1];
+extern int a1_i[__alignof(long double) == 16 ? 1 : -1];
+
+// Verify that long double is 128 bit IEEEquad
+
+long double foo = 1.0E4000L;
+// CHECK: long double foo = 1.00000000000000000000000000000000004E+4000L;
Index: cfe/trunk/test/Sema/i386-linux-android.c
===================================================================
--- cfe/trunk/test/Sema/i386-linux-android.c
+++ cfe/trunk/test/Sema/i386-linux-android.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-linux-android -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+extern int a1_0[sizeof(long double) == 8 ? 1 : -1];
+extern int a1_i[__alignof(long double) == 4 ? 1 : -1];
+

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8357.22632.patch
Type: text/x-patch
Size: 3299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150325/8decac88/attachment.bin>


More information about the cfe-commits mailing list