Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: test/cctest/compiler/graph-builder-tester.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/compiler/graph-builder-tester.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_
6 #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_
7
8 #include "src/v8.h"
9 #include "test/cctest/cctest.h"
10
11 #include "src/compiler/common-operator.h"
12 #include "src/compiler/graph-builder.h"
13 #include "src/compiler/machine-node-factory.h"
14 #include "src/compiler/machine-operator.h"
15 #include "src/compiler/simplified-node-factory.h"
16 #include "src/compiler/simplified-operator.h"
17 #include "test/cctest/compiler/call-tester.h"
18 #include "test/cctest/compiler/simplified-graph-builder.h"
19
20 namespace v8 {
21 namespace internal {
22 namespace compiler {
23
24 // A class that just passes node creation on to the Graph.
25 class DirectGraphBuilder : public GraphBuilder {
26 public:
27 explicit DirectGraphBuilder(Graph* graph) : GraphBuilder(graph) {}
28 virtual ~DirectGraphBuilder() {}
29
30 protected:
31 virtual Node* MakeNode(Operator* op, int value_input_count,
32 Node** value_inputs) {
33 return graph()->NewNode(op, value_input_count, value_inputs);
34 }
35 };
36
37
38 class MachineCallHelper : public CallHelper {
39 public:
40 MachineCallHelper(Zone* zone, MachineCallDescriptorBuilder* builder);
41
42 Node* Parameter(int offset);
43
44 protected:
45 virtual byte* Generate();
46 virtual void VerifyParameters(int parameter_count,
47 MachineRepresentation* parameters);
48 void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common);
49
50 private:
51 int parameter_count() const {
52 return call_descriptor_builder_->parameter_count();
53 }
54 MachineCallDescriptorBuilder* call_descriptor_builder_;
55 Node** parameters_;
56 // TODO(dcarney): shouldn't need graph stored.
57 Graph* graph_;
58 MaybeHandle<Code> code_;
59 };
60
61
62 class GraphAndBuilders {
63 public:
64 explicit GraphAndBuilders(Zone* zone)
65 : main_graph_(new (zone) Graph(zone)),
66 main_common_(zone),
67 main_machine_(zone),
68 main_simplified_(zone) {}
69
70 protected:
71 // Prefixed with main_ to avoid naiming conflicts.
72 Graph* const main_graph_;
73 CommonOperatorBuilder main_common_;
74 MachineOperatorBuilder main_machine_;
75 SimplifiedOperatorBuilder main_simplified_;
76 };
77
78
79 template <typename ReturnType>
80 class GraphBuilderTester
81 : public HandleAndZoneScope,
82 private GraphAndBuilders,
83 public MachineCallHelper,
84 public SimplifiedGraphBuilder,
85 public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > {
86 public:
87 explicit GraphBuilderTester(MachineRepresentation p0,
88 MachineRepresentation p1,
89 MachineRepresentation p2,
90 MachineRepresentation p3,
91 MachineRepresentation p4)
92 : GraphAndBuilders(main_zone()),
93 MachineCallHelper(
94 main_zone(),
95 ToCallDescriptorBuilder(
96 main_zone(), ReturnValueTraits<ReturnType>::Representation(),
97 p0, p1, p2, p3, p4)),
98 SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_,
99 &main_simplified_) {
100 Begin();
101 InitParameters(this, &main_common_);
102 }
103 virtual ~GraphBuilderTester() {}
104
105 Factory* factory() const { return isolate()->factory(); }
106 };
107 } // namespace compiler
108 } // namespace internal
109 } // namespace v8
110
111 #endif // V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/compiler/graph-builder-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698