From 3032a9ffb5021af57e58e10b20d9941eb230b216 Mon Sep 17 00:00:00 2001 From: Vasili Skurydzin Date: Wed, 14 Mar 2018 13:24:43 -0400 Subject: [PATCH] PPC/s390: [TurboFan] Use the FlagsContinuation more effectively Port ab9ac994583492bc84c9d999861b643b83e51549 Original Commit Message: We can reduce boilerplate if we pass the continuation to some InstructionSelector::Emit.* methods. R=mvstanton@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com BUG= LOG=N Change-Id: Ia9ddd0dcf5d6115ee9f8c35e1b05c10f9f0c4b39 Reviewed-on: https://chromium-review.googlesource.com/959441 Commit-Queue: Junliang Yan Reviewed-by: Junliang Yan Cr-Commit-Position: refs/heads/master@{#51948} --- src/compiler/ppc/instruction-selector-ppc.cc | 38 +----- .../s390/instruction-selector-s390.cc | 108 ++---------------- 2 files changed, 12 insertions(+), 134 deletions(-) diff --git a/src/compiler/ppc/instruction-selector-ppc.cc b/src/compiler/ppc/instruction-selector-ppc.cc index 7b58e24e93..e0cbe98a28 100644 --- a/src/compiler/ppc/instruction-selector-ppc.cc +++ b/src/compiler/ppc/instruction-selector-ppc.cc @@ -129,11 +129,6 @@ void VisitBinop(InstructionSelector* selector, Node* node, inputs[input_count++] = g.UseRegister(m.left().node()); inputs[input_count++] = g.UseOperand(m.right().node(), operand_mode); - if (cont->IsBranch()) { - inputs[input_count++] = g.Label(cont->true_block()); - inputs[input_count++] = g.Label(cont->false_block()); - } - if (cont->IsDeoptimize()) { // If we can deoptimize as a result of the binop, we need to make sure that // the deopt inputs are not overwritten by the binop result. One way @@ -142,26 +137,14 @@ void VisitBinop(InstructionSelector* selector, Node* node, } else { outputs[output_count++] = g.DefineAsRegister(node); } - if (cont->IsSet()) { - outputs[output_count++] = g.DefineAsRegister(cont->result()); - } DCHECK_NE(0u, input_count); DCHECK_NE(0u, output_count); DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(outputs), output_count); - opcode = cont->Encode(opcode); - if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, - cont->kind(), cont->reason(), cont->feedback(), - cont->frame_state()); - } else if (cont->IsTrap()) { - inputs[input_count++] = g.UseImmediate(cont->trap_id()); - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } else { - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } + selector->EmitWithContinuation(opcode, output_count, outputs, input_count, + inputs, cont); } @@ -1486,22 +1469,7 @@ namespace { void VisitCompare(InstructionSelector* selector, InstructionCode opcode, InstructionOperand left, InstructionOperand right, FlagsContinuation* cont) { - PPCOperandGenerator g(selector); - opcode = cont->Encode(opcode); - if (cont->IsBranch()) { - selector->Emit(opcode, g.NoOutput(), left, right, - g.Label(cont->true_block()), g.Label(cont->false_block())); - } else if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->kind(), - cont->reason(), cont->feedback(), - cont->frame_state()); - } else if (cont->IsSet()) { - selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); - } else { - DCHECK(cont->IsTrap()); - selector->Emit(opcode, g.NoOutput(), left, right, - g.UseImmediate(cont->trap_id())); - } + selector->EmitWithContinuation(opcode, left, right, cont); } diff --git a/src/compiler/s390/instruction-selector-s390.cc b/src/compiler/s390/instruction-selector-s390.cc index f0e4e4107f..c7ed5791d3 100644 --- a/src/compiler/s390/instruction-selector-s390.cc +++ b/src/compiler/s390/instruction-selector-s390.cc @@ -583,11 +583,6 @@ void VisitUnaryOp(InstructionSelector* selector, Node* node, inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt); } - if (cont->IsBranch()) { - inputs[input_count++] = g.Label(cont->true_block()); - inputs[input_count++] = g.Label(cont->false_block()); - } - if (!cont->IsDeoptimize()) { // If we can deoptimize as a result of the binop, we need to make sure // that the deopt inputs are not overwritten by the binop result. One way @@ -602,27 +597,13 @@ void VisitUnaryOp(InstructionSelector* selector, Node* node, outputs[output_count++] = g.DefineSameAsFirst(node); } - if (cont->IsSet()) { - outputs[output_count++] = g.DefineAsRegister(cont->result()); - } - DCHECK_NE(0u, input_count); DCHECK_NE(0u, output_count); DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(outputs), output_count); - opcode = cont->Encode(opcode); - - if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, - cont->kind(), cont->reason(), cont->feedback(), - cont->frame_state()); - } else if (cont->IsTrap()) { - inputs[input_count++] = g.UseImmediate(cont->trap_id()); - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } else { - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } + selector->EmitWithContinuation(opcode, output_count, outputs, input_count, + inputs, cont); } template @@ -658,11 +639,6 @@ void VisitBinOp(InstructionSelector* selector, Node* node, inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt); } - if (cont->IsBranch()) { - inputs[input_count++] = g.Label(cont->true_block()); - inputs[input_count++] = g.Label(cont->false_block()); - } - if ((operand_mode & OperandMode::kAllowDistinctOps) && // If we can deoptimize as a result of the binop, we need to make sure // that the deopt inputs are not overwritten by the binop result. One way @@ -678,27 +654,13 @@ void VisitBinOp(InstructionSelector* selector, Node* node, outputs[output_count++] = g.DefineSameAsFirst(node); } - if (cont->IsSet()) { - outputs[output_count++] = g.DefineAsRegister(cont->result()); - } - DCHECK_NE(0u, input_count); DCHECK_NE(0u, output_count); DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(outputs), output_count); - opcode = cont->Encode(opcode); - - if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, - cont->kind(), cont->reason(), cont->feedback(), - cont->frame_state()); - } else if (cont->IsTrap()) { - inputs[input_count++] = g.UseImmediate(cont->trap_id()); - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } else { - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } + selector->EmitWithContinuation(opcode, output_count, outputs, input_count, + inputs, cont); } } // namespace @@ -1651,22 +1613,7 @@ namespace { void VisitCompare(InstructionSelector* selector, InstructionCode opcode, InstructionOperand left, InstructionOperand right, FlagsContinuation* cont) { - S390OperandGenerator g(selector); - opcode = cont->Encode(opcode); - if (cont->IsBranch()) { - selector->Emit(opcode, g.NoOutput(), left, right, - g.Label(cont->true_block()), g.Label(cont->false_block())); - } else if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->kind(), - cont->reason(), cont->feedback(), - cont->frame_state()); - } else if (cont->IsSet()) { - selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); - } else { - DCHECK(cont->IsTrap()); - selector->Emit(opcode, g.NoOutput(), left, right, - g.UseImmediate(cont->trap_id())); - } + selector->EmitWithContinuation(opcode, left, right, cont); } void VisitLoadAndTest(InstructionSelector* selector, InstructionCode opcode, @@ -1727,27 +1674,9 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, inputs[input_count++] = g.UseAnyExceptImmediate(right); } - opcode = cont->Encode(opcode); - if (cont->IsBranch()) { - inputs[input_count++] = g.Label(cont->true_block()); - inputs[input_count++] = g.Label(cont->false_block()); - } else if (cont->IsSet()) { - outputs[output_count++] = g.DefineAsRegister(cont->result()); - } else if (cont->IsTrap()) { - inputs[input_count++] = g.UseImmediate(cont->trap_id()); - } else { - DCHECK(cont->IsDeoptimize()); - // nothing to do - } - DCHECK(input_count <= 8 && output_count <= 1); - if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, - cont->kind(), cont->reason(), cont->feedback(), - cont->frame_state()); - } else { - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } + selector->EmitWithContinuation(opcode, output_count, outputs, input_count, + inputs, cont); } void VisitWord32Compare(InstructionSelector* selector, Node* node, @@ -1832,28 +1761,9 @@ void VisitLoadAndTest(InstructionSelector* selector, InstructionCode opcode, outputs[output_count++] = g.DefineAsRegister(value); } - opcode = cont->Encode(opcode); - if (cont->IsBranch()) { - inputs[input_count++] = g.Label(cont->true_block()); - inputs[input_count++] = g.Label(cont->false_block()); - } else if (cont->IsSet()) { - outputs[output_count++] = g.DefineAsRegister(cont->result()); - } else if (cont->IsTrap()) { - inputs[input_count++] = g.UseImmediate(cont->trap_id()); - } else { - DCHECK(cont->IsDeoptimize()); - // nothing to do - } - DCHECK(input_count <= 8 && output_count <= 2); - opcode = cont->Encode(opcode); - if (cont->IsDeoptimize()) { - selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, - cont->kind(), cont->reason(), cont->feedback(), - cont->frame_state()); - } else { - selector->Emit(opcode, output_count, outputs, input_count, inputs); - } + selector->EmitWithContinuation(opcode, output_count, outputs, input_count, + inputs, cont); } } // namespace