Chromium Code Reviews| 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 /// \file | 10 /// \file |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #pragma clang diagnostic pop | 37 #pragma clang diagnostic pop |
| 38 #endif // __clang__ | 38 #endif // __clang__ |
| 39 | 39 |
| 40 #include <algorithm> // max() | 40 #include <algorithm> // max() |
| 41 #include <cctype> // isdigit(), isupper() | 41 #include <cctype> // isdigit(), isupper() |
| 42 #include <locale> // locale | 42 #include <locale> // locale |
| 43 | 43 |
| 44 namespace std { | 44 namespace std { |
| 45 template <> struct hash<Ice::RelocatableTuple> { | 45 template <> struct hash<Ice::RelocatableTuple> { |
| 46 size_t operator()(const Ice::RelocatableTuple &Key) const { | 46 size_t operator()(const Ice::RelocatableTuple &Key) const { |
| 47 return hash<Ice::IceString>()(Key.Name) + | 47 return hash<Ice::IceString>()(Key.Name); |
|
Jim Stichnoth
2016/02/02 17:13:44
Any reason not to add some aspect of OffsetExpr in
John
2016/02/02 19:36:39
Done.
| |
| 48 hash<Ice::RelocOffsetT>()(Key.Offset); | |
| 49 } | 48 } |
| 50 }; | 49 }; |
| 51 } // end of namespace std | 50 } // end of namespace std |
| 52 | 51 |
| 53 namespace Ice { | 52 namespace Ice { |
| 54 | 53 |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 // Define the key comparison function for the constant pool's unordered_map, | 56 // Define the key comparison function for the constant pool's unordered_map, |
| 58 // but only for key types of interest: integer types, floating point types, and | 57 // but only for key types of interest: integer types, floating point types, and |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 } | 777 } |
| 779 | 778 |
| 780 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { | 779 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { |
| 781 return getConstPool()->Floats.getOrAdd(this, ConstantFloat); | 780 return getConstPool()->Floats.getOrAdd(this, ConstantFloat); |
| 782 } | 781 } |
| 783 | 782 |
| 784 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { | 783 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { |
| 785 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); | 784 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); |
| 786 } | 785 } |
| 787 | 786 |
| 787 Constant *GlobalContext::getConstantSym(std::vector<RelocOffset *> Offset, | |
| 788 const IceString &Name, | |
| 789 bool SuppressMangling) { | |
| 790 return getConstPool()->Relocatables.getOrAdd( | |
| 791 this, RelocatableTuple(std::move(Offset), Name, SuppressMangling)); | |
| 792 } | |
| 793 | |
| 788 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, | 794 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, |
| 789 const IceString &Name, | 795 const IceString &Name, |
| 790 bool SuppressMangling) { | 796 bool SuppressMangling) { |
| 791 return getConstPool()->Relocatables.getOrAdd( | 797 return getConstantSym({RelocOffset::create(this, Offset)}, Name, |
| 792 this, RelocatableTuple(Offset, Name, SuppressMangling)); | 798 SuppressMangling); |
| 793 } | 799 } |
| 794 | 800 |
| 795 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { | 801 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { |
| 796 constexpr RelocOffsetT Offset = 0; | 802 constexpr RelocOffsetT Offset = 0; |
| 797 constexpr bool SuppressMangling = true; | 803 constexpr bool SuppressMangling = true; |
| 798 return getConstPool()->ExternRelocatables.getOrAdd( | 804 return getConstPool()->ExternRelocatables.getOrAdd( |
| 799 this, RelocatableTuple(Offset, Name, SuppressMangling)); | 805 this, RelocatableTuple({RelocOffset::create(this, Offset)}, Name, |
| 806 SuppressMangling)); | |
| 800 } | 807 } |
| 801 | 808 |
| 802 Constant *GlobalContext::getConstantUndef(Type Ty) { | 809 Constant *GlobalContext::getConstantUndef(Type Ty) { |
| 803 return getConstPool()->Undefs.getOrAdd(this, Ty); | 810 return getConstPool()->Undefs.getOrAdd(this, Ty); |
| 804 } | 811 } |
| 805 | 812 |
| 806 // All locking is done by the getConstant*() target function. | 813 // All locking is done by the getConstant*() target function. |
| 807 Constant *GlobalContext::getConstantZero(Type Ty) { | 814 Constant *GlobalContext::getConstantZero(Type Ty) { |
| 808 switch (Ty) { | 815 switch (Ty) { |
| 809 case IceType_i1: | 816 case IceType_i1: |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 Ctx = Func->getContext(); | 1023 Ctx = Func->getContext(); |
| 1017 Active = | 1024 Active = |
| 1018 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 1025 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
| 1019 if (Active) | 1026 if (Active) |
| 1020 Ctx->pushTimer(ID, StackID); | 1027 Ctx->pushTimer(ID, StackID); |
| 1021 } | 1028 } |
| 1022 | 1029 |
| 1023 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 1030 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 1024 | 1031 |
| 1025 } // end of namespace Ice | 1032 } // end of namespace Ice |
| OLD | NEW |