20#define DEBUG_TYPE "ppc-reg-bank-info"
22#define GET_TARGET_REGBANK_IMPL
23#include "PPCGenRegisterBank.inc"
26#include "PPCGenRegisterBankInfo.def"
36 case PPC::VSFRCRegClassID:
37 case PPC::SPILLTOVSRRC_and_VSFRCRegClassID:
38 case PPC::SPILLTOVSRRC_and_VFRCRegClassID:
39 case PPC::SPILLTOVSRRC_and_F4RCRegClassID:
40 case PPC::F8RCRegClassID:
41 case PPC::VFRCRegClassID:
42 case PPC::VSSRCRegClassID:
43 case PPC::F4RCRegClassID:
52 const unsigned Opc =
MI.getOpcode();
68 unsigned NumOperands =
MI.getNumOperands();
75 case TargetOpcode::G_ADD:
76 case TargetOpcode::G_SUB:
78 case TargetOpcode::G_AND:
79 case TargetOpcode::G_OR:
80 case TargetOpcode::G_XOR:
82 case TargetOpcode::G_SEXT:
83 case TargetOpcode::G_ZEXT:
84 case TargetOpcode::G_ANYEXT: {
86 "This code is for instructions with 3 or less operands");
87 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
99 case TargetOpcode::G_FADD:
100 case TargetOpcode::G_FSUB:
101 case TargetOpcode::G_FMUL:
102 case TargetOpcode::G_FDIV: {
107 "Unsupported floating point types!\n");
121 case TargetOpcode::G_FCMP: {
122 unsigned CmpSize =
MRI.getType(
MI.getOperand(2).getReg()).getSizeInBits();
130 case TargetOpcode::G_CONSTANT:
133 case TargetOpcode::G_CONSTANT_POOL:
136 case TargetOpcode::G_FPTOUI:
137 case TargetOpcode::G_FPTOSI: {
146 case TargetOpcode::G_UITOFP:
147 case TargetOpcode::G_SITOFP: {
156 case TargetOpcode::G_LOAD: {
159 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
168 return onlyUsesFP(UseMI, MRI, TRI);
179 case TargetOpcode::G_STORE: {
193 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS: {
200 case TargetOpcode::G_BITCAST: {
201 LLT DstTy =
MRI.getType(
MI.getOperand(0).getReg());
202 LLT SrcTy =
MRI.getType(
MI.getOperand(1).getReg());
210 const RegisterBank &DstRB = DstIsGPR ? PPC::GPRRegBank : PPC::VECRegBank;
211 const RegisterBank &SrcRB = SrcIsGPR ? PPC::GPRRegBank : PPC::VECRegBank;
235 unsigned Depth)
const {
236 unsigned Op =
MI.getOpcode();
238 if (
auto *GI = dyn_cast<GIntrinsic>(&
MI)) {
249 if (
Op != TargetOpcode::COPY && !
MI.isPHI() &&
255 if (RB == &PPC::FPRRegBank)
257 if (RB == &PPC::GPRRegBank)
264 if (!
MI.isPHI() ||
Depth > MaxFPRSearchDepth)
269 onlyDefinesFP(*MRI.getVRegDef(Op.getReg()), MRI, TRI, Depth + 1);
278 unsigned Depth)
const {
279 switch (
MI.getOpcode()) {
280 case TargetOpcode::G_FPTOSI:
281 case TargetOpcode::G_FPTOUI:
282 case TargetOpcode::G_FCMP:
283 case TargetOpcode::G_LROUND:
284 case TargetOpcode::G_LLROUND:
297 unsigned Depth)
const {
298 switch (
MI.getOpcode()) {
299 case TargetOpcode::G_SITOFP:
300 case TargetOpcode::G_UITOFP:
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool isFPIntrinsic(const MachineRegisterInfo &MRI, const MachineInstr &MI)
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
unsigned const TargetRegisterInfo * TRI
This file declares the targeting of the RegisterBankInfo class for PowerPC.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an Operation in the Expression.
constexpr bool isVector() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
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.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static const RegisterBankInfo::ValueMapping * getCopyMapping(unsigned DstBankID, unsigned SrcBankID, unsigned Size)
Get the pointer to the ValueMapping of the operands of a copy instruction from the SrcBankID register...
static const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx RBIdx)
Get the pointer to the ValueMapping representing the RegisterBank at RBIdx.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const override
Get a register bank that covers RC.
PPCRegisterBankInfo(const TargetRegisterInfo &TRI)
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
bool isValid() const
Check whether this object is valid.
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
TypeSize getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
virtual const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const
Get a register bank that covers RC.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End.
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
This class implements the register bank concept.
unsigned getID() const
Get the identifier of this register bank.
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned getID() const
Return the register class ID number.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
This is an optimization pass for GlobalISel generic memory operations.
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel.
bool isPreISelGenericOptimizationHint(unsigned Opcode)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
bool isPreISelGenericFloatingPointOpcode(unsigned Opc)
Returns whether opcode Opc is a pre-isel generic floating-point opcode, having only floating-point op...
Helper struct that represents how a value is mapped through different register banks.