Rename some GC classes so that their roll will hopefully be clearer.
[oota-llvm.git] / include / llvm / CodeGen / LiveStackAnalysis.h
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_LIVESTACK_ANALYSIS_H
17 #define LLVM_CODEGEN_LIVESTACK_ANALYSIS_H
18
19 #include "llvm/CodeGen/MachineFunctionPass.h"
20 #include "llvm/CodeGen/LiveInterval.h"
21 #include "llvm/Support/Allocator.h"
22 #include <map>
23
24 namespace llvm {
25
26   class LiveStacks : public MachineFunctionPass {
27     /// Special pool allocator for VNInfo's (LiveInterval val#).
28     ///
29     BumpPtrAllocator VNInfoAllocator;
30
31     /// s2iMap - Stack slot indices to live interval mapping.
32     ///
33     typedef std::map<int, LiveInterval> SS2IntervalMap;
34     SS2IntervalMap s2iMap;
35
36   public:
37     static char ID; // Pass identification, replacement for typeid
38     LiveStacks() : MachineFunctionPass((intptr_t)&ID) {}
39
40     typedef SS2IntervalMap::iterator iterator;
41     typedef SS2IntervalMap::const_iterator const_iterator;
42     const_iterator begin() const { return s2iMap.begin(); }
43     const_iterator end() const { return s2iMap.end(); }
44     iterator begin() { return s2iMap.begin(); }
45     iterator end() { return s2iMap.end(); }
46     unsigned getNumIntervals() const { return (unsigned)s2iMap.size(); }
47
48     LiveInterval &getOrCreateInterval(int Slot) {
49       SS2IntervalMap::iterator I = s2iMap.find(Slot);
50       if (I == s2iMap.end())
51         I = s2iMap.insert(I,std::make_pair(Slot,LiveInterval(Slot,0.0F,true)));
52       return I->second;
53     }
54
55     BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; }
56
57     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
58     virtual void releaseMemory();
59
60     /// runOnMachineFunction - pass entry point
61     virtual bool runOnMachineFunction(MachineFunction&);
62
63     /// print - Implement the dump method.
64     virtual void print(std::ostream &O, const Module* = 0) const;
65     void print(std::ostream *O, const Module* M = 0) const {
66       if (O) print(*O, M);
67     }
68   };
69 }
70
71 #endif /* LLVM_CODEGEN_LIVESTACK_ANALYSIS_H */