OLD | NEW |
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// | 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// |
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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 730 } |
731 } | 731 } |
732 | 732 |
733 void TargetLowering::sortVarsByAlignment(VarList &Dest, | 733 void TargetLowering::sortVarsByAlignment(VarList &Dest, |
734 const VarList &Source) const { | 734 const VarList &Source) const { |
735 Dest = Source; | 735 Dest = Source; |
736 // Instead of std::sort, we could do a bucket sort with log2(alignment) as | 736 // Instead of std::sort, we could do a bucket sort with log2(alignment) as |
737 // the buckets, if performance is an issue. | 737 // the buckets, if performance is an issue. |
738 std::sort(Dest.begin(), Dest.end(), | 738 std::sort(Dest.begin(), Dest.end(), |
739 [this](const Variable *V1, const Variable *V2) { | 739 [this](const Variable *V1, const Variable *V2) { |
740 return typeWidthInBytesOnStack(V1->getType()) > | 740 const size_t WidthV1 = typeWidthInBytesOnStack(V1->getType()); |
741 typeWidthInBytesOnStack(V2->getType()); | 741 const size_t WidthV2 = typeWidthInBytesOnStack(V2->getType()); |
| 742 if (WidthV1 == WidthV2) |
| 743 return V1->getIndex() < V2->getIndex(); |
| 744 return WidthV1 > WidthV2; |
742 }); | 745 }); |
743 } | 746 } |
744 | 747 |
745 void TargetLowering::getVarStackSlotParams( | 748 void TargetLowering::getVarStackSlotParams( |
746 VarList &SortedSpilledVariables, SmallBitVector &RegsUsed, | 749 VarList &SortedSpilledVariables, SmallBitVector &RegsUsed, |
747 size_t *GlobalsSize, size_t *SpillAreaSizeBytes, | 750 size_t *GlobalsSize, size_t *SpillAreaSizeBytes, |
748 uint32_t *SpillAreaAlignmentBytes, uint32_t *LocalsSlotsAlignmentBytes, | 751 uint32_t *SpillAreaAlignmentBytes, uint32_t *LocalsSlotsAlignmentBytes, |
749 std::function<bool(Variable *)> TargetVarHook) { | 752 std::function<bool(Variable *)> TargetVarHook) { |
750 const VariablesMetadata *VMetadata = Func->getVMetadata(); | 753 const VariablesMetadata *VMetadata = Func->getVMetadata(); |
751 BitVector IsVarReferenced(Func->getNumVariables()); | 754 BitVector IsVarReferenced(Func->getNumVariables()); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 case TARGET_LOWERING_CLASS_FOR(X): \ | 1091 case TARGET_LOWERING_CLASS_FOR(X): \ |
1089 return ::X::createTargetHeaderLowering(Ctx); | 1092 return ::X::createTargetHeaderLowering(Ctx); |
1090 #include "SZTargets.def" | 1093 #include "SZTargets.def" |
1091 #undef SUBZERO_TARGET | 1094 #undef SUBZERO_TARGET |
1092 } | 1095 } |
1093 } | 1096 } |
1094 | 1097 |
1095 TargetHeaderLowering::~TargetHeaderLowering() = default; | 1098 TargetHeaderLowering::~TargetHeaderLowering() = default; |
1096 | 1099 |
1097 } // end of namespace Ice | 1100 } // end of namespace Ice |
OLD | NEW |