1 //===-- ARMSubtarget.cpp - ARM Subtarget Information ----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ARM specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #include "ARMSubtarget.h"
15 #include "ARMBaseRegisterInfo.h"
16 #include "llvm/GlobalValue.h"
17 #include "llvm/Target/TargetSubtargetInfo.h"
18 #include "llvm/Support/CommandLine.h"
20 #define GET_SUBTARGETINFO_TARGET_DESC
21 #define GET_SUBTARGETINFO_CTOR
22 #include "ARMGenSubtargetInfo.inc"
27 ReserveR9("arm-reserve-r9", cl::Hidden,
28 cl::desc("Reserve R9, making it unavailable as GPR"));
31 DarwinUseMOVT("arm-darwin-use-movt", cl::init(true), cl::Hidden);
34 StrictAlign("arm-strict-align", cl::Hidden,
35 cl::desc("Disallow all unaligned memory accesses"));
37 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
38 const std::string &FS)
39 : ARMGenSubtargetInfo(TT, CPU, FS)
40 , ARMProcFamily(Others)
51 , UseNEONForSinglePrecisionFP(false)
53 , HasVMLxForwarding(false)
59 , PostRAScheduler(false)
60 , IsR9Reserved(ReserveR9)
62 , SupportsTailCall(false)
65 , HasHardwareDivide(false)
66 , HasT2ExtractPack(false)
67 , HasDataBarrier(false)
68 , Pref32BitThumb(false)
69 , AvoidCPSRPartialUpdate(false)
71 , HasMPExtension(false)
73 , AllowsUnalignedMem(false)
78 , TargetABI(ARM_ABI_APCS) {
79 // Determine default and user specified characteristics
80 if (CPUString.empty())
81 CPUString = "generic";
83 // Insert the architecture feature derived from the target triple into the
84 // feature string. This is important for setting features that are implied
85 // based on the architecture version.
86 std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPUString);
89 ArchFS = ArchFS + "," + FS;
93 ParseSubtargetFeatures(CPUString, ArchFS);
95 // Thumb2 implies at least V6T2. FIXME: Fix tests to explicitly specify a
96 // ARM version or CPU and then remove this.
97 if (!HasV6T2Ops && hasThumb2())
98 HasV4TOps = HasV5TOps = HasV5TEOps = HasV6Ops = HasV6T2Ops = true;
100 // Initialize scheduling itinerary for the specified CPU.
101 InstrItins = getInstrItineraryForCPU(CPUString);
103 if ((TT.find("eabi") != std::string::npos) || (isTargetIOS() && isMClass()))
104 // FIXME: We might want to separate AAPCS and EABI. Some systems, e.g.
105 // Darwin-EABI conforms to AACPS but not the rest of EABI.
106 TargetABI = ARM_ABI_AAPCS;
112 UseMovt = hasV6T2Ops();
114 IsR9Reserved = ReserveR9 | !HasV6Ops;
115 UseMovt = DarwinUseMOVT && hasV6T2Ops();
116 SupportsTailCall = !getTargetTriple().isOSVersionLT(5, 0);
119 if (!isThumb() || hasThumb2())
120 PostRAScheduler = true;
122 // v6+ may or may not support unaligned mem access depending on the system
124 if (!StrictAlign && hasV6Ops() && isTargetDarwin())
125 AllowsUnalignedMem = true;
128 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
130 ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,
131 Reloc::Model RelocM) const {
132 if (RelocM == Reloc::Static)
135 // Materializable GVs (in JIT lazy compilation mode) do not require an extra
137 bool isDecl = GV->hasAvailableExternallyLinkage();
138 if (GV->isDeclaration() && !GV->isMaterializable())
141 if (!isTargetDarwin()) {
142 // Extra load is needed for all externally visible.
143 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
147 if (RelocM == Reloc::PIC_) {
148 // If this is a strong reference to a definition, it is definitely not
150 if (!isDecl && !GV->isWeakForLinker())
153 // Unless we have a symbol with hidden visibility, we have to go through a
154 // normal $non_lazy_ptr stub because this symbol might be resolved late.
155 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
158 // If symbol visibility is hidden, we have a stub for common symbol
159 // references and external declarations.
160 if (isDecl || GV->hasCommonLinkage())
161 // Hidden $non_lazy_ptr reference.
166 // If this is a strong reference to a definition, it is definitely not
168 if (!isDecl && !GV->isWeakForLinker())
171 // Unless we have a symbol with hidden visibility, we have to go through a
172 // normal $non_lazy_ptr stub because this symbol might be resolved late.
173 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
181 unsigned ARMSubtarget::getMispredictionPenalty() const {
182 // If we have a reasonable estimate of the pipeline depth, then we can
183 // estimate the penalty of a misprediction based on that.
186 else if (isCortexA9())
189 // Otherwise, just return a sensible default.
193 bool ARMSubtarget::enablePostRAScheduler(
194 CodeGenOpt::Level OptLevel,
195 TargetSubtargetInfo::AntiDepBreakMode& Mode,
196 RegClassVector& CriticalPathRCs) const {
197 Mode = TargetSubtargetInfo::ANTIDEP_CRITICAL;
198 CriticalPathRCs.clear();
199 CriticalPathRCs.push_back(&ARM::GPRRegClass);
200 return PostRAScheduler && OptLevel >= CodeGenOpt::Default;