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 return &ARM::GPRRegClass;
315}
316
319 if (RC == &ARM::CCRRegClass)
320 return &ARM::rGPRRegClass; // Can't copy CCR registers.
321 if (RC == &ARM::cl_FPSCR_NZCVRegClass)
322 return &ARM::rGPRRegClass;
323 return RC;
324}
325
326unsigned
328 MachineFunction &MF) const {
329 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
330 const ARMFrameLowering *TFI = getFrameLowering(MF);
331
332 switch (RC->getID()) {
333 default:
334 return 0;
335 case ARM::tGPRRegClassID: {
336 // hasFP ends up calling getMaxCallFrameComputed() which may not be
337 // available when getPressureLimit() is called as part of
338 // ScheduleDAGRRList.
339 bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
340 ? TFI->hasFP(MF) : true;
341 return 5 - HasFP;
342 }
343 case ARM::GPRRegClassID: {
344 bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
345 ? TFI->hasFP(MF) : true;
346 return 10 - HasFP - (STI.isR9Reserved() ? 1 : 0);
347 }
348 case ARM::SPRRegClassID: // Currently not used as 'rep' register class.
349 case ARM::DPRRegClassID:
350 return 32 - 10;
351 }
352}
353
354// Get the other register in a GPRPair.
356 const MCRegisterInfo *RI) {
357 for (MCPhysReg Super : RI->superregs(Reg))
358 if (ARM::GPRPairRegClass.contains(Super))
359 return RI->getSubReg(Super, Odd ? ARM::gsub_1 : ARM::gsub_0);
360 return MCRegister();
361}
362
363// Resolve the RegPairEven / RegPairOdd register allocator hints.
365 Register VirtReg, ArrayRef<MCPhysReg> Order,
367 const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const {
368 const MachineRegisterInfo &MRI = MF.getRegInfo();
369 std::pair<unsigned, Register> Hint = MRI.getRegAllocationHint(VirtReg);
370
371 unsigned Odd;
372 switch (Hint.first) {
374 Odd = 0;
375 break;
377 Odd = 1;
378 break;
379 case ARMRI::RegLR:
380 TargetRegisterInfo::getRegAllocationHints(VirtReg, Order, Hints, MF, VRM);
381 if (MRI.getRegClass(VirtReg)->contains(ARM::LR))
382 Hints.push_back(ARM::LR);
383 return false;
384 default:
385 return TargetRegisterInfo::getRegAllocationHints(VirtReg, Order, Hints, MF, VRM);
386 }
387
388 // This register should preferably be even (Odd == 0) or odd (Odd == 1).
389 // Check if the other part of the pair has already been assigned, and provide
390 // the paired register as the first hint.
391 Register Paired = Hint.second;
392 if (!Paired)
393 return false;
394
395 Register PairedPhys;
396 if (Paired.isPhysical()) {
397 PairedPhys = Paired;
398 } else if (VRM && VRM->hasPhys(Paired)) {
399 PairedPhys = getPairedGPR(VRM->getPhys(Paired), Odd, this);
400 }
401
402 // First prefer the paired physreg.
403 if (PairedPhys && is_contained(Order, PairedPhys))
404 Hints.push_back(PairedPhys);
405
406 // Then prefer even or odd registers.
407 for (MCPhysReg Reg : Order) {
408 if (Reg == PairedPhys || (getEncodingValue(Reg) & 1) != Odd)
409 continue;
410 // Don't provide hints that are paired to a reserved register.
411 MCRegister Paired = getPairedGPR(Reg, !Odd, this);
412 if (!Paired || MRI.isReserved(Paired))
413 continue;
414 Hints.push_back(Reg);
415 }
416 return false;
417}
418
420 MachineFunction &MF) const {
421 MachineRegisterInfo *MRI = &MF.getRegInfo();
422 std::pair<unsigned, Register> Hint = MRI->getRegAllocationHint(Reg);
423 if ((Hint.first == ARMRI::RegPairOdd || Hint.first == ARMRI::RegPairEven) &&
424 Hint.second.isVirtual()) {
425 // If 'Reg' is one of the even / odd register pair and it's now changed
426 // (e.g. coalesced) into a different register. The other register of the
427 // pair allocation hint must be updated to reflect the relationship
428 // change.
429 Register OtherReg = Hint.second;
430 Hint = MRI->getRegAllocationHint(OtherReg);
431 // Make sure the pair has not already divorced.
432 if (Hint.second == Reg) {
433 MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg);
434 if (NewReg.isVirtual())
435 MRI->setRegAllocationHint(NewReg,
436 Hint.first == ARMRI::RegPairOdd
439 OtherReg);
440 }
441 }
442}
443
445 const MachineFrameInfo &MFI = MF.getFrameInfo();
446 const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
447 const ARMFrameLowering *TFI = getFrameLowering(MF);
448
449 // For Windows SEH, the runtime does not preserve SP or R11 for EH funclets.
450 // Fortunately, R4-R10 are always preserved.
451 // Therefore, we force these functions to set up a base pointer.
452 if (MF.hasEHFunclets())
453 return true;
454
455 // If we have stack realignment and VLAs, we have no pointer to use to
456 // access the stack. If we have stack realignment, and a large call frame,
457 // we have no place to allocate the emergency spill slot.
458 if (hasStackRealignment(MF) && !TFI->hasReservedCallFrame(MF))
459 return true;
460
461 // Thumb has trouble with negative offsets from the FP. Thumb2 has a limited
462 // negative range for ldr/str (255), and Thumb1 is positive offsets only.
463 //
464 // It's going to be better to use the SP or Base Pointer instead. When there
465 // are variable sized objects, we can't reference off of the SP, so we
466 // reserve a Base Pointer.
467 //
468 // For Thumb2, estimate whether a negative offset from the frame pointer
469 // will be sufficient to reach the whole stack frame. If a function has a
470 // smallish frame, it's less likely to have lots of spills and callee saved
471 // space, so it's all more likely to be within range of the frame pointer.
472 // If it's wrong, the scavenger will still enable access to work, it just
473 // won't be optimal. (We should always be able to reach the emergency
474 // spill slot from the frame pointer.)
475 if (AFI->isThumb2Function() && MFI.hasVarSizedObjects() &&
476 MFI.getLocalFrameSize() >= 128)
477 return true;
478 // For Thumb1, if sp moves, nothing is in range, so force a base pointer.
479 // This is necessary for correctness in cases where we need an emergency
480 // spill slot. (In Thumb1, we can't use a negative offset from the frame
481 // pointer.)
482 if (AFI->isThumb1OnlyFunction() && !TFI->hasReservedCallFrame(MF))
483 return true;
484 return false;
485}
486
488 const MachineRegisterInfo *MRI = &MF.getRegInfo();
489 const ARMFrameLowering *TFI = getFrameLowering(MF);
490 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
491 // We can't realign the stack if:
492 // 1. Dynamic stack realignment is explicitly disabled,
493 // 2. There are VLAs in the function and the base pointer is disabled.
495 return false;
496 // Stack realignment requires a frame pointer. If we already started
497 // register allocation with frame pointer elimination, it is too late now.
498 if (!MRI->canReserveReg(STI.getFramePointerReg()))
499 return false;
500 // We may also need a base pointer if there are dynamic allocas or stack
501 // pointer adjustments around calls.
502 if (TFI->hasReservedCallFrame(MF))
503 return true;
504 // A base pointer is required and allowed. Check that it isn't too late to
505 // reserve it.
506 return MRI->canReserveReg(BasePtr);
507}
508
510cannotEliminateFrame(const MachineFunction &MF) const {
511 const MachineFrameInfo &MFI = MF.getFrameInfo();
512 if (MF.disableFramePointerElim() && MFI.adjustsStack())
513 return true;
514 return MFI.hasVarSizedObjects() || MFI.isFrameAddressTaken() ||
515 hasStackRealignment(MF);
516}
517
520 const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
521 const ARMFrameLowering *TFI = getFrameLowering(MF);
522
523 if (TFI->hasFP(MF))
524 return STI.getFramePointerReg();
525 return ARM::SP;
526}
527
528unsigned
530 const auto &MFI = MF.getFrameInfo();
531 if (!MF.hasEHFunclets() && !MFI.hasVarSizedObjects())
532 return ARM::SP;
533 else if (MF.hasEHFunclets() || hasStackRealignment(MF))
534 return getBaseRegister();
535 return getFrameRegister(MF);
536}
537
538/// emitLoadConstPool - Emits a load from constpool to materialize the
539/// specified immediate.
542 const DebugLoc &dl, Register DestReg, unsigned SubIdx, int Val,
543 ARMCC::CondCodes Pred, Register PredReg, unsigned MIFlags) const {
544 MachineFunction &MF = *MBB.getParent();
547 const Constant *C =
548 ConstantInt::get(Type::getInt32Ty(MF.getFunction().getContext()), Val);
549 unsigned Idx = ConstantPool->getConstantPoolIndex(C, Align(4));
550
551 BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp))
552 .addReg(DestReg, getDefRegState(true), SubIdx)
554 .addImm(0)
555 .add(predOps(Pred, PredReg))
556 .setMIFlags(MIFlags);
557}
558
561 return true;
562}
563
566 return true;
567}
568
571 return true;
572}
573
575getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const {
576 const MCInstrDesc &Desc = MI->getDesc();
577 unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
578 int64_t InstrOffs = 0;
579 int Scale = 1;
580 unsigned ImmIdx = 0;
581 switch (AddrMode) {
587 InstrOffs = MI->getOperand(Idx+1).getImm();
588 Scale = 1;
589 break;
590 case ARMII::AddrMode5: {
591 // VFP address mode.
592 const MachineOperand &OffOp = MI->getOperand(Idx+1);
593 InstrOffs = ARM_AM::getAM5Offset(OffOp.getImm());
594 if (ARM_AM::getAM5Op(OffOp.getImm()) == ARM_AM::sub)
595 InstrOffs = -InstrOffs;
596 Scale = 4;
597 break;
598 }
599 case ARMII::AddrMode2:
600 ImmIdx = Idx+2;
601 InstrOffs = ARM_AM::getAM2Offset(MI->getOperand(ImmIdx).getImm());
602 if (ARM_AM::getAM2Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
603 InstrOffs = -InstrOffs;
604 break;
605 case ARMII::AddrMode3:
606 ImmIdx = Idx+2;
607 InstrOffs = ARM_AM::getAM3Offset(MI->getOperand(ImmIdx).getImm());
608 if (ARM_AM::getAM3Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
609 InstrOffs = -InstrOffs;
610 break;
612 ImmIdx = Idx+1;
613 InstrOffs = MI->getOperand(ImmIdx).getImm();
614 Scale = 4;
615 break;
616 default:
617 llvm_unreachable("Unsupported addressing mode!");
618 }
619
620 return InstrOffs * Scale;
621}
622
623/// needsFrameBaseReg - Returns true if the instruction's frame index
624/// reference would be better served by a base register other than FP
625/// or SP. Used by LocalStackFrameAllocation to determine which frame index
626/// references it should create new base registers for.
628needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const {
629 for (unsigned i = 0; !MI->getOperand(i).isFI(); ++i) {
630 assert(i < MI->getNumOperands() &&"Instr doesn't have FrameIndex operand!");
631 }
632
633 // It's the load/store FI references that cause issues, as it can be difficult
634 // to materialize the offset if it won't fit in the literal field. Estimate
635 // based on the size of the local frame and some conservative assumptions
636 // about the rest of the stack frame (note, this is pre-regalloc, so
637 // we don't know everything for certain yet) whether this offset is likely
638 // to be out of range of the immediate. Return true if so.
639
640 // We only generate virtual base registers for loads and stores, so
641 // return false for everything else.
642 unsigned Opc = MI->getOpcode();
643 switch (Opc) {
644 case ARM::LDRi12: case ARM::LDRH: case ARM::LDRBi12:
645 case ARM::STRi12: case ARM::STRH: case ARM::STRBi12:
646 case ARM::t2LDRi12: case ARM::t2LDRi8:
647 case ARM::t2STRi12: case ARM::t2STRi8:
648 case ARM::VLDRS: case ARM::VLDRD:
649 case ARM::VSTRS: case ARM::VSTRD:
650 case ARM::tSTRspi: case ARM::tLDRspi:
651 break;
652 default:
653 return false;
654 }
655
656 // Without a virtual base register, if the function has variable sized
657 // objects, all fixed-size local references will be via the frame pointer,
658 // Approximate the offset and see if it's legal for the instruction.
659 // Note that the incoming offset is based on the SP value at function entry,
660 // so it'll be negative.
661 MachineFunction &MF = *MI->getParent()->getParent();
662 const ARMFrameLowering *TFI = getFrameLowering(MF);
663 MachineFrameInfo &MFI = MF.getFrameInfo();
665
666 // Estimate an offset from the frame pointer.
667 // Conservatively assume all callee-saved registers get pushed. R4-R6
668 // will be earlier than the FP, so we ignore those.
669 // R7, LR
670 int64_t FPOffset = Offset - 8;
671 // ARM and Thumb2 functions also need to consider R8-R11 and D8-D15
672 if (!AFI->isThumbFunction() || !AFI->isThumb1OnlyFunction())
673 FPOffset -= 80;
674 // Estimate an offset from the stack pointer.
675 // The incoming offset is relating to the SP at the start of the function,
676 // but when we access the local it'll be relative to the SP after local
677 // allocation, so adjust our SP-relative offset by that allocation size.
678 Offset += MFI.getLocalFrameSize();
679 // Assume that we'll have at least some spill slots allocated.
680 // FIXME: This is a total SWAG number. We should run some statistics
681 // and pick a real one.
682 Offset += 128; // 128 bytes of spill slots
683
684 // If there's a frame pointer and the addressing mode allows it, try using it.
685 // The FP is only available if there is no dynamic realignment. We
686 // don't know for sure yet whether we'll need that, so we guess based
687 // on whether there are any local variables that would trigger it.
688 if (TFI->hasFP(MF) &&
689 !((MFI.getLocalFrameMaxAlign() > TFI->getStackAlign()) &&
690 canRealignStack(MF))) {
691 if (isFrameOffsetLegal(MI, getFrameRegister(MF), FPOffset))
692 return false;
693 }
694 // If we can reference via the stack pointer, try that.
695 // FIXME: This (and the code that resolves the references) can be improved
696 // to only disallow SP relative references in the live range of
697 // the VLA(s). In practice, it's unclear how much difference that
698 // would make, but it may be worth doing.
699 if (!MFI.hasVarSizedObjects() && isFrameOffsetLegal(MI, ARM::SP, Offset))
700 return false;
701
702 // The offset likely isn't legal, we want to allocate a virtual base register.
703 return true;
704}
705
706/// materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to
707/// be a pointer to FrameIdx at the beginning of the basic block.
710 int FrameIdx,
711 int64_t Offset) const {
712 ARMFunctionInfo *AFI = MBB->getParent()->getInfo<ARMFunctionInfo>();
713 unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri :
714 (AFI->isThumb1OnlyFunction() ? ARM::tADDframe : ARM::t2ADDri);
715
716 MachineBasicBlock::iterator Ins = MBB->begin();
717 DebugLoc DL; // Defaults to "unknown"
718 if (Ins != MBB->end())
719 DL = Ins->getDebugLoc();
720
721 const MachineFunction &MF = *MBB->getParent();
722 MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
724 const MCInstrDesc &MCID = TII.get(ADDriOpc);
725 Register BaseReg = MRI.createVirtualRegister(&ARM::GPRRegClass);
726 MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0));
727
728 MachineInstrBuilder MIB = BuildMI(*MBB, Ins, DL, MCID, BaseReg)
729 .addFrameIndex(FrameIdx).addImm(Offset);
730
731 if (!AFI->isThumb1OnlyFunction())
733
734 return BaseReg;
735}
736
738 int64_t Offset) const {
739 MachineBasicBlock &MBB = *MI.getParent();
740 MachineFunction &MF = *MBB.getParent();
741 const ARMBaseInstrInfo &TII =
742 *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
744 int Off = Offset; // ARM doesn't need the general 64-bit offsets
745 unsigned i = 0;
746
748 "This resolveFrameIndex does not support Thumb1!");
749
750 while (!MI.getOperand(i).isFI()) {
751 ++i;
752 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
753 }
754 bool Done = false;
755 if (!AFI->isThumbFunction())
756 Done = rewriteARMFrameIndex(MI, i, BaseReg, Off, TII);
757 else {
758 assert(AFI->isThumb2Function());
759 Done = rewriteT2FrameIndex(MI, i, BaseReg, Off, TII, this);
760 }
761 assert(Done && "Unable to resolve frame index!");
762 (void)Done;
763}
764
766 Register BaseReg,
767 int64_t Offset) const {
768 const MCInstrDesc &Desc = MI->getDesc();
769 unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
770 unsigned i = 0;
771 for (; !MI->getOperand(i).isFI(); ++i)
772 assert(i+1 < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!");
773
774 // AddrMode4 and AddrMode6 cannot handle any offset.
776 return Offset == 0;
777
778 unsigned NumBits = 0;
779 unsigned Scale = 1;
780 bool isSigned = true;
781 switch (AddrMode) {
786 // i8 supports only negative, and i12 supports only positive, so
787 // based on Offset sign, consider the appropriate instruction
788 Scale = 1;
789 if (Offset < 0) {
790 NumBits = 8;
791 Offset = -Offset;
792 } else {
793 NumBits = 12;
794 }
795 break;
796 case ARMII::AddrMode5:
797 // VFP address mode.
798 NumBits = 8;
799 Scale = 4;
800 break;
802 case ARMII::AddrMode2:
803 NumBits = 12;
804 break;
805 case ARMII::AddrMode3:
806 NumBits = 8;
807 break;
809 NumBits = (BaseReg == ARM::SP ? 8 : 5);
810 Scale = 4;
811 isSigned = false;
812 break;
813 default:
814 llvm_unreachable("Unsupported addressing mode!");
815 }
816
818 // Make sure the offset is encodable for instructions that scale the
819 // immediate.
820 if ((Offset & (Scale-1)) != 0)
821 return false;
822
823 if (isSigned && Offset < 0)
824 Offset = -Offset;
825
826 unsigned Mask = (1 << NumBits) - 1;
827 if ((unsigned)Offset <= Mask * Scale)
828 return true;
829
830 return false;
831}
832
833bool
835 int SPAdj, unsigned FIOperandNum,
836 RegScavenger *RS) const {
837 MachineInstr &MI = *II;
838 MachineBasicBlock &MBB = *MI.getParent();
839 MachineFunction &MF = *MBB.getParent();
840 const ARMBaseInstrInfo &TII =
841 *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
842 const ARMFrameLowering *TFI = getFrameLowering(MF);
845 "This eliminateFrameIndex does not support Thumb1!");
846 int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
847 Register FrameReg;
848
849 int Offset = TFI->ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
850
851 if (MI.getOpcode() == TargetOpcode::LOCAL_ESCAPE) {
852 MachineOperand &FI = MI.getOperand(FIOperandNum);
854 FI.ChangeToImmediate(Offset.getFixed());
855 return false;
856 }
857
858 // PEI::scavengeFrameVirtualRegs() cannot accurately track SPAdj because the
859 // call frame setup/destroy instructions have already been eliminated. That
860 // means the stack pointer cannot be used to access the emergency spill slot
861 // when !hasReservedCallFrame().
862#ifndef NDEBUG
863 if (RS && FrameReg == ARM::SP && RS->isScavengingFrameIndex(FrameIndex)){
864 assert(TFI->hasReservedCallFrame(MF) &&
865 "Cannot use SP to access the emergency spill slot in "
866 "functions without a reserved call frame");
868 "Cannot use SP to access the emergency spill slot in "
869 "functions with variable sized frame objects");
870 }
871#endif // NDEBUG
872
873 assert(!MI.isDebugValue() && "DBG_VALUEs should be handled in target-independent code");
874
875 // Modify MI as necessary to handle as much of 'Offset' as possible
876 bool Done = false;
877 if (!AFI->isThumbFunction())
878 Done = rewriteARMFrameIndex(MI, FIOperandNum, FrameReg, Offset, TII);
879 else {
880 assert(AFI->isThumb2Function());
881 Done = rewriteT2FrameIndex(MI, FIOperandNum, FrameReg, Offset, TII, this);
882 }
883 if (Done)
884 return false;
885
886 // If we get here, the immediate doesn't fit into the instruction. We folded
887 // as much as possible above, handle the rest, providing a register that is
888 // SP+LargeImm.
889 assert(
890 (Offset ||
891 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode4 ||
892 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode6 ||
893 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7 ||
894 (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7s2 ||
895 (MI.getDesc().TSFlags & ARMII::AddrModeMask) ==
897 "This code isn't needed if offset already handled!");
898
899 unsigned ScratchReg = 0;
900 int PIdx = MI.findFirstPredOperandIdx();
901 ARMCC::CondCodes Pred = (PIdx == -1)
902 ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImm();
903 Register PredReg = (PIdx == -1) ? Register() : MI.getOperand(PIdx+1).getReg();
904
905 const MCInstrDesc &MCID = MI.getDesc();
906 const TargetRegisterClass *RegClass = TII.getRegClass(MCID, FIOperandNum);
907
908 if (Offset == 0 && (FrameReg.isVirtual() || RegClass->contains(FrameReg)))
909 // Must be addrmode4/6.
910 MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false, false, false);
911 else {
912 ScratchReg = MF.getRegInfo().createVirtualRegister(RegClass);
913 if (!AFI->isThumbFunction())
914 emitARMRegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
915 Offset, Pred, PredReg, TII);
916 else {
917 assert(AFI->isThumb2Function());
918 emitT2RegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
919 Offset, Pred, PredReg, TII);
920 }
921 // Update the original instruction to use the scratch register.
922 MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false, false,true);
923 }
924 return false;
925}
926
928 const TargetRegisterClass *SrcRC,
929 unsigned SubReg,
930 const TargetRegisterClass *DstRC,
931 unsigned DstSubReg,
932 const TargetRegisterClass *NewRC,
933 LiveIntervals &LIS) const {
934 auto MBB = MI->getParent();
935 auto MF = MBB->getParent();
936 const MachineRegisterInfo &MRI = MF->getRegInfo();
937 // If not copying into a sub-register this should be ok because we shouldn't
938 // need to split the reg.
939 if (!DstSubReg)
940 return true;
941 // Small registers don't frequently cause a problem, so we can coalesce them.
942 if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
943 getRegSizeInBits(*SrcRC) < 256)
944 return true;
945
946 auto NewRCWeight =
948 auto SrcRCWeight =
950 auto DstRCWeight =
952 // If the source register class is more expensive than the destination, the
953 // coalescing is probably profitable.
954 if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
955 return true;
956 if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
957 return true;
958
959 // If the register allocator isn't constrained, we can always allow coalescing
960 // unfortunately we don't know yet if we will be constrained.
961 // The goal of this heuristic is to restrict how many expensive registers
962 // we allow to coalesce in a given basic block.
963 auto AFI = MF->getInfo<ARMFunctionInfo>();
964 auto It = AFI->getCoalescedWeight(MBB);
965
966 LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: "
967 << It->second << "\n");
968 LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: "
969 << NewRCWeight.RegWeight << "\n");
970
971 // This number is the largest round number that which meets the criteria:
972 // (1) addresses PR18825
973 // (2) generates better code in some test cases (like vldm-shed-a9.ll)
974 // (3) Doesn't regress any test cases (in-tree, test-suite, and SPEC)
975 // In practice the SizeMultiplier will only factor in for straight line code
976 // that uses a lot of NEON vectors, which isn't terribly common.
977 unsigned SizeMultiplier = MBB->size()/100;
978 SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
979 if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
980 It->second += NewRCWeight.RegWeight;
981 return true;
982 }
983 return false;
984}
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
const TargetRegisterClass * getPointerRegClass(unsigned Kind=0) 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.
LLVM_ABI 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:309
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:1947
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