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);
82 VirtReg, Order, Hints, MF, VRM,
Matrix);
87 for (
auto &
Use :
MRI->reg_nodbg_instructions(VirtReg))
92 if (VirtReg ==
Use.getOperand(0).getReg()) {
93 VRRegMO = &
Use.getOperand(0);
94 OtherMO = &
Use.getOperand(1);
95 if (
Use.isCommutable())
96 CommuMO = &
Use.getOperand(2);
97 }
else if (VirtReg ==
Use.getOperand(1).getReg()) {
98 VRRegMO = &
Use.getOperand(1);
99 OtherMO = &
Use.getOperand(0);
100 }
else if (VirtReg ==
Use.getOperand(2).getReg() &&
101 Use.isCommutable()) {
102 VRRegMO = &
Use.getOperand(2);
103 OtherMO = &
Use.getOperand(0);
113 PhysReg = getSubReg(PhysReg, MO->getSubReg());
115 PhysReg = getMatchingSuperReg(PhysReg, VRRegMO->
getSubReg(),
116 MRI->getRegClass(VirtReg));
118 TwoAddrHints.
insert(PhysReg);
126 if (TwoAddrHints.
count(OrderReg))
130 if (
MRI->getRegClass(VirtReg) == &SystemZ::GRX32BitRegClass) {
134 while (Worklist.
size()) {
136 if (!DoneRegs.
insert(Reg).second)
139 for (
auto &
Use :
MRI->reg_instructions(Reg)) {
144 if (
Use.getOpcode() == SystemZ::LOCRMux ||
145 Use.getOpcode() == SystemZ::SELRMux) {
151 if (
Use.getOpcode() == SystemZ::SELRMux)
152 RC =
TRI->getCommonSubClass(RC,
154 if (RC && RC != &SystemZ::GRX32BitRegClass) {
165 if (
MRI->getRegClass(OtherReg) == &SystemZ::GRX32BitRegClass)
168 else if (
Use.getOpcode() == SystemZ::CHIMux ||
169 Use.getOpcode() == SystemZ::CFIMux) {
170 if (
Use.getOperand(1).getImm() == 0) {
171 bool OnlyLMuxes =
true;
173 if (
DefMI.getOpcode() != SystemZ::LMux)
176 addHints(Order, Hints, &SystemZ::GR32BitRegClass,
MRI);
186 return BaseImplRetVal;
192 return Subtarget.hasVector() ? CSR_SystemZ_XPLINK64_Vector_SaveList
193 : CSR_SystemZ_XPLINK64_SaveList;
200 return CSR_SystemZ_NoRegs_SaveList;
202 return Subtarget.hasVector()? CSR_SystemZ_AllRegs_Vector_SaveList
203 : CSR_SystemZ_AllRegs_SaveList;
206 Attribute::SwiftError))
207 return CSR_SystemZ_SwiftError_SaveList;
208 return CSR_SystemZ_ELF_SaveList;
215 return Subtarget.hasVector() ? CSR_SystemZ_XPLINK64_Vector_RegMask
216 : CSR_SystemZ_XPLINK64_RegMask;
224 return CSR_SystemZ_NoRegs_RegMask;
226 return Subtarget.hasVector()? CSR_SystemZ_AllRegs_Vector_RegMask
227 : CSR_SystemZ_AllRegs_RegMask;
230 Attribute::SwiftError))
231 return CSR_SystemZ_SwiftError_RegMask;
232 return CSR_SystemZ_ELF_RegMask;
258 return CSR_SystemZ_NoRegs_RegMask;
290 int SPAdj,
unsigned FIOperandNum,
292 assert(SPAdj == 0 &&
"Outgoing arguments should be part of the frame");
301 int FrameIndex =
MI->getOperand(FIOperandNum).getIndex();
305 MI->getOperand(FIOperandNum + 1).getImm());
308 if (
MI->isDebugValue()) {
309 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
310 if (
MI->isNonListDebugValue()) {
311 MI->getDebugOffset().ChangeToImmediate(
Offset);
313 unsigned OpIdx =
MI->getDebugOperandIndex(&
MI->getOperand(FIOperandNum));
317 MI->getDebugExpressionOp().setMetadata(
325 unsigned Opcode =
MI->getOpcode();
326 unsigned OpcodeForOffset =
TII->getOpcodeForOffset(Opcode,
Offset, &*
MI);
327 if (OpcodeForOffset) {
328 if (OpcodeForOffset == SystemZ::LE &&
331 OpcodeForOffset = SystemZ::LDE32;
333 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
338 int64_t OldOffset =
Offset;
339 int64_t Mask = 0xffff;
341 Offset = OldOffset & Mask;
342 OpcodeForOffset =
TII->getOpcodeForOffset(Opcode,
Offset);
344 assert(Mask &&
"One offset must be OK");
345 }
while (!OpcodeForOffset);
349 int64_t HighOffset = OldOffset -
Offset;
352 &&
MI->getOperand(FIOperandNum + 2).getReg() == 0) {
355 TII->loadImmediate(
MBB,
MI, ScratchReg, HighOffset);
356 MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr,
false);
357 MI->getOperand(FIOperandNum + 2).ChangeToRegister(ScratchReg,
361 unsigned LAOpcode =
TII->getOpcodeForOffset(SystemZ::LA, HighOffset);
368 TII->loadImmediate(
MBB,
MI, ScratchReg, HighOffset);
374 MI->getOperand(FIOperandNum).ChangeToRegister(ScratchReg,
378 MI->setDesc(
TII->get(OpcodeForOffset));
379 MI->getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset);
390 assert (
MI->isCopy() &&
"Only expecting COPY instructions");
394 (getRegSizeInBits(*SrcRC) <= 64 || getRegSizeInBits(*DstRC) <= 64) &&
395 !
MI->getOperand(1).isUndef()))
401 unsigned SubregOpIdx = getRegSizeInBits(*SrcRC) == 128 ? 0 : 1;
419 if (MO.isReg() && MO.getReg().isPhysical()) {
420 for (
MCPhysReg SI : superregs_inclusive(MO.getReg()))
422 PhysClobbered.
set(
SI);
428 unsigned const DemandedFreeGR128 = 3;
441 return TFI->
hasFP(MF) ? Regs->getFramePointerRegister()
442 : Regs->getStackPointerRegister();
447 if (RC == &SystemZ::CCRRegClass)
448 return &SystemZ::GR32BitRegClass;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
MachineInstr unsigned OpIdx
SI optimize exec mask operations pre RA
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
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)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_type count() const
count - Returns the number of bits which are set.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
static LLVM_ABI 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.
MachineInstrBundleIterator< MachineInstr > iterator
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,...
LLVM_ABI 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.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
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
bool hasFP(const MachineFunction &MF) const
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()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ 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.
constexpr from_range_t from_range
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
const uint32_t * getNoPreservedMask() const override
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
SystemZRegisterInfo(unsigned int RA, unsigned int HwMode)
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
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...