| 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 if (!Key.EmitString.empty()) { |
| 48 return hash<Ice::IceString>()(Key.EmitString); |
| 49 } |
| 50 |
| 51 assert(!Key.OffsetExpr.empty()); |
| 52 if (Key.OffsetExpr[0]->hasOffset()) { |
| 53 return hash<Ice::IceString>()(Key.Name) + |
| 54 hash<Ice::RelocOffsetT>()(Key.OffsetExpr[0]->getOffset()); |
| 55 } |
| 56 |
| 47 return hash<Ice::IceString>()(Key.Name) + | 57 return hash<Ice::IceString>()(Key.Name) + |
| 48 hash<Ice::RelocOffsetT>()(Key.Offset); | 58 hash<std::size_t>()(Key.OffsetExpr.size()); |
| 49 } | 59 } |
| 50 }; | 60 }; |
| 51 } // end of namespace std | 61 } // end of namespace std |
| 52 | 62 |
| 53 namespace Ice { | 63 namespace Ice { |
| 54 | 64 |
| 55 namespace { | 65 namespace { |
| 56 | 66 |
| 57 // Define the key comparison function for the constant pool's unordered_map, | 67 // 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 | 68 // 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 } | 788 } |
| 779 | 789 |
| 780 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { | 790 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { |
| 781 return getConstPool()->Floats.getOrAdd(this, ConstantFloat); | 791 return getConstPool()->Floats.getOrAdd(this, ConstantFloat); |
| 782 } | 792 } |
| 783 | 793 |
| 784 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { | 794 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { |
| 785 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); | 795 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); |
| 786 } | 796 } |
| 787 | 797 |
| 798 Constant *GlobalContext::getConstantSym(const RelocOffsetArray &Offset, |
| 799 const IceString &Name, |
| 800 const IceString &EmitString, |
| 801 bool SuppressMangling) { |
| 802 return getConstPool()->Relocatables.getOrAdd( |
| 803 this, RelocatableTuple(Offset, Name, EmitString, SuppressMangling)); |
| 804 } |
| 805 |
| 788 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, | 806 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, |
| 789 const IceString &Name, | 807 const IceString &Name, |
| 790 bool SuppressMangling) { | 808 bool SuppressMangling) { |
| 791 return getConstPool()->Relocatables.getOrAdd( | 809 constexpr char EmptyEmitString[] = ""; |
| 792 this, RelocatableTuple(Offset, Name, SuppressMangling)); | 810 return getConstantSym({RelocOffset::create(this, Offset)}, Name, |
| 811 EmptyEmitString, SuppressMangling); |
| 793 } | 812 } |
| 794 | 813 |
| 795 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { | 814 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { |
| 796 constexpr RelocOffsetT Offset = 0; | 815 constexpr RelocOffsetT Offset = 0; |
| 797 constexpr bool SuppressMangling = true; | 816 constexpr bool SuppressMangling = true; |
| 798 return getConstPool()->ExternRelocatables.getOrAdd( | 817 return getConstPool()->ExternRelocatables.getOrAdd( |
| 799 this, RelocatableTuple(Offset, Name, SuppressMangling)); | 818 this, RelocatableTuple({RelocOffset::create(this, Offset)}, Name, |
| 819 SuppressMangling)); |
| 800 } | 820 } |
| 801 | 821 |
| 802 Constant *GlobalContext::getConstantUndef(Type Ty) { | 822 Constant *GlobalContext::getConstantUndef(Type Ty) { |
| 803 return getConstPool()->Undefs.getOrAdd(this, Ty); | 823 return getConstPool()->Undefs.getOrAdd(this, Ty); |
| 804 } | 824 } |
| 805 | 825 |
| 806 // All locking is done by the getConstant*() target function. | 826 // All locking is done by the getConstant*() target function. |
| 807 Constant *GlobalContext::getConstantZero(Type Ty) { | 827 Constant *GlobalContext::getConstantZero(Type Ty) { |
| 808 switch (Ty) { | 828 switch (Ty) { |
| 809 case IceType_i1: | 829 case IceType_i1: |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 Ctx = Func->getContext(); | 1036 Ctx = Func->getContext(); |
| 1017 Active = | 1037 Active = |
| 1018 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 1038 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
| 1019 if (Active) | 1039 if (Active) |
| 1020 Ctx->pushTimer(ID, StackID); | 1040 Ctx->pushTimer(ID, StackID); |
| 1021 } | 1041 } |
| 1022 | 1042 |
| 1023 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 1043 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
| 1024 | 1044 |
| 1025 } // end of namespace Ice | 1045 } // end of namespace Ice |
| OLD | NEW |