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) {}
106 bool runOnMachineFunction(MachineFunction &MF)
override;
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)
const;
142 void coalesceVSETVLIs(MachineBasicBlock &
MBB)
const;
143 bool insertVSETMTK(MachineBasicBlock &
MBB, TKTMMode
Mode)
const;
148char RISCVInsertVSETVLI::ID = 0;
160 if (
Info.getTWiden()) {
161 if (Info.hasAVLVLMAX()) {
162 Register DestReg = MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
163 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoSF_VSETTNTX0))
164 .addReg(DestReg, RegState::Define | RegState::Dead)
165 .addReg(RISCV::X0, RegState::Kill)
166 .addImm(Info.encodeVTYPE());
168 LIS->InsertMachineInstrInMaps(*MI);
169 LIS->createAndComputeVirtRegInterval(DestReg);
172 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoSF_VSETTNT))
173 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
174 .addReg(Info.getAVLReg())
175 .addImm(Info.encodeVTYPE());
177 LIS->InsertMachineInstrInMaps(*MI);
182 if (PrevInfo.isValid() && !PrevInfo.isUnknown()) {
185 if (Info.hasSameAVL(PrevInfo) && Info.hasSameVLMAX(PrevInfo)) {
186 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLIX0X0))
187 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
188 .addReg(RISCV::X0, RegState::Kill)
189 .addImm(Info.encodeVTYPE())
190 .addReg(RISCV::VL, RegState::Implicit);
192 LIS->InsertMachineInstrInMaps(*MI);
199 if (
Info.hasSameVLMAX(PrevInfo) &&
Info.hasAVLReg()) {
200 if (const MachineInstr *DefMI = Info.getAVLDefMI(LIS);
201 DefMI && RISCVInstrInfo::isVectorConfigInstr(*DefMI)) {
202 VSETVLIInfo DefInfo = VIA.getInfoForVSETVLI(*DefMI);
203 if (DefInfo.hasSameAVL(PrevInfo) && DefInfo.hasSameVLMAX(PrevInfo)) {
205 BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLIX0X0))
206 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
207 .addReg(RISCV::X0, RegState::Kill)
208 .addImm(Info.encodeVTYPE())
209 .addReg(RISCV::VL, RegState::Implicit);
211 LIS->InsertMachineInstrInMaps(*MI);
218 if (
Info.hasAVLImm()) {
219 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETIVLI))
220 .addReg(RISCV::X0, RegState::Define | RegState::Dead)
221 .addImm(Info.getAVLImm())
222 .addImm(Info.encodeVTYPE());
224 LIS->InsertMachineInstrInMaps(*MI);
229 Register DestReg = MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
230 auto MI = BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLIX0))
231 .addReg(DestReg, RegState::Define | RegState::Dead)
232 .addReg(RISCV::X0, RegState::Kill)
233 .addImm(Info.encodeVTYPE());
235 LIS->InsertMachineInstrInMaps(*MI);
236 LIS->createAndComputeVirtRegInterval(DestReg);
242 MRI->constrainRegClass(AVLReg, &RISCV::GPRNoX0RegClass);
259 MRI->createVirtualRegister(&RISCV::GPRNoX0RegClass);
263 II =
MBB->getFirstNonPHI();
272 MI->getOperand(1).setReg(AVLCopyReg);
305 Info.setVLMul(*NewVLMul);
315void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &
Info,
316 const MachineInstr &
MI)
const {
318 (
Info.isUnknown() || !
Info.isValid() ||
Info.hasSEWLMULRatioOnly())) {
336 if (
Info.isValid() && !needVSETVLI(Demanded, NewInfo,
Info))
339 const VSETVLIInfo PrevInfo =
Info;
340 if (!
Info.isValid() ||
Info.isUnknown())
343 const VSETVLIInfo IncomingInfo =
adjustIncoming(PrevInfo, NewInfo, Demanded);
355 Info.setAVL(IncomingInfo);
358 if (
Info.hasSEWLMULRatioOnly()) {
359 VSETVLIInfo RatiolessInfo = IncomingInfo;
361 Info = RatiolessInfo;
374 (Demanded.
AltFmt ? IncomingInfo :
Info).getAltFmt(),
382void RISCVInsertVSETVLI::transferAfter(VSETVLIInfo &
Info,
383 const MachineInstr &
MI)
const {
384 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
389 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
391 assert(
MI.getOperand(1).getReg().isVirtual());
397 Info.setAVLRegDef(VNI,
MI.getOperand(1).getReg());
399 Info.setAVLRegDef(
nullptr,
MI.getOperand(1).getReg());
405 if (
MI.isCall() ||
MI.isInlineAsm() ||
406 MI.modifiesRegister(RISCV::VL,
nullptr) ||
407 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
411bool RISCVInsertVSETVLI::computeVLVTYPEChanges(
const MachineBasicBlock &
MBB,
412 VSETVLIInfo &
Info)
const {
413 bool HadVectorOp =
false;
416 for (
const MachineInstr &
MI :
MBB) {
419 if (RISCVInstrInfo::isVectorConfigInstr(
MI) ||
422 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI))
431void RISCVInsertVSETVLI::computeIncomingVLVTYPE(
const MachineBasicBlock &
MBB) {
435 BBInfo.InQueue =
false;
439 VSETVLIInfo InInfo = BBInfo.
Pred;
445 InInfo = InInfo.
intersect(BlockInfo[
P->getNumber()].Exit);
453 if (InInfo == BBInfo.
Pred)
456 BBInfo.
Pred = InInfo;
458 <<
" changed to " << BBInfo.
Pred <<
"\n");
464 VSETVLIInfo TmpStatus;
465 computeVLVTYPEChanges(
MBB, TmpStatus);
469 if (BBInfo.
Exit == TmpStatus)
472 BBInfo.
Exit = TmpStatus;
474 <<
" changed to " << BBInfo.
Exit <<
"\n");
479 if (!BlockInfo[S->getNumber()].InQueue) {
480 BlockInfo[S->getNumber()].InQueue =
true;
488bool RISCVInsertVSETVLI::needVSETVLIPHI(
const VSETVLIInfo &Require,
489 const MachineBasicBlock &
MBB)
const {
504 const VSETVLIInfo &PBBExit = BlockInfo[PBB->getNumber()].Exit;
511 if (!
DefMI || !RISCVInstrInfo::isVectorConfigInstr(*
DefMI))
517 if (DefInfo != PBBExit)
532void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &
MBB) {
536 bool PrefixTransparent =
true;
537 for (MachineInstr &
MI :
MBB) {
538 const VSETVLIInfo PrevInfo = CurInfo;
539 transferBefore(CurInfo,
MI);
542 if (RISCVInstrInfo::isVectorConfigInstr(
MI)) {
544 assert(
MI.getOperand(3).getReg() == RISCV::VL &&
545 MI.getOperand(4).getReg() == RISCV::VTYPE &&
546 "Unexpected operands where VL and VTYPE should be");
547 MI.getOperand(3).setIsDead(
false);
548 MI.getOperand(4).setIsDead(
false);
549 PrefixTransparent =
false;
555 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
556 PrefixTransparent =
false;
562 uint64_t TSFlags =
MI.getDesc().TSFlags;
572 if (!PrefixTransparent || needVSETVLIPHI(CurInfo,
MBB))
573 insertVSETVLI(
MBB,
MI,
MI.getDebugLoc(), CurInfo, PrevInfo);
574 PrefixTransparent =
false;
598 for (MachineInstr *DeadMI : DeadMIs) {
599 if (!
TII->isAddImmediate(*DeadMI,
Reg))
602 Register AddReg = DeadMI->getOperand(1).getReg();
603 DeadMI->eraseFromParent();
616 if (
MI.isInlineAsm()) {
623 if (
MI.isCall() ||
MI.isInlineAsm() ||
624 MI.modifiesRegister(RISCV::VL,
nullptr) ||
625 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
626 PrefixTransparent =
false;
628 transferAfter(CurInfo,
MI);
632 if (CurInfo !=
Info.Exit) {
638 assert(CurInfo ==
Info.Exit &&
"InsertVSETVLI dataflow invariant violated");
646void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &
MBB) {
650 MachineBasicBlock *UnavailablePred =
nullptr;
651 VSETVLIInfo AvailableInfo;
653 const VSETVLIInfo &PredInfo = BlockInfo[
P->getNumber()].Exit;
658 }
else if (!AvailableInfo.
isValid()) {
659 AvailableInfo = PredInfo;
660 }
else if (AvailableInfo != PredInfo) {
667 if (!UnavailablePred || !AvailableInfo.
isValid())
705 VSETVLIInfo CurInfo = AvailableInfo;
706 int TransitionsRemoved = 0;
707 for (
const MachineInstr &
MI :
MBB) {
708 const VSETVLIInfo LastInfo = CurInfo;
709 const VSETVLIInfo LastOldInfo = OldInfo;
710 transferBefore(CurInfo,
MI);
711 transferBefore(OldInfo,
MI);
712 if (CurInfo == LastInfo)
713 TransitionsRemoved++;
714 if (LastOldInfo == OldInfo)
715 TransitionsRemoved--;
716 transferAfter(CurInfo,
MI);
717 transferAfter(OldInfo,
MI);
718 if (CurInfo == OldInfo)
722 if (CurInfo != OldInfo || TransitionsRemoved <= 0)
729 auto OldExit = BlockInfo[UnavailablePred->
getNumber()].Exit;
731 << UnavailablePred->
getName() <<
" with state "
732 << AvailableInfo <<
"\n");
733 BlockInfo[UnavailablePred->
getNumber()].Exit = AvailableInfo;
739 insertVSETVLI(*UnavailablePred, InsertPt,
741 AvailableInfo, OldExit);
746bool RISCVInsertVSETVLI::canMutatePriorConfig(
747 const MachineInstr &PrevMI,
const MachineInstr &
MI,
748 const DemandedFields &Used)
const {
752 if (!RISCVInstrInfo::isVLPreservingConfig(
MI)) {
756 if (
Used.VLZeroness) {
757 if (RISCVInstrInfo::isVLPreservingConfig(PrevMI))
764 auto &AVL =
MI.getOperand(1);
768 if (AVL.isReg() && AVL.getReg() != RISCV::X0) {
771 if (!VNI || !PrevVNI || VNI != PrevVNI)
786 auto VType =
MI.getOperand(2).getImm();
790void RISCVInsertVSETVLI::coalesceVSETVLIs(MachineBasicBlock &
MBB)
const {
791 MachineInstr *NextMI =
nullptr;
799 auto dropAVLUse = [&](MachineOperand &MO) {
800 if (!MO.isReg() || !MO.getReg().isVirtual())
808 MachineInstr *VLOpDef =
MRI->getUniqueVRegDef(OldVLReg);
809 if (VLOpDef &&
TII->isAddImmediate(*VLOpDef, OldVLReg) &&
810 MRI->use_nodbg_empty(OldVLReg))
817 RISCVInstrInfo::isXSfmmVectorConfigInstr(
MI)) {
822 if (!RISCVInstrInfo::isVectorConfigInstr(
MI)) {
824 if (
MI.isCall() ||
MI.isInlineAsm() ||
825 MI.modifiesRegister(RISCV::VL,
nullptr) ||
826 MI.modifiesRegister(RISCV::VTYPE,
nullptr))
831 if (!
MI.getOperand(0).isDead())
835 if (!
Used.usedVL() && !
Used.usedVTYPE()) {
836 dropAVLUse(
MI.getOperand(1));
839 MI.eraseFromParent();
840 NumCoalescedVSETVL++;
845 if (canMutatePriorConfig(
MI, *NextMI, Used)) {
846 if (!RISCVInstrInfo::isVLPreservingConfig(*NextMI)) {
849 MI.getOperand(0).setReg(DefReg);
850 MI.getOperand(0).setIsDead(
false);
853 dropAVLUse(
MI.getOperand(1));
866 SlotIndex NextMISlot =
869 LiveInterval::Segment S(MISlot, NextMISlot, DefVNI);
871 DefVNI->
def = MISlot;
888 NumCoalescedVSETVL++;
898 for (
auto *
MI : ToDelete) {
899 assert(
MI->getOpcode() == RISCV::ADDI);
905 MI->eraseFromParent();
911void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &
MBB) {
913 MachineInstr &
MI = *
I++;
914 if (RISCVInstrInfo::isFaultOnlyFirstLoad(
MI)) {
915 Register VLOutput =
MI.getOperand(1).getReg();
917 if (!
MI.getOperand(1).isDead()) {
919 TII->get(RISCV::PseudoReadVL), VLOutput);
928 DefVNI->
def = NewDefSI;
932 MI.getOperand(1).setReg(RISCV::X0);
933 MI.addRegisterDefined(RISCV::VL,
MRI->getTargetRegisterInfo());
938bool RISCVInsertVSETVLI::insertVSETMTK(MachineBasicBlock &
MBB,
939 TKTMMode
Mode)
const {
942 for (
auto &
MI :
MBB) {
943 uint64_t TSFlags =
MI.getDesc().TSFlags;
944 if (RISCVInstrInfo::isXSfmmVectorConfigTMTKInstr(
MI) ||
961 Opcode = RISCV::PseudoSF_VSETTK;
965 Opcode = RISCV::PseudoSF_VSETTM;
969 assert(OpNum && Opcode &&
"Invalid OpNum or Opcode");
971 MachineOperand &
Op =
MI.getOperand(OpNum);
997bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) {
1007 auto *LISWrapper = getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
1008 LIS = LISWrapper ? &LISWrapper->getLIS() :
nullptr;
1009 VIA = RISCVVSETVLIInfoAnalysis(ST, LIS);
1011 assert(BlockInfo.empty() &&
"Expect empty block infos");
1014 bool HaveVectorOp =
false;
1017 for (
const MachineBasicBlock &
MBB : MF) {
1018 VSETVLIInfo TmpStatus;
1019 HaveVectorOp |= computeVLVTYPEChanges(
MBB, TmpStatus);
1022 BBInfo.
Exit = TmpStatus;
1024 <<
" is " << BBInfo.
Exit <<
"\n");
1029 if (!HaveVectorOp) {
1037 for (
const MachineBasicBlock &
MBB : MF) {
1038 WorkList.push(&
MBB);
1041 while (!WorkList.empty()) {
1042 const MachineBasicBlock &
MBB = *WorkList.front();
1044 computeIncomingVLVTYPE(
MBB);
1048 for (MachineBasicBlock &
MBB : MF)
1055 for (MachineBasicBlock &
MBB : MF)
1068 coalesceVSETVLIs(*
MBB);
1072 for (MachineBasicBlock &
MBB : MF)
1075 for (MachineBasicBlock &
MBB : MF) {
1076 insertVSETMTK(
MBB, VSETTM);
1077 insertVSETMTK(
MBB, VSETTK);
1081 return HaveVectorOp;
1086 return new RISCVInsertVSETVLI();
unsigned const MachineRegisterInfo * MRI
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")
Analysis containing CSE Info
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)
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 & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const MachineOperand & getOperand(unsigned i) const
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 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
const VNInfo * getAVLVNInfo() const
bool hasSEWLMULRatioOnly() 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)
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.
static unsigned getVLOpNum(const MachineInstr &MI)
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.
@ Define
Register definition.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
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...
iterator_range< po_iterator< T > > post_order(const T &G)
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...
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