LLVM 24.0.0git
ARMBaseRegisterInfo.cpp
Go to the documentation of this file.
1//===-- ARMBaseRegisterInfo.cpp - ARM Register 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 contains the base ARM implementation of TargetRegisterInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ARMBaseRegisterInfo.h"
14#include "ARM.h"
15#include "ARMBaseInstrInfo.h"
16#include "ARMFrameLowering.h"
18#include "ARMSubtarget.h"
21#include "llvm/ADT/BitVector.h"
22#include "llvm/ADT/STLExtras.h"
36#include "llvm/IR/Attributes.h"
37#include "llvm/IR/Constants.h"
38#include "llvm/IR/DebugLoc.h"
39#include "llvm/IR/Function.h"
40#include "llvm/IR/Type.h"
41#include "llvm/MC/MCInstrDesc.h"
42#include "llvm/Support/Debug.h"
46#include <cassert>
47#include <utility>
48
49#define DEBUG_TYPE "arm-register-info"
50
51#define GET_REGINFO_TARGET_DESC
52#include "ARMGenRegisterInfo.inc"
53
54using namespace llvm;
55
60
61const MCPhysReg*
63 const ARMSubtarget &STI = MF->getSubtarget<ARMSubtarget>();
66 const Function &F = MF->getFunction();
67
68 if (F.getCallingConv() == CallingConv::GHC) {
69 // GHC set of callee saved regs is empty as all those regs are
70 // used for passing STG regs around
71 return CSR_NoRegs_SaveList;
72 } else if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH) {
73 return CSR_Win_SplitFP_SaveList;
74 } else if (F.getCallingConv() == CallingConv::CFGuard_Check) {
75 return CSR_Win_AAPCS_CFGuard_Check_SaveList;
76 } else if (F.getCallingConv() == CallingConv::SwiftTail) {
77 return STI.isTargetDarwin() ? CSR_iOS_SwiftTail_SaveList
78 : (PushPopSplit == ARMSubtarget::SplitR7
79 ? CSR_ATPCS_SplitPush_SwiftTail_SaveList
80 : CSR_AAPCS_SwiftTail_SaveList);
81 } else if (F.hasFnAttribute("interrupt")) {
82
83 // Don't save the floating point registers if target does not have floating
84 // point registers.
85 if (STI.hasFPRegs() && F.hasFnAttribute("save-fp")) {
86 bool HasNEON = STI.hasNEON();
87
88 if (STI.isMClass()) {
89 assert(!HasNEON && "NEON is only for Cortex-R/A");
90 return PushPopSplit == ARMSubtarget::SplitR7
91 ? CSR_ATPCS_SplitPush_FP_SaveList
92 : CSR_AAPCS_FP_SaveList;
93 }
94 if (F.getFnAttribute("interrupt").getValueAsString() == "FIQ") {
95 return HasNEON ? CSR_FIQ_FP_NEON_SaveList : CSR_FIQ_FP_SaveList;
96 }
97 return HasNEON ? CSR_GenericInt_FP_NEON_SaveList
98 : CSR_GenericInt_FP_SaveList;
99 }
100
101 if (STI.isMClass()) {
102 // M-class CPUs have hardware which saves the registers needed to allow a
103 // function conforming to the AAPCS to function as a handler.
104 return PushPopSplit == ARMSubtarget::SplitR7
105 ? CSR_ATPCS_SplitPush_SaveList
106 : CSR_AAPCS_SaveList;
107 } else if (F.getFnAttribute("interrupt").getValueAsString() == "FIQ") {
108 // Fast interrupt mode gives the handler a private copy of R8-R14, so less
109 // need to be saved to restore user-mode state.
110 return CSR_FIQ_SaveList;
111 } else {
112 // Generally only R13-R14 (i.e. SP, LR) are automatically preserved by
113 // exception handling.
114 return CSR_GenericInt_SaveList;
115 }
116 }
117
119 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError)) {
120 if (STI.isTargetDarwin())
121 return CSR_iOS_SwiftError_SaveList;
122
123 return PushPopSplit == ARMSubtarget::SplitR7
124 ? CSR_ATPCS_SplitPush_SwiftError_SaveList
125 : CSR_AAPCS_SwiftError_SaveList;
126 }
127
128 if (STI.isTargetDarwin() && F.getCallingConv() == CallingConv::CXX_FAST_TLS)
129 return MF->getInfo<ARMFunctionInfo>()->isSplitCSR()
130 ? CSR_iOS_CXX_TLS_PE_SaveList
131 : CSR_iOS_CXX_TLS_SaveList;
132
133 if (STI.isTargetDarwin())
134 return CSR_iOS_SaveList;
135
136 if (PushPopSplit == ARMSubtarget::SplitR7)
137 return STI.createAAPCSFrameChain() ? CSR_AAPCS_SplitPush_R7_SaveList
138 : CSR_ATPCS_SplitPush_SaveList;
139
140 if (PushPopSplit == ARMSubtarget::SplitR11AAPCSSignRA)
141 return CSR_AAPCS_SplitPush_R11_SaveList;
142
143 return CSR_AAPCS_SaveList;
144}
145
147 const MachineFunction *MF) const {
148 assert(MF && "Invalid MachineFunction pointer.");
151 return CSR_iOS_CXX_TLS_ViaCopy_SaveList;
152 return nullptr;
153}
154
155const uint32_t *
157 CallingConv::ID CC) const {
158 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
159 if (CC == CallingConv::GHC)
160 // This is academic because all GHC calls are (supposed to be) tail calls
161 return CSR_NoRegs_RegMask;
163 return CSR_Win_AAPCS_CFGuard_Check_RegMask;
164 if (CC == CallingConv::SwiftTail) {
165 return STI.isTargetDarwin() ? CSR_iOS_SwiftTail_RegMask
166 : CSR_AAPCS_SwiftTail_RegMask;
167 }
169 MF.getFunction().getAttributes().hasAttrSomewhere(Attribute::SwiftError))
170 return STI.isTargetDarwin() ? CSR_iOS_SwiftError_RegMask
171 : CSR_AAPCS_SwiftError_RegMask;
172
173 if (STI.isTargetDarwin() && CC == CallingConv::CXX_FAST_TLS)
174 return CSR_iOS_CXX_TLS_RegMask;
175 return STI.isTargetDarwin() ? CSR_iOS_RegMask : CSR_AAPCS_RegMask;
176}
177
178const uint32_t*
180 return CSR_NoRegs_RegMask;
181}
182
183const uint32_t *
186 "only know about special TLS call on Darwin");
187 return CSR_iOS_TLSCall_RegMask;
188}
189
190const uint32_t *
192 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
193 if (!STI.useSoftFloat() && STI.hasVFP2Base() && !STI.isThumb1Only())
194 return CSR_NoRegs_RegMask;
195 else
196 return CSR_FPRegs_RegMask;
197}
198
199const uint32_t *
201 CallingConv::ID CC) const {
202 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
203 // This should return a register mask that is the same as that returned by
204 // getCallPreservedMask but that additionally preserves the register used for
205 // the first i32 argument (which must also be the register used to return a
206 // single i32 return value)
207 //
208 // In case that the calling convention does not use the same register for
209 // both or otherwise does not want to enable this optimization, the function
210 // should return NULL
211 if (CC == CallingConv::GHC)
212 // This is academic because all GHC calls are (supposed to be) tail calls
213 return nullptr;
214 return STI.isTargetDarwin() ? CSR_iOS_ThisReturn_RegMask
215 : CSR_AAPCS_ThisReturn_RegMask;
216}
217
219 const MachineFunction *MF) const {
220 static const MCPhysReg IntraCallClobberedRegs[] = {ARM::R12};
221 return ArrayRef<MCPhysReg>(IntraCallClobberedRegs);
222}
223
225getReservedRegs(const MachineFunction &MF) const {
226 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
227 const ARMFrameLowering *TFI = getFrameLowering(MF);
228
229 // FIXME: avoid re-calculating this every time.
230 BitVector Reserved(getNumRegs());
231 markSuperRegs(Reserved, ARM::SP);
232 markSuperRegs(Reserved, ARM::PC);
233 markSuperRegs(Reserved, ARM::FPSCR);
234 markSuperRegs(Reserved, ARM::FPSCR_RM);
235 markSuperRegs(Reserved, ARM::APSR_NZCV);
236 if (TFI->isFPReserved(MF))
237 markSuperRegs(Reserved, STI.getFramePointerReg());
238 if (hasBasePointer(MF))
239 markSuperRegs(Reserved, BasePtr);
240 // Some targets reserve R9.
241 if (STI.isR9Reserved())
242 markSuperRegs(Reserved, ARM::R9);
243 // Reserve D16-D31 if the subtarget doesn't support them.
244 if (!STI.hasD32()) {
245 static_assert(ARM::D31 == ARM::D16 + 15, "Register list not consecutive!");
246 for (unsigned R = 0; R < 16; ++R)
247 markSuperRegs(Reserved, ARM::D16 + R);
248 }
249 const TargetRegisterClass &RC = ARM::GPRPairRegClass;
250 for (unsigned Reg : RC)
251 for (MCPhysReg S : subregs(Reg))
252 if (Reserved.test(S))
253 markSuperRegs(Reserved, Reg);
254 // For v8.1m architecture
255 markSuperRegs(Reserved, ARM::ZR);
256
257 assert(checkAllSuperRegsMarked(Reserved));
258 return Reserved;
259}
260
262isAsmClobberable(const MachineFunction &MF, MCRegister PhysReg) const {
263 return !getReservedRegs(MF).test(PhysReg);
264}
265
267 MCRegister PhysReg) const {
268 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
269 const ARMFrameLowering *TFI = getFrameLowering(MF);
270
271 BitVector Reserved(getNumRegs());
272 markSuperRegs(Reserved, ARM::PC);
273 if (TFI->isFPReserved(MF))
274 markSuperRegs(Reserved, STI.getFramePointerReg());
275 if (hasBasePointer(MF))
276 markSuperRegs(Reserved, BasePtr);
277 assert(checkAllSuperRegsMarked(Reserved));
278 return Reserved.test(PhysReg.id());
279}
280
283 const MachineFunction &MF) const {
284 unsigned SuperID = RC->getID();
285 auto I = RC->superclasses().begin();
286 auto E = RC->superclasses().end();
287 do {
288 switch (SuperID) {
289 case ARM::GPRRegClassID:
290 case ARM::SPRRegClassID:
291 case ARM::DPRRegClassID:
292 case ARM::GPRPairRegClassID:
293 return getRegClass(SuperID);
294 case ARM::QPRRegClassID:
295 case ARM::QQPRRegClassID:
296 case ARM::QQQQPRRegClassID:
297 if (MF.getSubtarget<ARMSubtarget>().hasNEON())
298 return getRegClass(SuperID);
299 break;
300 case ARM::MQPRRegClassID:
301 case ARM::MQQPRRegClassID:
302 case ARM::MQQQQPRRegClassID:
303 if (MF.getSubtarget<ARMSubtarget>().hasMVEIntegerOps())
304 return getRegClass(SuperID);
305 break;
306 }
307 SuperID = (I != E) ? *I++ : ~0U;
308 } while (SuperID != ~0U);
309 return RC;
310}
311
314 if (RC == &ARM::CCRRegClass)
315 return &ARM::rGPRRegClass; // Can't copy CCR registers.
316 if (RC == &ARM::cl_FPSCR_NZCVRegClass)
317 return &ARM::rGPRRegClass;
318 return RC;
319}
320
321unsigned
323 MachineFunction &MF) const {
324 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
325 const ARMFrameLowering *TFI = getFrameLowering(MF);
326
327 switch (RC->getID()) {
328 default:
329 return 0;
330 case ARM::tGPRRegClassID: {
331 // hasFP ends up calling getMaxCallFrameComputed() which may not be
332 // available when getPressureLimit() is called as part of
333 // ScheduleDAGRRList.
334 bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
335 ? TFI->hasFP(MF) : true;
336 return 5 - HasFP;
337 }
338 case ARM::GPRRegClassID: {
339 bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
340 ? TFI->hasFP(MF) : true;
341 return 10 - HasFP - (STI.isR9Reserved() ? 1 : 0);
342 }
343 case ARM::SPRRegClassID: // Currently not used as 'rep' register class.
344 case ARM::DPRRegClassID:
345 return 32 - 10;
346 }
347}
348
349// Get the other register in a GPRPair.
351 const MCRegisterInfo *RI) {
352 for (MCPhysReg Super : RI->superregs(Reg))
353 if (ARM::GPRPairRegClass.contains(Super))
354 return RI->getSubReg(Super, Odd ? ARM::gsub_1 : ARM::gsub_0);
355 return MCRegister();
356}
357
358// Resolve the RegPairEven / RegPairOdd register allocator hints.
360 Register VirtReg, ArrayRef<MCPhysReg> Order,
362 const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const {
363 const MachineRegisterInfo &MRI = MF.getRegInfo();
364 std::pair<unsigned, Register> Hint = MRI.getRegAllocationHint(VirtReg);
365
366 unsigned Odd;
367 switch (Hint.first) {
369 Odd = 0;
370 break;
372 Odd = 1;
373 break;
374 case ARMRI::RegLR:
375 TargetRegisterInfo::getRegAllocationHints(VirtReg, Order, Hints, MF, VRM);
376 if (MRI.getRegClass(VirtReg)->contains(ARM::LR))
377 Hints.push_back(ARM::LR);
378 return false;
379 default:
380 return TargetRegisterInfo::getRegAllocationHints(VirtReg, Order, Hints, MF, VRM);
381 }
382
383 // This register should preferably be even (Odd == 0) or odd (Odd == 1).
384 // Check if the other part of the pair has already been assigned, and provide
385 // the paired register as the first hint.
386 Register Paired = Hint.second;
387 if (!Paired)
388 return false;
389
390 Register PairedPhys;
391 if (Paired.isPhysical()) {
392 PairedPhys = Paired;
393 } else if (VRM && VRM->hasPhys(Paired)) {
394 PairedPhys = getPairedGPR(VRM->getPhys(Paired), Odd, this);
395 }
396
397 // First prefer the paired physreg.
398 if (PairedPhys && is_contained(Order, PairedPhys))
399 Hints.push_back(PairedPhys);
400
401 // Then prefer even or odd registers.
402 for (MCPhysReg Reg : Order) {
403 if (Reg == PairedPhys || (getEncodingValue(Reg) & 1) != Odd)
404 continue;
405 // Don't provide hints that are paired to a reserved register.
406 MCRegister Paired = getPairedGPR(Reg, !Odd, this);
407 if (!Paired || MRI.isReserved(Paired))
408 continue;
409 Hints.push_back(Reg);
410 }
411 return false;
412}
413
415 MachineFunction &MF) const {
416 MachineRegisterInfo *MRI = &MF.getRegInfo();
417 std::pair<unsigned, Register> Hint = MRI->getRegAllocationHint(Reg);
418 if ((Hint.first == ARMRI::RegPairOdd || Hint.first == ARMRI::RegPairEven) &&
419 Hint.second.isVirtual()) {
420 // If 'Reg' is one of the even / odd register pair and it's now changed
421 // (e.g. coalesced) into a different register. The other register of the
422 // pair allocation hint must be updated to reflect the relationship
423 // change.
424 Register OtherReg = Hint.second;
425 Hint = MRI->getRegAllocationHint(OtherReg);
426 // Make sure the pair has not already divorced.
427 if (Hint.second == Reg) {
428 MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg);
429 if (NewReg.isVirtual())
430 MRI->setRegAllocationHint(NewReg,
431 Hint.first == ARMRI::RegPairOdd
434 OtherReg);
435 }
436 }
437}
438
440 const MachineFrameInfo &MFI = MF.getFrameInfo();
441 const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
442 const ARMFrameLowering *TFI = getFrameLowering(MF);
443
444 // For Windows SEH, the runtime does not preserve SP or R11 for EH funclets.
445 // Fortunately, R4-R10 are always preserved.
446 // Therefore, we force these functions to set up a base pointer.
447 if (MF.hasEHFunclets())
448 return true;
449
450 // If we have stack realignment and VLAs, we have no pointer to use to
451 // access the stack. If we have stack realignment, and a large call frame,
452 // we have no place to allocate the emergency spill slot.
453 if (hasStackRealignment(MF) && !TFI->hasReservedCallFrame(MF))
454 return true;
455
456 // Thumb has trouble with negative offsets from the FP. Thumb2 has a limited
457 // negative range for ldr/str (255), and Thumb1 is positive offsets only.
458 //
459 // It's going to be better to use the SP or Base Pointer instead. When there
460 // are variable sized objects, we can't reference off of the SP, so we
461 // reserve a Base Pointer.
462 //
463 // For Thumb2, estimate whether a negative offset from the frame pointer
464 // will be sufficient to reach the whole stack frame. If a function has a
465 // smallish frame, it's less likely to have lots of spills and callee saved
466 // space, so it's all more likely to be within range of the frame pointer.
467 // If it's wrong, the scavenger will still enable access to work, it just
468 // won't be optimal. (We should always be able to reach the emergency
469 // spill slot from the frame pointer.)
470 if (AFI->isThumb2Function() && MFI.hasVarSizedObjects() &&
471 MFI.getLocalFrameSize() >= 128)
472 return true;
473 // For Thumb1, if sp moves, nothing is in range, so force a base pointer.
474 // This is necessary for correctness in cases where we need an emergency
475 // spill slot. (In Thumb1, we can't use a negative offset from the frame
476 // pointer.)
477 if (AFI->isThumb1OnlyFunction() && !TFI->hasReservedCallFrame(MF))
478 return true;
479 return false;
480}
481
483 const MachineRegisterInfo *MRI = &MF.getRegInfo();
484 const ARMFrameLowering *TFI = getFrameLowering(MF);
485 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
486 // We can't realign the stack if:
487 // 1. Dynamic stack realignment is explicitly disabled,
488 // 2. There are VLAs in the function and the base pointer is disabled.
490 return false;
491 // Stack realignment requires a frame pointer. If we already started
492 // register allocation with frame pointer elimination, it is too late now.
493 if (!MRI->canReserveReg(STI.getFramePointerReg()))
494 return false;
495 // We may also need a base pointer if there are dynamic allocas or stack
496 // pointer adjustments around calls.
497 if (TFI->hasReservedCallFrame(MF))
498 return true;
499 // A base pointer is required and allowed. Check that it isn't too late to
500 // reserve it.
501 return MRI->canReserveReg(BasePtr);
502}
503
505cannotEliminateFrame(const MachineFunction &MF) const {
506 const MachineFrameInfo &MFI = MF.getFrameInfo();
507 if (MF.disableFramePointerElim() && MFI.adjustsStack())
508 return true;
509 return MFI.hasVarSizedObjects() || MFI.isFrameAddressTaken() ||
510 hasStackRealignment(MF);
511}
512
515 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
516 const ARMFrameLowering *TFI = getFrameLowering(MF);
517
518 if (TFI->hasFP(MF))
519 return STI.getFramePointerReg();
520 return ARM::SP;
521}
522
523unsigned
525 const auto &MFI = MF.getFrameInfo();
526 if (!MF.hasEHFunclets() && !MFI.hasVarSizedObjects())
527 return ARM::SP;
528 else if (MF.hasEHFunclets() || hasStackRealignment(MF))
529 return getBaseRegister();
530 return getFrameRegister(MF);
531}
532
533/// emitLoadConstPool - Emits a load from constpool to materialize the
534/// specified immediate.
537 const DebugLoc &dl, Register DestReg, unsigned SubIdx, int Val,
538 ARMCC::CondCodes Pred, Register PredReg, unsigned MIFlags) const {
539 MachineFunction &MF = *MBB.getParent();
542 const Constant *C =
543 ConstantInt::get(Type::getInt32Ty(MF.getFunction().getContext()), Val);
544 unsigned Idx = ConstantPool->getConstantPoolIndex(C, Align(4));
545
546 BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp))
547 .addReg(DestReg, getDefRegState(true), SubIdx)
549 .addImm(0)
550 .add(predOps(Pred, PredReg))
551 .setMIFlags(MIFlags);
552}
553
556 return true;
557}
558
561 return true;
562}
563
566 return true;
567}
568
570getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const {
571 const MCInstrDesc &Desc = MI->getDesc();
572 unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
573 int64_t InstrOffs = 0;
574 int Scale = 1;
575 unsigned ImmIdx = 0;
576 switch (AddrMode) {
582 InstrOffs = MI->getOperand(Idx+1).getImm();
583 Scale = 1;
584 break;
585 case ARMII::AddrMode5: {
586 // VFP address mode.
587 const MachineOperand &OffOp = MI->getOperand(Idx+1);
588 InstrOffs = ARM_AM::getAM5Offset(OffOp.getImm());
589 if (ARM_AM::getAM5Op(OffOp.getImm()) == ARM_AM::sub)
590 InstrOffs = -InstrOffs;
591 Scale = 4;
592 break;
593 }
594 case ARMII::AddrMode2:
595 ImmIdx = Idx+2;
596 InstrOffs = ARM_AM::getAM2Offset(MI->getOperand(ImmIdx).getImm());
597 if (ARM_AM::getAM2Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
598 InstrOffs = -InstrOffs;
599 break;
600 case ARMII::AddrMode3:
601 ImmIdx = Idx+2;
602 InstrOffs = ARM_AM::getAM3Offset(MI->getOperand(ImmIdx).getImm());
603 if (ARM_AM::getAM3Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
604 InstrOffs = -InstrOffs;
605 break;
607 ImmIdx = Idx+1;
608 InstrOffs = MI->getOperand(ImmIdx).getImm();
609 Scale = 4;
610 break;
611 default:
612 llvm_unreachable("Unsupported addressing mode!");
613 }
614
615 return InstrOffs * Scale;
616}
617
618/// needsFrameBaseReg - Returns true if the instruction's frame index
619/// reference would be better served by a base register other than FP
620/// or SP. Used by LocalStackFrameAllocation to determine which frame index
621/// references it should create new base registers for.
623needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const {
624 for (unsigned i = 0; !MI->getOperand(i).isFI(); ++i) {
625 assert(i < MI->getNumOperands() &&"Instr doesn't have FrameIndex operand!");
626 }
627
628 // It's the load/store FI references that cause issues, as it can be difficult
629 // to materialize the offset if it won't fit in the literal field. Estimate
630 // based on the size of the local frame and some conservative assumptions
631 // about the rest of the stack frame (note, this is pre-regalloc, so
632 // we don't know everything for certain yet) whether this offset is likely
633 // to be out of range of the immediate. Return true if so.
634
635 // We only generate virtual base registers for loads and stores, so
636 // return false for everything else.
637 unsigned Opc = MI->getOpcode();
638 switch (Opc) {
639 case ARM::LDRi12: case ARM::LDRH: case ARM::LDRBi12:
640 case ARM::STRi12: case ARM::STRH: case ARM::STRBi12:
641 case ARM::t2LDRi12: case ARM::t2LDRi8:
642 case ARM::t2STRi12: case ARM::t2STRi8:
643 case ARM::VLDRS: case ARM::VLDRD:
644 case ARM::VSTRS: case ARM::VSTRD:
645 case ARM::tSTRspi: case ARM::tLDRspi:
646 break;
647 default:
648 return false;
649 }
650
651 // Without a virtual base register, if the function has variable sized
652 // objects, all fixed-size local references will be via the frame pointer,
653 // Approximate the offset and see if it's legal for the instruction.
654 // Note that the incoming offset is based on the SP value at function entry,
655 // so it'll be negative.
656 MachineFunction &MF = *MI->getParent()->getParent();
657 const ARMFrameLowering *TFI = getFrameLowering(MF);
658 MachineFrameInfo &MFI = MF.getFrameInfo();
660
661 // Estimate an offset from the frame pointer.
662 // Conservatively assume all callee-saved registers get pushed. R4-R6
663 // will be earlier than the FP, so we ignore those.
664 // R7, LR
665 int64_t FPOffset = Offset - 8;
666 // ARM and Thumb2 functions also need to consider R8-R11 and D8-D15
667 if (!AFI->isThumbFunction() || !AFI->isThumb1OnlyFunction())
668 FPOffset -= 80;
669 // Estimate an offset from the stack pointer.
670 // The incoming offset is relating to the SP at the start of the function,
671 // but when we access the local it'll be relative to the SP after local
672 // allocation, so adjust our SP-relative offset by that allocation size.
673 Offset += MFI.getLocalFrameSize();
674 // Assume that we'll have at least some spill slots allocated.
675 // FIXME: This is a total SWAG number. We should run some statistics
676 // and pick a real one.
677 Offset += 128; // 128 bytes of spill slots
678
679 // If there's a frame pointer and the addressing mode allows it, try using it.
680 // The FP is only available if there is no dynamic realignment. We
681 // don't know for sure yet whether we'll need that, so we guess based
682 // on whether there are any local variables that would trigger it.
683 if (TFI->hasFP(MF) &&
684 !((MFI.getLocalFrameMaxAlign() > TFI->getStackAlign()) &&
685 canRealignStack(MF))) {
686 if (isFrameOffsetLegal(MI, getFrameRegister(MF), FPOffset))
687 return false;
688 }
689 // If we can reference via the stack pointer, try that.
690 // FIXME: This (and the code that resolves the references) can be improved
691 // to only disallow SP relative references in the live range of
692 // the VLA(s). In practice, it's unclear how much difference that
693 // would make, but it may be worth doing.
694 if (!MFI.hasVarSizedObjects() && isFrameOffsetLegal(MI, ARM::SP, Offset))
695 return false;
696
697 // The offset likely isn't legal, we want to allocate a virtual base register.
698 return true;
699}
700
701/// materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to
702/// be a pointer to FrameIdx at the beginning of the basic block.
705 int FrameIdx,
706 int64_t Offset) const {
707 ARMFunctionInfo *AFI = MBB->getParent()->getInfo<ARMFunctionInfo>();
708 unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri :
709 (AFI->isThumb1OnlyFunction() ? ARM::tADDframe : ARM::t2ADDri);
710
711 MachineBasicBlock::iterator Ins = MBB->begin();
712 DebugLoc DL; // Defaults to "unknown"
713 if (Ins != MBB->end())
714 DL = Ins->getDebugLoc();
715
716 const MachineFunction &MF = *MBB->getParent();
717 MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
719 const MCInstrDesc &MCID = TII.get(ADDriOpc);
720 Register BaseReg = MRI.createVirtualRegister(&ARM::GPRRegClass);
721 MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0));
722
723 MachineInstrBuilder MIB = BuildMI(*MBB, Ins, DL, MCID, BaseReg)
724 .addFrameIndex(FrameIdx).addImm(Offset);
725
726 if (!AFI->isThumb1OnlyFunction())
728
729 return BaseReg;
730}
731
733 int64_t Offset) const {
734 MachineBasicBlock &MBB = *MI.getParent();
735 MachineFunction &MF = *MBB.getParent();
736 const ARMBaseInstrInfo &TII =
737 *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
739 int Off = Offset; // ARM doesn't need the general 64-bit offsets
740 unsigned i = 0;
741
743 "This resolveFrameIndex does not support Thumb1!");
744
745 while (!MI.getOperand(i).isFI()) {
746 ++i;
747 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
748 }
749 bool Done = false;
750 if (!AFI->isThumbFunction())
751 Done = rewriteARMFrameIndex(MI, i, BaseReg, Off, TII);
752 else {
753 assert(AFI->isThumb2Function());
754 Done = rewriteT2FrameIndex(MI, i, BaseReg, Off, TII, this);
755 }
756 assert(Done && "Unable to resolve frame index!");
757 (void)Done;
758}
759
761 Register BaseReg,
762 int64_t Offset) const {
763 const MCInstrDesc &Desc = MI->getDesc();
764 unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
765 unsigned i = 0;
766 for (; !MI->getOperand(i).isFI(); ++i)
767 assert(i+1 < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!");
768
769 // AddrMode4 and AddrMode6 cannot handle any offset.
771 return Offset == 0;
772
773 unsigned NumBits = 0;
774 unsigned Scale = 1;
775 bool isSigned = true;
776 switch (AddrMode) {
781 // i8 supports only negative, and i12 supports only positive, so
782 // based on Offset sign, consider the appropriate instruction
783 Scale = 1;
784 if (Offset < 0) {
785 NumBits = 8;
786 Offset = -Offset;
787 } else {
788 NumBits = 12;
789 }
790 break;
791 case ARMII::AddrMode5:
792 // VFP address mode.
793 NumBits = 8;
794 Scale = 4;
795 break;
797 case ARMII::AddrMode2:
798 NumBits = 12;
799 break;
800 case ARMII::AddrMode3:
801 NumBits = 8;
802 break;
804 NumBits = (BaseReg == ARM::SP ? 8 : 5);
805 Scale = 4;
806 isSigned = false;
807 break;
808 default:
809 llvm_unreachable("Unsupported addressing mode!");
810 }
811
813 // Make sure the offset is encodable for instructions that scale the
814 // immediate.
815 if ((Offset & (Scale-1)) != 0)
816 return false;
817
818 if (isSigned && Offset < 0)
819 Offset = -Offset;
820
821 unsigned Mask = (1 << NumBits) - 1;
822 if ((unsigned)Offset <= Mask * Scale)
823 return true;
824
825 return false;
826}
827
828bool
830 int SPAdj, unsigned FIOperandNum,
831 RegScavenger *RS) const {
832 MachineInstr &MI = *II;
833 MachineBasicBlock &MBB = *MI.getParent();
834 MachineFunction &MF = *MBB.getParent();
835 const ARMBaseInstrInfo &TII =
836 *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
837 const ARMFrameLowering *TFI = getFrameLowering(MF);
840 "This eliminateFrameIndex does not support Thumb1!");
841 int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
842 Register FrameReg;
843
844 int Offset = TFI->ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
845
846 if (MI.getOpcode() == TargetOpcode::LOCAL_ESCAPE) {
847 MachineOperand &FI = MI.getOperand(FIOperandNum);
849 FI.ChangeToImmediate(Offset.getFixed());
850 return false;
851 }
852
853 // PEI::scavengeFrameVirtualRegs() cannot accurately track SPAdj because the
854 // call frame setup/destroy instructions have already been eliminated. That
855 // means the stack pointer cannot be used to access the emergency spill slot
856 // when !hasReservedCallFrame().
857#ifndef NDEBUG
858 if (RS && FrameReg == ARM::SP && RS->isScavengingFrameIndex(FrameIndex)){
859 assert(TFI->hasReservedCallFrame(MF) &&
860 "Cannot use SP to access the emergency spill slot in "
861 "functions without a reserved call frame");
863 "Cannot use SP to access the emergency spill slot in "
864 "functions with variable sized frame objects");
865 }
866#endif // NDEBUG
867
868 assert(!MI.isDebugValue() && "DBG_VALUEs should be handled in target-independent code");
869
870 // Modify MI as necessary to handle as much of 'Offset' as possible
871 bool Done = false;
872 if (!AFI->isThumbFunction())
873 Done = rewriteARMFrameIndex(MI, FIOperandNum, FrameReg, Offset, TII);
874 else {
875 assert(AFI->isThumb2Function());
876 Done = rewriteT2FrameIndex(MI, FIOperandNum, FrameReg, Offset, TII, this);
877 }
878 if (Done)
879 return false;
880
881 // If we get here, the immediate doesn't fit into the instruction. We folded
882 // as much as possible above, handle the rest, providing a register that is
883 // SP+LargeImm.
884 assert(
885 (Offset ||
886 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode4 ||
887 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode6 ||
888 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7 ||
889 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7s2 ||
890 (MI.getDesc().TSFlags & ARMII::AddrModeMask) ==
892 "This code isn't needed if offset already handled!");
893
894 unsigned ScratchReg = 0;
895 int PIdx = MI.findFirstPredOperandIdx();
896 ARMCC::CondCodes Pred = (PIdx == -1)
897 ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImm();
898 Register PredReg = (PIdx == -1) ? Register() : MI.getOperand(PIdx+1).getReg();
899
900 const MCInstrDesc &MCID = MI.getDesc();
901 const TargetRegisterClass *RegClass = TII.getRegClass(MCID, FIOperandNum);
902
903 if (Offset == 0 && (FrameReg.isVirtual() || RegClass->contains(FrameReg)))
904 // Must be addrmode4/6.
905 MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false, false, false);
906 else {
907 ScratchReg = MF.getRegInfo().createVirtualRegister(RegClass);
908 if (!AFI->isThumbFunction())
909 emitARMRegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
910 Offset, Pred, PredReg, TII);
911 else {
912 assert(AFI->isThumb2Function());
913 emitT2RegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
914 Offset, Pred, PredReg, TII);
915 }
916 // Update the original instruction to use the scratch register.
917 MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false, false,true);
918 }
919 return false;
920}
921
923 const TargetRegisterClass *SrcRC,
924 unsigned SubReg,
925 const TargetRegisterClass *DstRC,
926 unsigned DstSubReg,
927 const TargetRegisterClass *NewRC,
928 LiveIntervals &LIS) const {
929 auto MBB = MI->getParent();
930 auto MF = MBB->getParent();
931 const MachineRegisterInfo &MRI = MF->getRegInfo();
932 // If not copying into a sub-register this should be ok because we shouldn't
933 // need to split the reg.
934 if (!DstSubReg)
935 return true;
936 // Small registers don't frequently cause a problem, so we can coalesce them.
937 if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
938 getRegSizeInBits(*SrcRC) < 256)
939 return true;
940
941 auto NewRCWeight =
943 auto SrcRCWeight =
945 auto DstRCWeight =
947 // If the source register class is more expensive than the destination, the
948 // coalescing is probably profitable.
949 if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
950 return true;
951 if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
952 return true;
953
954 // If the register allocator isn't constrained, we can always allow coalescing
955 // unfortunately we don't know yet if we will be constrained.
956 // The goal of this heuristic is to restrict how many expensive registers
957 // we allow to coalesce in a given basic block.
958 auto AFI = MF->getInfo<ARMFunctionInfo>();
959 auto It = AFI->getCoalescedWeight(MBB);
960
961 LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: "
962 << It->second << "\n");
963 LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: "
964 << NewRCWeight.RegWeight << "\n");
965
966 // This number is the largest round number that which meets the criteria:
967 // (1) addresses PR18825
968 // (2) generates better code in some test cases (like vldm-shed-a9.ll)
969 // (3) Doesn't regress any test cases (in-tree, test-suite, and SPEC)
970 // In practice the SizeMultiplier will only factor in for straight line code
971 // that uses a lot of NEON vectors, which isn't terribly common.
972 unsigned SizeMultiplier = MBB->size()/100;
973 SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
974 if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
975 It->second += NewRCWeight.RegWeight;
976 return true;
977 }
978 return false;
979}
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static MCRegister getPairedGPR(MCRegister Reg, bool Odd, const MCRegisterInfo *RI)
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file contains the simple types necessary to represent the attributes associated with functions a...
This file implements the BitVector class.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned Opcode)
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
Live Register Matrix
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register Reg
Promote Memory to Register
Definition Mem2Reg.cpp:110
uint64_t IntrinsicInst * II
This file declares the machine register scavenger class.
This file contains some templates that are useful if you are working with the STL at all.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
This file defines the SmallVector class.
#define LLVM_DEBUG(...)
Definition Debug.h:119
bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC, LiveIntervals &LIS) const override
SrcRC and DstRC will be morphed into NewRC if this returns true.
bool hasBasePointer(const MachineFunction &MF) const
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg, int64_t Offset) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const override
void updateRegAllocHint(Register Reg, Register NewReg, MachineFunction &MF) const override
const uint32_t * getNoPreservedMask() const override
bool isInlineAsmReadOnlyReg(const MachineFunction &MF, MCRegister PhysReg) const override
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
virtual void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, Register DestReg, unsigned SubIdx, int Val, ARMCC::CondCodes Pred=ARMCC::AL, Register PredReg=Register(), unsigned MIFlags=MachineInstr::NoFlags) const
emitLoadConstPool - Emits a load from constpool to materialize the specified immediate.
const uint32_t * getSjLjDispatchPreservedMask(const MachineFunction &MF) const
bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
unsigned getLocalAddressRegister(const MachineFunction &MF) const
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
bool cannotEliminateFrame(const MachineFunction &MF) const
Register getFrameRegister(const MachineFunction &MF) const override
bool isAsmClobberable(const MachineFunction &MF, MCRegister PhysReg) const override
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx, int64_t Offset) const override
materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx...
bool requiresRegisterScavenging(const MachineFunction &MF) const override
Code Generation virtual methods...
const uint32_t * getTLSCallPreservedMask(const MachineFunction &MF) const
void resolveFrameIndex(MachineInstr &MI, Register BaseReg, int64_t Offset) const override
unsigned BasePtr
BasePtr - ARM physical register used as a base ptr in complex stack frames.
ArrayRef< MCPhysReg > getIntraCallClobberedRegs(const MachineFunction *MF) const override
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction's frame index reference would be better served by...
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that 'returned' is on...
bool canRealignStack(const MachineFunction &MF) const override
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const override
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, int SPAdj) const
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
DenseMap< constMachineBasicBlock *, unsigned >::iterator getCoalescedWeight(MachineBasicBlock *MBB)
bool isThumb1Only() const
MCPhysReg getFramePointerReg() const
const ARMTargetLowering * getTargetLowering() const override
bool isTargetDarwin() const
bool hasVFP2Base() const
bool isR9Reserved() const
enum PushPopSplitVariation getPushPopSplitVariation(const MachineFunction &MF) const
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...
bool isMClass() const
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:130
iterator begin() const
Definition ArrayRef.h:129
bool test(unsigned Idx) const
Returns true if bit Idx is set.
Definition BitVector.h:482
This is an important base class in LLVM.
Definition Constant.h:43
A debug info location.
Definition DebugLoc.h:126
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition Function.h:273
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition Function.h:329
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition Function.cpp:356
Describe properties that are true of each instruction in the target description file.
ArrayRef< unsigned > superclasses() const
Returns a list of super-classes.
unsigned getID() const
getID() - Return the register class ID number.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
iterator_range< MCSuperRegIterator > superregs(MCRegister Reg) const
Return an iterator range over all super-registers of Reg, excluding Reg.
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo.
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
constexpr unsigned id() const
Definition MCRegister.h:82
MachineInstrBundleIterator< MachineInstr > iterator
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
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 adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
bool isMaxCallFrameSizeComputed() const
int64_t getLocalFrameSize() const
Get the size of the local object blob.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
bool disableFramePointerElim() const
Returns true if frame pointer elimination should be disabled for this function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
int64_t getImm() const
LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags=0)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
bool isReserved(MCRegister PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
std::pair< unsigned, Register > getRegAllocationHint(Register VReg) const
getRegAllocationHint - Return the register allocation hint for the specified virtual register.
void setRegAllocationHint(Register VReg, unsigned Type, Register PrefReg)
setRegAllocationHint - Specify a register allocation hint for the specified virtual register.
bool canReserveReg(MCRegister PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
const TargetRegisterInfo * getTargetRegisterInfo() const
LLVM_ABI const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
Wrapper class representing virtual and physical registers.
Definition Register.h:20
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition Register.h:83
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
StackOffset holds a fixed and a scalable offset in bytes.
Definition TypeSize.h:30
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
virtual bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM=nullptr, const LiveRegMatrix *Matrix=nullptr) const
Get a list of 'hint' registers that the register allocator should try first when allocating a physica...
virtual const TargetInstrInfo * getInstrInfo() const
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
Definition VirtRegMap.h:91
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
Definition VirtRegMap.h:87
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned char getAM3Offset(unsigned AM3Opc)
unsigned getAM2Offset(unsigned AM2Opc)
AddrOpc getAM5Op(unsigned AM5Opc)
unsigned char getAM5Offset(unsigned AM5Opc)
AddrOpc getAM2Op(unsigned AM2Opc)
AddrOpc getAM3Op(unsigned AM3Opc)
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
Define some predicates that are used for node matching.
Definition ARMEHABI.h:25
@ D16
Only 16 D registers.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ CFGuard_Check
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
Definition CallingConv.h:82
@ CXX_FAST_TLS
Used for access functions.
Definition CallingConv.h:72
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
Definition CallingConv.h:50
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
Definition CallingConv.h:87
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Done
Definition Threading.h:60
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, Register FrameReg, int &Offset, const ARMBaseInstrInfo &TII, const TargetRegisterInfo *TRI)
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
Op::Description Desc
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
constexpr RegState getDefRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
bool rewriteARMFrameIndex(MachineInstr &MI, unsigned FrameRegIdx, Register FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
rewriteARMFrameIndex / rewriteT2FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
void emitARMRegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, Register DestReg, Register BaseReg, int NumBytes, ARMCC::CondCodes Pred, Register PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of instructions to materializea des...
void emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, Register DestReg, Register BaseReg, int NumBytes, ARMCC::CondCodes Pred, Register PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39