OLD | NEW |
1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- C++ -*-===// | 1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares various useful types and classes that have | 10 // This file declares various useful types and classes that have |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include <map> | 25 #include <map> |
26 #include <string> | 26 #include <string> |
27 #include <vector> | 27 #include <vector> |
28 #include "llvm/ADT/ArrayRef.h" | 28 #include "llvm/ADT/ArrayRef.h" |
29 #include "llvm/ADT/BitVector.h" | 29 #include "llvm/ADT/BitVector.h" |
30 #include "llvm/ADT/ilist.h" | 30 #include "llvm/ADT/ilist.h" |
31 #include "llvm/ADT/ilist_node.h" | 31 #include "llvm/ADT/ilist_node.h" |
32 #include "llvm/ADT/SmallBitVector.h" | 32 #include "llvm/ADT/SmallBitVector.h" |
33 #include "llvm/ADT/SmallVector.h" | 33 #include "llvm/ADT/SmallVector.h" |
34 #include "llvm/ADT/STLExtras.h" | 34 #include "llvm/ADT/STLExtras.h" |
| 35 #include "llvm/Support/Allocator.h" |
35 #include "llvm/Support/Casting.h" | 36 #include "llvm/Support/Casting.h" |
36 #include "llvm/Support/ELF.h" | 37 #include "llvm/Support/ELF.h" |
37 #include "llvm/Support/raw_ostream.h" | 38 #include "llvm/Support/raw_ostream.h" |
38 | 39 |
39 namespace Ice { | 40 namespace Ice { |
40 | 41 |
41 class Cfg; | 42 class Cfg; |
42 class CfgNode; | 43 class CfgNode; |
43 class Constant; | 44 class Constant; |
44 class FunctionDeclaration; | 45 class FunctionDeclaration; |
45 class GlobalContext; | 46 class GlobalContext; |
46 class GlobalDeclaration; | 47 class GlobalDeclaration; |
47 class Inst; | 48 class Inst; |
48 class InstAssign; | 49 class InstAssign; |
49 class InstPhi; | 50 class InstPhi; |
50 class InstTarget; | 51 class InstTarget; |
51 class LiveRange; | 52 class LiveRange; |
52 class Liveness; | 53 class Liveness; |
53 class Operand; | 54 class Operand; |
54 class TargetLowering; | 55 class TargetLowering; |
55 class Variable; | 56 class Variable; |
56 class VariableDeclaration; | 57 class VariableDeclaration; |
57 class VariablesMetadata; | 58 class VariablesMetadata; |
58 | 59 |
59 // TODO: Switch over to LLVM's ADT container classes. | 60 typedef llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1024 * 1024> |
60 // http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-
for-a-task | 61 ArenaAllocator; |
| 62 |
| 63 ArenaAllocator *getCurrentCfgAllocator(); |
| 64 |
| 65 template <typename T> struct CfgLocalAllocator { |
| 66 using value_type = T; |
| 67 CfgLocalAllocator() = default; |
| 68 template <class U> CfgLocalAllocator(const CfgLocalAllocator<U> &) {} |
| 69 T *allocate(std::size_t Num) { |
| 70 return getCurrentCfgAllocator()->Allocate<T>(Num); |
| 71 } |
| 72 void deallocate(T *, std::size_t) {} |
| 73 }; |
| 74 template <typename T, typename U> |
| 75 inline bool operator==(const CfgLocalAllocator<T> &, |
| 76 const CfgLocalAllocator<U> &) { |
| 77 return true; |
| 78 } |
| 79 template <typename T, typename U> |
| 80 inline bool operator!=(const CfgLocalAllocator<T> &, |
| 81 const CfgLocalAllocator<U> &) { |
| 82 return false; |
| 83 } |
| 84 |
61 typedef std::string IceString; | 85 typedef std::string IceString; |
62 typedef llvm::ilist<Inst> InstList; | 86 typedef llvm::ilist<Inst> InstList; |
63 // Ideally PhiList would be llvm::ilist<InstPhi>, and similar for | 87 // Ideally PhiList would be llvm::ilist<InstPhi>, and similar for |
64 // AssignList, but this runs into issues with SFINAE. | 88 // AssignList, but this runs into issues with SFINAE. |
65 typedef InstList PhiList; | 89 typedef InstList PhiList; |
66 typedef InstList AssignList; | 90 typedef InstList AssignList; |
67 typedef std::vector<Variable *> VarList; | 91 // VarList and NodeList are arena-allocated from the Cfg's allocator. |
68 typedef std::vector<CfgNode *> NodeList; | 92 typedef std::vector<Variable *, CfgLocalAllocator<Variable *>> VarList; |
| 93 typedef std::vector<CfgNode *, CfgLocalAllocator<CfgNode *>> NodeList; |
69 typedef std::vector<Constant *> ConstantList; | 94 typedef std::vector<Constant *> ConstantList; |
70 | 95 |
71 // SizeT is for holding small-ish limits like number of source | 96 // SizeT is for holding small-ish limits like number of source |
72 // operands in an instruction. It is used instead of size_t (which | 97 // operands in an instruction. It is used instead of size_t (which |
73 // may be 64-bits wide) when we want to save space. | 98 // may be 64-bits wide) when we want to save space. |
74 typedef uint32_t SizeT; | 99 typedef uint32_t SizeT; |
75 | 100 |
76 // InstNumberT is for holding an instruction number. Instruction | 101 // InstNumberT is for holding an instruction number. Instruction |
77 // numbers are used for representing Variable live ranges. | 102 // numbers are used for representing Variable live ranges. |
78 typedef int32_t InstNumberT; | 103 typedef int32_t InstNumberT; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 IceV_Most = IceV_All & ~IceV_LinearScan | 151 IceV_Most = IceV_All & ~IceV_LinearScan |
127 }; | 152 }; |
128 typedef uint32_t VerboseMask; | 153 typedef uint32_t VerboseMask; |
129 | 154 |
130 typedef llvm::raw_ostream Ostream; | 155 typedef llvm::raw_ostream Ostream; |
131 typedef llvm::raw_fd_ostream Fdstream; | 156 typedef llvm::raw_fd_ostream Fdstream; |
132 | 157 |
133 } // end of namespace Ice | 158 } // end of namespace Ice |
134 | 159 |
135 #endif // SUBZERO_SRC_ICEDEFS_H | 160 #endif // SUBZERO_SRC_ICEDEFS_H |
OLD | NEW |