2014-08-12 08:24:20 +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.
|
|
|
|
|
2014-10-01 08:34:25 +00:00
|
|
|
#ifndef V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|
|
|
|
#define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|
2014-08-12 08:24:20 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
#include "src/compiler/common-operator.h"
|
2014-08-18 06:54:07 +00:00
|
|
|
#include "src/compiler/graph.h"
|
2014-08-12 08:24:20 +00:00
|
|
|
#include "src/compiler/machine-operator.h"
|
2014-10-01 08:34:25 +00:00
|
|
|
#include "test/unittests/test-utils.h"
|
2014-08-12 08:24:20 +00:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Forward declarations.
|
2014-10-07 07:36:21 +00:00
|
|
|
template <class T>
|
|
|
|
class Handle;
|
2014-08-12 08:24:20 +00:00
|
|
|
class HeapObject;
|
|
|
|
template <class T>
|
2014-09-04 13:45:05 +00:00
|
|
|
class Unique;
|
2014-08-12 08:24:20 +00:00
|
|
|
|
|
|
|
namespace compiler {
|
|
|
|
|
2014-10-07 07:36:21 +00:00
|
|
|
// Forward declarations.
|
|
|
|
struct ElementAccess;
|
|
|
|
struct FieldAccess;
|
|
|
|
|
|
|
|
|
2014-08-22 04:47:55 +00:00
|
|
|
using ::testing::Matcher;
|
|
|
|
|
|
|
|
|
2014-09-04 08:44:03 +00:00
|
|
|
class GraphTest : public TestWithContext, public TestWithZone {
|
2014-08-18 06:54:07 +00:00
|
|
|
public:
|
|
|
|
explicit GraphTest(int parameters = 1);
|
|
|
|
virtual ~GraphTest();
|
|
|
|
|
|
|
|
protected:
|
2014-08-22 04:47:55 +00:00
|
|
|
Node* Parameter(int32_t index);
|
2014-09-22 11:42:10 +00:00
|
|
|
Node* Float32Constant(volatile float value);
|
|
|
|
Node* Float64Constant(volatile double value);
|
2014-08-22 04:47:55 +00:00
|
|
|
Node* Int32Constant(int32_t value);
|
2014-10-09 12:20:45 +00:00
|
|
|
Node* Uint32Constant(uint32_t value) {
|
|
|
|
return Int32Constant(bit_cast<int32_t>(value));
|
|
|
|
}
|
2014-08-22 07:54:09 +00:00
|
|
|
Node* Int64Constant(int64_t value);
|
2014-09-22 11:42:10 +00:00
|
|
|
Node* NumberConstant(volatile double value);
|
2014-10-07 07:36:21 +00:00
|
|
|
Node* HeapConstant(const Handle<HeapObject>& value);
|
2014-09-04 13:45:05 +00:00
|
|
|
Node* HeapConstant(const Unique<HeapObject>& value);
|
2014-08-22 04:47:55 +00:00
|
|
|
Node* FalseConstant();
|
|
|
|
Node* TrueConstant();
|
2014-10-07 07:36:21 +00:00
|
|
|
Node* UndefinedConstant();
|
2014-08-22 04:47:55 +00:00
|
|
|
|
|
|
|
Matcher<Node*> IsFalseConstant();
|
|
|
|
Matcher<Node*> IsTrueConstant();
|
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
CommonOperatorBuilder* common() { return &common_; }
|
2014-08-18 06:54:07 +00:00
|
|
|
Graph* graph() { return &graph_; }
|
|
|
|
|
|
|
|
private:
|
2014-09-01 10:26:12 +00:00
|
|
|
CommonOperatorBuilder common_;
|
2014-08-18 06:54:07 +00:00
|
|
|
Graph graph_;
|
|
|
|
};
|
|
|
|
|
2014-08-12 08:24:20 +00:00
|
|
|
|
|
|
|
Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher);
|
2014-08-18 06:54:07 +00:00
|
|
|
Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
|
|
|
|
const Matcher<Node*>& control1_matcher);
|
|
|
|
Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
|
|
|
|
Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
|
2014-08-19 04:54:06 +00:00
|
|
|
Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
|
2014-08-18 11:36:06 +00:00
|
|
|
Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher);
|
|
|
|
Matcher<Node*> IsExternalConstant(
|
|
|
|
const Matcher<ExternalReference>& value_matcher);
|
2014-08-12 08:24:20 +00:00
|
|
|
Matcher<Node*> IsHeapConstant(
|
2014-09-04 13:45:05 +00:00
|
|
|
const Matcher<Unique<HeapObject> >& value_matcher);
|
2014-09-22 11:42:10 +00:00
|
|
|
Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
|
2014-08-22 04:47:55 +00:00
|
|
|
Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
|
2014-08-12 08:24:20 +00:00
|
|
|
Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
|
2014-08-22 07:54:09 +00:00
|
|
|
Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
|
2014-08-18 11:36:06 +00:00
|
|
|
Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
|
2014-09-05 11:44:31 +00:00
|
|
|
Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
|
|
|
|
const Matcher<Node*>& value0_matcher,
|
2014-08-12 08:24:20 +00:00
|
|
|
const Matcher<Node*>& value1_matcher,
|
|
|
|
const Matcher<Node*>& merge_matcher);
|
2014-09-08 06:49:17 +00:00
|
|
|
Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
|
2014-08-12 08:24:20 +00:00
|
|
|
const Matcher<Node*>& base_matcher);
|
2014-08-18 11:36:06 +00:00
|
|
|
Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& 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);
|
2014-08-12 08:24:20 +00:00
|
|
|
|
2014-09-23 11:40:00 +00:00
|
|
|
Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-09-26 14:06:56 +00:00
|
|
|
Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-07 07:36:21 +00:00
|
|
|
Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher);
|
|
|
|
Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& length_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher);
|
|
|
|
Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
|
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
|
|
|
const Matcher<Node*>& length_matcher,
|
|
|
|
const Matcher<Node*>& value_matcher,
|
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher);
|
2014-09-23 11:40:00 +00:00
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
|
2014-08-12 08:24:20 +00:00
|
|
|
const Matcher<Node*>& base_matcher,
|
|
|
|
const Matcher<Node*>& index_matcher,
|
2014-10-01 11:08:37 +00:00
|
|
|
const Matcher<Node*>& effect_matcher,
|
|
|
|
const Matcher<Node*>& control_matcher);
|
2014-10-09 12:20:45 +00:00
|
|
|
Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
|
2014-08-12 08:24:20 +00:00
|
|
|
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);
|
|
|
|
Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-08-20 04:01:36 +00:00
|
|
|
Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-14 11:57:06 +00:00
|
|
|
Matcher<Node*> IsWord32Shr(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-08-14 09:07:58 +00:00
|
|
|
Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-08-12 08:24:20 +00:00
|
|
|
Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
|
|
|
Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-14 11:57:06 +00:00
|
|
|
Matcher<Node*> IsInt32Add(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-13 11:09:32 +00:00
|
|
|
Matcher<Node*> IsInt32Sub(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-09-23 11:26:49 +00:00
|
|
|
Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-14 11:57:06 +00:00
|
|
|
Matcher<Node*> IsInt32MulHigh(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-13 11:09:32 +00:00
|
|
|
Matcher<Node*> IsInt32LessThan(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-10-10 10:23:04 +00:00
|
|
|
Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-08-20 04:01:36 +00:00
|
|
|
Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
|
|
|
|
const Matcher<Node*>& rhs_matcher);
|
2014-08-19 04:54:06 +00:00
|
|
|
Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
|
2014-08-27 14:47:50 +00:00
|
|
|
Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher);
|
2014-08-12 08:24:20 +00:00
|
|
|
Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
|
2014-08-19 08:48:41 +00:00
|
|
|
Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
|
2014-08-20 04:01:36 +00:00
|
|
|
Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
|
2014-08-19 08:48:41 +00:00
|
|
|
Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
|
2014-09-24 14:55:13 +00:00
|
|
|
Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher);
|
2014-08-20 04:01:00 +00:00
|
|
|
Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher);
|
2014-08-19 08:48:41 +00:00
|
|
|
Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
|
2014-09-24 10:24:19 +00:00
|
|
|
Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
|
2014-08-12 08:24:20 +00:00
|
|
|
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2014-10-01 08:34:25 +00:00
|
|
|
#endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|