LLVM: include/llvm/CodeGen/MachineBasicBlock.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
14#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
15
26#include
27#include
28#include
29#include
30#include
31
32namespace llvm {
33
35class MachineDomTreeUpdater;
36class MachineFunction;
38class ModuleSlotTracker;
40class Printable;
41class SlotIndexes;
42class StringRef;
43class raw_ostream;
44class LiveIntervals;
45class TargetRegisterClass;
46class TargetRegisterInfo;
47template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
49
50
51
52
53
54
58
63
65
66
69
72 }
73
75
76private:
77
79};
80
84
86 return MBBSectionID(NumberInfo::getEmptyKey());
87 }
89 return MBBSectionID(NumberInfo::getTombstoneKey());
90 }
93 NumberInfo::getHashValue(SecID.Number));
94 }
97 }
98};
99
100
101
105};
106
108private:
110
112
113 using instr_iterator =
115
116public:
120 instr_iterator Last);
122};
123
126public:
127
128
129
131 public:
134
137
140 }
141 };
142
143private:
145
147 int Number;
148
149
150
151
152
153
154
155 unsigned CallFrameSize = 0;
156
158 Instructions Insts;
159
160
163
164
165
166
167 std::vector Probs;
168 using probability_iterator = std::vector::iterator;
169 using const_probability_iterator =
170 std::vector::const_iterator;
171
172 std::optional<uint64_t> IrrLoopHeaderWeight;
173
174
175 using LiveInVector = std::vector;
176 LiveInVector LiveIns;
177
178
179
181
182
183
184 unsigned MaxBytesForAlignment = 0;
185
186
187 bool IsEHPad = false;
188
189
190
191 bool MachineBlockAddressTaken = false;
192
193
194
195 BasicBlock *AddressTakenIRBlock = nullptr;
196
197
198
199 bool LabelMustBeEmitted = false;
200
201
202
203
204 bool IsEHScopeEntry = false;
205
206
207 bool IsEHCatchretTarget = false;
208
209
210 bool IsEHFuncletEntry = false;
211
212
213 bool IsCleanupFuncletEntry = false;
214
215
216
217 std::optional BBID;
218
219
221
222
223 bool IsBeginSection = false;
224
225
226 bool IsEndSection = false;
227
228
229 bool IsInlineAsmBrIndirectTarget = false;
230
231
232
233 mutable MCSymbol *CachedMCSymbol = nullptr;
234
235
236 mutable MCSymbol *CachedEHCatchretMCSymbol = nullptr;
237
238
239
240 mutable MCSymbol *CachedEndMCSymbol = nullptr;
241
242
243 MachineBasicBlock() = default;
244
245 explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB);
246
247 ~MachineBasicBlock();
248
249
251
252public:
253
254
255
257
258
259
261 BB = nullptr;
262 }
263
264
266
267
269
270
272
273
274
275
276
278 return MachineBlockAddressTaken || AddressTakenIRBlock;
279 }
280
281
282
283
284
286
287
288
290
291
293
294
295
296
298
299
300
302
303
305
306
307
309
310
313
318
324
325 unsigned size() const { return (unsigned)Insts.size(); }
327 bool empty() const { return Insts.empty(); }
328
333
338
347
353 }
354
361 }
364 }
368 }
369
370
372 return &MachineBasicBlock::Insts;
373 }
374
377 }
380 }
381
382
385 }
388 }
389
390
410 { return Predecessors.rbegin();}
412 { return Predecessors.rbegin();}
414 { return Predecessors.rend(); }
416 { return Predecessors.rend(); }
418 return (unsigned)Predecessors.size();
419 }
426 { return Successors.rbegin(); }
428 { return Successors.rbegin(); }
430 { return Successors.rend(); }
432 { return Successors.rend(); }
434 return (unsigned)Successors.size();
435 }
437
440 }
443 }
446 }
449 }
450
451
452
453
454
455
459 }
461 LiveIns.push_back(RegMaskPair);
462 }
463
464
465
466
468
469
471
472
473
474 void clearLiveIns(std::vector &OldLiveIns);
475
476
477
478
480
481
484
485
488
489
490
492
493
494
495
496
500 }
501
507 }
508
509
511
512 const std::vector &getLiveIns() const { return LiveIns; }
513
515 public:
521
524 : ExceptionPointer(ExceptionPointer),
525 ExceptionSelector(ExceptionSelector), BlockI(MBB.succ_begin()),
528 BlockI = BlockEnd;
529 else if (BlockI != BlockEnd) {
530 LiveRegI = (*BlockI)->livein_begin();
531 if (!advanceToValidPosition())
532 return;
533 if (LiveRegI->PhysReg == ExceptionPointer ||
534 LiveRegI->PhysReg == ExceptionSelector)
535 ++(*this);
536 }
537 }
538
540 do {
541 ++LiveRegI;
542 if (!advanceToValidPosition())
543 return *this;
544 } while ((*BlockI)->isEHPad() &&
545 (LiveRegI->PhysReg == ExceptionPointer ||
546 LiveRegI->PhysReg == ExceptionSelector));
547 return *this;
548 }
549
552 ++(*this);
553 return Tmp;
554 }
555
557 return *LiveRegI;
558 }
559
561 return &*LiveRegI;
562 }
563
565 if (BlockI != BlockEnd)
566 return BlockI == RHS.BlockI && LiveRegI == RHS.LiveRegI;
567 return RHS.BlockI == BlockEnd;
568 }
569
571 return !(*this == RHS);
572 }
573 private:
574 bool advanceToValidPosition() {
575 if (LiveRegI != (*BlockI)->livein_end())
576 return true;
577
578 do {
579 ++BlockI;
580 } while (BlockI != BlockEnd && (*BlockI)->livein_empty());
581 if (BlockI == BlockEnd)
582 return false;
583
584 LiveRegI = (*BlockI)->livein_begin();
585 return true;
586 }
587
588 MCPhysReg ExceptionPointer, ExceptionSelector;
592 };
593
594
595
596
600 }
603 }
604
605
606
608
609
610
612
613
615
616
618
622 }
623
624
626
627
629 MaxBytesForAlignment = MaxBytes;
630 }
631
632
633
634 bool isEHPad() const { return IsEHPad; }
635
636
637
639
641
642
644
645
646
648
649
650
652
653
655
656
658
659
661
662
664
665
667
668
670
671
673
674
676
678
680
681 std::optional getBBID() const { return BBID; }
682
683
685
686
688 assert(!BBID.has_value() && "Cannot change BBID.");
689 BBID = V;
690 }
691
692
694
695
697
698
699
700
702
703
705 return IsInlineAsmBrIndirectTarget;
706 }
707
708
710 IsInlineAsmBrIndirectTarget = V;
711 }
712
713
715
716
717
718
719
720
723
724
727 }
728
729
730
731
732
733
734
736
737
738
739
740
741
742
743
744
745
746
749
750
751
752
753
755
756
758
759
760
761
762
763
766 }
767
768
769
771
772
773
774
775
777 bool NormalizeSuccProbs = false);
778
779
780
781
782
783
785 bool NormalizeSuccProbs = false);
786
787
789
790
791
792
793
794
796
797
798
800 bool NormalizeSuccProbs = false);
801
802
803
804
806
807
808
810
811
813
814
816
817
819
820
821
822
823
824
826
827
828
829
834 }
835
836
837
838
843 }
844
845
846
847
848
849
851
852
853
854
856
857
858
859
860
861
863
864
865
866
867
868
872 }
873
874
875
876
878
879
880
881
882
884 bool SkipPseudoOp = true);
885
886
887
891 }
892
893
894
896
897
898
899
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
921 SkipPseudoOp);
922 }
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
943 SkipPseudoOp);
944 }
945
946
947
950 }
951
952
953
956 }
957
958
959
960
961
962
963
964
965
968
969
970
971
972
973
979 }
980
986 return SplitCriticalEdge(Succ, nullptr, &MFAM, LiveInSets, MDTU);
987 }
988
989
993
994
995
996
997
999
1003
1004
1005
1006
1007
1008
1009
1011
1012
1013 template
1015 assert((I == end() || I->getParent() == this) &&
1016 "iterator points outside of basic block");
1017 Insts.insert(I.getInstrIterator(), S, E);
1018 }
1019
1020
1022 assert((I == end() || I->getParent() == this) &&
1023 "iterator points outside of basic block");
1024 assert(->isBundledWithPred() &&
->isBundledWithSucc() &&
1025 "Cannot insert instruction with bundle flags");
1026 return Insts.insert(I.getInstrIterator(), MI);
1027 }
1028
1029
1031 assert((I == end() || I->getParent() == this) &&
1032 "iterator points outside of basic block");
1033 assert(->isBundledWithPred() &&
->isBundledWithSucc() &&
1034 "Cannot insert instruction with bundle flags");
1035 return Insts.insertAfter(I.getInstrIterator(), MI);
1036 }
1037
1038
1039
1042 "iterator points outside of basic block");
1043 assert(->isBundledWithPred() &&
->isBundledWithSucc() &&
1044 "Cannot insert instruction with bundle flags");
1045 while (I->isBundledWithSucc())
1046 ++I;
1047 return Insts.insertAfter(I, MI);
1048 }
1049
1050
1051
1052
1053
1055
1056
1057
1058
1059
1062 }
1063
1064
1066 return Insts.erase(I.getInstrIterator(), E.getInstrIterator());
1067 }
1068
1069
1070
1071
1073 return erase(I, std::next(I));
1074 }
1075
1076
1077
1078
1079
1082 }
1083
1084
1085
1086
1087
1088
1090 assert(->isBundled() && "Cannot remove bundled instructions");
1092 }
1093
1094
1095
1096
1097
1098
1100
1102 Insts.clear();
1103 }
1104
1105
1106
1107
1108
1110
1111 if (Where != From)
1113 }
1114
1115
1116
1117
1118
1119
1124 }
1125
1126
1127
1129
1130
1132
1133
1134
1136
1137
1138
1140
1141
1142
1146 }
1147
1148
1149
1150
1154 }
1155
1156
1157
1158
1162 }
1163
1164
1165
1166
1167
1171 }
1172
1173
1174
1176
1177
1181 LQR_Unknown
1183
1184
1185
1186
1187
1188
1189
1190
1191
1195 unsigned Neighborhood = 10) const;
1196
1197
1198 void dump() const;
1200 bool IsStandalone = true) const;
1202 const SlotIndexes * = nullptr, bool IsStandalone = true) const;
1203
1205 PrintNameIr = (1 << 0),
1207 };
1208
1211
1212
1214
1215
1216
1219
1220
1222
1224
1225
1227
1228
1230
1232 return IrrLoopHeaderWeight;
1233 }
1234
1236 IrrLoopHeaderWeight = Weight;
1237 }
1238
1239
1240
1241
1243
1244private:
1245
1246 probability_iterator getProbabilityIterator(succ_iterator I);
1247 const_probability_iterator
1249
1252
1253
1255
1256
1257
1258
1259
1260
1262
1263
1264
1265
1267};
1268
1270
1271
1272
1273
1274
1275
1276
1278
1279
1283 return MBB->getNumber();
1284 }
1285};
1286
1287
1288
1289
1290
1291
1292
1293
1294
1298
1302
1304 assert(BB->getNumber() >= 0 && "negative block number");
1306 }
1307};
1308
1309static_assert(GraphHasNodeNumbers<MachineBasicBlock *>,
1310 "GraphTraits getNumber() not detected");
1311
1315
1319
1321 assert(BB->getNumber() >= 0 && "negative block number");
1323 }
1324};
1325
1326static_assert(GraphHasNodeNumbers<const MachineBasicBlock *>,
1327 "GraphTraits getNumber() not detected");
1328
1329
1330
1331
1332
1333
1334
1338
1340 return G.Graph;
1341 }
1342
1345
1347 assert(BB->getNumber() >= 0 && "negative block number");
1349 }
1350};
1351
1352static_assert(GraphHasNodeNumbers<Inverse<MachineBasicBlock *>>,
1353 "GraphTraits getNumber() not detected");
1354
1358
1360 return G.Graph;
1361 }
1362
1365
1367 assert(BB->getNumber() >= 0 && "negative block number");
1369 }
1370};
1371
1372static_assert(GraphHasNodeNumbers<Inverse<const MachineBasicBlock *>>,
1373 "GraphTraits getNumber() not detected");
1374
1375
1379}
1386
1387
1388
1389
1390
1394
1395public:
1399 assert(I == BB->end() || I->getParent() == BB);
1400 }
1401
1403 return B == MBB.end() ? MBB.begin() : std::next(B);
1404 }
1407
1409};
1410
1411
1412
1413
1414
1415template
1417 bool SkipPseudoOp = true) {
1418 while (It != End &&
1419 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1420 ++It;
1421 return It;
1422}
1423
1424
1425
1426
1427
1428template
1430 bool SkipPseudoOp = true) {
1431 while (It != Begin &&
1432 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1433 --It;
1434 return It;
1435}
1436
1437
1438
1439template
1440inline IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp = true) {
1442}
1443
1444
1445
1446template
1447inline IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp = true) {
1449}
1450
1451
1452
1453template
1455 bool SkipPseudoOp = true) {
1457 return .isDebugInstr() && !(SkipPseudoOp && MI.isPseudoProbe());
1458 });
1459}
1460
1461}
1462
1463#endif
aarch64 AArch64 CCMP Pass
MachineBasicBlock MachineBasicBlock::iterator MBBI
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
BlockVerifier::State From
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines DenseMapInfo traits for DenseMap.
This file defines the little GraphTraits template class that should be specialized by classes that...
A common definition of LaneBitmask for use in TableGen and CodeGen.
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SparseBitVector class.
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
static BranchProbability getUnknown()
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
Wrapper class representing physical registers. Should be passed by value.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class prints out the machine instructions using the MIR serialization format.
liveout_iterator(const MachineBasicBlock &MBB, MCPhysReg ExceptionPointer, MCPhysReg ExceptionSelector, bool End)
liveout_iterator & operator++()
std::ptrdiff_t difference_type
reference operator*() const
std::input_iterator_tag iterator_category
liveout_iterator operator++(int)
bool operator==(const liveout_iterator &RHS) const
pointer operator->() const
bool operator!=(const liveout_iterator &RHS) const
const MachineInstr & instr_front() const
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findPrevDebugLoc (it also searches towards the beginning of this MBB) exce...
Instructions::const_reverse_iterator const_reverse_instr_iterator
unsigned pred_size() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
bool hasEHPadSuccessor() const
void setBBID(const UniqueBBID &V)
Sets the fixed BBID of this basic block.
iterator erase(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
void setAddressTakenIRBlock(BasicBlock *BB)
Set this block to reflect that it corresponds to an IR-level basic block with a BlockAddress.
livein_iterator livein_end() const
iterator getFirstTerminatorForward()
Finds the first terminator in a block by scanning forward.
bool isEHPad() const
Returns true if the block is a landing pad.
iterator_range< liveout_iterator > liveouts() const
const MachineInstr & back() const
void replacePhiUsesWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
SmallVectorImpl< MachineBasicBlock * >::reverse_iterator pred_reverse_iterator
void setIsEHCatchretTarget(bool V=true)
Indicates if this is a target block of a catchret.
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it.
instr_iterator instr_begin()
void setIsEndSection(bool V=true)
void setIrrLoopHeaderWeight(uint64_t Weight)
MachineBasicBlock * getLogicalFallThrough()
Return the fallthrough block if the block can implicitly transfer control to it's successor,...
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
SmallVectorImpl< MachineBasicBlock * >::const_iterator const_succ_iterator
DebugLoc rfindPrevDebugLoc(reverse_iterator MBBI)
MCSymbol * getEHCatchretSymbol() const
Return the EHCatchret Symbol for this basic block.
const_pred_iterator pred_end() const
void moveBefore(MachineBasicBlock *NewAfter)
Move 'this' block before or after the specified block.
void setLabelMustBeEmitted()
Set this block to reflect that, regardless how we flow to it, we need its label be emitted.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
const_pred_reverse_iterator pred_rend() const
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
const_iterator getFirstNonDebugInstr(bool SkipPseudoOp=true) const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
const_reverse_instr_iterator instr_rend() const
iterator_range< livein_iterator > liveins() const
void setAlignment(Align A, unsigned MaxBytes)
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
reverse_instr_iterator instr_rbegin()
MachineInstrBundleIterator< const MachineInstr, true > const_reverse_iterator
SmallVectorImpl< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
void push_back(MachineInstr *MI)
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
pred_reverse_iterator pred_rbegin()
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
bool hasName() const
Check if there is a name of corresponding LLVM basic block.
MachineBasicBlock * getSinglePredecessor()
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
std::optional< UniqueBBID > getBBID() const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)
Split the old successor into old plus new and updates the probability info.
SmallVectorImpl< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
liveout_iterator liveout_end() const
const_instr_iterator instr_begin() const
const_succ_iterator succ_begin() const
const_succ_reverse_iterator succ_rbegin() const
pred_reverse_iterator pred_rend()
@ PrintNameIr
Add IR name where available.
@ PrintNameAttributes
Print attributes.
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
const MachineBasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor.
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
bool canFallThrough()
Return true if the block can implicitly transfer control to the block after it by falling off the end...
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the first non-debug instruction in the basic block, or end().
succ_iterator succ_begin()
DebugLoc rfindDebugLoc(reverse_iterator MBBI)
bool livein_empty() const
void removeLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
iterator erase(iterator I, iterator E)
Remove a range of instructions from the instruction list and delete them.
const MachineInstr & front() const
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
const_instr_range instrs() const
const_reverse_iterator rbegin() const
void clearBasicBlock()
Remove the reference to the underlying IR BasicBlock.
unsigned getMaxBytesForAlignment() const
Return the maximum amount of padding allowed for aligning the basic block.
void setMaxBytesForAlignment(unsigned MaxBytes)
Set the maximum amount of padding allowed for aligning the basic block.
void validateSuccProbs() const
Validate successors' probabilities and check if the sum of them is approximate one.
iterator_range< const_pred_iterator > predecessors() const
const MachineInstr & instr_back() const
bool isIRBlockAddressTaken() const
Test whether this block is the target of an IR BlockAddress.
LiveInVector::const_iterator livein_iterator
MCSymbol * getEndSymbol() const
Returns the MCSymbol marking the end of this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From, iterator To)
Take a block of instructions from MBB 'Other' in the range [From, To), and insert them into this MBB ...
void clearLiveIns()
Clear live in list.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
const_iterator getLastNonDebugInstr(bool SkipPseudoOp=true) const
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, MCRegister Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
bool sameSection(const MachineBasicBlock *MBB) const
Returns true if this and MBB belong to the same section.
const std::vector< RegisterMaskPair > & getLiveIns() const
iterator insert(iterator I, MachineInstr *MI)
Insert MI into the instruction list before I.
livein_iterator livein_begin() const
unsigned succ_size() const
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
iterator_range< livein_iterator > liveins_dbg() const
const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the start of this basic block.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
void setAlignment(Align A)
Set alignment of the basic block.
bool isEHScopeEntry() const
Returns true if this is the entry block of an EH scope, i.e., the block that used to have a catchpad ...
MachineInstr & instr_back()
bool isEntryBlock() const
Returns true if this is the entry block of the function.
iterator_range< const_instr_iterator > const_instr_range
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
SmallVectorImpl< MachineBasicBlock * >::iterator succ_iterator
const_pred_reverse_iterator pred_rbegin() const
void addLiveIn(const RegisterMaskPair &RegMaskPair)
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, MachineFunctionAnalysisManager &MFAM, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
MachineBasicBlock * getSingleSuccessor()
BasicBlock * getAddressTakenIRBlock() const
Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
bool isEHCatchretTarget() const
Returns true if this is a target block of a catchret.
const_iterator getFirstNonPHI() const
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
const MachineBasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
iterator_range< const_iterator > phis() const
const_instr_iterator instr_end() const
liveout_iterator liveout_begin() const
Iterator scanning successor basic blocks' liveins to determine the registers potentially live at the ...
DebugLoc findDebugLoc(iterator MBBI)
SmallVectorImpl< MachineBasicBlock * >::iterator pred_iterator
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
const_succ_iterator succ_end() const
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const_iterator begin() const
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
bool hasSuccessorProbabilities() const
Return true if any of the successors have probabilities attached to them.
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
iterator_range< const_iterator > terminators() const
livein_iterator livein_begin_dbg() const
Unlike livein_begin, this method does not check that the liveness information is accurate.
DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findDebugLoc (it also searches towards the end of this MBB) except that th...
const_pred_iterator pred_begin() const
void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
reverse_instr_iterator instr_rend()
const_reverse_iterator rend() const
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
Instructions::iterator instr_iterator
pred_iterator pred_begin()
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
succ_reverse_iterator succ_rbegin()
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
static Instructions MachineBasicBlock::* getSublistAccess(MachineInstr *)
Support for MachineInstr::getNextNode().
DebugLoc findPrevDebugLoc(instr_iterator MBBI)
Find the previous valid DebugLoc preceding MBBI, skipping any debug instructions.
MachineBasicBlock * splitAt(MachineInstr &SplitInst, bool UpdateLiveIns=true, LiveIntervals *LIS=nullptr)
Split a basic block into 2 pieces at SplitPoint.
MachineFunction * getParent()
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
friend class MachineFunction
void setIsInlineAsmBrIndirectTarget(bool V=true)
Indicates if this is the indirect dest of an INLINEASM_BR.
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
iterator_range< const_succ_iterator > successors() const
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const_iterator getFirstTerminator() const
const_succ_reverse_iterator succ_rend() const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
bool isBeginSection() const
Returns true if this block begins any section.
DebugLoc findPrevDebugLoc(iterator MBBI)
iterator_range< iterator > terminators()
unsigned getCallFrameSize() const
Return the call frame size on entry to this basic block.
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
iterator_range< succ_iterator > successors()
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
reverse_iterator rbegin()
bool isMachineBlockAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const
Print the basic block's name as:
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
bool isEndSection() const
Returns true if this block ends any section.
Align getAlignment() const
Return alignment of the basic block.
bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const
Check if the edge between this block and the given successor Succ, can be split.
MachineInstrBundleIterator< MachineInstr > iterator
bool isLegalToHoistInto() const
Returns true if it is legal to hoist instructions into this block.
MachineInstr & instr_front()
SmallVectorImpl< MachineBasicBlock * >::const_iterator const_pred_iterator
const_reverse_instr_iterator instr_rbegin() const
iterator erase(iterator I)
Remove an instruction or bundle from the instruction list and delete it.
instr_iterator insertAfterBundle(instr_iterator I, MachineInstr *MI)
If I is bundled then insert MI into the instruction list after the end of the bundle,...
const_iterator end() const
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
SmallVectorImpl< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
bool mayHaveInlineAsmBr() const
Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
@ LQR_Dead
Register is known to be fully dead.
@ LQR_Live
Register is known to be (at least partially) live.
@ LQR_Unknown
Register liveness not decidable from local neighborhood.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
void moveAfter(MachineBasicBlock *NewBefore)
succ_reverse_iterator succ_rend()
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
std::optional< uint64_t > getIrrLoopHeaderWeight() const
const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the end of the basic block.
void setIsBeginSection(bool V=true)
bool sizeWithoutDebugLargerThan(unsigned Limit) const
iterator_range< instr_iterator > instr_range
bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
MachineBasicBlock * removeFromParent()
This method unlinks 'this' from the containing function, and returns it, but does not delete it.
void insert(iterator I, IT S, IT E)
Insert a range of instructions into the instruction list before I.
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
Instructions::reverse_iterator reverse_instr_iterator
bool isCleanupFuncletEntry() const
Returns true if this is the entry block of a cleanup funclet.
instr_iterator getInstrIterator() const
static MachineInstrBundleIterator getAtBundleBegin(instr_iterator MI)
Get the bundle iterator for the given instruction's bundle.
MachineInstrSpan provides an interface to get an iteration range containing the instruction it was in...
MachineBasicBlock::iterator getInitial()
MachineInstrSpan(MachineBasicBlock::iterator I, MachineBasicBlock *BB)
MachineBasicBlock::iterator begin()
MachineBasicBlock::iterator end()
Representation of each machine instruction.
bool isReturn(QueryType Type=AnyInBundle) const
bool isEHScopeReturn(QueryType Type=AnyInBundle) const
Return true if this is an instruction that marks the end of an EH scope, i.e., a catchpad or a cleanu...
Manage lifetime of a slot tracker for printing IR.
Pass interface - Implemented by all 'passes'.
Simple wrapper around std::function<void(raw_ostream&)>.
Wrapper class representing virtual and physical registers.
typename SuperClass::const_iterator const_iterator
typename SuperClass::iterator iterator
reverse_iterator rbegin()
std::reverse_iterator< const_iterator > const_reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
An ilist node that can access its parent list.
base_list_type::const_reverse_iterator const_reverse_iterator
base_list_type::reverse_iterator reverse_iterator
base_list_type::const_iterator const_iterator
base_list_type::iterator iterator
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
A simple intrusive list implementation.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ BasicBlock
Various leaf nodes.
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
This is an optimization pass for GlobalISel generic memory operations.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
auto pred_end(const MachineBasicBlock *BB)
auto successors(const MachineBasicBlock *BB)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto pred_size(const MachineBasicBlock *BB)
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
auto succ_size(const MachineBasicBlock *BB)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
IterT skipDebugInstructionsBackward(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
auto pred_begin(const MachineBasicBlock *BB)
auto predecessors(const MachineBasicBlock *BB)
IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It, then continue decrementing it while it points to a debug instruction.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static MBBSectionID getEmptyKey()
static unsigned getHashValue(const MBBSectionID &SecID)
static bool isEqual(const MBBSectionID &LHS, const MBBSectionID &RHS)
static MBBSectionID getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
static ChildIteratorType child_end(NodeRef N)
static NodeRef getEntryNode(Inverse< MachineBasicBlock * > G)
MachineBasicBlock::pred_iterator ChildIteratorType
static unsigned getNumber(MachineBasicBlock *BB)
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static unsigned getNumber(const MachineBasicBlock *BB)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock * > G)
static ChildIteratorType child_begin(NodeRef N)
MachineBasicBlock::const_pred_iterator ChildIteratorType
static unsigned getNumber(MachineBasicBlock *BB)
MachineBasicBlock::succ_iterator ChildIteratorType
static NodeRef getEntryNode(MachineBasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static ChildIteratorType child_begin(NodeRef N)
MachineBasicBlock::const_succ_iterator ChildIteratorType
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const MachineBasicBlock *BB)
static NodeRef getEntryNode(const MachineBasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static constexpr LaneBitmask getAll()
unsigned operator()(const MachineBasicBlock *MBB) const
bool operator!=(const MBBSectionID &Other) const
static const MBBSectionID ExceptionSectionID
static const MBBSectionID ColdSectionID
enum llvm::MBBSectionID::SectionType Type
bool operator==(const MBBSectionID &Other) const
Pair of physical register and lane mask.
RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
bool operator==(const RegisterMaskPair &other) const
Callbacks do nothing by default in iplist and ilist.
void transferNodesFromList(ilist_traits &FromList, instr_iterator First, instr_iterator Last)
void addNodeToList(MachineInstr *N)
void removeNodeFromList(MachineInstr *N)
void deleteNode(MachineInstr *MI)
Template traits for intrusive list.