LLVM 22.0.0git
PPCRegisterInfo.h
Go to the documentation of this file.
1//===-- PPCRegisterInfo.h - PowerPC 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 PowerPC implementation of the TargetRegisterInfo
10// class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_POWERPC_PPCREGISTERINFO_H
15#define LLVM_LIB_TARGET_POWERPC_PPCREGISTERINFO_H
16
18#include "llvm/ADT/DenseMap.h"
19
20#define GET_REGINFO_HEADER
21#include "PPCGenRegisterInfo.inc"
22
23namespace llvm {
24class PPCTargetMachine;
25
26inline static unsigned getCRFromCRBit(unsigned SrcReg) {
27 unsigned Reg = 0;
28 if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR0GT ||
29 SrcReg == PPC::CR0EQ || SrcReg == PPC::CR0UN)
30 Reg = PPC::CR0;
31 else if (SrcReg == PPC::CR1LT || SrcReg == PPC::CR1GT ||
32 SrcReg == PPC::CR1EQ || SrcReg == PPC::CR1UN)
33 Reg = PPC::CR1;
34 else if (SrcReg == PPC::CR2LT || SrcReg == PPC::CR2GT ||
35 SrcReg == PPC::CR2EQ || SrcReg == PPC::CR2UN)
36 Reg = PPC::CR2;
37 else if (SrcReg == PPC::CR3LT || SrcReg == PPC::CR3GT ||
38 SrcReg == PPC::CR3EQ || SrcReg == PPC::CR3UN)
39 Reg = PPC::CR3;
40 else if (SrcReg == PPC::CR4LT || SrcReg == PPC::CR4GT ||
41 SrcReg == PPC::CR4EQ || SrcReg == PPC::CR4UN)
42 Reg = PPC::CR4;
43 else if (SrcReg == PPC::CR5LT || SrcReg == PPC::CR5GT ||
44 SrcReg == PPC::CR5EQ || SrcReg == PPC::CR5UN)
45 Reg = PPC::CR5;
46 else if (SrcReg == PPC::CR6LT || SrcReg == PPC::CR6GT ||
47 SrcReg == PPC::CR6EQ || SrcReg == PPC::CR6UN)
48 Reg = PPC::CR6;
49 else if (SrcReg == PPC::CR7LT || SrcReg == PPC::CR7GT ||
50 SrcReg == PPC::CR7EQ || SrcReg == PPC::CR7UN)
51 Reg = PPC::CR7;
52
53 assert(Reg != 0 && "Invalid CR bit register");
54 return Reg;
55}
56
59 const PPCTargetMachine &TM;
60
63 unsigned FrameIndex, bool IsLittleEndian, bool IsKilled,
64 Register Reg, int Offset) const;
65
66public:
68
69 /// getMappedIdxOpcForImmOpc - Return the mapped index form load/store opcode
70 /// for a given imm form load/store opcode \p ImmFormOpcode.
71 /// FIXME: move this to PPCInstrInfo class.
72 unsigned getMappedIdxOpcForImmOpc(unsigned ImmOpcode) const {
73 auto It = ImmToIdxMap.find(ImmOpcode);
74 if (It == ImmToIdxMap.end())
75 return PPC::INSTRUCTION_LIST_END;
76 return It->second;
77 }
78
79 /// getPointerRegClass - Return the register class to use to hold pointers.
80 /// This is used for addressing modes.
82 getPointerRegClass(unsigned Kind = 0) const override;
83
85 getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
86
88 MachineFunction &MF) const override;
89
92 const MachineFunction &MF) const override;
93
94 /// Code Generation virtual methods...
95 const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
97 CallingConv::ID CC) const override;
98 const uint32_t *getNoPreservedMask() const override;
99
100 void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
101
102 BitVector getReservedRegs(const MachineFunction &MF) const override;
103 bool isAsmClobberable(const MachineFunction &MF,
104 MCRegister PhysReg) const override;
106 const MachineFunction &MF) const override;
107
108 // Provide hints to the register allocator for allocating subregisters
109 // of primed and unprimed accumulators. For example, if accumulator
110 // ACC5 is assigned, we also want to assign UACC5 to the input.
111 // Similarly if UACC5 is assigned, we want to assign VSRp10, VSRp11
112 // to its inputs.
115 const MachineFunction &MF, const VirtRegMap *VRM,
116 const LiveRegMatrix *Matrix) const override;
117
118 /// We require the register scavenger.
119 bool requiresRegisterScavenging(const MachineFunction &MF) const override {
120 return true;
121 }
122
123 bool requiresFrameIndexScavenging(const MachineFunction &MF) const override;
124
125 bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override;
126
130 Register &NegSizeReg, bool &KillNegSizeReg,
131 Register &FramePointer) const;
134 unsigned FrameIndex) const;
136 unsigned FrameIndex) const;
138 unsigned FrameIndex) const;
140 unsigned FrameIndex) const;
141
143 unsigned FrameIndex) const;
145 unsigned FrameIndex) const;
147 unsigned FrameIndex) const;
148
150 unsigned FrameIndex) const;
152 unsigned FrameIndex) const;
153
155 unsigned FrameIndex) const;
157 unsigned FrameIndex) const;
158
160 unsigned FrameIndex) const;
162 unsigned FrameIndex) const;
163
164 static void emitAccCopyInfo(MachineBasicBlock &MBB, MCRegister DestReg,
165 MCRegister SrcReg);
166
168 int &FrameIdx) const override;
170 unsigned FIOperandNum,
171 RegScavenger *RS = nullptr) const override;
172
173 // Support for virtual base registers.
174 bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
176 int64_t Offset) const override;
178 int64_t Offset) const override;
179 bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg,
180 int64_t Offset) const override;
181
182 // Debug information queries.
183 Register getFrameRegister(const MachineFunction &MF) const override;
184
185 // Base pointer (stack realignment) support.
187 bool hasBasePointer(const MachineFunction &MF) const;
188
190 return Reg == PPC::LR || Reg == PPC::LR8;
191 }
192
193 bool isVirtualFrameRegister(MCRegister Reg) const override {
194 return Reg == PPC::FP || Reg == PPC::FP8;
195 }
196};
197
198} // end namespace llvm
199
200#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseMap class.
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
Live Register Matrix
Register Reg
uint64_t IntrinsicInst * II
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
A debug info location.
Definition DebugLoc.h:124
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
bool isNonallocatableRegisterCalleeSave(MCRegister Reg) const override
void resolveFrameIndex(MachineInstr &MI, Register BaseReg, int64_t Offset) const override
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
Register getFrameRegister(const MachineFunction &MF) const override
bool hasBasePointer(const MachineFunction &MF) const
Register getBaseRegister(const MachineFunction &MF) const
void lowerDMRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerDMRRestore - Generate the code to restore the DMR register.
void prepareDynamicAlloca(MachineBasicBlock::iterator II, Register &NegSizeReg, bool &KillNegSizeReg, Register &FramePointer) const
To accomplish dynamic stack allocation, we have to calculate exact size subtracted from the stack poi...
unsigned getMappedIdxOpcForImmOpc(unsigned ImmOpcode) const
getMappedIdxOpcForImmOpc - Return the mapped index form load/store opcode for a given imm form load/s...
void lowerCRBitSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
void lowerACCSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerACCSpilling - Generate the code for spilling the accumulator register.
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
void lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerCRSpilling - Generate the code for spilling a CR register.
const TargetRegisterClass * getPointerRegClass(unsigned Kind=0) const override
getPointerRegClass - Return the register class to use to hold pointers.
void lowerDynamicAreaOffset(MachineBasicBlock::iterator II) const
void lowerDynamicAlloc(MachineBasicBlock::iterator II) const
lowerDynamicAlloc - Generate the code for allocating an object in the current frame.
bool requiresRegisterScavenging(const MachineFunction &MF) const override
We require the register scavenger.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
bool hasReservedSpillSlot(const MachineFunction &MF, Register Reg, int &FrameIdx) const override
bool isCallerPreservedPhysReg(MCRegister PhysReg, const MachineFunction &MF) const override
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
Returns true if the instruction's frame index reference would be better served by a base register oth...
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
const uint32_t * getNoPreservedMask() const override
void lowerDMRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerDMRSpilling - Generate the code for spilling the DMR register.
void lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
void lowerQuadwordRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerQuadwordRestore - Generate code to restore paired general register.
static void emitAccCopyInfo(MachineBasicBlock &MBB, MCRegister DestReg, MCRegister SrcReg)
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
void lowerCRBitRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx, int64_t Offset) const override
Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx at the beginning of the basic ...
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
void lowerWACCRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerWACCRestore - Generate the code to restore the wide accumulator register.
void lowerPrepareProbedAlloca(MachineBasicBlock::iterator II) const
void lowerQuadwordSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerQuadwordSpilling - Generate code to spill paired general register.
PPCRegisterInfo(const PPCTargetMachine &TM)
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg, int64_t Offset) const override
void lowerWACCSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerWACCSpilling - Generate the code for spilling the wide accumulator register.
void lowerOctWordSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
Remove any STXVP[X] instructions and split them out into a pair of STXV[X] instructions if –disable-a...
bool isAsmClobberable(const MachineFunction &MF, MCRegister PhysReg) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
void lowerACCRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerACCRestore - Generate the code to restore the accumulator register.
bool isVirtualFrameRegister(MCRegister Reg) const override
Common code between 32-bit and 64-bit PowerPC targets.
Wrapper class representing virtual and physical registers.
Definition Register.h:19
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
TargetInstrInfo - Interface to description of machine instruction set.
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:477
static unsigned getCRFromCRBit(unsigned SrcReg)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21