llvm.org GIT mirror llvm / af65035
Remove unused MachineLoopRanges analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168659 91177308-0d34-0410-b5e6-96231b3b80d8 Jakub Staszak 8 years ago
7 changed file(s) with 0 addition(s) and 265 deletion(s). Raw diff Collapse all Expand all
None //===- MachineLoopRanges.h - Ranges of machine loops -----------*- c++ -*--===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the interface to the MachineLoopRanges analysis.
10 //
11 // Provide on-demand information about the ranges of machine instructions
12 // covered by a loop.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CODEGEN_MACHINELOOPRANGES_H
17 #define LLVM_CODEGEN_MACHINELOOPRANGES_H
18
19 #include "llvm/ADT/IntervalMap.h"
20 #include "llvm/CodeGen/SlotIndexes.h"
21
22 namespace llvm {
23
24 class MachineLoop;
25 class MachineLoopInfo;
26 class raw_ostream;
27
28 /// MachineLoopRange - Range information for a single loop.
29 class MachineLoopRange {
30 friend class MachineLoopRanges;
31
32 public:
33 typedef IntervalMap Map;
34 typedef Map::Allocator Allocator;
35
36 private:
37 /// The mapped loop.
38 const MachineLoop *const Loop;
39
40 /// Map intervals to a bit mask.
41 /// Bit 0 = inside loop block.
42 Map Intervals;
43
44 /// Loop area as measured by SlotIndex::distance.
45 unsigned Area;
46
47 /// Create a MachineLoopRange, only accessible to MachineLoopRanges.
48 MachineLoopRange(const MachineLoop*, Allocator&, SlotIndexes&);
49
50 public:
51 /// getLoop - Return the mapped machine loop.
52 const MachineLoop *getLoop() const { return Loop; }
53
54 /// overlaps - Return true if this loop overlaps the given range of machine
55 /// inteructions.
56 bool overlaps(SlotIndex Start, SlotIndex Stop);
57
58 /// getNumber - Return the loop number. This is the same as the number of the
59 /// header block.
60 unsigned getNumber() const;
61
62 /// getArea - Return the loop area. This number is approximately proportional
63 /// to the number of instructions in the loop.
64 unsigned getArea() const { return Area; }
65
66 /// getMap - Allow public read-only access for IntervalMapOverlaps.
67 const Map &getMap() { return Intervals; }
68
69 /// print - Print loop ranges on OS.
70 void print(raw_ostream&) const;
71
72 /// byNumber - Comparator for array_pod_sort that sorts a list of
73 /// MachineLoopRange pointers by number.
74 static int byNumber(const void*, const void*);
75
76 /// byAreaDesc - Comparator for array_pod_sort that sorts a list of
77 /// MachineLoopRange pointers by descending area, then by number.
78 static int byAreaDesc(const void*, const void*);
79 };
80
81 raw_ostream &operator<<(raw_ostream&, const MachineLoopRange&);
82
83 /// MachineLoopRanges - Analysis pass that provides on-demand per-loop range
84 /// information.
85 class MachineLoopRanges : public MachineFunctionPass {
86 typedef DenseMap CacheMap;
87 typedef MachineLoopRange::Allocator MapAllocator;
88
89 MapAllocator Allocator;
90 SlotIndexes *Indexes;
91 CacheMap Cache;
92
93 public:
94 static char ID; // Pass identification, replacement for typeid
95
96 MachineLoopRanges() : MachineFunctionPass(ID), Indexes(0) {}
97 ~MachineLoopRanges() { releaseMemory(); }
98
99 /// getLoopRange - Return the range of loop.
100 MachineLoopRange *getLoopRange(const MachineLoop *Loop);
101
102 private:
103 virtual bool runOnMachineFunction(MachineFunction&);
104 virtual void releaseMemory();
105 virtual void getAnalysisUsage(AnalysisUsage&) const;
106 };
107
108
109 } // end namespace llvm
110
111 #endif // LLVM_CODEGEN_MACHINELOOPRANGES_H
287287 /// MachineLoopInfo - This pass is a loop analysis pass.
288288 extern char &MachineLoopInfoID;
289289
290 /// MachineLoopRanges - This pass is an on-demand loop coverage analysis.
291 extern char &MachineLoopRangesID;
292
293290 /// MachineDominators - This pass is a machine dominators analysis pass.
294291 extern char &MachineDominatorsID;
295292
171171 void initializeMachinePostDominatorTreePass(PassRegistry&);
172172 void initializeMachineLICMPass(PassRegistry&);
173173 void initializeMachineLoopInfoPass(PassRegistry&);
174 void initializeMachineLoopRangesPass(PassRegistry&);
175174 void initializeMachineModuleInfoPass(PassRegistry&);
176175 void initializeMachineSchedulerPass(PassRegistry&);
177176 void initializeMachineSinkingPass(PassRegistry&);
5353 MachineInstrBundle.cpp
5454 MachineLICM.cpp
5555 MachineLoopInfo.cpp
56 MachineLoopRanges.cpp
5756 MachineModuleInfo.cpp
5857 MachineModuleInfoImpls.cpp
5958 MachinePassRegistry.cpp
1515 #define DEBUG_TYPE "regalloc"
1616 #include "LiveIntervalUnion.h"
1717 #include "llvm/ADT/SparseBitVector.h"
18 #include "llvm/CodeGen/MachineLoopRanges.h"
1918 #include "llvm/Support/Debug.h"
2019 #include "llvm/Support/raw_ostream.h"
2120 #include "llvm/Target/TargetRegisterInfo.h"
181180 return InterferingVRegs.size();
182181 }
183182
184 bool LiveIntervalUnion::Query::checkLoopInterference(MachineLoopRange *Loop) {
185 // VirtReg is likely live throughout the loop, so start by checking LIU-Loop
186 // overlaps.
187 IntervalMapOverlaps
188 Overlaps(LiveUnion->getMap(), Loop->getMap());
189 if (!Overlaps.valid())
190 return false;
191
192 // The loop is overlapping an LIU assignment. Check VirtReg as well.
193 LiveInterval::iterator VRI = VirtReg->find(Overlaps.start());
194
195 for (;;) {
196 if (VRI == VirtReg->end())
197 return false;
198 if (VRI->start < Overlaps.stop())
199 return true;
200
201 Overlaps.advanceTo(VRI->start);
202 if (!Overlaps.valid())
203 return false;
204 if (Overlaps.start() < VRI->end)
205 return true;
206
207 VRI = VirtReg->advanceTo(VRI, Overlaps.start());
208 }
209 }
210
211183 void LiveIntervalUnion::Array::init(LiveIntervalUnion::Allocator &Alloc,
212184 unsigned NSize) {
213185 // Reuse existing allocation.
172172 return InterferingVRegs;
173173 }
174174
175 /// checkLoopInterference - Return true if there is interference overlapping
176 /// Loop.
177 bool checkLoopInterference(MachineLoopRange*);
178
179175 private:
180176 Query(const Query&) LLVM_DELETED_FUNCTION;
181177 void operator=(const Query&) LLVM_DELETED_FUNCTION;
None //===- MachineLoopRanges.cpp - Ranges of machine loops --------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the implementation of the MachineLoopRanges analysis.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/CodeGen/MachineLoopRanges.h"
14 #include "llvm/CodeGen/MachineLoopInfo.h"
15 #include "llvm/CodeGen/Passes.h"
16
17 using namespace llvm;
18
19 char MachineLoopRanges::ID = 0;
20 INITIALIZE_PASS_BEGIN(MachineLoopRanges, "machine-loop-ranges",
21 "Machine Loop Ranges", true, true)
22 INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
23 INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
24 INITIALIZE_PASS_END(MachineLoopRanges, "machine-loop-ranges",
25 "Machine Loop Ranges", true, true)
26
27 char &llvm::MachineLoopRangesID = MachineLoopRanges::ID;
28
29 void MachineLoopRanges::getAnalysisUsage(AnalysisUsage &AU) const {
30 AU.setPreservesAll();
31 AU.addRequiredTransitive();
32 AU.addRequiredTransitive();
33 MachineFunctionPass::getAnalysisUsage(AU);
34 }
35
36 /// runOnMachineFunction - Don't do much, loop ranges are computed on demand.
37 bool MachineLoopRanges::runOnMachineFunction(MachineFunction &) {
38 releaseMemory();
39 Indexes = &getAnalysis();
40 return false;
41 }
42
43 void MachineLoopRanges::releaseMemory() {
44 DeleteContainerSeconds(Cache);
45 Cache.clear();
46 }
47
48 MachineLoopRange *MachineLoopRanges::getLoopRange(const MachineLoop *Loop) {
49 MachineLoopRange *&Range = Cache[Loop];
50 if (!Range)
51 Range = new MachineLoopRange(Loop, Allocator, *Indexes);
52 return Range;
53 }
54
55 /// Create a MachineLoopRange, only accessible to MachineLoopRanges.
56 MachineLoopRange::MachineLoopRange(const MachineLoop *loop,
57 MachineLoopRange::Allocator &alloc,
58 SlotIndexes &Indexes)
59 : Loop(loop), Intervals(alloc), Area(0) {
60 // Compute loop coverage.
61 for (MachineLoop::block_iterator I = Loop->block_begin(),
62 E = Loop->block_end(); I != E; ++I) {
63 const std::pair &Range = Indexes.getMBBRange(*I);
64 Intervals.insert(Range.first, Range.second, 1u);
65 Area += Range.first.distance(Range.second);
66 }
67 }
68
69 /// overlaps - Return true if this loop overlaps the given range of machine
70 /// instructions.
71 bool MachineLoopRange::overlaps(SlotIndex Start, SlotIndex Stop) {
72 Map::const_iterator I = Intervals.find(Start);
73 return I.valid() && Stop > I.start();
74 }
75
76 unsigned MachineLoopRange::getNumber() const {
77 return Loop->getHeader()->getNumber();
78 }
79
80 /// byNumber - Comparator for array_pod_sort that sorts a list of
81 /// MachineLoopRange pointers by number.
82 int MachineLoopRange::byNumber(const void *pa, const void *pb) {
83 const MachineLoopRange *a = *static_cast(pa);
84 const MachineLoopRange *b = *static_cast(pb);
85 unsigned na = a->getNumber();
86 unsigned nb = b->getNumber();
87 if (na < nb)
88 return -1;
89 if (na > nb)
90 return 1;
91 return 0;
92 }
93
94 /// byAreaDesc - Comparator for array_pod_sort that sorts a list of
95 /// MachineLoopRange pointers by:
96 /// 1. Descending area.
97 /// 2. Ascending number.
98 int MachineLoopRange::byAreaDesc(const void *pa, const void *pb) {
99 const MachineLoopRange *a = *static_cast(pa);
100 const MachineLoopRange *b = *static_cast(pb);
101 if (a->getArea() != b->getArea())
102 return a->getArea() > b->getArea() ? -1 : 1;
103 return byNumber(pa, pb);
104 }
105
106 void MachineLoopRange::print(raw_ostream &OS) const {
107 OS << "Loop#" << getNumber() << " =";
108 for (Map::const_iterator I = Intervals.begin(); I.valid(); ++I)
109 OS << " [" << I.start() << ';' << I.stop() << ')';
110 }
111
112 raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineLoopRange &MLR) {
113 MLR.print(OS);
114 return OS;
115 }