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 "ARMBaseInstrInfo.h"
17 #include "llvm/GlobalValue.h"
18 #include "llvm/Target/TargetInstrInfo.h"
19 #include "llvm/Support/CommandLine.h"
21 #define GET_SUBTARGETINFO_TARGET_DESC
22 #define GET_SUBTARGETINFO_CTOR
23 #include "ARMGenSubtargetInfo.inc"
28 ReserveR9("arm-reserve-r9", cl::Hidden,
29 cl::desc("Reserve R9, making it unavailable as GPR"));
32 DarwinUseMOVT("arm-darwin-use-movt", cl::init(true), cl::Hidden);
35 UseFusedMulOps("arm-use-mulops",
36 cl::init(true), cl::Hidden);
39 StrictAlign("arm-strict-align", cl::Hidden,
40 cl::desc("Disallow all unaligned memory accesses"));
42 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
43 const std::string &FS)
44 : ARMGenSubtargetInfo(TT, CPU, FS)
45 , ARMProcFamily(Others)
56 , UseNEONForSinglePrecisionFP(false)
57 , UseMulOps(UseFusedMulOps)
59 , HasVMLxForwarding(false)
65 , PostRAScheduler(false)
66 , IsR9Reserved(ReserveR9)
68 , SupportsTailCall(false)
71 , HasHardwareDivide(false)
72 , HasHardwareDivideInARM(false)
73 , HasT2ExtractPack(false)
74 , HasDataBarrier(false)
75 , Pref32BitThumb(false)
76 , AvoidCPSRPartialUpdate(false)
78 , HasMPExtension(false)
80 , AllowsUnalignedMem(false)
85 , TargetABI(ARM_ABI_APCS) {
86 // Determine default and user specified characteristics
87 if (CPUString.empty())
88 CPUString = "generic";
90 // Insert the architecture feature derived from the target triple into the
91 // feature string. This is important for setting features that are implied
92 // based on the architecture version.
93 std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPUString);
96 ArchFS = ArchFS + "," + FS;
100 ParseSubtargetFeatures(CPUString, ArchFS);
102 // Thumb2 implies at least V6T2. FIXME: Fix tests to explicitly specify a
103 // ARM version or CPU and then remove this.
104 if (!HasV6T2Ops && hasThumb2())
105 HasV4TOps = HasV5TOps = HasV5TEOps = HasV6Ops = HasV6T2Ops = true;
107 // Keep a pointer to static instruction cost data for the specified CPU.
108 SchedModel = getSchedModelForCPU(CPUString);
110 // Initialize scheduling itinerary for the specified CPU.
111 InstrItins = getInstrItineraryForCPU(CPUString);
113 if ((TT.find("eabi") != std::string::npos) || (isTargetIOS() && isMClass()))
114 // FIXME: We might want to separate AAPCS and EABI. Some systems, e.g.
115 // Darwin-EABI conforms to AACPS but not the rest of EABI.
116 TargetABI = ARM_ABI_AAPCS;
122 UseMovt = hasV6T2Ops();
124 IsR9Reserved = ReserveR9 | !HasV6Ops;
125 UseMovt = DarwinUseMOVT && hasV6T2Ops();
126 SupportsTailCall = !getTargetTriple().isOSVersionLT(5, 0);
129 if (!isThumb() || hasThumb2())
130 PostRAScheduler = true;
132 // v6+ may or may not support unaligned mem access depending on the system
134 if (!StrictAlign && hasV6Ops() && isTargetDarwin())
135 AllowsUnalignedMem = true;
138 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
140 ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV,
141 Reloc::Model RelocM) const {
142 if (RelocM == Reloc::Static)
145 // Materializable GVs (in JIT lazy compilation mode) do not require an extra
147 bool isDecl = GV->hasAvailableExternallyLinkage();
148 if (GV->isDeclaration() && !GV->isMaterializable())
151 if (!isTargetDarwin()) {
152 // Extra load is needed for all externally visible.
153 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
157 if (RelocM == Reloc::PIC_) {
158 // If this is a strong reference to a definition, it is definitely not
160 if (!isDecl && !GV->isWeakForLinker())
163 // Unless we have a symbol with hidden visibility, we have to go through a
164 // normal $non_lazy_ptr stub because this symbol might be resolved late.
165 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
168 // If symbol visibility is hidden, we have a stub for common symbol
169 // references and external declarations.
170 if (isDecl || GV->hasCommonLinkage())
171 // Hidden $non_lazy_ptr reference.
176 // If this is a strong reference to a definition, it is definitely not
178 if (!isDecl && !GV->isWeakForLinker())
181 // Unless we have a symbol with hidden visibility, we have to go through a
182 // normal $non_lazy_ptr stub because this symbol might be resolved late.
183 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
191 unsigned ARMSubtarget::getMispredictionPenalty() const {
192 return SchedModel->MispredictPenalty;
195 bool ARMSubtarget::enablePostRAScheduler(
196 CodeGenOpt::Level OptLevel,
197 TargetSubtargetInfo::AntiDepBreakMode& Mode,
198 RegClassVector& CriticalPathRCs) const {
199 Mode = TargetSubtargetInfo::ANTIDEP_CRITICAL;
200 CriticalPathRCs.clear();
201 CriticalPathRCs.push_back(&ARM::GPRRegClass);
202 return PostRAScheduler && OptLevel >= CodeGenOpt::Default;