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

Side by Side Diff: src/compiler/instruction.cc

Issue 2410673002: [Turbofan] Add concept of FP register aliasing on ARM 32. (Closed)
Patch Set: Fix reg codes (ia32) and register allocator (arm32). Created 4 years, 2 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 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/instruction.h" 7 #include "src/compiler/instruction.h"
8 #include "src/compiler/schedule.h" 8 #include "src/compiler/schedule.h"
9 #include "src/compiler/state-values-utils.h" 9 #include "src/compiler/state-values-utils.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 case kOverflow: 57 case kOverflow:
58 case kNotOverflow: 58 case kNotOverflow:
59 case kUnorderedEqual: 59 case kUnorderedEqual:
60 case kUnorderedNotEqual: 60 case kUnorderedNotEqual:
61 return condition; 61 return condition;
62 } 62 }
63 UNREACHABLE(); 63 UNREACHABLE();
64 return condition; 64 return condition;
65 } 65 }
66 66
67 bool InstructionOperand::InterferesWith(const InstructionOperand& that) const { 67 bool InstructionOperand::InterferesWith(const InstructionOperand& other) const {
68 return EqualsCanonicalized(that); 68 if (kSimpleFPAliasing || !this->IsFPLocationOperand() ||
69 !other.IsFPLocationOperand())
70 return EqualsCanonicalized(other);
71 // Aliasing is complex and both operands are fp locations.
72 const LocationOperand& loc = *LocationOperand::cast(this);
73 const LocationOperand& other_loc = LocationOperand::cast(other);
74 LocationOperand::LocationKind kind = loc.location_kind();
75 LocationOperand::LocationKind other_kind = other_loc.location_kind();
76 if (kind != other_kind) return false;
77 MachineRepresentation rep = loc.representation();
78 MachineRepresentation other_rep = other_loc.representation();
79 if (rep == other_rep) return EqualsCanonicalized(other);
80 if (kind == LocationOperand::REGISTER) {
81 // FP register-register interference.
82 return GetRegConfig()->AreAliases(rep, loc.register_code(), other_rep,
83 other_loc.register_code());
84 } else {
85 // FP slot-slot interference. Slots of different FP reps can alias because
86 // the gap resolver may break a move into 2 or 4 equivalent smaller moves.
87 DCHECK_EQ(LocationOperand::STACK_SLOT, kind);
88 int index_hi = loc.index();
89 const int kBaseRep = static_cast<int>(MachineRepresentation::kFloat32);
90 int index_lo = index_hi - (1 << (static_cast<int>(rep) - kBaseRep)) + 1;
91 int other_index_hi = other_loc.index();
92 int other_index_lo =
93 other_index_hi - (1 << (static_cast<int>(other_rep) - kBaseRep)) + 1;
94 return !(other_index_hi < index_lo || index_hi < other_index_lo);
95 }
96 return false;
69 } 97 }
70 98
71 void InstructionOperand::Print(const RegisterConfiguration* config) const { 99 void InstructionOperand::Print(const RegisterConfiguration* config) const {
72 OFStream os(stdout); 100 OFStream os(stdout);
73 PrintableInstructionOperand wrapper; 101 PrintableInstructionOperand wrapper;
74 wrapper.register_configuration_ = config; 102 wrapper.register_configuration_ = config;
75 wrapper.op_ = *this; 103 wrapper.op_ = *this;
76 os << wrapper << std::endl; 104 os << wrapper << std::endl;
77 } 105 }
78 106
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 253 }
226 254
227 255
228 bool ParallelMove::IsRedundant() const { 256 bool ParallelMove::IsRedundant() const {
229 for (MoveOperands* move : *this) { 257 for (MoveOperands* move : *this) {
230 if (!move->IsRedundant()) return false; 258 if (!move->IsRedundant()) return false;
231 } 259 }
232 return true; 260 return true;
233 } 261 }
234 262
235 263 void ParallelMove::PrepareInsertAfter(
236 MoveOperands* ParallelMove::PrepareInsertAfter(MoveOperands* move) const { 264 MoveOperands* move, ZoneVector<MoveOperands*>* to_eliminate) const {
265 bool no_aliasing =
266 kSimpleFPAliasing || !move->destination().IsFPLocationOperand();
237 MoveOperands* replacement = nullptr; 267 MoveOperands* replacement = nullptr;
238 MoveOperands* to_eliminate = nullptr; 268 MoveOperands* eliminated = nullptr;
239 for (MoveOperands* curr : *this) { 269 for (MoveOperands* curr : *this) {
240 if (curr->IsEliminated()) continue; 270 if (curr->IsEliminated()) continue;
241 if (curr->destination().EqualsCanonicalized(move->source())) { 271 if (curr->destination().EqualsCanonicalized(move->source())) {
242 DCHECK(!replacement); 272 DCHECK(!replacement);
243 replacement = curr; 273 replacement = curr;
244 if (to_eliminate != nullptr) break; 274 if (no_aliasing && eliminated != nullptr) break;
245 } else if (curr->destination().EqualsCanonicalized(move->destination())) { 275 } else if (curr->destination().InterferesWith(move->destination())) {
246 DCHECK(!to_eliminate); 276 eliminated = curr;
247 to_eliminate = curr; 277 to_eliminate->push_back(curr);
georgia.kouveli 2016/10/12 17:38:41 If the representation of "move" is narrower than t
bbudge 2016/10/12 23:07:17 I don't think splitting is needed here in either c
248 if (replacement != nullptr) break; 278 if (no_aliasing && replacement != nullptr) break;
249 } 279 }
250 } 280 }
251 DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr);
252 if (replacement != nullptr) move->set_source(replacement->source()); 281 if (replacement != nullptr) move->set_source(replacement->source());
253 return to_eliminate;
254 } 282 }
255 283
256
257 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, 284 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep,
258 int index) 285 int index)
259 : LocationOperand(EXPLICIT, kind, rep, index) { 286 : LocationOperand(EXPLICIT, kind, rep, index) {
260 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), 287 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep),
261 GetRegConfig()->IsAllocatableGeneralCode(index)); 288 GetRegConfig()->IsAllocatableGeneralCode(index));
262 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32, 289 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32,
263 GetRegConfig()->IsAllocatableFloatCode(index)); 290 GetRegConfig()->IsAllocatableFloatCode(index));
264 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64), 291 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64),
265 GetRegConfig()->IsAllocatableDoubleCode(index)); 292 GetRegConfig()->IsAllocatableDoubleCode(index));
266 } 293 }
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 for (int i = 0; i < code.InstructionBlockCount(); i++) { 1063 for (int i = 0; i < code.InstructionBlockCount(); i++) {
1037 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i)); 1064 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i));
1038 os << printable_block; 1065 os << printable_block;
1039 } 1066 }
1040 return os; 1067 return os;
1041 } 1068 }
1042 1069
1043 } // namespace compiler 1070 } // namespace compiler
1044 } // namespace internal 1071 } // namespace internal
1045 } // namespace v8 1072 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698