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
50#define OPTIONS_STRUCT_DEFS
51#include "ARMOptions.inc"
52
53/// initializeSubtargetDependencies - Initializes using a CPU and feature string
54/// so that we can use initializer lists for subtarget initialization.
56 StringRef FS) {
57 initSubtargetFeatures(CPU, FS);
58 return *this;
59}
60
61ARMFrameLowering *ARMSubtarget::initializeFrameLowering(StringRef CPU,
62 StringRef FS) {
64 if (STI.isThumb1Only())
65 return (ARMFrameLowering *)new Thumb1FrameLowering(STI);
66
67 return new ARMFrameLowering(STI);
68}
69
70ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
71 const std::string &FS,
72 const ARMBaseTargetMachine &TM, bool IsLittle,
74 bool MinSize, DenormalMode DM)
75 : ARMGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), CLOpts(TM.getCLOpts()),
76 CPUString(CPU), OptMinSize(MinSize), IsLittle(IsLittle), DM(DM),
78 ABI(ABI), FrameLowering(initializeFrameLowering(CPU, FS)),
79 // At this point initializeSubtargetDependencies has been called so
80 // we can query directly.
81 InstrInfo(isThumb1Only() ? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
82 : !isThumb() ? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
83 : (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
84 TLInfo(TM, *this) {
85
86 CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));
87 Legalizer.reset(new ARMLegalizerInfo(*this));
88
89 auto *RBI = new ARMRegisterBankInfo(*getRegisterInfo());
90
91 // FIXME: At this point, we can't rely on Subtarget having RBI.
92 // It's awkward to mix passing RBI and the Subtarget; should we pass
93 // TII/TRI as well?
94 InstSelector.reset(createARMInstructionSelector(TM, *this, *RBI));
95
96 RegBankInfo.reset(RBI);
97}
98
100 return CallLoweringInfo.get();
101}
102
104 return InstSelector.get();
105}
106
108 return Legalizer.get();
109}
110
112 return RegBankInfo.get();
113}
114
116 const Triple &TT = getTargetTriple();
117 if (TT.isOSBinFormatMachO()) {
118 // Uses VFP for Thumb libfuncs if available.
119 if (isThumb() && hasVFP2Base() && hasARMOps() && !useSoftFloat()) {
120 // clang-format off
121 static const struct {
122 const RTLIB::Libcall Op;
123 const RTLIB::LibcallImpl Impl;
124 } LibraryCalls[] = {
125 // Single-precision floating-point arithmetic.
126 { RTLIB::ADD_F32, RTLIB::impl___addsf3vfp },
127 { RTLIB::SUB_F32, RTLIB::impl___subsf3vfp },
128 { RTLIB::MUL_F32, RTLIB::impl___mulsf3vfp },
129 { RTLIB::DIV_F32, RTLIB::impl___divsf3vfp },
130
131 // Double-precision floating-point arithmetic.
132 { RTLIB::ADD_F64, RTLIB::impl___adddf3vfp },
133 { RTLIB::SUB_F64, RTLIB::impl___subdf3vfp },
134 { RTLIB::MUL_F64, RTLIB::impl___muldf3vfp },
135 { RTLIB::DIV_F64, RTLIB::impl___divdf3vfp },
136
137 // Single-precision comparisons.
138 { RTLIB::OEQ_F32, RTLIB::impl___eqsf2vfp },
139 { RTLIB::UNE_F32, RTLIB::impl___nesf2vfp },
140 { RTLIB::OLT_F32, RTLIB::impl___ltsf2vfp },
141 { RTLIB::OLE_F32, RTLIB::impl___lesf2vfp },
142 { RTLIB::OGE_F32, RTLIB::impl___gesf2vfp },
143 { RTLIB::OGT_F32, RTLIB::impl___gtsf2vfp },
144 { RTLIB::UO_F32, RTLIB::impl___unordsf2vfp },
145
146 // Double-precision comparisons.
147 { RTLIB::OEQ_F64, RTLIB::impl___eqdf2vfp },
148 { RTLIB::UNE_F64, RTLIB::impl___nedf2vfp },
149 { RTLIB::OLT_F64, RTLIB::impl___ltdf2vfp },
150 { RTLIB::OLE_F64, RTLIB::impl___ledf2vfp },
151 { RTLIB::OGE_F64, RTLIB::impl___gedf2vfp },
152 { RTLIB::OGT_F64, RTLIB::impl___gtdf2vfp },
153 { RTLIB::UO_F64, RTLIB::impl___unorddf2vfp },
154
155 // Floating-point to integer conversions.
156 // i64 conversions are done via library routines even when generating VFP
157 // instructions, so use the same ones.
158 { RTLIB::FPTOSINT_F64_I32, RTLIB::impl___fixdfsivfp },
159 { RTLIB::FPTOUINT_F64_I32, RTLIB::impl___fixunsdfsivfp },
160 { RTLIB::FPTOSINT_F32_I32, RTLIB::impl___fixsfsivfp },
161 { RTLIB::FPTOUINT_F32_I32, RTLIB::impl___fixunssfsivfp },
162
163 // Conversions between floating types.
164 { RTLIB::FPROUND_F64_F32, RTLIB::impl___truncdfsf2vfp },
165 { RTLIB::FPEXT_F32_F64, RTLIB::impl___extendsfdf2vfp },
166
167 // Integer to floating-point conversions.
168 // i64 conversions are done via library routines even when generating VFP
169 // instructions, so use the same ones.
170 // FIXME: There appears to be some naming inconsistency in ARM libgcc:
171 // e.g., __floatunsidf vs. __floatunssidfvfp.
172 { RTLIB::SINTTOFP_I32_F64, RTLIB::impl___floatsidfvfp },
173 { RTLIB::UINTTOFP_I32_F64, RTLIB::impl___floatunssidfvfp },
174 { RTLIB::SINTTOFP_I32_F32, RTLIB::impl___floatsisfvfp },
175 { RTLIB::UINTTOFP_I32_F32, RTLIB::impl___floatunssisfvfp },
176 };
177 // clang-format on
178
179 for (const auto &LC : LibraryCalls)
180 Info.setLibcallImpl(LC.Op, LC.Impl);
181 }
182 }
183
184 static const struct {
185 const RTLIB::Libcall Op;
186 const RTLIB::LibcallImpl Impl;
187 } AEABISelected[] = {
188 // Double-precision arithmetic.
189 {RTLIB::ADD_F64, RTLIB::impl___aeabi_dadd},
190 {RTLIB::DIV_F64, RTLIB::impl___aeabi_ddiv},
191 {RTLIB::MUL_F64, RTLIB::impl___aeabi_dmul},
192 {RTLIB::SUB_F64, RTLIB::impl___aeabi_dsub},
193 // Double-precision comparisons.
194 {RTLIB::OEQ_F64, RTLIB::impl___aeabi_dcmpeq},
195 {RTLIB::OLT_F64, RTLIB::impl___aeabi_dcmplt},
196 {RTLIB::OLE_F64, RTLIB::impl___aeabi_dcmple},
197 {RTLIB::OGE_F64, RTLIB::impl___aeabi_dcmpge},
198 {RTLIB::OGT_F64, RTLIB::impl___aeabi_dcmpgt},
199 {RTLIB::UO_F64, RTLIB::impl___aeabi_dcmpun},
200 // Single-precision arithmetic.
201 {RTLIB::ADD_F32, RTLIB::impl___aeabi_fadd},
202 {RTLIB::DIV_F32, RTLIB::impl___aeabi_fdiv},
203 {RTLIB::MUL_F32, RTLIB::impl___aeabi_fmul},
204 {RTLIB::SUB_F32, RTLIB::impl___aeabi_fsub},
205 // Single-precision comparisons.
206 {RTLIB::OEQ_F32, RTLIB::impl___aeabi_fcmpeq},
207 {RTLIB::OLT_F32, RTLIB::impl___aeabi_fcmplt},
208 {RTLIB::OLE_F32, RTLIB::impl___aeabi_fcmple},
209 {RTLIB::OGE_F32, RTLIB::impl___aeabi_fcmpge},
210 {RTLIB::OGT_F32, RTLIB::impl___aeabi_fcmpgt},
211 {RTLIB::UO_F32, RTLIB::impl___aeabi_fcmpun},
212 // Floating-point to integer conversions.
213 {RTLIB::FPTOSINT_F64_I32, RTLIB::impl___aeabi_d2iz},
214 {RTLIB::FPTOUINT_F64_I32, RTLIB::impl___aeabi_d2uiz},
215 {RTLIB::FPTOSINT_F64_I64, RTLIB::impl___aeabi_d2lz},
216 {RTLIB::FPTOUINT_F64_I64, RTLIB::impl___aeabi_d2ulz},
217 {RTLIB::FPTOSINT_F32_I32, RTLIB::impl___aeabi_f2iz},
218 {RTLIB::FPTOUINT_F32_I32, RTLIB::impl___aeabi_f2uiz},
219 {RTLIB::FPTOSINT_F32_I64, RTLIB::impl___aeabi_f2lz},
220 {RTLIB::FPTOUINT_F32_I64, RTLIB::impl___aeabi_f2ulz},
221 // Integer to floating-point conversions.
222 {RTLIB::SINTTOFP_I32_F64, RTLIB::impl___aeabi_i2d},
223 {RTLIB::UINTTOFP_I32_F64, RTLIB::impl___aeabi_ui2d},
224 {RTLIB::SINTTOFP_I64_F64, RTLIB::impl___aeabi_l2d},
225 {RTLIB::UINTTOFP_I64_F64, RTLIB::impl___aeabi_ul2d},
226 {RTLIB::SINTTOFP_I32_F32, RTLIB::impl___aeabi_i2f},
227 {RTLIB::UINTTOFP_I32_F32, RTLIB::impl___aeabi_ui2f},
228 {RTLIB::SINTTOFP_I64_F32, RTLIB::impl___aeabi_l2f},
229 {RTLIB::UINTTOFP_I64_F32, RTLIB::impl___aeabi_ul2f},
230 // Long long helpers.
231 {RTLIB::MUL_I64, RTLIB::impl___aeabi_lmul},
232 {RTLIB::SHL_I64, RTLIB::impl___aeabi_llsl},
233 {RTLIB::SRL_I64, RTLIB::impl___aeabi_llsr},
234 {RTLIB::SRA_I64, RTLIB::impl___aeabi_lasr},
235 // Integer division.
236 {RTLIB::SDIV_I32, RTLIB::impl___aeabi_idiv},
237 {RTLIB::UDIV_I32, RTLIB::impl___aeabi_uidiv},
238 };
239
240 const RTLIB::RuntimeLibcallsInfo &RTLCI = Info.getRuntimeLibcallsInfo();
241 for (const auto &LC : AEABISelected) {
242 if (RTLCI.isAvailable(LC.Impl))
243 Info.setLibcallImpl(LC.Op, LC.Impl);
244 }
245
246 // AEABI provides an ordered-equal compare (__aeabi_{f,d}cmpeq) but no
247 // not-equal compare. Clear the not-equal libcalls so UNE will lower as !OEQ
248 // using the AEABI compare, rather than emitting the generic not-equal helper
249 // which would otherwise be preferred.
250 if (RTLCI.isAvailable(RTLIB::impl___aeabi_fcmpeq)) {
251 Info.setLibcallImpl(RTLIB::UNE_F32, RTLIB::Unsupported);
252 Info.setLibcallImpl(RTLIB::FCMP3_PRED_UNE_F32, RTLIB::Unsupported);
253 }
254
255 if (RTLCI.isAvailable(RTLIB::impl___aeabi_dcmpeq)) {
256 Info.setLibcallImpl(RTLIB::UNE_F64, RTLIB::Unsupported);
257 Info.setLibcallImpl(RTLIB::FCMP3_PRED_UNE_F64, RTLIB::Unsupported);
258 }
259}
260
262 // We don't currently support Thumb, but Windows requires Thumb.
263 return hasV6Ops() && hasARMOps() && !isTargetWindows();
264}
265
266void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
267 if (CPUString.empty()) {
268 CPUString = "generic";
269
270 if (isTargetDarwin()) {
272 ARM::ArchKind AK = ARM::parseArch(ArchName);
273 if (AK == ARM::ArchKind::ARMV7S)
274 // Default to the Swift CPU when targeting armv7s/thumbv7s.
275 CPUString = "swift";
276 else if (AK == ARM::ArchKind::ARMV7K)
277 // Default to the Cortex-a7 CPU when targeting armv7k/thumbv7k.
278 // ARMv7k does not use SjLj exception handling.
279 CPUString = "cortex-a7";
280 }
281 }
282
283 // Insert the architecture feature derived from the target triple into the
284 // feature string. This is important for setting features that are implied
285 // based on the architecture version.
286 std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple, CPUString);
287 if (!FS.empty()) {
288 if (!ArchFS.empty())
289 ArchFS = (Twine(ArchFS) + "," + FS).str();
290 else
291 ArchFS = std::string(FS);
292 }
293 ParseSubtargetFeatures(CPUString, /*TuneCPU*/ CPUString, ArchFS);
294
295 // FIXME: This used enable V6T2 support implicitly for Thumb2 mode.
296 // Assert this for now to make the change obvious.
297 assert(hasV6T2Ops() || !hasThumb2());
298
299 if (genExecuteOnly()) {
300 // Execute only support for >= v8-M Baseline requires movt support
301 if (hasV8MBaselineOps())
302 NoMovt = false;
303 if (!hasV6MOps())
304 report_fatal_error("Cannot generate execute-only code for this target");
305 }
306
307 // Keep a pointer to static instruction cost data for the specified CPU.
308 SchedModel = getSchedModelForCPU(CPUString);
309
310 // Initialize scheduling itinerary for the specified CPU.
311 InstrItins = getInstrItineraryForCPU(CPUString);
312
313 // FIXME: this is invalid for WindowsCE
314 if (isTargetWindows())
315 NoARM = true;
316
317 if (isAAPCS_ABI())
319 if (isAAPCS16_ABI())
320 stackAlignment = Align(16);
321
322 // FIXME: Completely disable sibcall for Thumb1 since ThumbRegisterInfo::
323 // emitEpilogue is not ready for them. Thumb tail calls also use t2B, as
324 // the Thumb1 16-bit unconditional branch doesn't have sufficient relocation
325 // support in the assembler and linker to be used. This would need to be
326 // fixed to fully support tail calls in Thumb1.
327 //
328 // For ARMv8-M, we /do/ implement tail calls. Doing this is tricky for v8-M
329 // baseline, since the LDM/POP instruction on Thumb doesn't take LR. This
330 // means if we need to reload LR, it takes extra instructions, which outweighs
331 // the value of the tail call; but here we don't know yet whether LR is going
332 // to be used. We take the optimistic approach of generating the tail call and
333 // perhaps taking a hit if we need to restore the LR.
334
335 // Thumb1 PIC calls to external symbols use BX, so they can be tail calls,
336 // but we need to make sure there are enough registers; the only valid
337 // registers are the 4 used for parameters. We don't currently do this
338 // case.
339
340 SupportsTailCall = !isThumb1Only() || hasV8MBaselineOps();
341
342 // NEON f32 ops are non-IEEE 754 compliant. Darwin is ok with it by default.
343 const FeatureBitset &Bits = getFeatureBits();
344 if ((Bits[ARM::ProcA5] || Bits[ARM::ProcA8]) && // Where this matters
346 HasNEONForFP = true;
347
348 const ARM::ArchKind Arch = ARM::parseArch(TargetTriple.getArchName());
349 if (isRWPI() ||
350 (isTargetIOS() &&
351 (Arch == ARM::ArchKind::ARMV6K || Arch == ARM::ArchKind::ARMV6) &&
352 TargetTriple.isOSVersionLT(3, 0)))
353 ReserveR9 = true;
354
355 // If MVEVectorCostFactor is still 0 (has not been set to anything else), default it to 2
356 if (MVEVectorCostFactor == 0)
358
359 // FIXME: Teach TableGen to deal with these instead of doing it manually here.
360 switch (ARMProcFamily) {
361 case Others:
362 case CortexA5:
363 break;
364 case CortexA7:
366 break;
367 case CortexA8:
369 break;
370 case CortexA9:
373 break;
374 case CortexA12:
375 break;
376 case CortexA15:
380 break;
381 case CortexA17:
382 case CortexA32:
383 case CortexA35:
384 case CortexA53:
385 case CortexA55:
386 case CortexA57:
387 case CortexA72:
388 case CortexA73:
389 case CortexA75:
390 case CortexA76:
391 case CortexA77:
392 case CortexA78:
393 case CortexA78AE:
394 case CortexA78C:
395 case CortexA510:
396 case CortexA710:
397 case CortexR4:
398 case CortexR5:
399 case CortexR7:
400 case CortexM3:
401 case CortexM55:
402 case CortexM7:
403 case CortexM85:
404 case CortexR52:
405 case CortexR52plus:
406 case CortexX1:
407 case CortexX1C:
408 break;
409 case Exynos:
412 if (!isThumb())
414 break;
415 case Kryo:
416 break;
417 case Krait:
419 break;
420 case NeoverseV1:
421 break;
422 case Swift:
427 break;
428 }
429}
430
432 // FIXME: This should ideally come from a function attribute, to work
433 // correctly with LTO.
434 return TM.getRelocationModel() == Reloc::ROPI ||
435 TM.getRelocationModel() == Reloc::ROPI_RWPI;
436}
437
439 // FIXME: This should ideally come from a function attribute, to work
440 // correctly with LTO.
441 return TM.getRelocationModel() == Reloc::RWPI ||
442 TM.getRelocationModel() == Reloc::ROPI_RWPI;
443}
444
446 return TM.isGVIndirectSymbol(GV);
447}
448
450 return isTargetELF() && TM.isPositionIndependent() && !GV->isDSOLocal();
451}
452
454 // The MachineScheduler can increase register usage, so we use more high
455 // registers and end up with more T2 instructions that cannot be converted to
456 // T1 instructions. At least until we do better at converting to thumb1
457 // instructions, on cortex-m at Oz where we are size-paranoid, don't use the
458 // Machine scheduler, relying on the DAG register pressure scheduler instead.
459 if (isMClass() && hasMinSize())
460 return false;
461 // Enable the MachineScheduler before register allocation for subtargets
462 // with the use-misched feature.
463 return useMachineScheduler();
464}
465
467 // Enable SubRegLiveness for MVE to better optimize s subregs for mqpr regs
468 // and q subregs for qqqqpr regs.
469 return hasMVEIntegerOps();
470}
471
473 // Enable the MachinePipeliner before register allocation for subtargets
474 // with the use-mipipeliner feature.
475 return getSchedModel().hasInstrSchedModel() && useMachinePipeliner();
476}
477
478bool ARMSubtarget::useDFAforSMS() const { return false; }
479
480// This overrides the PostRAScheduler bit in the SchedModel for any CPU.
483 return false;
484 if (disablePostRAScheduler())
485 return false;
486 // Thumb1 cores will generally not benefit from post-ra scheduling
487 return !isThumb1Only();
488}
489
492 return false;
493 if (disablePostRAScheduler())
494 return false;
495 return !isThumb1Only();
496}
497
499 // For general targets, the prologue can grow when VFPs are allocated with
500 // stride 4 (more vpush instructions). But WatchOS uses a compact unwind
501 // format which it's more important to get right.
502 return isTargetWatchABI() ||
503 (useWideStrideVFP() && !OptMinSize);
504}
505
507 // NOTE Windows on ARM needs to use mov.w/mov.t pairs to materialise 32-bit
508 // immediates as it is inherently position independent, and may be out of
509 // range otherwise.
510 return !NoMovt && hasV8MBaselineOps() &&
511 (isTargetWindows() || !OptMinSize || genExecuteOnly());
512}
513
515 // Enable fast-isel for any target, for testing only.
516 if (CLOpts.force_fast_isel)
517 return true;
518
519 // Limit fast-isel to the targets that are or have been tested.
520 if (!hasV6Ops())
521 return false;
522
523 // Thumb2 support on iOS; ARM support on iOS and Linux.
524 return TM.Options.EnableFastISel && ((isTargetMachO() && !isThumb1Only()) ||
525 (isTargetLinux() && !isThumb()));
526}
527
529 // The GPR register class has multiple possible allocation orders, with
530 // tradeoffs preferred by different sub-architectures and optimisation goals.
531 // The allocation orders are:
532 // 0: (the default tablegen order, not used)
533 // 1: r14, r0-r13
534 // 2: r0-r7
535 // 3: r0-r7, r12, lr, r8-r11
536 // Note that the register allocator will change this order so that
537 // callee-saved registers are used later, as they require extra work in the
538 // prologue/epilogue (though we sometimes override that).
539
540 // For thumb1-only targets, only the low registers are allocatable.
541 if (isThumb1Only())
542 return 2;
543
544 // Allocate low registers first, so we can select more 16-bit instructions.
545 // We also (in getCSRAllocationOrderMask) override the default behaviour
546 // with regards to callee-saved registers, because pushing extra registers is
547 // much cheaper (in terms of code size) than using high registers. After
548 // that, we allocate r12 (doesn't need to be saved), lr (saving it means we
549 // can return with the pop, don't need an extra "bx lr") and then the rest of
550 // the high registers.
551 if (isThumb2() && MF.getFunction().hasMinSize())
552 return 3;
553
554 // Otherwise, allocate in the default order, using LR first because saving it
555 // allows a shorter epilogue sequence.
556 return 1;
557}
558
560 BitVector &Mask) const {
561 // To minimize code size in Thumb2, we prefer the usage of low regs (lower
562 // cost per use) so we can use narrow encoding. By default, caller-saved
563 // registers (e.g. lr, r12) are always allocated first, regardless of
564 // their cost per use. When optForMinSize, we prefer the low regs even if
565 // they are CSR because usually push/pop can be folded into existing ones.
566 if (!isThumb2() || !MF.getFunction().hasMinSize())
567 return;
568
569 Mask.resize(getRegisterInfo()->getNumRegs());
570 for (MCPhysReg Reg : ARM::GPRRegClass)
571 Mask.set(Reg);
572}
573
576 const MachineFrameInfo &MFI = MF.getFrameInfo();
577
578 // Thumb1 always splits the pushes at R7, because the Thumb1 push instruction
579 // cannot use high registers except for lr.
580 if (isThumb1Only())
581 return SplitR7;
582
583 // If R7 is the frame pointer, we must split at R7 to ensure that the
584 // previous frame pointer (R7) and return address (LR) are adjacent on the
585 // stack, to form a valid frame record.
586 if (getFramePointerReg() == ARM::R7 && MF.framePointerIsReserved())
587 return SplitR7;
588
589 // Returns SplitR11WindowsSEH when the stack pointer needs to be
590 // restored from the frame pointer r11 + an offset and Windows CFI is enabled.
591 // This stack unwinding cannot be expressed with SEH unwind opcodes when done
592 // with a single push, making it necessary to split the push into r4-r10, and
593 // another containing r11+lr.
594 if (MF.needsWinCFI() &&
595 (MFI.hasVarSizedObjects() || getRegisterInfo()->hasStackRealignment(MF)))
596 return SplitR11WindowsSEH;
597
598 // Returns SplitR11AAPCSSignRA when the frame pointer is R11, requiring R11
599 // and LR to be adjacent on the stack, and branch signing is enabled,
600 // requiring R12 to be on the stack.
602 getFramePointerReg() == ARM::R11 && MF.framePointerIsReserved())
603 return SplitR11AAPCSSignRA;
604 return NoSplit;
605}
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.
This file implements the BitVector class.
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
ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const ARMBaseTargetMachine &TM, bool IsLittle, FloatABI::ABIType FloatABI, ARM::ARMABI ABI, bool MinSize=false, DenormalMode DM=DenormalMode::getIEEE())
This constructor initializes the data members to match that of the specified triple.
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).
const ARMOptions & CLOpts
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 isAAPCS_ABI() const
bool useStride4VFPs() const
bool OptMinSize
OptMinSize - True if we're optimising for minimum code size, equal to the function attribute.
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
const CallLowering * getCallLowering() const override
const ARMOptions & getCLOpts() const
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
const ARM::ARMABI ABI
The ABI in effect.
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.
bool isAAPCS16_ABI() const
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:705
bool isDSOLocal() const
Tracks which library functions to use for a particular subtarget or function.
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 ...
bool framePointerIsReserved() const
Returns true if the frame pointer must always either point to a new frame record or be un-modified in...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool needsWinCFI() const
True if this function uses SEH unwind opcodes and needs an unwind table entry.
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...
Holds all the information related to register banks.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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:1442
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
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