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

Side by Side Diff: src/compiler/move-optimizer.cc

Issue 2086653003: [Turbofan] Add the concept of aliasing to RegisterConfiguration. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 6 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/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
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 (!operand.IsFPRegister()) return set.find(operand) != set.end(); 31 if (set.find(operand) != set.end()) return true;
32 // Only FP registers alias.
33 if (!operand.IsFPRegister()) return false;
32 34
33 const LocationOperand& loc = LocationOperand::cast(operand); 35 const LocationOperand& loc = LocationOperand::cast(operand);
34 if (loc.representation() == MachineRepresentation::kFloat64) { 36 MachineRepresentation rep = loc.representation();
35 return set.find(operand) != set.end() || 37 MachineRepresentation other_fp_rep = rep == MachineRepresentation::kFloat64
36 set.find(LocationOperand(loc.kind(), loc.location_kind(), 38 ? MachineRepresentation::kFloat32
37 MachineRepresentation::kFloat32, 39 : MachineRepresentation::kFloat64;
38 loc.register_code())) != set.end(); 40 const RegisterConfiguration* config =
41 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN);
42 if (config->fp_aliasing_kind() != RegisterConfiguration::COMBINE) {
43 // Overlap aliasing case.
44 return set.find(LocationOperand(loc.kind(), loc.location_kind(),
45 other_fp_rep, loc.register_code())) !=
46 set.end();
39 } 47 }
40 DCHECK_EQ(MachineRepresentation::kFloat32, loc.representation()); 48 // Combine aliasing case.
41 return set.find(operand) != set.end() || 49 int alias_base_index = -1;
42 set.find(LocationOperand(loc.kind(), loc.location_kind(), 50 int aliases = config->GetAliases(rep, loc.register_code(), other_fp_rep,
43 MachineRepresentation::kFloat64, 51 &alias_base_index);
44 loc.register_code())) != set.end(); 52 while (aliases--) {
53 int aliased_reg = alias_base_index + aliases;
54 if (set.find(LocationOperand(loc.kind(), loc.location_kind(), other_fp_rep,
55 aliased_reg)) != set.end())
56 return true;
57 }
58 return false;
45 } 59 }
46 60
47 int FindFirstNonEmptySlot(const Instruction* instr) { 61 int FindFirstNonEmptySlot(const Instruction* instr) {
48 int i = Instruction::FIRST_GAP_POSITION; 62 int i = Instruction::FIRST_GAP_POSITION;
49 for (; i <= Instruction::LAST_GAP_POSITION; i++) { 63 for (; i <= Instruction::LAST_GAP_POSITION; i++) {
50 ParallelMove* moves = instr->parallel_moves()[i]; 64 ParallelMove* moves = instr->parallel_moves()[i];
51 if (moves == nullptr) continue; 65 if (moves == nullptr) continue;
52 for (MoveOperands* move : *moves) { 66 for (MoveOperands* move : *moves) {
53 if (!move->IsRedundant()) return i; 67 if (!move->IsRedundant()) return i;
54 move->Eliminate(); 68 move->Eliminate();
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 static_cast<Instruction::GapPosition>(1), code_zone()); 501 static_cast<Instruction::GapPosition>(1), code_zone());
488 slot_1->AddMove(group_begin->destination(), load->destination()); 502 slot_1->AddMove(group_begin->destination(), load->destination());
489 load->Eliminate(); 503 load->Eliminate();
490 } 504 }
491 loads.clear(); 505 loads.clear();
492 } 506 }
493 507
494 } // namespace compiler 508 } // namespace compiler
495 } // namespace internal 509 } // namespace internal
496 } // namespace v8 510 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698