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

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

Issue 2092103004: [Turbofan] Add Simd128 registers to RegisterConfiguration. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add simd128 mask. Created 4 years, 5 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
« no previous file with comments | « src/arm64/assembler-arm64.h ('k') | src/compiler/register-allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 namespace { 11 namespace {
12 12
13 struct MoveKey { 13 struct MoveKey {
14 InstructionOperand source; 14 InstructionOperand source;
15 InstructionOperand destination; 15 InstructionOperand destination;
16 }; 16 };
17 17
18 struct MoveKeyCompare { 18 struct MoveKeyCompare {
19 bool operator()(const MoveKey& a, const MoveKey& b) const { 19 bool operator()(const MoveKey& a, const MoveKey& b) const {
20 if (a.source.EqualsCanonicalized(b.source)) { 20 if (a.source.EqualsCanonicalized(b.source)) {
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 Contains(const OperandSet& set, const LocationOperand& loc,
31 MachineRepresentation rep, int reg_code) {
32 return set.find(LocationOperand(loc.kind(), loc.location_kind(), rep,
33 reg_code)) != set.end();
34 }
35
30 bool Blocks(const OperandSet& set, const InstructionOperand& operand) { 36 bool Blocks(const OperandSet& set, const InstructionOperand& operand) {
31 if (set.find(operand) != set.end()) return true; 37 if (set.find(operand) != set.end()) return true;
32 // Only FP registers alias. 38 // General registers don't alias.
33 if (!operand.IsFPRegister()) return false; 39 if (!operand.IsFPRegister()) return false;
34 40
41 // Check operand against operands of other FP types for interference.
35 const LocationOperand& loc = LocationOperand::cast(operand); 42 const LocationOperand& loc = LocationOperand::cast(operand);
36 MachineRepresentation rep = loc.representation(); 43 MachineRepresentation rep = loc.representation();
37 MachineRepresentation other_fp_rep = rep == MachineRepresentation::kFloat64 44 MachineRepresentation other_rep1, other_rep2;
38 ? MachineRepresentation::kFloat32 45 switch (rep) {
39 : MachineRepresentation::kFloat64; 46 case MachineRepresentation::kFloat32:
47 other_rep1 = MachineRepresentation::kFloat64;
48 other_rep2 = MachineRepresentation::kSimd128;
49 break;
50 case MachineRepresentation::kFloat64:
51 other_rep1 = MachineRepresentation::kFloat32;
52 other_rep2 = MachineRepresentation::kSimd128;
53 break;
54 case MachineRepresentation::kSimd128:
55 other_rep1 = MachineRepresentation::kFloat32;
56 other_rep2 = MachineRepresentation::kFloat64;
57 break;
58 default:
59 UNREACHABLE();
60 break;
61 }
40 const RegisterConfiguration* config = RegisterConfiguration::Turbofan(); 62 const RegisterConfiguration* config = RegisterConfiguration::Turbofan();
41 if (config->fp_aliasing_kind() != RegisterConfiguration::COMBINE) { 63 if (config->fp_aliasing_kind() != RegisterConfiguration::COMBINE) {
42 // Overlap aliasing case. 64 // Overlap aliasing case.
43 return set.find(LocationOperand(loc.kind(), loc.location_kind(), 65 return Contains(set, loc, other_rep1, loc.register_code()) ||
44 other_fp_rep, loc.register_code())) != 66 Contains(set, loc, other_rep2, loc.register_code());
45 set.end();
46 } 67 }
47 // Combine aliasing case. 68 // Combine aliasing case.
48 int alias_base_index = -1; 69 int base = -1;
49 int aliases = config->GetAliases(rep, loc.register_code(), other_fp_rep, 70 int aliases = config->GetAliases(rep, loc.register_code(), other_rep1, &base);
Mircea Trofin 2016/06/27 20:32:26 Is base expected to be positive after this?
bbudge 2016/06/27 20:43:21 It is left unchanged if the return value is 0 (no
Mircea Trofin 2016/06/27 20:49:20 Should we have the DCHECK right after the call to
bbudge 2016/06/27 21:08:01 Good idea, I've added a DCHECK at all GetAliases c
50 &alias_base_index);
51 while (aliases--) { 71 while (aliases--) {
52 int aliased_reg = alias_base_index + aliases; 72 if (Contains(set, loc, other_rep1, base + aliases)) return true;
53 if (set.find(LocationOperand(loc.kind(), loc.location_kind(), other_fp_rep, 73 }
54 aliased_reg)) != set.end()) 74 aliases = config->GetAliases(rep, loc.register_code(), other_rep2, &base);
55 return true; 75 while (aliases--) {
76 if (Contains(set, loc, other_rep2, base + aliases)) return true;
56 } 77 }
57 return false; 78 return false;
58 } 79 }
59 80
60 int FindFirstNonEmptySlot(const Instruction* instr) { 81 int FindFirstNonEmptySlot(const Instruction* instr) {
61 int i = Instruction::FIRST_GAP_POSITION; 82 int i = Instruction::FIRST_GAP_POSITION;
62 for (; i <= Instruction::LAST_GAP_POSITION; i++) { 83 for (; i <= Instruction::LAST_GAP_POSITION; i++) {
63 ParallelMove* moves = instr->parallel_moves()[i]; 84 ParallelMove* moves = instr->parallel_moves()[i];
64 if (moves == nullptr) continue; 85 if (moves == nullptr) continue;
65 for (MoveOperands* move : *moves) { 86 for (MoveOperands* move : *moves) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 static_cast<Instruction::GapPosition>(1), code_zone()); 521 static_cast<Instruction::GapPosition>(1), code_zone());
501 slot_1->AddMove(group_begin->destination(), load->destination()); 522 slot_1->AddMove(group_begin->destination(), load->destination());
502 load->Eliminate(); 523 load->Eliminate();
503 } 524 }
504 loads.clear(); 525 loads.clear();
505 } 526 }
506 527
507 } // namespace compiler 528 } // namespace compiler
508 } // namespace internal 529 } // namespace internal
509 } // namespace v8 530 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/assembler-arm64.h ('k') | src/compiler/register-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698