Lines Matching refs:Node
11 #include "src/compiler/node-matchers.h"
12 #include "src/compiler/node-properties.h"
14 #include "src/compiler/node.h"
51 if (top.input_index == top.node->InputCount()) {
54 state_.Set(top.node, State::kVisited);
55 LowerNode(top.node);
58 Node* input = top.node->InputAt(top.input_index++);
107 void Int64Lowering::GetIndexNodes(Node* index, Node*& index_low,
108 Node*& index_high) {
131 void Int64Lowering::LowerNode(Node* node) {
132 switch (node->opcode()) {
134 int64_t value = OpParameter<int64_t>(node);
135 Node* low_node = graph()->NewNode(
137 Node* high_node = graph()->NewNode(
139 ReplaceNode(node, low_node, high_node);
145 if (node->opcode() == IrOpcode::kLoad) {
146 rep = LoadRepresentationOf(node->op()).representation();
148 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad);
149 rep = UnalignedLoadRepresentationOf(node->op()).representation();
153 Node* base = node->InputAt(0);
154 Node* index = node->InputAt(1);
155 Node* index_low;
156 Node* index_high;
160 if (node->opcode() == IrOpcode::kLoad) {
163 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad);
167 Node* high_node;
168 if (node->InputCount() > 2) {
169 Node* effect_high = node->InputAt(2);
170 Node* control_high = node->InputAt(3);
175 node->ReplaceInput(2, high_node);
179 node->ReplaceInput(1, index_low);
180 NodeProperties::ChangeOp(node, load_op);
181 ReplaceNode(node, node, high_node);
183 DefaultLowering(node);
190 if (node->opcode() == IrOpcode::kStore) {
191 rep = StoreRepresentationOf(node->op()).representation();
193 DCHECK(node->opcode() == IrOpcode::kUnalignedStore);
194 rep = UnalignedStoreRepresentationOf(node->op());
198 // We change the original store node to store the low word, and create
199 // a new store node to store the high word. The effect and control edges
200 // are copied from the original store to the new store node, the effect
202 Node* base = node->InputAt(0);
203 Node* index = node->InputAt(1);
204 Node* index_low;
205 Node* index_high;
207 Node* value = node->InputAt(2);
212 if (node->opcode() == IrOpcode::kStore) {
214 StoreRepresentationOf(node->op()).write_barrier_kind();
218 DCHECK(node->opcode() == IrOpcode::kUnalignedStore);
222 Node* high_node;
223 if (node->InputCount() > 3) {
224 Node* effect_high = node->InputAt(3);
225 Node* control_high = node->InputAt(4);
229 node->ReplaceInput(3, high_node);
236 node->ReplaceInput(1, index_low);
237 node->ReplaceInput(2, GetReplacementLow(value));
238 NodeProperties::ChangeOp(node, store_op);
239 ReplaceNode(node, node, high_node);
241 DefaultLowering(node, true);
247 // Only exchange the node if the parameter count actually changed.
251 int new_output_count = node->op()->ValueOutputCount() + delta;
252 NodeProperties::ChangeOp(node, common()->Start(new_output_count));
257 DCHECK(node->InputCount() == 1);
258 // Only exchange the node if the parameter count actually changed. We do
259 // not even have to do the default lowering because the the start node,
260 // the only input of a parameter node, only changes if the parameter count
264 int old_index = ParameterIndexOf(node->op());
266 NodeProperties::ChangeOp(node, common()->Parameter(new_index));
268 Node* high_node = nullptr;
274 ReplaceNode(node, node, high_node);
279 DefaultLowering(node);
282 NodeProperties::ChangeOp(node, common()->Return(new_return_count));
289 const_cast<CallDescriptor*>(CallDescriptorOf(node->op()));
290 if (DefaultLowering(node) ||
296 NodeProperties::ChangeOp(node, op);
301 Node* low_node =
302 graph()->NewNode(common()->Projection(0), node, graph()->start());
303 Node* high_node =
304 graph()->NewNode(common()->Projection(1), node, graph()->start());
305 ReplaceNode(node, low_node, high_node);
310 DCHECK(node->InputCount() == 2);
311 Node* left = node->InputAt(0);
312 Node* right = node->InputAt(1);
314 Node* low_node =
317 Node* high_node =
320 ReplaceNode(node, low_node, high_node);
324 DCHECK(node->InputCount() == 1);
325 Node* input = node->InputAt(0);
326 ReplaceNode(node, GetReplacementLow(input), nullptr);
327 node->NullAllInputs();
331 DCHECK(node->InputCount() == 2);
333 Node* right = node->InputAt(1);
334 node->ReplaceInput(1, GetReplacementLow(right));
335 node->AppendInput(zone(), GetReplacementHigh(right));
337 Node* left = node->InputAt(0);
338 node->ReplaceInput(0, GetReplacementLow(left));
339 node->InsertInput(zone(), 1, GetReplacementHigh(left));
341 NodeProperties::ChangeOp(node, machine()->Int32PairAdd());
343 Node* low_node =
344 graph()->NewNode(common()->Projection(0), node, graph()->start());
345 Node* high_node =
346 graph()->NewNode(common()->Projection(1), node, graph()->start());
347 ReplaceNode(node, low_node, high_node);
351 DCHECK(node->InputCount() == 2);
353 Node* right = node->InputAt(1);
354 node->ReplaceInput(1, GetReplacementLow(right));
355 node->AppendInput(zone(), GetReplacementHigh(right));
357 Node* left = node->InputAt(0);
358 node->ReplaceInput(0, GetReplacementLow(left));
359 node->InsertInput(zone(), 1, GetReplacementHigh(left));
361 NodeProperties::ChangeOp(node, machine()->Int32PairSub());
363 Node* low_node =
364 graph()->NewNode(common()->Projection(0), node, graph()->start());
365 Node* high_node =
366 graph()->NewNode(common()->Projection(1), node, graph()->start());
367 ReplaceNode(node, low_node, high_node);
371 DCHECK(node->InputCount() == 2);
373 Node* right = node->InputAt(1);
374 node->ReplaceInput(1, GetReplacementLow(right));
375 node->AppendInput(zone(), GetReplacementHigh(right));
377 Node* left = node->InputAt(0);
378 node->ReplaceInput(0, GetReplacementLow(left));
379 node->InsertInput(zone(), 1, GetReplacementHigh(left));
381 NodeProperties::ChangeOp(node, machine()->Int32PairMul());
383 Node* low_node =
384 graph()->NewNode(common()->Projection(0), node, graph()->start());
385 Node* high_node =
386 graph()->NewNode(common()->Projection(1), node, graph()->start());
387 ReplaceNode(node, low_node, high_node);
391 DCHECK(node->InputCount() == 2);
392 Node* left = node->InputAt(0);
393 Node* right = node->InputAt(1);
395 Node* low_node =
398 Node* high_node =
401 ReplaceNode(node, low_node, high_node);
405 DCHECK(node->InputCount() == 2);
406 Node* left = node->InputAt(0);
407 Node* right = node->InputAt(1);
409 Node* low_node =
412 Node* high_node =
415 ReplaceNode(node, low_node, high_node);
421 DCHECK(node->InputCount() == 2);
422 Node* shift = node->InputAt(1);
426 node->ReplaceInput(1, GetReplacementLow(shift));
429 Node* value = node->InputAt(0);
430 node->ReplaceInput(0, GetReplacementLow(value));
431 node->InsertInput(zone(), 1, GetReplacementHigh(value));
433 NodeProperties::ChangeOp(node, machine()->Word32PairShl());
435 Node* low_node =
436 graph()->NewNode(common()->Projection(0), node, graph()->start());
437 Node* high_node =
438 graph()->NewNode(common()->Projection(1), node, graph()->start());
439 ReplaceNode(node, low_node, high_node);
445 DCHECK(node->InputCount() == 2);
446 Node* shift = node->InputAt(1);
450 node->ReplaceInput(1, GetReplacementLow(shift));
453 Node* value = node->InputAt(0);
454 node->ReplaceInput(0, GetReplacementLow(value));
455 node->InsertInput(zone(), 1, GetReplacementHigh(value));
457 NodeProperties::ChangeOp(node, machine()->Word32PairShr());
459 Node* low_node =
460 graph()->NewNode(common()->Projection(0), node, graph()->start());
461 Node* high_node =
462 graph()->NewNode(common()->Projection(1), node, graph()->start());
463 ReplaceNode(node, low_node, high_node);
469 DCHECK(node->InputCount() == 2);
470 Node* shift = node->InputAt(1);
474 node->ReplaceInput(1, GetReplacementLow(shift));
477 Node* value = node->InputAt(0);
478 node->ReplaceInput(0, GetReplacementLow(value));
479 node->InsertInput(zone(), 1, GetReplacementHigh(value));
481 NodeProperties::ChangeOp(node, machine()->Word32PairSar());
483 Node* low_node =
484 graph()->NewNode(common()->Projection(0), node, graph()->start());
485 Node* high_node =
486 graph()->NewNode(common()->Projection(1), node, graph()->start());
487 ReplaceNode(node, low_node, high_node);
491 DCHECK(node->InputCount() == 2);
492 Node* left = node->InputAt(0);
493 Node* right = node->InputAt(1);
496 Node* replacement = graph()->NewNode(
506 ReplaceNode(node, replacement, nullptr);
510 LowerComparison(node, machine()->Int32LessThan(),
515 LowerComparison(node, machine()->Int32LessThan(),
520 LowerComparison(node, machine()->Uint32LessThan(),
525 LowerComparison(node, machine()->Uint32LessThan(),
530 DCHECK(node->InputCount() == 1);
531 Node* input = node->InputAt(0);
537 node, input,
540 node->NullAllInputs();
544 DCHECK(node->InputCount() == 1);
545 Node* input = node->InputAt(0);
549 ReplaceNode(node, input, graph()->NewNode(common()->Int32Constant(0)));
550 node->NullAllInputs();
554 DCHECK(node->InputCount() == 1);
555 Node* input = node->InputAt(0);
556 Node* stack_slot = graph()->NewNode(
559 Node* store_high_word = graph()->NewNode(
567 Node* store_low_word = graph()->NewNode(
575 Node* load =
580 ReplaceNode(node, load, nullptr);
584 DCHECK(node->InputCount() == 1);
585 Node* input = node->InputAt(0);
589 Node* stack_slot = graph()->NewNode(
591 Node* store = graph()->NewNode(
598 Node* high_node = graph()->NewNode(
603 Node* low_node = graph()->NewNode(
607 ReplaceNode(node, low_node, high_node);
611 DCHECK(node->InputCount() == 2);
612 Node* input = node->InputAt(0);
613 Node* shift = HasReplacementLow(node->InputAt(1))
614 ? GetReplacementLow(node->InputAt(1))
615 : node->InputAt(1);
621 ReplaceNode(node, GetReplacementLow(input),
624 ReplaceNode(node, GetReplacementHigh(input),
627 Node* low_input;
628 Node* high_input;
637 Node* masked_shift =
639 Node* inv_shift = graph()->NewNode(
642 Node* low_node = graph()->NewNode(
646 Node* high_node = graph()->NewNode(
650 ReplaceNode(node, low_node, high_node);
653 Node* safe_shift = shift;
662 Node* inv_mask = graph()->NewNode(
670 Node* bit_mask =
677 Node* masked_shift6 = shift;
692 Node* input_low =
695 Node* input_high =
699 Node* rotate_low =
701 Node* rotate_high =
704 Node* low_node = graph()->NewNode(
709 Node* high_node = graph()->NewNode(
714 ReplaceNode(node, low_node, high_node);
719 DCHECK(node->InputCount() == 1);
720 Node* input = node->InputAt(0);
726 Node* low_node = d.Phi(
733 ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
737 DCHECK(node->InputCount() == 1);
739 Node* input = node->InputAt(0);
744 Node* low_node =
752 ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
756 DCHECK(node->InputCount() == 1);
757 Node* input = node->InputAt(0);
758 // We assume that a Word64Popcnt node only has been created if
761 ReplaceNode(node, graph()->NewNode(
771 MachineRepresentation rep = PhiRepresentationOf(node->op());
775 Node* low_node = GetReplacementLow(node);
776 Node* high_node = GetReplacementHigh(node);
777 for (int i = 0; i < node->op()->ValueInputCount(); i++) {
778 low_node->ReplaceInput(i, GetReplacementLow(node->InputAt(i)));
779 high_node->ReplaceInput(i, GetReplacementHigh(node->InputAt(i)));
782 DefaultLowering(node);
787 Node* call = node->InputAt(0);
799 Node* input = node->InputAt(0);
800 ReplaceNode(node, graph()->NewNode(machine()->Word32ReverseBytes().op(),
807 default: { DefaultLowering(node); }
811 void Int64Lowering::LowerComparison(Node* node, const Operator* high_word_op,
813 DCHECK(node
814 Node* left = node->InputAt(0);
815 Node* right = node->InputAt(1);
816 Node* replacement = graph()->NewNode(
827 ReplaceNode(node, replacement, nullptr);
830 bool Int64Lowering::DefaultLowering(Node* node, bool low_word_only) {
832 for (int i = NodeProperties::PastValueIndex(node) - 1; i >= 0; i--) {
833 Node* input = node->InputAt(i);
836 node->ReplaceInput(i, GetReplacementLow(input));
840 node->InsertInput(zone(), i + 1, GetReplacementHigh(input));
846 void Int64Lowering::ReplaceNode(Node* old, Node* new_low, Node* new_high) {
853 bool Int64Lowering::HasReplacementLow(Node* node) {
854 return replacements_[node->id()].low != nullptr;
857 Node* Int64Lowering::GetReplacementLow(Node* node) {
858 Node* result = replacements_[node->id()].low;
863 bool Int64Lowering::HasReplacementHigh(Node* node) {
864 return replacements_[node->id()].high != nullptr;
867 Node* Int64Lowering::GetReplacementHigh(Node* node) {
868 Node* result = replacements_[node->id()].high;
873 void Int64Lowering::PreparePhiReplacement(Node* phi) {
876 // We have to create the replacements for a phi node before we actually
878 // input nodes do not exist yet, so we use a placeholder node to pass the
881 Node** inputs_low = zone()->NewArray<Node*>(value_count + 1);
882 Node** inputs_high = zone()->NewArray<Node*>(value_count + 1);