2007-01-19 07:51:42 +00:00
|
|
|
//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 07:51:42 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the ARM specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "ARMGenSubtarget.inc"
|
2011-01-11 21:46:47 +00:00
|
|
|
#include "ARMBaseRegisterInfo.h"
|
2009-08-28 23:18:09 +00:00
|
|
|
#include "llvm/GlobalValue.h"
|
2009-06-22 21:01:46 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-11-10 00:48:55 +00:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-22 21:01:46 +00:00
|
|
|
static cl::opt<bool>
|
|
|
|
ReserveR9("arm-reserve-r9", cl::Hidden,
|
|
|
|
cl::desc("Reserve R9, making it unavailable as GPR"));
|
|
|
|
|
2009-11-24 00:44:37 +00:00
|
|
|
static cl::opt<bool>
|
2011-01-21 18:55:51 +00:00
|
|
|
DarwinUseMOVT("arm-darwin-use-movt", cl::init(true), cl::Hidden);
|
2009-11-24 00:44:37 +00:00
|
|
|
|
2010-09-28 04:09:35 +00:00
|
|
|
static cl::opt<bool>
|
|
|
|
StrictAlign("arm-strict-align", cl::Hidden,
|
|
|
|
cl::desc("Disallow all unaligned memory accesses"));
|
|
|
|
|
2009-08-02 22:11:08 +00:00
|
|
|
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
2009-10-16 06:11:08 +00:00
|
|
|
bool isT)
|
2010-03-06 19:39:36 +00:00
|
|
|
: ARMArchVersion(V4)
|
2010-09-10 01:29:16 +00:00
|
|
|
, ARMProcFamily(Others)
|
2009-05-23 19:51:43 +00:00
|
|
|
, ARMFPUType(None)
|
2010-03-25 23:47:34 +00:00
|
|
|
, UseNEONForSinglePrecisionFP(false)
|
2010-12-05 22:04:16 +00:00
|
|
|
, SlowFPVMLx(false)
|
2011-04-01 09:20:31 +00:00
|
|
|
, HasVMLxForwarding(false)
|
2010-08-09 19:19:36 +00:00
|
|
|
, SlowFPBrcc(false)
|
2009-10-16 06:11:08 +00:00
|
|
|
, IsThumb(isT)
|
2009-06-01 20:00:48 +00:00
|
|
|
, ThumbMode(Thumb1)
|
2010-08-11 07:17:46 +00:00
|
|
|
, NoARM(false)
|
2009-09-30 00:10:16 +00:00
|
|
|
, PostRAScheduler(false)
|
2009-06-22 21:01:46 +00:00
|
|
|
, IsR9Reserved(ReserveR9)
|
2011-01-17 08:03:18 +00:00
|
|
|
, UseMovt(false)
|
2010-03-14 18:42:38 +00:00
|
|
|
, HasFP16(false)
|
2010-10-12 16:22:47 +00:00
|
|
|
, HasD16(false)
|
2010-05-05 23:44:43 +00:00
|
|
|
, HasHardwareDivide(false)
|
|
|
|
, HasT2ExtractPack(false)
|
2010-08-11 06:22:01 +00:00
|
|
|
, HasDataBarrier(false)
|
2010-08-09 19:19:36 +00:00
|
|
|
, Pref32BitThumb(false)
|
2011-04-19 18:11:49 +00:00
|
|
|
, AvoidCPSRPartialUpdate(false)
|
2010-11-03 06:34:55 +00:00
|
|
|
, HasMPExtension(false)
|
2010-08-11 15:44:15 +00:00
|
|
|
, FPOnlySP(false)
|
2010-09-28 04:09:35 +00:00
|
|
|
, AllowsUnalignedMem(false)
|
2007-02-13 19:52:28 +00:00
|
|
|
, stackAlignment(4)
|
2009-05-23 19:50:50 +00:00
|
|
|
, CPUString("generic")
|
2011-01-11 21:46:47 +00:00
|
|
|
, TargetTriple(TT)
|
2007-02-13 19:52:28 +00:00
|
|
|
, TargetABI(ARM_ABI_APCS) {
|
2007-01-19 07:51:42 +00:00
|
|
|
// Determine default and user specified characteristics
|
|
|
|
|
2010-03-06 19:39:36 +00:00
|
|
|
// When no arch is specified either by CPU or by attributes, make the default
|
|
|
|
// ARMv4T.
|
2010-11-09 22:50:47 +00:00
|
|
|
const char *ARMArchFeature = "";
|
|
|
|
if (CPUString == "generic" && (FS.empty() || FS == "generic")) {
|
2010-03-06 19:39:36 +00:00
|
|
|
ARMArchVersion = V4T;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v4t";
|
|
|
|
}
|
2010-03-06 19:39:36 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Set the boolean corresponding to the current target triple, or the default
|
|
|
|
// if one cannot be determined, to true.
|
2009-03-08 04:02:49 +00:00
|
|
|
unsigned Len = TT.length();
|
2009-03-09 20:25:39 +00:00
|
|
|
unsigned Idx = 0;
|
2009-05-29 23:41:08 +00:00
|
|
|
|
2009-03-09 20:25:39 +00:00
|
|
|
if (Len >= 5 && TT.substr(0, 4) == "armv")
|
|
|
|
Idx = 4;
|
2009-06-22 21:28:22 +00:00
|
|
|
else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
|
2009-06-01 20:00:48 +00:00
|
|
|
IsThumb = true;
|
2009-03-09 20:25:39 +00:00
|
|
|
if (Len >= 7 && TT[5] == 'v')
|
|
|
|
Idx = 6;
|
|
|
|
}
|
|
|
|
if (Idx) {
|
|
|
|
unsigned SubVer = TT[Idx];
|
2010-03-06 19:39:36 +00:00
|
|
|
if (SubVer >= '7' && SubVer <= '9') {
|
|
|
|
ARMArchVersion = V7A;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v7a";
|
|
|
|
if (Len >= Idx+2 && TT[Idx+1] == 'm') {
|
2010-05-05 20:44:35 +00:00
|
|
|
ARMArchVersion = V7M;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v7m";
|
|
|
|
}
|
2010-03-06 19:39:36 +00:00
|
|
|
} else if (SubVer == '6') {
|
|
|
|
ARMArchVersion = V6;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v6";
|
|
|
|
if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') {
|
2010-03-06 19:39:36 +00:00
|
|
|
ARMArchVersion = V6T2;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v6t2";
|
|
|
|
}
|
2010-03-06 19:39:36 +00:00
|
|
|
} else if (SubVer == '5') {
|
|
|
|
ARMArchVersion = V5T;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v5t";
|
|
|
|
if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') {
|
2010-03-06 19:39:36 +00:00
|
|
|
ARMArchVersion = V5TE;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v5te";
|
|
|
|
}
|
2010-03-06 19:39:36 +00:00
|
|
|
} else if (SubVer == '4') {
|
2010-11-09 22:50:47 +00:00
|
|
|
if (Len >= Idx+2 && TT[Idx+1] == 't') {
|
2010-03-06 19:39:36 +00:00
|
|
|
ARMArchVersion = V4T;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = ",+v4t";
|
|
|
|
} else {
|
2010-03-06 19:39:36 +00:00
|
|
|
ARMArchVersion = V4;
|
2010-11-09 22:50:47 +00:00
|
|
|
ARMArchFeature = "";
|
|
|
|
}
|
2009-03-08 04:02:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-13 19:52:28 +00:00
|
|
|
if (TT.find("eabi") != std::string::npos)
|
|
|
|
TargetABI = ARM_ABI_AAPCS;
|
|
|
|
|
2010-11-09 22:50:47 +00:00
|
|
|
// Parse features string. If the first entry in FS (the CPU) is missing,
|
|
|
|
// insert the architecture feature derived from the target triple. This is
|
|
|
|
// important for setting features that are implied based on the architecture
|
|
|
|
// version.
|
|
|
|
std::string FSWithArch;
|
|
|
|
if (FS.empty())
|
|
|
|
FSWithArch = std::string(ARMArchFeature);
|
|
|
|
else if (FS.find(',') == 0)
|
|
|
|
FSWithArch = std::string(ARMArchFeature) + FS;
|
|
|
|
else
|
|
|
|
FSWithArch = FS;
|
|
|
|
CPUString = ParseSubtargetFeatures(FSWithArch, 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
// After parsing Itineraries, set ItinData.IssueWidth.
|
|
|
|
computeIssueWidth();
|
|
|
|
|
2010-11-09 22:50:47 +00:00
|
|
|
// Thumb2 implies at least V6T2.
|
|
|
|
if (ARMArchVersion >= V6T2)
|
|
|
|
ThumbMode = Thumb2;
|
|
|
|
else if (ThumbMode >= Thumb2)
|
|
|
|
ARMArchVersion = V6T2;
|
|
|
|
|
2007-02-13 19:52:28 +00:00
|
|
|
if (isAAPCS_ABI())
|
|
|
|
stackAlignment = 8;
|
|
|
|
|
2011-01-17 08:03:18 +00:00
|
|
|
if (!isTargetDarwin())
|
|
|
|
UseMovt = hasV6T2Ops();
|
|
|
|
else {
|
2009-06-22 21:01:46 +00:00
|
|
|
IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);
|
2011-01-21 18:55:51 +00:00
|
|
|
UseMovt = DarwinUseMOVT && hasV6T2Ops();
|
2011-01-17 08:03:18 +00:00
|
|
|
}
|
2009-10-01 21:46:35 +00:00
|
|
|
|
2009-10-16 06:11:08 +00:00
|
|
|
if (!isThumb() || hasThumb2())
|
|
|
|
PostRAScheduler = true;
|
2010-09-28 04:09:35 +00:00
|
|
|
|
|
|
|
// v6+ may or may not support unaligned mem access depending on the system
|
|
|
|
// configuration.
|
|
|
|
if (!StrictAlign && hasV6Ops() && isTargetDarwin())
|
|
|
|
AllowsUnalignedMem = true;
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
2009-08-28 23:18:09 +00:00
|
|
|
|
|
|
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
2009-09-03 07:04:02 +00:00
|
|
|
bool
|
2010-04-15 01:51:59 +00:00
|
|
|
ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,
|
|
|
|
Reloc::Model RelocM) const {
|
2009-09-03 07:04:02 +00:00
|
|
|
if (RelocM == Reloc::Static)
|
2009-08-28 23:18:09 +00:00
|
|
|
return false;
|
2009-09-03 07:04:02 +00:00
|
|
|
|
2010-01-27 20:34:15 +00:00
|
|
|
// Materializable GVs (in JIT lazy compilation mode) do not require an extra
|
|
|
|
// load from stub.
|
2011-02-22 06:58:34 +00:00
|
|
|
bool isDecl = GV->hasAvailableExternallyLinkage();
|
|
|
|
if (GV->isDeclaration() && !GV->isMaterializable())
|
|
|
|
isDecl = true;
|
2009-09-03 07:04:02 +00: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 04:28:06 +00:00
|
|
|
|
2009-09-03 07:04:02 +00: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-28 23:18:09 +00:00
|
|
|
}
|
2009-11-10 00:48:55 +00:00
|
|
|
|
2010-09-28 21:57:50 +00: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 04:28:06 +00:00
|
|
|
|
2010-09-28 21:57:50 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00: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 00:32:57 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 00:48:55 +00:00
|
|
|
bool ARMSubtarget::enablePostRAScheduler(
|
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
TargetSubtarget::AntiDepBreakMode& Mode,
|
2009-11-13 19:52:48 +00:00
|
|
|
RegClassVector& CriticalPathRCs) const {
|
2009-11-10 00:48:55 +00:00
|
|
|
Mode = TargetSubtarget::ANTIDEP_CRITICAL;
|
2009-11-13 19:52:48 +00:00
|
|
|
CriticalPathRCs.clear();
|
|
|
|
CriticalPathRCs.push_back(&ARM::GPRRegClass);
|
2009-11-10 00:48:55 +00:00
|
|
|
return PostRAScheduler && OptLevel >= CodeGenOpt::Default;
|
|
|
|
}
|