llvm.org GIT mirror llvm / 6463296
[CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303820 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
15 changed file(s) with 372 addition(s) and 295 deletion(s). Raw diff Collapse all Expand all
3333 namespace llvm {
3434
3535 class AsmPrinterHandler;
36 class BasicBlock;
3637 class BlockAddress;
3738 class Constant;
3839 class ConstantArray;
4243 class DwarfDebug;
4344 class GCMetadataPrinter;
4445 class GlobalIndirectSymbol;
46 class GlobalObject;
4547 class GlobalValue;
4648 class GlobalVariable;
4749 class GCStrategy;
6466 class MCSymbol;
6567 class MCTargetOptions;
6668 class MDNode;
69 class Module;
70 class raw_ostream;
6771 class TargetLoweringObjectFile;
6872 class TargetMachine;
6973
108112
109113 /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
110114 /// its number of uses by other globals.
111 typedef std::pair GOTEquivUsePair;
115 using GOTEquivUsePair = std::pair;
112116 MapVector GlobalGOTEquivs;
113117
114118 /// Enable print [latency:throughput] in output
None //===-- AtomicExpandUtils.h - Utilities for expanding atomic instructions -===//
0 //===- AtomicExpandUtils.h - Utilities for expanding atomic instructions --===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #ifndef LLVM_CODEGEN_ATOMICEXPANDUTILS_H
10 #define LLVM_CODEGEN_ATOMICEXPANDUTILS_H
11
912 #include "llvm/ADT/STLExtras.h"
1013 #include "llvm/IR/IRBuilder.h"
14 #include "llvm/Support/AtomicOrdering.h"
1115
1216 namespace llvm {
17
18 class AtomicRMWInst;
1319 class Value;
14 class AtomicRMWInst;
15
1620
1721 /// Parameters (see the expansion example below):
1822 /// (the builder, %addr, %loaded, %new_val, ordering,
1923 /// /* OUT */ %success, /* OUT */ %new_loaded)
20 typedef function_ref &, Value *, Value *, Value *,
21 AtomicOrdering, Value *&, Value *&)> CreateCmpXchgInstFun;
24 using CreateCmpXchgInstFun =
25 function_ref &, Value *, Value *, Value *, AtomicOrdering,
26 Value *&, Value *&)>;
2227
2328 /// \brief Expand an atomic RMW instruction into a loop utilizing
2429 /// cmpxchg. You'll want to make sure your target machine likes cmpxchg
4146 /// loop:
4247 /// %loaded = phi iN [ %init_loaded, %entry ], [ %new_loaded, %loop ]
4348 /// %new = some_op iN %loaded, %incr
44 /// ; This is what -atomic-expand will produce using this function on i686 targets:
49 /// ; This is what -atomic-expand will produce using this function on i686
50 /// targets:
4551 /// %pair = cmpxchg iN* %addr, iN %loaded, iN %new_val
4652 /// %new_loaded = extractvalue { iN, i1 } %pair, 0
4753 /// %success = extractvalue { iN, i1 } %pair, 1
5157 /// [...]
5258 ///
5359 /// Returns true if the containing function was modified.
54 bool
55 expandAtomicRMWToCmpXchg(AtomicRMWInst *AI, CreateCmpXchgInstFun Factory);
56 }
60 bool expandAtomicRMWToCmpXchg(AtomicRMWInst *AI, CreateCmpXchgInstFun Factory);
61
62 } // end namespace llvm
63
64 #endif // LLVM_CODEGEN_ATOMICEXPANDUTILS_H
None //===--- lib/CodeGen/DIE.h - DWARF Info Entries -----------------*- C++ -*-===//
0 //===- lib/CodeGen/DIE.h - DWARF Info Entries -------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
3030 #include
3131 #include
3232 #include
33 #include
3334 #include
3435
3536 namespace llvm {
5253 dwarf::Form Form;
5354
5455 /// Dwarf attribute value for DW_FORM_implicit_const
55 int64_t Value;
56 int64_t Value = 0;
5657
5758 public:
5859 DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
59 : Attribute(A), Form(F), Value(0) {}
60 : Attribute(A), Form(F) {}
6061 DIEAbbrevData(dwarf::Attribute A, int64_t V)
6162 : Attribute(A), Form(dwarf::DW_FORM_implicit_const), Value(V) {}
6263
135136 /// storage container.
136137 BumpPtrAllocator &Alloc;
137138 /// \brief FoldingSet that uniques the abbreviations.
138 llvm::FoldingSet AbbreviationsSet;
139 FoldingSet AbbreviationsSet;
139140 /// A list of all the unique abbreviations in use.
140141 std::vector Abbreviations;
141142
142143 public:
143144 DIEAbbrevSet(BumpPtrAllocator &A) : Alloc(A) {}
144145 ~DIEAbbrevSet();
146
145147 /// Generate the abbreviation declaration for a DIE and return a pointer to
146148 /// the generated abbreviation.
147149 ///
288290 /// A pointer to another debug information entry. An instance of this class can
289291 /// also be used as a proxy for a debug information entry not yet defined
290292 /// (ie. types.)
291 class DIE;
292293 class DIEEntry {
293294 DIE *Entry;
294295
296 public:
295297 DIEEntry() = delete;
296
297 public:
298298 explicit DIEEntry(DIE &E) : Entry(&E) {}
299299
300300 DIE &getEntry() const { return *Entry; }
347347 ///
348348 /// All values that aren't standard layout (or are larger than 8 bytes)
349349 /// should be stored by reference instead of by value.
350 typedef AlignedCharArrayUnion
351 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
352 DIELocList>
353 ValTy;
350 using ValTy = AlignedCharArrayUnion
351 DIEDelta *, DIEEntry, DIEBlock *,
352 DIELoc *, DIELocList>;
353
354354 static_assert(sizeof(ValTy) <= sizeof(uint64_t) ||
355355 sizeof(ValTy) <= sizeof(void *),
356356 "Expected all large types to be stored via pointer");
485485 };
486486
487487 struct IntrusiveBackListBase {
488 typedef IntrusiveBackListNode Node;
488 using Node = IntrusiveBackListNode;
489
489490 Node *Last = nullptr;
490491
491492 bool empty() const { return !Last; }
493
492494 void push_back(Node &N) {
493495 assert(N.Next.getPointer() == &N && "Expected unlinked node");
494496 assert(N.Next.getInt() == true && "Expected unlinked node");
504506 template class IntrusiveBackList : IntrusiveBackListBase {
505507 public:
506508 using IntrusiveBackListBase::empty;
509
507510 void push_back(T &N) { IntrusiveBackListBase::push_back(N); }
508511 T &back() { return *static_cast(Last); }
509512 const T &back() const { return *static_cast(Last); }
512515 class iterator
513516 : public iterator_facade_base {
514517 friend class const_iterator;
518
515519 Node *N = nullptr;
516520
517521 public:
584588 class DIEValueList {
585589 struct Node : IntrusiveBackListNode {
586590 DIEValue V;
591
587592 explicit Node(DIEValue V) : V(V) {}
588593 };
589594
590 typedef IntrusiveBackList ListTy;
595 using ListTy = IntrusiveBackList;
596
591597 ListTy List;
592598
593599 public:
596602 : public iterator_adaptor_base
597603 std::forward_iterator_tag, DIEValue> {
598604 friend class const_value_iterator;
599 typedef iterator_adaptor_base
600 std::forward_iterator_tag,
601 DIEValue> iterator_adaptor;
605
606 using iterator_adaptor =
607 iterator_adaptor_base
608 std::forward_iterator_tag, DIEValue>;
602609
603610 public:
604611 value_iterator() = default;
611618 class const_value_iterator : public iterator_adaptor_base<
612619 const_value_iterator, ListTy::const_iterator,
613620 std::forward_iterator_tag, const DIEValue> {
614 typedef iterator_adaptor_base
615 std::forward_iterator_tag,
616 const DIEValue> iterator_adaptor;
621 using iterator_adaptor =
622 iterator_adaptor_base
623 std::forward_iterator_tag, const DIEValue>;
617624
618625 public:
619626 const_value_iterator() = default;
626633 const DIEValue &operator*() const { return wrapped()->V; }
627634 };
628635
629 typedef iterator_range value_range;
630 typedef iterator_range const_value_range;
636 using value_range = iterator_range;
637 using const_value_range = iterator_range;
631638
632639 value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V) {
633640 List.push_back(*new (Alloc) Node(V));
656663 friend class DIEUnit;
657664
658665 /// Dwarf unit relative offset.
659 unsigned Offset;
666 unsigned Offset = 0;
660667 /// Size of instance + children.
661 unsigned Size;
668 unsigned Size = 0;
662669 unsigned AbbrevNumber = ~0u;
663670 /// Dwarf tag code.
664671 dwarf::Tag Tag = (dwarf::Tag)0;
665672 /// Set to true to force a DIE to emit an abbreviation that says it has
666673 /// children even when it doesn't. This is used for unit testing purposes.
667 bool ForceChildren;
674 bool ForceChildren = false;
668675 /// Children DIEs.
669676 IntrusiveBackList Children;
670677
672679 /// DIEUnit which contains this DIE as its unit DIE.
673680 PointerUnion Owner;
674681
682 explicit DIE(dwarf::Tag Tag) : Tag(Tag) {}
683
684 public:
675685 DIE() = delete;
676 explicit DIE(dwarf::Tag Tag) : Offset(0), Size(0), Tag(Tag),
677 ForceChildren(false) {}
678
679 public:
686 DIE(const DIE &RHS) = delete;
687 DIE(DIE &&RHS) = delete;
688 DIE &operator=(const DIE &RHS) = delete;
689 DIE &operator=(const DIE &&RHS) = delete;
690
680691 static DIE *get(BumpPtrAllocator &Alloc, dwarf::Tag Tag) {
681692 return new (Alloc) DIE(Tag);
682693 }
683
684 DIE(const DIE &RHS) = delete;
685 DIE(DIE &&RHS) = delete;
686 void operator=(const DIE &RHS) = delete;
687 void operator=(const DIE &&RHS) = delete;
688694
689695 // Accessors.
690696 unsigned getAbbrevNumber() const { return AbbrevNumber; }
695701 bool hasChildren() const { return ForceChildren || !Children.empty(); }
696702 void setForceChildren(bool B) { ForceChildren = B; }
697703
698 typedef IntrusiveBackList::iterator child_iterator;
699 typedef IntrusiveBackList::const_iterator const_child_iterator;
700 typedef iterator_range child_range;
701 typedef iterator_range const_child_range;
704 using child_iterator = IntrusiveBackList::iterator;
705 using const_child_iterator = IntrusiveBackList::const_iterator;
706 using child_range = iterator_range;
707 using const_child_range = iterator_range;
702708
703709 child_range children() {
704710 return make_range(Children.begin(), Children.end());
837843 /// DIELoc - Represents an expression location.
838844 //
839845 class DIELoc : public DIEValueList {
840 mutable unsigned Size; // Size in bytes excluding size header.
841
842 public:
843 DIELoc() : Size(0) {}
846 mutable unsigned Size = 0; // Size in bytes excluding size header.
847
848 public:
849 DIELoc() = default;
844850
845851 /// ComputeSize - Calculate the size of the location expression.
846852 ///
871877 /// DIEBlock - Represents a block of values.
872878 //
873879 class DIEBlock : public DIEValueList {
874 mutable unsigned Size; // Size in bytes excluding size header.
875
876 public:
877 DIEBlock() : Size(0) {}
880 mutable unsigned Size = 0; // Size in bytes excluding size header.
881
882 public:
883 DIEBlock() = default;
878884
879885 /// ComputeSize - Calculate the size of the location expression.
880886 ///
5555 HandlerOffsetExpr(HandlerOffset) {}
5656 };
5757
58 typedef std::vector FunctionFaultInfos;
58 using FunctionFaultInfos = std::vector;
5959
6060 // We'd like to keep a stable iteration order for FunctionInfos to help
6161 // FileCheck based testing.
7777 /// generated by the version of LLVM that includes it. No guarantees are made
7878 /// with respect to forward or backward compatibility.
7979 class FaultMapParser {
80 typedef uint8_t FaultMapVersionType;
80 using FaultMapVersionType = uint8_t;
81 using Reserved0Type = uint8_t;
82 using Reserved1Type = uint16_t;
83 using NumFunctionsType = uint32_t;
84
8185 static const size_t FaultMapVersionOffset = 0;
82
83 typedef uint8_t Reserved0Type;
8486 static const size_t Reserved0Offset =
8587 FaultMapVersionOffset + sizeof(FaultMapVersionType);
86
87 typedef uint16_t Reserved1Type;
8888 static const size_t Reserved1Offset = Reserved0Offset + sizeof(Reserved0Type);
89
90 typedef uint32_t NumFunctionsType;
9189 static const size_t NumFunctionsOffset =
9290 Reserved1Offset + sizeof(Reserved1Type);
93
9491 static const size_t FunctionInfosOffset =
9592 NumFunctionsOffset + sizeof(NumFunctionsType);
9693
104101
105102 public:
106103 class FunctionFaultInfoAccessor {
107 typedef uint32_t FaultKindType;
104 using FaultKindType = uint32_t;
105 using FaultingPCOffsetType = uint32_t;
106 using HandlerPCOffsetType = uint32_t;
107
108108 static const size_t FaultKindOffset = 0;
109
110 typedef uint32_t FaultingPCOffsetType;
111109 static const size_t FaultingPCOffsetOffset =
112110 FaultKindOffset + sizeof(FaultKindType);
113
114 typedef uint32_t HandlerPCOffsetType;
115111 static const size_t HandlerPCOffsetOffset =
116112 FaultingPCOffsetOffset + sizeof(FaultingPCOffsetType);
117113
139135 };
140136
141137 class FunctionInfoAccessor {
142 typedef uint64_t FunctionAddrType;
138 using FunctionAddrType = uint64_t;
139 using NumFaultingPCsType = uint32_t;
140 using ReservedType = uint32_t;
141
143142 static const size_t FunctionAddrOffset = 0;
144
145 typedef uint32_t NumFaultingPCsType;
146143 static const size_t NumFaultingPCsOffset =
147144 FunctionAddrOffset + sizeof(FunctionAddrType);
148
149 typedef uint32_t ReservedType;
150145 static const size_t ReservedOffset =
151146 NumFaultingPCsOffset + sizeof(NumFaultingPCsType);
152
153147 static const size_t FunctionFaultInfosOffset =
154148 ReservedOffset + sizeof(ReservedType);
155
156149 static const size_t FunctionInfoHeaderSize = FunctionFaultInfosOffset;
157150
158151 const uint8_t *P = nullptr;
None //===-- llvm/CodeGen/LiveInterval.h - Interval representation ---*- C++ -*-===//
0 //===- llvm/CodeGen/LiveInterval.h - Interval representation ----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2020 #ifndef LLVM_CODEGEN_LIVEINTERVAL_H
2121 #define LLVM_CODEGEN_LIVEINTERVAL_H
2222
23 #include "llvm/ADT/ArrayRef.h"
2324 #include "llvm/ADT/IntEqClasses.h"
25 #include "llvm/ADT/iterator_range.h"
26 #include "llvm/ADT/SmallVector.h"
27 #include "llvm/ADT/STLExtras.h"
2428 #include "llvm/CodeGen/SlotIndexes.h"
29 #include "llvm/MC/LaneBitmask.h"
2530 #include "llvm/Support/Allocator.h"
26 #include "llvm/Target/TargetRegisterInfo.h"
31 #include "llvm/Support/MathExtras.h"
32 #include
2733 #include
28 #include limits>
34 #include stddef>
35 #include
36 #include
2937 #include
38 #include
39 #include
3040
3141 namespace llvm {
42
3243 class CoalescerPair;
3344 class LiveIntervals;
34 class MachineInstr;
3545 class MachineRegisterInfo;
36 class TargetRegisterInfo;
3746 class raw_ostream;
38 template class SmallPtrSet;
3947
4048 /// VNInfo - Value Number Information.
4149 /// This class holds information about a machine level values, including
4351 ///
4452 class VNInfo {
4553 public:
46 typedef BumpPtrAllocator Allocator;
54 using Allocator = BumpPtrAllocator;
4755
4856 /// The ID number of this value.
4957 unsigned id;
5260 SlotIndex def;
5361
5462 /// VNInfo constructor.
55 VNInfo(unsigned i, SlotIndex d)
56 : id(i), def(d)
57 { }
63 VNInfo(unsigned i, SlotIndex d) : id(i), def(d) {}
5864
5965 /// VNInfo constructor, copies values from orig, except for the value number.
60 VNInfo(unsigned i, const VNInfo &orig)
61 : id(i), def(orig.def)
62 { }
66 VNInfo(unsigned i, const VNInfo &orig) : id(i), def(orig.def) {}
6367
6468 /// Copy from the parameter into this VNInfo.
6569 void copyFrom(VNInfo &src) {
151155 /// segment with a new value number is used.
152156 class LiveRange {
153157 public:
154
155158 /// This represents a simple continuous liveness interval for a value.
156159 /// The start point is inclusive, the end point exclusive. These intervals
157160 /// are rendered as [start,end).
158161 struct Segment {
159162 SlotIndex start; // Start point of the interval (inclusive)
160163 SlotIndex end; // End point of the interval (exclusive)
161 VNInfo *valno; // identifier for the value contained in this segment.
162
163 Segment() : valno(nullptr) {}
164 VNInfo *valno = nullptr; // identifier for the value contained in this
165 // segment.
166
167 Segment() = default;
164168
165169 Segment(SlotIndex S, SlotIndex E, VNInfo *V)
166170 : start(S), end(E), valno(V) {
188192 void dump() const;
189193 };
190194
191 typedef SmallVector Segments;
192 typedef SmallVector VNInfoList;
195 using Segments = SmallVector;
196 using VNInfoList = SmallVector;
193197
194198 Segments segments; // the liveness segments
195199 VNInfoList valnos; // value#'s
197201 // The segment set is used temporarily to accelerate initial computation
198202 // of live ranges of physical registers in computeRegUnitRange.
199203 // After that the set is flushed to the segment vector and deleted.
200 typedef std::set SegmentSet;
204 using SegmentSet = std::set;
201205 std::unique_ptr segmentSet;
202206
203 typedef Segments::iterator iterator;
207 using iterator = Segments::iterator;
208 using const_iterator = Segments::const_iterator;
209
204210 iterator begin() { return segments.begin(); }
205211 iterator end() { return segments.end(); }
206212
207 typedef Segments::const_iterator const_iterator;
208213 const_iterator begin() const { return segments.begin(); }
209214 const_iterator end() const { return segments.end(); }
210215
211 typedef VNInfoList::iterator vni_iterator;
216 using vni_iterator = VNInfoList::iterator;
217 using const_vni_iterator = VNInfoList::const_iterator;
218
212219 vni_iterator vni_begin() { return valnos.begin(); }
213220 vni_iterator vni_end() { return valnos.end(); }
214221
215 typedef VNInfoList::const_iterator const_vni_iterator;
216222 const_vni_iterator vni_begin() const { return valnos.begin(); }
217223 const_vni_iterator vni_end() const { return valnos.end(); }
218224
630636 /// or stack slot.
631637 class LiveInterval : public LiveRange {
632638 public:
633 typedef LiveRange super;
639 using super = LiveRange;
634640
635641 /// A live range for subregisters. The LaneMask specifies which parts of the
636642 /// super register are covered by the interval.
637643 /// (@sa TargetRegisterInfo::getSubRegIndexLaneMask()).
638644 class SubRange : public LiveRange {
639645 public:
640 SubRange *Next;
646 SubRange *Next = nullptr;
641647 LaneBitmask LaneMask;
642648
643649 /// Constructs a new SubRange object.
644 SubRange(LaneBitmask LaneMask)
645 : Next(nullptr), LaneMask(LaneMask) {
646 }
650 SubRange(LaneBitmask LaneMask) : LaneMask(LaneMask) {}
647651
648652 /// Constructs a new SubRange object by copying liveness from @p Other.
649653 SubRange(LaneBitmask LaneMask, const LiveRange &Other,
650654 BumpPtrAllocator &Allocator)
651 : LiveRange(Other, Allocator), Next(nullptr), LaneMask(LaneMask) {
652 }
655 : LiveRange(Other, Allocator), LaneMask(LaneMask) {}
653656
654657 void print(raw_ostream &OS) const;
655658 void dump() const;
656659 };
657660
658661 private:
659 SubRange *SubRanges; ///< Single linked list of subregister live ranges.
662 SubRange *SubRanges = nullptr; ///< Single linked list of subregister live
663 /// ranges.
660664
661665 public:
662666 const unsigned reg; // the register or stack slot of this interval.
663667 float weight; // weight of this interval
664668
665 LiveInterval(unsigned Reg, float Weight)
666 : SubRanges(nullptr), reg(Reg), weight(Weight) {}
669 LiveInterval(unsigned Reg, float Weight) : reg(Reg), weight(Weight) {}
667670
668671 ~LiveInterval() {
669672 clearSubRanges();
672675 template
673676 class SingleLinkedListIterator {
674677 T *P;
678
675679 public:
676680 SingleLinkedListIterator(T *P) : P(P) {}
681
677682 SingleLinkedListIterator &operator++() {
678683 P = P->Next;
679684 return *this;
697702 }
698703 };
699704
700 typedef SingleLinkedListIterator subrange_iterator;
705 using subrange_iterator = SingleLinkedListIterator;
706 using const_subrange_iterator = SingleLinkedListIterator;
707
701708 subrange_iterator subrange_begin() {
702709 return subrange_iterator(SubRanges);
703710 }
705712 return subrange_iterator(nullptr);
706713 }
707714
708 typedef SingleLinkedListIterator const_subrange_iterator;
709715 const_subrange_iterator subrange_begin() const {
710716 return const_subrange_iterator(SubRanges);
711717 }
758764
759765 /// isSpillable - Can this interval be spilled?
760766 bool isSpillable() const {
761 return weight != llvm::huge_valf;
767 return weight != huge_valf;
762768 }
763769
764770 /// markNotSpillable - Mark interval as not spillable
765771 void markNotSpillable() {
766 weight = llvm::huge_valf;
772 weight = huge_valf;
767773 }
768774
769775 /// For a given lane mask @p LaneMask, compute indexes at which the
930936 void Distribute(LiveInterval &LI, LiveInterval *LIV[],
931937 MachineRegisterInfo &MRI);
932938 };
933 }
934 #endif
939
940 } // end namespace llvm
941
942 #endif // LLVM_CODEGEN_LIVEINTERVAL_H
None //===-- LiveIntervalAnalysis.h - Live Interval Analysis ---------*- C++ -*-===//
0 //===- LiveIntervalAnalysis.h - Live Interval Analysis ----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1919 #ifndef LLVM_CODEGEN_LIVEINTERVALANALYSIS_H
2020 #define LLVM_CODEGEN_LIVEINTERVALANALYSIS_H
2121
22 #include "llvm/ADT/ArrayRef.h"
2223 #include "llvm/ADT/IndexedMap.h"
2324 #include "llvm/ADT/SmallVector.h"
2425 #include "llvm/Analysis/AliasAnalysis.h"
2627 #include "llvm/CodeGen/MachineBasicBlock.h"
2728 #include "llvm/CodeGen/MachineFunctionPass.h"
2829 #include "llvm/CodeGen/SlotIndexes.h"
29 #include "llvm/Support/Allocator.h"
30 #include "llvm/MC/LaneBitmask.h"
3031 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/Compiler.h"
33 #include "llvm/Support/ErrorHandling.h"
3134 #include "llvm/Target/TargetRegisterInfo.h"
32 #include math>
35 #include assert>
36 #include
37 #include
3338
3439 namespace llvm {
3540
3641 extern cl::opt UseSegmentSetForPhysRegs;
3742
38 class BitVector;
39 class BlockFrequency;
40 class LiveRangeCalc;
41 class LiveVariables;
42 class MachineDominatorTree;
43 class MachineLoopInfo;
44 class TargetRegisterInfo;
45 class MachineRegisterInfo;
46 class TargetInstrInfo;
47 class TargetRegisterClass;
48 class VirtRegMap;
49 class MachineBlockFrequencyInfo;
43 class BitVector;
44 class LiveRangeCalc;
45 class MachineBlockFrequencyInfo;
46 class MachineDominatorTree;
47 class MachineFunction;
48 class MachineInstr;
49 class MachineRegisterInfo;
50 class raw_ostream;
51 class TargetInstrInfo;
52 class VirtRegMap;
5053
5154 class LiveIntervals : public MachineFunctionPass {
5255 MachineFunction* MF;
5558 const TargetInstrInfo* TII;
5659 AliasAnalysis *AA;
5760 SlotIndexes* Indexes;
58 MachineDominatorTree *DomTree;
59 LiveRangeCalc *LRCalc;
61 MachineDominatorTree *DomTree = nullptr;
62 LiveRangeCalc *LRCalc = nullptr;
6063
6164 /// Special pool allocator for VNInfo's (LiveInterval val#).
6265 VNInfo::Allocator VNInfoAllocator;
9497
9598 public:
9699 static char ID;
100
97101 LiveIntervals();
98102 ~LiveIntervals() override;
99103
465469
466470 class HMEditor;
467471 };
468 } // End llvm namespace
469
470 #endif
472
473 } // end namespace llvm
474
475 #endif // LLVM_CODEGEN_LIVEINTERVALANALYSIS_H
2525
2626 namespace llvm {
2727
28 class raw_ostream;
2829 class TargetRegisterInfo;
2930
3031 #ifndef NDEBUG
3132 // forward declaration
3233 template class SparseBitVector;
33 typedef SparseBitVector<128> LiveVirtRegBitSet;
34
35 using LiveVirtRegBitSet = SparseBitVector<128>;
3436 #endif
3537
3638 /// Union of live intervals that are strong candidates for coalescing into a
4143 // A set of live virtual register segments that supports fast insertion,
4244 // intersection, and removal.
4345 // Mapping SlotIndex intervals to virtual register numbers.
44 typedef IntervalMap LiveSegments;
46 using LiveSegments = IntervalMap;
4547
4648 public:
4749 // SegmentIter can advance to the next segment ordered by starting position
4850 // which may belong to a different live virtual register. We also must be able
4951 // to reach the current segment's containing virtual register.
50 typedef LiveSegments::iterator SegmentIter;
52 using SegmentIter = LiveSegments::iterator;
5153
5254 /// Const version of SegmentIter.
53 typedef LiveSegments::const_iterator ConstSegmentIter;
55 using ConstSegmentIter = LiveSegments::const_iterator;
5456
5557 // LiveIntervalUnions share an external allocator.
56 typedef LiveSegments::Allocator Allocator;
58 using Allocator = LiveSegments::Allocator;
5759
5860 private:
5961 unsigned Tag = 0; // unique tag for current contents.
7577 SlotIndex startIndex() const { return Segments.start(); }
7678
7779 // Provide public access to the underlying map to allow overlap iteration.
78 typedef LiveSegments Map;
80 using Map = LiveSegments;
7981 const Map &getMap() const { return Segments; }
8082
8183 /// getTag - Return an opaque tag representing the current state of the union.
3838 namespace llvm {
3939
4040 class MachineInstr;
41 class MachineOperand;
42 class MachineRegisterInfo;
43 class raw_ostream;
4144
4245 /// \brief A set of live physical registers with functions to track liveness
4346 /// when walking backward/forward through a basic block.
4447 class LivePhysRegs {
4548 const TargetRegisterInfo *TRI = nullptr;
4649 SparseSet LiveRegs;
47
48 LivePhysRegs(const LivePhysRegs&) = delete;
49 LivePhysRegs &operator=(const LivePhysRegs&) = delete;
5050
5151 public:
5252 /// \brief Constructs a new empty LivePhysRegs set.
5757 assert(TRI && "Invalid TargetRegisterInfo pointer.");
5858 LiveRegs.setUniverse(TRI->getNumRegs());
5959 }
60
61 LivePhysRegs(const LivePhysRegs&) = delete;
62 LivePhysRegs &operator=(const LivePhysRegs&) = delete;
6063
6164 /// \brief Clear and initialize the LivePhysRegs set.
6265 void init(const TargetRegisterInfo &TRI) {
133136 /// registers.
134137 void addLiveOutsNoPristines(const MachineBasicBlock &MBB);
135138
136 typedef SparseSet::const_iterator const_iterator;
139 using const_iterator = SparseSet::const_iterator;
140
137141 const_iterator begin() const { return LiveRegs.begin(); }
138142 const_iterator end() const { return LiveRegs.end(); }
139143
None //===---- LiveRangeEdit.h - Basic tools for split and spill -----*- C++ -*-===//
0 //===- LiveRangeEdit.h - Basic tools for split and spill --------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1818 #define LLVM_CODEGEN_LIVERANGEEDIT_H
1919
2020 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/None.h"
2122 #include "llvm/ADT/SetVector.h"
2223 #include "llvm/ADT/SmallPtrSet.h"
24 #include "llvm/ADT/SmallVector.h"
2325 #include "llvm/Analysis/AliasAnalysis.h"
2426 #include "llvm/CodeGen/LiveInterval.h"
27 #include "llvm/CodeGen/MachineBasicBlock.h"
28 #include "llvm/CodeGen/MachineFunction.h"
2529 #include "llvm/CodeGen/MachineRegisterInfo.h"
26 #include "llvm/Target/TargetMachine.h"
30 #include "llvm/CodeGen/SlotIndexes.h"
2731 #include "llvm/Target/TargetSubtargetInfo.h"
32 #include
2833
2934 namespace llvm {
3035
3136 class LiveIntervals;
3237 class MachineBlockFrequencyInfo;
38 class MachineInstr;
3339 class MachineLoopInfo;
40 class MachineOperand;
41 class TargetInstrInfo;
42 class TargetRegisterInfo;
3443 class VirtRegMap;
3544
3645 class LiveRangeEdit : private MachineRegisterInfo::Delegate {
3847 /// Callback methods for LiveRangeEdit owners.
3948 class Delegate {
4049 virtual void anchor();
50
4151 public:
52 virtual ~Delegate() = default;
53
4254 /// Called immediately before erasing a dead machine instruction.
4355 virtual void LRE_WillEraseInstruction(MachineInstr *MI) {}
4456
5264 /// Called after cloning a virtual register.
5365 /// This is used for new registers representing connected components of Old.
5466 virtual void LRE_DidCloneVirtReg(unsigned New, unsigned Old) {}
55
56 virtual ~Delegate() {}
5767 };
5868
5969 private:
6979 const unsigned FirstNew;
7080
7181 /// ScannedRemattable - true when remattable values have been identified.
72 bool ScannedRemattable;
82 bool ScannedRemattable = false;
7383
7484 /// DeadRemats - The saved instructions which have already been dead after
7585 /// rematerialization but not deleted yet -- to be done in postOptimization.
7787
7888 /// Remattable - Values defined by remattable instructions as identified by
7989 /// tii.isTriviallyReMaterializable().
80 SmallPtrSet*,4> Remattable;
90 SmallPtrSet *, 4> Remattable;
8191
8292 /// Rematted - Values that were actually rematted, and so need to have their
8393 /// live range trimmed or entirely removed.
84 SmallPtrSet*,4> Rematted;
94 SmallPtrSet *, 4> Rematted;
8595
8696 /// scanRemattable - Identify the Parent values that may rematerialize.
8797 void scanRemattable(AliasAnalysis *aa);
93103
94104 /// foldAsLoad - If LI has a single use and a single def that can be folded as
95105 /// a load, eliminate the register by folding the def into the use.
96 bool foldAsLoad(LiveInterval *LI, SmallVectorImpl &Dead);
97
98 typedef SetVector
99 SmallVector,
100 SmallPtrSet > ToShrinkSet;
106 bool foldAsLoad(LiveInterval *LI, SmallVectorImpl &Dead);
107
108 using ToShrinkSet = SetVector,
109 SmallPtrSet>;
110
101111 /// Helper for eliminateDeadDefs.
102112 void eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink,
103113 AliasAnalysis *AA);
128138 SmallPtrSet *deadRemats = nullptr)
129139 : Parent(parent), NewRegs(newRegs), MRI(MF.getRegInfo()), LIS(lis),
130140 VRM(vrm), TII(*MF.getSubtarget().getInstrInfo()), TheDelegate(delegate),
131 FirstNew(newRegs.size()), ScannedRemattable(false),
132 DeadRemats(deadRemats) {
141 FirstNew(newRegs.size()), DeadRemats(deadRemats) {
133142 MRI.setDelegate(this);
134143 }
135144
136145 ~LiveRangeEdit() override { MRI.resetDelegate(this); }
137146
138147 LiveInterval &getParent() const {
139 assert(Parent && "No parent LiveInterval");
140 return *Parent;
141 }
148 assert(Parent && "No parent LiveInterval");
149 return *Parent;
150 }
151
142152 unsigned getReg() const { return getParent().reg; }
143153
144154 /// Iterator for accessing the new registers added by this edit.
145 typedef SmallVectorImpl::const_iterator iterator;
146 iterator begin() const { return NewRegs.begin()+FirstNew; }
155 using iterator = SmallVectorImpl::const_iterator;
156 iterator begin() const { return NewRegs.begin() + FirstNew; }
147157 iterator end() const { return NewRegs.end(); }
148 unsigned size() const { return NewRegs.size()-FirstNew; }
158 unsigned size() const { return NewRegs.size() - FirstNew; }
149159 bool empty() const { return size() == 0; }
150 unsigned get(unsigned idx) const { return NewRegs[idx+FirstNew]; }
160 unsigned get(unsigned idx) const { return NewRegs[idx + FirstNew]; }
151161
152162 /// pop_back - It allows LiveRangeEdit users to drop new registers.
153163 /// The context is when an original def instruction of a register is
175185 return createEmptyIntervalFrom(getReg());
176186 }
177187
178 unsigned create() {
179 return createFrom(getReg());
180 }
188 unsigned create() { return createFrom(getReg()); }
181189
182190 /// anyRematerializable - Return true if any parent values may be
183191 /// rematerializable.
184192 /// This function must be called before any rematerialization is attempted.
185 bool anyRematerializable(AliasAnalysis*);
193 bool anyRematerializable(AliasAnalysis *);
186194
187195 /// checkRematerializable - Manually add VNI to the list of rematerializable
188196 /// values if DefMI may be rematerializable.
189197 bool checkRematerializable(VNInfo *VNI, const MachineInstr *DefMI,
190 AliasAnalysis*);
198 AliasAnalysis *);
191199
192200 /// Remat - Information needed to rematerialize at a specific location.
193201 struct Remat {
194 VNInfo *ParentVNI; // parent_'s value at the remat location.
195 MachineInstr *OrigMI; // Instruction defining OrigVNI. It contains the
196 // real expr for remat.
197 explicit Remat(VNInfo *ParentVNI) : ParentVNI(ParentVNI), OrigMI(nullptr) {}
202 VNInfo *ParentVNI; // parent_'s value at the remat location.
203 MachineInstr *OrigMI = nullptr; // Instruction defining OrigVNI. It contains
204 // the real expr for remat.
205
206 explicit Remat(VNInfo *ParentVNI) : ParentVNI(ParentVNI) {}
198207 };
199208
200209 /// canRematerializeAt - Determine if ParentVNI can be rematerialized at
208217 /// liveness is not updated.
209218 /// Return the SlotIndex of the new instruction.
210219 SlotIndex rematerializeAt(MachineBasicBlock &MBB,
211 MachineBasicBlock::iterator MI,
212 unsigned DestReg,
213 const Remat &RM,
214 const TargetRegisterInfo&,
220 MachineBasicBlock::iterator MI, unsigned DestReg,
221 const Remat &RM, const TargetRegisterInfo &,
215222 bool Late = false);
216223
217224 /// markRematerialized - explicitly mark a value as rematerialized after doing
247254
248255 /// calculateRegClassAndHint - Recompute register class and hint for each new
249256 /// register.
250 void calculateRegClassAndHint(MachineFunction&,
251 const MachineLoopInfo&,
252 const MachineBlockFrequencyInfo&);
257 void calculateRegClassAndHint(MachineFunction &, const MachineLoopInfo &,
258 const MachineBlockFrequencyInfo &);
253259 };
254260
255 }
256
257 #endif
261 } // end namespace llvm
262
263 #endif // LLVM_CODEGEN_LIVERANGEEDIT_H
None //===-- LiveStackAnalysis.h - Live Stack Slot Analysis ----------*- C++ -*-===//
0 //===- LiveStackAnalysis.h - Live Stack Slot Analysis -----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1717
1818 #include "llvm/CodeGen/LiveInterval.h"
1919 #include "llvm/CodeGen/MachineFunctionPass.h"
20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Target/TargetRegisterInfo.h"
20 #include "llvm/Pass.h"
21 #include
2222 #include
2323 #include
2424
2525 namespace llvm {
26
27 class TargetRegisterClass;
28 class TargetRegisterInfo;
2629
2730 class LiveStacks : public MachineFunctionPass {
2831 const TargetRegisterInfo *TRI;
3235 VNInfo::Allocator VNInfoAllocator;
3336
3437 /// S2IMap - Stack slot indices to live interval mapping.
35 ///
36 typedef std::unordered_map SS2IntervalMap;
38 using SS2IntervalMap = std::unordered_map;
3739 SS2IntervalMap S2IMap;
3840
3941 /// S2RCMap - Stack slot indices to register class mapping.
4143
4244 public:
4345 static char ID; // Pass identification, replacement for typeid
46
4447 LiveStacks() : MachineFunctionPass(ID) {
4548 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
4649 }
4750
48 typedef SS2IntervalMap::iterator iterator;
49 typedef SS2IntervalMap::const_iterator const_iterator;
51 using iterator = SS2IntervalMap::iterator;
52 using const_iterator = SS2IntervalMap::const_iterator;
53
5054 const_iterator begin() const { return S2IMap.begin(); }
5155 const_iterator end() const { return S2IMap.end(); }
5256 iterator begin() { return S2IMap.begin(); }
9296 /// print - Implement the dump method.
9397 void print(raw_ostream &O, const Module * = nullptr) const override;
9498 };
95 }
9699
97 #endif /* LLVM_CODEGEN_LIVESTACK_ANALYSIS_H */
100 } // end namespace llvm
101
102 #endif // LLVM_CODEGEN_LIVESTACK_ANALYSIS_H
None //===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*-===//
0 //===- llvm/CodeGen/MachineBasicBlock.h -------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
1515
1616 #include "llvm/ADT/GraphTraits.h"
17 #include "llvm/ADT/ilist.h"
18 #include "llvm/ADT/ilist_node.h"
1719 #include "llvm/ADT/iterator_range.h"
20 #include "llvm/ADT/simple_ilist.h"
1821 #include "llvm/CodeGen/MachineInstrBundleIterator.h"
1922 #include "llvm/CodeGen/MachineInstr.h"
23 #include "llvm/IR/DebugLoc.h"
2024 #include "llvm/Support/BranchProbability.h"
2125 #include "llvm/MC/LaneBitmask.h"
2226 #include "llvm/MC/MCRegisterInfo.h"
23 #include "llvm/Support/DataTypes.h"
27 #include
28 #include
2429 #include
30 #include
31 #include
32 #include
2533
2634 namespace llvm {
2735
28 class Pass;
2936 class BasicBlock;
3037 class MachineFunction;
3138 class MCSymbol;
32 class MIPrinter;
39 class ModuleSlotTracker;
40 class Pass;
3341 class SlotIndexes;
3442 class StringRef;
3543 class raw_ostream;
36 class MachineBranchProbabilityInfo;
44 class TargetRegisterClass;
45 class TargetRegisterInfo;
3746
3847 template <> struct ilist_traits {
3948 private:
4049 friend class MachineBasicBlock; // Set by the owning MachineBasicBlock.
50
4151 MachineBasicBlock *Parent;
4252
43 typedef simple_ilist>::iterator
44 instr_iterator;
53 using instr_iterator =
54 simple_ilist>::iterator;
4555
4656 public:
4757 void addNodeToList(MachineInstr *N);
4858 void removeNodeFromList(MachineInstr *N);
4959 void transferNodesFromList(ilist_traits &OldList, instr_iterator First,
5060 instr_iterator Last);
51
5261 void deleteNode(MachineInstr *MI);
5362 };
5463
6877 };
6978
7079 private:
71 typedef ilist> Instructions;
80 using Instructions = ilist>;
81
7282 Instructions Insts;
7383 const BasicBlock *BB;
7484 int Number;
8292 /// same order as Successors, or it is empty if we don't use it (disable
8393 /// optimization).
8494 std::vector Probs;
85 typedef std::vector::iterator probability_iterator;
86 typedef std::vector::const_iterator
87 const_probability_iterator;
95 using probability_iterator = std::vector::iterator;
96 using const_probability_iterator =
97 std::vector::const_iterator;
8898
8999 /// Keep track of the physical registers that are livein of the basicblock.
90 typedef std::vector LiveInVector;
100 using LiveInVector = std::vector;
91101 LiveInVector LiveIns;
92102
93103 /// Alignment of the basic block. Zero if the basic block does not need to be
112122 mutable MCSymbol *CachedMCSymbol = nullptr;
113123
114124 // Intrusive list support
115 MachineBasicBlock() {}
125 MachineBasicBlock() = default;
116126
117127 explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB);
118128
144154 const MachineFunction *getParent() const { return xParent; }
145155 MachineFunction *getParent() { return xParent; }
146156
147 typedef Instructions::iterator instr_iterator;
148 typedef Instructions::const_iterator const_instr_iterator;
149 typedef Instructions::reverse_iterator reverse_instr_iterator;
150 typedef Instructions::const_reverse_iterator const_reverse_instr_iterator;
151
152 typedef MachineInstrBundleIterator iterator;
153 typedef MachineInstrBundleIterator const_iterator;
154 typedef MachineInstrBundleIterator reverse_iterator;
155 typedef MachineInstrBundleIterator
156 const_reverse_iterator;
157 using instr_iterator = Instructions::iterator;
158 using const_instr_iterator = Instructions::const_iterator;
159 using reverse_instr_iterator = Instructions::reverse_iterator;
160 using const_reverse_instr_iterator = Instructions::const_reverse_iterator;
161
162 using iterator = MachineInstrBundleIterator;
163 using const_iterator = MachineInstrBundleIterator;
164 using reverse_iterator = MachineInstrBundleIterator;
165 using const_reverse_iterator =
166 MachineInstrBundleIterator;
157167
158168 unsigned size() const { return (unsigned)Insts.size(); }
159169 bool empty() const { return Insts.empty(); }
177187 reverse_instr_iterator instr_rend () { return Insts.rend(); }
178188 const_reverse_instr_iterator instr_rend () const { return Insts.rend(); }
179189
180 typedef iterator_range instr_range;
181 typedef iterator_range const_instr_range;
190 using instr_range = iterator_range;
191 using const_instr_range = iterator_range;
182192 instr_range instrs() { return instr_range(instr_begin(), instr_end()); }
183193 const_instr_range instrs() const {
184194 return const_instr_range(instr_begin(), instr_end());
212222 }
213223
214224 // Machine-CFG iterators
215 typedef std::vector::iterator pred_iterator;
216 typedef std::vector::const_iterator const_pred_iterator;
217 typedef std::vector::iterator succ_iterator;
218 typedef std::vector::const_iterator const_succ_iterator;
219 typedef std::vector::reverse_iterator
220 pred_reverse_iterator;
221 typedef std::vector::const_reverse_iterator
222 const_pred_reverse_iterator;
223 typedef std::vector::reverse_iterator
224 succ_reverse_iterator;
225 typedef std::vector::const_reverse_iterator
226 const_succ_reverse_iterator;
225 using pred_iterator = std::vector::iterator;
226 using const_pred_iterator = std::vector::const_iterator;
227 using succ_iterator = std::vector::iterator;
228 using const_succ_iterator = std::vector::const_iterator;
229 using pred_reverse_iterator =
230 std::vector::reverse_iterator;
231 using const_pred_reverse_iterator =
232 std::vector::const_reverse_iterator;
233 using succ_reverse_iterator =
234 std::vector::reverse_iterator;
235 using const_succ_reverse_iterator =
236 std::vector::const_reverse_iterator;
227237 pred_iterator pred_begin() { return Predecessors.begin(); }
228238 const_pred_iterator pred_begin() const { return Predecessors.begin(); }
229239 pred_iterator pred_end() { return Predecessors.end(); }
306316
307317 // Iteration support for live in sets. These sets are kept in sorted
308318 // order by their register number.
309 typedef LiveInVector::const_iterator livein_iterator;
319 using livein_iterator = LiveInVector::const_iterator;
310320 #ifndef NDEBUG
311321 /// Unlike livein_begin, this method does not check that the liveness
312322 /// information is accurate. Still for debug purposes it may be useful
453463 /// all, for example if this block ends with an unconditional branch to some
454464 /// other block.
455465 bool isLayoutSuccessor(const MachineBasicBlock *MBB) const;
456
457466
458467 /// Return the fallthrough block if the block can implicitly
459468 /// transfer control to the block after it by falling off the end of
694703 LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI,
695704 unsigned Reg,
696705 const_iterator Before,
697 unsigned Neighborhood=10) const;
706 unsigned Neighborhood = 10) const;
698707
699708 // Debugging methods.
700709 void dump() const;
713722 /// Return the MCSymbol for this basic block.
714723 MCSymbol *getSymbol() const;
715724
716
717725 private:
718726 /// Return probability iterator corresponding to the I successor iterator.
719727 probability_iterator getProbabilityIterator(succ_iterator I);
763771 //
764772
765773 template <> struct GraphTraits {
766 typedef MachineBasicBlock *NodeRef;
767 typedef MachineBasicBlock::succ_iterator ChildIteratorType;
774 using NodeRef = MachineBasicBlock *;
775 using ChildIteratorType = MachineBasicBlock::succ_iterator;
768776
769777 static NodeRef getEntryNode(MachineBasicBlock *BB) { return BB; }
770778 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
772780 };
773781
774782 template <> struct GraphTraits {
775 typedef const MachineBasicBlock *NodeRef;
776 typedef MachineBasicBlock::const_succ_iterator ChildIteratorType;
783 using NodeRef = const MachineBasicBlock *;
784 using ChildIteratorType = MachineBasicBlock::const_succ_iterator;
777785
778786 static NodeRef getEntryNode(const MachineBasicBlock *BB) { return BB; }
779787 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
786794 // to be when traversing the predecessor edges of a MBB
787795 // instead of the successor edges.
788796 //
789 template <> struct GraphTraits > {
790 typedef MachineBasicBlock *NodeRef;
791 typedef MachineBasicBlock::pred_iterator ChildIteratorType;
797 template <> struct GraphTraits> {
798 using NodeRef = MachineBasicBlock *;
799 using ChildIteratorType = MachineBasicBlock::pred_iterator;
800
792801 static NodeRef getEntryNode(Inverse G) {
793802 return G.Graph;
794803 }
804
795805 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
796806 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
797807 };
798808
799 template <> struct GraphTraits > {
800 typedef const MachineBasicBlock *NodeRef;
801 typedef MachineBasicBlock::const_pred_iterator ChildIteratorType;
809 template <> struct GraphTraits> {
810 using NodeRef = const MachineBasicBlock *;
811 using ChildIteratorType = MachineBasicBlock::const_pred_iterator;
812
802813 static NodeRef getEntryNode(Inverse G) {
803814 return G.Graph;
804815 }
816
805817 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
806818 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
807819 };
808
809
810820
811821 /// MachineInstrSpan provides an interface to get an iteration range
812822 /// containing the instruction it was initialized with, along with all
815825 class MachineInstrSpan {
816826 MachineBasicBlock &MBB;
817827 MachineBasicBlock::iterator I, B, E;
828
818829 public:
819830 MachineInstrSpan(MachineBasicBlock::iterator I)
820831 : MBB(*I->getParent()),
853864 return It;
854865 }
855866
856 } // End llvm namespace
857
858 #endif
867 } // end namespace llvm
868
869 #endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H
None //===- MachineBlockFrequencyInfo.h - MBB Frequency Analysis -*- C++ -*-----===//
0 //===- MachineBlockFrequencyInfo.h - MBB Frequency Analysis -----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1616 #include "llvm/ADT/Optional.h"
1717 #include "llvm/CodeGen/MachineFunctionPass.h"
1818 #include "llvm/Support/BlockFrequency.h"
19 #include limits>
19 #include stdint>
20 #include
2021
2122 namespace llvm {
2223
24 template class BlockFrequencyInfoImpl;
2325 class MachineBasicBlock;
2426 class MachineBranchProbabilityInfo;
27 class MachineFunction;
2528 class MachineLoopInfo;
26 template class BlockFrequencyInfoImpl;
29 class raw_ostream;
2730
2831 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
2932 /// to estimate machine basic block frequencies.
3033 class MachineBlockFrequencyInfo : public MachineFunctionPass {
31 typedef BlockFrequencyInfoImpl ImplType;
34 using ImplType = BlockFrequencyInfoImpl;
3235 std::unique_ptr MBFI;
3336
3437 public:
3538 static char ID;
3639
3740 MachineBlockFrequencyInfo();
38
3941 ~MachineBlockFrequencyInfo() override;
4042
4143 void getAnalysisUsage(AnalysisUsage &AU) const override;
7375 const MachineBasicBlock *MBB) const;
7476
7577 uint64_t getEntryFreq() const;
76
7778 };
7879
79 }
80 } // end namespace llvm
8081
81 #endif
82 #endif // LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
1010 #define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
1111
1212 #include "llvm/Analysis/DominanceFrontier.h"
13 #include "llvm/Analysis/DominanceFrontierImpl.h"
1314 #include "llvm/CodeGen/MachineBasicBlock.h"
1415 #include "llvm/CodeGen/MachineFunctionPass.h"
15
16 #include "llvm/Support/GenericDomTree.h"
17 #include
1618
1719 namespace llvm {
1820
1921 class MachineDominanceFrontier : public MachineFunctionPass {
2022 ForwardDominanceFrontierBase Base;
23
2124 public:
22 typedef DominatorTreeBase DomTreeT;
23 typedef DomTreeNodeBase DomTreeNodeT;
24 typedef DominanceFrontierBase::DomSetType DomSetType;
25 typedef DominanceFrontierBase::iterator iterator;
26 typedef DominanceFrontierBase::const_iterator const_iterator;
25 using DomTreeT = DominatorTreeBase;
26 using DomTreeNodeT = DomTreeNodeBase;
27 using DomSetType = DominanceFrontierBase::DomSetType;
28 using iterator = DominanceFrontierBase::iterator;
29 using const_iterator =
30 DominanceFrontierBase::const_iterator;
2731
28 void operator=(const MachineDominanceFrontier &) = delete;
2932 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete;
33 MachineDominanceFrontier &
34 operator=(const MachineDominanceFrontier &) = delete;
3035
3136 static char ID;
3237
103108 void getAnalysisUsage(AnalysisUsage &AU) const override;
104109 };
105110
106 }
111 } // end namespace llvm
107112
108 #endif
113 #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
None //=- llvm/CodeGen/MachineDominators.h - Machine Dom Calculation --*- C++ -*-==//
0 //==- llvm/CodeGen/MachineDominators.h - Machine Dom Calculation -*- C++ -*-==//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #define LLVM_CODEGEN_MACHINEDOMINATORS_H
1616
1717 #include "llvm/ADT/SmallSet.h"
18 #include "llvm/ADT/SmallVector.h"
1819 #include "llvm/CodeGen/MachineBasicBlock.h"
19 #include "llvm/CodeGen/MachineFunction.h"
2020 #include "llvm/CodeGen/MachineFunctionPass.h"
21 #include "llvm/CodeGen/MachineInstr.h"
2122 #include "llvm/Support/GenericDomTree.h"
2223 #include "llvm/Support/GenericDomTreeConstruction.h"
24 #include
2325 #include
26 #include
2427
2528 namespace llvm {
2629
3235 extern template class DomTreeNodeBase;
3336 extern template class DominatorTreeBase;
3437
35 typedef DomTreeNodeBase MachineDomTreeNode;
38 using MachineDomTreeNode = DomTreeNodeBase;
3639
3740 //===-------------------------------------
3841 /// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to
5154 /// The splitting of a critical edge is local and thus, it is possible
5255 /// to apply several of those changes at the same time.
5356 mutable SmallVector CriticalEdgesToSplit;
57
5458 /// \brief Remember all the basic blocks that are inserted during
5559 /// edge splitting.
5660 /// Invariant: NewBBs == all the basic blocks contained in the NewBB
258262
259263 template
260264 struct MachineDomTreeGraphTraitsBase {
261 typedef Node *NodeRef;
262 typedef ChildIterator ChildIteratorType;
265 using NodeRef = Node *;
266 using ChildIteratorType = ChildIterator;
263267
264268 static NodeRef getEntryNode(NodeRef N) { return N; }
265269 static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
286290 }
287291 };
288292
289 }
290
291 #endif
293 } // end namespace llvm
294
295 #endif // LLVM_CODEGEN_MACHINEDOMINATORS_H
None //===-- LiveIntervalAnalysis.cpp - Live Interval Analysis -----------------===//
0 //===- LiveIntervalAnalysis.cpp - Live Interval Analysis ------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 //
1414 //===----------------------------------------------------------------------===//
1515
16 #include "LiveRangeCalc.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/DepthFirstIterator.h"
19 #include "llvm/ADT/iterator_range.h"
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/Analysis/AliasAnalysis.h"
23 #include "llvm/CodeGen/LiveInterval.h"
1624 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
17 #include "LiveRangeCalc.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/Analysis/AliasAnalysis.h"
2025 #include "llvm/CodeGen/LiveVariables.h"
26 #include "llvm/CodeGen/MachineBasicBlock.h"
2127 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
2228 #include "llvm/CodeGen/MachineDominators.h"
29 #include "llvm/CodeGen/MachineFunction.h"
2330 #include "llvm/CodeGen/MachineInstr.h"
31 #include "llvm/CodeGen/MachineInstrBundle.h"
32 #include "llvm/CodeGen/MachineOperand.h"
2433 #include "llvm/CodeGen/MachineRegisterInfo.h"
2534 #include "llvm/CodeGen/Passes.h"
35 #include "llvm/CodeGen/SlotIndexes.h"
2636 #include "llvm/CodeGen/VirtRegMap.h"
27 #include "llvm/IR/Value.h"
37 #include "llvm/MC/LaneBitmask.h"
38 #include "llvm/MC/MCRegisterInfo.h"
39 #include "llvm/Pass.h"
2840 #include "llvm/Support/BlockFrequency.h"
2941 #include "llvm/Support/CommandLine.h"
42 #include "llvm/Support/Compiler.h"
3043 #include "llvm/Support/Debug.h"
31 #include "llvm/Support/ErrorHandling.h"
44 #include "llvm/Support/MathExtras.h"
3245 #include "llvm/Support/raw_ostream.h"
33 #include "llvm/Target/TargetInstrInfo.h"
3446 #include "llvm/Target/TargetRegisterInfo.h"
3547 #include "llvm/Target/TargetSubtargetInfo.h"
3648 #include
37 #include math>
49 #include assert>
50 #include
51 #include
52 #include
53 #include
54
3855 using namespace llvm;
3956
4057 #define DEBUG_TYPE "regalloc"
5875 #endif // NDEBUG
5976
6077 namespace llvm {
78
6179 cl::opt UseSegmentSetForPhysRegs(
6280 "use-segment-set-for-physregs", cl::Hidden, cl::init(true),
6381 cl::desc(
6482 "Use segment set for the computation of the live ranges of physregs."));
65 }
83
84 } // end namespace llvm
6685
6786 void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
6887 AU.setPreservesCFG();
7796 MachineFunctionPass::getAnalysisUsage(AU);
7897 }
7998
80 LiveIntervals::LiveIntervals() : MachineFunctionPass(ID),
81 DomTree(nullptr), LRCalc(nullptr) {
99 LiveIntervals::LiveIntervals() : MachineFunctionPass(ID) {
82100 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
83101 }
84102
167185 #endif
168186
169187 LiveInterval* LiveIntervals::createInterval(unsigned reg) {
170 float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ?
171 llvm::huge_valf : 0.0F;
188 float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ? huge_valf : 0.0F;
172189 return new LiveInterval(reg, Weight);
173190 }
174
175191
176192 /// Compute the live interval of a virtual register, based on defs and uses.
177193 void LiveIntervals::computeVirtRegInterval(LiveInterval &LI) {
336352 }
337353 }
338354
339 typedef SmallVector, 16> ShrinkToUsesWorkList;
355 using ShrinkToUsesWorkList = SmallVector, 16>;
340356
341357 static void extendSegmentsToUses(LiveRange &LR, const SlotIndexes &Indexes,
342358 ShrinkToUsesWorkList &WorkList,
592608 // Find all blocks that are reachable from KillMBB without leaving VNI's live
593609 // range. It is possible that KillMBB itself is reachable, so start a DFS
594610 // from each successor.
595 typedef df_iterator_default_set VisitedTy;
611 using VisitedTy = df_iterator_default_set;
596612 VisitedTy Visited;
597613 for (MachineBasicBlock *Succ : KillMBB->successors()) {
598614 for (df_ext_iterator
821837 return S;
822838 }
823839
824
825840 //===----------------------------------------------------------------------===//
826841 // Register mask functions
827842 //===----------------------------------------------------------------------===//
854869 return false;
855870
856871 bool Found = false;
857 for (;;) {
872 while (true) {
858873 assert(*SlotI >= LiveI->start);
859874 // Loop over all slots overlapping this segment.
860875 while (*SlotI < LiveI->end) {