LLVM 24.0.0git
ARMBaseRegisterInfo.h
Go to the documentation of this file.
1//===-- ARMBaseRegisterInfo.h - ARM Register Information Impl ---*- C++ -*-===//
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#ifndef LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H
14#define LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H
15
20#include "llvm/IR/CallingConv.h"
22#include <cstdint>
23
24#define GET_REGINFO_HEADER
25#include "ARMGenRegisterInfo.inc"
26
27namespace llvm {
28
29class LiveIntervals;
30
31/// Register allocation hints.
32namespace ARMRI {
33
34 enum {
35 // Used for LDRD register pairs
38 // Used to hint for lr in t2DoLoopStart
40 };
41
42} // end namespace ARMRI
43
45 const MCPhysReg *CSRegs) {
46 for (unsigned i = 0; CSRegs[i]; ++i)
47 if (Reg == CSRegs[i])
48 return true;
49 return false;
50}
51
53protected:
54 /// BasePtr - ARM physical register used as a base ptr in complex stack
55 /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
56 /// variable size stack objects.
57 unsigned BasePtr = ARM::R6;
58
59 // Can be only subclassed.
60 explicit ARMBaseRegisterInfo();
61
62public:
63 /// Code Generation virtual methods...
64 const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
65 const MCPhysReg *
68 CallingConv::ID) const override;
69 const uint32_t *getNoPreservedMask() const override;
70 const uint32_t *getTLSCallPreservedMask(const MachineFunction &MF) const;
72
73 /// getThisReturnPreservedMask - Returns a call preserved mask specific to the
74 /// case that 'returned' is on an i32 first argument if the calling convention
75 /// is one that can (partially) model this attribute with a preserved mask
76 /// (i.e. it is a calling convention that uses the same register for the first
77 /// i32 argument and an i32 return value)
78 ///
79 /// Should return NULL in the case that the calling convention does not have
80 /// this property
82 CallingConv::ID) const;
83
85 getIntraCallClobberedRegs(const MachineFunction *MF) const override;
86
87 BitVector getReservedRegs(const MachineFunction &MF) const override;
88 bool isAsmClobberable(const MachineFunction &MF,
89 MCRegister PhysReg) const override;
91 MCRegister PhysReg) const override;
92
94 getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
95
98 const MachineFunction &MF) const override;
99
100 unsigned getRegPressureLimit(const TargetRegisterClass *RC,
101 MachineFunction &MF) const override;
102
105 const MachineFunction &MF, const VirtRegMap *VRM,
106 const LiveRegMatrix *Matrix) const override;
107
109 MachineFunction &MF) const override;
110
111 bool hasBasePointer(const MachineFunction &MF) const;
112
113 bool canRealignStack(const MachineFunction &MF) const override;
115 int Idx) const override;
116 bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
118 int64_t Offset) const override;
120 int64_t Offset) const override;
121 bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg,
122 int64_t Offset) const override;
123
124 bool cannotEliminateFrame(const MachineFunction &MF) const;
125
126 // Debug information queries.
127 Register getFrameRegister(const MachineFunction &MF) const override;
128 unsigned getLocalAddressRegister(const MachineFunction &MF) const;
129 Register getBaseRegister() const { return BasePtr; }
130
131 /// emitLoadConstPool - Emits a load from constpool to materialize the
132 /// specified immediate.
133 virtual void
135 const DebugLoc &dl, Register DestReg, unsigned SubIdx,
136 int Val, ARMCC::CondCodes Pred = ARMCC::AL,
137 Register PredReg = Register(),
138 unsigned MIFlags = MachineInstr::NoFlags) const;
139
140 /// Code Generation virtual methods...
141 bool requiresRegisterScavenging(const MachineFunction &MF) const override;
142
143 bool requiresFrameIndexScavenging(const MachineFunction &MF) const override;
144
145 bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override;
146
148 int SPAdj, unsigned FIOperandNum,
149 RegScavenger *RS = nullptr) const override;
150
151 /// SrcRC and DstRC will be morphed into NewRC if this returns true
153 const TargetRegisterClass *SrcRC,
154 unsigned SubReg,
155 const TargetRegisterClass *DstRC,
156 unsigned DstSubReg,
157 const TargetRegisterClass *NewRC,
158 LiveIntervals &LIS) const override;
159
160 int getSEHRegNum(unsigned i) const { return getEncodingValue(i); }
161};
162
163} // end namespace llvm
164
165#endif // LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator MBBI
IRTranslator LLVM IR MI
Live Register Matrix
Register Reg
Promote Memory to Register
Definition Mem2Reg.cpp:110
uint64_t IntrinsicInst * II
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
unsigned getLocalAddressRegister(const MachineFunction &MF) const
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
int getSEHRegNum(unsigned i) const
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.
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallSetVector< MCPhysReg, 16 > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
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
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A debug info location.
Definition DebugLoc.h:126
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:345
Register allocation hints.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
static bool isCalleeSavedRegister(MCRegister Reg, const MCPhysReg *CSRegs)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58