LLVM 24.0.0git
RISCVRegisterBankInfo.cpp
Go to the documentation of this file.
1//===-- RISCVRegisterBankInfo.cpp -------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file implements the targeting of the RegisterBankInfo class for RISC-V.
10/// \todo This should be generated by TableGen.
11//===----------------------------------------------------------------------===//
12
15#include "RISCVSubtarget.h"
21#include "llvm/IR/IntrinsicsRISCV.h"
22
23#define GET_TARGET_REGBANK_IMPL
24#include "RISCVGenRegisterBank.inc"
25
26namespace llvm {
27namespace RISCV {
28
30 // clang-format off
31 {0, 32, GPRBRegBank},
32 {0, 64, GPRBRegBank},
33 {0, 16, FPRBRegBank},
34 {0, 32, FPRBRegBank},
35 {0, 64, FPRBRegBank},
36 {0, 64, VRBRegBank},
37 {0, 128, VRBRegBank},
38 {0, 256, VRBRegBank},
39 {0, 512, VRBRegBank},
40 // clang-format on
41};
42
54
56 // Invalid value mapping.
57 {nullptr, 0},
58 // Maximum 3 GPR operands; 32 bit.
62 // Maximum 3 GPR operands; 64 bit.
66 // Maximum 3 FPR operands; 16 bit.
70 // Maximum 3 FPR operands; 32 bit.
74 // Maximum 3 FPR operands; 64 bit.
78 // Maximum 3 VR LMUL={1, MF2, MF4, MF8} operands.
82 // Maximum 3 VR LMUL=2 operands.
86 // Maximum 3 VR LMUL=4 operands.
90 // Maximum 3 VR LMUL=8 operands.
94};
95
108} // namespace RISCV
109} // namespace llvm
110
111using namespace llvm;
112
115
116const RegisterBank &
118 LLT Ty) const {
119 switch (RC.getID()) {
120 // Vector control and status register class
121 case RISCV::VCSRRegClassID:
122 return getRegBank(RISCV::GPRBRegBankID);
123 default:
124 // For all GPR register classes and others, use the default implementation
126 }
127}
128
130 unsigned Idx;
131 switch (Size) {
132 default:
133 llvm_unreachable("Unexpected size");
134 case 16:
135 Idx = RISCV::FPRB16Idx;
136 break;
137 case 32:
138 Idx = RISCV::FPRB32Idx;
139 break;
140 case 64:
141 Idx = RISCV::FPRB64Idx;
142 break;
143 }
144 return &RISCV::ValueMappings[Idx];
145}
146
147// TODO: Make this more like AArch64?
148bool RISCVRegisterBankInfo::hasFPConstraints(
149 const MachineInstr &MI, const MachineRegisterInfo &MRI,
150 const TargetRegisterInfo &TRI) const {
152 return true;
153
154 // If we have a copy instruction, we could be feeding floating point
155 // instructions.
156 if (MI.getOpcode() != TargetOpcode::COPY)
157 return false;
158
159 return getRegBank(MI.getOperand(0).getReg(), MRI, TRI) == &RISCV::FPRBRegBank;
160}
161
162bool RISCVRegisterBankInfo::onlyUsesFP(const MachineInstr &MI,
164 const TargetRegisterInfo &TRI) const {
165 switch (MI.getOpcode()) {
166 case RISCV::G_FCVT_W_RV64:
167 case RISCV::G_FCVT_WU_RV64:
168 case RISCV::G_FCVT_X:
169 case RISCV::G_FCVT_XU:
170 case RISCV::G_FCLASS:
171 case TargetOpcode::G_FPTOSI:
172 case TargetOpcode::G_FPTOUI:
173 case TargetOpcode::G_LROUND:
174 case TargetOpcode::G_LLROUND:
175 case TargetOpcode::G_INTRINSIC_LRINT:
176 case TargetOpcode::G_INTRINSIC_LLRINT:
177 case TargetOpcode::G_FCMP:
178 return true;
179 default:
180 break;
181 }
182
183 return hasFPConstraints(MI, MRI, TRI);
184}
185
186bool RISCVRegisterBankInfo::onlyDefinesFP(const MachineInstr &MI,
188 const TargetRegisterInfo &TRI) const {
189 switch (MI.getOpcode()) {
190 case TargetOpcode::G_SITOFP:
191 case TargetOpcode::G_UITOFP:
192 return true;
193 default:
194 break;
195 }
196
197 return hasFPConstraints(MI, MRI, TRI);
198}
199
200bool RISCVRegisterBankInfo::anyUseOnlyUseFP(
201 Register Def, const MachineRegisterInfo &MRI,
202 const TargetRegisterInfo &TRI) const {
203 return any_of(
205 [&](const MachineInstr &UseMI) { return onlyUsesFP(UseMI, MRI, TRI); });
206}
207
208/// Decide whether an s64 value on RV32 belongs in a GPRPair (an i64, needs
209/// Zilsd) rather than in FPR64 (an f64, needs D).
210///
211/// With extended LLTs the type answers this directly. Without them every
212/// 64-bit scalar is an ANY_SCALAR LLT, so i64 and f64 are indistinguishable --
213/// guessing from the uses gets it wrong, e.g. an f64 whose only use is a
214/// G_SELECT looks like an integer because G_SELECT is not itself floating
215/// point constrained. So fall back to using a GPRPair only where the value
216/// cannot be an f64 at all.
217static bool useGPRPairForS64(const RISCVSubtarget &ST, LLT Ty) {
218 if (!ST.hasStdExtZilsd())
219 return false;
220 // With typed LLTs, an i64 always uses a GPR pair. An f64 only uses one when
221 // there is no D extension to hold it in an FPR.
223 return Ty.isInteger() || !ST.hasStdExtD();
224 return !ST.hasStdExtD();
225}
226
227/// Returns true if a scalar floating point value of the given size is held in
228/// an FPR. Otherwise (soft-float, Zfinx, ...) it lives in a GPR.
229static bool hasFPRFor(const RISCVSubtarget &ST, unsigned Size) {
230 switch (Size) {
231 case 16:
232 return ST.hasStdExtZfhmin();
233 case 32:
234 return ST.hasStdExtF();
235 case 64:
236 return ST.hasStdExtD();
237 default:
238 return false;
239 }
240}
241
243 unsigned Idx;
244
245 if (Size <= 64)
246 Idx = RISCV::VRB64Idx;
247 else if (Size == 128)
248 Idx = RISCV::VRB128Idx;
249 else if (Size == 256)
250 Idx = RISCV::VRB256Idx;
251 else if (Size == 512)
252 Idx = RISCV::VRB512Idx;
253 else
254 llvm::report_fatal_error("Invalid Size");
255
256 return &RISCV::ValueMappings[Idx];
257}
258
261 const unsigned Opc = MI.getOpcode();
262
263 // Try the default logic for non-generic instructions that are either copies
264 // or already have some operands assigned to banks.
265 if (!isPreISelGenericOpcode(Opc) || Opc == TargetOpcode::G_PHI) {
266 const InstructionMapping &Mapping = getInstrMappingImpl(MI);
267 if (Mapping.isValid())
268 return Mapping;
269 }
270
271 const MachineFunction &MF = *MI.getParent()->getParent();
272 const MachineRegisterInfo &MRI = MF.getRegInfo();
274 const TargetRegisterInfo &TRI = *Subtarget.getRegisterInfo();
275
276 unsigned GPRSize = Subtarget.getXLen();
277
278 unsigned NumOperands = MI.getNumOperands();
279 const ValueMapping *GPRValueMapping =
282
283 switch (Opc) {
284 case TargetOpcode::G_ADD:
285 case TargetOpcode::G_SUB:
286 case TargetOpcode::G_SHL:
287 case TargetOpcode::G_ASHR:
288 case TargetOpcode::G_LSHR:
289 case TargetOpcode::G_AND:
290 case TargetOpcode::G_OR:
291 case TargetOpcode::G_XOR:
292 case TargetOpcode::G_MUL:
293 case TargetOpcode::G_SDIV:
294 case TargetOpcode::G_SREM:
295 case TargetOpcode::G_SMULH:
296 case TargetOpcode::G_SMAX:
297 case TargetOpcode::G_SMIN:
298 case TargetOpcode::G_UDIV:
299 case TargetOpcode::G_UREM:
300 case TargetOpcode::G_UMULH:
301 case TargetOpcode::G_UMAX:
302 case TargetOpcode::G_UMIN:
303 case TargetOpcode::G_PTR_ADD:
304 case TargetOpcode::G_PTRTOINT:
305 case TargetOpcode::G_INTTOPTR:
306 case TargetOpcode::G_FADD:
307 case TargetOpcode::G_FSUB:
308 case TargetOpcode::G_FMUL:
309 case TargetOpcode::G_FDIV:
310 case TargetOpcode::G_FABS:
311 case TargetOpcode::G_FNEG:
312 case TargetOpcode::G_FSQRT:
313 case TargetOpcode::G_FMAXNUM:
314 case TargetOpcode::G_FMINNUM: {
315 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
316 TypeSize Size = Ty.getSizeInBits();
317
318 const ValueMapping *Mapping;
319 if (Ty.isVector())
320 Mapping = getVRBValueMapping(Size.getKnownMinValue());
322 Mapping = getFPValueMapping(Size.getFixedValue());
323 else
324 Mapping = GPRValueMapping;
325
326#ifndef NDEBUG
327 // Make sure all the operands are using similar size and type.
328 for (unsigned Idx = 1; Idx != NumOperands; ++Idx) {
329 LLT OpTy = MRI.getType(MI.getOperand(Idx).getReg());
330 assert(Ty.isVector() == OpTy.isVector() &&
331 "Operand has incompatible type");
332 // Don't check size for GPR.
334 assert(Size == OpTy.getSizeInBits() && "Operand has incompatible size");
335 }
336#endif // End NDEBUG
337
338 return getInstructionMapping(DefaultMappingID, 1, Mapping, NumOperands);
339 }
340 case TargetOpcode::G_SEXTLOAD:
341 case TargetOpcode::G_ZEXTLOAD:
342 return getInstructionMapping(DefaultMappingID, /*Cost=*/1, GPRValueMapping,
343 NumOperands);
344 case TargetOpcode::G_IMPLICIT_DEF: {
345 Register Dst = MI.getOperand(0).getReg();
346 LLT DstTy = MRI.getType(Dst);
347 unsigned DstMinSize = DstTy.getSizeInBits().getKnownMinValue();
348 auto Mapping = GPRValueMapping;
349 // FIXME: May need to do a better job determining when to use FPRB.
350 // For example, the look through COPY case:
351 // %0:_(s32) = G_IMPLICIT_DEF
352 // %1:_(s32) = COPY %0
353 // $f10_d = COPY %1(s32)
354 if (DstTy.isVector())
355 Mapping = getVRBValueMapping(DstMinSize);
356 else if (anyUseOnlyUseFP(Dst, MRI, TRI))
357 Mapping = getFPValueMapping(DstMinSize);
358
359 return getInstructionMapping(DefaultMappingID, /*Cost=*/1, Mapping,
360 NumOperands);
361 }
362 }
363
364 SmallVector<const ValueMapping *, 4> OpdsMapping(NumOperands);
365
366 switch (Opc) {
367 case TargetOpcode::G_LOAD: {
368 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
369 TypeSize Size = Ty.getSizeInBits();
370
371 OpdsMapping[1] = GPRValueMapping;
372
373 if (Ty.isVector()) {
374 OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
375 break;
376 }
377
378 OpdsMapping[0] = GPRValueMapping;
379
380 // Atomics always use GPR destinations. Don't refine any further.
381 if (cast<GLoad>(MI).isAtomic())
382 break;
383
384 // RV32 s64 loads: f64 (D) uses FPR64; i64 (Zilsd without D) uses a
385 // GPRPair.
386 if (GPRSize == 32 && Size.getFixedValue() == 64) {
388 if (useGPRPairForS64(ST, Ty)) {
389 OpdsMapping[0] = &RISCV::ValueMappings[RISCV::GPRB64Idx];
390 break;
391 }
392 assert(ST.hasStdExtD() && "s64 load without D or Zilsd");
393 OpdsMapping[0] = getFPValueMapping(Size);
394 break;
395 }
396
397 // Check if that load feeds fp instructions.
398 // In that case, we want the default mapping to be on FPR
399 // instead of blind map every scalar to GPR.
400 if (anyUseOnlyUseFP(MI.getOperand(0).getReg(), MRI, TRI)) {
401 // If we have at least one direct use in a FP instruction,
402 // assume this was a floating point load in the IR. If it was
403 // not, we would have had a bitcast before reaching that
404 // instruction.
405 OpdsMapping[0] = getFPValueMapping(Size);
406 break;
407 }
408
409 break;
410 }
411 case TargetOpcode::G_STORE: {
412 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
413 TypeSize Size = Ty.getSizeInBits();
414
415 OpdsMapping[1] = GPRValueMapping;
416
417 if (Ty.isVector()) {
418 OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
419 break;
420 }
421
422 OpdsMapping[0] = GPRValueMapping;
423
424 // Atomics always use GPR sources. Don't refine any further.
425 if (cast<GStore>(MI).isAtomic())
426 break;
427
428 // RV32 s64 stores: f64 (D) uses FPR64; i64 (Zilsd without D) uses a
429 // GPRPair.
430 if (GPRSize == 32 && Size.getFixedValue() == 64) {
432 if (useGPRPairForS64(ST, Ty)) {
433 OpdsMapping[0] = &RISCV::ValueMappings[RISCV::GPRB64Idx];
434 break;
435 }
436 assert(ST.hasStdExtD() && "s64 store without D or Zilsd");
437 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
438 break;
439 }
440
441 MachineInstr *DefMI = MRI.getVRegDef(MI.getOperand(0).getReg());
442 if (onlyDefinesFP(*DefMI, MRI, TRI))
443 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
444 break;
445 }
446 case TargetOpcode::G_SELECT: {
447 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
448
449 if (Ty.isVector()) {
450 auto &Sel = cast<GSelect>(MI);
451 LLT TestTy = MRI.getType(Sel.getCondReg());
452 assert(TestTy.isVector() && "Unexpected condition argument type");
453 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] =
454 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
455 OpdsMapping[1] =
457 break;
458 }
459
460 // Try to minimize the number of copies. If we have more floating point
461 // constrained values than not, then we'll put everything on FPR. Otherwise,
462 // everything has to be on GPR.
463 unsigned NumFP = 0;
464
465 // Use FPR64 for s64 select on rv32. An s64 select is only legal here when
466 // D is present (see the G_SELECT rules), so this cannot be a Zilsd i64,
467 // which would need a GPRPair instead.
468 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
469 NumFP = 3;
470 } else {
471 // Check if the uses of the result always produce floating point values.
472 //
473 // For example:
474 //
475 // %z = G_SELECT %cond %x %y
476 // fpr = G_FOO %z ...
477 if (any_of(MRI.use_nodbg_instructions(MI.getOperand(0).getReg()),
478 [&](const MachineInstr &UseMI) {
479 return onlyUsesFP(UseMI, MRI, TRI);
480 }))
481 ++NumFP;
482
483 // Check if the defs of the source values always produce floating point
484 // values.
485 //
486 // For example:
487 //
488 // %x = G_SOMETHING_ALWAYS_FLOAT %a ...
489 // %z = G_SELECT %cond %x %y
490 //
491 // Also check whether or not the sources have already been decided to be
492 // FPR. Keep track of this.
493 //
494 // This doesn't check the condition, since the condition is always an
495 // integer.
496 for (unsigned Idx = 2; Idx < 4; ++Idx) {
497 Register VReg = MI.getOperand(Idx).getReg();
498 MachineInstr *DefMI = MRI.getVRegDef(VReg);
499 if (getRegBank(VReg, MRI, TRI) == &RISCV::FPRBRegBank ||
500 onlyDefinesFP(*DefMI, MRI, TRI))
501 ++NumFP;
502 }
503 }
504
505 // Condition operand is always GPR.
506 OpdsMapping[1] = GPRValueMapping;
507
508 const ValueMapping *Mapping = GPRValueMapping;
509 if (NumFP >= 2)
510 Mapping = getFPValueMapping(Ty.getSizeInBits());
511
512 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] = Mapping;
513 break;
514 }
515 case RISCV::G_FCVT_W_RV64:
516 case RISCV::G_FCVT_WU_RV64:
517 case RISCV::G_FCVT_X:
518 case RISCV::G_FCVT_XU:
519 case TargetOpcode::G_FPTOSI:
520 case TargetOpcode::G_FPTOUI:
521 case TargetOpcode::G_LROUND:
522 case TargetOpcode::G_LLROUND:
523 case TargetOpcode::G_INTRINSIC_LRINT:
524 case TargetOpcode::G_INTRINSIC_LLRINT:
525 case RISCV::G_FCLASS: {
526 LLT Ty = MRI.getType(MI.getOperand(1).getReg());
527 OpdsMapping[0] = GPRValueMapping;
528 OpdsMapping[1] = getFPValueMapping(Ty.getSizeInBits());
529 break;
530 }
531 case TargetOpcode::G_SITOFP:
532 case TargetOpcode::G_UITOFP: {
533 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
534 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
535 OpdsMapping[1] = GPRValueMapping;
536 break;
537 }
538 case TargetOpcode::G_FCMP: {
539 LLT Ty = MRI.getType(MI.getOperand(2).getReg());
540
541 unsigned Size = Ty.getSizeInBits();
542
543 OpdsMapping[0] = GPRValueMapping;
544 OpdsMapping[2] = OpdsMapping[3] = getFPValueMapping(Size);
545 break;
546 }
547 case TargetOpcode::G_MERGE_VALUES: {
548 // RV32 s64: f64 (D) uses FPR64; i64 (Zilsd without D) uses a GPRPair.
549 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
550 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
552 OpdsMapping[0] = useGPRPairForS64(ST, Ty)
554 : getFPValueMapping(Ty.getSizeInBits());
555 assert((useGPRPairForS64(ST, Ty) || ST.hasStdExtD()) &&
556 "s64 merge without D or Zilsd");
557 OpdsMapping[1] = GPRValueMapping;
558 OpdsMapping[2] = GPRValueMapping;
559 }
560 break;
561 }
562 case TargetOpcode::G_UNMERGE_VALUES: {
563 // RV32 s64: f64 (D) uses FPR64; i64 (Zilsd without D) uses a GPRPair.
564 LLT Ty = MRI.getType(MI.getOperand(2).getReg());
565 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
567 OpdsMapping[2] = useGPRPairForS64(ST, Ty)
569 : getFPValueMapping(Ty.getSizeInBits());
570 assert((useGPRPairForS64(ST, Ty) || ST.hasStdExtD()) &&
571 "s64 unmerge without D or Zilsd");
572 OpdsMapping[0] = GPRValueMapping;
573 OpdsMapping[1] = GPRValueMapping;
574 }
575 break;
576 }
577 case TargetOpcode::G_BITCAST: {
578 // Scalar bitcasts move values between the FPR and GPR banks based on the
579 // type kind. Vector bitcasts stay in the VR bank.
580 for (unsigned Idx = 0; Idx < 2; ++Idx) {
581 LLT Ty = MRI.getType(MI.getOperand(Idx).getReg());
582 if (Ty.isVector())
583 OpdsMapping[Idx] =
584 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
585 else if (Ty.isFloat() && hasFPRFor(Subtarget, Ty.getSizeInBits()))
586 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
587 else
588 OpdsMapping[Idx] = GPRValueMapping;
589 }
590 break;
591 }
592 case TargetOpcode::G_SPLAT_VECTOR: {
593 OpdsMapping[0] = getVRBValueMapping(MRI.getType(MI.getOperand(0).getReg())
594 .getSizeInBits()
595 .getKnownMinValue());
596
597 LLT ScalarTy = MRI.getType(MI.getOperand(1).getReg());
598 MachineInstr *DefMI = MRI.getVRegDef(MI.getOperand(1).getReg());
599 if ((GPRSize == 32 && ScalarTy.getSizeInBits() == 64) ||
600 onlyDefinesFP(*DefMI, MRI, TRI)) {
601 assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
602 OpdsMapping[1] = getFPValueMapping(ScalarTy.getSizeInBits());
603 } else
604 OpdsMapping[1] = GPRValueMapping;
605 break;
606 }
607 case TargetOpcode::G_INTRINSIC: {
608 Intrinsic::ID IntrinsicID = cast<GIntrinsic>(MI).getIntrinsicID();
609
611 RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(IntrinsicID)) {
612 unsigned ScalarIdx = -1;
613 if (II->hasScalarOperand()) {
614 ScalarIdx = II->ScalarOperand + 2;
615 }
616 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
617 const MachineOperand &MO = MI.getOperand(Idx);
618 if (!MO.isReg())
619 continue;
620 LLT Ty = MRI.getType(MO.getReg());
621 if (Ty.isVector()) {
622 OpdsMapping[Idx] =
623 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
624 } else if (II->IsFPIntrinsic && ScalarIdx == Idx) {
625 // Chose the right FPR for scalar operand of RVV intrinsics.
626 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
627 } else {
628 OpdsMapping[Idx] = GPRValueMapping;
629 }
630 }
631 }
632
633 if (IntrinsicID == Intrinsic::riscv_orc_b ||
634 IntrinsicID == Intrinsic::riscv_vsetvli ||
635 IntrinsicID == Intrinsic::riscv_vsetvlimax) {
636 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
637 const MachineOperand &MO = MI.getOperand(Idx);
638 if (!MO.isReg())
639 continue;
640 OpdsMapping[Idx] = GPRValueMapping;
641 }
642 }
643 break;
644 }
645 default:
646 // By default map all scalars to GPR.
647 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
648 auto &MO = MI.getOperand(Idx);
649 if (!MO.isReg() || !MO.getReg())
650 continue;
651 LLT Ty = MRI.getType(MO.getReg());
652 if (!Ty.isValid())
653 continue;
654
655 if (Ty.isVector())
656 OpdsMapping[Idx] =
657 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
659 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
660 else
661 OpdsMapping[Idx] = GPRValueMapping;
662 }
663 break;
664 }
665
666 return getInstructionMapping(DefaultMappingID, /*Cost=*/1,
667 getOperandsMapping(OpdsMapping), NumOperands);
668}
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
IRTranslator LLVM IR MI
static bool isAtomic(MachineBasicBlock::iterator I)
Register const TargetRegisterInfo * TRI
uint64_t IntrinsicInst * II
MachineRegisterInfo & MRI
static const RegisterBankInfo::ValueMapping * getFPValueMapping(unsigned Size)
static const RegisterBankInfo::ValueMapping * getVRBValueMapping(unsigned Size)
static bool useGPRPairForS64(const RISCVSubtarget &ST, LLT Ty)
Decide whether an s64 value on RV32 belongs in a GPRPair (an i64, needs Zilsd) rather than in FPR64 (...
static bool hasFPRFor(const RISCVSubtarget &ST, unsigned Size)
Returns true if a scalar floating point value of the given size is held in an FPR.
This file declares the targeting of the RegisterBankInfo class for RISC-V.
static bool getUseExtended()
constexpr bool isVector() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
unsigned getID() const
getID() - Return the register class ID number.
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.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
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.
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...
unsigned HwMode
Current HwMode for the target.
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.
Definition Register.h:20
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...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
#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.
Definition STLExtras.h:1762
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI bool isPreISelGenericFloatingPointOpcode(unsigned Opc)
Returns whether opcode Opc is a pre-isel generic floating-point opcode, having only floating-point op...
Definition Utils.cpp:1862
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
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.