blob: 23027e92481f16cacc5c1749d0e7aefd1e620fb2 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- ARMSubtarget.cpp - ARM Subtarget Information ----------------------===//
Evan Cheng10043e22007-01-19 07:51:42 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Cheng10043e22007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file implements the ARM specific subclass of TargetSubtargetInfo.
Evan Cheng10043e22007-01-19 07:51:42 +000011//
12//===----------------------------------------------------------------------===//
13
Quentin Colombet51b7af32017-07-01 00:45:45 +000014#include "ARM.h"
15
Quentin Colombet51b7af32017-07-01 00:45:45 +000016#include "ARMCallLowering.h"
17#include "ARMLegalizerInfo.h"
18#include "ARMRegisterBankInfo.h"
Evan Cheng10043e22007-01-19 07:51:42 +000019#include "ARMSubtarget.h"
Eric Christopher80b24ef2014-06-26 19:30:02 +000020#include "ARMFrameLowering.h"
Eric Christopher80b24ef2014-06-26 19:30:02 +000021#include "ARMInstrInfo.h"
Eric Christopher80b24ef2014-06-26 19:30:02 +000022#include "ARMSubtarget.h"
Eric Christopher661f2d12014-12-18 02:20:58 +000023#include "ARMTargetMachine.h"
Eugene Zelenkoe79c0772017-01-27 23:58:02 +000024#include "MCTargetDesc/ARMMCTargetDesc.h"
Eric Christopher80b24ef2014-06-26 19:30:02 +000025#include "Thumb1FrameLowering.h"
26#include "Thumb1InstrInfo.h"
27#include "Thumb2InstrInfo.h"
Eugene Zelenkoe79c0772017-01-27 23:58:02 +000028#include "llvm/ADT/StringRef.h"
29#include "llvm/ADT/Triple.h"
30#include "llvm/ADT/Twine.h"
Quentin Colombet51b7af32017-07-01 00:45:45 +000031#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
Eugene Zelenkoe79c0772017-01-27 23:58:02 +000032#include "llvm/CodeGen/MachineFunction.h"
Bill Wendling5a92eec2013-02-15 22:41:25 +000033#include "llvm/IR/Function.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000034#include "llvm/IR/GlobalValue.h"
Tim Northover747ae9a2015-11-18 21:10:39 +000035#include "llvm/MC/MCAsmInfo.h"
Eugene Zelenkoe79c0772017-01-27 23:58:02 +000036#include "llvm/MC/MCTargetOptions.h"
Eugene Zelenkoe79c0772017-01-27 23:58:02 +000037#include "llvm/Support/CodeGen.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000038#include "llvm/Support/CommandLine.h"
Zijiao Ma53d55f42016-08-17 02:08:28 +000039#include "llvm/Support/TargetParser.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000040#include "llvm/Target/TargetOptions.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000041
Chandler Carruthd174b722014-04-22 02:03:14 +000042using namespace llvm;
43
Chandler Carruthe96dd892014-04-21 22:55:11 +000044#define DEBUG_TYPE "arm-subtarget"
45
Evan Cheng54b68e32011-07-01 20:45:01 +000046#define GET_SUBTARGETINFO_TARGET_DESC
Evan Cheng4d1ca962011-07-08 01:53:10 +000047#define GET_SUBTARGETINFO_CTOR
Evan Chengc9c090d2011-07-01 22:36:09 +000048#include "ARMGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000049
Bob Wilson45825302009-06-22 21:01:46 +000050static cl::opt<bool>
Bob Wilsone8a549c2012-09-29 21:43:49 +000051UseFusedMulOps("arm-use-mulops",
52 cl::init(true), cl::Hidden);
53
Weiming Zhao0da5cc02013-11-13 18:29:49 +000054enum ITMode {
55 DefaultIT,
56 RestrictedIT,
57 NoRestrictedIT
58};
59
60static cl::opt<ITMode>
61IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT),
62 cl::ZeroOrMore,
63 cl::values(clEnumValN(DefaultIT, "arm-default-it",
64 "Generate IT block based on arch"),
65 clEnumValN(RestrictedIT, "arm-restrict-it",
66 "Disallow deprecated IT based on ARMv8"),
67 clEnumValN(NoRestrictedIT, "arm-no-restrict-it",
Mehdi Amini732afdd2016-10-08 19:41:06 +000068 "Allow IT blocks based on ARMv7")));
Weiming Zhao0da5cc02013-11-13 18:29:49 +000069
Oliver Stannardf2ed5c62015-09-23 09:19:54 +000070/// ForceFastISel - Use the fast-isel, even for subtargets where it is not
71/// currently supported (for testing only).
72static cl::opt<bool>
73ForceFastISel("arm-force-fast-isel",
74 cl::init(false), cl::Hidden);
75
Eric Christophera47f6802014-06-13 00:20:35 +000076/// initializeSubtargetDependencies - Initializes using a CPU and feature string
77/// so that we can use initializer lists for subtarget initialization.
78ARMSubtarget &ARMSubtarget::initializeSubtargetDependencies(StringRef CPU,
79 StringRef FS) {
80 initializeEnvironment();
Eric Christopherb68e2532014-09-03 20:36:31 +000081 initSubtargetFeatures(CPU, FS);
Eric Christophera47f6802014-06-13 00:20:35 +000082 return *this;
83}
84
Eric Christopher8b770652015-01-26 19:03:15 +000085ARMFrameLowering *ARMSubtarget::initializeFrameLowering(StringRef CPU,
86 StringRef FS) {
87 ARMSubtarget &STI = initializeSubtargetDependencies(CPU, FS);
88 if (STI.isThumb1Only())
89 return (ARMFrameLowering *)new Thumb1FrameLowering(STI);
90
91 return new ARMFrameLowering(STI);
92}
93
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000094ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
Eric Christopher8b770652015-01-26 19:03:15 +000095 const std::string &FS,
96 const ARMBaseTargetMachine &TM, bool IsLittle)
Diana Picuseb1068a2016-06-27 13:06:10 +000097 : ARMGenSubtargetInfo(TT, CPU, FS), UseMulOps(UseFusedMulOps),
Eric Christopher015dc202017-07-01 02:55:22 +000098 CPUString(CPU), IsLittle(IsLittle), TargetTriple(TT), Options(TM.Options),
99 TM(TM), FrameLowering(initializeFrameLowering(CPU, FS)),
Eric Christopher8b770652015-01-26 19:03:15 +0000100 // At this point initializeSubtargetDependencies has been called so
101 // we can query directly.
Eric Christopher80b24ef2014-06-26 19:30:02 +0000102 InstrInfo(isThumb1Only()
103 ? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
104 : !isThumb()
105 ? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
106 : (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
Quentin Colombet51b7af32017-07-01 00:45:45 +0000107 TLInfo(TM, *this) {
Eric Christopher3df231a2017-07-01 03:41:53 +0000108
Quentin Colombet61d71a12017-08-15 22:31:51 +0000109 CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));
110 Legalizer.reset(new ARMLegalizerInfo(*this));
Quentin Colombet51b7af32017-07-01 00:45:45 +0000111
112 auto *RBI = new ARMRegisterBankInfo(*getRegisterInfo());
113
114 // FIXME: At this point, we can't rely on Subtarget having RBI.
115 // It's awkward to mix passing RBI and the Subtarget; should we pass
116 // TII/TRI as well?
Quentin Colombet61d71a12017-08-15 22:31:51 +0000117 InstSelector.reset(createARMInstructionSelector(
Quentin Colombet51b7af32017-07-01 00:45:45 +0000118 *static_cast<const ARMBaseTargetMachine *>(&TM), *this, *RBI));
119
Quentin Colombet61d71a12017-08-15 22:31:51 +0000120 RegBankInfo.reset(RBI);
Quentin Colombet51b7af32017-07-01 00:45:45 +0000121}
Diana Picus22274932016-11-11 08:27:37 +0000122
123const CallLowering *ARMSubtarget::getCallLowering() const {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000124 return CallLoweringInfo.get();
Diana Picus22274932016-11-11 08:27:37 +0000125}
126
127const InstructionSelector *ARMSubtarget::getInstructionSelector() const {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000128 return InstSelector.get();
Diana Picus22274932016-11-11 08:27:37 +0000129}
130
131const LegalizerInfo *ARMSubtarget::getLegalizerInfo() const {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000132 return Legalizer.get();
Diana Picus22274932016-11-11 08:27:37 +0000133}
134
135const RegisterBankInfo *ARMSubtarget::getRegBankInfo() const {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000136 return RegBankInfo.get();
Diana Picus22274932016-11-11 08:27:37 +0000137}
Bill Wendling5a92eec2013-02-15 22:41:25 +0000138
Dean Michael Berris464015442016-09-19 00:54:35 +0000139bool ARMSubtarget::isXRaySupported() const {
140 // We don't currently suppport Thumb, but Windows requires Thumb.
141 return hasV6Ops() && hasARMOps() && !isTargetWindows();
142}
143
Bill Wendling61375d82013-02-16 01:36:26 +0000144void ARMSubtarget::initializeEnvironment() {
Tim Northover747ae9a2015-11-18 21:10:39 +0000145 // MCAsmInfo isn't always present (e.g. in opt) so we can't initialize this
146 // directly from it, but we can try to make sure they're consistent when both
147 // available.
Martin Storsjoadceba52017-09-28 19:04:14 +0000148 UseSjLjEH = (isTargetDarwin() && !isTargetWatchABI() &&
149 Options.ExceptionModel == ExceptionHandling::None) ||
150 Options.ExceptionModel == ExceptionHandling::SjLj;
Tim Northover747ae9a2015-11-18 21:10:39 +0000151 assert((!TM.getMCAsmInfo() ||
152 (TM.getMCAsmInfo()->getExceptionHandlingType() ==
153 ExceptionHandling::SjLj) == UseSjLjEH) &&
154 "inconsistent sjlj choice between CodeGen and MC");
Bill Wendling61375d82013-02-16 01:36:26 +0000155}
156
Eric Christopherb68e2532014-09-03 20:36:31 +0000157void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
Tilmann Scheller63872ce2013-09-02 17:09:01 +0000158 if (CPUString.empty()) {
Tim Northovere0ccdc62015-10-28 22:46:43 +0000159 CPUString = "generic";
160
161 if (isTargetDarwin()) {
162 StringRef ArchName = TargetTriple.getArchName();
Florian Hahn67ddd1d2017-07-27 16:27:56 +0000163 ARM::ArchKind AK = ARM::parseArch(ArchName);
164 if (AK == ARM::ArchKind::ARMV7S)
Tim Northovere0ccdc62015-10-28 22:46:43 +0000165 // Default to the Swift CPU when targeting armv7s/thumbv7s.
166 CPUString = "swift";
Florian Hahn67ddd1d2017-07-27 16:27:56 +0000167 else if (AK == ARM::ArchKind::ARMV7K)
Tim Northovere0ccdc62015-10-28 22:46:43 +0000168 // Default to the Cortex-a7 CPU when targeting armv7k/thumbv7k.
169 // ARMv7k does not use SjLj exception handling.
170 CPUString = "cortex-a7";
171 }
Tilmann Scheller63872ce2013-09-02 17:09:01 +0000172 }
Evan Chengec415ef2009-03-08 04:02:49 +0000173
Evan Cheng0b33a322011-06-30 02:12:44 +0000174 // Insert the architecture feature derived from the target triple into the
175 // feature string. This is important for setting features that are implied
176 // based on the architecture version.
Daniel Sanders50f17232015-09-15 16:17:27 +0000177 std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple, CPUString);
Evan Cheng2bd65362011-07-07 00:08:19 +0000178 if (!FS.empty()) {
179 if (!ArchFS.empty())
Yaron Keren075759a2015-03-30 15:42:36 +0000180 ArchFS = (Twine(ArchFS) + "," + FS).str();
Evan Cheng2bd65362011-07-07 00:08:19 +0000181 else
182 ArchFS = FS;
183 }
Evan Cheng1a72add62011-07-07 07:07:08 +0000184 ParseSubtargetFeatures(CPUString, ArchFS);
Evan Cheng2bd65362011-07-07 00:08:19 +0000185
Joerg Sonnenberger002a1472013-12-13 11:16:00 +0000186 // FIXME: This used enable V6T2 support implicitly for Thumb2 mode.
187 // Assert this for now to make the change obvious.
188 assert(hasV6T2Ops() || !hasThumb2());
Bob Wilsond0046ca2010-11-09 22:50:47 +0000189
Prakhar Bahuguna52a7dd72016-12-15 07:59:08 +0000190 // Execute only support requires movt support
191 if (genExecuteOnly())
192 assert(hasV8MBaselineOps() && !NoMovt && "Cannot generate execute-only code for this target");
193
Andrew Trick352abc12012-08-08 02:44:16 +0000194 // Keep a pointer to static instruction cost data for the specified CPU.
195 SchedModel = getSchedModelForCPU(CPUString);
196
Evan Cheng54b68e32011-07-01 20:45:01 +0000197 // Initialize scheduling itinerary for the specified CPU.
198 InstrItins = getInstrItineraryForCPU(CPUString);
199
Saleem Abdulrasoolcd130822014-04-02 20:32:05 +0000200 // FIXME: this is invalid for WindowsCE
Eric Christopher1971c352014-12-18 02:08:45 +0000201 if (isTargetWindows())
Saleem Abdulrasoolcd130822014-04-02 20:32:05 +0000202 NoARM = true;
Saleem Abdulrasoolcd130822014-04-02 20:32:05 +0000203
Lauro Ramos Venancio048e16ff2007-02-13 19:52:28 +0000204 if (isAAPCS_ABI())
205 stackAlignment = 8;
Tim Northovere0ccdc62015-10-28 22:46:43 +0000206 if (isTargetNaCl() || isAAPCS16_ABI())
Mark Seabornbe266aa2014-02-16 18:59:48 +0000207 stackAlignment = 16;
Lauro Ramos Venancio048e16ff2007-02-13 19:52:28 +0000208
Artyom Skrobovad8a0632015-09-28 09:44:11 +0000209 // FIXME: Completely disable sibcall for Thumb1 since ThumbRegisterInfo::
210 // emitEpilogue is not ready for them. Thumb tail calls also use t2B, as
211 // the Thumb1 16-bit unconditional branch doesn't have sufficient relocation
212 // support in the assembler and linker to be used. This would need to be
213 // fixed to fully support tail calls in Thumb1.
214 //
Sanne Woudaa9941852017-02-03 11:15:53 +0000215 // For ARMv8-M, we /do/ implement tail calls. Doing this is tricky for v8-M
216 // baseline, since the LDM/POP instruction on Thumb doesn't take LR. This
217 // means if we need to reload LR, it takes extra instructions, which outweighs
218 // the value of the tail call; but here we don't know yet whether LR is going
Momchil Velikovdc86e142017-11-14 10:36:52 +0000219 // to be used. We take the optimistic approach of generating the tail call and
220 // perhaps taking a hit if we need to restore the LR.
Artyom Skrobovad8a0632015-09-28 09:44:11 +0000221
222 // Thumb1 PIC calls to external symbols use BX, so they can be tail calls,
223 // but we need to make sure there are enough registers; the only valid
224 // registers are the 4 used for parameters. We don't currently do this
225 // case.
226
Bradley Smitha1189102016-01-15 10:26:17 +0000227 SupportsTailCall = !isThumb() || hasV8MBaselineOps();
Artyom Skrobovad8a0632015-09-28 09:44:11 +0000228
229 if (isTargetMachO() && isTargetIOS() && getTargetTriple().isOSVersionLT(5, 0))
230 SupportsTailCall = false;
David Goodwin9a051a52009-10-01 21:46:35 +0000231
Weiming Zhao0da5cc02013-11-13 18:29:49 +0000232 switch (IT) {
233 case DefaultIT:
Alexander Kornienkofb37cfa2015-04-14 15:32:58 +0000234 RestrictIT = hasV8Ops();
Weiming Zhao0da5cc02013-11-13 18:29:49 +0000235 break;
236 case RestrictedIT:
237 RestrictIT = true;
238 break;
239 case NoRestrictedIT:
240 RestrictIT = false;
241 break;
242 }
243
Renato Golinb4dd6c52013-03-21 18:47:47 +0000244 // NEON f32 ops are non-IEEE 754 compliant. Darwin is ok with it by default.
Michael Kupersteindb0712f2015-05-26 10:47:10 +0000245 const FeatureBitset &Bits = getFeatureBits();
246 if ((Bits[ARM::ProcA5] || Bits[ARM::ProcA8]) && // Where this matters
Renato Golinb4dd6c52013-03-21 18:47:47 +0000247 (Options.UnsafeFPMath || isTargetDarwin()))
248 UseNEONForSinglePrecisionFP = true;
Diana Picus92423ce2016-06-27 09:08:23 +0000249
Oliver Stannard8331aae2016-08-08 15:28:31 +0000250 if (isRWPI())
251 ReserveR9 = true;
252
Diana Picus92423ce2016-06-27 09:08:23 +0000253 // FIXME: Teach TableGen to deal with these instead of doing it manually here.
254 switch (ARMProcFamily) {
255 case Others:
256 case CortexA5:
257 break;
258 case CortexA7:
259 LdStMultipleTiming = DoubleIssue;
260 break;
261 case CortexA8:
262 LdStMultipleTiming = DoubleIssue;
263 break;
264 case CortexA9:
265 LdStMultipleTiming = DoubleIssueCheckUnalignedAccess;
266 PreISelOperandLatencyAdjustment = 1;
267 break;
268 case CortexA12:
269 break;
270 case CortexA15:
271 MaxInterleaveFactor = 2;
272 PreISelOperandLatencyAdjustment = 1;
Diana Picusb772e402016-07-06 11:22:11 +0000273 PartialUpdateClearance = 12;
Diana Picus92423ce2016-06-27 09:08:23 +0000274 break;
275 case CortexA17:
276 case CortexA32:
277 case CortexA35:
278 case CortexA53:
Sam Parkerb252ffd2017-08-21 08:43:06 +0000279 case CortexA55:
Diana Picus92423ce2016-06-27 09:08:23 +0000280 case CortexA57:
281 case CortexA72:
282 case CortexA73:
Sam Parkerb252ffd2017-08-21 08:43:06 +0000283 case CortexA75:
Diana Picus92423ce2016-06-27 09:08:23 +0000284 case CortexR4:
285 case CortexR4F:
286 case CortexR5:
287 case CortexR7:
288 case CortexM3:
Javed Absar97979892016-10-07 13:41:55 +0000289 case CortexR52:
Evandro Menezesb3ed4bc2017-07-26 21:28:20 +0000290 case ExynosM1:
Yi Kong60b5a1c2017-04-06 22:47:47 +0000291 case Kryo:
Diana Picus92423ce2016-06-27 09:08:23 +0000292 break;
293 case Krait:
294 PreISelOperandLatencyAdjustment = 1;
295 break;
296 case Swift:
297 MaxInterleaveFactor = 2;
298 LdStMultipleTiming = SingleIssuePlusExtras;
299 PreISelOperandLatencyAdjustment = 1;
Diana Picusb772e402016-07-06 11:22:11 +0000300 PartialUpdateClearance = 12;
Diana Picus92423ce2016-06-27 09:08:23 +0000301 break;
302 }
Evan Cheng10043e22007-01-19 07:51:42 +0000303}
Evan Cheng43b9ca62009-08-28 23:18:09 +0000304
Eric Christopher661f2d12014-12-18 02:20:58 +0000305bool ARMSubtarget::isAPCS_ABI() const {
306 assert(TM.TargetABI != ARMBaseTargetMachine::ARM_ABI_UNKNOWN);
307 return TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_APCS;
308}
309bool ARMSubtarget::isAAPCS_ABI() const {
310 assert(TM.TargetABI != ARMBaseTargetMachine::ARM_ABI_UNKNOWN);
Tim Northovere0ccdc62015-10-28 22:46:43 +0000311 return TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS ||
312 TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16;
Eric Christopher661f2d12014-12-18 02:20:58 +0000313}
Tim Northovere0ccdc62015-10-28 22:46:43 +0000314bool ARMSubtarget::isAAPCS16_ABI() const {
315 assert(TM.TargetABI != ARMBaseTargetMachine::ARM_ABI_UNKNOWN);
316 return TM.TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16;
317}
318
Oliver Stannard8331aae2016-08-08 15:28:31 +0000319bool ARMSubtarget::isROPI() const {
320 return TM.getRelocationModel() == Reloc::ROPI ||
321 TM.getRelocationModel() == Reloc::ROPI_RWPI;
322}
323bool ARMSubtarget::isRWPI() const {
324 return TM.getRelocationModel() == Reloc::RWPI ||
325 TM.getRelocationModel() == Reloc::ROPI_RWPI;
326}
327
Rafael Espindola5ac8f5c2016-06-28 15:38:13 +0000328bool ARMSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
Rafael Espindola3beef8d2016-06-27 23:15:57 +0000329 if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
Evan Cheng1b389522009-09-03 07:04:02 +0000330 return true;
Peter Collingbourne6a9d1772015-07-05 20:52:35 +0000331
Rafael Espindolaeece1132016-05-27 22:41:51 +0000332 // 32 bit macho has no relocation for a-b if a is undefined, even if b is in
333 // the section that is being relocated. This means we have to use o load even
334 // for GVs that are known to be local to the dso.
Rafael Espindola70c6a392016-08-24 19:02:29 +0000335 if (isTargetMachO() && TM.isPositionIndependent() &&
Rafael Espindolaeece1132016-05-27 22:41:51 +0000336 (GV->isDeclarationForLinker() || GV->hasCommonLinkage()))
337 return true;
Evan Cheng1b389522009-09-03 07:04:02 +0000338
339 return false;
Evan Cheng43b9ca62009-08-28 23:18:09 +0000340}
David Goodwin0d412c22009-11-10 00:48:55 +0000341
Evgeniy Stepanov76d5ac42017-11-13 20:45:38 +0000342bool ARMSubtarget::isGVInGOT(const GlobalValue *GV) const {
343 return isTargetELF() && TM.isPositionIndependent() &&
344 !TM.shouldAssumeDSOLocal(*GV->getParent(), GV);
Diana Picusc9f29c62017-08-29 09:47:55 +0000345}
346
Owen Andersona3181e22010-09-28 21:57:50 +0000347unsigned ARMSubtarget::getMispredictionPenalty() const {
Pete Cooper11759452014-09-02 17:43:54 +0000348 return SchedModel.MispredictPenalty;
Owen Andersona3181e22010-09-28 21:57:50 +0000349}
350
Matthias Braun9e859802015-07-17 23:18:30 +0000351bool ARMSubtarget::enableMachineScheduler() const {
Florian Hahne3583bd2017-07-27 19:56:44 +0000352 // Enable the MachineScheduler before register allocation for subtargets
353 // with the use-misched feature.
354 return useMachineScheduler();
Matthias Braun9e859802015-07-17 23:18:30 +0000355}
356
Sanjay Patela2f658d2014-07-15 22:39:58 +0000357// This overrides the PostRAScheduler bit in the SchedModel for any CPU.
Matthias Braun39a2afc2015-06-13 03:42:16 +0000358bool ARMSubtarget::enablePostRAScheduler() const {
Sam Parkerb0367572017-08-31 08:57:51 +0000359 if (disablePostRAScheduler())
Matthias Braun9e859802015-07-17 23:18:30 +0000360 return false;
Sam Parkerb0367572017-08-31 08:57:51 +0000361 // Don't reschedule potential IT blocks.
362 return !isThumb1Only();
Andrew Trick8d2ee372014-06-04 07:06:27 +0000363}
364
Weiming Zhao962eaae2016-11-03 21:49:08 +0000365bool ARMSubtarget::enableAtomicExpand() const { return hasAnyDataBarrier(); }
Eric Christopherc40e5ed2014-06-19 21:03:04 +0000366
Tim Northover910dde72015-08-03 17:20:10 +0000367bool ARMSubtarget::useStride4VFPs(const MachineFunction &MF) const {
Tim Northoverf8e47e42015-10-28 22:56:36 +0000368 // For general targets, the prologue can grow when VFPs are allocated with
369 // stride 4 (more vpush instructions). But WatchOS uses a compact unwind
370 // format which it's more important to get right.
Matthias Braunf1caa282017-12-15 22:22:58 +0000371 return isTargetWatchABI() || (isSwift() && !MF.getFunction().optForMinSize());
Tim Northover910dde72015-08-03 17:20:10 +0000372}
373
Eric Christopherc1058df2014-07-04 01:55:26 +0000374bool ARMSubtarget::useMovt(const MachineFunction &MF) const {
375 // NOTE Windows on ARM needs to use mov.w/mov.t pairs to materialise 32-bit
376 // immediates as it is inherently position independent, and may be out of
377 // range otherwise.
Bradley Smithd9a99ce2016-01-15 10:25:14 +0000378 return !NoMovt && hasV8MBaselineOps() &&
Matthias Braunf1caa282017-12-15 22:22:58 +0000379 (isTargetWindows() || !MF.getFunction().optForMinSize() || genExecuteOnly());
Eric Christopherc1058df2014-07-04 01:55:26 +0000380}
Akira Hatanakaddf76aa2015-05-23 01:14:08 +0000381
382bool ARMSubtarget::useFastISel() const {
Oliver Stannardf2ed5c62015-09-23 09:19:54 +0000383 // Enable fast-isel for any target, for testing only.
384 if (ForceFastISel)
385 return true;
386
Eric Christophera8359562015-09-18 20:08:18 +0000387 // Limit fast-isel to the targets that are or have been tested.
388 if (!hasV6Ops())
389 return false;
390
Akira Hatanakaddf76aa2015-05-23 01:14:08 +0000391 // Thumb2 support on iOS; ARM support on iOS, Linux and NaCl.
392 return TM.Options.EnableFastISel &&
393 ((isTargetMachO() && !isThumb1Only()) ||
394 (isTargetLinux() && !isThumb()) || (isTargetNaCl() && !isThumb()));
395}