2012-02-18 20:03:15 +08:00
|
|
|
//===-- ARMSubtarget.cpp - ARM Subtarget Information ----------------------===//
|
2007-01-19 15:51:42 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 15:51:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-02 05:01:15 +08:00
|
|
|
// This file implements the ARM specific subclass of TargetSubtargetInfo.
|
2007-01-19 15:51:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
2012-09-18 11:18:56 +08:00
|
|
|
#include "ARMBaseInstrInfo.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "ARMBaseRegisterInfo.h"
|
2009-08-29 07:18:09 +08:00
|
|
|
#include "llvm/GlobalValue.h"
|
2009-06-23 05:01:46 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2011-07-02 04:45:01 +08:00
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
2011-07-08 09:53:10 +08:00
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
2011-07-02 06:36:09 +08:00
|
|
|
#include "ARMGenSubtargetInfo.inc"
|
2011-07-02 04:45:01 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-23 05:01:46 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
ReserveR9("arm-reserve-r9", cl::Hidden,
|
|
|
|
cl::desc("Reserve R9, making it unavailable as GPR"));
|
|
|
|
|
2009-11-24 08:44:37 +08:00
|
|
|
static cl::opt<bool>
|
2011-01-22 02:55:51 +08:00
|
|
|
DarwinUseMOVT("arm-darwin-use-movt", cl::init(true), cl::Hidden);
|
2009-11-24 08:44:37 +08:00
|
|
|
|
2012-09-30 05:43:49 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
UseFusedMulOps("arm-use-mulops",
|
|
|
|
cl::init(true), cl::Hidden);
|
|
|
|
|
2010-09-28 12:09:35 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
StrictAlign("arm-strict-align", cl::Hidden,
|
|
|
|
cl::desc("Disallow all unaligned memory accesses"));
|
|
|
|
|
2011-06-30 09:53:36 +08:00
|
|
|
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
|
2011-07-07 08:08:19 +08:00
|
|
|
const std::string &FS)
|
2011-07-07 15:07:08 +08:00
|
|
|
: ARMGenSubtargetInfo(TT, CPU, FS)
|
2010-09-10 09:29:16 +08:00
|
|
|
, ARMProcFamily(Others)
|
2011-07-07 11:55:05 +08:00
|
|
|
, HasV4TOps(false)
|
|
|
|
, HasV5TOps(false)
|
|
|
|
, HasV5TEOps(false)
|
|
|
|
, HasV6Ops(false)
|
|
|
|
, HasV6T2Ops(false)
|
|
|
|
, HasV7Ops(false)
|
|
|
|
, HasVFPv2(false)
|
|
|
|
, HasVFPv3(false)
|
2012-01-22 20:07:33 +08:00
|
|
|
, HasVFPv4(false)
|
2011-07-07 11:55:05 +08:00
|
|
|
, HasNEON(false)
|
2010-03-26 07:47:34 +08:00
|
|
|
, UseNEONForSinglePrecisionFP(false)
|
2012-09-30 05:43:49 +08:00
|
|
|
, UseMulOps(UseFusedMulOps)
|
2010-12-06 06:04:16 +08:00
|
|
|
, SlowFPVMLx(false)
|
2011-04-01 17:20:31 +08:00
|
|
|
, HasVMLxForwarding(false)
|
2010-08-10 03:19:36 +08:00
|
|
|
, SlowFPBrcc(false)
|
2011-07-08 03:05:12 +08:00
|
|
|
, InThumbMode(false)
|
2011-07-07 08:08:19 +08:00
|
|
|
, HasThumb2(false)
|
2011-09-28 22:21:38 +08:00
|
|
|
, IsMClass(false)
|
2010-08-11 15:17:46 +08:00
|
|
|
, NoARM(false)
|
2009-09-30 08:10:16 +08:00
|
|
|
, PostRAScheduler(false)
|
2009-06-23 05:01:46 +08:00
|
|
|
, IsR9Reserved(ReserveR9)
|
2011-01-17 16:03:18 +08:00
|
|
|
, UseMovt(false)
|
2011-10-08 01:17:49 +08:00
|
|
|
, SupportsTailCall(false)
|
2010-03-15 02:42:38 +08:00
|
|
|
, HasFP16(false)
|
2010-10-13 00:22:47 +08:00
|
|
|
, HasD16(false)
|
2010-05-06 07:44:43 +08:00
|
|
|
, HasHardwareDivide(false)
|
2012-09-30 05:43:49 +08:00
|
|
|
, HasHardwareDivideInARM(false)
|
2010-05-06 07:44:43 +08:00
|
|
|
, HasT2ExtractPack(false)
|
2010-08-11 14:22:01 +08:00
|
|
|
, HasDataBarrier(false)
|
2010-08-10 03:19:36 +08:00
|
|
|
, Pref32BitThumb(false)
|
2011-04-20 02:11:49 +08:00
|
|
|
, AvoidCPSRPartialUpdate(false)
|
2012-12-21 03:59:30 +08:00
|
|
|
, AvoidMOVsShifterOperand(false)
|
2012-04-22 19:52:41 +08:00
|
|
|
, HasRAS(false)
|
2010-11-03 14:34:55 +08:00
|
|
|
, HasMPExtension(false)
|
2010-08-11 23:44:15 +08:00
|
|
|
, FPOnlySP(false)
|
2010-09-28 12:09:35 +08:00
|
|
|
, AllowsUnalignedMem(false)
|
2011-07-02 05:12:19 +08:00
|
|
|
, Thumb2DSP(false)
|
2007-02-14 03:52:28 +08:00
|
|
|
, stackAlignment(4)
|
2011-06-30 09:53:36 +08:00
|
|
|
, CPUString(CPU)
|
2011-01-12 05:46:47 +08:00
|
|
|
, TargetTriple(TT)
|
2007-02-14 03:52:28 +08:00
|
|
|
, TargetABI(ARM_ABI_APCS) {
|
2007-01-19 15:51:42 +08:00
|
|
|
// Determine default and user specified characteristics
|
2011-06-30 09:53:36 +08:00
|
|
|
if (CPUString.empty())
|
|
|
|
CPUString = "generic";
|
2009-03-08 12:02:49 +08:00
|
|
|
|
2011-06-30 10:12:44 +08:00
|
|
|
// Insert the architecture feature derived from the target triple into the
|
|
|
|
// feature string. This is important for setting features that are implied
|
|
|
|
// based on the architecture version.
|
2012-04-26 09:13:36 +08:00
|
|
|
std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPUString);
|
2011-07-07 08:08:19 +08:00
|
|
|
if (!FS.empty()) {
|
|
|
|
if (!ArchFS.empty())
|
|
|
|
ArchFS = ArchFS + "," + FS;
|
|
|
|
else
|
|
|
|
ArchFS = FS;
|
|
|
|
}
|
2011-07-07 15:07:08 +08:00
|
|
|
ParseSubtargetFeatures(CPUString, ArchFS);
|
2011-07-07 08:08:19 +08:00
|
|
|
|
|
|
|
// Thumb2 implies at least V6T2. FIXME: Fix tests to explicitly specify a
|
|
|
|
// ARM version or CPU and then remove this.
|
2011-07-07 11:55:05 +08:00
|
|
|
if (!HasV6T2Ops && hasThumb2())
|
|
|
|
HasV4TOps = HasV5TOps = HasV5TEOps = HasV6Ops = HasV6T2Ops = true;
|
2010-11-10 06:50:47 +08:00
|
|
|
|
2012-08-08 10:44:16 +08:00
|
|
|
// Keep a pointer to static instruction cost data for the specified CPU.
|
|
|
|
SchedModel = getSchedModelForCPU(CPUString);
|
|
|
|
|
2011-07-02 04:45:01 +08:00
|
|
|
// Initialize scheduling itinerary for the specified CPU.
|
|
|
|
InstrItins = getInstrItineraryForCPU(CPUString);
|
|
|
|
|
2012-04-27 10:11:10 +08:00
|
|
|
if ((TT.find("eabi") != std::string::npos) || (isTargetIOS() && isMClass()))
|
2012-02-22 04:46:00 +08:00
|
|
|
// FIXME: We might want to separate AAPCS and EABI. Some systems, e.g.
|
|
|
|
// Darwin-EABI conforms to AACPS but not the rest of EABI.
|
2011-07-07 15:07:08 +08:00
|
|
|
TargetABI = ARM_ABI_AAPCS;
|
|
|
|
|
2007-02-14 03:52:28 +08:00
|
|
|
if (isAAPCS_ABI())
|
|
|
|
stackAlignment = 8;
|
|
|
|
|
2011-12-21 02:26:50 +08:00
|
|
|
if (!isTargetIOS())
|
2011-01-17 16:03:18 +08:00
|
|
|
UseMovt = hasV6T2Ops();
|
|
|
|
else {
|
2011-07-07 11:55:05 +08:00
|
|
|
IsR9Reserved = ReserveR9 | !HasV6Ops;
|
2011-01-22 02:55:51 +08:00
|
|
|
UseMovt = DarwinUseMOVT && hasV6T2Ops();
|
2012-02-22 04:46:00 +08:00
|
|
|
SupportsTailCall = !getTargetTriple().isOSVersionLT(5, 0);
|
2011-01-17 16:03:18 +08:00
|
|
|
}
|
2009-10-02 05:46:35 +08:00
|
|
|
|
2009-10-16 14:11:08 +08:00
|
|
|
if (!isThumb() || hasThumb2())
|
|
|
|
PostRAScheduler = true;
|
2010-09-28 12:09:35 +08:00
|
|
|
|
|
|
|
// v6+ may or may not support unaligned mem access depending on the system
|
|
|
|
// configuration.
|
|
|
|
if (!StrictAlign && hasV6Ops() && isTargetDarwin())
|
|
|
|
AllowsUnalignedMem = true;
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
2009-08-29 07:18:09 +08:00
|
|
|
|
|
|
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
2009-09-03 15:04:02 +08:00
|
|
|
bool
|
2010-04-15 09:51:59 +08:00
|
|
|
ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,
|
|
|
|
Reloc::Model RelocM) const {
|
2009-09-03 15:04:02 +08:00
|
|
|
if (RelocM == Reloc::Static)
|
2009-08-29 07:18:09 +08:00
|
|
|
return false;
|
2009-09-03 15:04:02 +08:00
|
|
|
|
2010-01-28 04:34:15 +08:00
|
|
|
// Materializable GVs (in JIT lazy compilation mode) do not require an extra
|
|
|
|
// load from stub.
|
2011-02-22 14:58:34 +08:00
|
|
|
bool isDecl = GV->hasAvailableExternallyLinkage();
|
|
|
|
if (GV->isDeclaration() && !GV->isMaterializable())
|
|
|
|
isDecl = true;
|
2009-09-03 15:04:02 +08:00
|
|
|
|
|
|
|
if (!isTargetDarwin()) {
|
|
|
|
// Extra load is needed for all externally visible.
|
|
|
|
if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (RelocM == Reloc::PIC_) {
|
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// If symbol visibility is hidden, we have a stub for common symbol
|
|
|
|
// references and external declarations.
|
|
|
|
if (isDecl || GV->hasCommonLinkage())
|
|
|
|
// Hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
|
|
|
return false;
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2009-09-03 15:04:02 +08:00
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2009-08-29 07:18:09 +08:00
|
|
|
}
|
2009-11-10 08:48:55 +08:00
|
|
|
|
2010-09-29 05:57:50 +08:00
|
|
|
unsigned ARMSubtarget::getMispredictionPenalty() const {
|
2012-08-08 10:44:16 +08:00
|
|
|
return SchedModel->MispredictPenalty;
|
2010-09-29 05:57:50 +08:00
|
|
|
}
|
|
|
|
|
2009-11-10 08:48:55 +08:00
|
|
|
bool ARMSubtarget::enablePostRAScheduler(
|
|
|
|
CodeGenOpt::Level OptLevel,
|
2011-07-02 05:01:15 +08:00
|
|
|
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
2009-11-14 03:52:48 +08:00
|
|
|
RegClassVector& CriticalPathRCs) const {
|
2011-07-02 05:01:15 +08:00
|
|
|
Mode = TargetSubtargetInfo::ANTIDEP_CRITICAL;
|
2009-11-14 03:52:48 +08:00
|
|
|
CriticalPathRCs.clear();
|
|
|
|
CriticalPathRCs.push_back(&ARM::GPRRegClass);
|
2009-11-10 08:48:55 +08:00
|
|
|
return PostRAScheduler && OptLevel >= CodeGenOpt::Default;
|
|
|
|
}
|