40#define DEBUG_TYPE "riscv-insert-vsetvli"
41#define RISCV_INSERT_VSETVLI_NAME "RISC-V Insert VSETVLI pass"
43STATISTIC(NumInsertedVSETVL,
"Number of VSETVL inst inserted");
44STATISTIC(NumCoalescedVSETVL,
"Number of VSETVL inst coalesced");
58 return LI.getVNInfoBefore(
SI);
86 const RISCVSubtarget *ST;
87 const TargetInstrInfo *TII;
88 MachineRegisterInfo *MRI;
91 RISCVVSETVLIInfoAnalysis VIA;
93 std::vector<BlockData> BlockInfo;
94 std::queue<const MachineBasicBlock *> WorkList;
99 RISCVInsertVSETVLI() : MachineFunctionPass(ID) {}
102 void getAnalysisUsage(AnalysisUsage &AU)
const override {
117 bool needVSETVLI(
const DemandedFields &Used,
const VSETVLIInfo &Require,
118 const VSETVLIInfo &CurInfo)
const;
119 bool needVSETVLIPHI(
const VSETVLIInfo &Require,
120 const MachineBasicBlock &
MBB)
const;
121 void insertVSETVLI(MachineBasicBlock &
MBB,
123 const VSETVLIInfo &Info,
const VSETVLIInfo &PrevInfo);
125 void transferBefore(VSETVLIInfo &Info,
const MachineInstr &
MI)
const;
126 void transferAfter(VSETVLIInfo &Info,
const MachineInstr &
MI)
const;
127 bool computeVLVTYPEChanges(
const MachineBasicBlock &
MBB,
128 VSETVLIInfo &Info)
const;
129 void computeIncomingVLVTYPE(
const MachineBasicBlock &
MBB);
130 void emitVSETVLIs(MachineBasicBlock &
MBB);
131 void doPRE(MachineBasicBlock &
MBB);
132 void insertReadVL(MachineBasicBlock &
MBB);
134 bool canMutatePriorConfig(
const MachineInstr &PrevMI,
const MachineInstr &
MI,
135 const DemandedFields &Used,
136 MachineInstr *&AVLDefToMove)
const;
137 void coalesceVSETVLIs(MachineBasicBlock &
MBB)
const;
138 bool canMutatePriorConfigWithTWiden(
const MachineInstr &PrevMI,
139 const MachineInstr &
MI)
const;
140 void coalesceVSETVLIsForTWiden(MachineBasicBlock &
MBB)
const;
141 bool insertVSETMTK(MachineBasicBlock &
MBB, TKTMMode
Mode)
const;
146char RISCVInsertVSETVLI::ID = 0;
158 if (PrevInfo.isKnown()) {
161 if (Info.hasSameAVL(PrevInfo) && Info.hasSameVLMAX(PrevInfo)) {
162 auto MI = BuildMI(MBB, InsertPt, DL,
163 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0X0
164 : RISCV::PseudoVSETVLIX0X0))
165 .addDef(RISCV::X0, RegState::Dead)
166 .addReg(RISCV::X0, RegState::Kill)
167 .addImm(Info.encodeVTYPE())
168 .addReg(RISCV::VL, RegState::Implicit);
170 LIS->InsertMachineInstrInMaps(*MI);
177 if (Info.hasSameVLMAX(PrevInfo) && Info.hasAVLReg()) {
178 if (const MachineInstr *DefMI = Info.getAVLDefMI(LIS);
179 DefMI && RISCVInstrInfo::isVectorConfigInstr(*DefMI)) {
180 VSETVLIInfo DefInfo = VIA.getInfoForVSETVLI(*DefMI);
181 if (DefInfo.hasSameAVL(PrevInfo) && DefInfo.hasSameVLMAX(PrevInfo)) {
183 BuildMI(MBB, InsertPt, DL,
184 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0X0
185 : RISCV::PseudoVSETVLIX0X0))
186 .addDef(RISCV::X0, RegState::Dead)
187 .addReg(RISCV::X0, RegState::Kill)
188 .addImm(Info.encodeVTYPE())
189 .addReg(RISCV::VL, RegState::Implicit);
191 LIS->InsertMachineInstrInMaps(*MI);
198 if (Info.hasAVLImm()) {
199 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETIVLI))
200 .addDef(RISCV::X0, RegState::Dead)
201 .addImm(Info.getAVLImm())
202 .addImm(Info.encodeVTYPE());
204 LIS->InsertMachineInstrInMaps(*MI);
208 if (Info.hasAVLVLMAX()) {
209 Register DestReg = MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
210 auto MI = BuildMI(MBB, InsertPt, DL,
211 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0
212 : RISCV::PseudoVSETVLIX0))
213 .addDef(DestReg, RegState::Dead)
214 .addReg(RISCV::X0, RegState::Kill)
215 .addImm(Info.encodeVTYPE());
217 LIS->InsertMachineInstrInMaps(*MI);
218 LIS->createAndComputeVirtRegInterval(DestReg);
224 MRI->constrainRegClass(AVLReg, &RISCV::GPRNoX0RegClass);
226 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNT
227 : RISCV::PseudoVSETVLI))
230 .
addImm(Info.encodeVTYPE());
235 const VNInfo *CurVNI = Info.getAVLVNInfo();
243 MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
247 II =
MBB->getFirstNonPHI();
256 MI->getOperand(1).setReg(AVLCopyReg);
288 Info.setVLMul(*NewVLMul);
298void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
299 const MachineInstr &
MI)
const {
300 if (ST->
getCLOpts().insert_vsetvli_whole_vector_register_move_valid_vtype &&
302 (!
Info.isKnown() ||
Info.hasSEWLMULRatioOnly())) {
320 if (
Info.isValid() && !needVSETVLI(Demanded, NewInfo, Info))
323 const VSETVLIInfo PrevInfo =
Info;
327 const VSETVLIInfo IncomingInfo =
adjustIncoming(PrevInfo, NewInfo, Demanded);
339 Info.setAVL(IncomingInfo);
342 if (
Info.hasSEWLMULRatioOnly()) {
343 VSETVLIInfo RatiolessInfo = IncomingInfo;
344 RatiolessInfo.
setAVL(Info);
345 Info = RatiolessInfo;
356 (Demanded.
TailPolicy ? IncomingInfo : Info).getTailAgnostic() ||
358 (Demanded.
MaskPolicy ? IncomingInfo : Info).getMaskAgnostic() ||
361 (Demanded.
AltFmt ? IncomingInfo : Info).getAltFmt() && SEW < 32,
369void RISCVInsertVSETVLI::transferAfter(VSETVLIInfo &Info,
370 const MachineInstr &
MI)
const {
371 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
379 if (RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(
MI))
382 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
384 assert(
MI.getOperand(1).getReg().isVirtual());
390 Info.setAVLRegDef(VNI,
MI.getOperand(1).getReg());
392 Info.setAVLRegDef(
nullptr,
MI.getOperand(1).getReg());
398 if (
MI.isCall() ||
MI.isInlineAsm() ||
399 MI.modifiesRegister(RISCV::VL,
nullptr) ||
400 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
404bool RISCVInsertVSETVLI::computeVLVTYPEChanges(
const MachineBasicBlock &
MBB,
405 VSETVLIInfo &Info)
const {
406 bool HadVectorOp =
false;
409 for (
const MachineInstr &
MI :
MBB) {
410 transferBefore(Info,
MI);
412 if (RISCVInstrInfo::isVectorConfigInstr(
MI) ||
415 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI))
418 transferAfter(Info,
MI);
424void RISCVInsertVSETVLI::computeIncomingVLVTYPE(
const MachineBasicBlock &
MBB) {
428 BBInfo.InQueue =
false;
432 VSETVLIInfo InInfo = BBInfo.
Pred;
438 InInfo = InInfo.
intersect(BlockInfo[
P->getNumber()].Exit);
446 if (InInfo == BBInfo.
Pred)
449 BBInfo.
Pred = InInfo;
451 <<
" changed to " << BBInfo.
Pred <<
"\n");
457 VSETVLIInfo TmpStatus;
458 computeVLVTYPEChanges(
MBB, TmpStatus);
462 if (BBInfo.
Exit == TmpStatus)
465 BBInfo.
Exit = TmpStatus;
467 <<
" changed to " << BBInfo.
Exit <<
"\n");
472 if (!BlockInfo[S->getNumber()].InQueue) {
473 BlockInfo[S->getNumber()].InQueue =
true;
481bool RISCVInsertVSETVLI::needVSETVLIPHI(
const VSETVLIInfo &Require,
482 const MachineBasicBlock &
MBB)
const {
497 const VSETVLIInfo &PBBExit = BlockInfo[PBB->getNumber()].Exit;
504 if (!
DefMI || !RISCVInstrInfo::isVectorConfigInstr(*
DefMI))
510 if (DefInfo != PBBExit)
525void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &
MBB) {
529 bool PrefixTransparent =
true;
530 for (MachineInstr &
MI :
MBB) {
531 const VSETVLIInfo PrevInfo = CurInfo;
532 transferBefore(CurInfo,
MI);
535 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
537 assert(
MI.getOperand(3).getReg() == RISCV::VL &&
538 MI.getOperand(4).getReg() == RISCV::VTYPE &&
539 "Unexpected operands where VL and VTYPE should be");
544 if (
MI.getOperand(3).isDead())
546 if (
MI.getOperand(4).isDead())
550 MI.getOperand(3).setIsDead(
false);
551 MI.getOperand(4).setIsDead(
false);
552 PrefixTransparent =
false;
555 if (ST->
getCLOpts().insert_vsetvli_whole_vector_register_move_valid_vtype &&
558 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
559 PrefixTransparent =
false;
575 if (!PrefixTransparent || needVSETVLIPHI(CurInfo,
MBB))
576 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
577 PrefixTransparent =
false;
601 for (MachineInstr *DeadMI : DeadMIs) {
602 if (!
TII->isAddImmediate(*DeadMI,
Reg))
605 Register AddReg = DeadMI->getOperand(1).getReg();
606 DeadMI->eraseFromParent();
619 if (
MI.isInlineAsm()) {
620 MI.addRegisterDefined(RISCV::VL,
nullptr);
621 MI.addRegisterDefined(RISCV::VTYPE,
nullptr);
624 if (
MI.isCall() ||
MI.isInlineAsm() ||
625 MI.modifiesRegister(RISCV::VL,
nullptr) ||
626 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
627 PrefixTransparent =
false;
629 transferAfter(CurInfo,
MI);
633 if (CurInfo !=
Info.Exit) {
639 assert(CurInfo ==
Info.Exit &&
"InsertVSETVLI dataflow invariant violated");
647void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &
MBB) {
651 MachineBasicBlock *UnavailablePred =
nullptr;
652 VSETVLIInfo AvailableInfo;
654 const VSETVLIInfo &PredInfo = BlockInfo[
P->getNumber()].Exit;
659 }
else if (!AvailableInfo.
isValid()) {
660 AvailableInfo = PredInfo;
661 }
else if (AvailableInfo != PredInfo) {
668 if (!UnavailablePred || !AvailableInfo.
isValid())
706 VSETVLIInfo CurInfo = AvailableInfo;
707 int TransitionsRemoved = 0;
708 for (
const MachineInstr &
MI :
MBB) {
709 const VSETVLIInfo LastInfo = CurInfo;
710 const VSETVLIInfo LastOldInfo = OldInfo;
711 transferBefore(CurInfo,
MI);
712 transferBefore(OldInfo,
MI);
713 if (CurInfo == LastInfo)
714 TransitionsRemoved++;
715 if (LastOldInfo == OldInfo)
716 TransitionsRemoved--;
717 transferAfter(CurInfo,
MI);
718 transferAfter(OldInfo,
MI);
719 if (CurInfo == OldInfo)
723 if (CurInfo != OldInfo || TransitionsRemoved <= 0)
730 auto OldExit = BlockInfo[UnavailablePred->
getNumber()].Exit;
732 << UnavailablePred->
getName() <<
" with state "
733 << AvailableInfo <<
"\n");
734 BlockInfo[UnavailablePred->
getNumber()].Exit = AvailableInfo;
740 insertVSETVLI(*UnavailablePred, InsertPt,
742 AvailableInfo, OldExit);
749bool RISCVInsertVSETVLI::canMutatePriorConfig(
750 const MachineInstr &PrevMI,
const MachineInstr &
MI,
751 const DemandedFields &Used, MachineInstr *&AVLDefToMove)
const {
752 AVLDefToMove =
nullptr;
756 if (!RISCVInstrInfo::isVLPreservingConfig(
MI)) {
760 if (
Used.VLZeroness) {
761 if (RISCVInstrInfo::isVLPreservingConfig(PrevMI))
768 auto &AVL =
MI.getOperand(1);
772 if (AVL.isReg() && AVL.getReg() != RISCV::X0) {
775 if (!VNI || !PrevVNI || VNI != PrevVNI) {
782 if (!AVL.getReg().isVirtual())
786 if (!
DefMI || !RISCVInstrInfo::isLoadImmediate(*
DefMI) ||
791 AVLDefToMove =
DefMI;
806 auto VType =
MI.getOperand(2).getImm();
810void RISCVInsertVSETVLI::coalesceVSETVLIs(MachineBasicBlock &
MBB)
const {
811 MachineInstr *NextMI =
nullptr;
819 auto dropAVLUse = [&](MachineOperand &MO) {
820 if (!MO.isReg() || !MO.getReg().isVirtual())
829 if (VLOpDef &&
TII->isAddImmediate(*VLOpDef, OldVLReg) &&
837 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI)) {
842 if (!RISCVInstrInfo::isVectorConfigInstr(
MI)) {
844 if (
MI.isCall() ||
MI.isInlineAsm() ||
845 MI.modifiesRegister(RISCV::VL,
nullptr) ||
846 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
851 if (!
MI.getOperand(0).isDead())
855 if (!
Used.usedVL() && !
Used.usedVTYPE()) {
856 dropAVLUse(
MI.getOperand(1));
859 MI.eraseFromParent();
860 NumCoalescedVSETVL++;
865 MachineInstr *AVLDefToMove =
nullptr;
866 if (canMutatePriorConfig(
MI, *NextMI, Used, AVLDefToMove)) {
867 if (!RISCVInstrInfo::isVLPreservingConfig(*NextMI)) {
870 MI.getOperand(0).setReg(DefReg);
871 MI.getOperand(0).setIsDead(
false);
874 dropAVLUse(
MI.getOperand(1));
896 SlotIndex NextMISlot =
899 LiveInterval::Segment S(MISlot, NextMISlot, DefVNI);
901 DefVNI->
def = MISlot;
918 NumCoalescedVSETVL++;
928 for (
auto *
MI : ToDelete) {
929 assert(
MI->getOpcode() == RISCV::ADDI);
935 MI->eraseFromParent();
963bool RISCVInsertVSETVLI::canMutatePriorConfigWithTWiden(
964 const MachineInstr &PrevMI,
const MachineInstr &
MI)
const {
966 if (PrevMI.
getOpcode() != RISCV::PseudoVSETVLI)
969 if (
MI.getOpcode() != RISCV::PseudoSF_VSETTNT)
975 assert(CurrInfo.hasAVLReg() &&
"Invalid PseudoSF_VSETTNT without an AVLReg.");
977 auto AVLReg = CurrInfo.getAVLReg();
984 if (!RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(*AVLRegDefMI))
988 if (AVLRegDefMIInfo.getTWiden() != CurrInfo.getTWiden())
991 if (AVLRegDefMIInfo.getSEW() != PrevInfo.
getSEW())
1001 if (PrevInfo.
getSEW() != CurrInfo.getSEW())
1004 if (PrevInfo.
getAltFmt() != CurrInfo.getAltFmt())
1011 unsigned KMAX = (CurrInfo.getSEW() >= 32) ? 1 : (32 / CurrInfo.getSEW());
1013 if (Fractional || LMul < (8 / KMAX))
1019void RISCVInsertVSETVLI::coalesceVSETVLIsForTWiden(
1020 MachineBasicBlock &
MBB)
const {
1021 MachineInstr *NextMI =
nullptr;
1025 if (!RISCVInstrInfo::isVectorConfigInstr(
MI))
1030 if (canMutatePriorConfigWithTWiden(
MI, *NextMI)) {
1033 MI.getOperand(2).setImm(NextInfo.encodeVTYPE());
1044void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &
MBB) {
1046 MachineInstr &
MI = *
I++;
1047 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
1048 Register VLOutput =
MI.getOperand(1).getReg();
1050 if (!
MI.getOperand(1).isDead()) {
1052 TII->get(RISCV::PseudoReadVL), VLOutput);
1055 SlotIndex NewDefSI =
1061 DefVNI->
def = NewDefSI;
1065 MI.getOperand(1).setReg(RISCV::X0);
1071bool RISCVInsertVSETVLI::insertVSETMTK(MachineBasicBlock &
MBB,
1072 TKTMMode
Mode)
const {
1075 for (
auto &
MI :
MBB) {
1077 if (RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(
MI) ||
1083 unsigned Opcode = 0, OpNum = 0;
1089 Opcode = RISCV::PseudoSF_VSETTK;
1095 Opcode = RISCV::PseudoSF_VSETTM;
1099 assert(OpNum && Opcode &&
"Invalid OpNum or Opcode");
1101 MachineOperand &
Op =
MI.getOperand(OpNum);
1104 .
addDef(RISCV::X0, RegState::Dead)
1112 Op.setIsKill(
false);
1137 auto *LISWrapper = getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
1138 LIS = LISWrapper ? &LISWrapper->getLIS() :
nullptr;
1139 VIA = RISCVVSETVLIInfoAnalysis(ST, LIS);
1141 assert(BlockInfo.empty() &&
"Expect empty block infos");
1144 bool HaveVectorOp =
false;
1147 for (
const MachineBasicBlock &
MBB : MF) {
1148 VSETVLIInfo TmpStatus;
1149 HaveVectorOp |= computeVLVTYPEChanges(
MBB, TmpStatus);
1152 BBInfo.
Exit = TmpStatus;
1154 <<
" is " << BBInfo.
Exit <<
"\n");
1159 if (!HaveVectorOp) {
1167 for (
const MachineBasicBlock &
MBB : MF) {
1168 WorkList.push(&
MBB);
1171 while (!WorkList.empty()) {
1172 const MachineBasicBlock &
MBB = *WorkList.front();
1174 computeIncomingVLVTYPE(
MBB);
1178 for (MachineBasicBlock &
MBB : MF)
1185 for (MachineBasicBlock &
MBB : MF)
1198 coalesceVSETVLIs(*
MBB);
1200 if (ST->hasVendorXSfmmbase()) {
1201 for (MachineBasicBlock &
MBB : MF)
1202 coalesceVSETVLIsForTWiden(
MBB);
1207 for (MachineBasicBlock &
MBB : MF)
1210 if (ST->hasVendorXSfmmbase()) {
1211 for (MachineBasicBlock &
MBB : MF) {
1212 insertVSETMTK(
MBB, VSETTM);
1213 insertVSETMTK(
MBB, VSETTK);
1218 return HaveVectorOp;
1223 return new RISCVInsertVSETVLI();
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
Promote Memory to Register
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static VSETVLIInfo adjustIncoming(const VSETVLIInfo &PrevInfo, const VSETVLIInfo &NewInfo, DemandedFields &Demanded)
#define RISCV_INSERT_VSETVLI_NAME
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
SI Optimize VGPR LiveRange
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
LiveInterval - This class represents the liveness of a register, or stack slot.
void setWeight(float Value)
void removeAllRegUnitsForPhysReg(MCRegister Reg)
Remove associated live ranges for the register units associated with Reg.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
LLVM_ABI void handleMove(MachineInstr &MI, bool UpdateFlags=false)
Call this method to notify LiveIntervals that instruction MI has been moved within a basic block.
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
void RemoveMachineInstrFromMaps(MachineInstr &MI)
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
void removeInterval(Register Reg)
Interval removal.
LLVM_ABI bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses.
LLVM_ABI void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
LLVM_ABI void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval * > &SplitLIs)
Split separate components in LiveInterval LI into separate intervals.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
LiveInterval & createAndComputeVirtRegInterval(Register Reg)
LLVM_ABI iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
bool liveAt(SlotIndex index) const
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarily including Idx,...
bool containsOneValue() const
LLVM_ABI void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified interval from this live range.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
unsigned succ_size() const
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
iterator_range< iterator > terminators()
iterator_range< succ_iterator > successors()
LLVM_ABI instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
LLVM_ABI void moveBefore(MachineInstr *MovePos)
Move the instruction before MovePos.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsKill(bool Val=true)
Register getReg() const
getReg - Returns the register number.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
const TargetRegisterInfo * getTargetRegisterInfo() const
LLVM_ABI LLVM_READONLY MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
const RISCVOptions & getCLOpts() const
bool hasVInstructions() const
const RISCVRegisterInfo * getRegisterInfo() const override
const RISCVInstrInfo * getInstrInfo() const override
VSETVLIInfo getInfoForVSETVLI(const MachineInstr &MI) const
VSETVLIInfo computeInfoForInstr(const MachineInstr &MI) const
Defines the abstract state with which the forward dataflow models the values of the VL and VTYPE regi...
bool hasSameVTYPE(const VSETVLIInfo &Other) const
unsigned getTWiden() const
bool getMaskAgnostic() const
VSETVLIInfo intersect(const VSETVLIInfo &Other) const
void setAVLImm(unsigned Imm)
unsigned getSEWLMULRatio() const
void setVTYPE(unsigned VType)
Register getAVLReg() const
bool getTailAgnostic() const
bool hasSameVLMAX(const VSETVLIInfo &Other) const
bool isCompatible(const DemandedFields &Used, const VSETVLIInfo &Require, const LiveIntervals *LIS) const
bool hasSameAVL(const VSETVLIInfo &Other) const
const VNInfo * getAVLVNInfo() const
bool hasSEWLMULRatioOnly() const
RISCVVType::VLMUL getVLMUL() const
bool hasEquallyZeroAVL(const VSETVLIInfo &Other, const LiveIntervals *LIS) const
static VSETVLIInfo getUnknown()
void setAVL(const VSETVLIInfo &Info)
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
void push_back(const T &Elt)
VNInfo - Value Number Information.
SlotIndex def
The index of the defining instruction.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
static unsigned getTMOpNum(const MCInstrDesc &Desc)
static bool hasTWidenOp(uint64_t TSFlags)
static unsigned getTKOpNum(const MCInstrDesc &Desc)
static unsigned getVLOpNum(const MCInstrDesc &Desc)
static bool hasTKOp(uint64_t TSFlags)
static bool hasVLOp(uint64_t TSFlags)
static bool hasTMOp(uint64_t TSFlags)
static bool hasSEWOp(uint64_t TSFlags)
LLVM_ABI std::optional< VLMUL > getSameRatioLMUL(unsigned Ratio, unsigned EEW)
LLVM_ABI std::pair< unsigned, bool > decodeVLMUL(VLMUL VLMul)
static const MachineOperand & getVLOp(const MachineInstr &MI)
DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST)
Return the fields and properties demanded by the provided instruction.
bool areCompatibleVTYPEs(uint64_t CurVType, uint64_t NewVType, const DemandedFields &Used)
Return true if moving from CurVType to NewVType is indistinguishable from the perspective of an instr...
static VNInfo * getVNInfoFromReg(Register Reg, const MachineInstr &MI, const LiveIntervals *LIS)
Given a virtual register Reg, return the corresponding VNInfo for it.
bool isVectorCopy(const TargetRegisterInfo *TRI, const MachineInstr &MI)
Return true if MI is a copy that will be lowered to one or more vmvNr.vs.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createRISCVInsertVSETVLIPass()
Returns an instance of the Insert VSETVLI pass.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
auto post_order(const T &G)
Post-order traversal of a graph.
DWARFExpression::Operation Op
char & RISCVInsertVSETVLIID
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Which subfields of VL or VTYPE have values we need to preserve?
static DemandedFields all()
enum llvm::RISCV::DemandedFields::@326061152055210015167034143142117063364004052074 SEW
enum llvm::RISCV::DemandedFields::@201276154261047021277240313173154105356124146047 LMUL