LLVM 24.0.0git
ARMSubtarget.cpp
Go to the documentation of this file.
1//===-- ARMSubtarget.cpp - ARM Subtarget Information ----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the ARM specific subclass of TargetSubtargetInfo.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ARM.h"
14
15#include "ARMCallLowering.h"
16#include "ARMFrameLowering.h"
17#include "ARMInstrInfo.h"
18#include "ARMLegalizerInfo.h"
19#include "ARMRegisterBankInfo.h"
20#include "ARMSubtarget.h"
21#include "ARMTargetMachine.h"
23#include "Thumb1FrameLowering.h"
24#include "Thumb1InstrInfo.h"
25#include "Thumb2InstrInfo.h"
26#include "llvm/ADT/BitVector.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/ADT/Twine.h"
32#include "llvm/IR/Function.h"
33#include "llvm/IR/GlobalValue.h"
34#include "llvm/MC/MCAsmInfo.h"
41
42using namespace llvm;
43
44#define DEBUG_TYPE "arm-subtarget"
45
46#define GET_SUBTARGETINFO_TARGET_DESC
47#define GET_SUBTARGETINFO_CTOR
48#include "ARMGenSubtargetInfo.inc"
49
50static cl::opt<bool>
51UseFusedMulOps("arm-use-mulops",
52 cl::init(true), cl::Hidden);
53
58
59static cl::opt<ITMode>
60 IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT),
61 cl::values(clEnumValN(DefaultIT, "arm-default-it",
62 "Generate any type of IT block"),
63 clEnumValN(RestrictedIT, "arm-restrict-it",
64 "Disallow complex IT blocks")));
65
66/// ForceFastISel - Use the fast-isel, even for subtargets where it is not
67/// currently supported (for testing only).
68static cl::opt<bool>
69ForceFastISel("arm-force-fast-isel",
70 cl::init(false), cl::Hidden);
71
72/// initializeSubtargetDependencies - Initializes using a CPU and feature string
73/// so that we can use initializer lists for subtarget initialization.
75 StringRef FS) {
76 initSubtargetFeatures(CPU, FS);
77 return *this;
78}
79
80ARMFrameLowering *ARMSubtarget::initializeFrameLowering(StringRef CPU,
81 StringRef FS) {
83 if (STI.isThumb1Only())
84 return (ARMFrameLowering *)new Thumb1FrameLowering(STI);
85
86 return new ARMFrameLowering(STI);
87}
88
89ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
90 const std::string &FS,
91 const ARMBaseTargetMachine &TM, bool IsLittle,
92 FloatABI::ABIType FloatABI, bool MinSize,
94 : ARMGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
97 FloatABIType(FloatABI), FrameLowering(initializeFrameLowering(CPU, FS)),
98 // At this point initializeSubtargetDependencies has been called so
99 // we can query directly.
100 InstrInfo(isThumb1Only() ? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
101 : !isThumb() ? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
102 : (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
103 TLInfo(TM, *this) {
104
105 CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));
106 Legalizer.reset(new ARMLegalizerInfo(*this));
107
108 auto *RBI = new ARMRegisterBankInfo(*getRegisterInfo());
109
110 // FIXME: At this point, we can't rely on Subtarget having RBI.
111 // It's awkward to mix passing RBI and the Subtarget; should we pass
112 // TII/TRI as well?
113 InstSelector.reset(createARMInstructionSelector(TM, *this, *RBI));
114
115 RegBankInfo.reset(RBI);
116}
117
119 return CallLoweringInfo.get();
120}
121
123 return InstSelector.get();
124}
125
127 return Legalizer.get();
128}
129
131 return RegBankInfo.get();
132}
133
135 const Triple &TT = getTargetTriple();
136 if (TT.isOSBinFormatMachO()) {
137 // Uses VFP for Thumb libfuncs if available.
138 if (isThumb() && hasVFP2Base() && hasARMOps() && !useSoftFloat()) {
139 // clang-format off
140 static const struct {
141 const RTLIB::Libcall Op;
142 const RTLIB::LibcallImpl Impl;
143 } LibraryCalls[] = {
144 // Single-precision floating-point arithmetic.
145 { RTLIB::ADD_F32, RTLIB::impl___addsf3vfp },
146 { RTLIB::SUB_F32, RTLIB::impl___subsf3vfp },
147 { RTLIB::MUL_F32, RTLIB::impl___mulsf3vfp },
148 { RTLIB::DIV_F32, RTLIB::impl___divsf3vfp },
149
150 // Double-precision floating-point arithmetic.
151 { RTLIB::ADD_F64, RTLIB::impl___adddf3vfp },
152 { RTLIB::SUB_F64, RTLIB::impl___subdf3vfp },
153 { RTLIB::MUL_F64, RTLIB::impl___muldf3vfp },
154 { RTLIB::DIV_F64, RTLIB::impl___divdf3vfp },
155
156 // Single-precision comparisons.
157 { RTLIB::OEQ_F32, RTLIB::impl___eqsf2vfp },
158 { RTLIB::UNE_F32, RTLIB::impl___nesf2vfp },
159 { RTLIB::OLT_F32, RTLIB::impl___ltsf2vfp },
160 { RTLIB::OLE_F32, RTLIB::impl___lesf2vfp },
161 { RTLIB::OGE_F32, RTLIB::impl___gesf2vfp },
162 { RTLIB::OGT_F32, RTLIB::impl___gtsf2vfp },
163 { RTLIB::UO_F32, RTLIB::impl___unordsf2vfp },
164
165 // Double-precision comparisons.
166 { RTLIB::OEQ_F64, RTLIB::impl___eqdf2vfp },
167 { RTLIB::UNE_F64, RTLIB::impl___nedf2vfp },
168 { RTLIB::OLT_F64, RTLIB::impl___ltdf2vfp },
169 { RTLIB::OLE_F64, RTLIB::impl___ledf2vfp },
170 { RTLIB::OGE_F64, RTLIB::impl___gedf2vfp },
171 { RTLIB::OGT_F64, RTLIB::impl___gtdf2vfp },
172 { RTLIB::UO_F64, RTLIB::impl___unorddf2vfp },
173
174 // Floating-point to integer conversions.
175 // i64 conversions are done via library routines even when generating VFP
176 // instructions, so use the same ones.
177 { RTLIB::FPTOSINT_F64_I32, RTLIB::impl___fixdfsivfp },
178 { RTLIB::FPTOUINT_F64_I32, RTLIB::impl___fixunsdfsivfp },
179 { RTLIB::FPTOSINT_F32_I32, RTLIB::impl___fixsfsivfp },
180 { RTLIB::FPTOUINT_F32_I32, RTLIB::impl___fixunssfsivfp },
181
182 // Conversions between floating types.
183 { RTLIB::FPROUND_F64_F32, RTLIB::impl___truncdfsf2vfp },
184 { RTLIB::FPEXT_F32_F64, RTLIB::impl___extendsfdf2vfp },
185
186 // Integer to floating-point conversions.
187 // i64 conversions are done via library routines even when generating VFP
188 // instructions, so use the same ones.
189 // FIXME: There appears to be some naming inconsistency in ARM libgcc:
190 // e.g., __floatunsidf vs. __floatunssidfvfp.
191 { RTLIB::SINTTOFP_I32_F64, RTLIB::impl___floatsidfvfp },
192 { RTLIB::UINTTOFP_I32_F64, RTLIB::impl___floatunssidfvfp },
193 { RTLIB::SINTTOFP_I32_F32, RTLIB::impl___floatsisfvfp },
194 { RTLIB::UINTTOFP_I32_F32, RTLIB::impl___floatunssisfvfp },
195 };
196 // clang-format on
197
198 for (const auto &LC : LibraryCalls)
199 Info.setLibcallImpl(LC.Op, LC.Impl);
200 }
201 }
202
203 static const struct {
204 const RTLIB::Libcall Op;
205 const RTLIB::LibcallImpl Impl;
206 } AEABISelected[] = {
207 // Double-precision arithmetic.
208 {RTLIB::ADD_F64, RTLIB::impl___aeabi_dadd},
209 {RTLIB::DIV_F64, RTLIB::impl___aeabi_ddiv},
210 {RTLIB::MUL_F64, RTLIB::impl___aeabi_dmul},
211 {RTLIB::SUB_F64, RTLIB::impl___aeabi_dsub},
212 // Double-precision comparisons.
213 {RTLIB::OEQ_F64, RTLIB::impl___aeabi_dcmpeq},
214 {RTLIB::OLT_F64, RTLIB::impl___aeabi_dcmplt},
215 {RTLIB::OLE_F64, RTLIB::impl___aeabi_dcmple},
216 {RTLIB::OGE_F64, RTLIB::impl___aeabi_dcmpge},
217 {RTLIB::OGT_F64, RTLIB::impl___aeabi_dcmpgt},
218 {RTLIB::UO_F64, RTLIB::impl___aeabi_dcmpun},
219 // Single-precision arithmetic.
220 {RTLIB::ADD_F32, RTLIB::impl___aeabi_fadd},
221 {RTLIB::DIV_F32, RTLIB::impl___aeabi_fdiv},
222 {RTLIB::MUL_F32, RTLIB::impl___aeabi_fmul},
223 {RTLIB::SUB_F32, RTLIB::impl___aeabi_fsub},
224 // Single-precision comparisons.
225 {RTLIB::OEQ_F32, RTLIB::impl___aeabi_fcmpeq},
226 {RTLIB::OLT_F32, RTLIB::impl___aeabi_fcmplt},
227 {RTLIB::OLE_F32, RTLIB::impl___aeabi_fcmple},
228 {RTLIB::OGE_F32, RTLIB::impl___aeabi_fcmpge},
229 {RTLIB::OGT_F32, RTLIB::impl___aeabi_fcmpgt},
230 {RTLIB::UO_F32, RTLIB::impl___aeabi_fcmpun},
231 // Floating-point to integer conversions.
232 {RTLIB::FPTOSINT_F64_I32, RTLIB::impl___aeabi_d2iz},
233 {RTLIB::FPTOUINT_F64_I32, RTLIB::impl___aeabi_d2uiz},
234 {RTLIB::FPTOSINT_F64_I64, RTLIB::impl___aeabi_d2lz},
235 {RTLIB::FPTOUINT_F64_I64, RTLIB::impl___aeabi_d2ulz},
236 {RTLIB::FPTOSINT_F32_I32, RTLIB::impl___aeabi_f2iz},
237 {RTLIB::FPTOUINT_F32_I32, RTLIB::impl___aeabi_f2uiz},
238 {RTLIB::FPTOSINT_F32_I64, RTLIB::impl___aeabi_f2lz},
239 {RTLIB::FPTOUINT_F32_I64, RTLIB::impl___aeabi_f2ulz},
240 // Integer to floating-point conversions.
241 {RTLIB::SINTTOFP_I32_F64, RTLIB::impl___aeabi_i2d},
242 {RTLIB::UINTTOFP_I32_F64, RTLIB::impl___aeabi_ui2d},
243 {RTLIB::SINTTOFP_I64_F64, RTLIB::impl___aeabi_l2d},
244 {RTLIB::UINTTOFP_I64_F64, RTLIB::impl___aeabi_ul2d},
245 {RTLIB::SINTTOFP_I32_F32, RTLIB::impl___aeabi_i2f},
246 {RTLIB::UINTTOFP_I32_F32, RTLIB::impl___aeabi_ui2f},
247 {RTLIB::SINTTOFP_I64_F32, RTLIB::impl___aeabi_l2f},
248 {RTLIB::UINTTOFP_I64_F32, RTLIB::impl___aeabi_ul2f},
249 // Long long helpers.
250 {RTLIB::MUL_I64, RTLIB::impl___aeabi_lmul},
251 {RTLIB::SHL_I64, RTLIB::impl___aeabi_llsl},
252 {RTLIB::SRL_I64, RTLIB::impl___aeabi_llsr},
253 {RTLIB::SRA_I64, RTLIB::impl___aeabi_lasr},
254 // Integer division.
255 {RTLIB::SDIV_I32, RTLIB::impl___aeabi_idiv},
256 {RTLIB::UDIV_I32, RTLIB::impl___aeabi_uidiv},
257 };
258
259 const RTLIB::RuntimeLibcallsInfo &RTLCI = Info.getRuntimeLibcallsInfo();
260 for (const auto &LC : AEABISelected) {
261 if (RTLCI.isAvailable(LC.Impl))
262 Info.setLibcallImpl(LC.Op, LC.Impl);
263 }
264
265 // AEABI provides an ordered-equal compare (__aeabi_{f,d}cmpeq) but no
266 // not-equal compare. Clear the not-equal libcalls so UNE will lower as !OEQ
267 // using the AEABI compare, rather than emitting the generic not-equal helper
268 // which would otherwise be preferred.
269 if (RTLCI.isAvailable(RTLIB::impl___aeabi_fcmpeq)) {
270 Info.setLibcallImpl(RTLIB::UNE_F32, RTLIB::Unsupported);
271 Info.setLibcallImpl(RTLIB::FCMP3_PRED_UNE_F32, RTLIB::Unsupported);
272 }
273
274 if (RTLCI.isAvailable(RTLIB::impl___aeabi_dcmpeq)) {
275 Info.setLibcallImpl(RTLIB::UNE_F64, RTLIB::Unsupported);
276 Info.setLibcallImpl(RTLIB::FCMP3_PRED_UNE_F64, RTLIB::Unsupported);
277 }
278}
279
281 // We don't currently support Thumb, but Windows requires Thumb.
282 return hasV6Ops() && hasARMOps() && !isTargetWindows();
283}
284
285void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
286 if (CPUString.empty()) {
287 CPUString = "generic";
288
289 if (isTargetDarwin()) {
291 ARM::ArchKind AK = ARM::parseArch(ArchName);
292 if (AK == ARM::ArchKind::ARMV7S)
293 // Default to the Swift CPU when targeting armv7s/thumbv7s.
294 CPUString = "swift";
295 else if (AK == ARM::ArchKind::ARMV7K)
296 // Default to the Cortex-a7 CPU when targeting armv7k/thumbv7k.
297 // ARMv7k does not use SjLj exception handling.
298 CPUString = "cortex-a7";
299 }
300 }
301
302 // Insert the architecture feature derived from the target triple into the
303 // feature string. This is important for setting features that are implied
304 // based on the architecture version.
305 std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple, CPUString);
306 if (!FS.empty()) {
307 if (!ArchFS.empty())
308 ArchFS = (Twine(ArchFS) + "," + FS).str();
309 else
310 ArchFS = std::string(FS);
311 }
312 ParseSubtargetFeatures(CPUString, /*TuneCPU*/ CPUString, ArchFS);
313
314 // FIXME: This used enable V6T2 support implicitly for Thumb2 mode.
315 // Assert this for now to make the change obvious.
316 assert(hasV6T2Ops() || !hasThumb2());
317
318 if (genExecuteOnly()) {
319 // Execute only support for >= v8-M Baseline requires movt support
320 if (hasV8MBaselineOps())
321 NoMovt = false;
322 if (!hasV6MOps())
323 report_fatal_error("Cannot generate execute-only code for this target");
324 }
325
326 // Keep a pointer to static instruction cost data for the specified CPU.
327 SchedModel = getSchedModelForCPU(CPUString);
328
329 // Initialize scheduling itinerary for the specified CPU.
330 InstrItins = getInstrItineraryForCPU(CPUString);
331
332 // FIXME: this is invalid for WindowsCE
333 if (isTargetWindows())
334 NoARM = true;
335
336 if (TM.isAAPCS_ABI())
338 if (TM.isAAPCS16_ABI())
339 stackAlignment = Align(16);
340
341 // FIXME: Completely disable sibcall for Thumb1 since ThumbRegisterInfo::
342 // emitEpilogue is not ready for them. Thumb tail calls also use t2B, as
343 // the Thumb1 16-bit unconditional branch doesn't have sufficient relocation
344 // support in the assembler and linker to be used. This would need to be
345 // fixed to fully support tail calls in Thumb1.
346 //
347 // For ARMv8-M, we /do/ implement tail calls. Doing this is tricky for v8-M
348 // baseline, since the LDM/POP instruction on Thumb doesn't take LR. This
349 // means if we need to reload LR, it takes extra instructions, which outweighs
350 // the value of the tail call; but here we don't know yet whether LR is going
351 // to be used. We take the optimistic approach of generating the tail call and
352 // perhaps taking a hit if we need to restore the LR.
353
354 // Thumb1 PIC calls to external symbols use BX, so they can be tail calls,
355 // but we need to make sure there are enough registers; the only valid
356 // registers are the 4 used for parameters. We don't currently do this
357 // case.
358
359 SupportsTailCall = !isThumb1Only() || hasV8MBaselineOps();
360
361 switch (IT) {
362 case DefaultIT:
363 RestrictIT = false;
364 break;
365 case RestrictedIT:
366 RestrictIT = true;
367 break;
368 }
369
370 // NEON f32 ops are non-IEEE 754 compliant. Darwin is ok with it by default.
371 const FeatureBitset &Bits = getFeatureBits();
372 if ((Bits[ARM::ProcA5] || Bits[ARM::ProcA8]) && // Where this matters
374 HasNEONForFP = true;
375
376 const ARM::ArchKind Arch = ARM::parseArch(TargetTriple.getArchName());
377 if (isRWPI() ||
378 (isTargetIOS() &&
379 (Arch == ARM::ArchKind::ARMV6K || Arch == ARM::ArchKind::ARMV6) &&
380 TargetTriple.isOSVersionLT(3, 0)))
381 ReserveR9 = true;
382
383 // If MVEVectorCostFactor is still 0 (has not been set to anything else), default it to 2
384 if (MVEVectorCostFactor == 0)
386
387 // FIXME: Teach TableGen to deal with these instead of doing it manually here.
388 switch (ARMProcFamily) {
389 case Others:
390 case CortexA5:
391 break;
392 case CortexA7:
394 break;
395 case CortexA8:
397 break;
398 case CortexA9:
401 break;
402 case CortexA12:
403 break;
404 case CortexA15:
408 break;
409 case CortexA17:
410 case CortexA32:
411 case CortexA35:
412 case CortexA53:
413 case CortexA55:
414 case CortexA57:
415 case CortexA72:
416 case CortexA73:
417 case CortexA75:
418 case CortexA76:
419 case CortexA77:
420 case CortexA78:
421 case CortexA78AE:
422 case CortexA78C:
423 case CortexA510:
424 case CortexA710:
425 case CortexR4:
426 case CortexR5:
427 case CortexR7:
428 case CortexM3:
429 case CortexM55:
430 case CortexM7:
431 case CortexM85:
432 case CortexR52:
433 case CortexR52plus:
434 case CortexX1:
435 case CortexX1C:
436 break;
437 case Exynos:
440 if (!isThumb())
442 break;
443 case Kryo:
444 break;
445 case Krait:
447 break;
448 case NeoverseV1:
449 break;
450 case Swift:
455 break;
456 }
457}
458
460 // FIXME: This should ideally come from a function attribute, to work
461 // correctly with LTO.
462 return TM.getRelocationModel() == Reloc::ROPI ||
463 TM.getRelocationModel() == Reloc::ROPI_RWPI;
464}
465
467 // FIXME: This should ideally come from a function attribute, to work
468 // correctly with LTO.
469 return TM.getRelocationModel() == Reloc::RWPI ||
470 TM.getRelocationModel() == Reloc::ROPI_RWPI;
471}
472
474 return TM.isGVIndirectSymbol(GV);
475}
476
478 return isTargetELF() && TM.isPositionIndependent() && !GV->isDSOLocal();
479}
480
482 // The MachineScheduler can increase register usage, so we use more high
483 // registers and end up with more T2 instructions that cannot be converted to
484 // T1 instructions. At least until we do better at converting to thumb1
485 // instructions, on cortex-m at Oz where we are size-paranoid, don't use the
486 // Machine scheduler, relying on the DAG register pressure scheduler instead.
487 if (isMClass() && hasMinSize())
488 return false;
489 // Enable the MachineScheduler before register allocation for subtargets
490 // with the use-misched feature.
491 return useMachineScheduler();
492}
493
495 // Enable SubRegLiveness for MVE to better optimize s subregs for mqpr regs
496 // and q subregs for qqqqpr regs.
497 return hasMVEIntegerOps();
498}
499
501 // Enable the MachinePipeliner before register allocation for subtargets
502 // with the use-mipipeliner feature.
503 return getSchedModel().hasInstrSchedModel() && useMachinePipeliner();
504}
505
506bool ARMSubtarget::useDFAforSMS() const { return false; }
507
508// This overrides the PostRAScheduler bit in the SchedModel for any CPU.
511 return false;
512 if (disablePostRAScheduler())
513 return false;
514 // Thumb1 cores will generally not benefit from post-ra scheduling
515 return !isThumb1Only();
516}
517
520 return false;
521 if (disablePostRAScheduler())
522 return false;
523 return !isThumb1Only();
524}
525
527 // For general targets, the prologue can grow when VFPs are allocated with
528 // stride 4 (more vpush instructions). But WatchOS uses a compact unwind
529 // format which it's more important to get right.
530 return isTargetWatchABI() ||
531 (useWideStrideVFP() && !OptMinSize);
532}
533
535 // NOTE Windows on ARM needs to use mov.w/mov.t pairs to materialise 32-bit
536 // immediates as it is inherently position independent, and may be out of
537 // range otherwise.
538 return !NoMovt && hasV8MBaselineOps() &&
539 (isTargetWindows() || !OptMinSize || genExecuteOnly());
540}
541
543 // Enable fast-isel for any target, for testing only.
544 if (ForceFastISel)
545 return true;
546
547 // Limit fast-isel to the targets that are or have been tested.
548 if (!hasV6Ops())
549 return false;
550
551 // Thumb2 support on iOS; ARM support on iOS and Linux.
552 return TM.Options.EnableFastISel && ((isTargetMachO() && !isThumb1Only()) ||
553 (isTargetLinux() && !isThumb()));
554}
555
557 // The GPR register class has multiple possible allocation orders, with
558 // tradeoffs preferred by different sub-architectures and optimisation goals.
559 // The allocation orders are:
560 // 0: (the default tablegen order, not used)
561 // 1: r14, r0-r13
562 // 2: r0-r7
563 // 3: r0-r7, r12, lr, r8-r11
564 // Note that the register allocator will change this order so that
565 // callee-saved registers are used later, as they require extra work in the
566 // prologue/epilogue (though we sometimes override that).
567
568 // For thumb1-only targets, only the low registers are allocatable.
569 if (isThumb1Only())
570 return 2;
571
572 // Allocate low registers first, so we can select more 16-bit instructions.
573 // We also (in getCSRAllocationOrderMask) override the default behaviour
574 // with regards to callee-saved registers, because pushing extra registers is
575 // much cheaper (in terms of code size) than using high registers. After
576 // that, we allocate r12 (doesn't need to be saved), lr (saving it means we
577 // can return with the pop, don't need an extra "bx lr") and then the rest of
578 // the high registers.
579 if (isThumb2() && MF.getFunction().hasMinSize())
580 return 3;
581
582 // Otherwise, allocate in the default order, using LR first because saving it
583 // allows a shorter epilogue sequence.
584 return 1;
585}
586
588 BitVector &Mask) const {
589 // To minimize code size in Thumb2, we prefer the usage of low regs (lower
590 // cost per use) so we can use narrow encoding. By default, caller-saved
591 // registers (e.g. lr, r12) are always allocated first, regardless of
592 // their cost per use. When optForMinSize, we prefer the low regs even if
593 // they are CSR because usually push/pop can be folded into existing ones.
594 if (!isThumb2() || !MF.getFunction().hasMinSize())
595 return;
596
597 Mask.resize(getRegisterInfo()->getNumRegs());
598 for (MCPhysReg Reg : ARM::GPRRegClass)
599 Mask.set(Reg);
600}
601
604 const Function &F = MF.getFunction();
605 const MachineFrameInfo &MFI = MF.getFrameInfo();
606
607 // Thumb1 always splits the pushes at R7, because the Thumb1 push instruction
608 // cannot use high registers except for lr.
609 if (isThumb1Only())
610 return SplitR7;
611
612 // If R7 is the frame pointer, we must split at R7 to ensure that the
613 // previous frame pointer (R7) and return address (LR) are adjacent on the
614 // stack, to form a valid frame record.
615 if (getFramePointerReg() == ARM::R7 &&
617 return SplitR7;
618
619 // Returns SplitR11WindowsSEH when the stack pointer needs to be
620 // restored from the frame pointer r11 + an offset and Windows CFI is enabled.
621 // This stack unwinding cannot be expressed with SEH unwind opcodes when done
622 // with a single push, making it necessary to split the push into r4-r10, and
623 // another containing r11+lr.
625 F.needsUnwindTableEntry() &&
626 (MFI.hasVarSizedObjects() || getRegisterInfo()->hasStackRealignment(MF)))
627 return SplitR11WindowsSEH;
628
629 // Returns SplitR11AAPCSSignRA when the frame pointer is R11, requiring R11
630 // and LR to be adjacent on the stack, and branch signing is enabled,
631 // requiring R12 to be on the stack.
633 getFramePointerReg() == ARM::R11 &&
635 return SplitR11AAPCSSignRA;
636 return NoSplit;
637}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isThumb(const MCSubtargetInfo &STI)
This file describes how to lower LLVM calls to machine code calls.
This file declares the targeting of the Machinelegalizer class for ARM.
This file declares the targeting of the RegisterBankInfo class for ARM.
static cl::opt< bool > UseFusedMulOps("arm-use-mulops", cl::init(true), cl::Hidden)
static cl::opt< bool > ForceFastISel("arm-force-fast-isel", cl::init(false), cl::Hidden)
ForceFastISel - Use the fast-isel, even for subtargets where it is not currently supported (for testi...
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
ITMode
@ RestrictedIT
@ DefaultIT
This file implements the BitVector class.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
#define F(x, y, z)
Definition MD5.cpp:54
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
This class provides the information for the target register banks.
bool useFastISel() const
True if fast-isel is used.
bool isTargetMachO() const
bool IsLittle
IsLittle - The target is Little Endian.
FloatABI::ABIType FloatABIType
The floating-point ABI in effect for this subtarget.
bool enablePostRAScheduler() const override
True for some subtargets at > -O0.
ARMLdStMultipleTiming LdStMultipleTiming
What kind of timing do load multiple/store multiple have (double issue, single issue etc).
bool hasARMOps() const
const Triple & getTargetTriple() const
unsigned getGPRAllocationOrder(const MachineFunction &MF) const
const RegisterBankInfo * getRegBankInfo() const override
unsigned MaxInterleaveFactor
const ARMBaseTargetMachine & TM
bool isThumb1Only() const
ARMProcFamilyEnum ARMProcFamily
ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
void getCSRAllocationOrderMask(const MachineFunction &MF, BitVector &Mask) const override
bool isThumb2() const
bool useDFAforSMS() const override
MCPhysReg getFramePointerReg() const
DenormalMode DM
DM - Denormal mode NEON and VFP RunFast mode are not IEEE 754 compliant, use this field to determine ...
bool isTargetWindows() const
bool enableSubRegLiveness() const override
Check whether this subtarget wants to use subregister liveness.
bool isGVIndirectSymbol(const GlobalValue *GV) const
True if the GV will be accessed via an indirect symbol.
unsigned MVEVectorCostFactor
The cost factor for MVE instructions, representing the multiple beats an.
const ARMTargetLowering * getTargetLowering() const override
MCSchedModel SchedModel
SchedModel - Processor specific instruction costs.
std::string CPUString
CPUString - String name of used CPU.
unsigned PreferBranchLogAlignment
What alignment is preferred for loop bodies and functions, in log2(bytes).
void initLibcallLoweringInfo(LibcallLoweringInfo &Info) const override
Triple TargetTriple
TargetTriple - What processor and OS we're targeting.
bool enableMachineScheduler() const override
Returns true if machine scheduler should be enabled.
bool isTargetDarwin() const
const ARMBaseRegisterInfo * getRegisterInfo() const override
InstrItineraryData InstrItins
Selected instruction itineraries (one entry per itinerary class.)
bool useStride4VFPs() const
bool OptMinSize
OptMinSize - True if we're optimising for minimum code size, equal to the function attribute.
bool RestrictIT
RestrictIT - If true, the subtarget disallows generation of complex IT blocks.
bool hasVFP2Base() const
Align stackAlignment
stackAlignment - The minimum alignment known to hold of the stack frame on entry to the function and ...
unsigned PartialUpdateClearance
Clearance before partial register updates (in number of instructions)
bool enableMachinePipeliner() const override
Returns true if machine pipeliner should be enabled.
bool enablePostRAMachineScheduler() const override
True for some subtargets at > -O0.
InstructionSelector * getInstructionSelector() const override
bool isXRaySupported() const override
ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const ARMBaseTargetMachine &TM, bool IsLittle, FloatABI::ABIType FloatABI, bool MinSize=false, DenormalMode DM=DenormalMode::getIEEE())
This constructor initializes the data members to match that of the specified triple.
const CallLowering * getCallLowering() const override
enum PushPopSplitVariation getPushPopSplitVariation(const MachineFunction &MF) const
bool hasMinSize() const
ARMSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
initializeSubtargetDependencies - Initializes using a CPU and feature string so that we can use initi...
PushPopSplitVariation
How the push and pop instructions of callee saved general-purpose registers should be split.
@ SplitR11WindowsSEH
When the stack frame size is not known (because of variable-sized objects or realignment),...
@ SplitR7
R7 and LR must be adjacent, because R7 is the frame pointer, and must point to a frame record consist...
@ SplitR11AAPCSSignRA
When generating AAPCS-compilant frame chains, R11 is the frame pointer, and must be pushed adjacent t...
@ NoSplit
All GPRs can be pushed in a single instruction.
bool isTargetIOS() const
bool isGVInGOT(const GlobalValue *GV) const
Returns the constant pool modifier needed to access the GV.
bool isTargetWatchABI() const
bool UseMulOps
UseMulOps - True if non-microcoded fused integer multiply-add and multiply-subtract instructions shou...
const TargetOptions & Options
Options passed via command line that could influence the target.
@ DoubleIssueCheckUnalignedAccess
Can load/store 2 registers/cycle, but needs an extra cycle if the access is not 64-bit aligned.
@ DoubleIssue
Can load/store 2 registers/cycle.
@ SingleIssuePlusExtras
Can load/store 1 register/cycle, but needs an extra cycle for address computation and potentially als...
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
bool useMachinePipeliner() const
bool useMachineScheduler() const
const LegalizerInfo * getLegalizerInfo() const override
bool isTargetLinux() const
bool isMClass() const
bool SupportsTailCall
SupportsTailCall - True if the OS supports tail call.
int PreISelOperandLatencyAdjustment
The adjustment that we need to apply to get the operand latency from the operand cycle returned by th...
bool isTargetELF() const
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Definition Function.h:695
bool isDSOLocal() const
Tracks which library functions to use for a particular subtarget.
bool usesWindowsCFI() const
Definition MCAsmInfo.h:675
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Holds all the information related to register banks.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
const MCAsmInfo & getMCAsmInfo() const
Return target specific asm information.
TargetOptions Options
LLVM_ABI bool FramePointerIsReserved(const MachineFunction &MF) const
FramePointerIsReserved - This returns true if the frame pointer must always either point to a new fra...
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
LLVM_ABI StringRef getArchName() const
Get the architecture (first) component of the triple.
Definition Triple.cpp:1416
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
std::string ParseARMTriple(const Triple &TT, StringRef CPU)
LLVM_ABI ArchKind parseArch(StringRef Arch)
@ Swift
Calling convention for Swift.
Definition CallingConv.h:69
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
InstructionSelector * createARMInstructionSelector(const ARMBaseTargetMachine &TM, const ARMSubtarget &STI, const ARMRegisterBankInfo &RBI)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
DWARFExpression::Operation Op
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getPreserveSign()
A simple container for information about the supported runtime calls.
bool isAvailable(RTLIB::LibcallImpl Impl) const