r233177 - Create android x86_32 and x86_64 target info
Tamas Berghammer
tberghammer at google.com
Wed Mar 25 03:38:50 PDT 2015
Author: tberghammer
Date: Wed Mar 25 05:38:50 2015
New Revision: 233177
URL: http://llvm.org/viewvc/llvm-project?rev=233177&view=rev
Log:
Create android x86_32 and x86_64 target info
On android x86_32 the long double is only 64 bits (compared to 80 bits
on linux x86_32) and on android x86_64 the long double is IEEEquad
(compared to x87DoubleExtended on linux x86_64). This CL creates new
TargetInfo classes for this targets to represent these differences.
Differential revision: http://reviews.llvm.org/D8357
Added:
cfe/trunk/test/Sema/i386-linux-android.c
cfe/trunk/test/Sema/x86_64-linux-android.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=233177&r1=233176&r2=233177&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Mar 25 05:38:50 2015
@@ -6506,6 +6506,30 @@ const Builtin::Info XCoreTargetInfo::Bui
};
} // 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 @@ static TargetInfo *AllocateTarget(const
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 @@ static TargetInfo *AllocateTarget(const
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:
Added: cfe/trunk/test/Sema/i386-linux-android.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/i386-linux-android.c?rev=233177&view=auto
==============================================================================
--- cfe/trunk/test/Sema/i386-linux-android.c (added)
+++ cfe/trunk/test/Sema/i386-linux-android.c Wed Mar 25 05:38:50 2015
@@ -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];
+
Added: cfe/trunk/test/Sema/x86_64-linux-android.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/x86_64-linux-android.c?rev=233177&view=auto
==============================================================================
--- cfe/trunk/test/Sema/x86_64-linux-android.c (added)
+++ cfe/trunk/test/Sema/x86_64-linux-android.c Wed Mar 25 05:38:50 2015
@@ -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;
More information about the cfe-commits
mailing list