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

Side by Side Diff: src/IceRegAlloc.cpp

Issue 1909853002: Subzero: Fix srem.i8/urem.i8 lowering for x86-64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/IceInstX8664.def ('k') | src/IceTargetLoweringX86BaseImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 int32_t findMinWeightIndex( 86 int32_t findMinWeightIndex(
87 const SmallBitVector &RegMask, 87 const SmallBitVector &RegMask,
88 const llvm::SmallVector<RegWeight, LinearScan::REGS_SIZE> &Weights) { 88 const llvm::SmallVector<RegWeight, LinearScan::REGS_SIZE> &Weights) {
89 int MinWeightIndex = -1; 89 int MinWeightIndex = -1;
90 for (RegNumT i : RegNumBVIter(RegMask)) { 90 for (RegNumT i : RegNumBVIter(RegMask)) {
91 if (MinWeightIndex < 0 || Weights[i] < Weights[MinWeightIndex]) 91 if (MinWeightIndex < 0 || Weights[i] < Weights[MinWeightIndex])
92 MinWeightIndex = i; 92 MinWeightIndex = i;
93 } 93 }
94 assert(MinWeightIndex >= 0); 94 assert(getFlags().getRegAllocReserve() || MinWeightIndex >= 0);
95 return MinWeightIndex; 95 return MinWeightIndex;
96 } 96 }
97 97
98 } // end of anonymous namespace 98 } // end of anonymous namespace
99 99
100 LinearScan::LinearScan(Cfg *Func) 100 LinearScan::LinearScan(Cfg *Func)
101 : Func(Func), Ctx(Func->getContext()), Target(Func->getTarget()), 101 : Func(Func), Ctx(Func->getContext()), Target(Func->getTarget()),
102 Verbose(BuildDefs::dump() && Func->isVerbose(IceV_LinearScan)), 102 Verbose(BuildDefs::dump() && Func->isVerbose(IceV_LinearScan)),
103 UseReserve(getFlags().getRegAllocReserve()) {} 103 UseReserve(getFlags().getRegAllocReserve()) {}
104 104
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 const auto &Aliases = *RegAliases[Item->getRegNumTmp()]; 679 const auto &Aliases = *RegAliases[Item->getRegNumTmp()];
680 RegWeight W = Item->getWeight(Func); 680 RegWeight W = Item->getWeight(Func);
681 for (RegNumT RegAlias : RegNumBVIter(Aliases)) { 681 for (RegNumT RegAlias : RegNumBVIter(Aliases)) {
682 Iter.Weights[RegAlias].addWeight(W); 682 Iter.Weights[RegAlias].addWeight(W);
683 } 683 }
684 } 684 }
685 685
686 // All the weights are now calculated. Find the register with smallest weight. 686 // All the weights are now calculated. Find the register with smallest weight.
687 int32_t MinWeightIndex = findMinWeightIndex(Iter.RegMask, Iter.Weights); 687 int32_t MinWeightIndex = findMinWeightIndex(Iter.RegMask, Iter.Weights);
688 688
689 if (Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) { 689 if (MinWeightIndex < 0 ||
690 Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) {
690 if (!Iter.Cur->mustHaveReg()) { 691 if (!Iter.Cur->mustHaveReg()) {
691 // Iter.Cur doesn't have priority over any other live ranges, so don't 692 // Iter.Cur doesn't have priority over any other live ranges, so don't
692 // allocate any register to it, and move it to the Handled state. 693 // allocate any register to it, and move it to the Handled state.
693 Handled.push_back(Iter.Cur); 694 Handled.push_back(Iter.Cur);
694 return; 695 return;
695 } 696 }
696 if (Kind == RAK_Phi) { 697 if (Kind == RAK_Phi) {
697 // Iter.Cur is infinite-weight but all physical registers are already 698 // Iter.Cur is infinite-weight but all physical registers are already
698 // taken, so we need to force one to be temporarily available. 699 // taken, so we need to force one to be temporarily available.
699 addSpillFill(Iter); 700 addSpillFill(Iter);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 864
864 // Allocate memory once outside the loop. 865 // Allocate memory once outside the loop.
865 IterationState Iter; 866 IterationState Iter;
866 Iter.Weights.reserve(NumRegisters); 867 Iter.Weights.reserve(NumRegisters);
867 Iter.PrecoloredUnhandledMask.reserve(NumRegisters); 868 Iter.PrecoloredUnhandledMask.reserve(NumRegisters);
868 869
869 while (!Unhandled.empty()) { 870 while (!Unhandled.empty()) {
870 Iter.Cur = Unhandled.back(); 871 Iter.Cur = Unhandled.back();
871 Unhandled.pop_back(); 872 Unhandled.pop_back();
872 dumpLiveRangeTrace("\nConsidering ", Iter.Cur); 873 dumpLiveRangeTrace("\nConsidering ", Iter.Cur);
873 assert(Target->getRegistersForVariable(Iter.Cur).any()); 874 if (UseReserve)
875 assert(Target->getAllRegistersForVariable(Iter.Cur).any());
876 else
877 assert(Target->getRegistersForVariable(Iter.Cur).any());
874 Iter.RegMask = RegMaskFull & Target->getRegistersForVariable(Iter.Cur); 878 Iter.RegMask = RegMaskFull & Target->getRegistersForVariable(Iter.Cur);
875 Iter.RegMaskUnfiltered = 879 Iter.RegMaskUnfiltered =
876 RegMaskFull & Target->getAllRegistersForVariable(Iter.Cur); 880 RegMaskFull & Target->getAllRegistersForVariable(Iter.Cur);
877 KillsRange.trim(Iter.Cur->getLiveRange().getStart()); 881 KillsRange.trim(Iter.Cur->getLiveRange().getStart());
878 882
879 // Check for pre-colored ranges. If Cur is pre-colored, it definitely gets 883 // Check for pre-colored ranges. If Cur is pre-colored, it definitely gets
880 // that register. Previously processed live ranges would have avoided that 884 // that register. Previously processed live ranges would have avoided that
881 // register due to it being pre-colored. Future processed live ranges won't 885 // register due to it being pre-colored. Future processed live ranges won't
882 // evict that register because the live range has infinite weight. 886 // evict that register because the live range has infinite weight.
883 if (Iter.Cur->hasReg()) { 887 if (Iter.Cur->hasReg()) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 Str << "\n"; 1018 Str << "\n";
1015 } 1019 }
1016 Str << "++++++ Inactive:\n"; 1020 Str << "++++++ Inactive:\n";
1017 for (const Variable *Item : Inactive) { 1021 for (const Variable *Item : Inactive) {
1018 dumpLiveRange(Item, Func); 1022 dumpLiveRange(Item, Func);
1019 Str << "\n"; 1023 Str << "\n";
1020 } 1024 }
1021 } 1025 }
1022 1026
1023 } // end of namespace Ice 1027 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8664.def ('k') | src/IceTargetLoweringX86BaseImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698