aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-14 00:35:03 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-14 00:35:03 +0000
commit018ba5ab0671d9b6eefecaffc118c869bea151a1 (patch)
tree771f355acb2b806090d8c4a8a72b6df4bc5d2d53
parent2030d8f46b4226fa99e59389e3ca856a79c27e9a (diff)
Add TargetInfo::getABI(), and base ARM APCS vs AAPCS choice on that.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81735 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/TargetInfo.h5
-rw-r--r--lib/Basic/Targets.cpp10
-rw-r--r--lib/CodeGen/TargetABIInfo.cpp5
-rw-r--r--test/CodeGen/arm-apcs-arguments.c2
4 files changed, 16 insertions, 6 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index ee742aafe3..64692ba37a 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -352,6 +352,11 @@ public:
llvm::StringMap<bool> &Features) const {
}
+ /// getABI - Get the ABI in use.
+ virtual const char *getABI() const {
+ return "";
+ }
+
/// setABI - Use the specific ABI.
///
/// \return - False on error (invalid ABI name).
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index c9a3deab28..eed9e2cc19 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -991,8 +991,13 @@ class ARMTargetInfo : public TargetInfo {
Armv7a,
XScale
} ArmArch;
+
+ std::string ABI;
+
public:
- ARMTargetInfo(const std::string& triple) : TargetInfo(triple) {
+ ARMTargetInfo(const std::string& triple)
+ : TargetInfo(triple), ABI("aapcs-linux")
+ {
// FIXME: Are the defaults correct for ARM?
DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
"i64:32:32-f32:32:32-f64:32:32-"
@@ -1016,7 +1021,10 @@ public:
ArmArch = Armv6;
}
}
+ virtual const char *getABI() const { return ABI.c_str(); }
virtual bool setABI(const std::string &Name) {
+ ABI = Name;
+
// The defaults (above) are for AAPCS, check if we need to change them.
//
// FIXME: We need support for -meabi... we could just mangle it into the
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index 892994af10..6d95adad86 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -1682,11 +1682,8 @@ const ABIInfo &CodeGenTypes::getABIInfo() const {
case llvm::Triple::arm:
case llvm::Triple::thumb:
- // FIXME: We should get this from the target, we also need a -target-abi
- // because the user should have some control over this.
- //
// FIXME: We want to know the float calling convention as well.
- if (Triple.getOS() == llvm::Triple::Darwin)
+ if (strcmp(getContext().Target.getABI(), "apcs-gnu") == 0)
return *(TheABIInfo = new ARMABIInfo(ARMABIInfo::APCS));
return *(TheABIInfo = new ARMABIInfo(ARMABIInfo::AAPCS));
diff --git a/test/CodeGen/arm-apcs-arguments.c b/test/CodeGen/arm-apcs-arguments.c
index d427dd144a..db985d7a20 100644
--- a/test/CodeGen/arm-apcs-arguments.c
+++ b/test/CodeGen/arm-apcs-arguments.c
@@ -1,5 +1,5 @@
// RUX: iphone-llvm-gcc -arch armv7 -flto -S -o - %s | FileCheck %s
-// RUN: clang-cc -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
+// RUN: clang-cc -triple armv7-apple-darwin9 -target-abi=apcs-gnu -emit-llvm -w -o - %s | FileCheck %s
// CHECK: define arm_apcscc signext i8 @f0()
char f0(void) {