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");
48 cl::desc(
"Insert vsetvlis before vmvNr.vs to ensure vtype is valid and "
64 return LI.getVNInfoBefore(
SI);
92 const RISCVSubtarget *ST;
93 const TargetInstrInfo *TII;
94 MachineRegisterInfo *MRI;
97 RISCVVSETVLIInfoAnalysis VIA;
99 std::vector<BlockData> BlockInfo;
100 std::queue<const MachineBasicBlock *> WorkList;
105 RISCVInsertVSETVLI() : MachineFunctionPass(ID) {}
108 void getAnalysisUsage(AnalysisUsage &AU)
const override {
123 bool needVSETVLI(
const DemandedFields &Used,
const VSETVLIInfo &Require,
124 const VSETVLIInfo &CurInfo)
const;
125 bool needVSETVLIPHI(
const VSETVLIInfo &Require,
126 const MachineBasicBlock &
MBB)
const;
127 void insertVSETVLI(MachineBasicBlock &
MBB,
129 const VSETVLIInfo &Info,
const VSETVLIInfo &PrevInfo);
131 void transferBefore(VSETVLIInfo &Info,
const MachineInstr &
MI)
const;
132 void transferAfter(VSETVLIInfo &Info,
const MachineInstr &
MI)
const;
133 bool computeVLVTYPEChanges(
const MachineBasicBlock &
MBB,
134 VSETVLIInfo &Info)
const;
135 void computeIncomingVLVTYPE(
const MachineBasicBlock &
MBB);
136 void emitVSETVLIs(MachineBasicBlock &
MBB);
137 void doPRE(MachineBasicBlock &
MBB);
138 void insertReadVL(MachineBasicBlock &
MBB);
140 bool canMutatePriorConfig(
const MachineInstr &PrevMI,
const MachineInstr &
MI,
141 const DemandedFields &Used,
142 MachineInstr *&AVLDefToMove)
const;
143 void coalesceVSETVLIs(MachineBasicBlock &
MBB)
const;
144 bool canMutatePriorConfigWithTWiden(
const MachineInstr &PrevMI,
145 const MachineInstr &
MI)
const;
146 void coalesceVSETVLIsForTWiden(MachineBasicBlock &
MBB)
const;
147 bool insertVSETMTK(MachineBasicBlock &
MBB, TKTMMode
Mode)
const;
152char RISCVInsertVSETVLI::ID = 0;
164 if (PrevInfo.isKnown()) {
167 if (Info.hasSameAVL(PrevInfo) && Info.hasSameVLMAX(PrevInfo)) {
168 auto MI = BuildMI(MBB, InsertPt, DL,
169 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0X0
170 : RISCV::PseudoVSETVLIX0X0))
171 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
172 .addReg(RISCV::X0, RegState::Kill)
173 .addImm(Info.encodeVTYPE())
174 .addReg(RISCV::VL, RegState::Implicit);
176 LIS->InsertMachineInstrInMaps(*MI);
183 if (Info.hasSameVLMAX(PrevInfo) && Info.hasAVLReg()) {
184 if (const MachineInstr *DefMI = Info.getAVLDefMI(LIS);
185 DefMI && RISCVInstrInfo::isVectorConfigInstr(*DefMI)) {
186 VSETVLIInfo DefInfo = VIA.getInfoForVSETVLI(*DefMI);
187 if (DefInfo.hasSameAVL(PrevInfo) && DefInfo.hasSameVLMAX(PrevInfo)) {
189 BuildMI(MBB, InsertPt, DL,
190 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0X0
191 : RISCV::PseudoVSETVLIX0X0))
192 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
193 .addReg(RISCV::X0, RegState::Kill)
194 .addImm(Info.encodeVTYPE())
195 .addReg(RISCV::VL, RegState::Implicit);
197 LIS->InsertMachineInstrInMaps(*MI);
204 if (Info.hasAVLImm()) {
205 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETIVLI))
206 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
207 .addImm(Info.getAVLImm())
208 .addImm(Info.encodeVTYPE());
210 LIS->InsertMachineInstrInMaps(*MI);
214 if (Info.hasAVLVLMAX()) {
215 Register DestReg = MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
216 auto MI = BuildMI(MBB, InsertPt, DL,
217 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNTX0
218 : RISCV::PseudoVSETVLIX0))
219 .addReg(DestReg, RegState::Define | RegState::Dead)
220 .addReg(RISCV::X0, RegState::Kill)
221 .addImm(Info.encodeVTYPE());
223 LIS->InsertMachineInstrInMaps(*MI);
224 LIS->createAndComputeVirtRegInterval(DestReg);
230 MRI->constrainRegClass(AVLReg, &RISCV::GPRNoX0RegClass);
232 TII->get(Info.getTWiden() ? RISCV::PseudoSF_VSETTNT
233 : RISCV::PseudoVSETVLI))
236 .
addImm(Info.encodeVTYPE());
241 const VNInfo *CurVNI = Info.getAVLVNInfo();
249 MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
253 II =
MBB->getFirstNonPHI();
262 MI->getOperand(1).setReg(AVLCopyReg);
294 Info.setVLMul(*NewVLMul);
304void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
305 const MachineInstr &
MI)
const {
308 (!
Info.isKnown() ||
Info.hasSEWLMULRatioOnly())) {
326 if (
Info.isValid() && !needVSETVLI(Demanded, NewInfo, Info))
329 const VSETVLIInfo PrevInfo =
Info;
333 const VSETVLIInfo IncomingInfo =
adjustIncoming(PrevInfo, NewInfo, Demanded);
345 Info.setAVL(IncomingInfo);
348 if (
Info.hasSEWLMULRatioOnly()) {
349 VSETVLIInfo RatiolessInfo = IncomingInfo;
350 RatiolessInfo.
setAVL(Info);
351 Info = RatiolessInfo;
362 (Demanded.
TailPolicy ? IncomingInfo : Info).getTailAgnostic() ||
364 (Demanded.
MaskPolicy ? IncomingInfo : Info).getMaskAgnostic() ||
367 (Demanded.
AltFmt ? IncomingInfo : Info).getAltFmt() && SEW < 32,
375void RISCVInsertVSETVLI::transferAfter(VSETVLIInfo &Info,
376 const MachineInstr &
MI)
const {
377 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
385 if (RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(
MI))
388 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
390 assert(
MI.getOperand(1).getReg().isVirtual());
396 Info.setAVLRegDef(VNI,
MI.getOperand(1).getReg());
398 Info.setAVLRegDef(
nullptr,
MI.getOperand(1).getReg());
404 if (
MI.isCall() ||
MI.isInlineAsm() ||
405 MI.modifiesRegister(RISCV::VL,
nullptr) ||
406 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
410bool RISCVInsertVSETVLI::computeVLVTYPEChanges(
const MachineBasicBlock &
MBB,
411 VSETVLIInfo &Info)
const {
412 bool HadVectorOp =
false;
415 for (
const MachineInstr &
MI :
MBB) {
416 transferBefore(Info,
MI);
418 if (RISCVInstrInfo::isVectorConfigInstr(
MI) ||
421 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI))
424 transferAfter(Info,
MI);
430void RISCVInsertVSETVLI::computeIncomingVLVTYPE(
const MachineBasicBlock &
MBB) {
434 BBInfo.InQueue =
false;
438 VSETVLIInfo InInfo = BBInfo.
Pred;
444 InInfo = InInfo.
intersect(BlockInfo[
P->getNumber()].Exit);
452 if (InInfo == BBInfo.
Pred)
455 BBInfo.
Pred = InInfo;
457 <<
" changed to " << BBInfo.
Pred <<
"\n");
463 VSETVLIInfo TmpStatus;
464 computeVLVTYPEChanges(
MBB, TmpStatus);
468 if (BBInfo.
Exit == TmpStatus)
471 BBInfo.
Exit = TmpStatus;
473 <<
" changed to " << BBInfo.
Exit <<
"\n");
478 if (!BlockInfo[S->getNumber()].InQueue) {
479 BlockInfo[S->getNumber()].InQueue =
true;
487bool RISCVInsertVSETVLI::needVSETVLIPHI(
const VSETVLIInfo &Require,
488 const MachineBasicBlock &
MBB)
const {
503 const VSETVLIInfo &PBBExit = BlockInfo[PBB->getNumber()].Exit;
510 if (!
DefMI || !RISCVInstrInfo::isVectorConfigInstr(*
DefMI))
516 if (DefInfo != PBBExit)
531void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &
MBB) {
535 bool PrefixTransparent =
true;
536 for (MachineInstr &
MI :
MBB) {
537 const VSETVLIInfo PrevInfo = CurInfo;
538 transferBefore(CurInfo,
MI);
541 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
543 assert(
MI.getOperand(3).getReg() == RISCV::VL &&
544 MI.getOperand(4).getReg() == RISCV::VTYPE &&
545 "Unexpected operands where VL and VTYPE should be");
546 MI.getOperand(3).setIsDead(
false);
547 MI.getOperand(4).setIsDead(
false);
548 PrefixTransparent =
false;
554 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
555 PrefixTransparent =
false;
571 if (!PrefixTransparent || needVSETVLIPHI(CurInfo,
MBB))
572 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
573 PrefixTransparent =
false;
597 for (MachineInstr *DeadMI : DeadMIs) {
598 if (!
TII->isAddImmediate(*DeadMI,
Reg))
601 Register AddReg = DeadMI->getOperand(1).getReg();
602 DeadMI->eraseFromParent();
615 if (
MI.isInlineAsm()) {
622 if (
MI.isCall() ||
MI.isInlineAsm() ||
623 MI.modifiesRegister(RISCV::VL,
nullptr) ||
624 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
625 PrefixTransparent =
false;
627 transferAfter(CurInfo,
MI);
631 if (CurInfo !=
Info.Exit) {
637 assert(CurInfo ==
Info.Exit &&
"InsertVSETVLI dataflow invariant violated");
645void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &
MBB) {
649 MachineBasicBlock *UnavailablePred =
nullptr;
650 VSETVLIInfo AvailableInfo;
652 const VSETVLIInfo &PredInfo = BlockInfo[
P->getNumber()].Exit;
657 }
else if (!AvailableInfo.
isValid()) {
658 AvailableInfo = PredInfo;
659 }
else if (AvailableInfo != PredInfo) {
666 if (!UnavailablePred || !AvailableInfo.
isValid())
704 VSETVLIInfo CurInfo = AvailableInfo;
705 int TransitionsRemoved = 0;
706 for (
const MachineInstr &
MI :
MBB) {
707 const VSETVLIInfo LastInfo = CurInfo;
708 const VSETVLIInfo LastOldInfo = OldInfo;
709 transferBefore(CurInfo,
MI);
710 transferBefore(OldInfo,
MI);
711 if (CurInfo == LastInfo)
712 TransitionsRemoved++;
713 if (LastOldInfo == OldInfo)
714 TransitionsRemoved--;
715 transferAfter(CurInfo,
MI);
716 transferAfter(OldInfo,
MI);
717 if (CurInfo == OldInfo)
721 if (CurInfo != OldInfo || TransitionsRemoved <= 0)
728 auto OldExit = BlockInfo[UnavailablePred->
getNumber()].Exit;
730 << UnavailablePred->
getName() <<
" with state "
731 << AvailableInfo <<
"\n");
732 BlockInfo[UnavailablePred->
getNumber()].Exit = AvailableInfo;
738 insertVSETVLI(*UnavailablePred, InsertPt,
740 AvailableInfo, OldExit);
747bool RISCVInsertVSETVLI::canMutatePriorConfig(
748 const MachineInstr &PrevMI,
const MachineInstr &
MI,
749 const DemandedFields &Used, MachineInstr *&AVLDefToMove)
const {
750 AVLDefToMove =
nullptr;
754 if (!RISCVInstrInfo::isVLPreservingConfig(
MI)) {
758 if (
Used.VLZeroness) {
759 if (RISCVInstrInfo::isVLPreservingConfig(PrevMI))
766 auto &AVL =
MI.getOperand(1);
770 if (AVL.isReg() && AVL.getReg() != RISCV::X0) {
773 if (!VNI || !PrevVNI || VNI != PrevVNI) {
780 if (!AVL.getReg().isVirtual())
784 if (!
DefMI || !RISCVInstrInfo::isLoadImmediate(*
DefMI) ||
789 AVLDefToMove =
DefMI;
804 auto VType =
MI.getOperand(2).getImm();
808void RISCVInsertVSETVLI::coalesceVSETVLIs(MachineBasicBlock &
MBB)
const {
809 MachineInstr *NextMI =
nullptr;
817 auto dropAVLUse = [&](MachineOperand &MO) {
818 if (!MO.isReg() || !MO.getReg().isVirtual())
827 if (VLOpDef &&
TII->isAddImmediate(*VLOpDef, OldVLReg) &&
835 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI)) {
840 if (!RISCVInstrInfo::isVectorConfigInstr(
MI)) {
842 if (
MI.isCall() ||
MI.isInlineAsm() ||
843 MI.modifiesRegister(RISCV::VL,
nullptr) ||
844 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
849 if (!
MI.getOperand(0).isDead())
853 if (!
Used.usedVL() && !
Used.usedVTYPE()) {
854 dropAVLUse(
MI.getOperand(1));
857 MI.eraseFromParent();
858 NumCoalescedVSETVL++;
863 MachineInstr *AVLDefToMove =
nullptr;
864 if (canMutatePriorConfig(
MI, *NextMI, Used, AVLDefToMove)) {
865 if (!RISCVInstrInfo::isVLPreservingConfig(*NextMI)) {
868 MI.getOperand(0).setReg(DefReg);
869 MI.getOperand(0).setIsDead(
false);
872 dropAVLUse(
MI.getOperand(1));
894 SlotIndex NextMISlot =
897 LiveInterval::Segment S(MISlot, NextMISlot, DefVNI);
899 DefVNI->
def = MISlot;
916 NumCoalescedVSETVL++;
926 for (
auto *
MI : ToDelete) {
927 assert(
MI->getOpcode() == RISCV::ADDI);
933 MI->eraseFromParent();
961bool RISCVInsertVSETVLI::canMutatePriorConfigWithTWiden(
962 const MachineInstr &PrevMI,
const MachineInstr &
MI)
const {
964 if (PrevMI.
getOpcode() != RISCV::PseudoVSETVLI)
967 if (
MI.getOpcode() != RISCV::PseudoSF_VSETTNT)
973 assert(CurrInfo.hasAVLReg() &&
"Invalid PseudoSF_VSETTNT without an AVLReg.");
975 auto AVLReg = CurrInfo.getAVLReg();
982 if (!RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(*AVLRegDefMI))
986 if (AVLRegDefMIInfo.getTWiden() != CurrInfo.getTWiden())
989 if (AVLRegDefMIInfo.getSEW() != PrevInfo.
getSEW())
999 if (PrevInfo.
getSEW() != CurrInfo.getSEW())
1002 if (PrevInfo.
getAltFmt() != CurrInfo.getAltFmt())
1009 unsigned KMAX = (CurrInfo.getSEW() >= 32) ? 1 : (32 / CurrInfo.getSEW());
1011 if (Fractional || LMul < (8 / KMAX))
1017void RISCVInsertVSETVLI::coalesceVSETVLIsForTWiden(
1018 MachineBasicBlock &
MBB)
const {
1019 MachineInstr *NextMI =
nullptr;
1023 if (!RISCVInstrInfo::isVectorConfigInstr(
MI))
1028 if (canMutatePriorConfigWithTWiden(
MI, *NextMI)) {
1031 MI.getOperand(2).setImm(NextInfo.encodeVTYPE());
1042void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &
MBB) {
1044 MachineInstr &
MI = *
I++;
1045 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
1046 Register VLOutput =
MI.getOperand(1).getReg();
1048 if (!
MI.getOperand(1).isDead()) {
1050 TII->get(RISCV::PseudoReadVL), VLOutput);
1053 SlotIndex NewDefSI =
1059 DefVNI->
def = NewDefSI;
1063 MI.getOperand(1).setReg(RISCV::X0);
1069bool RISCVInsertVSETVLI::insertVSETMTK(MachineBasicBlock &
MBB,
1070 TKTMMode
Mode)
const {
1073 for (
auto &
MI :
MBB) {
1075 if (RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(
MI) ||
1081 unsigned Opcode = 0, OpNum = 0;
1087 Opcode = RISCV::PseudoSF_VSETTK;
1093 Opcode = RISCV::PseudoSF_VSETTM;
1097 assert(OpNum && Opcode &&
"Invalid OpNum or Opcode");
1099 MachineOperand &
Op =
MI.getOperand(OpNum);
1102 .
addReg(RISCV::X0, RegState::Define | RegState::Dead)
1110 Op.setIsKill(
false);
1135 auto *LISWrapper = getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
1136 LIS = LISWrapper ? &LISWrapper->getLIS() :
nullptr;
1137 VIA = RISCVVSETVLIInfoAnalysis(ST, LIS);
1139 assert(BlockInfo.empty() &&
"Expect empty block infos");
1142 bool HaveVectorOp =
false;
1145 for (
const MachineBasicBlock &
MBB : MF) {
1146 VSETVLIInfo TmpStatus;
1147 HaveVectorOp |= computeVLVTYPEChanges(
MBB, TmpStatus);
1150 BBInfo.
Exit = TmpStatus;
1152 <<
" is " << BBInfo.
Exit <<
"\n");
1157 if (!HaveVectorOp) {
1165 for (
const MachineBasicBlock &
MBB : MF) {
1166 WorkList.push(&
MBB);
1169 while (!WorkList.empty()) {
1170 const MachineBasicBlock &
MBB = *WorkList.front();
1172 computeIncomingVLVTYPE(
MBB);
1176 for (MachineBasicBlock &
MBB : MF)
1183 for (MachineBasicBlock &
MBB : MF)
1196 coalesceVSETVLIs(*
MBB);
1198 if (ST->hasVendorXSfmmbase()) {
1199 for (MachineBasicBlock &
MBB : MF)
1200 coalesceVSETVLIsForTWiden(
MBB);
1205 for (MachineBasicBlock &
MBB : MF)
1208 if (ST->hasVendorXSfmmbase()) {
1209 for (MachineBasicBlock &
MBB : MF) {
1210 insertVSETMTK(
MBB, VSETTM);
1211 insertVSETMTK(
MBB, VSETTK);
1216 return HaveVectorOp;
1221 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 cl::opt< bool > EnsureWholeVectorRegisterMoveValidVTYPE(DEBUG_TYPE "-whole-vector-register-move-valid-vtype", cl::Hidden, cl::desc("Insert vsetvlis before vmvNr.vs to ensure vtype is valid and " "vill is cleared"), cl::init(true))
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)
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.
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...
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.
initializer< Ty > init(const Ty &Val)
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.
@ Define
Register definition.
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