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