22#define GET_REGINFO_TARGET_DESC
23#include "SystemZGenRegisterInfo.inc"
32 if (SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
35 return &SystemZ::GR32BitRegClass;
36 if (SystemZ::GRH32BitRegClass.hasSubClassEq(RC) ||
39 return &SystemZ::GRH32BitRegClass;
43 if (SystemZ::GR32BitRegClass.
contains(PhysReg))
44 return &SystemZ::GR32BitRegClass;
46 "Phys reg not in GR32 or GRH32?");
47 return &SystemZ::GRH32BitRegClass;
50 assert (RC == &SystemZ::GRX32BitRegClass);
65 if (CopyHints.
count(Reg) &&
69 if (!CopyHints.
count(Reg) &&
83 VirtReg, Order, Hints, MF, VRM,
Matrix);
88 for (
auto &
Use :
MRI->reg_nodbg_instructions(VirtReg))
93 if (VirtReg ==
Use.getOperand(0).getReg()) {
94 VRRegMO = &
Use.getOperand(0);
95 OtherMO = &
Use.getOperand(1);
96 if (
Use.isCommutable())
97 CommuMO = &
Use.getOperand(2);
98 }
else if (VirtReg ==
Use.getOperand(1).getReg()) {
99 VRRegMO = &
Use.getOperand(1);
100 OtherMO = &
Use.getOperand(0);
101 }
else if (VirtReg ==
Use.getOperand(2).getReg() &&
102 Use.isCommutable()) {
103 VRRegMO = &
Use.getOperand(2);
104 OtherMO = &
Use.getOperand(0);
114 PhysReg = getSubReg(PhysReg, MO->getSubReg());
116 PhysReg = getMatchingSuperReg(PhysReg, VRRegMO->
getSubReg(),
117 MRI->getRegClass(VirtReg));
119 TwoAddrHints.
insert(PhysReg);
127 if (TwoAddrHints.
count(OrderReg))
131 if (
MRI->getRegClass(VirtReg) == &SystemZ::GRX32BitRegClass) {
135 while (Worklist.
size()) {
137 if (!DoneRegs.
insert(Reg).second)
140 for (
auto &
Use :
MRI->reg_instructions(Reg)) {
145 if (
Use.getOpcode() == SystemZ::LOCRMux ||
146 Use.getOpcode() == SystemZ::SELRMux) {
152 if (
Use.getOpcode() == SystemZ::SELRMux)
153 RC =
TRI->getCommonSubClass(RC,
155 if (RC && RC != &SystemZ::GRX32BitRegClass) {
166 if (
MRI->getRegClass(OtherReg) == &SystemZ::GRX32BitRegClass)
169 else if (
Use.getOpcode() == SystemZ::CHIMux ||
170 Use.getOpcode() == SystemZ::CFIMux) {
171 if (
Use.getOperand(1).getImm() == 0) {
172 bool OnlyLMuxes =
true;
174 if (
DefMI.getOpcode() != SystemZ::LMux)
177 addHints(Order, Hints, &SystemZ::GR32BitRegClass,
MRI);
187 return BaseImplRetVal;
193 return Subtarget.hasVector() ? CSR_SystemZ_XPLINK64_Vector_SaveList
194 : CSR_SystemZ_XPLINK64_SaveList;
201 return CSR_SystemZ_NoRegs_SaveList;
203 return Subtarget.hasVector()? CSR_SystemZ_AllRegs_Vector_SaveList
204 : CSR_SystemZ_AllRegs_SaveList;
207 Attribute::SwiftError))
208 return CSR_SystemZ_SwiftError_SaveList;
209 return CSR_SystemZ_ELF_SaveList;
216 return Subtarget.hasVector() ? CSR_SystemZ_XPLINK64_Vector_RegMask
217 : CSR_SystemZ_XPLINK64_RegMask;
225 return CSR_SystemZ_NoRegs_RegMask;
227 return Subtarget.hasVector()? CSR_SystemZ_AllRegs_Vector_RegMask
228 : CSR_SystemZ_AllRegs_RegMask;
231 Attribute::SwiftError))
232 return CSR_SystemZ_SwiftError_RegMask;
233 return CSR_SystemZ_ELF_RegMask;
286 int SPAdj,
unsigned FIOperandNum,
288 assert(SPAdj == 0 &&
"Outgoing arguments should be part of the frame");
297 int FrameIndex =
MI->getOperand(FIOperandNum).getIndex();
301 MI->getOperand(FIOperandNum + 1).getImm());
304 if (
MI->isDebugValue()) {
305 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
306 if (
MI->isNonListDebugValue()) {
307 MI->getDebugOffset().ChangeToImmediate(
Offset);
309 unsigned OpIdx =
MI->getDebugOperandIndex(&
MI->getOperand(FIOperandNum));
313 MI->getDebugExpressionOp().setMetadata(
321 unsigned Opcode =
MI->getOpcode();
322 unsigned OpcodeForOffset =
TII->getOpcodeForOffset(Opcode,
Offset, &*
MI);
323 if (OpcodeForOffset) {
324 if (OpcodeForOffset == SystemZ::LE &&
327 OpcodeForOffset = SystemZ::LDE32;
329 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
334 int64_t OldOffset =
Offset;
335 int64_t Mask = 0xffff;
337 Offset = OldOffset & Mask;
338 OpcodeForOffset =
TII->getOpcodeForOffset(Opcode,
Offset);
340 assert(Mask &&
"One offset must be OK");
341 }
while (!OpcodeForOffset);
345 int64_t HighOffset = OldOffset -
Offset;
348 &&
MI->getOperand(FIOperandNum + 2).getReg() == 0) {
351 TII->loadImmediate(
MBB,
MI, ScratchReg, HighOffset);
352 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
353 MI->getOperand(FIOperandNum + 2).ChangeToRegister(ScratchReg,
357 unsigned LAOpcode =
TII->getOpcodeForOffset(SystemZ::LA, HighOffset);
364 TII->loadImmediate(
MBB,
MI, ScratchReg, HighOffset);
370 MI->getOperand(FIOperandNum).ChangeToRegister(ScratchReg,
374 MI->setDesc(
TII->get(OpcodeForOffset));
375 MI->getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset);
386 assert (
MI->isCopy() &&
"Only expecting COPY instructions");
390 (getRegSizeInBits(*SrcRC) <= 64 || getRegSizeInBits(*DstRC) <= 64) &&
391 !
MI->getOperand(1).isUndef()))
397 unsigned SubregOpIdx = getRegSizeInBits(*SrcRC) == 128 ? 0 : 1;
415 if (MO.isReg() && MO.getReg().isPhysical()) {
416 for (
MCPhysReg SI : superregs_inclusive(MO.getReg()))
418 PhysClobbered.
set(SI);
424 unsigned const DemandedFreeGR128 = 3;
437 return TFI->
hasFP(MF) ? Regs->getFramePointerRegister()
438 : Regs->getStackPointerRegister();
443 if (RC == &SystemZ::CCRRegClass)
444 return &SystemZ::GR32BitRegClass;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder MachineInstrBuilder & DefMI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI optimize exec mask operations pre RA
This file defines the SmallSet class.
static const TargetRegisterClass * getRC32(MachineOperand &MO, const VirtRegMap *VRM, const MachineRegisterInfo *MRI)
static void addHints(ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const TargetRegisterClass *RC, const MachineRegisterInfo *MRI)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
size_type count() const
count - Returns the number of bits which are set.
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
static DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
AttributeList getAttributes() const
Return the attribute list for this Function.
LiveInterval - This class represents the liveness of a register, or stack slot.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
LiveInterval & getInterval(Register Reg)
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
SlotIndex endIndex() const
endNumber - return the maximum point of the range of the whole, exclusive.
MCRegAliasIterator enumerates all registers aliasing Reg.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Wrapper class representing virtual and physical registers.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static StackOffset getFixed(int64_t Fixed)
A SystemZ-specific class detailing special use registers particular for calling conventions.
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const =0
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const final
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const final
SystemZCallingConventionRegisters * getSpecialRegisters() const
const SystemZRegisterInfo * getRegisterInfo() const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const final
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const final
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
unsigned getNumRegs() const
Return the number of registers in this class.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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 TargetLowering * getTargetLowering() const
A Use represents the edge between a Value definition and its users.
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
self_iterator getIterator()
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ Kill
The last use of a register.
int getTwoOperandOpcode(uint16_t Opcode)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
SystemZRegisterInfo(unsigned int RA)
Register getFrameRegister(const MachineFunction &MF) 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.
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...