21 #define GET_TARGET_REGBANK_IMPL 23 #include "MipsGenRegisterBank.inc" 85 case Mips::GPR32RegClassID:
86 case Mips::CPU16Regs_and_GPRMM16ZeroRegClassID:
87 case Mips::GPRMM16MovePPairFirstRegClassID:
88 case Mips::CPU16Regs_and_GPRMM16MovePPairSecondRegClassID:
89 case Mips::GPRMM16MoveP_and_CPU16Regs_and_GPRMM16ZeroRegClassID:
90 case Mips::GPRMM16MovePPairFirst_and_GPRMM16MovePPairSecondRegClassID:
91 case Mips::SP32RegClassID:
92 case Mips::GP32RegClassID:
94 case Mips::FGRCCRegClassID:
95 case Mips::FGR32RegClassID:
96 case Mips::FGR64RegClassID:
97 case Mips::AFGR64RegClassID:
98 case Mips::MSA128BRegClassID:
99 case Mips::MSA128HRegClassID:
100 case Mips::MSA128WRegClassID:
101 case Mips::MSA128DRegClassID:
111 case TargetOpcode::G_FCONSTANT:
112 case TargetOpcode::G_FADD:
113 case TargetOpcode::G_FSUB:
114 case TargetOpcode::G_FMUL:
115 case TargetOpcode::G_FDIV:
116 case TargetOpcode::G_FABS:
117 case TargetOpcode::G_FSQRT:
118 case TargetOpcode::G_FCEIL:
119 case TargetOpcode::G_FFLOOR:
120 case TargetOpcode::G_FPEXT:
121 case TargetOpcode::G_FPTRUNC:
132 case TargetOpcode::G_FPTOSI:
133 case TargetOpcode::G_FPTOUI:
134 case TargetOpcode::G_FCMP:
137 case Mips::ExtractElementF64_64:
148 case TargetOpcode::G_SITOFP:
149 case TargetOpcode::G_UITOFP:
152 case Mips::BuildPairF64_64:
161 case TargetOpcode::G_LOAD:
162 case TargetOpcode::G_STORE:
163 case TargetOpcode::G_PHI:
164 case TargetOpcode::G_SELECT:
165 case TargetOpcode::G_IMPLICIT_DEF:
172 void MipsRegisterBankInfo::AmbiguousRegDefUseContainer::addDefUses(
175 "Pointers are gprb, they should not be considered as ambiguous.\n");
179 if (NonCopyInstr->
getOpcode() == TargetOpcode::COPY &&
183 DefUses.push_back(skipCopiesOutgoing(&
UseMI));
187 void MipsRegisterBankInfo::AmbiguousRegDefUseContainer::addUseDef(
190 "Pointers are gprb, they should not be considered as ambiguous.\n");
192 UseDefs.push_back(skipCopiesIncoming(DefMI));
196 MipsRegisterBankInfo::AmbiguousRegDefUseContainer::skipCopiesOutgoing(
201 while (Ret->
getOpcode() == TargetOpcode::COPY &&
210 MipsRegisterBankInfo::AmbiguousRegDefUseContainer::skipCopiesIncoming(
215 while (Ret->
getOpcode() == TargetOpcode::COPY &&
221 MipsRegisterBankInfo::AmbiguousRegDefUseContainer::AmbiguousRegDefUseContainer(
224 "Not implemented for non Ambiguous opcode.\n");
228 if (MI->
getOpcode() == TargetOpcode::G_LOAD)
231 if (MI->
getOpcode() == TargetOpcode::G_STORE)
234 if (MI->
getOpcode() == TargetOpcode::G_PHI) {
241 if (MI->
getOpcode() == TargetOpcode::G_SELECT) {
248 if (MI->
getOpcode() == TargetOpcode::G_IMPLICIT_DEF)
252 bool MipsRegisterBankInfo::TypeInfoForMF::visit(
259 AmbiguousRegDefUseContainer DefUseContainer(MI);
262 if (visitAdjacentInstrs(MI, DefUseContainer.getDefUses(),
true))
266 if (visitAdjacentInstrs(MI, DefUseContainer.getUseDefs(),
false))
270 if (!WaitingForTypeOfMI) {
272 setTypes(MI, InstType::Ambiguous);
283 addToWaitingQueue(WaitingForTypeOfMI, MI);
287 bool MipsRegisterBankInfo::TypeInfoForMF::visitAdjacentInstrs(
290 while (!AdjacentInstrs.
empty()) {
295 setTypes(MI, InstType::FloatingPoint);
301 if (AdjMI->
getOpcode() == TargetOpcode::COPY) {
302 setTypesAccordingToPhysicalRegister(MI, AdjMI, isDefUse ? 0 : 1);
315 if (!wasVisited(AdjMI) ||
316 getRecordedTypeForInstr(AdjMI) != InstType::NotDetermined) {
317 if (visit(AdjMI, MI)) {
319 setTypes(MI, getRecordedTypeForInstr(AdjMI));
327 void MipsRegisterBankInfo::TypeInfoForMF::setTypes(
const MachineInstr *MI,
329 changeRecordedTypeForInstr(MI, InstTy);
330 for (
const MachineInstr *WaitingInstr : getWaitingQueueFor(MI)) {
331 setTypes(WaitingInstr, InstTy);
335 void MipsRegisterBankInfo::TypeInfoForMF::setTypesAccordingToPhysicalRegister(
338 "Copies of non physical registers should not be considered here.\n");
348 if (Bank == &Mips::FPRBRegBank)
349 setTypes(MI, InstType::FloatingPoint);
350 else if (Bank == &Mips::GPRBRegBank)
356 MipsRegisterBankInfo::InstType
357 MipsRegisterBankInfo::TypeInfoForMF::determineInstType(
const MachineInstr *MI) {
359 return getRecordedTypeForInstr(MI);
362 void MipsRegisterBankInfo::TypeInfoForMF::cleanupIfNewFunction(
364 if (MFName != FunctionName) {
365 MFName = FunctionName;
366 WaitingQueues.clear();
371 static const MipsRegisterBankInfo::ValueMapping *
374 "MSA mapping not available on target without MSA.");
387 static const MipsRegisterBankInfo::ValueMapping *
399 static TypeInfoForMF TI;
408 if (MI.
getOpcode() != TargetOpcode::G_PHI) {
415 using namespace TargetOpcode;
471 if (Op0Size == 128) {
478 InstTy = TI.determineInstType(&MI);
480 if (InstTy == InstType::FloatingPoint ||
481 (Op0Size == 64 && InstTy == InstType::Ambiguous))
492 InstTy = TI.determineInstType(&MI);
506 InstTy = TI.determineInstType(&MI);
508 if (InstTy == InstType::FloatingPoint ||
509 (Op0Size == 64 && InstTy == InstType::Ambiguous)) {
524 InstTy = TI.determineInstType(&MI);
526 if (InstTy == InstType::FloatingPoint)
532 case G_UNMERGE_VALUES:
573 assert((Op0Size == 32) &&
"Unsupported integer size");
581 "Unsupported integer size");
618 InstManager(
InstListTy &Insts) : InstList(Insts) {}
631 case TargetOpcode::G_STORE:
634 case TargetOpcode::G_CONSTANT:
635 case TargetOpcode::G_LOAD:
636 case TargetOpcode::G_SELECT:
637 case TargetOpcode::G_PHI:
638 case TargetOpcode::G_IMPLICIT_DEF: {
643 case TargetOpcode::G_PTR_ADD: {
660 DeadMI->eraseFromParent();
672 InstManager NewInstrObserver(NewInstrs);
678 case TargetOpcode::G_LOAD:
679 case TargetOpcode::G_STORE:
680 case TargetOpcode::G_PHI:
681 case TargetOpcode::G_SELECT:
682 case TargetOpcode::G_IMPLICIT_DEF: {
685 while (!NewInstrs.
empty()) {
690 if (NewMI->
getOpcode() == TargetOpcode::G_UNMERGE_VALUES)
694 else if (NewMI->
getOpcode() == TargetOpcode::G_MERGE_VALUES)
702 case TargetOpcode::G_UNMERGE_VALUES:
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End...
void setRegBank(MachineInstr &MI, MachineRegisterInfo &MRI) const
RegBankSelect determined that s64 operand is better to be split into two s32 operands in gprb...
static const MipsRegisterBankInfo::ValueMapping * getGprbOrCustomMapping(unsigned Size, unsigned &MappingID)
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
This class represents lattice values for constants.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
RegisterBankInfo::ValueMapping ValueMappings[]
unsigned getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
MachineRegisterInfo & getMRI() const
The MachineRegisterInfo we used to realize the mapping.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
static const MipsRegisterBankInfo::ValueMapping * getMSAMapping(const MachineFunction &MF)
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
unsigned const TargetRegisterInfo * TRI
void setRegBank(unsigned Reg, const RegisterBank &RegBank)
Set the register bank to RegBank for Reg.
iterator_range< mop_iterator > operands()
static const unsigned CustomMappingID
static bool isFloatingPointOpcodeUse(unsigned Opc)
static bool isFloatingPointOpcode(unsigned Opc)
Holds all the information related to register banks.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT) const override
Get a register bank that covers RC.
unsigned getNumOperands() const
Retuns the total number of operands.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
static bool isFloatingPointOpcodeDef(unsigned Opc)
unsigned getID() const
Return the register class ID number.
static bool isAmbiguous(unsigned Opc)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
This file declares the targeting of the RegisterBankInfo class for Mips.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
virtual const LegalizerInfo * getLegalizerInfo() const
Abstract class that contains various methods for clients to notify about changes. ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstrBuilder & UseMI
Helper struct that represents how a value is partially mapped into a register.
Helper class to build MachineInstr.
use_instr_iterator use_instr_begin(unsigned RegNo) const
RegisterBankInfo::PartialMapping PartMappings[]
void applyMappingImpl(const OperandsMapper &OpdMapper) const override
Here we have to narrowScalar s64 operands to s32, combine away G_MERGE or G_UNMERGE and erase instruc...
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static const MipsRegisterBankInfo::ValueMapping * getFprbMapping(unsigned Size)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isValid() const
Check whether this object is valid.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static void applyDefaultMapping(const OperandsMapper &OpdMapper)
Helper method to apply something that is like the default mapping.
MachineInstr & getMI() const
MachineInstrBuilder MachineInstrBuilder & DefMI
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
LLVM_NODISCARD T pop_back_val()
MachineInstr * pop_back_val()
void insert(MachineInstr *I)
Add the specified instruction to the worklist if it isn't already in it.
This class implements the register bank concept.
Helper struct that represents how a value is mapped through different register banks.
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.
bool hasOneUse(unsigned RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
bool tryCombineMerges(MachineInstr &MI, SmallVectorImpl< MachineInstr *> &DeadInsts, SmallVectorImpl< Register > &UpdatedDefs)
iterator_range< use_instr_iterator > use_instructions(unsigned Reg) const
LegalizeResult narrowScalar(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize an instruction by reducing the width of the underlying scalar type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MipsRegisterBankInfo(const TargetRegisterInfo &TRI)
static void combineAwayG_UNMERGE_VALUES(LegalizationArtifactCombiner &ArtCombiner, MachineInstr &MI)
StringRef - Represent a constant reference to a string, i.e.
Simple wrapper observer that takes several observers, and calls each one for each event...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Wrapper class representing virtual and physical registers.