2007-01-19 08:51:42 +01:00
|
|
|
//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 08:51:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-01 23:01:15 +02:00
|
|
|
// This file implements the ARM specific subclass of TargetSubtargetInfo.
|
2007-01-19 08:51:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
2011-01-11 22:46:47 +01:00
|
|
|
#include "ARMBaseRegisterInfo.h"
|
2009-08-29 01:18:09 +02:00
|
|
|
#include "llvm/GlobalValue.h"
|
2011-07-01 23:01:15 +02:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2009-06-22 23:01:46 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-11-10 01:48:55 +01:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2011-07-01 22:45:01 +02:00
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
2011-07-08 03:53:10 +02:00
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
2011-07-02 00:36:09 +02:00
|
|
|
#include "ARMGenSubtargetInfo.inc"
|
2011-07-01 22:45:01 +02:00
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-22 23:01:46 +02:00
|
|
|
static cl::opt<bool>
|
|
|
|
ReserveR9("arm-reserve-r9", cl::Hidden,
|
|
|
|
cl::desc("Reserve R9, making it unavailable as GPR"));
|
|
|
|
|
2009-11-24 01:44:37 +01:00
|
|
|
static cl::opt<bool>
|
2011-01-21 19:55:51 +01:00
|
|
|
DarwinUseMOVT("arm-darwin-use-movt", cl::init(true), cl::Hidden);
|
2009-11-24 01:44:37 +01:00
|
|
|
|
2010-09-28 06:09:35 +02:00
|
|
|
static cl::opt<bool>
|
|
|
|
StrictAlign("arm-strict-align", cl::Hidden,
|
|
|
|
cl::desc("Disallow all unaligned memory accesses"));
|
|
|
|
|
2011-06-30 03:53:36 +02:00
|
|
|
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
|
2011-07-07 02:08:19 +02:00
|
|
|
const std::string &FS)
|
2011-07-07 09:07:08 +02:00
|
|
|
: ARMGenSubtargetInfo(TT, CPU, FS)
|
2010-09-10 03:29:16 +02:00
|
|
|
, ARMProcFamily(Others)
|
2011-07-07 05:55:05 +02:00
|
|
|
, HasV4TOps(false)
|
|
|
|
, HasV5TOps(false)
|
|
|
|
, HasV5TEOps(false)
|
|
|
|
, HasV6Ops(false)
|
|
|
|
, HasV6T2Ops(false)
|
|
|
|
, HasV7Ops(false)
|
|
|
|
, HasVFPv2(false)
|
|
|
|
, HasVFPv3(false)
|
|
|
|
, HasNEON(false)
|
2010-03-26 00:47:34 +01:00
|
|
|
, UseNEONForSinglePrecisionFP(false)
|
2010-12-05 23:04:16 +01:00
|
|
|
, SlowFPVMLx(false)
|
2011-04-01 11:20:31 +02:00
|
|
|
, HasVMLxForwarding(false)
|
2010-08-09 21:19:36 +02:00
|
|
|
, SlowFPBrcc(false)
|
2011-07-07 21:05:12 +02:00
|
|
|
, InThumbMode(false)
|
2011-07-07 02:08:19 +02:00
|
|
|
, HasThumb2(false)
|
2011-09-28 16:21:38 +02:00
|
|
|
, IsMClass(false)
|
2010-08-11 09:17:46 +02:00
|
|
|
, NoARM(false)
|
2009-09-30 02:10:16 +02:00
|
|
|
, PostRAScheduler(false)
|
2009-06-22 23:01:46 +02:00
|
|
|
, IsR9Reserved(ReserveR9)
|
2011-01-17 09:03:18 +01:00
|
|
|
, UseMovt(false)
|
2011-10-07 19:17:49 +02:00
|
|
|
, SupportsTailCall(false)
|
2010-03-14 19:42:38 +01:00
|
|
|
, HasFP16(false)
|
2010-10-12 18:22:47 +02:00
|
|
|
, HasD16(false)
|
2010-05-06 01:44:43 +02:00
|
|
|
, HasHardwareDivide(false)
|
|
|
|
, HasT2ExtractPack(false)
|
2010-08-11 08:22:01 +02:00
|
|
|
, HasDataBarrier(false)
|
2010-08-09 21:19:36 +02:00
|
|
|
, Pref32BitThumb(false)
|
2011-04-19 20:11:49 +02:00
|
|
|
, AvoidCPSRPartialUpdate(false)
|
2010-11-03 07:34:55 +01:00
|
|
|
, HasMPExtension(false)
|
2010-08-11 17:44:15 +02:00
|
|
|
, FPOnlySP(false)
|
2010-09-28 06:09:35 +02:00
|
|
|
, AllowsUnalignedMem(false)
|
2011-07-01 23:12:19 +02:00
|
|
|
, Thumb2DSP(false)
|
2007-02-13 20:52:28 +01:00
|
|
|
, stackAlignment(4)
|
2011-06-30 03:53:36 +02:00
|
|
|
, CPUString(CPU)
|
2011-01-11 22:46:47 +01:00
|
|
|
, TargetTriple(TT)
|
2007-02-13 20:52:28 +01:00
|
|
|
, TargetABI(ARM_ABI_APCS) {
|
2007-01-19 08:51:42 +01:00
|
|
|
// Determine default and user specified characteristics
|
2011-06-30 03:53:36 +02:00
|
|
|
if (CPUString.empty())
|
|
|
|
CPUString = "generic";
|
2009-03-08 05:02:49 +01:00
|
|
|
|
2011-06-30 04:12:44 +02: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.
|
2011-07-07 10:26:46 +02:00
|
|
|
std::string ArchFS = ARM_MC::ParseARMTriple(TT);
|
2011-07-07 02:08:19 +02:00
|
|
|
if (!FS.empty()) {
|
|
|
|
if (!ArchFS.empty())
|
|
|
|
ArchFS = ArchFS + "," + FS;
|
|
|
|
else
|
|
|
|
ArchFS = FS;
|
|
|
|
}
|
2011-07-07 09:07:08 +02:00
|
|
|
ParseSubtargetFeatures(CPUString, ArchFS);
|
2011-07-07 02:08:19 +02:00
|
|
|
|
|
|
|
// Thumb2 implies at least V6T2. FIXME: Fix tests to explicitly specify a
|
|
|
|
// ARM version or CPU and then remove this.
|
2011-07-07 05:55:05 +02:00
|
|
|
if (!HasV6T2Ops && hasThumb2())
|
|
|
|
HasV4TOps = HasV5TOps = HasV5TEOps = HasV6Ops = HasV6T2Ops = true;
|
2010-11-09 23:50:47 +01:00
|
|
|
|
2011-07-01 22:45:01 +02:00
|
|
|
// Initialize scheduling itinerary for the specified CPU.
|
|
|
|
InstrItins = getInstrItineraryForCPU(CPUString);
|
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
// After parsing Itineraries, set ItinData.IssueWidth.
|
|
|
|
computeIssueWidth();
|
|
|
|
|
2011-07-07 09:07:08 +02:00
|
|
|
if (TT.find("eabi") != std::string::npos)
|
|
|
|
TargetABI = ARM_ABI_AAPCS;
|
|
|
|
|
2007-02-13 20:52:28 +01:00
|
|
|
if (isAAPCS_ABI())
|
|
|
|
stackAlignment = 8;
|
|
|
|
|
2011-12-20 19:26:50 +01:00
|
|
|
if (!isTargetIOS())
|
2011-01-17 09:03:18 +01:00
|
|
|
UseMovt = hasV6T2Ops();
|
|
|
|
else {
|
2011-07-07 05:55:05 +02:00
|
|
|
IsR9Reserved = ReserveR9 | !HasV6Ops;
|
2011-01-21 19:55:51 +01:00
|
|
|
UseMovt = DarwinUseMOVT && hasV6T2Ops();
|
2011-10-07 19:17:49 +02:00
|
|
|
const Triple &T = getTargetTriple();
|
2011-12-20 19:26:50 +01:00
|
|
|
SupportsTailCall = !T.isOSVersionLT(5, 0);
|
2011-01-17 09:03:18 +01:00
|
|
|
}
|
2009-10-01 23:46:35 +02:00
|
|
|
|
2009-10-16 08:11:08 +02:00
|
|
|
if (!isThumb() || hasThumb2())
|
|
|
|
PostRAScheduler = true;
|
2010-09-28 06:09:35 +02:00
|
|
|
|
|
|
|
// v6+ may or may not support unaligned mem access depending on the system
|
|
|
|
// configuration.
|
|
|
|
if (!StrictAlign && hasV6Ops() && isTargetDarwin())
|
|
|
|
AllowsUnalignedMem = true;
|
2007-01-19 08:51:42 +01:00
|
|
|
}
|
2009-08-29 01:18:09 +02:00
|
|
|
|
|
|
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
2009-09-03 09:04:02 +02:00
|
|
|
bool
|
2010-04-15 03:51:59 +02:00
|
|
|
ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,
|
|
|
|
Reloc::Model RelocM) const {
|
2009-09-03 09:04:02 +02:00
|
|
|
if (RelocM == Reloc::Static)
|
2009-08-29 01:18:09 +02:00
|
|
|
return false;
|
2009-09-03 09:04:02 +02:00
|
|
|
|
2010-01-27 21:34:15 +01:00
|
|
|
// Materializable GVs (in JIT lazy compilation mode) do not require an extra
|
|
|
|
// load from stub.
|
2011-02-22 07:58:34 +01:00
|
|
|
bool isDecl = GV->hasAvailableExternallyLinkage();
|
|
|
|
if (GV->isDeclaration() && !GV->isMaterializable())
|
|
|
|
isDecl = true;
|
2009-09-03 09:04:02 +02: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 05:28:06 +01:00
|
|
|
|
2009-09-03 09:04:02 +02: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 01:18:09 +02:00
|
|
|
}
|
2009-11-10 01:48:55 +01:00
|
|
|
|
2010-09-28 23:57:50 +02:00
|
|
|
unsigned ARMSubtarget::getMispredictionPenalty() const {
|
|
|
|
// If we have a reasonable estimate of the pipeline depth, then we can
|
|
|
|
// estimate the penalty of a misprediction based on that.
|
|
|
|
if (isCortexA8())
|
|
|
|
return 13;
|
|
|
|
else if (isCortexA9())
|
|
|
|
return 8;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2010-09-28 23:57:50 +02:00
|
|
|
// Otherwise, just return a sensible default.
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
void ARMSubtarget::computeIssueWidth() {
|
|
|
|
unsigned allStage1Units = 0;
|
|
|
|
for (const InstrItinerary *itin = InstrItins.Itineraries;
|
|
|
|
itin->FirstStage != ~0U; ++itin) {
|
|
|
|
const InstrStage *IS = InstrItins.Stages + itin->FirstStage;
|
|
|
|
allStage1Units |= IS->getUnits();
|
|
|
|
}
|
|
|
|
InstrItins.IssueWidth = 0;
|
|
|
|
while (allStage1Units) {
|
|
|
|
++InstrItins.IssueWidth;
|
|
|
|
// clear the lowest bit
|
|
|
|
allStage1Units ^= allStage1Units & ~(allStage1Units - 1);
|
|
|
|
}
|
2011-01-04 01:32:57 +01:00
|
|
|
assert(InstrItins.IssueWidth <= 2 && "itinerary bug, too many stage 1 units");
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
}
|
|
|
|
|
2009-11-10 01:48:55 +01:00
|
|
|
bool ARMSubtarget::enablePostRAScheduler(
|
|
|
|
CodeGenOpt::Level OptLevel,
|
2011-07-01 23:01:15 +02:00
|
|
|
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
2009-11-13 20:52:48 +01:00
|
|
|
RegClassVector& CriticalPathRCs) const {
|
2011-07-01 23:01:15 +02:00
|
|
|
Mode = TargetSubtargetInfo::ANTIDEP_CRITICAL;
|
2009-11-13 20:52:48 +01:00
|
|
|
CriticalPathRCs.clear();
|
|
|
|
CriticalPathRCs.push_back(&ARM::GPRRegClass);
|
2009-11-10 01:48:55 +01:00
|
|
|
return PostRAScheduler && OptLevel >= CodeGenOpt::Default;
|
|
|
|
}
|