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_FROUND:
171 case RISCV::G_FCLASS:
172 case TargetOpcode::G_FPTOSI:
173 case TargetOpcode::G_FPTOUI:
174 case TargetOpcode::G_LROUND:
175 case TargetOpcode::G_LLROUND:
176 case TargetOpcode::G_INTRINSIC_LRINT:
177 case TargetOpcode::G_INTRINSIC_LLRINT:
178 case TargetOpcode::G_FCMP:
179 return true;
180 default:
181 break;
182 }
183
184 return hasFPConstraints(MI, MRI, TRI);
185}
186
187bool RISCVRegisterBankInfo::onlyDefinesFP(const MachineInstr &MI,
189 const TargetRegisterInfo &TRI) const {
190 switch (MI.getOpcode()) {
191 case TargetOpcode::G_SITOFP:
192 case TargetOpcode::G_UITOFP:
193 return true;
194 default:
195 break;
196 }
197
198 return hasFPConstraints(MI, MRI, TRI);
199}
200
201bool RISCVRegisterBankInfo::anyUseOnlyUseFP(
202 Register Def, const MachineRegisterInfo &MRI,
203 const TargetRegisterInfo &TRI) const {
204 return any_of(
206 [&](const MachineInstr &UseMI) { return onlyUsesFP(UseMI, MRI, TRI); });
207}
208
209/// Decide whether an s64 value on RV32 belongs in a GPRPair (an i64, needs
210/// Zilsd) rather than in FPR64 (an f64, needs D).
211///
212/// With extended LLTs the type answers this directly. Without them every
213/// 64-bit scalar is an ANY_SCALAR LLT, so i64 and f64 are indistinguishable --
214/// guessing from the uses gets it wrong, e.g. an f64 whose only use is a
215/// G_SELECT looks like an integer because G_SELECT is not itself floating
216/// point constrained. So fall back to using a GPRPair only where the value
217/// cannot be an f64 at all.
218static bool useGPRPairForS64(const RISCVSubtarget &ST, LLT Ty) {
219 if (!ST.hasStdExtZilsd())
220 return false;
221 // With typed LLTs, an i64 always uses a GPR pair. An f64 only uses one when
222 // there is no D extension to hold it in an FPR.
224 return Ty.isInteger() || !ST.hasStdExtD();
225 return !ST.hasStdExtD();
226}
227
228/// Returns true if a scalar floating point value of the given size is held in
229/// an FPR. Otherwise (soft-float, Zfinx, ...) it lives in a GPR.
230static bool hasFPRFor(const RISCVSubtarget &ST, unsigned Size) {
231 switch (Size) {
232 case 16:
233 return ST.hasStdExtZfhmin();
234 case 32:
235 return ST.hasStdExtF();
236 case 64:
237 return ST.hasStdExtD();
238 default:
239 return false;
240 }
241}
242
244 unsigned Idx;
245
246 if (Size <= 64)
247 Idx = RISCV::VRB64Idx;
248 else if (Size == 128)
249 Idx = RISCV::VRB128Idx;
250 else if (Size == 256)
251 Idx = RISCV::VRB256Idx;
252 else if (Size == 512)
253 Idx = RISCV::VRB512Idx;
254 else
255 llvm::report_fatal_error("Invalid Size");
256
257 return &RISCV::ValueMappings[Idx];
258}
259
262 const unsigned Opc = MI.getOpcode();
263
264 // Try the default logic for non-generic instructions that are either copies
265 // or already have some operands assigned to banks.
266 if (!isPreISelGenericOpcode(Opc) || Opc == TargetOpcode::G_PHI) {
267 const InstructionMapping &Mapping = getInstrMappingImpl(MI);
268 if (Mapping.isValid())
269 return Mapping;
270 }
271
272 const MachineFunction &MF = *MI.getParent()->getParent();
273 const MachineRegisterInfo &MRI = MF.getRegInfo();
275 const TargetRegisterInfo &TRI = *Subtarget.getRegisterInfo();
276
277 unsigned GPRSize = Subtarget.getXLen();
278
279 unsigned NumOperands = MI.getNumOperands();
280 const ValueMapping *GPRValueMapping =
283
284 switch (Opc) {
285 case TargetOpcode::G_ADD:
286 case TargetOpcode::G_SUB:
287 case TargetOpcode::G_SHL:
288 case TargetOpcode::G_ASHR:
289 case TargetOpcode::G_LSHR:
290 case TargetOpcode::G_AND:
291 case TargetOpcode::G_OR:
292 case TargetOpcode::G_XOR:
293 case TargetOpcode::G_MUL:
294 case TargetOpcode::G_SDIV:
295 case TargetOpcode::G_SREM:
296 case TargetOpcode::G_SMULH:
297 case TargetOpcode::G_SMAX:
298 case TargetOpcode::G_SMIN:
299 case TargetOpcode::G_UDIV:
300 case TargetOpcode::G_UREM:
301 case TargetOpcode::G_UMULH:
302 case TargetOpcode::G_UMAX:
303 case TargetOpcode::G_UMIN:
304 case TargetOpcode::G_PTR_ADD:
305 case TargetOpcode::G_PTRTOINT:
306 case TargetOpcode::G_INTTOPTR:
307 case TargetOpcode::G_FADD:
308 case TargetOpcode::G_FSUB:
309 case TargetOpcode::G_FMUL:
310 case TargetOpcode::G_FDIV:
311 case TargetOpcode::G_FABS:
312 case TargetOpcode::G_FNEG:
313 case TargetOpcode::G_FSQRT:
314 case TargetOpcode::G_FMAXNUM:
315 case TargetOpcode::G_FMINNUM: {
316 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
317 TypeSize Size = Ty.getSizeInBits();
318
319 const ValueMapping *Mapping;
320 if (Ty.isVector())
321 Mapping = getVRBValueMapping(Size.getKnownMinValue());
323 Mapping = getFPValueMapping(Size.getFixedValue());
324 else
325 Mapping = GPRValueMapping;
326
327#ifndef NDEBUG
328 // Make sure all the operands are using similar size and type.
329 for (unsigned Idx = 1; Idx != NumOperands; ++Idx) {
330 LLT OpTy = MRI.getType(MI.getOperand(Idx).getReg());
331 assert(Ty.isVector() == OpTy.isVector() &&
332 "Operand has incompatible type");
333 // Don't check size for GPR.
335 assert(Size == OpTy.getSizeInBits() && "Operand has incompatible size");
336 }
337#endif // End NDEBUG
338
339 return getInstructionMapping(DefaultMappingID, 1, Mapping, NumOperands);
340 }
341 case TargetOpcode::G_SEXTLOAD:
342 case TargetOpcode::G_ZEXTLOAD:
343 return getInstructionMapping(DefaultMappingID, /*Cost=*/1, GPRValueMapping,
344 NumOperands);
345 case TargetOpcode::G_IMPLICIT_DEF: {
346 Register Dst = MI.getOperand(0).getReg();
347 LLT DstTy = MRI.getType(Dst);
348 unsigned DstMinSize = DstTy.getSizeInBits().getKnownMinValue();
349 auto Mapping = GPRValueMapping;
350 // FIXME: May need to do a better job determining when to use FPRB.
351 // For example, the look through COPY case:
352 // %0:_(s32) = G_IMPLICIT_DEF
353 // %1:_(s32) = COPY %0
354 // $f10_d = COPY %1(s32)
355 if (DstTy.isVector())
356 Mapping = getVRBValueMapping(DstMinSize);
357 else if (anyUseOnlyUseFP(Dst, MRI, TRI))
358 Mapping = getFPValueMapping(DstMinSize);
359
360 return getInstructionMapping(DefaultMappingID, /*Cost=*/1, Mapping,
361 NumOperands);
362 }
363 }
364
365 SmallVector<const ValueMapping *, 4> OpdsMapping(NumOperands);
366
367 switch (Opc) {
368 case TargetOpcode::G_LOAD: {
369 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
370 TypeSize Size = Ty.getSizeInBits();
371
372 OpdsMapping[1] = GPRValueMapping;
373
374 if (Ty.isVector()) {
375 OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
376 break;
377 }
378
379 OpdsMapping[0] = GPRValueMapping;
380
381 // Atomics always use GPR destinations. Don't refine any further.
382 if (cast<GLoad>(MI).isAtomic())
383 break;
384
385 // RV32 s64 loads: f64 (D) uses FPR64; i64 (Zilsd without D) uses a
386 // GPRPair.
387 if (GPRSize == 32 && Size.getFixedValue() == 64) {
389 if (useGPRPairForS64(ST, Ty)) {
390 OpdsMapping[0] = &RISCV::ValueMappings[RISCV::GPRB64Idx];
391 break;
392 }
393 assert(ST.hasStdExtD() && "s64 load without D or Zilsd");
394 OpdsMapping[0] = getFPValueMapping(Size);
395 break;
396 }
397
398 // Check if that load feeds fp instructions.
399 // In that case, we want the default mapping to be on FPR
400 // instead of blind map every scalar to GPR.
401 if (anyUseOnlyUseFP(MI.getOperand(0).getReg(), MRI, TRI)) {
402 // If we have at least one direct use in a FP instruction,
403 // assume this was a floating point load in the IR. If it was
404 // not, we would have had a bitcast before reaching that
405 // instruction.
406 OpdsMapping[0] = getFPValueMapping(Size);
407 break;
408 }
409
410 break;
411 }
412 case TargetOpcode::G_STORE: {
413 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
414 TypeSize Size = Ty.getSizeInBits();
415
416 OpdsMapping[1] = GPRValueMapping;
417
418 if (Ty.isVector()) {
419 OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
420 break;
421 }
422
423 OpdsMapping[0] = GPRValueMapping;
424
425 // Atomics always use GPR sources. Don't refine any further.
426 if (cast<GStore>(MI).isAtomic())
427 break;
428
429 // RV32 s64 stores: f64 (D) uses FPR64; i64 (Zilsd without D) uses a
430 // GPRPair.
431 if (GPRSize == 32 && Size.getFixedValue() == 64) {
433 if (useGPRPairForS64(ST, Ty)) {
434 OpdsMapping[0] = &RISCV::ValueMappings[RISCV::GPRB64Idx];
435 break;
436 }
437 assert(ST.hasStdExtD() && "s64 store without D or Zilsd");
438 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
439 break;
440 }
441
442 MachineInstr *DefMI = MRI.getVRegDef(MI.getOperand(0).getReg());
443 if (onlyDefinesFP(*DefMI, MRI, TRI))
444 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
445 break;
446 }
447 case TargetOpcode::G_SELECT: {
448 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
449
450 if (Ty.isVector()) {
451 auto &Sel = cast<GSelect>(MI);
452 LLT TestTy = MRI.getType(Sel.getCondReg());
453 assert(TestTy.isVector() && "Unexpected condition argument type");
454 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] =
455 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
456 OpdsMapping[1] =
458 break;
459 }
460
461 // Try to minimize the number of copies. If we have more floating point
462 // constrained values than not, then we'll put everything on FPR. Otherwise,
463 // everything has to be on GPR.
464 unsigned NumFP = 0;
465
466 // Use FPR64 for s64 select on rv32. An s64 select is only legal here when
467 // D is present (see the G_SELECT rules), so this cannot be a Zilsd i64,
468 // which would need a GPRPair instead.
469 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
470 NumFP = 3;
471 } else {
472 // Check if the uses of the result always produce floating point values.
473 //
474 // For example:
475 //
476 // %z = G_SELECT %cond %x %y
477 // fpr = G_FOO %z ...
478 if (any_of(MRI.use_nodbg_instructions(MI.getOperand(0).getReg()),
479 [&](const MachineInstr &UseMI) {
480 return onlyUsesFP(UseMI, MRI, TRI);
481 }))
482 ++NumFP;
483
484 // Check if the defs of the source values always produce floating point
485 // values.
486 //
487 // For example:
488 //
489 // %x = G_SOMETHING_ALWAYS_FLOAT %a ...
490 // %z = G_SELECT %cond %x %y
491 //
492 // Also check whether or not the sources have already been decided to be
493 // FPR. Keep track of this.
494 //
495 // This doesn't check the condition, since the condition is always an
496 // integer.
497 for (unsigned Idx = 2; Idx < 4; ++Idx) {
498 Register VReg = MI.getOperand(Idx).getReg();
499 MachineInstr *DefMI = MRI.getVRegDef(VReg);
500 if (getRegBank(VReg, MRI, TRI) == &RISCV::FPRBRegBank ||
501 onlyDefinesFP(*DefMI, MRI, TRI))
502 ++NumFP;
503 }
504 }
505
506 // Condition operand is always GPR.
507 OpdsMapping[1] = GPRValueMapping;
508
509 const ValueMapping *Mapping = GPRValueMapping;
510 if (NumFP >= 2)
511 Mapping = getFPValueMapping(Ty.getSizeInBits());
512
513 OpdsMapping[0] = OpdsMapping[2] = OpdsMapping[3] = Mapping;
514 break;
515 }
516 case RISCV::G_FCVT_W_RV64:
517 case RISCV::G_FCVT_WU_RV64:
518 case RISCV::G_FCVT_X:
519 case RISCV::G_FCVT_XU:
520 case TargetOpcode::G_FPTOSI:
521 case TargetOpcode::G_FPTOUI:
522 case TargetOpcode::G_LROUND:
523 case TargetOpcode::G_LLROUND:
524 case TargetOpcode::G_INTRINSIC_LRINT:
525 case TargetOpcode::G_INTRINSIC_LLRINT:
526 case RISCV::G_FCLASS: {
527 LLT Ty = MRI.getType(MI.getOperand(1).getReg());
528 OpdsMapping[0] = GPRValueMapping;
529 OpdsMapping[1] = getFPValueMapping(Ty.getSizeInBits());
530 break;
531 }
532 case RISCV::G_FROUND: {
533 // Destination, source and the max value all live in an FPR. The remaining
534 // operand is the rounding mode immediate.
535 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
536 OpdsMapping[0] = OpdsMapping[1] = OpdsMapping[2] =
537 getFPValueMapping(Ty.getSizeInBits());
538 break;
539 }
540 case TargetOpcode::G_SITOFP:
541 case TargetOpcode::G_UITOFP: {
542 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
543 OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
544 OpdsMapping[1] = GPRValueMapping;
545 break;
546 }
547 case TargetOpcode::G_FCMP: {
548 LLT Ty = MRI.getType(MI.getOperand(2).getReg());
549
550 unsigned Size = Ty.getSizeInBits();
551
552 OpdsMapping[0] = GPRValueMapping;
553 OpdsMapping[2] = OpdsMapping[3] = getFPValueMapping(Size);
554 break;
555 }
556 case TargetOpcode::G_MERGE_VALUES: {
557 // RV32 s64: f64 (D) uses FPR64; i64 (Zilsd without D) uses a GPRPair.
558 LLT Ty = MRI.getType(MI.getOperand(0).getReg());
559 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
561 OpdsMapping[0] = useGPRPairForS64(ST, Ty)
563 : getFPValueMapping(Ty.getSizeInBits());
564 assert((useGPRPairForS64(ST, Ty) || ST.hasStdExtD()) &&
565 "s64 merge without D or Zilsd");
566 OpdsMapping[1] = GPRValueMapping;
567 OpdsMapping[2] = GPRValueMapping;
568 }
569 break;
570 }
571 case TargetOpcode::G_UNMERGE_VALUES: {
572 // RV32 s64: f64 (D) uses FPR64; i64 (Zilsd without D) uses a GPRPair.
573 LLT Ty = MRI.getType(MI.getOperand(2).getReg());
574 if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
576 OpdsMapping[2] = useGPRPairForS64(ST, Ty)
578 : getFPValueMapping(Ty.getSizeInBits());
579 assert((useGPRPairForS64(ST, Ty) || ST.hasStdExtD()) &&
580 "s64 unmerge without D or Zilsd");
581 OpdsMapping[0] = GPRValueMapping;
582 OpdsMapping[1] = GPRValueMapping;
583 }
584 break;
585 }
586 case TargetOpcode::G_BITCAST: {
587 // Scalar bitcasts move values between the FPR and GPR banks based on the
588 // type kind. Vector bitcasts stay in the VR bank.
589 for (unsigned Idx = 0; Idx < 2; ++Idx) {
590 LLT Ty = MRI.getType(MI.getOperand(Idx).getReg());
591 if (Ty.isVector())
592 OpdsMapping[Idx] =
593 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
594 else if (Ty.isFloat() && hasFPRFor(Subtarget, Ty.getSizeInBits()))
595 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
596 else
597 OpdsMapping[Idx] = GPRValueMapping;
598 }
599 break;
600 }
601 case TargetOpcode::G_SPLAT_VECTOR: {
602 OpdsMapping[0] = getVRBValueMapping(MRI.getType(MI.getOperand(0).getReg())
603 .getSizeInBits()
604 .getKnownMinValue());
605
606 LLT ScalarTy = MRI.getType(MI.getOperand(1).getReg());
607 MachineInstr *DefMI = MRI.getVRegDef(MI.getOperand(1).getReg());
608 if ((GPRSize == 32 && ScalarTy.getSizeInBits() == 64) ||
609 onlyDefinesFP(*DefMI, MRI, TRI)) {
610 assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
611 OpdsMapping[1] = getFPValueMapping(ScalarTy.getSizeInBits());
612 } else
613 OpdsMapping[1] = GPRValueMapping;
614 break;
615 }
616 case TargetOpcode::G_INTRINSIC: {
617 Intrinsic::ID IntrinsicID = cast<GIntrinsic>(MI).getIntrinsicID();
618
620 RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(IntrinsicID)) {
621 unsigned ScalarIdx = -1;
622 if (II->hasScalarOperand()) {
623 ScalarIdx = II->ScalarOperand + 2;
624 }
625 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
626 const MachineOperand &MO = MI.getOperand(Idx);
627 if (!MO.isReg())
628 continue;
629 LLT Ty = MRI.getType(MO.getReg());
630 if (Ty.isVector()) {
631 OpdsMapping[Idx] =
632 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
633 } else if (II->IsFPIntrinsic && ScalarIdx == Idx) {
634 // Chose the right FPR for scalar operand of RVV intrinsics.
635 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
636 } else {
637 OpdsMapping[Idx] = GPRValueMapping;
638 }
639 }
640 }
641
642 if (IntrinsicID == Intrinsic::riscv_vsetvli ||
643 IntrinsicID == Intrinsic::riscv_vsetvlimax) {
644 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
645 const MachineOperand &MO = MI.getOperand(Idx);
646 if (!MO.isReg())
647 continue;
648 OpdsMapping[Idx] = GPRValueMapping;
649 }
650 }
651 break;
652 }
653 default:
654 // By default map all scalars to GPR.
655 for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
656 auto &MO = MI.getOperand(Idx);
657 if (!MO.isReg() || !MO.getReg())
658 continue;
659 LLT Ty = MRI.getType(MO.getReg());
660 if (!Ty.isValid())
661 continue;
662
663 if (Ty.isVector())
664 OpdsMapping[Idx] =
665 getVRBValueMapping(Ty.getSizeInBits().getKnownMinValue());
667 OpdsMapping[Idx] = getFPValueMapping(Ty.getSizeInBits());
668 else
669 OpdsMapping[Idx] = GPRValueMapping;
670 }
671 break;
672 }
673
674 return getInstructionMapping(DefaultMappingID, /*Cost=*/1,
675 getOperandsMapping(OpdsMapping), NumOperands);
676}
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)
unsigned Opc
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:1858
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.