| OLD | NEW |
| 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 Loading... |
| 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 int index_lo = index_hi - (1 << ElementSizeLog2Of(rep)) / kPointerSize + 1; |
| 90 int other_index_hi = other_loc.index(); |
| 91 int other_index_lo = |
| 92 other_index_hi - (1 << ElementSizeLog2Of(other_rep)) / kPointerSize + 1; |
| 93 return other_index_hi >= index_lo && index_hi >= other_index_lo; |
| 94 } |
| 95 return false; |
| 69 } | 96 } |
| 70 | 97 |
| 71 void InstructionOperand::Print(const RegisterConfiguration* config) const { | 98 void InstructionOperand::Print(const RegisterConfiguration* config) const { |
| 72 OFStream os(stdout); | 99 OFStream os(stdout); |
| 73 PrintableInstructionOperand wrapper; | 100 PrintableInstructionOperand wrapper; |
| 74 wrapper.register_configuration_ = config; | 101 wrapper.register_configuration_ = config; |
| 75 wrapper.op_ = *this; | 102 wrapper.op_ = *this; |
| 76 os << wrapper << std::endl; | 103 os << wrapper << std::endl; |
| 77 } | 104 } |
| 78 | 105 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 252 } |
| 226 | 253 |
| 227 | 254 |
| 228 bool ParallelMove::IsRedundant() const { | 255 bool ParallelMove::IsRedundant() const { |
| 229 for (MoveOperands* move : *this) { | 256 for (MoveOperands* move : *this) { |
| 230 if (!move->IsRedundant()) return false; | 257 if (!move->IsRedundant()) return false; |
| 231 } | 258 } |
| 232 return true; | 259 return true; |
| 233 } | 260 } |
| 234 | 261 |
| 235 | 262 void ParallelMove::PrepareInsertAfter( |
| 236 MoveOperands* ParallelMove::PrepareInsertAfter(MoveOperands* move) const { | 263 MoveOperands* move, ZoneVector<MoveOperands*>* to_eliminate) const { |
| 264 bool no_aliasing = |
| 265 kSimpleFPAliasing || !move->destination().IsFPLocationOperand(); |
| 237 MoveOperands* replacement = nullptr; | 266 MoveOperands* replacement = nullptr; |
| 238 MoveOperands* to_eliminate = nullptr; | 267 MoveOperands* eliminated = nullptr; |
| 239 for (MoveOperands* curr : *this) { | 268 for (MoveOperands* curr : *this) { |
| 240 if (curr->IsEliminated()) continue; | 269 if (curr->IsEliminated()) continue; |
| 241 if (curr->destination().EqualsCanonicalized(move->source())) { | 270 if (curr->destination().EqualsCanonicalized(move->source())) { |
| 271 // We must replace move's source with curr's destination in order to |
| 272 // insert it into this ParallelMove. |
| 242 DCHECK(!replacement); | 273 DCHECK(!replacement); |
| 243 replacement = curr; | 274 replacement = curr; |
| 244 if (to_eliminate != nullptr) break; | 275 if (no_aliasing && eliminated != nullptr) break; |
| 245 } else if (curr->destination().EqualsCanonicalized(move->destination())) { | 276 } else if (curr->destination().InterferesWith(move->destination())) { |
| 246 DCHECK(!to_eliminate); | 277 // We can eliminate curr, since move overwrites at least a part of its |
| 247 to_eliminate = curr; | 278 // destination, implying its value is no longer live. |
| 248 if (replacement != nullptr) break; | 279 eliminated = curr; |
| 280 to_eliminate->push_back(curr); |
| 281 if (no_aliasing && replacement != nullptr) break; |
| 249 } | 282 } |
| 250 } | 283 } |
| 251 DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr); | |
| 252 if (replacement != nullptr) move->set_source(replacement->source()); | 284 if (replacement != nullptr) move->set_source(replacement->source()); |
| 253 return to_eliminate; | |
| 254 } | 285 } |
| 255 | 286 |
| 256 | |
| 257 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, | 287 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, |
| 258 int index) | 288 int index) |
| 259 : LocationOperand(EXPLICIT, kind, rep, index) { | 289 : LocationOperand(EXPLICIT, kind, rep, index) { |
| 260 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), | 290 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), |
| 261 GetRegConfig()->IsAllocatableGeneralCode(index)); | 291 GetRegConfig()->IsAllocatableGeneralCode(index)); |
| 262 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32, | 292 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32, |
| 263 GetRegConfig()->IsAllocatableFloatCode(index)); | 293 GetRegConfig()->IsAllocatableFloatCode(index)); |
| 264 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64), | 294 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64), |
| 265 GetRegConfig()->IsAllocatableDoubleCode(index)); | 295 GetRegConfig()->IsAllocatableDoubleCode(index)); |
| 266 } | 296 } |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 for (int i = 0; i < code.InstructionBlockCount(); i++) { | 1066 for (int i = 0; i < code.InstructionBlockCount(); i++) { |
| 1037 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i)); | 1067 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i)); |
| 1038 os << printable_block; | 1068 os << printable_block; |
| 1039 } | 1069 } |
| 1040 return os; | 1070 return os; |
| 1041 } | 1071 } |
| 1042 | 1072 |
| 1043 } // namespace compiler | 1073 } // namespace compiler |
| 1044 } // namespace internal | 1074 } // namespace internal |
| 1045 } // namespace v8 | 1075 } // namespace v8 |
| OLD | NEW |