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

Side by Side Diff: src/compiler/register-allocator.cc

Issue 1242303005: [turbofan]: Elide extra move when accessing stack or frame register (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: src/compiler/code-generator.cc Created 5 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
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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/linkage.h" 6 #include "src/compiler/linkage.h"
7 #include "src/compiler/register-allocator.h" 7 #include "src/compiler/register-allocator.h"
8 #include "src/string-stream.h" 8 #include "src/string-stream.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 UNREACHABLE(); 159 UNREACHABLE();
160 return false; 160 return false;
161 } 161 }
162 162
163 163
164 UsePositionHintType UsePosition::HintTypeForOperand( 164 UsePositionHintType UsePosition::HintTypeForOperand(
165 const InstructionOperand& op) { 165 const InstructionOperand& op) {
166 switch (op.kind()) { 166 switch (op.kind()) {
167 case InstructionOperand::CONSTANT: 167 case InstructionOperand::CONSTANT:
168 case InstructionOperand::IMMEDIATE: 168 case InstructionOperand::IMMEDIATE:
169 case InstructionOperand::STACK_POINTER:
170 case InstructionOperand::FRAME_POINTER:
169 return UsePositionHintType::kNone; 171 return UsePositionHintType::kNone;
170 case InstructionOperand::UNALLOCATED: 172 case InstructionOperand::UNALLOCATED:
171 return UsePositionHintType::kUnresolved; 173 return UsePositionHintType::kUnresolved;
172 case InstructionOperand::ALLOCATED: 174 case InstructionOperand::ALLOCATED:
173 switch (AllocatedOperand::cast(op).allocated_kind()) { 175 switch (AllocatedOperand::cast(op).allocated_kind()) {
174 case AllocatedOperand::REGISTER: 176 case AllocatedOperand::REGISTER:
175 case AllocatedOperand::DOUBLE_REGISTER: 177 case AllocatedOperand::DOUBLE_REGISTER:
176 return UsePositionHintType::kOperand; 178 return UsePositionHintType::kOperand;
177 case AllocatedOperand::STACK_SLOT: 179 case AllocatedOperand::STACK_SLOT:
178 case AllocatedOperand::DOUBLE_STACK_SLOT: 180 case AllocatedOperand::DOUBLE_STACK_SLOT:
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 } 1240 }
1239 } 1241 }
1240 } 1242 }
1241 1243
1242 1244
1243 void ConstraintBuilder::MeetConstraintsBefore(int instr_index) { 1245 void ConstraintBuilder::MeetConstraintsBefore(int instr_index) {
1244 auto second = InstructionAt(instr_index); 1246 auto second = InstructionAt(instr_index);
1245 // Handle fixed input operands of second instruction. 1247 // Handle fixed input operands of second instruction.
1246 for (size_t i = 0; i < second->InputCount(); i++) { 1248 for (size_t i = 0; i < second->InputCount(); i++) {
1247 auto input = second->InputAt(i); 1249 auto input = second->InputAt(i);
1248 if (input->IsImmediate()) continue; // Ignore immediates. 1250 if (input->IsImmediate() || input->IsStackPointer() ||
1251 input->IsFramePointer()) {
1252 continue; // Ignore immediates and special registers
1253 }
1249 auto cur_input = UnallocatedOperand::cast(input); 1254 auto cur_input = UnallocatedOperand::cast(input);
1250 if (cur_input->HasFixedPolicy()) { 1255 if (cur_input->HasFixedPolicy()) {
1251 int input_vreg = cur_input->virtual_register(); 1256 int input_vreg = cur_input->virtual_register();
1252 UnallocatedOperand input_copy(UnallocatedOperand::ANY, input_vreg); 1257 UnallocatedOperand input_copy(UnallocatedOperand::ANY, input_vreg);
1253 bool is_tagged = IsReference(input_vreg); 1258 bool is_tagged = IsReference(input_vreg);
1254 AllocateFixed(cur_input, instr_index, is_tagged); 1259 AllocateFixed(cur_input, instr_index, is_tagged);
1255 data()->AddGapMove(instr_index, Instruction::END, input_copy, *cur_input); 1260 data()->AddGapMove(instr_index, Instruction::END, input_copy, *cur_input);
1256 } 1261 }
1257 } 1262 }
1258 // Handle "output same as input" for second instruction. 1263 // Handle "output same as input" for second instruction.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 if (!IsOutputDoubleRegisterOf(instr, i)) { 1516 if (!IsOutputDoubleRegisterOf(instr, i)) {
1512 auto range = FixedDoubleLiveRangeFor(i); 1517 auto range = FixedDoubleLiveRangeFor(i);
1513 range->AddUseInterval(curr_position, curr_position.End(), 1518 range->AddUseInterval(curr_position, curr_position.End(),
1514 allocation_zone()); 1519 allocation_zone());
1515 } 1520 }
1516 } 1521 }
1517 } 1522 }
1518 1523
1519 for (size_t i = 0; i < instr->InputCount(); i++) { 1524 for (size_t i = 0; i < instr->InputCount(); i++) {
1520 auto input = instr->InputAt(i); 1525 auto input = instr->InputAt(i);
1521 if (input->IsImmediate()) continue; // Ignore immediates. 1526 if (input->IsImmediate() || input->IsStackPointer() ||
1527 input->IsFramePointer()) {
1528 continue; // Ignore immediates and special registers
1529 }
1522 LifetimePosition use_pos; 1530 LifetimePosition use_pos;
1523 if (input->IsUnallocated() && 1531 if (input->IsUnallocated() &&
1524 UnallocatedOperand::cast(input)->IsUsedAtStart()) { 1532 UnallocatedOperand::cast(input)->IsUsedAtStart()) {
1525 use_pos = curr_position; 1533 use_pos = curr_position;
1526 } else { 1534 } else {
1527 use_pos = curr_position.End(); 1535 use_pos = curr_position.End();
1528 } 1536 }
1529 1537
1530 if (input->IsUnallocated()) { 1538 if (input->IsUnallocated()) {
1531 UnallocatedOperand* unalloc = UnallocatedOperand::cast(input); 1539 UnallocatedOperand* unalloc = UnallocatedOperand::cast(input);
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 auto eliminate = moves->PrepareInsertAfter(move); 2892 auto eliminate = moves->PrepareInsertAfter(move);
2885 to_insert.push_back(move); 2893 to_insert.push_back(move);
2886 if (eliminate != nullptr) to_eliminate.push_back(eliminate); 2894 if (eliminate != nullptr) to_eliminate.push_back(eliminate);
2887 } 2895 }
2888 } 2896 }
2889 2897
2890 2898
2891 } // namespace compiler 2899 } // namespace compiler
2892 } // namespace internal 2900 } // namespace internal
2893 } // namespace v8 2901 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips64/code-generator-mips64.cc ('k') | src/compiler/register-allocator-verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698