22#define GET_TARGET_REGBANK_IMPL
23#include "RISCVGenRegisterBank.inc"
111 switch (RC.
getID()) {
114 case RISCV::GPRRegClassID:
115 case RISCV::GPRF16RegClassID:
116 case RISCV::GPRF32RegClassID:
117 case RISCV::GPRNoX0RegClassID:
118 case RISCV::GPRNoX0X2RegClassID:
119 case RISCV::GPRJALRRegClassID:
120 case RISCV::GPRTCRegClassID:
121 case RISCV::GPRC_and_GPRTCRegClassID:
122 case RISCV::GPRCRegClassID:
123 case RISCV::GPRC_and_SR07RegClassID:
124 case RISCV::SR07RegClassID:
125 case RISCV::SPRegClassID:
126 case RISCV::GPRX0RegClassID:
128 case RISCV::FPR64RegClassID:
129 case RISCV::FPR16RegClassID:
130 case RISCV::FPR32RegClassID:
131 case RISCV::FPR64CRegClassID:
132 case RISCV::FPR32CRegClassID:
134 case RISCV::VMRegClassID:
135 case RISCV::VRRegClassID:
136 case RISCV::VRNoV0RegClassID:
137 case RISCV::VRM2RegClassID:
138 case RISCV::VRM2NoV0RegClassID:
139 case RISCV::VRM4RegClassID:
140 case RISCV::VRM4NoV0RegClassID:
141 case RISCV::VMV0RegClassID:
142 case RISCV::VRM2_with_sub_vrm1_0_in_VMV0RegClassID:
143 case RISCV::VRM4_with_sub_vrm1_0_in_VMV0RegClassID:
144 case RISCV::VRM8RegClassID:
145 case RISCV::VRM8NoV0RegClassID:
146 case RISCV::VRM8_with_sub_vrm1_0_in_VMV0RegClassID:
158bool RISCVRegisterBankInfo::hasFPConstraints(
166 if (
MI.getOpcode() != TargetOpcode::COPY)
175 switch (
MI.getOpcode()) {
176 case TargetOpcode::G_FPTOSI:
177 case TargetOpcode::G_FPTOUI:
178 case TargetOpcode::G_FCMP:
184 return hasFPConstraints(
MI,
MRI,
TRI);
190 switch (
MI.getOpcode()) {
191 case TargetOpcode::G_SITOFP:
192 case TargetOpcode::G_UITOFP:
198 return hasFPConstraints(
MI,
MRI,
TRI);
201bool RISCVRegisterBankInfo::anyUseOnlyUseFP(
205 MRI.use_nodbg_instructions(Def),
214 else if (
Size == 128)
216 else if (
Size == 256)
218 else if (
Size == 512)
228 const unsigned Opc =
MI.getOpcode();
244 assert((GPRSize == 32 || GPRSize == 64) &&
"Unexpected GPR size");
246 unsigned NumOperands =
MI.getNumOperands();
252 case TargetOpcode::G_ADD:
253 case TargetOpcode::G_SUB:
254 case TargetOpcode::G_SHL:
255 case TargetOpcode::G_ASHR:
256 case TargetOpcode::G_LSHR:
257 case TargetOpcode::G_AND:
258 case TargetOpcode::G_OR:
259 case TargetOpcode::G_XOR:
260 case TargetOpcode::G_MUL:
261 case TargetOpcode::G_SDIV:
262 case TargetOpcode::G_SREM:
263 case TargetOpcode::G_SMULH:
264 case TargetOpcode::G_SMAX:
265 case TargetOpcode::G_SMIN:
266 case TargetOpcode::G_UDIV:
267 case TargetOpcode::G_UREM:
268 case TargetOpcode::G_UMULH:
269 case TargetOpcode::G_UMAX:
270 case TargetOpcode::G_UMIN:
271 case TargetOpcode::G_PTR_ADD:
272 case TargetOpcode::G_PTRTOINT:
273 case TargetOpcode::G_INTTOPTR:
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());
292 Mapping = GPRValueMapping;
296 for (
unsigned Idx = 1;
Idx != NumOperands; ++
Idx) {
297 LLT OpTy =
MRI.getType(
MI.getOperand(
Idx).getReg());
299 "Operand has incompatible type");
308 case TargetOpcode::G_SEXTLOAD:
309 case TargetOpcode::G_ZEXTLOAD:
312 case TargetOpcode::G_IMPLICIT_DEF: {
314 LLT DstTy =
MRI.getType(Dst);
316 auto Mapping = GPRValueMapping;
324 else if (anyUseOnlyUseFP(Dst,
MRI,
TRI))
335 case TargetOpcode::G_LOAD: {
336 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
337 OpdsMapping[0] = GPRValueMapping;
338 OpdsMapping[1] = GPRValueMapping;
349 if (anyUseOnlyUseFP(
MI.getOperand(0).getReg(),
MRI,
TRI))
358 case TargetOpcode::G_STORE: {
359 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
360 OpdsMapping[0] = GPRValueMapping;
361 OpdsMapping[1] = GPRValueMapping;
374 case TargetOpcode::G_SELECT: {
375 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
378 auto &Sel = cast<GSelect>(
MI);
379 LLT TestTy =
MRI.getType(Sel.getCondReg());
380 assert(TestTy.
isVector() &&
"Unexpected condition argument type");
381 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] =
403 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
405 return onlyUsesFP(UseMI, MRI, TRI);
432 OpdsMapping[1] = GPRValueMapping;
438 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] = Mapping;
441 case TargetOpcode::G_FPTOSI:
442 case TargetOpcode::G_FPTOUI:
443 case RISCV::G_FCLASS: {
444 LLT Ty =
MRI.getType(
MI.getOperand(1).getReg());
445 OpdsMapping[0] = GPRValueMapping;
449 case TargetOpcode::G_SITOFP:
450 case TargetOpcode::G_UITOFP: {
451 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
453 OpdsMapping[1] = GPRValueMapping;
456 case TargetOpcode::G_FCMP: {
457 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
460 assert((
Size == 32 ||
Size == 64) &&
"Unsupported size for G_FCMP");
462 OpdsMapping[0] = GPRValueMapping;
466 case TargetOpcode::G_MERGE_VALUES: {
468 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
472 OpdsMapping[1] = GPRValueMapping;
473 OpdsMapping[2] = GPRValueMapping;
477 case TargetOpcode::G_UNMERGE_VALUES: {
479 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
482 OpdsMapping[0] = GPRValueMapping;
483 OpdsMapping[1] = GPRValueMapping;
490 for (
unsigned Idx = 0;
Idx < NumOperands; ++
Idx) {
491 auto &MO =
MI.getOperand(
Idx);
492 if (!MO.isReg() || !MO.getReg())
494 LLT Ty =
MRI.getType(MO.getReg());
504 OpdsMapping[
Idx] = GPRValueMapping;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
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
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
unsigned const TargetRegisterInfo * TRI
static const RegisterBankInfo::ValueMapping * getFPValueMapping(unsigned Size)
static const RegisterBankInfo::ValueMapping * getVRBValueMapping(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 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.
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.
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#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.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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 partially mapped into a register.
Helper struct that represents how a value is mapped through different register banks.