21#define GET_TARGET_REGBANK_IMPL
22#include "RISCVGenRegisterBank.inc"
83 case RISCV::GPRRegClassID:
84 case RISCV::GPRF16RegClassID:
85 case RISCV::GPRF32RegClassID:
86 case RISCV::GPRNoX0RegClassID:
87 case RISCV::GPRNoX0X2RegClassID:
88 case RISCV::GPRJALRRegClassID:
89 case RISCV::GPRTCRegClassID:
90 case RISCV::GPRC_and_GPRTCRegClassID:
91 case RISCV::GPRCRegClassID:
92 case RISCV::GPRC_and_SR07RegClassID:
93 case RISCV::SR07RegClassID:
94 case RISCV::SPRegClassID:
95 case RISCV::GPRX0RegClassID:
97 case RISCV::FPR64RegClassID:
98 case RISCV::FPR16RegClassID:
99 case RISCV::FPR32RegClassID:
100 case RISCV::FPR64CRegClassID:
101 case RISCV::FPR32CRegClassID:
103 case RISCV::VMRegClassID:
104 case RISCV::VRRegClassID:
105 case RISCV::VRNoV0RegClassID:
106 case RISCV::VRM2RegClassID:
107 case RISCV::VRM2NoV0RegClassID:
108 case RISCV::VRM4RegClassID:
109 case RISCV::VRM4NoV0RegClassID:
110 case RISCV::VMV0RegClassID:
111 case RISCV::VRM2_with_sub_vrm1_0_in_VMV0RegClassID:
112 case RISCV::VRM4_with_sub_vrm1_0_in_VMV0RegClassID:
113 case RISCV::VRM8RegClassID:
114 case RISCV::VRM8NoV0RegClassID:
115 case RISCV::VRM8_with_sub_vrm1_0_in_VMV0RegClassID:
132 case TargetOpcode::G_FADD:
133 case TargetOpcode::G_FSUB:
134 case TargetOpcode::G_FMUL:
135 case TargetOpcode::G_FMA:
136 case TargetOpcode::G_FDIV:
137 case TargetOpcode::G_FCONSTANT:
138 case TargetOpcode::G_FPEXT:
139 case TargetOpcode::G_FPTRUNC:
140 case TargetOpcode::G_FCEIL:
141 case TargetOpcode::G_FFLOOR:
142 case TargetOpcode::G_FNEARBYINT:
143 case TargetOpcode::G_FNEG:
144 case TargetOpcode::G_FCOPYSIGN:
145 case TargetOpcode::G_FCOS:
146 case TargetOpcode::G_FSIN:
147 case TargetOpcode::G_FLOG10:
148 case TargetOpcode::G_FLOG:
149 case TargetOpcode::G_FLOG2:
150 case TargetOpcode::G_FSQRT:
151 case TargetOpcode::G_FABS:
152 case TargetOpcode::G_FEXP:
153 case TargetOpcode::G_FRINT:
154 case TargetOpcode::G_INTRINSIC_TRUNC:
155 case TargetOpcode::G_INTRINSIC_ROUND:
156 case TargetOpcode::G_INTRINSIC_ROUNDEVEN:
157 case TargetOpcode::G_FMAXNUM:
158 case TargetOpcode::G_FMINNUM:
159 case TargetOpcode::G_FMAXIMUM:
160 case TargetOpcode::G_FMINIMUM:
167bool RISCVRegisterBankInfo::hasFPConstraints(
175 if (
MI.getOpcode() != TargetOpcode::COPY)
184 switch (
MI.getOpcode()) {
185 case TargetOpcode::G_FPTOSI:
186 case TargetOpcode::G_FPTOUI:
187 case TargetOpcode::G_FCMP:
193 return hasFPConstraints(
MI,
MRI,
TRI);
199 switch (
MI.getOpcode()) {
200 case TargetOpcode::G_SITOFP:
201 case TargetOpcode::G_UITOFP:
207 return hasFPConstraints(
MI,
MRI,
TRI);
210bool RISCVRegisterBankInfo::anyUseOnlyUseFP(
214 MRI.use_nodbg_instructions(Def),
220 const unsigned Opc =
MI.getOpcode();
236 assert((GPRSize == 32 || GPRSize == 64) &&
"Unexpected GPR size");
238 unsigned NumOperands =
MI.getNumOperands();
244 case TargetOpcode::G_ADD:
245 case TargetOpcode::G_SUB:
246 case TargetOpcode::G_SHL:
247 case TargetOpcode::G_ASHR:
248 case TargetOpcode::G_LSHR:
249 case TargetOpcode::G_AND:
250 case TargetOpcode::G_OR:
251 case TargetOpcode::G_XOR:
252 case TargetOpcode::G_MUL:
253 case TargetOpcode::G_SDIV:
254 case TargetOpcode::G_SREM:
255 case TargetOpcode::G_SMULH:
256 case TargetOpcode::G_SMAX:
257 case TargetOpcode::G_SMIN:
258 case TargetOpcode::G_UDIV:
259 case TargetOpcode::G_UREM:
260 case TargetOpcode::G_UMULH:
261 case TargetOpcode::G_UMAX:
262 case TargetOpcode::G_UMIN:
263 case TargetOpcode::G_PTR_ADD:
264 case TargetOpcode::G_PTRTOINT:
265 case TargetOpcode::G_INTTOPTR:
266 case TargetOpcode::G_TRUNC:
267 case TargetOpcode::G_ANYEXT:
268 case TargetOpcode::G_SEXT:
269 case TargetOpcode::G_ZEXT:
270 case TargetOpcode::G_SEXTLOAD:
271 case TargetOpcode::G_ZEXTLOAD:
274 case TargetOpcode::G_FADD:
275 case TargetOpcode::G_FSUB:
276 case TargetOpcode::G_FMUL:
277 case TargetOpcode::G_FDIV:
278 case TargetOpcode::G_FABS:
279 case TargetOpcode::G_FNEG:
280 case TargetOpcode::G_FSQRT:
281 case TargetOpcode::G_FMAXNUM:
282 case TargetOpcode::G_FMINNUM: {
283 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
288 case TargetOpcode::G_IMPLICIT_DEF: {
290 auto Mapping = GPRValueMapping;
296 if (anyUseOnlyUseFP(Dst,
MRI,
TRI))
306 case TargetOpcode::G_LOAD: {
307 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
308 OpdsMapping[0] = GPRValueMapping;
309 OpdsMapping[1] = GPRValueMapping;
320 if (anyUseOnlyUseFP(
MI.getOperand(0).getReg(),
MRI,
TRI))
329 case TargetOpcode::G_STORE: {
330 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
331 OpdsMapping[0] = GPRValueMapping;
332 OpdsMapping[1] = GPRValueMapping;
345 case TargetOpcode::G_SELECT: {
346 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
363 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
365 return onlyUsesFP(UseMI, MRI, TRI);
392 OpdsMapping[1] = GPRValueMapping;
398 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] = Mapping;
401 case TargetOpcode::G_FPTOSI:
402 case TargetOpcode::G_FPTOUI:
403 case RISCV::G_FCLASS: {
404 LLT Ty =
MRI.getType(
MI.getOperand(1).getReg());
405 OpdsMapping[0] = GPRValueMapping;
409 case TargetOpcode::G_SITOFP:
410 case TargetOpcode::G_UITOFP: {
411 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
413 OpdsMapping[1] = GPRValueMapping;
416 case TargetOpcode::G_FCMP: {
417 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
420 assert((
Size == 32 ||
Size == 64) &&
"Unsupported size for G_FCMP");
422 OpdsMapping[0] = GPRValueMapping;
426 case TargetOpcode::G_MERGE_VALUES: {
428 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
432 OpdsMapping[1] = GPRValueMapping;
433 OpdsMapping[2] = GPRValueMapping;
437 case TargetOpcode::G_UNMERGE_VALUES: {
439 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
442 OpdsMapping[0] = GPRValueMapping;
443 OpdsMapping[1] = GPRValueMapping;
450 for (
unsigned Idx = 0;
Idx < NumOperands; ++
Idx) {
451 auto &MO =
MI.getOperand(
Idx);
452 if (!MO.isReg() || !MO.getReg())
454 LLT Ty =
MRI.getType(MO.getReg());
461 OpdsMapping[
Idx] = GPRValueMapping;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool isPreISelGenericFloatingPointOpcode(unsigned Opc)
Returns whether opcode Opc is a pre-isel generic floating-point opcode, having only floating-point op...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
unsigned const TargetRegisterInfo * TRI
static const RegisterBankInfo::ValueMapping * getFPValueMapping(unsigned Size)
This file declares the targeting of the RegisterBankInfo class for RISC-V.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr bool isValid() 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.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
RISCVRegisterBankInfo(unsigned HwMode)
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const override
Get a register bank that covers RC.
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.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
const RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
unsigned getMaximumSize(unsigned RegBankID) const
Get the maximum size in bits that fits in the given register bank.
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.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const RegisterBankInfo::PartialMapping PartMappings[]
const RegisterBankInfo::ValueMapping ValueMappings[]
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 any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Helper struct that represents how a value is partially mapped into a register.
Helper struct that represents how a value is mapped through different register banks.