21 #define GET_REGINFO_TARGET_DESC 22 #include "SystemZGenRegisterInfo.inc" 34 if (SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
37 return &SystemZ::GR32BitRegClass;
38 if (SystemZ::GRH32BitRegClass.hasSubClassEq(RC) ||
41 return &SystemZ::GRH32BitRegClass;
45 if (SystemZ::GR32BitRegClass.
contains(PhysReg))
46 return &SystemZ::GR32BitRegClass;
48 "Phys reg not in GR32 or GRH32?");
49 return &SystemZ::GRH32BitRegClass;
52 assert (RC == &SystemZ::GRX32BitRegClass);
88 VirtReg, Order, Hints, MF, VRM, Matrix);
98 if (VirtReg ==
Use.getOperand(0).getReg()) {
99 VRRegMO = &
Use.getOperand(0);
100 OtherMO = &
Use.getOperand(1);
101 if (
Use.isCommutable())
102 CommuMO = &
Use.getOperand(2);
103 }
else if (VirtReg ==
Use.getOperand(1).getReg()) {
104 VRRegMO = &
Use.getOperand(1);
105 OtherMO = &
Use.getOperand(0);
106 }
else if (VirtReg ==
Use.getOperand(2).getReg() &&
107 Use.isCommutable()) {
108 VRRegMO = &
Use.getOperand(2);
109 OtherMO = &
Use.getOperand(0);
119 PhysReg = getSubReg(PhysReg, MO->getSubReg());
121 PhysReg = getMatchingSuperReg(PhysReg, VRRegMO->
getSubReg(),
124 TwoAddrHints.
insert(PhysReg);
132 if (TwoAddrHints.
count(OrderReg))
136 if (MRI->
getRegClass(VirtReg) == &SystemZ::GRX32BitRegClass) {
140 while (Worklist.
size()) {
142 if (!DoneRegs.
insert(Reg).second)
150 if (
Use.getOpcode() == SystemZ::LOCRMux ||
151 Use.getOpcode() == SystemZ::SELRMux) {
155 TRI->getCommonSubClass(
getRC32(FalseMO, VRM, MRI),
157 if (
Use.getOpcode() == SystemZ::SELRMux)
158 RC = TRI->getCommonSubClass(RC,
160 if (RC && RC != &SystemZ::GRX32BitRegClass) {
171 if (MRI->
getRegClass(OtherReg) == &SystemZ::GRX32BitRegClass)
174 else if (
Use.getOpcode() == SystemZ::CHIMux ||
175 Use.getOpcode() == SystemZ::CFIMux) {
176 if (
Use.getOperand(1).getImm() == 0) {
177 bool OnlyLMuxes =
true;
179 if (
DefMI.getOpcode() != SystemZ::LMux)
182 addHints(Order, Hints, &SystemZ::GR32BitRegClass, MRI);
192 return BaseImplRetVal;
199 return CSR_SystemZ_NoRegs_SaveList;
201 return Subtarget.
hasVector()? CSR_SystemZ_AllRegs_Vector_SaveList
202 : CSR_SystemZ_AllRegs_SaveList;
205 Attribute::SwiftError))
206 return CSR_SystemZ_SwiftError_SaveList;
207 return CSR_SystemZ_SaveList;
215 return CSR_SystemZ_NoRegs_RegMask;
217 return Subtarget.
hasVector()? CSR_SystemZ_AllRegs_Vector_RegMask
218 : CSR_SystemZ_AllRegs_RegMask;
221 Attribute::SwiftError))
222 return CSR_SystemZ_SwiftError_RegMask;
223 return CSR_SystemZ_RegMask;
231 if (TFI->
hasFP(MF)) {
233 Reserved.
set(SystemZ::R11D);
234 Reserved.
set(SystemZ::R11L);
235 Reserved.
set(SystemZ::R11H);
236 Reserved.
set(SystemZ::R10Q);
240 Reserved.
set(SystemZ::R15D);
241 Reserved.
set(SystemZ::R15L);
242 Reserved.
set(SystemZ::R15H);
243 Reserved.
set(SystemZ::R14Q);
246 Reserved.
set(SystemZ::A0);
247 Reserved.
set(SystemZ::A1);
250 Reserved.
set(SystemZ::FPC);
257 int SPAdj,
unsigned FIOperandNum,
259 assert(SPAdj == 0 &&
"Outgoing arguments should be part of the frame");
269 int FrameIndex = MI->getOperand(FIOperandNum).getIndex();
272 MI->getOperand(FIOperandNum + 1).getImm());
275 if (MI->isDebugValue()) {
276 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
277 MI->getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
283 unsigned Opcode = MI->getOpcode();
284 unsigned OpcodeForOffset =
TII->getOpcodeForOffset(Opcode, Offset);
285 if (OpcodeForOffset) {
289 OpcodeForOffset = SystemZ::LDE32;
291 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
296 int64_t OldOffset =
Offset;
297 int64_t
Mask = 0xffff;
299 Offset = OldOffset &
Mask;
300 OpcodeForOffset =
TII->getOpcodeForOffset(Opcode, Offset);
302 assert(Mask &&
"One offset must be OK");
303 }
while (!OpcodeForOffset);
307 int64_t HighOffset = OldOffset -
Offset;
310 && MI->getOperand(FIOperandNum + 2).getReg() == 0) {
313 TII->loadImmediate(MBB, MI, ScratchReg, HighOffset);
314 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
315 MI->getOperand(FIOperandNum + 2).ChangeToRegister(ScratchReg,
319 unsigned LAOpcode =
TII->getOpcodeForOffset(SystemZ::LA, HighOffset);
321 BuildMI(MBB, MI, DL,
TII->get(LAOpcode),ScratchReg)
326 TII->loadImmediate(MBB, MI, ScratchReg, HighOffset);
327 BuildMI(MBB, MI, DL,
TII->get(SystemZ::AGR),ScratchReg)
332 MI->getOperand(FIOperandNum).ChangeToRegister(ScratchReg,
336 MI->setDesc(
TII->get(OpcodeForOffset));
337 MI->getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
347 assert (MI->
isCopy() &&
"Only expecting COPY instructions");
351 (getRegSizeInBits(*SrcRC) <= 64 || getRegSizeInBits(*DstRC) <= 64)))
358 unsigned WideOpNo = (getRegSizeInBits(*SrcRC) == 128 ? 1 : 0);
372 if ((!FirstMI_GR128 || FirstMI_GR128->
getParent() != MBB) ||
373 (!FirstMI_GRNar || FirstMI_GRNar->
getParent() != MBB) ||
374 (!LastMI_GR128 || LastMI_GR128->
getParent() != MBB) ||
375 (!LastMI_GRNar || LastMI_GRNar->
getParent() != MBB))
391 for (; MII != MEE; ++MII) {
397 PhysClobbered.
set(*
SI);
404 unsigned const DemandedFreeGR128 = 3;
414 return TFI->
hasFP(MF) ? SystemZ::R11D : SystemZ::R15D;
419 if (RC == &SystemZ::CCRRegClass)
420 return &SystemZ::GR32BitRegClass;
virtual bool getRegAllocationHints(unsigned 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...
iterator_range< reg_instr_nodbg_iterator > reg_nodbg_instructions(unsigned Reg) const
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
This class represents lattice values for constants.
unsigned getNumRegs() const
Return the number of registers in this class.
BitVector getReservedRegs(const MachineFunction &MF) const override
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
LiveInterval - This class represents the liveness of a register, or stack slot.
unsigned getSubReg() const
virtual const TargetLowering * getTargetLowering() const
static void addHints(ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const TargetRegisterClass *RC, const MachineRegisterInfo *MRI)
unsigned const TargetRegisterInfo * TRI
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
return AArch64::GPR64RegClass contains(Reg)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
bool getRegAllocationHints(unsigned VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const override
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
MCSuperRegIterator enumerates all super-registers of Reg.
const HexagonInstrInfo * TII
A Use represents the edge between a Value definition and its users.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
AttributeList getAttributes() const
Return the attribute list for this Function.
virtual const TargetInstrInfo * getInstrInfo() const
int getTwoOperandOpcode(uint16_t Opcode)
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
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.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
SlotIndex endIndex() const
endNumber - return the maximum point of the range of the whole, exclusive.
unsigned const MachineRegisterInfo * MRI
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
LiveInterval & getInterval(Register Reg)
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static const TargetRegisterClass * getRC32(MachineOperand &MO, const VirtRegMap *VRM, const MachineRegisterInfo *MRI)
size_type count() const
count - Returns the number of bits which are set.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
MachineOperand class - Representation of each machine instruction operand.
MachineInstrBuilder MachineInstrBuilder & DefMI
LLVM_NODISCARD T pop_back_val()
const Function & getFunction() const
Return the LLVM function that this machine code represents.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Register getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
iterator_range< reg_instr_iterator > reg_instructions(unsigned Reg) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
iterator_range< def_instr_iterator > def_instructions(unsigned Reg) const
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const SystemZRegisterInfo * getRegisterInfo() const override
Wrapper class representing virtual and physical registers.
Register getFrameRegister(const MachineFunction &MF) const override
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.