LLVM  4.0.0
LiveStackAnalysis.h
Go to the documentation of this file.
1 //===-- LiveStackAnalysis.h - Live Stack Slot Analysis ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the live stack slot analysis pass. It is analogous to
11 // live interval analysis except it's analyzing liveness of stack slots rather
12 // than registers.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CODEGEN_LIVESTACKANALYSIS_H
17 #define LLVM_CODEGEN_LIVESTACKANALYSIS_H
18 
21 #include "llvm/Support/Allocator.h"
23 #include <map>
24 #include <unordered_map>
25 
26 namespace llvm {
27 
29  const TargetRegisterInfo *TRI;
30 
31  /// Special pool allocator for VNInfo's (LiveInterval val#).
32  ///
33  VNInfo::Allocator VNInfoAllocator;
34 
35  /// S2IMap - Stack slot indices to live interval mapping.
36  ///
37  typedef std::unordered_map<int, LiveInterval> SS2IntervalMap;
38  SS2IntervalMap S2IMap;
39 
40  /// S2RCMap - Stack slot indices to register class mapping.
41  std::map<int, const TargetRegisterClass *> S2RCMap;
42 
43 public:
44  static char ID; // Pass identification, replacement for typeid
47  }
48 
49  typedef SS2IntervalMap::iterator iterator;
50  typedef SS2IntervalMap::const_iterator const_iterator;
51  const_iterator begin() const { return S2IMap.begin(); }
52  const_iterator end() const { return S2IMap.end(); }
53  iterator begin() { return S2IMap.begin(); }
54  iterator end() { return S2IMap.end(); }
55 
56  unsigned getNumIntervals() const { return (unsigned)S2IMap.size(); }
57 
59 
61  assert(Slot >= 0 && "Spill slot indice must be >= 0");
62  SS2IntervalMap::iterator I = S2IMap.find(Slot);
63  assert(I != S2IMap.end() && "Interval does not exist for stack slot");
64  return I->second;
65  }
66 
67  const LiveInterval &getInterval(int Slot) const {
68  assert(Slot >= 0 && "Spill slot indice must be >= 0");
69  SS2IntervalMap::const_iterator I = S2IMap.find(Slot);
70  assert(I != S2IMap.end() && "Interval does not exist for stack slot");
71  return I->second;
72  }
73 
74  bool hasInterval(int Slot) const { return S2IMap.count(Slot); }
75 
76  const TargetRegisterClass *getIntervalRegClass(int Slot) const {
77  assert(Slot >= 0 && "Spill slot indice must be >= 0");
78  std::map<int, const TargetRegisterClass *>::const_iterator I =
79  S2RCMap.find(Slot);
80  assert(I != S2RCMap.end() &&
81  "Register class info does not exist for stack slot");
82  return I->second;
83  }
84 
85  VNInfo::Allocator &getVNInfoAllocator() { return VNInfoAllocator; }
86 
87  void getAnalysisUsage(AnalysisUsage &AU) const override;
88  void releaseMemory() override;
89 
90  /// runOnMachineFunction - pass entry point
91  bool runOnMachineFunction(MachineFunction &) override;
92 
93  /// print - Implement the dump method.
94  void print(raw_ostream &O, const Module * = nullptr) const override;
95 };
96 }
97 
98 #endif /* LLVM_CODEGEN_LIVESTACK_ANALYSIS_H */
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const LiveInterval & getInterval(int Slot) const
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
LiveInterval - This class represents the liveness of a register, or stack slot.
Definition: LiveInterval.h:625
LiveInterval & getInterval(int Slot)
VNInfo::Allocator & getVNInfoAllocator()
const_iterator end() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetRegisterClass * getIntervalRegClass(int Slot) const
LiveInterval & getOrCreateInterval(int Slot, const TargetRegisterClass *RC)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
SS2IntervalMap::const_iterator const_iterator
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
void initializeLiveStacksPass(PassRegistry &)
Represent the analysis usage information of a pass.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool hasInterval(int Slot) const
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - pass entry point
unsigned getNumIntervals() const
#define I(x, y, z)
Definition: MD5.cpp:54
const_iterator begin() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
SS2IntervalMap::iterator iterator
void print(raw_ostream &O, const Module *=nullptr) const override
print - Implement the dump method.