| OLD | NEW |
| 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// |
| 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 defines aspects of the compilation that persist across | 10 // This file defines aspects of the compilation that persist across |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // TypePool maps constants of type KeyType (e.g. float) to pointers to | 29 // TypePool maps constants of type KeyType (e.g. float) to pointers to |
| 30 // type ValueType (e.g. ConstantFloat). KeyType values are compared | 30 // type ValueType (e.g. ConstantFloat). KeyType values are compared |
| 31 // using memcmp() because of potential NaN values in KeyType values. | 31 // using memcmp() because of potential NaN values in KeyType values. |
| 32 // KeyTypeHasFP indicates whether KeyType is a floating-point type | 32 // KeyTypeHasFP indicates whether KeyType is a floating-point type |
| 33 // whose values need to be compared using memcmp() for NaN | 33 // whose values need to be compared using memcmp() for NaN |
| 34 // correctness. TODO: use std::is_floating_point<KeyType> instead of | 34 // correctness. TODO: use std::is_floating_point<KeyType> instead of |
| 35 // KeyTypeHasFP with C++11. | 35 // KeyTypeHasFP with C++11. |
| 36 template <typename KeyType, typename ValueType, bool KeyTypeHasFP = false> | 36 template <typename KeyType, typename ValueType, bool KeyTypeHasFP = false> |
| 37 class TypePool { | 37 class TypePool { |
| 38 TypePool(const TypePool &) LLVM_DELETED_FUNCTION; | 38 TypePool(const TypePool &) = delete; |
| 39 TypePool &operator=(const TypePool &) LLVM_DELETED_FUNCTION; | 39 TypePool &operator=(const TypePool &) = delete; |
| 40 | 40 |
| 41 public: | 41 public: |
| 42 TypePool() : NextPoolID(0) {} | 42 TypePool() : NextPoolID(0) {} |
| 43 ValueType *getOrAdd(GlobalContext *Ctx, Type Ty, KeyType Key) { | 43 ValueType *getOrAdd(GlobalContext *Ctx, Type Ty, KeyType Key) { |
| 44 TupleType TupleKey = std::make_pair(Ty, Key); | 44 TupleType TupleKey = std::make_pair(Ty, Key); |
| 45 typename ContainerType::const_iterator Iter = Pool.find(TupleKey); | 45 typename ContainerType::const_iterator Iter = Pool.find(TupleKey); |
| 46 if (Iter != Pool.end()) | 46 if (Iter != Pool.end()) |
| 47 return Iter->second; | 47 return Iter->second; |
| 48 ValueType *Result = ValueType::create(Ctx, Ty, Key, NextPoolID++); | 48 ValueType *Result = ValueType::create(Ctx, Ty, Key, NextPoolID++); |
| 49 Pool[TupleKey] = Result; | 49 Pool[TupleKey] = Result; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 72 return A.second < B.second; | 72 return A.second < B.second; |
| 73 } | 73 } |
| 74 }; | 74 }; |
| 75 typedef std::map<const TupleType, ValueType *, TupleCompare> ContainerType; | 75 typedef std::map<const TupleType, ValueType *, TupleCompare> ContainerType; |
| 76 ContainerType Pool; | 76 ContainerType Pool; |
| 77 uint32_t NextPoolID; | 77 uint32_t NextPoolID; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // UndefPool maps ICE types to the corresponding ConstantUndef values. | 80 // UndefPool maps ICE types to the corresponding ConstantUndef values. |
| 81 class UndefPool { | 81 class UndefPool { |
| 82 UndefPool(const UndefPool &) LLVM_DELETED_FUNCTION; | 82 UndefPool(const UndefPool &) = delete; |
| 83 UndefPool &operator=(const UndefPool &) LLVM_DELETED_FUNCTION; | 83 UndefPool &operator=(const UndefPool &) = delete; |
| 84 | 84 |
| 85 public: | 85 public: |
| 86 UndefPool() : NextPoolID(0) {} | 86 UndefPool() : NextPoolID(0) {} |
| 87 | 87 |
| 88 ConstantUndef *getOrAdd(GlobalContext *Ctx, Type Ty) { | 88 ConstantUndef *getOrAdd(GlobalContext *Ctx, Type Ty) { |
| 89 ContainerType::iterator I = Pool.find(Ty); | 89 ContainerType::iterator I = Pool.find(Ty); |
| 90 if (I != Pool.end()) | 90 if (I != Pool.end()) |
| 91 return I->second; | 91 return I->second; |
| 92 ConstantUndef *Undef = ConstantUndef::create(Ctx, Ty, NextPoolID++); | 92 ConstantUndef *Undef = ConstantUndef::create(Ctx, Ty, NextPoolID++); |
| 93 Pool[Ty] = Undef; | 93 Pool[Ty] = Undef; |
| 94 return Undef; | 94 return Undef; |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 uint32_t NextPoolID; | 98 uint32_t NextPoolID; |
| 99 typedef std::map<Type, ConstantUndef *> ContainerType; | 99 typedef std::map<Type, ConstantUndef *> ContainerType; |
| 100 ContainerType Pool; | 100 ContainerType Pool; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // The global constant pool bundles individual pools of each type of | 103 // The global constant pool bundles individual pools of each type of |
| 104 // interest. | 104 // interest. |
| 105 class ConstantPool { | 105 class ConstantPool { |
| 106 ConstantPool(const ConstantPool &) LLVM_DELETED_FUNCTION; | 106 ConstantPool(const ConstantPool &) = delete; |
| 107 ConstantPool &operator=(const ConstantPool &) LLVM_DELETED_FUNCTION; | 107 ConstantPool &operator=(const ConstantPool &) = delete; |
| 108 | 108 |
| 109 public: | 109 public: |
| 110 ConstantPool() {} | 110 ConstantPool() {} |
| 111 TypePool<float, ConstantFloat, true> Floats; | 111 TypePool<float, ConstantFloat, true> Floats; |
| 112 TypePool<double, ConstantDouble, true> Doubles; | 112 TypePool<double, ConstantDouble, true> Doubles; |
| 113 TypePool<uint32_t, ConstantInteger32> Integers32; | 113 TypePool<uint32_t, ConstantInteger32> Integers32; |
| 114 TypePool<uint64_t, ConstantInteger64> Integers64; | 114 TypePool<uint64_t, ConstantInteger64> Integers64; |
| 115 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables; | 115 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables; |
| 116 UndefPool Undefs; | 116 UndefPool Undefs; |
| 117 }; | 117 }; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } else { | 400 } else { |
| 401 StatsFunction.dump(Name, getStrDump()); | 401 StatsFunction.dump(Name, getStrDump()); |
| 402 StatsCumulative.dump("_TOTAL_", getStrDump()); | 402 StatsCumulative.dump("_TOTAL_", getStrDump()); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 | 406 |
| 407 void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } | 407 void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } |
| 408 | 408 |
| 409 } // end of namespace Ice | 409 } // end of namespace Ice |
| OLD | NEW |