2014-10-20 11:26:23 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "test/unittests/compiler/node-test-utils.h"
|
|
|
|
|
2015-04-23 09:04:37 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-12-23 12:50:43 +00:00
|
|
|
#include "src/assembler.h"
|
2015-07-23 14:21:26 +00:00
|
|
|
#include "src/compiler/common-operator.h"
|
2015-06-02 09:37:49 +00:00
|
|
|
#include "src/compiler/js-operator.h"
|
2015-01-29 09:17:45 +00:00
|
|
|
#include "src/compiler/node-properties.h"
|
2014-10-20 11:26:23 +00:00
|
|
|
#include "src/compiler/simplified-operator.h"
|
2015-09-01 10:30:40 +00:00
|
|
|
#include "src/handles-inl.h"
|
2017-01-09 13:43:28 +00:00
|
|
|
#include "src/objects-inl.h"
|
2015-11-17 15:06:41 +00:00
|
|
|
#include "src/objects.h"
|
2014-10-20 11:26:23 +00:00
|
|
|
|
|
|
|
using testing::_;
|
|
|
|
using testing::MakeMatcher;
|
|
|
|
using testing::MatcherInterface;
|
|
|
|
using testing::MatchResultListener;
|
|
|
|
using testing::StringMatchResultListener;
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2015-08-31 08:24:52 +00:00
|
|
|
|
|
|
|
bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
|
|
|
|
return lhs.is_identical_to(rhs);
|
|
|
|
}
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
namespace compiler {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
template <typename T>
|
2015-04-23 09:04:37 +00:00
|
|
|
bool PrintMatchAndExplain(const T& value, const std::string& value_name,
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<T>& value_matcher,
|
|
|
|
MatchResultListener* listener) {
|
|
|
|
StringMatchResultListener value_listener;
|
|
|
|
if (!value_matcher.MatchAndExplain(value, &value_listener)) {
|
|
|
|
*listener << "whose " << value_name << " " << value << " doesn't match";
|
|
|
|
if (value_listener.str() != "") {
|
|
|
|
*listener << ", " << value_listener.str();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class TestNodeMatcher : public MatcherInterface<Node*> {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2017-09-28 17:55:52 +00:00
|
|
|
explicit TestNodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const override {
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
|
|
|
|
}
|
|
|
|
|
2014-12-22 13:47:54 +00:00
|
|
|
bool MatchAndExplain(Node* node,
|
2015-04-20 13:08:11 +00:00
|
|
|
MatchResultListener* listener) const override {
|
2014-10-20 11:26:23 +00:00
|
|
|
if (node == NULL) {
|
|
|
|
*listener << "which is NULL";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (node->opcode() != opcode_) {
|
|
|
|
*listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
|
|
|
|
<< " but should have been " << IrOpcode::Mnemonic(opcode_);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const IrOpcode::Value opcode_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsBranchMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsBranchMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kBranch),
|
2014-10-20 11:26:23 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsSwitchMatcher final : public TestNodeMatcher {
|
2015-02-17 13:29:31 +00:00
|
|
|
public:
|
|
|
|
IsSwitchMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kSwitch),
|
2015-02-17 13:29:31 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-02-17 13:29:31 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-02-17 13:29:31 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsIfValueMatcher final : public TestNodeMatcher {
|
2015-02-17 13:29:31 +00:00
|
|
|
public:
|
2018-03-02 10:54:30 +00:00
|
|
|
IsIfValueMatcher(const Matcher<IfValueParameters>& value_matcher,
|
2015-02-17 13:29:31 +00:00
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kIfValue),
|
2015-02-17 13:29:31 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-02-17 13:29:31 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-02 10:54:30 +00:00
|
|
|
PrintMatchAndExplain(IfValueParametersOf(node->op()), "value",
|
2015-02-17 13:29:31 +00:00
|
|
|
value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-03-02 10:54:30 +00:00
|
|
|
const Matcher<IfValueParameters> value_matcher_;
|
2015-02-17 13:29:31 +00:00
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsControl1Matcher final : public TestNodeMatcher {
|
2015-01-20 09:45:02 +00:00
|
|
|
public:
|
|
|
|
IsControl1Matcher(IrOpcode::Value opcode,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode), control_matcher_(control_matcher) {}
|
2015-01-20 09:45:02 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-01-20 09:45:02 +00:00
|
|
|
*os << " whose control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-01-20 09:45:02 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsControl2Matcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2015-01-20 09:45:02 +00:00
|
|
|
IsControl2Matcher(IrOpcode::Value opcode,
|
|
|
|
const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2014-10-20 11:26:23 +00:00
|
|
|
control0_matcher_(control0_matcher),
|
|
|
|
control1_matcher_(control1_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose control0 (";
|
|
|
|
control0_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control1 (";
|
|
|
|
control1_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
|
|
|
|
"control0", control0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
|
|
|
|
"control1", control1_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> control0_matcher_;
|
|
|
|
const Matcher<Node*> control1_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsControl3Matcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2015-01-20 09:45:02 +00:00
|
|
|
IsControl3Matcher(IrOpcode::Value opcode,
|
|
|
|
const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher,
|
|
|
|
const Matcher<Node*>& control2_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2015-01-20 09:45:02 +00:00
|
|
|
control0_matcher_(control0_matcher),
|
|
|
|
control1_matcher_(control1_matcher),
|
|
|
|
control2_matcher_(control2_matcher) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-01-20 09:45:02 +00:00
|
|
|
*os << " whose control0 (";
|
|
|
|
control0_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control1 (";
|
|
|
|
control1_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control2 (";
|
|
|
|
control2_matcher_.DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-01-20 09:45:02 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
|
|
|
|
"control0", control0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
|
|
|
|
"control1", control1_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 2),
|
|
|
|
"control2", control2_matcher_, listener));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-01-20 09:45:02 +00:00
|
|
|
const Matcher<Node*> control0_matcher_;
|
|
|
|
const Matcher<Node*> control1_matcher_;
|
|
|
|
const Matcher<Node*> control2_matcher_;
|
2014-10-20 11:26:23 +00:00
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsBeginRegionMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2015-10-14 14:53:04 +00:00
|
|
|
explicit IsBeginRegionMatcher(const Matcher<Node*>& effect_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kBeginRegion),
|
|
|
|
effect_matcher_(effect_matcher) {}
|
2015-10-14 14:53:04 +00:00
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-10-14 14:53:04 +00:00
|
|
|
*os << " whose effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-10-14 14:53:04 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsFinishRegionMatcher final : public TestNodeMatcher {
|
2015-10-14 14:53:04 +00:00
|
|
|
public:
|
|
|
|
IsFinishRegionMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kFinishRegion),
|
2014-10-20 11:26:23 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
effect_matcher_(effect_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsReturnMatcher final : public TestNodeMatcher {
|
2015-01-20 09:45:02 +00:00
|
|
|
public:
|
|
|
|
IsReturnMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kReturn),
|
2015-01-20 09:45:02 +00:00
|
|
|
value_matcher_(value_matcher),
|
2016-02-23 15:33:06 +00:00
|
|
|
value2_matcher_(_),
|
2015-01-20 09:45:02 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
2016-02-23 15:33:06 +00:00
|
|
|
control_matcher_(control_matcher),
|
|
|
|
has_second_return_value_(false) {}
|
|
|
|
|
|
|
|
IsReturnMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kReturn),
|
2016-02-23 15:33:06 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
value2_matcher_(value2_matcher),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher),
|
|
|
|
has_second_return_value_(true) {}
|
2015-01-20 09:45:02 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-01-20 09:45:02 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
2016-02-23 15:33:06 +00:00
|
|
|
if (has_second_return_value_) {
|
|
|
|
*os << ") and second value (";
|
|
|
|
value2_matcher_.DescribeTo(os);
|
|
|
|
}
|
2015-01-20 09:45:02 +00:00
|
|
|
*os << ") and effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2016-11-02 13:15:39 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
2015-01-20 09:45:02 +00:00
|
|
|
"value", value_matcher_, listener) &&
|
2016-02-23 15:33:06 +00:00
|
|
|
(!has_second_return_value_ ||
|
2016-11-02 13:15:39 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
|
2016-02-23 15:33:06 +00:00
|
|
|
"value2", value2_matcher_, listener)) &&
|
2015-01-20 09:45:02 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> value_matcher_;
|
2016-02-23 15:33:06 +00:00
|
|
|
const Matcher<Node*> value2_matcher_;
|
2015-01-20 09:45:02 +00:00
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
2016-02-23 15:33:06 +00:00
|
|
|
bool has_second_return_value_;
|
2015-01-20 09:45:02 +00:00
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsTerminateMatcher final : public TestNodeMatcher {
|
2015-05-06 12:51:41 +00:00
|
|
|
public:
|
|
|
|
IsTerminateMatcher(const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kTerminate),
|
2015-05-06 12:51:41 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-05-06 12:51:41 +00:00
|
|
|
*os << " whose effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-05-06 12:51:41 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsTypeGuardMatcher final : public TestNodeMatcher {
|
2016-08-31 05:48:05 +00:00
|
|
|
public:
|
|
|
|
IsTypeGuardMatcher(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kTypeGuard),
|
2016-08-31 05:48:05 +00:00
|
|
|
value_matcher_(value_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2016-08-31 05:48:05 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2016-08-31 05:48:05 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
2015-05-06 12:51:41 +00:00
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
template <typename T>
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsConstantMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode), value_matcher_(value_matcher) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-05 08:41:11 +00:00
|
|
|
PrintMatchAndExplain(OpParameter<T>(node->op()), "value",
|
|
|
|
value_matcher_, listener));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<T> value_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsSelectMatcher final : public TestNodeMatcher {
|
2014-10-29 14:16:32 +00:00
|
|
|
public:
|
2015-12-10 09:03:30 +00:00
|
|
|
IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher,
|
2014-10-29 14:16:32 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kSelect),
|
2014-10-29 14:16:32 +00:00
|
|
|
type_matcher_(type_matcher),
|
|
|
|
value0_matcher_(value0_matcher),
|
|
|
|
value1_matcher_(value1_matcher),
|
|
|
|
value2_matcher_(value2_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-12-10 09:03:30 +00:00
|
|
|
*os << " whose representation (";
|
2014-10-29 14:16:32 +00:00
|
|
|
type_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value0 (";
|
|
|
|
value0_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value1 (";
|
|
|
|
value1_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and value2 (";
|
|
|
|
value2_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2015-12-10 09:03:30 +00:00
|
|
|
return (
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-12-10 09:03:30 +00:00
|
|
|
PrintMatchAndExplain(SelectParametersOf(node->op()).representation(),
|
|
|
|
"representation", type_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0",
|
|
|
|
value0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value1",
|
|
|
|
value1_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "value2",
|
|
|
|
value2_matcher_, listener));
|
2014-10-29 14:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-12-10 09:03:30 +00:00
|
|
|
const Matcher<MachineRepresentation> type_matcher_;
|
2014-10-29 14:16:32 +00:00
|
|
|
const Matcher<Node*> value0_matcher_;
|
|
|
|
const Matcher<Node*> value1_matcher_;
|
|
|
|
const Matcher<Node*> value2_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsPhiMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2015-12-10 09:03:30 +00:00
|
|
|
IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher,
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kPhi),
|
2014-10-20 11:26:23 +00:00
|
|
|
type_matcher_(type_matcher),
|
|
|
|
value0_matcher_(value0_matcher),
|
|
|
|
value1_matcher_(value1_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-12-10 09:03:30 +00:00
|
|
|
*os << " whose representation (";
|
2014-10-20 11:26:23 +00:00
|
|
|
type_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value0 (";
|
|
|
|
value0_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value1 (";
|
|
|
|
value1_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-12-10 09:03:30 +00:00
|
|
|
PrintMatchAndExplain(PhiRepresentationOf(node->op()),
|
|
|
|
"representation", type_matcher_, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value0", value0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
|
|
|
"value1", value1_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-12-10 09:03:30 +00:00
|
|
|
const Matcher<MachineRepresentation> type_matcher_;
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*> value0_matcher_;
|
|
|
|
const Matcher<Node*> value1_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsPhi2Matcher final : public TestNodeMatcher {
|
2015-01-20 09:45:02 +00:00
|
|
|
public:
|
2015-12-10 09:03:30 +00:00
|
|
|
IsPhi2Matcher(const Matcher<MachineRepresentation>& type_matcher,
|
2015-01-20 09:45:02 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kPhi),
|
2015-01-20 09:45:02 +00:00
|
|
|
type_matcher_(type_matcher),
|
|
|
|
value0_matcher_(value0_matcher),
|
|
|
|
value1_matcher_(value1_matcher),
|
|
|
|
value2_matcher_(value2_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-12-10 09:03:30 +00:00
|
|
|
*os << " whose representation (";
|
2015-01-20 09:45:02 +00:00
|
|
|
type_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value0 (";
|
|
|
|
value0_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value1 (";
|
|
|
|
value1_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value2 (";
|
|
|
|
value2_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-12-10 09:03:30 +00:00
|
|
|
PrintMatchAndExplain(PhiRepresentationOf(node->op()),
|
|
|
|
"representation", type_matcher_, listener) &&
|
2015-01-20 09:45:02 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"value0", value0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
|
|
|
"value1", value1_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
|
|
|
|
"value2", value2_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-12-10 09:03:30 +00:00
|
|
|
const Matcher<MachineRepresentation> type_matcher_;
|
2015-01-20 09:45:02 +00:00
|
|
|
const Matcher<Node*> value0_matcher_;
|
|
|
|
const Matcher<Node*> value1_matcher_;
|
|
|
|
const Matcher<Node*> value2_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsEffectPhiMatcher final : public TestNodeMatcher {
|
2014-11-04 14:37:22 +00:00
|
|
|
public:
|
|
|
|
IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher,
|
|
|
|
const Matcher<Node*>& effect1_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kEffectPhi),
|
2014-11-04 14:37:22 +00:00
|
|
|
effect0_matcher_(effect0_matcher),
|
|
|
|
effect1_matcher_(effect1_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-11-04 14:37:22 +00:00
|
|
|
*os << "), effect0 (";
|
|
|
|
effect0_matcher_.DescribeTo(os);
|
|
|
|
*os << "), effect1 (";
|
|
|
|
effect1_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-11-04 14:37:22 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0),
|
|
|
|
"effect0", effect0_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1),
|
|
|
|
"effect1", effect1_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> effect0_matcher_;
|
|
|
|
const Matcher<Node*> effect1_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsProjectionMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsProjectionMatcher(const Matcher<size_t>& index_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kProjection),
|
2014-10-20 11:26:23 +00:00
|
|
|
index_matcher_(index_matcher),
|
|
|
|
base_matcher_(base_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose index (";
|
|
|
|
index_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and base (";
|
|
|
|
base_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-05 08:41:11 +00:00
|
|
|
PrintMatchAndExplain(OpParameter<size_t>(node->op()), "index",
|
2014-10-20 11:26:23 +00:00
|
|
|
index_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<size_t> index_matcher_;
|
|
|
|
const Matcher<Node*> base_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsCallMatcher final : public TestNodeMatcher {
|
2014-11-04 12:58:17 +00:00
|
|
|
public:
|
2015-09-02 04:55:07 +00:00
|
|
|
IsCallMatcher(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2015-04-23 09:04:37 +00:00
|
|
|
const std::vector<Matcher<Node*>>& value_matchers,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kCall),
|
2014-10-20 11:26:23 +00:00
|
|
|
descriptor_matcher_(descriptor_matcher),
|
2015-04-23 09:04:37 +00:00
|
|
|
value_matchers_(value_matchers),
|
2014-10-20 11:26:23 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-04-23 09:04:37 +00:00
|
|
|
for (size_t i = 0; i < value_matchers_.size(); ++i) {
|
|
|
|
if (i == 0) {
|
|
|
|
*os << " whose value0 (";
|
|
|
|
} else {
|
|
|
|
*os << "), value" << i << " (";
|
|
|
|
}
|
|
|
|
value_matchers_[i].DescribeTo(os);
|
|
|
|
}
|
|
|
|
*os << "), effect (";
|
2014-10-20 11:26:23 +00:00
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
if (!TestNodeMatcher::MatchAndExplain(node, listener) ||
|
2018-03-21 16:21:56 +00:00
|
|
|
!PrintMatchAndExplain(CallDescriptorOf(node->op()), "descriptor",
|
|
|
|
descriptor_matcher_, listener)) {
|
2015-04-23 09:04:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < value_matchers_.size(); ++i) {
|
|
|
|
std::ostringstream ost;
|
|
|
|
ost << "value" << i;
|
|
|
|
if (!PrintMatchAndExplain(
|
|
|
|
NodeProperties::GetValueInput(node, static_cast<int>(i)),
|
|
|
|
ost.str(), value_matchers_[i], listener)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-12-10 13:36:20 +00:00
|
|
|
Node* effect_node = nullptr;
|
|
|
|
Node* control_node = nullptr;
|
|
|
|
if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
|
|
|
|
effect_node = NodeProperties::GetEffectInput(node);
|
|
|
|
}
|
|
|
|
if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
|
|
|
|
control_node = NodeProperties::GetControlInput(node);
|
|
|
|
}
|
|
|
|
return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
|
|
|
|
listener) &&
|
|
|
|
PrintMatchAndExplain(control_node, "control", control_matcher_,
|
|
|
|
listener));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-02 04:55:07 +00:00
|
|
|
const Matcher<const CallDescriptor*> descriptor_matcher_;
|
2015-04-23 09:04:37 +00:00
|
|
|
const std::vector<Matcher<Node*>> value_matchers_;
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsTailCallMatcher final : public TestNodeMatcher {
|
2015-05-05 09:42:59 +00:00
|
|
|
public:
|
|
|
|
IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const std::vector<Matcher<Node*>>& value_matchers,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kTailCall),
|
2015-05-05 09:42:59 +00:00
|
|
|
descriptor_matcher_(descriptor_matcher),
|
|
|
|
value_matchers_(value_matchers),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-05-05 09:42:59 +00:00
|
|
|
for (size_t i = 0; i < value_matchers_.size(); ++i) {
|
|
|
|
if (i == 0) {
|
|
|
|
*os << " whose value0 (";
|
|
|
|
} else {
|
|
|
|
*os << "), value" << i << " (";
|
|
|
|
}
|
|
|
|
value_matchers_[i].DescribeTo(os);
|
|
|
|
}
|
|
|
|
*os << "), effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
if (!TestNodeMatcher::MatchAndExplain(node, listener) ||
|
2018-03-21 16:21:56 +00:00
|
|
|
!PrintMatchAndExplain(CallDescriptorOf(node->op()), "descriptor",
|
|
|
|
descriptor_matcher_, listener)) {
|
2015-05-05 09:42:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < value_matchers_.size(); ++i) {
|
|
|
|
std::ostringstream ost;
|
|
|
|
ost << "value" << i;
|
|
|
|
if (!PrintMatchAndExplain(
|
|
|
|
NodeProperties::GetValueInput(node, static_cast<int>(i)),
|
|
|
|
ost.str(), value_matchers_[i], listener)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-12-10 13:36:20 +00:00
|
|
|
Node* effect_node = nullptr;
|
|
|
|
Node* control_node = nullptr;
|
|
|
|
if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
|
|
|
|
effect_node = NodeProperties::GetEffectInput(node);
|
|
|
|
}
|
|
|
|
if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
|
|
|
|
control_node = NodeProperties::GetControlInput(node);
|
|
|
|
}
|
|
|
|
return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
|
|
|
|
listener) &&
|
|
|
|
PrintMatchAndExplain(control_node, "control", control_matcher_,
|
|
|
|
listener));
|
2015-05-05 09:42:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<CallDescriptor const*> descriptor_matcher_;
|
|
|
|
const std::vector<Matcher<Node*>> value_matchers_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsSpeculativeBinopMatcher final : public TestNodeMatcher {
|
2016-06-02 09:20:50 +00:00
|
|
|
public:
|
2016-08-08 06:07:21 +00:00
|
|
|
IsSpeculativeBinopMatcher(IrOpcode::Value opcode,
|
|
|
|
const Matcher<NumberOperationHint>& hint_matcher,
|
|
|
|
const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2016-07-29 11:03:57 +00:00
|
|
|
hint_matcher_(hint_matcher),
|
2016-06-02 09:20:50 +00:00
|
|
|
lhs_matcher_(lhs_matcher),
|
|
|
|
rhs_matcher_(rhs_matcher),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2016-06-02 09:20:50 +00:00
|
|
|
// TODO(bmeurer): The type parameter is currently ignored.
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(NumberOperationHintOf(node->op()), "hints",
|
|
|
|
hint_matcher_, listener) &&
|
2016-06-02 09:20:50 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
|
|
|
|
lhs_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
|
|
|
|
rhs_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-08-08 06:07:21 +00:00
|
|
|
const Matcher<NumberOperationHint> hint_matcher_;
|
2016-06-02 09:20:50 +00:00
|
|
|
const Matcher<Type*> type_matcher_;
|
|
|
|
const Matcher<Node*> lhs_matcher_;
|
|
|
|
const Matcher<Node*> rhs_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
2015-05-27 04:23:29 +00:00
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsAllocateMatcher final : public TestNodeMatcher {
|
2015-05-04 12:07:12 +00:00
|
|
|
public:
|
|
|
|
IsAllocateMatcher(const Matcher<Node*>& size_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kAllocate),
|
2015-05-04 12:07:12 +00:00
|
|
|
size_matcher_(size_matcher),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-05-04 12:07:12 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "size",
|
|
|
|
size_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> size_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsLoadFieldMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
2014-10-28 08:33:52 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kLoadField),
|
2014-10-20 11:26:23 +00:00
|
|
|
access_matcher_(access_matcher),
|
|
|
|
base_matcher_(base_matcher),
|
2014-10-28 08:33:52 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose access (";
|
|
|
|
access_matcher_.DescribeTo(os);
|
|
|
|
*os << "), base (";
|
|
|
|
base_matcher_.DescribeTo(os);
|
2014-10-28 08:33:52 +00:00
|
|
|
*os << "), effect (";
|
2014-10-20 11:26:23 +00:00
|
|
|
effect_matcher_.DescribeTo(os);
|
2014-10-28 08:33:52 +00:00
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(FieldAccessOf(node->op()), "access",
|
2014-10-20 11:26:23 +00:00
|
|
|
access_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
2014-10-28 08:33:52 +00:00
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<FieldAccess> access_matcher_;
|
|
|
|
const Matcher<Node*> base_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
2014-10-28 08:33:52 +00:00
|
|
|
const Matcher<Node*> control_matcher_;
|
2014-10-20 11:26:23 +00:00
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsStoreFieldMatcher final : public TestNodeMatcher {
|
2014-12-04 10:50:43 +00:00
|
|
|
public:
|
|
|
|
IsStoreFieldMatcher(const Matcher<FieldAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kStoreField),
|
2014-12-04 10:50:43 +00:00
|
|
|
access_matcher_(access_matcher),
|
|
|
|
base_matcher_(base_matcher),
|
|
|
|
value_matcher_(value_matcher),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-12-04 10:50:43 +00:00
|
|
|
*os << " whose access (";
|
|
|
|
access_matcher_.DescribeTo(os);
|
|
|
|
*os << "), base (";
|
|
|
|
base_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << "), effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(FieldAccessOf(node->op()), "access",
|
2014-12-04 10:50:43 +00:00
|
|
|
access_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<FieldAccess> access_matcher_;
|
|
|
|
const Matcher<Node*> base_matcher_;
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsLoadElementMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
2014-12-02 04:48:57 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kLoadElement),
|
2014-10-20 11:26:23 +00:00
|
|
|
access_matcher_(access_matcher),
|
|
|
|
base_matcher_(base_matcher),
|
|
|
|
index_matcher_(index_matcher),
|
2014-12-02 04:48:57 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose access (";
|
|
|
|
access_matcher_.DescribeTo(os);
|
|
|
|
*os << "), base (";
|
|
|
|
base_matcher_.DescribeTo(os);
|
|
|
|
*os << "), index (";
|
|
|
|
index_matcher_.DescribeTo(os);
|
2014-12-02 04:48:57 +00:00
|
|
|
*os << "), effect (";
|
2014-10-20 11:26:23 +00:00
|
|
|
effect_matcher_.DescribeTo(os);
|
2014-12-02 04:48:57 +00:00
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(ElementAccessOf(node->op()), "access",
|
|
|
|
access_matcher_, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
|
|
|
"index", index_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
2014-12-02 04:48:57 +00:00
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<ElementAccess> access_matcher_;
|
|
|
|
const Matcher<Node*> base_matcher_;
|
|
|
|
const Matcher<Node*> index_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
2014-12-02 04:48:57 +00:00
|
|
|
const Matcher<Node*> control_matcher_;
|
2014-10-20 11:26:23 +00:00
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsStoreElementMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kStoreElement),
|
2014-10-20 11:26:23 +00:00
|
|
|
access_matcher_(access_matcher),
|
|
|
|
base_matcher_(base_matcher),
|
|
|
|
index_matcher_(index_matcher),
|
|
|
|
value_matcher_(value_matcher),
|
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose access (";
|
|
|
|
access_matcher_.DescribeTo(os);
|
|
|
|
*os << "), base (";
|
|
|
|
base_matcher_.DescribeTo(os);
|
|
|
|
*os << "), index (";
|
|
|
|
index_matcher_.DescribeTo(os);
|
|
|
|
*os << "), value (";
|
|
|
|
value_matcher_.DescribeTo(os);
|
|
|
|
*os << "), effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(ElementAccessOf(node->op()), "access",
|
|
|
|
access_matcher_, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
|
|
|
|
"index", index_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
|
|
|
|
"value", value_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<ElementAccess> access_matcher_;
|
|
|
|
const Matcher<Node*> base_matcher_;
|
|
|
|
const Matcher<Node*> index_matcher_;
|
|
|
|
const Matcher<Node*> value_matcher_;
|
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2018-03-21 16:21:56 +00:00
|
|
|
#define LOAD_MATCHER(kLoad) \
|
|
|
|
class Is##kLoad##Matcher final : public TestNodeMatcher { \
|
|
|
|
public: \
|
|
|
|
Is##kLoad##Matcher(const Matcher<LoadRepresentation>& rep_matcher, \
|
|
|
|
const Matcher<Node*>& base_matcher, \
|
|
|
|
const Matcher<Node*>& index_matcher, \
|
|
|
|
const Matcher<Node*>& effect_matcher, \
|
|
|
|
const Matcher<Node*>& control_matcher) \
|
|
|
|
: TestNodeMatcher(IrOpcode::k##kLoad), \
|
|
|
|
rep_matcher_(rep_matcher), \
|
|
|
|
base_matcher_(base_matcher), \
|
|
|
|
index_matcher_(index_matcher), \
|
|
|
|
effect_matcher_(effect_matcher), \
|
|
|
|
control_matcher_(control_matcher) {} \
|
|
|
|
\
|
|
|
|
void DescribeTo(std::ostream* os) const final { \
|
|
|
|
TestNodeMatcher::DescribeTo(os); \
|
|
|
|
*os << " whose rep ("; \
|
|
|
|
rep_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), base ("; \
|
|
|
|
base_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), index ("; \
|
|
|
|
index_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), effect ("; \
|
|
|
|
effect_matcher_.DescribeTo(os); \
|
|
|
|
*os << ") and control ("; \
|
|
|
|
control_matcher_.DescribeTo(os); \
|
|
|
|
*os << ")"; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
bool MatchAndExplain(Node* node, \
|
|
|
|
MatchResultListener* listener) const final { \
|
|
|
|
Node* effect_node = nullptr; \
|
|
|
|
Node* control_node = nullptr; \
|
|
|
|
if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
|
|
|
|
effect_node = NodeProperties::GetEffectInput(node); \
|
|
|
|
} \
|
|
|
|
if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
|
|
|
|
control_node = NodeProperties::GetControlInput(node); \
|
|
|
|
} \
|
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) && \
|
|
|
|
PrintMatchAndExplain(LoadRepresentationOf(node->op()), "rep", \
|
|
|
|
rep_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
|
|
|
|
"base", base_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
|
|
|
|
"index", index_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
|
|
|
|
listener) && \
|
|
|
|
PrintMatchAndExplain(control_node, "control", control_matcher_, \
|
|
|
|
listener)); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
const Matcher<LoadRepresentation> rep_matcher_; \
|
|
|
|
const Matcher<Node*> base_matcher_; \
|
|
|
|
const Matcher<Node*> index_matcher_; \
|
|
|
|
const Matcher<Node*> effect_matcher_; \
|
|
|
|
const Matcher<Node*> control_matcher_; \
|
2016-07-22 20:55:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
LOAD_MATCHER(Load)
|
|
|
|
LOAD_MATCHER(UnalignedLoad)
|
2018-03-26 15:44:44 +00:00
|
|
|
LOAD_MATCHER(PoisonedLoad)
|
2016-07-22 20:55:03 +00:00
|
|
|
|
|
|
|
#define STORE_MATCHER(kStore) \
|
2017-09-28 17:55:52 +00:00
|
|
|
class Is##kStore##Matcher final : public TestNodeMatcher { \
|
2016-07-22 20:55:03 +00:00
|
|
|
public: \
|
|
|
|
Is##kStore##Matcher(const Matcher<kStore##Representation>& rep_matcher, \
|
|
|
|
const Matcher<Node*>& base_matcher, \
|
|
|
|
const Matcher<Node*>& index_matcher, \
|
|
|
|
const Matcher<Node*>& value_matcher, \
|
|
|
|
const Matcher<Node*>& effect_matcher, \
|
|
|
|
const Matcher<Node*>& control_matcher) \
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::k##kStore), \
|
2016-07-22 20:55:03 +00:00
|
|
|
rep_matcher_(rep_matcher), \
|
|
|
|
base_matcher_(base_matcher), \
|
|
|
|
index_matcher_(index_matcher), \
|
|
|
|
value_matcher_(value_matcher), \
|
|
|
|
effect_matcher_(effect_matcher), \
|
|
|
|
control_matcher_(control_matcher) {} \
|
|
|
|
\
|
|
|
|
void DescribeTo(std::ostream* os) const final { \
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os); \
|
2016-07-22 20:55:03 +00:00
|
|
|
*os << " whose rep ("; \
|
|
|
|
rep_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), base ("; \
|
|
|
|
base_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), index ("; \
|
|
|
|
index_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), value ("; \
|
|
|
|
value_matcher_.DescribeTo(os); \
|
|
|
|
*os << "), effect ("; \
|
|
|
|
effect_matcher_.DescribeTo(os); \
|
|
|
|
*os << ") and control ("; \
|
|
|
|
control_matcher_.DescribeTo(os); \
|
|
|
|
*os << ")"; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
bool MatchAndExplain(Node* node, \
|
|
|
|
MatchResultListener* listener) const final { \
|
|
|
|
Node* effect_node = nullptr; \
|
|
|
|
Node* control_node = nullptr; \
|
|
|
|
if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
|
|
|
|
effect_node = NodeProperties::GetEffectInput(node); \
|
|
|
|
} \
|
|
|
|
if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
|
|
|
|
control_node = NodeProperties::GetControlInput(node); \
|
|
|
|
} \
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) && \
|
2018-03-05 08:41:11 +00:00
|
|
|
PrintMatchAndExplain( \
|
|
|
|
OpParameter<kStore##Representation>(node->op()), "rep", \
|
|
|
|
rep_matcher_, listener) && \
|
2016-07-22 20:55:03 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
|
|
|
|
"base", base_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
|
|
|
|
"index", index_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), \
|
|
|
|
"value", value_matcher_, listener) && \
|
|
|
|
PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
|
|
|
|
listener) && \
|
|
|
|
PrintMatchAndExplain(control_node, "control", control_matcher_, \
|
|
|
|
listener)); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
const Matcher<kStore##Representation> rep_matcher_; \
|
|
|
|
const Matcher<Node*> base_matcher_; \
|
|
|
|
const Matcher<Node*> index_matcher_; \
|
|
|
|
const Matcher<Node*> value_matcher_; \
|
|
|
|
const Matcher<Node*> effect_matcher_; \
|
|
|
|
const Matcher<Node*> control_matcher_; \
|
|
|
|
};
|
|
|
|
|
|
|
|
STORE_MATCHER(Store)
|
|
|
|
STORE_MATCHER(UnalignedStore)
|
2014-11-25 08:40:18 +00:00
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsStackSlotMatcher final : public TestNodeMatcher {
|
2016-03-15 12:17:09 +00:00
|
|
|
public:
|
2017-05-16 12:27:56 +00:00
|
|
|
explicit IsStackSlotMatcher(
|
|
|
|
const Matcher<StackSlotRepresentation>& rep_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {}
|
2016-03-15 12:17:09 +00:00
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2017-05-16 12:27:56 +00:00
|
|
|
*os << " whose rep (";
|
|
|
|
rep_matcher_.DescribeTo(os);
|
2016-03-15 12:17:09 +00:00
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2018-03-21 16:21:56 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
|
|
|
PrintMatchAndExplain(StackSlotRepresentationOf(node->op()), "rep",
|
|
|
|
rep_matcher_, listener));
|
2016-03-15 12:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-05-16 12:27:56 +00:00
|
|
|
const Matcher<StackSlotRepresentation> rep_matcher_;
|
2016-03-15 12:17:09 +00:00
|
|
|
};
|
2014-11-25 08:40:18 +00:00
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsToNumberMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
2015-06-02 09:37:49 +00:00
|
|
|
IsToNumberMatcher(const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& context_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kJSToNumber),
|
2014-10-20 11:26:23 +00:00
|
|
|
base_matcher_(base_matcher),
|
2015-06-02 09:37:49 +00:00
|
|
|
context_matcher_(context_matcher),
|
2014-10-20 11:26:23 +00:00
|
|
|
effect_matcher_(effect_matcher),
|
|
|
|
control_matcher_(control_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-06-02 09:37:49 +00:00
|
|
|
*os << " whose base (";
|
2014-10-20 11:26:23 +00:00
|
|
|
base_matcher_.DescribeTo(os);
|
2015-06-02 09:37:49 +00:00
|
|
|
*os << "), context (";
|
|
|
|
context_matcher_.DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << "), effect (";
|
|
|
|
effect_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and control (";
|
|
|
|
control_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
|
|
|
|
base_matcher_, listener) &&
|
2015-06-02 09:37:49 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetContextInput(node),
|
|
|
|
"context", context_matcher_, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
|
|
|
|
effect_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
|
|
|
|
"control", control_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> base_matcher_;
|
2015-06-02 09:37:49 +00:00
|
|
|
const Matcher<Node*> context_matcher_;
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*> effect_matcher_;
|
|
|
|
const Matcher<Node*> control_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsLoadContextMatcher final : public TestNodeMatcher {
|
2015-06-02 09:37:49 +00:00
|
|
|
public:
|
|
|
|
IsLoadContextMatcher(const Matcher<ContextAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& context_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kJSLoadContext),
|
2015-06-02 09:37:49 +00:00
|
|
|
access_matcher_(access_matcher),
|
|
|
|
context_matcher_(context_matcher) {}
|
|
|
|
|
2015-06-08 08:59:00 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2015-06-08 08:59:00 +00:00
|
|
|
*os << " whose access (";
|
|
|
|
access_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and context (";
|
|
|
|
context_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-06-02 09:37:49 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2018-03-21 16:21:56 +00:00
|
|
|
PrintMatchAndExplain(ContextAccessOf(node->op()), "access",
|
|
|
|
access_matcher_, listener) &&
|
2015-06-02 09:37:49 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetContextInput(node),
|
|
|
|
"context", context_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<ContextAccess> access_matcher_;
|
|
|
|
const Matcher<Node*> context_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsQuadopMatcher final : public TestNodeMatcher {
|
2016-03-14 15:33:15 +00:00
|
|
|
public:
|
|
|
|
IsQuadopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& a_matcher,
|
|
|
|
const Matcher<Node*>& b_matcher,
|
|
|
|
const Matcher<Node*>& c_matcher,
|
|
|
|
const Matcher<Node*>& d_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2016-03-14 15:33:15 +00:00
|
|
|
a_matcher_(a_matcher),
|
|
|
|
b_matcher_(b_matcher),
|
|
|
|
c_matcher_(c_matcher),
|
|
|
|
d_matcher_(d_matcher) {}
|
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2016-03-14 15:33:15 +00:00
|
|
|
*os << " whose a (";
|
|
|
|
a_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and b (";
|
|
|
|
b_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and c (";
|
|
|
|
c_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and d (";
|
|
|
|
d_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2016-03-14 15:33:15 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a",
|
|
|
|
a_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b",
|
|
|
|
b_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "c",
|
|
|
|
c_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), "d",
|
|
|
|
d_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> a_matcher_;
|
|
|
|
const Matcher<Node*> b_matcher_;
|
|
|
|
const Matcher<Node*> c_matcher_;
|
|
|
|
const Matcher<Node*> d_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsTernopMatcher final : public TestNodeMatcher {
|
2016-03-07 15:17:54 +00:00
|
|
|
public:
|
|
|
|
IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& mid_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2016-03-07 15:17:54 +00:00
|
|
|
lhs_matcher_(lhs_matcher),
|
|
|
|
mid_matcher_(mid_matcher),
|
|
|
|
rhs_matcher_(rhs_matcher) {}
|
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2016-03-07 15:17:54 +00:00
|
|
|
*os << " whose lhs (";
|
|
|
|
lhs_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and mid (";
|
|
|
|
mid_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and rhs (";
|
|
|
|
rhs_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2016-03-07 15:17:54 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
|
|
|
|
lhs_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid",
|
|
|
|
mid_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "rhs",
|
|
|
|
rhs_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> lhs_matcher_;
|
|
|
|
const Matcher<Node*> mid_matcher_;
|
|
|
|
const Matcher<Node*> rhs_matcher_;
|
|
|
|
};
|
2015-06-02 09:37:49 +00:00
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsBinopMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode),
|
2014-10-20 11:26:23 +00:00
|
|
|
lhs_matcher_(lhs_matcher),
|
|
|
|
rhs_matcher_(rhs_matcher) {}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose lhs (";
|
|
|
|
lhs_matcher_.DescribeTo(os);
|
|
|
|
*os << ") and rhs (";
|
|
|
|
rhs_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
|
|
|
|
lhs_matcher_, listener) &&
|
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
|
|
|
|
rhs_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> lhs_matcher_;
|
|
|
|
const Matcher<Node*> rhs_matcher_;
|
|
|
|
};
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsUnopMatcher final : public TestNodeMatcher {
|
2014-10-20 11:26:23 +00:00
|
|
|
public:
|
|
|
|
IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(opcode), input_matcher_(input_matcher) {}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
void DescribeTo(std::ostream* os) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
TestNodeMatcher::DescribeTo(os);
|
2014-10-20 11:26:23 +00:00
|
|
|
*os << " whose input (";
|
|
|
|
input_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2014-10-20 11:26:23 +00:00
|
|
|
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
|
|
|
|
"input", input_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<Node*> input_matcher_;
|
|
|
|
};
|
2015-01-27 14:02:21 +00:00
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
class IsParameterMatcher final : public TestNodeMatcher {
|
2015-07-23 14:21:26 +00:00
|
|
|
public:
|
|
|
|
explicit IsParameterMatcher(const Matcher<int>& index_matcher)
|
2017-09-28 17:55:52 +00:00
|
|
|
: TestNodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {}
|
2015-07-23 14:21:26 +00:00
|
|
|
|
|
|
|
void DescribeTo(std::ostream* os) const override {
|
|
|
|
*os << "is a Parameter node with index(";
|
|
|
|
index_matcher_.DescribeTo(os);
|
|
|
|
*os << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
|
2017-09-28 17:55:52 +00:00
|
|
|
return (TestNodeMatcher::MatchAndExplain(node, listener) &&
|
2015-07-23 14:21:26 +00:00
|
|
|
PrintMatchAndExplain(ParameterIndexOf(node->op()), "index",
|
|
|
|
index_matcher_, listener));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Matcher<int> index_matcher_;
|
|
|
|
};
|
|
|
|
|
2015-01-27 14:02:21 +00:00
|
|
|
} // namespace
|
|
|
|
|
[turbofan] Proper dead code elimination as regular reducer.
The three different concerns that the ControlReducer used to deal with
are now properly separated into
a.) DeadCodeElimination, which is a regular AdvancedReducer, that
propagates Dead via control edges,
b.) CommonOperatorReducer, which does strength reduction on common
operators (i.e. Branch, Phi, and friends), and
c.) GraphTrimming, which removes dead->live edges from the graph.
This will make it possible to run the DeadCodeElimination together with
other passes that actually introduce Dead nodes, i.e. typed lowering;
and it opens the door for general inlining without two stage fix point
iteration.
To make the DeadCodeElimination easier and more uniform, we basically
reverted the introduction of DeadValue and DeadEffect, and changed the
Dead operator to produce control, value and effect. Note however that
this is not a requirement, but merely a way to make dead propagation
easier and more uniform. We could always go back and decide to have
different Dead operators if some other change requires that.
Note that there are several additional opportunities for cleanup now,
i.e. OSR deconstruction could be a regular reducer now, and we don't
need to use TheHole as dead value marker in the GraphReducer. And we can
actually run the dead code elimination together with the other passes
instead of using separate passes over the graph. We will do this in
follow up CLs.
R=jarin@chromium.org, mstarzinger@chromium.org
Review URL: https://codereview.chromium.org/1193833002
Cr-Commit-Position: refs/heads/master@{#29146}
2015-06-19 12:07:17 +00:00
|
|
|
Matcher<Node*> IsDead() {
|
2017-09-28 17:55:52 +00:00
|
|
|
return MakeMatcher(new TestNodeMatcher(IrOpcode::kDead));
|
[turbofan] Proper dead code elimination as regular reducer.
The three different concerns that the ControlReducer used to deal with
are now properly separated into
a.) DeadCodeElimination, which is a regular AdvancedReducer, that
propagates Dead via control edges,
b.) CommonOperatorReducer, which does strength reduction on common
operators (i.e. Branch, Phi, and friends), and
c.) GraphTrimming, which removes dead->live edges from the graph.
This will make it possible to run the DeadCodeElimination together with
other passes that actually introduce Dead nodes, i.e. typed lowering;
and it opens the door for general inlining without two stage fix point
iteration.
To make the DeadCodeElimination easier and more uniform, we basically
reverted the introduction of DeadValue and DeadEffect, and changed the
Dead operator to produce control, value and effect. Note however that
this is not a requirement, but merely a way to make dead propagation
easier and more uniform. We could always go back and decide to have
different Dead operators if some other change requires that.
Note that there are several additional opportunities for cleanup now,
i.e. OSR deconstruction could be a regular reducer now, and we don't
need to use TheHole as dead value marker in the GraphReducer. And we can
actually run the dead code elimination together with the other passes
instead of using separate passes over the graph. We will do this in
follow up CLs.
R=jarin@chromium.org, mstarzinger@chromium.org
Review URL: https://codereview.chromium.org/1193833002
Cr-Commit-Position: refs/heads/master@{#29146}
2015-06-19 12:07:17 +00:00
|
|
|
}
|
|
|
|
|
2015-05-26 10:31:55 +00:00
|
|
|
Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) {
|
|
|
|
return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher) {
|
|
|
|
return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher,
|
|
|
|
control1_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-26 08:20:53 +00:00
|
|
|
Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher,
|
|
|
|
const Matcher<Node*>& control2_matcher) {
|
|
|
|
return MakeMatcher(new IsControl3Matcher(IrOpcode::kEnd, control0_matcher,
|
|
|
|
control1_matcher, control2_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher) {
|
2015-01-20 09:45:02 +00:00
|
|
|
return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher,
|
|
|
|
control1_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 13:29:31 +00:00
|
|
|
Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher,
|
|
|
|
const Matcher<Node*>& control2_matcher) {
|
|
|
|
return MakeMatcher(new IsControl3Matcher(IrOpcode::kMerge, control0_matcher,
|
|
|
|
control1_matcher, control2_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-20 09:45:02 +00:00
|
|
|
Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher) {
|
|
|
|
return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher,
|
|
|
|
control1_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher,
|
|
|
|
const Matcher<Node*>& control2_matcher) {
|
|
|
|
return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher,
|
|
|
|
control1_matcher, control2_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-03 06:11:37 +00:00
|
|
|
Matcher<Node*> IsIfSuccess(const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsControl1Matcher(IrOpcode::kIfSuccess, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 13:29:31 +00:00
|
|
|
Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2018-03-02 10:54:30 +00:00
|
|
|
Matcher<Node*> IsIfValue(const Matcher<IfValueParameters>& value_matcher,
|
2015-02-17 13:29:31 +00:00
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsControl1Matcher(IrOpcode::kIfDefault, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-14 14:53:04 +00:00
|
|
|
Matcher<Node*> IsBeginRegion(const Matcher<Node*>& effect_matcher) {
|
|
|
|
return MakeMatcher(new IsBeginRegionMatcher(effect_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-14 14:53:04 +00:00
|
|
|
Matcher<Node*> IsFinishRegion(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher) {
|
|
|
|
return MakeMatcher(new IsFinishRegionMatcher(value_matcher, effect_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-20 09:45:02 +00:00
|
|
|
Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsReturnMatcher(value_matcher, effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2016-02-23 15:33:06 +00:00
|
|
|
Matcher<Node*> IsReturn2(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsReturnMatcher(value_matcher, value2_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
2015-01-20 09:45:02 +00:00
|
|
|
|
2015-05-06 12:51:41 +00:00
|
|
|
Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2016-08-31 05:48:05 +00:00
|
|
|
Matcher<Node*> IsTypeGuard(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsTypeGuardMatcher(value_matcher, control_matcher));
|
|
|
|
}
|
2015-05-06 12:51:41 +00:00
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
Matcher<Node*> IsExternalConstant(
|
|
|
|
const Matcher<ExternalReference>& value_matcher) {
|
|
|
|
return MakeMatcher(new IsConstantMatcher<ExternalReference>(
|
|
|
|
IrOpcode::kExternalConstant, value_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-31 08:24:52 +00:00
|
|
|
Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) {
|
|
|
|
return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>(
|
|
|
|
IrOpcode::kHeapConstant, value));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
|
|
|
|
}
|
|
|
|
|
2016-11-11 13:04:08 +00:00
|
|
|
Matcher<Node*> IsPointerConstant(const Matcher<intptr_t>& value_matcher) {
|
|
|
|
return MakeMatcher(new IsConstantMatcher<intptr_t>(IrOpcode::kPointerConstant,
|
|
|
|
value_matcher));
|
|
|
|
}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
Matcher<Node*> IsSelect(const Matcher<MachineRepresentation>& type_matcher,
|
2014-10-29 14:16:32 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher) {
|
|
|
|
return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher,
|
|
|
|
value1_matcher, value2_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& merge_matcher) {
|
|
|
|
return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
|
|
|
|
value1_matcher, merge_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
|
2015-01-20 09:45:02 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& merge_matcher) {
|
|
|
|
return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher,
|
|
|
|
value1_matcher, value2_matcher,
|
|
|
|
merge_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-04 14:37:22 +00:00
|
|
|
Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
|
|
|
|
const Matcher<Node*>& effect1_matcher,
|
|
|
|
const Matcher<Node*>& merge_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher) {
|
|
|
|
return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
|
|
|
|
}
|
|
|
|
|
2016-02-23 15:33:06 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-09-02 04:55:07 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2014-11-04 12:58:17 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
2015-04-23 09:04:37 +00:00
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
2014-11-04 12:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-02 04:55:07 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2015-08-25 11:31:09 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-02 04:55:07 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2015-08-25 11:31:09 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-02 04:55:07 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& value3_matcher,
|
2015-04-23 09:04:37 +00:00
|
|
|
const Matcher<Node*>& value4_matcher,
|
2014-10-20 11:26:23 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
2015-04-23 09:04:37 +00:00
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-02 04:55:07 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2015-04-23 09:04:37 +00:00
|
|
|
const Matcher<Node*>& value0_matcher,
|
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher,
|
|
|
|
const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher,
|
|
|
|
const Matcher<Node*>& value5_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
value_matchers.push_back(value5_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsCall(
|
2015-09-02 04:55:07 +00:00
|
|
|
const Matcher<const CallDescriptor*>& descriptor_matcher,
|
2015-04-23 09:04:37 +00:00
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
|
|
|
|
const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
value_matchers.push_back(value5_matcher);
|
|
|
|
value_matchers.push_back(value6_matcher);
|
|
|
|
return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-05 09:42:59 +00:00
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-23 14:21:26 +00:00
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-30 08:18:23 +00:00
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-18 12:41:41 +00:00
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher, const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
value_matchers.push_back(value5_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-24 10:25:34 +00:00
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
|
|
|
|
const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
value_matchers.push_back(value5_matcher);
|
|
|
|
value_matchers.push_back(value6_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsTailCall(
|
|
|
|
const Matcher<CallDescriptor const*>& descriptor_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
|
|
|
|
const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
|
|
|
|
const Matcher<Node*>& value6_matcher, const Matcher<Node*>& value7_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
std::vector<Matcher<Node*>> value_matchers;
|
|
|
|
value_matchers.push_back(value0_matcher);
|
|
|
|
value_matchers.push_back(value1_matcher);
|
|
|
|
value_matchers.push_back(value2_matcher);
|
|
|
|
value_matchers.push_back(value3_matcher);
|
|
|
|
value_matchers.push_back(value4_matcher);
|
|
|
|
value_matchers.push_back(value5_matcher);
|
|
|
|
value_matchers.push_back(value6_matcher);
|
|
|
|
value_matchers.push_back(value7_matcher);
|
|
|
|
return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2016-08-08 06:07:21 +00:00
|
|
|
#define DEFINE_SPECULATIVE_BINOP_MATCHER(opcode) \
|
|
|
|
Matcher<Node*> Is##opcode(const Matcher<NumberOperationHint>& hint_matcher, \
|
|
|
|
const Matcher<Node*>& lhs_matcher, \
|
|
|
|
const Matcher<Node*>& rhs_matcher, \
|
|
|
|
const Matcher<Node*>& effect_matcher, \
|
|
|
|
const Matcher<Node*>& control_matcher) { \
|
|
|
|
return MakeMatcher(new IsSpeculativeBinopMatcher( \
|
|
|
|
IrOpcode::k##opcode, hint_matcher, lhs_matcher, rhs_matcher, \
|
|
|
|
effect_matcher, control_matcher)); \
|
2016-08-02 13:41:48 +00:00
|
|
|
}
|
|
|
|
SPECULATIVE_BINOPS(DEFINE_SPECULATIVE_BINOP_MATCHER);
|
|
|
|
#undef DEFINE_SPECULATIVE_BINOP_MATCHER
|
2016-07-29 11:03:57 +00:00
|
|
|
|
2015-05-04 12:07:12 +00:00
|
|
|
Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
2014-10-28 08:33:52 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-04 10:50:43 +00:00
|
|
|
Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsStoreFieldMatcher(access_matcher, base_matcher,
|
|
|
|
value_matcher, effect_matcher,
|
|
|
|
control_matcher));
|
|
|
|
}
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
2014-12-02 04:48:57 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
2014-10-20 11:26:23 +00:00
|
|
|
return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
|
2014-12-02 04:48:57 +00:00
|
|
|
index_matcher, effect_matcher,
|
|
|
|
control_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsStoreElementMatcher(
|
2014-12-02 04:48:57 +00:00
|
|
|
access_matcher, base_matcher, index_matcher, value_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
2014-10-20 11:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2018-03-26 15:44:44 +00:00
|
|
|
Matcher<Node*> IsPoisonedLoad(const Matcher<LoadRepresentation>& rep_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsPoisonedLoadMatcher(rep_matcher, base_matcher,
|
|
|
|
index_matcher, effect_matcher,
|
|
|
|
control_matcher));
|
|
|
|
}
|
|
|
|
|
2018-03-08 09:49:00 +00:00
|
|
|
Matcher<Node*> IsUnalignedLoad(const Matcher<LoadRepresentation>& rep_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
2016-07-22 20:55:03 +00:00
|
|
|
return MakeMatcher(new IsUnalignedLoadMatcher(rep_matcher, base_matcher,
|
|
|
|
index_matcher, effect_matcher,
|
|
|
|
control_matcher));
|
|
|
|
}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
|
|
|
Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
|
|
|
|
index_matcher, value_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
2016-07-22 20:55:03 +00:00
|
|
|
Matcher<Node*> IsUnalignedStore(
|
|
|
|
const Matcher<UnalignedStoreRepresentation>& rep_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsUnalignedStoreMatcher(
|
|
|
|
rep_matcher, base_matcher, index_matcher, value_matcher, effect_matcher,
|
|
|
|
control_matcher));
|
|
|
|
}
|
|
|
|
|
2017-05-16 12:27:56 +00:00
|
|
|
Matcher<Node*> IsStackSlot(
|
|
|
|
const Matcher<StackSlotRepresentation>& rep_matcher) {
|
|
|
|
return MakeMatcher(new IsStackSlotMatcher(rep_matcher));
|
2016-03-15 12:17:09 +00:00
|
|
|
}
|
2014-10-20 11:26:23 +00:00
|
|
|
|
2015-06-02 09:37:49 +00:00
|
|
|
Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& context_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher) {
|
|
|
|
return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher,
|
|
|
|
effect_matcher, control_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matcher<Node*> IsLoadContext(const Matcher<ContextAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& context_matcher) {
|
|
|
|
return MakeMatcher(new IsLoadContextMatcher(access_matcher, context_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-23 14:21:26 +00:00
|
|
|
Matcher<Node*> IsParameter(const Matcher<int> index_matcher) {
|
|
|
|
return MakeMatcher(new IsParameterMatcher(index_matcher));
|
|
|
|
}
|
|
|
|
|
|
|
|
Matcher<Node*> IsLoadFramePointer() {
|
2017-09-28 17:55:52 +00:00
|
|
|
return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadFramePointer));
|
2015-07-23 14:21:26 +00:00
|
|
|
}
|
|
|
|
|
2016-04-19 12:47:25 +00:00
|
|
|
Matcher<Node*> IsLoadParentFramePointer() {
|
2017-09-28 17:55:52 +00:00
|
|
|
return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadParentFramePointer));
|
2016-04-19 12:47:25 +00:00
|
|
|
}
|
|
|
|
|
2016-03-14 15:33:15 +00:00
|
|
|
#define IS_QUADOP_MATCHER(Name) \
|
|
|
|
Matcher<Node*> Is##Name( \
|
|
|
|
const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, \
|
|
|
|
const Matcher<Node*>& c_matcher, const Matcher<Node*>& d_matcher) { \
|
|
|
|
return MakeMatcher(new IsQuadopMatcher(IrOpcode::k##Name, a_matcher, \
|
|
|
|
b_matcher, c_matcher, d_matcher)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
IS_QUADOP_MATCHER(Int32PairAdd)
|
2016-03-16 10:56:29 +00:00
|
|
|
IS_QUADOP_MATCHER(Int32PairSub)
|
2016-03-30 10:39:04 +00:00
|
|
|
IS_QUADOP_MATCHER(Int32PairMul)
|
2016-03-14 15:33:15 +00:00
|
|
|
|
2016-03-07 15:17:54 +00:00
|
|
|
#define IS_TERNOP_MATCHER(Name) \
|
|
|
|
Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
|
|
|
|
const Matcher<Node*>& mid_matcher, \
|
|
|
|
const Matcher<Node*>& rhs_matcher) { \
|
|
|
|
return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \
|
|
|
|
mid_matcher, rhs_matcher)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
IS_TERNOP_MATCHER(Word32PairShl)
|
2016-03-09 16:37:29 +00:00
|
|
|
IS_TERNOP_MATCHER(Word32PairShr)
|
|
|
|
IS_TERNOP_MATCHER(Word32PairSar)
|
2015-07-23 14:21:26 +00:00
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
#define IS_BINOP_MATCHER(Name) \
|
|
|
|
Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
|
|
|
|
const Matcher<Node*>& rhs_matcher) { \
|
|
|
|
return MakeMatcher( \
|
|
|
|
new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
|
|
|
|
}
|
2014-10-28 08:33:52 +00:00
|
|
|
IS_BINOP_MATCHER(NumberEqual)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(NumberLessThan)
|
|
|
|
IS_BINOP_MATCHER(NumberSubtract)
|
2014-10-29 14:16:32 +00:00
|
|
|
IS_BINOP_MATCHER(NumberMultiply)
|
2015-07-03 11:41:54 +00:00
|
|
|
IS_BINOP_MATCHER(NumberShiftLeft)
|
|
|
|
IS_BINOP_MATCHER(NumberShiftRight)
|
|
|
|
IS_BINOP_MATCHER(NumberShiftRightLogical)
|
2016-05-12 18:42:13 +00:00
|
|
|
IS_BINOP_MATCHER(NumberImul)
|
2016-06-13 07:06:49 +00:00
|
|
|
IS_BINOP_MATCHER(NumberAtan2)
|
2016-07-22 08:22:05 +00:00
|
|
|
IS_BINOP_MATCHER(NumberMax)
|
|
|
|
IS_BINOP_MATCHER(NumberMin)
|
2016-06-28 10:23:58 +00:00
|
|
|
IS_BINOP_MATCHER(NumberPow)
|
2016-11-24 06:36:46 +00:00
|
|
|
IS_BINOP_MATCHER(ReferenceEqual)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(Word32And)
|
2015-10-01 17:22:58 +00:00
|
|
|
IS_BINOP_MATCHER(Word32Or)
|
2016-02-24 09:51:30 +00:00
|
|
|
IS_BINOP_MATCHER(Word32Xor)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(Word32Sar)
|
|
|
|
IS_BINOP_MATCHER(Word32Shl)
|
|
|
|
IS_BINOP_MATCHER(Word32Shr)
|
|
|
|
IS_BINOP_MATCHER(Word32Ror)
|
|
|
|
IS_BINOP_MATCHER(Word32Equal)
|
|
|
|
IS_BINOP_MATCHER(Word64And)
|
2015-10-01 17:22:58 +00:00
|
|
|
IS_BINOP_MATCHER(Word64Or)
|
2017-09-11 13:44:42 +00:00
|
|
|
IS_BINOP_MATCHER(Word64Xor)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(Word64Sar)
|
|
|
|
IS_BINOP_MATCHER(Word64Shl)
|
2017-09-11 13:44:42 +00:00
|
|
|
IS_BINOP_MATCHER(Word64Shr)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(Word64Equal)
|
|
|
|
IS_BINOP_MATCHER(Int32AddWithOverflow)
|
2016-07-14 09:23:44 +00:00
|
|
|
IS_BINOP_MATCHER(Int32SubWithOverflow)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_BINOP_MATCHER(Int32Add)
|
|
|
|
IS_BINOP_MATCHER(Int32Sub)
|
|
|
|
IS_BINOP_MATCHER(Int32Mul)
|
|
|
|
IS_BINOP_MATCHER(Int32MulHigh)
|
|
|
|
IS_BINOP_MATCHER(Int32LessThan)
|
|
|
|
IS_BINOP_MATCHER(Uint32LessThan)
|
|
|
|
IS_BINOP_MATCHER(Uint32LessThanOrEqual)
|
2015-07-23 14:21:26 +00:00
|
|
|
IS_BINOP_MATCHER(Int64Add)
|
2015-07-30 11:36:26 +00:00
|
|
|
IS_BINOP_MATCHER(Int64Sub)
|
2016-12-12 14:52:30 +00:00
|
|
|
IS_BINOP_MATCHER(Int64Mul)
|
2015-09-10 16:21:34 +00:00
|
|
|
IS_BINOP_MATCHER(JSAdd)
|
2018-04-26 06:59:15 +00:00
|
|
|
IS_BINOP_MATCHER(JSParseInt)
|
2015-07-13 05:23:40 +00:00
|
|
|
IS_BINOP_MATCHER(Float32Equal)
|
|
|
|
IS_BINOP_MATCHER(Float32LessThan)
|
|
|
|
IS_BINOP_MATCHER(Float32LessThanOrEqual)
|
2015-03-12 14:07:28 +00:00
|
|
|
IS_BINOP_MATCHER(Float64Max)
|
|
|
|
IS_BINOP_MATCHER(Float64Min)
|
2016-09-16 17:55:03 +00:00
|
|
|
IS_BINOP_MATCHER(Float64Add)
|
2014-11-06 06:13:10 +00:00
|
|
|
IS_BINOP_MATCHER(Float64Sub)
|
2016-09-16 17:55:03 +00:00
|
|
|
IS_BINOP_MATCHER(Float64Mul)
|
2015-03-05 09:22:26 +00:00
|
|
|
IS_BINOP_MATCHER(Float64InsertLowWord32)
|
|
|
|
IS_BINOP_MATCHER(Float64InsertHighWord32)
|
2014-10-20 11:26:23 +00:00
|
|
|
#undef IS_BINOP_MATCHER
|
|
|
|
|
|
|
|
|
|
|
|
#define IS_UNOP_MATCHER(Name) \
|
|
|
|
Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \
|
|
|
|
return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
|
|
|
|
}
|
2014-10-28 08:33:52 +00:00
|
|
|
IS_UNOP_MATCHER(BooleanNot)
|
2016-09-27 10:26:09 +00:00
|
|
|
IS_UNOP_MATCHER(BitcastWordToTagged)
|
2016-04-24 11:39:31 +00:00
|
|
|
IS_UNOP_MATCHER(TruncateFloat64ToWord32)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_UNOP_MATCHER(ChangeFloat64ToInt32)
|
|
|
|
IS_UNOP_MATCHER(ChangeFloat64ToUint32)
|
|
|
|
IS_UNOP_MATCHER(ChangeInt32ToFloat64)
|
|
|
|
IS_UNOP_MATCHER(ChangeInt32ToInt64)
|
|
|
|
IS_UNOP_MATCHER(ChangeUint32ToFloat64)
|
|
|
|
IS_UNOP_MATCHER(ChangeUint32ToUint64)
|
|
|
|
IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
|
|
|
|
IS_UNOP_MATCHER(TruncateInt64ToInt32)
|
2015-04-08 11:54:53 +00:00
|
|
|
IS_UNOP_MATCHER(Float32Abs)
|
2016-08-08 08:39:38 +00:00
|
|
|
IS_UNOP_MATCHER(Float32Neg)
|
2015-04-08 11:54:53 +00:00
|
|
|
IS_UNOP_MATCHER(Float64Abs)
|
2016-08-08 08:39:38 +00:00
|
|
|
IS_UNOP_MATCHER(Float64Neg)
|
2014-10-20 11:26:23 +00:00
|
|
|
IS_UNOP_MATCHER(Float64Sqrt)
|
2015-03-10 08:42:47 +00:00
|
|
|
IS_UNOP_MATCHER(Float64RoundDown)
|
Add floor, ceil, round (truncate) instructions for ia32, x64 (if SSE4.1) and
add floor, ceil, round (truncate and away from zero) for arm64.
R=bmeurer@chromium.org, dcarney@chromium.org, mstarzinger@chromium.org, rodolph.perfetta@arm.com
TEST=test/mjsunit/asm/math-floor.js,test/mjsunit/asm/math-ceil.js,test/unittest/compiler/js-builtin-reducer-unittest.cc
Review URL: https://codereview.chromium.org/677433002
Cr-Commit-Position: refs/heads/master@{#25018}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25018 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-10-30 14:15:20 +00:00
|
|
|
IS_UNOP_MATCHER(Float64RoundTruncate)
|
|
|
|
IS_UNOP_MATCHER(Float64RoundTiesAway)
|
2015-03-05 09:22:26 +00:00
|
|
|
IS_UNOP_MATCHER(Float64ExtractLowWord32)
|
|
|
|
IS_UNOP_MATCHER(Float64ExtractHighWord32)
|
2016-06-28 04:34:20 +00:00
|
|
|
IS_UNOP_MATCHER(NumberAbs)
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
IS_UNOP_MATCHER(NumberAcos)
|
|
|
|
IS_UNOP_MATCHER(NumberAcosh)
|
|
|
|
IS_UNOP_MATCHER(NumberAsin)
|
|
|
|
IS_UNOP_MATCHER(NumberAsinh)
|
2016-06-13 07:06:49 +00:00
|
|
|
IS_UNOP_MATCHER(NumberAtan)
|
2016-06-17 09:13:22 +00:00
|
|
|
IS_UNOP_MATCHER(NumberAtanh)
|
2016-06-15 05:43:36 +00:00
|
|
|
IS_UNOP_MATCHER(NumberCeil)
|
|
|
|
IS_UNOP_MATCHER(NumberClz32)
|
2016-06-20 05:51:37 +00:00
|
|
|
IS_UNOP_MATCHER(NumberCbrt)
|
2016-06-17 15:21:48 +00:00
|
|
|
IS_UNOP_MATCHER(NumberCos)
|
2016-06-30 08:41:05 +00:00
|
|
|
IS_UNOP_MATCHER(NumberCosh)
|
2016-06-17 05:19:35 +00:00
|
|
|
IS_UNOP_MATCHER(NumberExp)
|
2016-06-17 09:13:22 +00:00
|
|
|
IS_UNOP_MATCHER(NumberExpm1)
|
2016-06-15 05:43:36 +00:00
|
|
|
IS_UNOP_MATCHER(NumberFloor)
|
|
|
|
IS_UNOP_MATCHER(NumberFround)
|
2016-06-13 05:46:38 +00:00
|
|
|
IS_UNOP_MATCHER(NumberLog)
|
|
|
|
IS_UNOP_MATCHER(NumberLog1p)
|
2016-06-16 11:22:32 +00:00
|
|
|
IS_UNOP_MATCHER(NumberLog10)
|
2016-06-20 05:51:37 +00:00
|
|
|
IS_UNOP_MATCHER(NumberLog2)
|
2016-06-15 05:43:36 +00:00
|
|
|
IS_UNOP_MATCHER(NumberRound)
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
IS_UNOP_MATCHER(NumberSign)
|
2016-06-17 15:21:48 +00:00
|
|
|
IS_UNOP_MATCHER(NumberSin)
|
2016-06-30 08:41:05 +00:00
|
|
|
IS_UNOP_MATCHER(NumberSinh)
|
2016-06-15 05:43:36 +00:00
|
|
|
IS_UNOP_MATCHER(NumberSqrt)
|
2016-06-20 05:51:37 +00:00
|
|
|
IS_UNOP_MATCHER(NumberTan)
|
2016-06-30 08:41:05 +00:00
|
|
|
IS_UNOP_MATCHER(NumberTanh)
|
2016-06-15 05:43:36 +00:00
|
|
|
IS_UNOP_MATCHER(NumberTrunc)
|
2016-09-06 08:54:19 +00:00
|
|
|
IS_UNOP_MATCHER(NumberToBoolean)
|
2014-11-25 08:40:18 +00:00
|
|
|
IS_UNOP_MATCHER(NumberToInt32)
|
|
|
|
IS_UNOP_MATCHER(NumberToUint32)
|
2016-06-10 07:41:45 +00:00
|
|
|
IS_UNOP_MATCHER(PlainPrimitiveToNumber)
|
2018-03-16 08:36:57 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsFiniteNumber)
|
2018-04-23 08:49:19 +00:00
|
|
|
IS_UNOP_MATCHER(NumberIsFinite)
|
2018-03-16 08:37:33 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsInteger)
|
2018-03-21 12:04:47 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsSafeInteger)
|
2017-03-03 09:08:14 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsNaN)
|
2018-04-23 08:49:19 +00:00
|
|
|
IS_UNOP_MATCHER(NumberIsNaN)
|
2016-02-02 11:42:38 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsReceiver)
|
2015-01-26 09:05:47 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsSmi)
|
2016-11-24 06:36:46 +00:00
|
|
|
IS_UNOP_MATCHER(ObjectIsUndetectable)
|
2018-03-23 13:03:34 +00:00
|
|
|
IS_UNOP_MATCHER(StringFromSingleCharCode)
|
2017-11-30 06:10:35 +00:00
|
|
|
IS_UNOP_MATCHER(StringLength)
|
2015-03-20 08:37:20 +00:00
|
|
|
IS_UNOP_MATCHER(Word32Clz)
|
2016-03-16 12:14:44 +00:00
|
|
|
IS_UNOP_MATCHER(Word32Ctz)
|
2016-03-15 10:41:55 +00:00
|
|
|
IS_UNOP_MATCHER(Word32Popcnt)
|
2016-07-29 19:31:54 +00:00
|
|
|
IS_UNOP_MATCHER(Word32ReverseBytes)
|
2018-02-21 11:38:35 +00:00
|
|
|
IS_UNOP_MATCHER(SpeculativeToNumber)
|
2018-03-26 15:44:44 +00:00
|
|
|
IS_UNOP_MATCHER(PoisonOnSpeculationTagged)
|
2014-10-20 11:26:23 +00:00
|
|
|
#undef IS_UNOP_MATCHER
|
|
|
|
|
2018-01-29 12:16:32 +00:00
|
|
|
// Special-case Bitcast operators which are disabled when ENABLE_VERIFY_CSA is
|
|
|
|
// not enabled.
|
|
|
|
Matcher<Node*> IsBitcastTaggedToWord(const Matcher<Node*>& input_matcher) {
|
|
|
|
#ifdef ENABLE_VERIFY_CSA
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsUnopMatcher(IrOpcode::kBitcastTaggedToWord, input_matcher));
|
|
|
|
#else
|
|
|
|
return input_matcher;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
Matcher<Node*> IsBitcastWordToTaggedSigned(
|
|
|
|
const Matcher<Node*>& input_matcher) {
|
|
|
|
#ifdef ENABLE_VERIFY_CSA
|
|
|
|
return MakeMatcher(
|
|
|
|
new IsUnopMatcher(IrOpcode::kBitcastWordToTaggedSigned, input_matcher));
|
|
|
|
#else
|
|
|
|
return input_matcher;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-05 08:41:11 +00:00
|
|
|
#undef LOAD_MATCHER
|
|
|
|
#undef STORE_MATCHER
|
|
|
|
#undef IS_QUADOP_MATCHER
|
|
|
|
#undef IS_TERNOP_MATCHER
|
|
|
|
|
2014-10-20 11:26:23 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|