blob: 1dc9c3dae72b215edf9f65cbf9d3024fbf15f6c6 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_GRAPH_UNITTEST_H_
6#define V8_COMPILER_GRAPH_UNITTEST_H_
7
8#include "src/compiler/common-operator.h"
9#include "src/compiler/graph.h"
10#include "src/compiler/machine-operator.h"
11#include "src/test/test-utils.h"
12#include "testing/gmock/include/gmock/gmock.h"
13
14namespace v8 {
15namespace internal {
16
17// Forward declarations.
18class HeapObject;
19template <class T>
20class Unique;
21
22namespace compiler {
23
24using ::testing::Matcher;
25
26
27class GraphTest : public TestWithContext, public TestWithZone {
28 public:
29 explicit GraphTest(int parameters = 1);
30 virtual ~GraphTest();
31
32 protected:
33 Node* Parameter(int32_t index);
34 Node* Float32Constant(volatile float value);
35 Node* Float64Constant(volatile double value);
36 Node* Int32Constant(int32_t value);
37 Node* Int64Constant(int64_t value);
38 Node* NumberConstant(volatile double value);
39 Node* HeapConstant(const Unique<HeapObject>& value);
40 Node* FalseConstant();
41 Node* TrueConstant();
42
43 Matcher<Node*> IsFalseConstant();
44 Matcher<Node*> IsTrueConstant();
45
46 CommonOperatorBuilder* common() { return &common_; }
47 Graph* graph() { return &graph_; }
48
49 private:
50 CommonOperatorBuilder common_;
51 Graph graph_;
52};
53
54
55Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
56 const Matcher<Node*>& control_matcher);
57Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
58 const Matcher<Node*>& control1_matcher);
59Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
60Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
61Matcher<Node*> IsControlEffect(const Matcher<Node*>& control_matcher);
62Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
63Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
64 const Matcher<Node*>& effect_matcher);
65Matcher<Node*> IsExternalConstant(
66 const Matcher<ExternalReference>& value_matcher);
67Matcher<Node*> IsHeapConstant(
68 const Matcher<Unique<HeapObject> >& value_matcher);
69Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
70Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
71Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
72Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
73Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
74Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
75 const Matcher<Node*>& value0_matcher,
76 const Matcher<Node*>& value1_matcher,
77 const Matcher<Node*>& merge_matcher);
78Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
79 const Matcher<Node*>& base_matcher);
80Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
81 const Matcher<Node*>& value0_matcher,
82 const Matcher<Node*>& value1_matcher,
83 const Matcher<Node*>& value2_matcher,
84 const Matcher<Node*>& value3_matcher,
85 const Matcher<Node*>& effect_matcher,
86 const Matcher<Node*>& control_matcher);
87
88Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
89 const Matcher<Node*>& rhs_matcher);
90
91Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
92 const Matcher<Node*>& base_matcher,
93 const Matcher<Node*>& index_matcher,
94 const Matcher<Node*>& effect_matcher);
95Matcher<Node*> IsStore(const Matcher<MachineType>& type_matcher,
96 const Matcher<WriteBarrierKind>& write_barrier_matcher,
97 const Matcher<Node*>& base_matcher,
98 const Matcher<Node*>& index_matcher,
99 const Matcher<Node*>& value_matcher,
100 const Matcher<Node*>& effect_matcher,
101 const Matcher<Node*>& control_matcher);
102Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
103 const Matcher<Node*>& rhs_matcher);
104Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
105 const Matcher<Node*>& rhs_matcher);
106Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
107 const Matcher<Node*>& rhs_matcher);
108Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
109 const Matcher<Node*>& rhs_matcher);
110Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
111 const Matcher<Node*>& rhs_matcher);
112Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
113 const Matcher<Node*>& rhs_matcher);
114Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
115 const Matcher<Node*>& rhs_matcher);
116Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
117 const Matcher<Node*>& rhs_matcher);
118Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
119 const Matcher<Node*>& rhs_matcher);
120Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
121 const Matcher<Node*>& rhs_matcher);
122Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
123 const Matcher<Node*>& rhs_matcher);
124Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
125 const Matcher<Node*>& rhs_matcher);
126Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
127Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher);
128Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
129Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
130Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
131Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
132Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher);
133Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
134Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
135
136} // namespace compiler
137} // namespace internal
138} // namespace v8
139
140#endif // V8_COMPILER_GRAPH_UNITTEST_H_