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/move-optimizer.h" | 5 #include "src/compiler/move-optimizer.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 return a.destination.CompareCanonicalized(b.destination); | 21 return a.destination.CompareCanonicalized(b.destination); |
22 } | 22 } |
23 return a.source.CompareCanonicalized(b.source); | 23 return a.source.CompareCanonicalized(b.source); |
24 } | 24 } |
25 }; | 25 }; |
26 | 26 |
27 typedef ZoneMap<MoveKey, unsigned, MoveKeyCompare> MoveMap; | 27 typedef ZoneMap<MoveKey, unsigned, MoveKeyCompare> MoveMap; |
28 typedef ZoneSet<InstructionOperand, CompareOperandModuloType> OperandSet; | 28 typedef ZoneSet<InstructionOperand, CompareOperandModuloType> OperandSet; |
29 | 29 |
30 bool Blocks(const OperandSet& set, const InstructionOperand& operand) { | 30 bool Blocks(const OperandSet& set, const InstructionOperand& operand) { |
31 if (set.find(operand) != set.end()) return true; | 31 if (!operand.IsFPRegister()) return set.find(operand) != set.end(); |
32 // Only FP registers on archs with non-simple aliasing need extra checks. | |
33 if (!operand.IsFPRegister() || kSimpleFPAliasing) return false; | |
34 | 32 |
35 // Check operand against operands of other FP types for interference. | |
36 const LocationOperand& loc = LocationOperand::cast(operand); | 33 const LocationOperand& loc = LocationOperand::cast(operand); |
37 MachineRepresentation rep = loc.representation(); | 34 if (loc.representation() == MachineRepresentation::kFloat64) { |
38 MachineRepresentation other_rep1, other_rep2; | 35 return set.find(operand) != set.end() || |
39 switch (rep) { | 36 set.find(LocationOperand(loc.kind(), loc.location_kind(), |
40 case MachineRepresentation::kFloat32: | 37 MachineRepresentation::kFloat32, |
41 other_rep1 = MachineRepresentation::kFloat64; | 38 loc.register_code())) != set.end(); |
42 other_rep2 = MachineRepresentation::kSimd128; | |
43 break; | |
44 case MachineRepresentation::kFloat64: | |
45 other_rep1 = MachineRepresentation::kFloat32; | |
46 other_rep2 = MachineRepresentation::kSimd128; | |
47 break; | |
48 case MachineRepresentation::kSimd128: | |
49 other_rep1 = MachineRepresentation::kFloat32; | |
50 other_rep2 = MachineRepresentation::kFloat64; | |
51 break; | |
52 default: | |
53 UNREACHABLE(); | |
54 break; | |
55 } | 39 } |
56 const RegisterConfiguration* config = RegisterConfiguration::Turbofan(); | 40 DCHECK_EQ(MachineRepresentation::kFloat32, loc.representation()); |
57 int base = -1; | 41 return set.find(operand) != set.end() || |
58 int aliases = config->GetAliases(rep, loc.register_code(), other_rep1, &base); | 42 set.find(LocationOperand(loc.kind(), loc.location_kind(), |
59 DCHECK(aliases > 0 || (aliases == 0 && base == -1)); | 43 MachineRepresentation::kFloat64, |
60 while (aliases--) { | 44 loc.register_code())) != set.end(); |
61 if (set.find(LocationOperand(loc.kind(), loc.location_kind(), other_rep1, | |
62 base + aliases)) != set.end()) | |
63 return true; | |
64 } | |
65 aliases = config->GetAliases(rep, loc.register_code(), other_rep2, &base); | |
66 DCHECK(aliases > 0 || (aliases == 0 && base == -1)); | |
67 while (aliases--) { | |
68 if (set.find(LocationOperand(loc.kind(), loc.location_kind(), other_rep2, | |
69 base + aliases)) != set.end()) | |
70 return true; | |
71 } | |
72 return false; | |
73 } | 45 } |
74 | 46 |
75 int FindFirstNonEmptySlot(const Instruction* instr) { | 47 int FindFirstNonEmptySlot(const Instruction* instr) { |
76 int i = Instruction::FIRST_GAP_POSITION; | 48 int i = Instruction::FIRST_GAP_POSITION; |
77 for (; i <= Instruction::LAST_GAP_POSITION; i++) { | 49 for (; i <= Instruction::LAST_GAP_POSITION; i++) { |
78 ParallelMove* moves = instr->parallel_moves()[i]; | 50 ParallelMove* moves = instr->parallel_moves()[i]; |
79 if (moves == nullptr) continue; | 51 if (moves == nullptr) continue; |
80 for (MoveOperands* move : *moves) { | 52 for (MoveOperands* move : *moves) { |
81 if (!move->IsRedundant()) return i; | 53 if (!move->IsRedundant()) return i; |
82 move->Eliminate(); | 54 move->Eliminate(); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 static_cast<Instruction::GapPosition>(1), code_zone()); | 487 static_cast<Instruction::GapPosition>(1), code_zone()); |
516 slot_1->AddMove(group_begin->destination(), load->destination()); | 488 slot_1->AddMove(group_begin->destination(), load->destination()); |
517 load->Eliminate(); | 489 load->Eliminate(); |
518 } | 490 } |
519 loads.clear(); | 491 loads.clear(); |
520 } | 492 } |
521 | 493 |
522 } // namespace compiler | 494 } // namespace compiler |
523 } // namespace internal | 495 } // namespace internal |
524 } // namespace v8 | 496 } // namespace v8 |
OLD | NEW |