Commit da9c42dd authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Make Node::set_op safer via wrapper.

This introduces the NodeProperties::ChangeOp helper which guards node
operator changes so that additional checking can be done without any
additional dependencies being pulled into the Node class. For now only
the input count is checked, but additional checking might follow.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1366753003

Cr-Commit-Position: refs/heads/master@{#30916}
parent 9e5b0a5a
......@@ -4219,12 +4219,12 @@ Node* AstGraphBuilder::MergeControl(Node* control, Node* other) {
// Control node for loop exists, add input.
const Operator* op = common()->Loop(inputs);
control->AppendInput(graph_zone(), other);
control->set_op(op);
NodeProperties::ChangeOp(control, op);
} else if (control->opcode() == IrOpcode::kMerge) {
// Control node for merge exists, add input.
const Operator* op = common()->Merge(inputs);
control->AppendInput(graph_zone(), other);
control->set_op(op);
NodeProperties::ChangeOp(control, op);
} else {
// Control node is a singleton, introduce a merge.
const Operator* op = common()->Merge(inputs);
......@@ -4240,8 +4240,8 @@ Node* AstGraphBuilder::MergeEffect(Node* value, Node* other, Node* control) {
if (value->opcode() == IrOpcode::kEffectPhi &&
NodeProperties::GetControlInput(value) == control) {
// Phi already exists, add input.
value->set_op(common()->EffectPhi(inputs));
value->InsertInput(graph_zone(), inputs - 1, other);
NodeProperties::ChangeOp(value, common()->EffectPhi(inputs));
} else if (value != other) {
// Phi does not exist yet, introduce one.
value = NewEffectPhi(inputs, value, control);
......@@ -4256,8 +4256,8 @@ Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) {
if (value->opcode() == IrOpcode::kPhi &&
NodeProperties::GetControlInput(value) == control) {
// Phi already exists, add input.
value->set_op(common()->Phi(kMachAnyTagged, inputs));
value->InsertInput(graph_zone(), inputs - 1, other);
NodeProperties::ChangeOp(value, common()->Phi(kMachAnyTagged, inputs));
} else if (value != other) {
// Phi does not exist yet, introduce one.
value = NewPhi(inputs, value, control);
......
......@@ -418,12 +418,12 @@ Node* BytecodeGraphBuilder::MergeControl(Node* control, Node* other) {
// Control node for loop exists, add input.
const Operator* op = common()->Loop(inputs);
control->AppendInput(graph_zone(), other);
control->set_op(op);
NodeProperties::ChangeOp(control, op);
} else if (control->opcode() == IrOpcode::kMerge) {
// Control node for merge exists, add input.
const Operator* op = common()->Merge(inputs);
control->AppendInput(graph_zone(), other);
control->set_op(op);
NodeProperties::ChangeOp(control, op);
} else {
// Control node is a singleton, introduce a merge.
const Operator* op = common()->Merge(inputs);
......
......@@ -85,10 +85,10 @@ Reduction CommonOperatorReducer::ReduceBranch(Node* node) {
for (Node* const use : node->uses()) {
switch (use->opcode()) {
case IrOpcode::kIfTrue:
use->set_op(common()->IfFalse());
NodeProperties::ChangeOp(use, common()->IfFalse());
break;
case IrOpcode::kIfFalse:
use->set_op(common()->IfTrue());
NodeProperties::ChangeOp(use, common()->IfTrue());
break;
default:
UNREACHABLE();
......@@ -99,7 +99,8 @@ Reduction CommonOperatorReducer::ReduceBranch(Node* node) {
// graph reduction logic will ensure that the uses are revisited properly.
node->ReplaceInput(0, cond->InputAt(0));
// Negate the hint for {branch}.
node->set_op(common()->Branch(NegateBranchHint(BranchHintOf(node->op()))));
NodeProperties::ChangeOp(
node, common()->Branch(NegateBranchHint(BranchHintOf(node->op()))));
return Changed(node);
}
Decision const decision = DecideCondition(cond);
......@@ -148,8 +149,8 @@ Reduction CommonOperatorReducer::ReduceMerge(Node* node) {
DCHECK(branch->OwnedBy(if_true, if_false));
Node* const control = branch->InputAt(1);
// Mark the {branch} as {Dead}.
branch->set_op(common()->Dead());
branch->TrimInputCount(0);
NodeProperties::ChangeOp(branch, common()->Dead());
return Replace(control);
}
}
......@@ -280,9 +281,8 @@ Reduction CommonOperatorReducer::ReduceReturn(Node* node) {
DCHECK_NE(0, control_input_count);
DCHECK_EQ(control_input_count, value->InputCount() - 1);
DCHECK_EQ(control_input_count, effect->InputCount() - 1);
Node* const end = graph()->end();
DCHECK_EQ(IrOpcode::kEnd, end->opcode());
DCHECK_NE(0, end->InputCount());
DCHECK_EQ(IrOpcode::kEnd, graph()->end()->opcode());
DCHECK_NE(0, graph()->end()->InputCount());
for (int i = 0; i < control_input_count; ++i) {
// Create a new {Return} and connect it to {end}. We don't need to mark
// {end} as revisit, because we mark {node} as {Dead} below, which was
......@@ -290,8 +290,7 @@ Reduction CommonOperatorReducer::ReduceReturn(Node* node) {
// the reducer logic will visit {end} again.
Node* ret = graph()->NewNode(common()->Return(), value->InputAt(i),
effect->InputAt(i), control->InputAt(i));
end->set_op(common()->End(end->InputCount() + 1));
end->AppendInput(graph()->zone(), ret);
NodeProperties::MergeControlToEnd(graph(), common(), ret);
}
// Mark the merge {control} and return {node} as {dead}.
Replace(control, dead());
......@@ -361,19 +360,19 @@ Reduction CommonOperatorReducer::ReduceSelect(Node* node) {
Reduction CommonOperatorReducer::Change(Node* node, Operator const* op,
Node* a) {
node->set_op(op);
node->ReplaceInput(0, a);
node->TrimInputCount(1);
NodeProperties::ChangeOp(node, op);
return Changed(node);
}
Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, Node* a,
Node* b) {
node->set_op(op);
node->ReplaceInput(0, a);
node->ReplaceInput(1, b);
node->TrimInputCount(2);
NodeProperties::ChangeOp(node, op);
return Changed(node);
}
......
......@@ -245,7 +245,7 @@ bool ControlFlowOptimizer::TryBuildSwitch(Node* node) {
branch->NullAllInputs();
if_true->ReplaceInput(0, node);
}
if_true->set_op(common()->IfValue(value));
NodeProperties::ChangeOp(if_true, common()->IfValue(value));
if_false->NullAllInputs();
Enqueue(if_true);
......@@ -261,13 +261,13 @@ bool ControlFlowOptimizer::TryBuildSwitch(Node* node) {
return false;
}
DCHECK_LT(1u, values.size());
node->set_op(common()->Switch(values.size() + 1));
node->ReplaceInput(0, index);
if_true->set_op(common()->IfValue(value));
NodeProperties::ChangeOp(node, common()->Switch(values.size() + 1));
if_true->ReplaceInput(0, node);
NodeProperties::ChangeOp(if_true, common()->IfValue(value));
Enqueue(if_true);
if_false->set_op(common()->IfDefault());
if_false->ReplaceInput(0, node);
NodeProperties::ChangeOp(if_false, common()->IfDefault());
Enqueue(if_false);
branch->NullAllInputs();
return true;
......
......@@ -52,8 +52,8 @@ Reduction DeadCodeElimination::ReduceEnd(Node* node) {
if (live_input_count == 0) {
return Replace(dead());
} else if (live_input_count < input_count) {
node->set_op(common()->End(live_input_count));
node->TrimInputCount(live_input_count);
NodeProperties::ChangeOp(node, common()->End(live_input_count));
return Changed(node);
}
DCHECK_EQ(input_count, live_input_count);
......@@ -137,7 +137,7 @@ Reduction DeadCodeElimination::ReduceNode(Node* node) {
void DeadCodeElimination::TrimMergeOrPhi(Node* node, int size) {
const Operator* const op = common()->ResizeMergeOrPhi(node->op(), size);
node->TrimInputCount(OperatorProperties::GetTotalInputCount(op));
node->set_op(op);
NodeProperties::ChangeOp(node, op);
}
} // namespace compiler
......
......@@ -8,6 +8,7 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
namespace v8 {
namespace internal {
......@@ -60,20 +61,20 @@ struct Diamond {
void OverwriteWithPhi(Node* node, MachineType machine_type, Node* tv,
Node* fv) {
DCHECK(node->InputCount() >= 3);
node->set_op(common->Phi(machine_type, 2));
node->ReplaceInput(0, tv);
node->ReplaceInput(1, fv);
node->ReplaceInput(2, merge);
node->TrimInputCount(3);
NodeProperties::ChangeOp(node, common->Phi(machine_type, 2));
}
void OverwriteWithEffectPhi(Node* node, Node* te, Node* fe) {
DCHECK(node->InputCount() >= 3);
node->set_op(common->EffectPhi(2));
node->ReplaceInput(0, te);
node->ReplaceInput(1, fe);
node->ReplaceInput(2, merge);
node->TrimInputCount(3);
NodeProperties::ChangeOp(node, common->EffectPhi(2));
}
};
}
......
......@@ -77,8 +77,8 @@ Reduction JSContextSpecialization::ReduceJSLoadContext(Node* node) {
}
const Operator* op = jsgraph_->javascript()->LoadContext(
0, access.index(), access.immutable());
node->set_op(op);
node->ReplaceInput(0, jsgraph_->Constant(context));
NodeProperties::ChangeOp(node, op);
return Changed(node);
}
Handle<Object> value =
......@@ -119,8 +119,8 @@ Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) {
context = handle(context->previous(), isolate());
}
node->set_op(javascript()->StoreContext(0, access.index()));
node->ReplaceInput(0, jsgraph_->Constant(context));
NodeProperties::ChangeOp(node, javascript()->StoreContext(0, access.index()));
return Changed(node);
}
......
......@@ -208,7 +208,7 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
node->ReplaceInput(0, booleanize);
node->ReplaceInput(1, true_value);
node->ReplaceInput(2, false_value);
node->set_op(common()->Select(kMachAnyTagged));
NodeProperties::ChangeOp(node, common()->Select(kMachAnyTagged));
}
......@@ -219,7 +219,7 @@ void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
isolate(), zone(), callable.descriptor(), 0, flags, properties);
Node* stub_code = jsgraph()->HeapConstant(callable.code());
node->InsertInput(zone(), 0, stub_code);
node->set_op(common()->Call(desc));
NodeProperties::ChangeOp(node, common()->Call(desc));
}
......@@ -236,7 +236,7 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
node->InsertInput(zone(), nargs + 1, ref);
node->InsertInput(zone(), nargs + 2, arity);
node->set_op(common()->Call(desc));
NodeProperties::ChangeOp(node, common()->Call(desc));
}
......@@ -440,7 +440,7 @@ void JSGenericLowering::LowerJSLoadContext(Node* node) {
node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
static_cast<int>(access.index()))));
node->AppendInput(zone(), graph()->start());
node->set_op(machine()->Load(kMachAnyTagged));
NodeProperties::ChangeOp(node, machine()->Load(kMachAnyTagged));
}
......@@ -458,8 +458,8 @@ void JSGenericLowering::LowerJSStoreContext(Node* node) {
node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1));
node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
static_cast<int>(access.index()))));
node->set_op(
machine()->Store(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier)));
NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation(
kMachAnyTagged, kFullWriteBarrier)));
}
......@@ -551,7 +551,7 @@ void JSGenericLowering::LowerJSCallConstruct(Node* node) {
node->InsertInput(zone(), 2, actual_construct);
node->InsertInput(zone(), 3, original_construct);
node->InsertInput(zone(), 4, jsgraph()->UndefinedConstant());
node->set_op(common()->Call(desc));
NodeProperties::ChangeOp(node, common()->Call(desc));
}
......@@ -568,7 +568,7 @@ void JSGenericLowering::LowerJSCallFunction(Node* node) {
isolate(), zone(), d, static_cast<int>(p.arity() - 1), flags);
Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
node->InsertInput(zone(), 0, stub_code);
node->set_op(common()->Call(desc));
NodeProperties::ChangeOp(node, common()->Call(desc));
}
......
......@@ -179,9 +179,8 @@ Reduction JSInliner::InlineCall(Node* call, Node* context, Node* frame_state,
case IrOpcode::kDeoptimize:
case IrOpcode::kTerminate:
case IrOpcode::kThrow:
jsgraph_->graph()->end()->AppendInput(jsgraph_->zone(), input);
jsgraph_->graph()->end()->set_op(
jsgraph_->common()->End(jsgraph_->graph()->end()->InputCount()));
NodeProperties::MergeControlToEnd(jsgraph_->graph(), jsgraph_->common(),
input);
break;
default:
UNREACHABLE();
......
......@@ -149,8 +149,8 @@ Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
graph()->NewNode(common()->Deoptimize(), frame_state, effect, control);
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
node->set_op(common()->Dead());
node->TrimInputCount(0);
NodeProperties::ChangeOp(node, common()->Dead());
return Changed(node);
}
......@@ -283,11 +283,12 @@ Reduction JSIntrinsicLowering::ReduceSeqStringGetChar(
Node* node, String::Encoding encoding) {
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
node->set_op(
simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding)));
node->ReplaceInput(2, effect);
node->ReplaceInput(3, control);
node->TrimInputCount(4);
NodeProperties::ChangeOp(
node,
simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding)));
RelaxControls(node);
return Changed(node);
}
......@@ -301,14 +302,15 @@ Reduction JSIntrinsicLowering::ReduceSeqStringSetChar(
Node* string = NodeProperties::GetValueInput(node, 2);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
node->set_op(
simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding)));
node->ReplaceInput(0, string);
node->ReplaceInput(1, index);
node->ReplaceInput(2, chr);
node->ReplaceInput(3, effect);
node->ReplaceInput(4, control);
node->TrimInputCount(5);
NodeProperties::ChangeOp(
node,
simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding)));
NodeProperties::RemoveType(node);
ReplaceWithValue(node, string, node);
return Changed(node);
......@@ -337,7 +339,7 @@ Reduction JSIntrinsicLowering::ReduceUnLikely(Node* node, BranchHint hint) {
nodes_to_visit.push(use);
} else if (use->opcode() == IrOpcode::kBranch) {
// Actually set the hint on any branch using the intrinsic node.
use->set_op(common()->Branch(hint));
NodeProperties::ChangeOp(use, common()->Branch(hint));
}
}
}
......@@ -417,7 +419,7 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op) {
// Remove the inputs corresponding to context, effect and control.
NodeProperties::RemoveNonValueInputs(node);
// Finally update the operator to the new one.
node->set_op(op);
NodeProperties::ChangeOp(node, op);
return Changed(node);
}
......@@ -519,14 +521,14 @@ Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) {
graph()->NewNode(common()->Deoptimize(), frame_state, effect, control);
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
node->set_op(common()->Dead());
node->TrimInputCount(0);
NodeProperties::ChangeOp(node, common()->Dead());
return Changed(node);
}
Reduction JSIntrinsicLowering::ReduceToObject(Node* node) {
node->set_op(javascript()->ToObject());
NodeProperties::ChangeOp(node, javascript()->ToObject());
return Changed(node);
}
......@@ -534,24 +536,26 @@ Reduction JSIntrinsicLowering::ReduceToObject(Node* node) {
Reduction JSIntrinsicLowering::ReduceCallFunction(Node* node) {
CallRuntimeParameters params = OpParameter<CallRuntimeParameters>(node->op());
size_t arity = params.arity();
node->set_op(javascript()->CallFunction(arity, NO_CALL_FUNCTION_FLAGS, STRICT,
VectorSlotPair(), ALLOW_TAIL_CALLS));
Node* function = node->InputAt(static_cast<int>(arity - 1));
while (--arity != 0) {
node->ReplaceInput(static_cast<int>(arity),
node->InputAt(static_cast<int>(arity - 1)));
}
node->ReplaceInput(0, function);
NodeProperties::ChangeOp(
node,
javascript()->CallFunction(params.arity(), NO_CALL_FUNCTION_FLAGS, STRICT,
VectorSlotPair(), ALLOW_TAIL_CALLS));
return Changed(node);
}
Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
Node* b) {
node->set_op(op);
node->ReplaceInput(0, a);
node->ReplaceInput(1, b);
node->TrimInputCount(2);
NodeProperties::ChangeOp(node, op);
RelaxControls(node);
return Changed(node);
}
......@@ -559,11 +563,11 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
Node* b, Node* c) {
node->set_op(op);
node->ReplaceInput(0, a);
node->ReplaceInput(1, b);
node->ReplaceInput(2, c);
node->TrimInputCount(3);
NodeProperties::ChangeOp(node, op);
RelaxControls(node);
return Changed(node);
}
......@@ -571,12 +575,12 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
Node* b, Node* c, Node* d) {
node->set_op(op);
node->ReplaceInput(0, a);
node->ReplaceInput(1, b);
node->ReplaceInput(2, c);
node->ReplaceInput(3, d);
node->TrimInputCount(4);
NodeProperties::ChangeOp(node, op);
RelaxControls(node);
return Changed(node);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -195,6 +195,13 @@ void NodeProperties::ReplaceUses(Node* node, Node* value, Node* effect,
}
// static
void NodeProperties::ChangeOp(Node* node, const Operator* new_op) {
DCHECK_EQ(OperatorProperties::GetTotalInputCount(new_op), node->InputCount());
node->set_op(new_op);
}
// static
Node* NodeProperties::FindProjection(Node* node, size_t projection_index) {
for (auto use : node->uses()) {
......
......@@ -94,6 +94,10 @@ class NodeProperties final {
static void ReplaceUses(Node* node, Node* value, Node* effect = nullptr,
Node* success = nullptr, Node* exception = nullptr);
// Safe wrapper to mutate the operator of a node. Checks that the node is
// currently in a state that satisfies constraints of the new operator.
static void ChangeOp(Node* node, const Operator* new_op);
// ---------------------------------------------------------------------------
// Miscellaneous utilities.
......
......@@ -49,7 +49,6 @@ class Node final {
void Kill();
const Operator* op() const { return op_; }
void set_op(const Operator* op) { op_ = op; }
IrOpcode::Value opcode() const {
DCHECK(op_->opcode() <= IrOpcode::kLast);
......@@ -284,6 +283,9 @@ class Node final {
void* operator new(size_t, void* location) { return location; }
// Only NodeProperties should manipulate the op.
void set_op(const Operator* op) { op_ = op; }
// Only NodeProperties should manipulate the type.
Type* type() const { return type_; }
void set_type(Type* type) { type_ = type; }
......
......@@ -237,7 +237,7 @@ static void PeelOuterLoopsForOsr(Graph* graph, CommonOperatorBuilder* common,
NodeId const id = end->InputAt(i)->id();
for (NodeVector* const copy : copies) {
end->AppendInput(graph->zone(), copy->at(id));
end->set_op(common->End(end->InputCount()));
NodeProperties::ChangeOp(end, common->End(end->InputCount()));
}
}
......@@ -301,12 +301,14 @@ void OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common,
CHECK_NE(0, live_input_count);
for (Node* const use : osr_loop->uses()) {
if (NodeProperties::IsPhi(use)) {
use->set_op(common->ResizeMergeOrPhi(use->op(), live_input_count));
use->RemoveInput(0);
NodeProperties::ChangeOp(
use, common->ResizeMergeOrPhi(use->op(), live_input_count));
}
}
osr_loop->set_op(common->ResizeMergeOrPhi(osr_loop->op(), live_input_count));
osr_loop->RemoveInput(0);
NodeProperties::ChangeOp(
osr_loop, common->ResizeMergeOrPhi(osr_loop->op(), live_input_count));
// Run control reduction and graph trimming.
// TODO(bmeurer): The OSR deconstruction could be a regular reducer and play
......
......@@ -8,6 +8,7 @@
#include "src/compiler/diamond.h"
#include "src/compiler/graph.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
namespace v8 {
namespace internal {
......@@ -51,7 +52,7 @@ Reduction SelectLowering::Reduce(Node* node) {
}
// Create a Phi hanging off the previously determined merge.
node->set_op(common()->Phi(p.type(), 2));
NodeProperties::ChangeOp(node, common()->Phi(p.type(), 2));
node->ReplaceInput(0, vthen);
node->ReplaceInput(1, velse);
node->ReplaceInput(2, merge);
......
This diff is collapsed.
......@@ -100,8 +100,8 @@ Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
Node* a) {
DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
DCHECK_LE(1, node->InputCount());
node->set_op(op);
node->ReplaceInput(0, a);
NodeProperties::ChangeOp(node, op);
return Changed(node);
}
......
......@@ -63,8 +63,6 @@ Reduction TailCallOptimization::Reduce(Node* node) {
DCHECK_EQ(call, NodeProperties::GetControlInput(control, 0));
DCHECK_EQ(3, node->InputCount());
node->set_op(
common()->TailCall(OpParameter<CallDescriptor const*>(call)));
node->ReplaceInput(0, NodeProperties::GetEffectInput(call));
node->ReplaceInput(1, NodeProperties::GetControlInput(call));
node->RemoveInput(2);
......@@ -72,6 +70,8 @@ Reduction TailCallOptimization::Reduce(Node* node) {
node->InsertInput(graph()->zone(), index,
NodeProperties::GetValueInput(call, index));
}
NodeProperties::ChangeOp(
node, common()->TailCall(OpParameter<CallDescriptor const*>(call)));
return Changed(node);
}
}
......
......@@ -5,6 +5,7 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operator.h"
#include "test/unittests/compiler/graph-reducer-unittest.h"
#include "test/unittests/test-utils.h"
......@@ -63,15 +64,15 @@ class InPlaceABReducer final : public Reducer {
switch (node->op()->opcode()) {
case kOpcodeA0:
EXPECT_EQ(0, node->InputCount());
node->set_op(&kOpB0);
NodeProperties::ChangeOp(node, &kOpB0);
return Replace(node);
case kOpcodeA1:
EXPECT_EQ(1, node->InputCount());
node->set_op(&kOpB1);
NodeProperties::ChangeOp(node, &kOpB1);
return Replace(node);
case kOpcodeA2:
EXPECT_EQ(2, node->InputCount());
node->set_op(&kOpB2);
NodeProperties::ChangeOp(node, &kOpB2);
return Replace(node);
}
return NoChange();
......@@ -178,15 +179,15 @@ class InPlaceBCReducer final : public Reducer {
switch (node->op()->opcode()) {
case kOpcodeB0:
EXPECT_EQ(0, node->InputCount());
node->set_op(&kOpC0);
NodeProperties::ChangeOp(node, &kOpC0);
return Replace(node);
case kOpcodeB1:
EXPECT_EQ(1, node->InputCount());
node->set_op(&kOpC1);
NodeProperties::ChangeOp(node, &kOpC1);
return Replace(node);
case kOpcodeB2:
EXPECT_EQ(2, node->InputCount());
node->set_op(&kOpC2);
NodeProperties::ChangeOp(node, &kOpC2);
return Replace(node);
}
return NoChange();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment