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