| 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/base/bits.h" | 5 #include "src/base/bits.h" |
| 6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
| 7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 outputs[output_count++] = g.DefineAsRegister(node); | 98 outputs[output_count++] = g.DefineAsRegister(node); |
| 99 if (cont->IsSet()) { | 99 if (cont->IsSet()) { |
| 100 outputs[output_count++] = g.DefineAsRegister(cont->result()); | 100 outputs[output_count++] = g.DefineAsRegister(cont->result()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 DCHECK_NE(0, input_count); | 103 DCHECK_NE(0, input_count); |
| 104 DCHECK_NE(0, output_count); | 104 DCHECK_NE(0, output_count); |
| 105 DCHECK_GE(arraysize(inputs), input_count); | 105 DCHECK_GE(arraysize(inputs), input_count); |
| 106 DCHECK_GE(arraysize(outputs), output_count); | 106 DCHECK_GE(arraysize(outputs), output_count); |
| 107 | 107 |
| 108 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, | 108 selector->Emit(cont->Encode(opcode), output_count, outputs, input_count, |
| 109 outputs, input_count, inputs); | 109 inputs); |
| 110 if (cont->IsBranch()) instr->MarkAsControl(); | |
| 111 } | 110 } |
| 112 | 111 |
| 113 | 112 |
| 114 static void VisitBinop(InstructionSelector* selector, Node* node, | 113 static void VisitBinop(InstructionSelector* selector, Node* node, |
| 115 InstructionCode opcode) { | 114 InstructionCode opcode) { |
| 116 FlagsContinuation cont; | 115 FlagsContinuation cont; |
| 117 VisitBinop(selector, node, opcode, &cont); | 116 VisitBinop(selector, node, opcode, &cont); |
| 118 } | 117 } |
| 119 | 118 |
| 120 | 119 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 namespace { | 578 namespace { |
| 580 | 579 |
| 581 // Shared routine for multiple compare operations. | 580 // Shared routine for multiple compare operations. |
| 582 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 581 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 583 InstructionOperand* left, InstructionOperand* right, | 582 InstructionOperand* left, InstructionOperand* right, |
| 584 FlagsContinuation* cont) { | 583 FlagsContinuation* cont) { |
| 585 MipsOperandGenerator g(selector); | 584 MipsOperandGenerator g(selector); |
| 586 opcode = cont->Encode(opcode); | 585 opcode = cont->Encode(opcode); |
| 587 if (cont->IsBranch()) { | 586 if (cont->IsBranch()) { |
| 588 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), | 587 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), |
| 589 g.Label(cont->false_block()))->MarkAsControl(); | 588 g.Label(cont->false_block())); |
| 590 } else { | 589 } else { |
| 591 DCHECK(cont->IsSet()); | 590 DCHECK(cont->IsSet()); |
| 592 // TODO(plind): Revisit and test this path. | 591 // TODO(plind): Revisit and test this path. |
| 593 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 592 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| 594 } | 593 } |
| 595 } | 594 } |
| 596 | 595 |
| 597 | 596 |
| 598 // Shared routine for multiple float compare operations. | 597 // Shared routine for multiple float compare operations. |
| 599 void VisitFloat64Compare(InstructionSelector* selector, Node* node, | 598 void VisitFloat64Compare(InstructionSelector* selector, Node* node, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 707 } |
| 709 break; | 708 break; |
| 710 } | 709 } |
| 711 | 710 |
| 712 // Continuation could not be combined with a compare, emit compare against 0. | 711 // Continuation could not be combined with a compare, emit compare against 0. |
| 713 MipsOperandGenerator g(selector); | 712 MipsOperandGenerator g(selector); |
| 714 InstructionCode const opcode = cont->Encode(kMipsCmp); | 713 InstructionCode const opcode = cont->Encode(kMipsCmp); |
| 715 InstructionOperand* const value_operand = g.UseRegister(value); | 714 InstructionOperand* const value_operand = g.UseRegister(value); |
| 716 if (cont->IsBranch()) { | 715 if (cont->IsBranch()) { |
| 717 selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0), | 716 selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0), |
| 718 g.Label(cont->true_block()), | 717 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 719 g.Label(cont->false_block()))->MarkAsControl(); | |
| 720 } else { | 718 } else { |
| 721 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, | 719 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, |
| 722 g.TempImmediate(0)); | 720 g.TempImmediate(0)); |
| 723 } | 721 } |
| 724 } | 722 } |
| 725 | 723 |
| 726 | 724 |
| 727 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 725 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 728 BasicBlock* fbranch) { | 726 BasicBlock* fbranch) { |
| 729 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 727 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 803 |
| 806 // static | 804 // static |
| 807 MachineOperatorBuilder::Flags | 805 MachineOperatorBuilder::Flags |
| 808 InstructionSelector::SupportedMachineOperatorFlags() { | 806 InstructionSelector::SupportedMachineOperatorFlags() { |
| 809 return MachineOperatorBuilder::kNoFlags; | 807 return MachineOperatorBuilder::kNoFlags; |
| 810 } | 808 } |
| 811 | 809 |
| 812 } // namespace compiler | 810 } // namespace compiler |
| 813 } // namespace internal | 811 } // namespace internal |
| 814 } // namespace v8 | 812 } // namespace v8 |
| OLD | NEW |