Add a new string member to the TargetOptions struct for the name
of the abi we should be using. For targets that don't use the
option there's no change, otherwise this allows external users
to set the ABI via string and avoid some of the -backend-option
pain in clang.
Use this option to move the ABI for the ARM port from the
Subtarget to the TargetMachine and update the testcases
accordingly since it's no longer valid to set via -mattr.
llvm-svn: 224492
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.cpp b/llvm/lib/Target/ARM/ARMSubtarget.cpp
index 199000f..699c11d 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -18,6 +18,7 @@
#include "ARMSelectionDAGInfo.h"
#include "ARMSubtarget.h"
#include "ARMMachineFunctionInfo.h"
+#include "ARMTargetMachine.h"
#include "Thumb1FrameLowering.h"
#include "Thumb1InstrInfo.h"
#include "Thumb2InstrInfo.h"
@@ -147,11 +148,11 @@
}
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
- const std::string &FS, const TargetMachine &TM,
+ const std::string &FS, const ARMBaseTargetMachine &TM,
bool IsLittle)
: ARMGenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
ARMProcClass(None), stackAlignment(4), CPUString(CPU), IsLittle(IsLittle),
- TargetTriple(TT), Options(TM.Options), TargetABI(ARM_ABI_UNKNOWN),
+ TargetTriple(TT), Options(TM.Options), TM(TM),
DL(computeDataLayout(initializeSubtargetDependencies(CPU, FS))),
TSInfo(DL),
InstrInfo(isThumb1Only()
@@ -245,43 +246,6 @@
// Initialize scheduling itinerary for the specified CPU.
InstrItins = getInstrItineraryForCPU(CPUString);
- if (TargetABI == ARM_ABI_UNKNOWN) {
- // FIXME: This is duplicated code from the front end and should be unified.
- if (TargetTriple.isOSBinFormatMachO()) {
- if (TargetTriple.getEnvironment() == llvm::Triple::EABI ||
- (TargetTriple.getOS() == llvm::Triple::UnknownOS &&
- TargetTriple.getObjectFormat() == llvm::Triple::MachO) ||
- CPU.startswith("cortex-m")) {
- TargetABI = ARM_ABI_AAPCS;
- } else {
- TargetABI = ARM_ABI_APCS;
- }
- } else if (TargetTriple.isOSWindows()) {
- // FIXME: this is invalid for WindowsCE
- TargetABI = ARM_ABI_AAPCS;
- } else {
- // Select the default based on the platform.
- switch (TargetTriple.getEnvironment()) {
- case llvm::Triple::Android:
- case llvm::Triple::GNUEABI:
- case llvm::Triple::GNUEABIHF:
- case llvm::Triple::EABIHF:
- case llvm::Triple::EABI:
- TargetABI = ARM_ABI_AAPCS;
- break;
- case llvm::Triple::GNU:
- TargetABI = ARM_ABI_APCS;
- break;
- default:
- if (TargetTriple.getOS() == llvm::Triple::NetBSD)
- TargetABI = ARM_ABI_APCS;
- else
- TargetABI = ARM_ABI_AAPCS;
- break;
- }
- }
- }
-
// FIXME: this is invalid for WindowsCE
if (isTargetWindows())
NoARM = true;
@@ -346,6 +310,15 @@
UseNEONForSinglePrecisionFP = true;
}
+bool ARMSubtarget::isAPCS_ABI() const {
+ assert(TM.TargetABI != ARMBaseTargetMachine::ARM_ABI_UNKNOWN);
+ return TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_APCS;
+}
+bool ARMSubtarget::isAAPCS_ABI() const {
+ assert(TM.TargetABI != ARMBaseTargetMachine::ARM_ABI_UNKNOWN);
+ return TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS;
+}
+
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
bool
ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,