124#define DEBUG_TYPE "expand-condsets"
146 StringRef getPassName()
const override {
return "Hexagon Expand Condsets"; }
148 void getAnalysisUsage(AnalysisUsage &AU)
const override {
160 const HexagonInstrInfo *HII =
nullptr;
161 const TargetRegisterInfo *TRI =
nullptr;
162 MachineDominatorTree *MDT;
163 MachineRegisterInfo *MRI =
nullptr;
164 LiveIntervals *LIS =
nullptr;
165 bool CoaLimitActive =
false;
166 bool TfrLimitActive =
false;
169 unsigned CoaCounter = 0;
170 unsigned TfrCounter = 0;
171 SmallPtrSet<const MachineOperand *, 16> KilledUses;
175 RegisterRef(
const MachineOperand &
Op) : Reg(
Op.
getReg()),
176 Sub(
Op.getSubReg()) {}
177 RegisterRef(
unsigned R = 0,
unsigned S = 0) : Reg(
R), Sub(S) {}
180 return Reg == RR.Reg && Sub == RR.Sub;
184 return Reg < RR.Reg || (Reg == RR.Reg && Sub < RR.Sub);
191 using ReferenceMap = DenseMap<unsigned, unsigned>;
192 enum { Sub_Low = 0x1, Sub_High = 0x2, Sub_None = (Sub_Low | Sub_High) };
193 enum { Exec_Then = 0x10, Exec_Else = 0x20 };
195 unsigned getMaskForSub(
unsigned Sub);
196 bool isCondset(
const MachineInstr &
MI);
199 void addRefToMap(RegisterRef RR, ReferenceMap &Map,
unsigned Exec);
200 bool isRefInMap(RegisterRef, ReferenceMap &Map,
unsigned Exec);
206 void removeInstr(MachineInstr &
MI);
207 void updateLiveness(
const std::set<Register> &RegSet,
bool Recalc,
208 bool UpdateKills,
bool UpdateDeads);
209 void distributeLiveIntervals(
const std::set<Register> &Regs);
211 unsigned getCondTfrOpcode(
const MachineOperand &SO,
bool Cond);
212 MachineInstr *genCondTfrFor(MachineOperand &SrcOp,
214 unsigned DstSR,
const MachineOperand &PredOp,
bool PredSense,
215 bool ReadUndef,
bool ImpUse);
216 bool split(MachineInstr &
MI, std::set<Register> &UpdRegs);
218 bool isPredicable(MachineInstr *
MI);
219 MachineInstr *getReachingDefForPred(RegisterRef RD,
221 bool canMoveOver(MachineInstr &
MI, ReferenceMap &Defs, ReferenceMap &
Uses);
222 bool canMoveMemTo(MachineInstr &
MI, MachineInstr &ToI,
bool IsDown);
223 void predicateAt(
const MachineOperand &DefOp, MachineInstr &
MI,
225 const MachineOperand &PredOp,
bool Cond,
226 std::set<Register> &UpdRegs);
227 void renameInRange(RegisterRef RO, RegisterRef RN,
unsigned PredR,
230 bool predicate(MachineInstr &TfrI,
bool Cond, std::set<Register> &UpdRegs);
231 bool predicateInBlock(MachineBasicBlock &
B, std::set<Register> &UpdRegs);
233 bool isIntReg(RegisterRef RR,
unsigned &BW);
234 bool isIntraBlocks(LiveInterval &LI);
235 bool coalesceRegisters(RegisterRef R1, RegisterRef
R2);
236 bool coalesceSegments(
const SmallVectorImpl<MachineInstr *> &
Condsets,
237 std::set<Register> &UpdRegs);
242char HexagonExpandCondsets::ID = 0;
246 "Hexagon Expand Condsets",
false,
false)
253unsigned HexagonExpandCondsets::getMaskForSub(
unsigned Sub) {
255 case Hexagon::isub_lo:
256 case Hexagon::vsub_lo:
258 case Hexagon::isub_hi:
259 case Hexagon::vsub_hi:
261 case Hexagon::NoSubRegister:
268 unsigned Opc =
MI.getOpcode();
270 case Hexagon::C2_mux:
271 case Hexagon::C2_muxii:
272 case Hexagon::C2_muxir:
273 case Hexagon::C2_muxri:
274 case Hexagon::PS_pselect:
281LaneBitmask HexagonExpandCondsets::getLaneMask(
Register Reg,
unsigned Sub) {
283 return Sub != 0 ?
TRI->getSubRegIndexLaneMask(
Sub)
287void HexagonExpandCondsets::addRefToMap(RegisterRef RR, ReferenceMap &Map,
289 unsigned Mask = getMaskForSub(RR.Sub) |
Exec;
293bool HexagonExpandCondsets::isRefInMap(RegisterRef RR, ReferenceMap &Map,
295 ReferenceMap::iterator
F =
Map.find(RR.Reg);
298 unsigned Mask = getMaskForSub(RR.Sub) |
Exec;
299 if (Mask &
F->second)
304void HexagonExpandCondsets::computeKills(
Register Reg) {
305 auto KillAt = [
this,
Reg](SlotIndex
K, LaneBitmask LM) ->
void {
308 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
309 MachineOperand &
Op =
MI->getOperand(i);
310 if (!
Op.isReg() || !
Op.isUse() ||
Op.getReg() !=
Reg ||
311 MI->isRegTiedToDefOperand(i))
313 LaneBitmask SLM = getLaneMask(
Reg,
Op.getSubReg());
314 if ((SLM & LM) == SLM) {
316 KilledUses.insert(&
Op);
323 KilledUses.erase(&
Op);
327 if (!
I->end.isRegister())
331 auto NextI = std::next(
I);
332 if (NextI !=
E && NextI->start.isRegister()) {
337 bool WholeReg =
true;
339 auto EndsAtI = [
I] (LiveInterval::SubRange &S) ->
bool {
340 LiveRange::iterator
F = S.find(
I->end);
341 return F != S.end() &&
I->end ==
F->end;
345 for (LiveInterval::SubRange &S : LI.
subranges()) {
347 KillAt(
I->end, S.LaneMask);
357void HexagonExpandCondsets::updateDeadsInRange(
Register Reg, LaneBitmask LM,
364 auto IsRegDef = [
this,
Reg,LM] (MachineOperand &
Op) -> std::pair<bool,bool> {
365 if (!
Op.isReg() || !
Op.isDef())
366 return {
false,
false };
369 return {
false,
false };
370 LaneBitmask SLM = getLaneMask(DR, DSR);
371 LaneBitmask
A = SLM & LM;
372 return {
A.any(),
A == SLM };
382 auto Dominate = [
this] (SetVector<MachineBasicBlock*> &Defs,
383 MachineBasicBlock *Dest) ->
bool {
384 for (MachineBasicBlock *
D : Defs) {
388 MachineBasicBlock *
Entry = &Dest->getParent()->front();
389 SetVector<MachineBasicBlock *> Work(
llvm::from_range, Dest->predecessors());
390 for (
unsigned i = 0; i < Work.size(); ++i) {
391 MachineBasicBlock *
B = Work[i];
396 Work.insert_range(
B->predecessors());
404 SetVector<MachineBasicBlock*> Defs;
406 for (
auto &Seg :
Range) {
407 if (!Seg.start.isRegister())
419 for (
auto &SI : PredDefs) {
422 if (
P.first !=
nullptr ||
P.second)
429 for (
auto &SI : PredDefs) {
445 if (Dominate(Defs, BB))
459 std::set<RegisterRef> DefRegs;
460 for (
auto &Seg :
Range) {
461 if (!Seg.start.isRegister())
465 auto P = IsRegDef(
Op);
466 if (
P.second && Seg.end.isDead()) {
468 }
else if (
P.first) {
477 for (
auto &Seg :
Range) {
478 if (!Seg.start.isRegister() || !
Range.liveAt(Seg.start.getPrevSlot()))
486 std::map<RegisterRef,unsigned> ImpUses;
489 if (!
Op.isReg() || !DefRegs.count(
Op))
495 ImpUses.insert({
Op, i});
509 for (
auto [R, DefIdx] : ImpUses) {
510 MachineInstrBuilder(MF, DefI).addReg(
R.Reg, RegState::Implicit,
R.Sub);
516void HexagonExpandCondsets::updateDeadFlags(
Register Reg) {
519 for (LiveInterval::SubRange &S : LI.
subranges()) {
520 updateDeadsInRange(
Reg, S.LaneMask, S);
530void HexagonExpandCondsets::recalculateLiveInterval(
Register Reg) {
535void HexagonExpandCondsets::removeInstr(MachineInstr &
MI) {
536 for (
const MachineOperand &
Op :
MI.operands())
537 KilledUses.erase(&
Op);
539 MI.eraseFromParent();
542void HexagonExpandCondsets::updateLiveness(
const std::set<Register> &RegSet,
543 bool Recalc,
bool UpdateKills,
546 if (!
R.isVirtual()) {
554 recalculateLiveInterval(R);
565void HexagonExpandCondsets::distributeLiveIntervals(
566 const std::set<Register> &Regs) {
567 ConnectedVNInfoEqClasses EQC(*LIS);
572 unsigned NumComp = EQC.Classify(LI);
578 for (
unsigned I = 1;
I < NumComp; ++
I) {
582 EQC.Distribute(LI, NewLIs.
begin(), *
MRI);
588unsigned HexagonExpandCondsets::getCondTfrOpcode(
const MachineOperand &SO,
593 if (
RS.Reg.isVirtual()) {
595 assert(
VC->begin() !=
VC->end() &&
"Empty register class");
596 PhysR = *
VC->begin();
600 MCRegister PhysS = (
RS.Sub == 0) ? PhysR :
TRI->getSubReg(PhysR,
RS.
Sub);
602 switch (
TRI->getRegSizeInBits(*RC)) {
604 return IfTrue ? Hexagon::A2_tfrt : Hexagon::A2_tfrf;
606 return IfTrue ? Hexagon::A2_tfrpt : Hexagon::A2_tfrpf;
619 return IfTrue ? Hexagon::C2_cmoveit : Hexagon::C2_cmoveif;
630MachineInstr *HexagonExpandCondsets::genCondTfrFor(MachineOperand &SrcOp,
632 unsigned DstR,
unsigned DstSR,
const MachineOperand &PredOp,
633 bool PredSense,
bool ReadUndef,
bool ImpUse) {
635 MachineBasicBlock &
B = *At->getParent();
644 unsigned Opc = getCondTfrOpcode(SrcOp, PredSense);
647 MachineInstrBuilder MIB;
651 .
addReg(DstR, DstState, DstSR)
654 if (KilledUses.contains(&SrcOp) &&
655 RegisterRef(SrcOp) != RegisterRef(DstR, DstSR))
659 .
addReg(DstR, DstState, DstSR)
670bool HexagonExpandCondsets::split(MachineInstr &
MI,
671 std::set<Register> &UpdRegs) {
672 if (TfrLimitActive) {
673 if (TfrCounter >= TfrLimit)
679 MachineOperand &MD =
MI.getOperand(0);
680 MachineOperand &MP =
MI.getOperand(1);
686 auto updateRegs = [&UpdRegs] (
const MachineInstr &
MI) ->
void {
687 for (
auto &
Op :
MI.operands()) {
689 UpdRegs.insert(
Op.getReg());
696 MachineOperand &
ST =
MI.getOperand(2);
697 MachineOperand &SF =
MI.getOperand(3);
698 if (
ST.isReg() && SF.
isReg()) {
700 if (RT == RegisterRef(SF)) {
703 MI.setDesc(HII->get(TargetOpcode::COPY));
705 for (
const MachineOperand &
Op :
MI.operands())
706 KilledUses.erase(&
Op);
707 while (
MI.getNumOperands() > 1)
708 MI.removeOperand(
MI.getNumOperands()-1);
710 MachineInstrBuilder(MF,
MI).addReg(RT.Reg, S, RT.Sub);
719 genCondTfrFor(ST, At, DR, DSR, MP,
true, ReadUndef,
false);
721 genCondTfrFor(SF, At, DR, DSR, MP,
false, ReadUndef,
true);
732bool HexagonExpandCondsets::isPredicable(MachineInstr *
MI) {
735 if (
MI->hasUnmodeledSideEffects() ||
MI->mayStore())
739 for (
auto &
Op :
MI->operands()) {
740 if (!
Op.isReg() || !
Op.isDef())
746 for (
auto &Mo :
MI->memoperands()) {
747 if (Mo->isVolatile() || Mo->isAtomic())
756MachineInstr *HexagonExpandCondsets::getReachingDefForPred(RegisterRef RD,
758 MachineBasicBlock &
B = *UseIt->getParent();
763 bool PredValid =
true;
766 MachineInstr *
MI = &*
I;
770 if (
MI->readsRegister(PredR,
nullptr) &&
777 for (
auto &
Op :
MI->operands()) {
778 if (!
Op.isReg() || !
Op.isDef())
781 if (RR.Reg == PredR) {
785 if (RR.Reg != RD.Reg)
790 if (RR.Sub == RD.Sub)
792 if (RR.Sub == 0 || RD.Sub == 0)
806bool HexagonExpandCondsets::canMoveOver(MachineInstr &
MI, ReferenceMap &Defs,
807 ReferenceMap &
Uses) {
811 for (
auto &
Op :
MI.operands()) {
818 if (!RR.Reg.isVirtual())
821 if (isRefInMap(RR, Defs, Exec_Then))
824 if (
Op.isDef() && isRefInMap(RR,
Uses, Exec_Then))
832bool HexagonExpandCondsets::canMoveMemTo(MachineInstr &TheI, MachineInstr &ToI,
835 if (!IsLoad && !IsStore)
848 if (
MI.hasUnmodeledSideEffects())
850 bool L =
MI.mayLoad(), S =
MI.mayStore();
853 if (Ordered &&
MI.hasOrderedMemoryRef())
856 bool Conflict = (
L && IsStore) || S;
865void HexagonExpandCondsets::predicateAt(
const MachineOperand &DefOp,
868 const MachineOperand &PredOp,
bool Cond,
869 std::set<Register> &UpdRegs) {
881 MachineBasicBlock &
B = *
MI.getParent();
883 unsigned Opc =
MI.getOpcode();
885 MachineInstrBuilder MB =
BuildMI(
B, Where,
DL, HII->get(PredOpc));
886 unsigned Ox = 0, NP =
MI.getNumOperands();
889 MachineOperand &MO =
MI.getOperand(Ox);
900 MachineOperand &MO =
MI.getOperand(Ox);
907 MachineInstr *NewI = MB;
913 UpdRegs.insert(
Op.getReg());
920void HexagonExpandCondsets::renameInRange(RegisterRef RO, RegisterRef RN,
929 if (!
MI.readsRegister(PredR,
nullptr) ||
933 for (
auto &
Op :
MI.operands()) {
934 if (!
Op.isReg() || RO != RegisterRef(
Op))
937 Op.setSubReg(
RN.Sub);
939 assert(!
Op.isDef() &&
"Not expecting a def");
947bool HexagonExpandCondsets::predicate(MachineInstr &TfrI,
bool Cond,
948 std::set<Register> &UpdRegs) {
952 assert(
Opc == Hexagon::A2_tfrt ||
Opc == Hexagon::A2_tfrf);
962 if (!KilledUses.contains(&MS))
971 MachineInstr *DefI = getReachingDefForPred(RT, TfrI, PredR,
Cond);
972 if (!DefI || !isPredicable(DefI))
980 ReferenceMap
Uses, Defs;
986 bool PredValid =
true;
988 if (!
MI.modifiesRegister(PredR,
nullptr))
998 if (
MI.isDebugInstr())
1004 unsigned Exec = Exec_Then | Exec_Else;
1006 MI.readsRegister(PredR,
nullptr))
1009 for (
auto &
Op :
MI.operands()) {
1019 RegisterRef RR =
Op;
1020 if (!RR.Reg.isVirtual())
1023 ReferenceMap &
Map =
Op.isDef() ? Defs :
Uses;
1024 if (
Op.isDef() &&
Op.isUndef()) {
1025 assert(RR.Sub &&
"Expecting a subregister on <def,read-undef>");
1031 addRefToMap(RR, Map, Exec);
1048 if (isRefInMap(RT, Defs, Exec_Then) || isRefInMap(RT,
Uses, Exec_Else))
1050 RegisterRef RD = MD;
1057 bool CanUp = canMoveOver(TfrI, Defs,
Uses);
1058 bool CanDown = canMoveOver(*DefI, Defs,
Uses);
1062 if (!canMoveMemTo(*DefI, TfrI,
true))
1067 <<
", can move down: " << (CanDown ?
"yes\n" :
"no\n"));
1070 predicateAt(MD, *DefI, PastDefIt, MP,
Cond, UpdRegs);
1072 predicateAt(MD, *DefI, TfrIt, MP,
Cond, UpdRegs);
1077 renameInRange(RT, RD, PredR,
Cond, PastDefIt, TfrIt);
1078 UpdRegs.insert(RT.Reg);
1087bool HexagonExpandCondsets::predicateInBlock(MachineBasicBlock &
B,
1088 std::set<Register> &UpdRegs) {
1091 unsigned Opc =
MI.getOpcode();
1092 if (
Opc == Hexagon::A2_tfrt ||
Opc == Hexagon::A2_tfrf) {
1093 bool Done = predicate(
MI, (
Opc == Hexagon::A2_tfrt), UpdRegs);
1097 if (RegisterRef(
MI.getOperand(0)) == RegisterRef(
MI.getOperand(2))) {
1098 for (
auto &
Op :
MI.operands()) {
1100 UpdRegs.insert(
Op.getReg());
1111bool HexagonExpandCondsets::isIntReg(RegisterRef RR,
unsigned &BW) {
1112 if (!RR.Reg.isVirtual())
1115 if (RC == &Hexagon::IntRegsRegClass) {
1119 if (RC == &Hexagon::DoubleRegsRegClass) {
1120 BW = (RR.Sub != 0) ? 32 : 64;
1126bool HexagonExpandCondsets::isIntraBlocks(LiveInterval &LI) {
1127 for (LiveRange::Segment &LR : LI) {
1129 if (!LR.start.isRegister())
1132 if (!LR.end.isRegister() && !LR.end.isDead())
1138bool HexagonExpandCondsets::coalesceRegisters(RegisterRef R1, RegisterRef
R2) {
1139 if (CoaLimitActive) {
1140 if (CoaCounter >= CoaLimit)
1161 << (Overlap ?
"overlap" :
"disjoint") <<
")\n "
1162 <<
printReg(R1.Reg,
TRI, R1.Sub) <<
" " << L1 <<
"\n "
1164 if (R1.Sub ||
R2.Sub)
1172 if (!isIntraBlocks(L1) && !isIntraBlocks(L2))
1178 using ValueInfoMap = DenseMap<VNInfo *, VNInfo *>;
1180 for (LiveRange::Segment &
I : L2) {
1181 VNInfo *NewVN, *OldVN =
I.valno;
1182 ValueInfoMap::iterator
F = VM.find(OldVN);
1183 if (
F == VM.end()) {
1185 VM.insert(std::make_pair(OldVN, NewVN));
1189 L1.
addSegment(LiveRange::Segment(
I.start,
I.end, NewVN));
1192 L2.removeSegment(*L2.begin());
1195 computeKills(R1.Reg);
1205bool HexagonExpandCondsets::coalesceSegments(
1206 const SmallVectorImpl<MachineInstr *> &
Condsets,
1207 std::set<Register> &UpdRegs) {
1210 MachineOperand &
S1 =
MI->getOperand(2), &S2 =
MI->getOperand(3);
1211 if (!
S1.isReg() && !S2.isReg())
1217 for (MachineInstr *CI : TwoRegs) {
1218 RegisterRef RD = CI->getOperand(0);
1219 RegisterRef
RP = CI->getOperand(1);
1220 MachineOperand &
S1 = CI->getOperand(2), &S2 = CI->getOperand(3);
1241 RegisterRef
RS =
S1;
1242 MachineInstr *RDef = getReachingDefForPred(RS, CI,
RP.Reg,
true);
1244 Done = coalesceRegisters(RD, RS);
1246 UpdRegs.insert(RD.Reg);
1247 UpdRegs.erase(
RS.Reg);
1251 if (!
Done && S2.isReg()) {
1252 RegisterRef
RS = S2;
1253 MachineInstr *RDef = getReachingDefForPred(RS, CI,
RP.Reg,
false);
1255 Done = coalesceRegisters(RD, RS);
1257 UpdRegs.insert(RD.Reg);
1258 UpdRegs.erase(
RS.Reg);
1267bool HexagonExpandCondsets::runOnMachineFunction(
MachineFunction &MF) {
1271 HII =
static_cast<const HexagonInstrInfo*
>(MF.
getSubtarget().getInstrInfo());
1273 MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
1274 LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
1280 std::set<Register> CoalUpd, PredUpd;
1283 for (
auto &
B : MF) {
1297 std::set<Register> KillUpd;
1299 for (MachineOperand &
Op :
MI->operands()) {
1300 if (
Op.isReg() &&
Op.isUse()) {
1301 if (!CoalUpd.count(
Op.getReg()))
1302 KillUpd.insert(
Op.getReg());
1328 Changed |= predicateInBlock(
B, PredUpd);
1331 PredUpd.insert(CoalUpd.begin(), CoalUpd.end());
1336 distributeLiveIntervals(PredUpd);
1340 LIS->
print(
dbgs() <<
"After expand-condsets\n");
1350 return new HexagonExpandCondsets();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseMap class.
static cl::opt< unsigned > OptCoaLimit("expand-condsets-coa-limit", cl::init(~0U), cl::Hidden, cl::desc("Max number of segment coalescings"))
static cl::opt< unsigned > OptTfrLimit("expand-condsets-tfr-limit", cl::init(~0U), cl::Hidden, cl::desc("Max number of mux expansions"))
expand Hexagon Expand Condsets
A common definition of LaneBitmask for use in TableGen and CodeGen.
SmallVector< MachineOperand, 4 > Cond
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static void updateLiveness(MachineFunction &MF)
Helper function to update the liveness information for the callee-saved registers.
MachineRegisterInfo & MRI
Remove Loads Into Fake Uses
SI Optimize VGPR LiveRange
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
FunctionPass class - This class is used to implement most global optimizations.
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
int getCondOpcode(int Opc, bool sense) const
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
bool isPredicable(const MachineInstr &MI) const override
Return true if the specified instruction can be predicated.
bool isPredicatedTrue(const MachineInstr &MI) const
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
bool verify(const MachineRegisterInfo *MRI=nullptr) const
Walks the interval and assert if any invariants fail to hold.
LLVM_ABI void computeSubRangeUndefs(SmallVectorImpl< SlotIndex > &Undefs, LaneBitmask LaneMask, const MachineRegisterInfo &MRI, const SlotIndexes &Indexes) const
For a given lane mask LaneMask, compute indexes at which the lane is marked undefined by subregister ...
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
SlotIndexes * getSlotIndexes() const
void RemoveMachineInstrFromMaps(MachineInstr &MI)
VNInfo::Allocator & getVNInfoAllocator()
LiveInterval & getInterval(Register Reg)
void removeInterval(Register Reg)
Interval removal.
LLVM_ABI bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr, LaneBitmask SubRangeMask=LaneBitmask::getAll())
After removing some uses of a register, shrink its live range to just the remaining uses.
LLVM_ABI void constructMainRangeFromSubranges(LiveInterval &LI)
For live interval LI with correct SubRanges construct matching information for the main live range.
LiveInterval & createEmptyInterval(Register Reg)
Interval creation.
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 print(raw_ostream &O) const
Implement the dump method.
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.
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
VNInfo * getNextValue(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
Analysis pass which computes a MachineDominatorTree.
bool dominates(const MachineInstr *A, const MachineInstr *B) const
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
unsigned getNumOperands() const
Retuns the total number of operands.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
LLVM_ABI bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore,...
LLVM_ABI void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI void clearKillInfo()
Clears kill flags on all operands.
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
@ MO_TargetIndex
Target-dependent index+offset operand.
@ MO_FPImmediate
Floating-point immediate operand.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
bool isReserved(MCRegister PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
LLVM_ABI bool isLiveIn(Register Reg) const
bool shouldTrackSubRegLiveness(const TargetRegisterClass &RC) const
Returns true if liveness for register class RC should be tracked at the subregister level.
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
iterator_range< use_iterator > use_operands(Register Reg) const
LLVM_ABI void replaceRegWith(Register FromReg, Register ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
bool insert(const value_type &X)
Insert a new element into the SetVector.
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isIntReg(MCRegister Reg)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
RegState
Flags to represent properties of register accesses.
@ Kill
The last use of a register.
bool operator!=(uint64_t V1, const APInt &V2)
constexpr from_range_t from_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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...
FunctionPass * createHexagonExpandCondsets()
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)
Split the specified string over a separator and return a range-compatible iterable over its partition...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
RegState getRegState(const MachineOperand &RegOp)
Get all register state flags from machine operand RegOp.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ Sub
Subtraction of integers.
char & HexagonExpandCondsetsID
DWARFExpression::Operation Op
@ End
Run the machine verifier once, at the end of the pipeline.
constexpr RegState getUndefRegState(bool B)
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
MCRegisterClass TargetRegisterClass