Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: src/IceGlobalContext.cpp

Issue 1651163002: Subzero. Enables moar complex relocation offsets. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (!Key.EmitString.empty()) {
48 hash<Ice::RelocOffsetT>()(Key.Offset); 48 return hash<Ice::IceString>()(Key.EmitString);
49 }
50 if (Key.OffsetExpr[0]->hasOffset()) {
Jim Stichnoth 2016/02/02 20:57:49 Please assert(!Key.OffsetExpr.empty()) otherwise i
John 2016/02/03 15:50:41 Done.
51 return hash<Ice::IceString>()(Key.Name) +
52 hash<Ice::RelocOffsetT>()(Key.OffsetExpr[0]->getOffset());
53 }
54 return hash<Ice::IceString>()(Key.Name);
55 hash<std::size_t>()(Key.OffsetExpr.size());
Jim Stichnoth 2016/02/02 20:57:49 remove this
John 2016/02/03 15:50:41 I meant to add it to the return value.
49 } 56 }
50 }; 57 };
51 } // end of namespace std 58 } // end of namespace std
52 59
53 namespace Ice { 60 namespace Ice {
54 61
55 namespace { 62 namespace {
56 63
57 // Define the key comparison function for the constant pool's unordered_map, 64 // 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 65 // 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
778 } 785 }
779 786
780 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { 787 Constant *GlobalContext::getConstantFloat(float ConstantFloat) {
781 return getConstPool()->Floats.getOrAdd(this, ConstantFloat); 788 return getConstPool()->Floats.getOrAdd(this, ConstantFloat);
782 } 789 }
783 790
784 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { 791 Constant *GlobalContext::getConstantDouble(double ConstantDouble) {
785 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); 792 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble);
786 } 793 }
787 794
795 Constant *GlobalContext::getConstantSym(const RelocOffsetArray &Offset,
796 const IceString &Name,
797 const IceString &EmitString,
798 bool SuppressMangling) {
799 return getConstPool()->Relocatables.getOrAdd(
800 this, RelocatableTuple(Offset, Name, EmitString, SuppressMangling));
801 }
802
788 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, 803 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset,
789 const IceString &Name, 804 const IceString &Name,
790 bool SuppressMangling) { 805 bool SuppressMangling) {
791 return getConstPool()->Relocatables.getOrAdd( 806 constexpr char EmptyEmitString[] = "";
792 this, RelocatableTuple(Offset, Name, SuppressMangling)); 807 return getConstantSym({RelocOffset::create(this, Offset)}, Name,
808 EmptyEmitString, SuppressMangling);
793 } 809 }
794 810
795 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { 811 Constant *GlobalContext::getConstantExternSym(const IceString &Name) {
796 constexpr RelocOffsetT Offset = 0; 812 constexpr RelocOffsetT Offset = 0;
797 constexpr bool SuppressMangling = true; 813 constexpr bool SuppressMangling = true;
798 return getConstPool()->ExternRelocatables.getOrAdd( 814 return getConstPool()->ExternRelocatables.getOrAdd(
799 this, RelocatableTuple(Offset, Name, SuppressMangling)); 815 this, RelocatableTuple({RelocOffset::create(this, Offset)}, Name,
816 SuppressMangling));
800 } 817 }
801 818
802 Constant *GlobalContext::getConstantUndef(Type Ty) { 819 Constant *GlobalContext::getConstantUndef(Type Ty) {
803 return getConstPool()->Undefs.getOrAdd(this, Ty); 820 return getConstPool()->Undefs.getOrAdd(this, Ty);
804 } 821 }
805 822
806 // All locking is done by the getConstant*() target function. 823 // All locking is done by the getConstant*() target function.
807 Constant *GlobalContext::getConstantZero(Type Ty) { 824 Constant *GlobalContext::getConstantZero(Type Ty) {
808 switch (Ty) { 825 switch (Ty) {
809 case IceType_i1: 826 case IceType_i1:
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 Ctx = Func->getContext(); 1033 Ctx = Func->getContext();
1017 Active = 1034 Active =
1018 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); 1035 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled();
1019 if (Active) 1036 if (Active)
1020 Ctx->pushTimer(ID, StackID); 1037 Ctx->pushTimer(ID, StackID);
1021 } 1038 }
1022 1039
1023 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); 1040 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
1024 1041
1025 } // end of namespace Ice 1042 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698