Lines Matching defs:node
18 #include "src/compiler/node.h"
31 explicit NodeMatcher(Node* node) : node_(node) {}
33 Node* node() const { return node_; }
34 const Operator* op() const { return node()->op(); }
35 IrOpcode::Value opcode() const { return node()->opcode(); }
40 Node* InputAt(int index) const { return node()->InputAt(index); }
42 bool Equals(const Node* node) const { return node_ == node; }
55 inline Node* SkipValueIdentities(Node* node) {
61 if (node->opcode() == IrOpcode::kFoldConstant) {
66 } while (NodeProperties::IsValueIdentity(node, &node));
67 DCHECK_NOT_NULL(node);
68 return node;
73 // Note that value identities on the input node are skipped when matching. The
74 // resolved value may not be a parameter of the input node. The node() method
75 // returns the unmodified input node. This is by design, as reducers may wish to
76 // match value constants but delay reducing the node until a later phase. For
83 explicit ValueMatcher(Node* node)
84 : NodeMatcher(node), resolved_value_(), has_resolved_value_(false) {
85 node = SkipValueIdentities(node);
86 has_resolved_value_ = node->opcode() == kOpcode;
88 resolved_value_ = OpParameter<T>(node->op());
105 Node* node)
106 : NodeMatcher(node), resolved_value_(), has_resolved_value_(false) {
107 node = SkipValueIdentities(node);
108 has_resolved_value_ = node->opcode() == IrOpcode::kInt32Constant;
110 resolved_value_ = static_cast<uint32_t>(OpParameter<int32_t>(node->op()));
115 inline ValueMatcher<int64_t, IrOpcode::kInt64Constant>::ValueMatcher(Node* node)
116 : NodeMatcher(node), resolved_value_(), has_resolved_value_(false) {
117 node = SkipValueIdentities(node);
118 if (node->opcode() == IrOpcode::kInt32Constant) {
119 resolved_value_ = OpParameter<int32_t>(node->op());
121 } else if (node->opcode() == IrOpcode::kInt64Constant) {
122 resolved_value_ = OpParameter<int64_t>(node->op());
129 Node* node)
130 : NodeMatcher(node), resolved_value_(), has_resolved_value_(false) {
131 node = SkipValueIdentities(node);
132 if (node->opcode() == IrOpcode::kInt32Constant) {
133 resolved_value_ = static_cast<uint32_t>(OpParameter<int32_t>(node->op()));
135 } else if (node->opcode() == IrOpcode::kInt64Constant) {
136 resolved_value_ = static_cast<uint64_t>(OpParameter<int64_t>(node->op()));
144 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
188 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
233 explicit HeapObjectMatcherImpl(Node* node)
234 : ValueMatcher<Handle<HeapObject>, kHeapConstantOpcode>(node) {}
260 explicit ExternalReferenceMatcher(Node* node)
261 : ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {}
272 explicit LoadMatcher(Node* node)
273 : NodeMatcher(node), object_(InputAt(0)), index_(InputAt(1)) {}
291 explicit BinopMatcher(Node* node)
292 : NodeMatcher(node), left_(InputAt(0)), right_(InputAt(1)) {
295 BinopMatcher(Node* node, bool allow_input_swap)
296 : NodeMatcher(node), left_(InputAt(0)), right_(InputAt(1)) {
309 bool LeftEqualsRight() const { return left().node() == right().node(); }
313 if (use != node()) {
326 node()->ReplaceInput(0, left().node());
327 node()->ReplaceInput(1, right().node());
358 explicit ScaleMatcher(Node* node, bool allow_power_of_two_plus_one = false)
360 if (node->InputCount() < 2) return;
361 BinopMatcher m(node);
362 if (node->opcode() == kShiftOpcode) {
370 } else if (node->opcode() == kMulOpcode) {
420 AddMatcher(Node* node, bool allow_input_swap)
421 : BinopMatcher(node, allow_input_swap),
424 Initialize(node, allow_input_swap);
426 explicit AddMatcher(Node* node)
427 : BinopMatcher(node, node->op()->HasProperty(Operator::kCommutative)),
430 Initialize(node, node->op()->HasProperty(Operator::kCommutative));
436 return this->left().node()->InputAt(0);
445 void Initialize(Node* node, bool allow_input_swap) {
446 Matcher left_matcher(this->left().node(), true);
457 Matcher right_matcher(this->right().node(), true);
498 BaseWithIndexAndDisplacementMatcher(Node* node, AddressOptions options)
505 Initialize(node, options);
508 explicit BaseWithIndexAndDisplacementMatcher(Node* node)
515 Initialize(node, AddressOption::kAllowScale |
516 (node->op()->HasProperty(Operator::kCommutative)
536 void Initialize(Node* node, AddressOptions options) {
539 // enumerating all possible patterns by brute force, checking for node
553 if (node->InputCount() < 2) return;
554 AddMatcher m(node, options & AddressOption::kAllowInputSwap);
555 Node* left = m.left().node();
556 Node* right = m.right().node();
575 base = right_matcher.left().node();
576 displacement = right_matcher.right().node();
587 base = right_matcher.left().node();
588 displacement = right_matcher.right().node();
606 Node* left_left = left_matcher.left().node();
607 Node* left_right = left_matcher.right().node();
633 Node* left_left = left_matcher.left().node();
634 Node* left_right = left_matcher.right().node();
646 if (left->OwnedBy(node)) {
671 if (left->OwnedBy(node)) {
743 // Warning: When {node} is used by a Add/Sub instruction, this function does
745 static bool OwnedByAddressingOperand(Node* node) {
746 for (auto use : node->use_edges()) {
768 // If the stored value is this node, it is not an addressing use.
769 if (from->InputAt(2) == node) return false;
791 Node* Branch() const { return node(); }
806 return if_true_->OwnedBy(node()) && if_false_->OwnedBy(node());
812 Node* Merge() const { return node(); }
836 explicit LoadTransformMatcher(Node* node) : ValueMatcher(node) {}