Chromium Code Reviews| 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 const int kBaseRep = static_cast<int>(MachineRepresentation::kFloat32); | |
| 90 int index_lo = index_hi - (1 << (static_cast<int>(rep) - kBaseRep)) + 1; | |
|
Jarin
2016/10/18 11:44:28
Could we express this in terms of ElementSizeLog2O
bbudge
2016/10/19 00:32:21
Done. (both places)
| |
| 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); | |
|
bbudge
2016/10/19 00:32:21
I also De-morgan'ed this boolean expression.
| |
| 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 Loading... | |
| 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())) { |
| 272 // We must replace move's source with curr's destination in order to | |
| 273 // insert it into this ParallelMove. | |
| 242 DCHECK(!replacement); | 274 DCHECK(!replacement); |
| 243 replacement = curr; | 275 replacement = curr; |
| 244 if (to_eliminate != nullptr) break; | 276 if (no_aliasing && eliminated != nullptr) break; |
| 245 } else if (curr->destination().EqualsCanonicalized(move->destination())) { | 277 } else if (curr->destination().InterferesWith(move->destination())) { |
| 246 DCHECK(!to_eliminate); | 278 // We can eliminate curr, since move overwrites at least a part of its |
| 247 to_eliminate = curr; | 279 // destination, implying its value is no longer live. |
| 248 if (replacement != nullptr) break; | 280 eliminated = curr; |
| 281 to_eliminate->push_back(curr); | |
| 282 if (no_aliasing && replacement != nullptr) break; | |
| 249 } | 283 } |
| 250 } | 284 } |
| 251 DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr); | |
| 252 if (replacement != nullptr) move->set_source(replacement->source()); | 285 if (replacement != nullptr) move->set_source(replacement->source()); |
| 253 return to_eliminate; | |
| 254 } | 286 } |
| 255 | 287 |
| 256 | |
| 257 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, | 288 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, |
| 258 int index) | 289 int index) |
| 259 : LocationOperand(EXPLICIT, kind, rep, index) { | 290 : LocationOperand(EXPLICIT, kind, rep, index) { |
| 260 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), | 291 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), |
| 261 GetRegConfig()->IsAllocatableGeneralCode(index)); | 292 GetRegConfig()->IsAllocatableGeneralCode(index)); |
| 262 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32, | 293 DCHECK_IMPLIES(kind == REGISTER && rep == MachineRepresentation::kFloat32, |
| 263 GetRegConfig()->IsAllocatableFloatCode(index)); | 294 GetRegConfig()->IsAllocatableFloatCode(index)); |
| 264 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64), | 295 DCHECK_IMPLIES(kind == REGISTER && (rep == MachineRepresentation::kFloat64), |
| 265 GetRegConfig()->IsAllocatableDoubleCode(index)); | 296 GetRegConfig()->IsAllocatableDoubleCode(index)); |
| 266 } | 297 } |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1036 for (int i = 0; i < code.InstructionBlockCount(); i++) { | 1067 for (int i = 0; i < code.InstructionBlockCount(); i++) { |
| 1037 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i)); | 1068 printable_block.block_ = code.InstructionBlockAt(RpoNumber::FromInt(i)); |
| 1038 os << printable_block; | 1069 os << printable_block; |
| 1039 } | 1070 } |
| 1040 return os; | 1071 return os; |
| 1041 } | 1072 } |
| 1042 | 1073 |
| 1043 } // namespace compiler | 1074 } // namespace compiler |
| 1044 } // namespace internal | 1075 } // namespace internal |
| 1045 } // namespace v8 | 1076 } // namespace v8 |
| OLD | NEW |