OLD | NEW |
1 //===- subzero/src/IceDefs.h - Common Subzero declarations ------*- C++ -*-===// | 1 //===- subzero/src/IceDefs.h - Common Subzero declarations ------*- 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 /// \file | 10 /// \file |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class VariablesMetadata; | 73 class VariablesMetadata; |
74 | 74 |
75 template <size_t SlabSize = 1024 * 1024> | 75 template <size_t SlabSize = 1024 * 1024> |
76 using ArenaAllocator = | 76 using ArenaAllocator = |
77 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, SlabSize>; | 77 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, SlabSize>; |
78 | 78 |
79 ArenaAllocator<> *getCurrentCfgAllocator(); | 79 ArenaAllocator<> *getCurrentCfgAllocator(); |
80 | 80 |
81 template <typename T> struct CfgLocalAllocator { | 81 template <typename T> struct CfgLocalAllocator { |
82 using value_type = T; | 82 using value_type = T; |
| 83 using pointer = T *; |
| 84 using const_pointer = const T *; |
| 85 using reference = T &; |
| 86 using const_reference = const T &; |
| 87 using size_type = std::size_t; |
83 CfgLocalAllocator() = default; | 88 CfgLocalAllocator() = default; |
84 template <class U> CfgLocalAllocator(const CfgLocalAllocator<U> &) {} | 89 template <class U> CfgLocalAllocator(const CfgLocalAllocator<U> &) {} |
85 T *allocate(std::size_t Num) { | 90 pointer allocate(size_type Num) { |
86 return getCurrentCfgAllocator()->Allocate<T>(Num); | 91 return getCurrentCfgAllocator()->Allocate<T>(Num); |
87 } | 92 } |
88 void deallocate(T *, std::size_t) {} | 93 void deallocate(pointer, size_type) {} |
| 94 template <class U> struct rebind { typedef CfgLocalAllocator<U> other; }; |
| 95 void construct(pointer P, const T &Val) { |
| 96 new (static_cast<void *>(P)) T(Val); |
| 97 } |
| 98 void destroy(pointer P) { P->~T(); } |
89 }; | 99 }; |
90 template <typename T, typename U> | 100 template <typename T, typename U> |
91 inline bool operator==(const CfgLocalAllocator<T> &, | 101 inline bool operator==(const CfgLocalAllocator<T> &, |
92 const CfgLocalAllocator<U> &) { | 102 const CfgLocalAllocator<U> &) { |
93 return true; | 103 return true; |
94 } | 104 } |
95 template <typename T, typename U> | 105 template <typename T, typename U> |
96 inline bool operator!=(const CfgLocalAllocator<T> &, | 106 inline bool operator!=(const CfgLocalAllocator<T> &, |
97 const CfgLocalAllocator<U> &) { | 107 const CfgLocalAllocator<U> &) { |
98 return false; | 108 return false; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 RPE_GlobalVariableReordering, | 300 RPE_GlobalVariableReordering, |
291 RPE_NopInsertion, | 301 RPE_NopInsertion, |
292 RPE_PooledConstantReordering, | 302 RPE_PooledConstantReordering, |
293 RPE_RegAllocRandomization, | 303 RPE_RegAllocRandomization, |
294 RPE_num | 304 RPE_num |
295 }; | 305 }; |
296 | 306 |
297 } // end of namespace Ice | 307 } // end of namespace Ice |
298 | 308 |
299 #endif // SUBZERO_SRC_ICEDEFS_H | 309 #endif // SUBZERO_SRC_ICEDEFS_H |
OLD | NEW |