22#define GET_TARGET_REGBANK_IMPL
23#include "RISCVGenRegisterBank.inc"
134bool RISCVRegisterBankInfo::hasFPConstraints(
142 if (
MI.getOpcode() != TargetOpcode::COPY)
151 switch (
MI.getOpcode()) {
152 case RISCV::G_FCVT_W_RV64:
153 case RISCV::G_FCVT_WU_RV64:
154 case RISCV::G_FCLASS:
155 case TargetOpcode::G_FPTOSI:
156 case TargetOpcode::G_FPTOUI:
157 case TargetOpcode::G_FCMP:
163 return hasFPConstraints(
MI,
MRI,
TRI);
169 switch (
MI.getOpcode()) {
170 case TargetOpcode::G_SITOFP:
171 case TargetOpcode::G_UITOFP:
177 return hasFPConstraints(
MI,
MRI,
TRI);
180bool RISCVRegisterBankInfo::anyUseOnlyUseFP(
184 MRI.use_nodbg_instructions(Def),
193 else if (
Size == 128)
195 else if (
Size == 256)
197 else if (
Size == 512)
207 const unsigned Opc =
MI.getOpcode();
223 assert((GPRSize == 32 || GPRSize == 64) &&
"Unexpected GPR size");
225 unsigned NumOperands =
MI.getNumOperands();
231 case TargetOpcode::G_ADD:
232 case TargetOpcode::G_SUB:
233 case TargetOpcode::G_SHL:
234 case TargetOpcode::G_ASHR:
235 case TargetOpcode::G_LSHR:
236 case TargetOpcode::G_AND:
237 case TargetOpcode::G_OR:
238 case TargetOpcode::G_XOR:
239 case TargetOpcode::G_MUL:
240 case TargetOpcode::G_SDIV:
241 case TargetOpcode::G_SREM:
242 case TargetOpcode::G_SMULH:
243 case TargetOpcode::G_SMAX:
244 case TargetOpcode::G_SMIN:
245 case TargetOpcode::G_UDIV:
246 case TargetOpcode::G_UREM:
247 case TargetOpcode::G_UMULH:
248 case TargetOpcode::G_UMAX:
249 case TargetOpcode::G_UMIN:
250 case TargetOpcode::G_PTR_ADD:
251 case TargetOpcode::G_PTRTOINT:
252 case TargetOpcode::G_INTTOPTR:
253 case TargetOpcode::G_FADD:
254 case TargetOpcode::G_FSUB:
255 case TargetOpcode::G_FMUL:
256 case TargetOpcode::G_FDIV:
257 case TargetOpcode::G_FABS:
258 case TargetOpcode::G_FNEG:
259 case TargetOpcode::G_FSQRT:
260 case TargetOpcode::G_FMAXNUM:
261 case TargetOpcode::G_FMINNUM: {
262 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
271 Mapping = GPRValueMapping;
275 for (
unsigned Idx = 1;
Idx != NumOperands; ++
Idx) {
276 LLT OpTy =
MRI.getType(
MI.getOperand(
Idx).getReg());
278 "Operand has incompatible type");
287 case TargetOpcode::G_SEXTLOAD:
288 case TargetOpcode::G_ZEXTLOAD:
291 case TargetOpcode::G_IMPLICIT_DEF: {
293 LLT DstTy =
MRI.getType(Dst);
295 auto Mapping = GPRValueMapping;
303 else if (anyUseOnlyUseFP(Dst,
MRI,
TRI))
314 case TargetOpcode::G_LOAD: {
315 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
318 OpdsMapping[1] = GPRValueMapping;
325 OpdsMapping[0] = GPRValueMapping;
328 if (GPRSize == 32 &&
Size.getFixedValue() == 64) {
337 if (anyUseOnlyUseFP(
MI.getOperand(0).getReg(),
MRI,
TRI)) {
348 case TargetOpcode::G_STORE: {
349 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
352 OpdsMapping[1] = GPRValueMapping;
359 OpdsMapping[0] = GPRValueMapping;
362 if (GPRSize == 32 &&
Size.getFixedValue() == 64) {
373 case TargetOpcode::G_SELECT: {
374 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
377 auto &Sel = cast<GSelect>(
MI);
378 LLT TestTy =
MRI.getType(Sel.getCondReg());
379 assert(TestTy.
isVector() &&
"Unexpected condition argument type");
380 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] =
402 if (
any_of(
MRI.use_nodbg_instructions(
MI.getOperand(0).getReg()),
404 return onlyUsesFP(UseMI, MRI, TRI);
431 OpdsMapping[1] = GPRValueMapping;
437 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] = Mapping;
440 case RISCV::G_FCVT_W_RV64:
441 case RISCV::G_FCVT_WU_RV64:
442 case TargetOpcode::G_FPTOSI:
443 case TargetOpcode::G_FPTOUI:
444 case RISCV::G_FCLASS: {
445 LLT Ty =
MRI.getType(
MI.getOperand(1).getReg());
446 OpdsMapping[0] = GPRValueMapping;
450 case TargetOpcode::G_SITOFP:
451 case TargetOpcode::G_UITOFP: {
452 LLT Ty =
MRI.getType(
MI.getOperand(0).getReg());
454 OpdsMapping[1] = GPRValueMapping;
457 case TargetOpcode::G_FCMP: {
458 LLT Ty =
MRI.getType(
MI.getOperand(2).getReg());
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;
488 case TargetOpcode::G_SPLAT_VECTOR: {
491 .getKnownMinValue());
493 LLT ScalarTy =
MRI.getType(
MI.getOperand(1).getReg());
500 OpdsMapping[1] = GPRValueMapping;
505 for (
unsigned Idx = 0;
Idx < NumOperands; ++
Idx) {
506 auto &MO =
MI.getOperand(
Idx);
507 if (!MO.isReg() || !MO.getReg())
509 LLT Ty =
MRI.getType(MO.getReg());
519 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 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.
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.
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.