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

Side by Side Diff: test/cctest/compiler/test-machine-operator-reducer.cc

Issue 555283004: [turbofan] Next step towards shared operators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 6
7 #include "src/base/utils/random-number-generator.h" 7 #include "src/base/utils/random-number-generator.h"
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/machine-operator-reducer.h" 10 #include "src/compiler/machine-operator-reducer.h"
11 #include "src/compiler/typer.h" 11 #include "src/compiler/typer.h"
12 #include "test/cctest/compiler/value-helper.h" 12 #include "test/cctest/compiler/value-helper.h"
13 13
14 using namespace v8::internal; 14 using namespace v8::internal;
15 using namespace v8::internal::compiler; 15 using namespace v8::internal::compiler;
16 16
17 template <typename T> 17 template <typename T>
18 Operator* NewConstantOperator(CommonOperatorBuilder* common, volatile T value); 18 const Operator* NewConstantOperator(CommonOperatorBuilder* common,
19 volatile T value);
19 20
20 template <> 21 template <>
21 Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common, 22 const Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common,
22 volatile int32_t value) { 23 volatile int32_t value) {
23 return common->Int32Constant(value); 24 return common->Int32Constant(value);
24 } 25 }
25 26
26 template <> 27 template <>
27 Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, 28 const Operator* NewConstantOperator<double>(CommonOperatorBuilder* common,
28 volatile double value) { 29 volatile double value) {
29 return common->Float64Constant(value); 30 return common->Float64Constant(value);
30 } 31 }
31 32
32 33
33 template <typename T> 34 template <typename T>
34 T ValueOfOperator(const Operator* op); 35 T ValueOfOperator(const Operator* op);
35 36
36 template <> 37 template <>
37 int32_t ValueOfOperator<int32_t>(const Operator* op) { 38 int32_t ValueOfOperator<int32_t>(const Operator* op) {
38 CHECK_EQ(IrOpcode::kInt32Constant, op->opcode()); 39 CHECK_EQ(IrOpcode::kInt32Constant, op->opcode());
(...skipping 17 matching lines...) Expand all
56 common(main_zone()), 57 common(main_zone()),
57 graph(main_zone()), 58 graph(main_zone()),
58 typer(main_zone()), 59 typer(main_zone()),
59 jsgraph(&graph, &common, &typer), 60 jsgraph(&graph, &common, &typer),
60 maxuint32(Constant<int32_t>(kMaxUInt32)) { 61 maxuint32(Constant<int32_t>(kMaxUInt32)) {
61 Node* s = graph.NewNode(common.Start(num_parameters)); 62 Node* s = graph.NewNode(common.Start(num_parameters));
62 graph.SetStart(s); 63 graph.SetStart(s);
63 } 64 }
64 65
65 Isolate* isolate; 66 Isolate* isolate;
66 Operator* binop; 67 const Operator* binop;
67 Operator* unop; 68 const Operator* unop;
68 MachineOperatorBuilder machine; 69 MachineOperatorBuilder machine;
69 CommonOperatorBuilder common; 70 CommonOperatorBuilder common;
70 Graph graph; 71 Graph graph;
71 Typer typer; 72 Typer typer;
72 JSGraph jsgraph; 73 JSGraph jsgraph;
73 Node* maxuint32; 74 Node* maxuint32;
74 75
75 template <typename T> 76 template <typename T>
76 Node* Constant(volatile T value) { 77 Node* Constant(volatile T value) {
77 return graph.NewNode(NewConstantOperator<T>(&common, value)); 78 return graph.NewNode(NewConstantOperator<T>(&common, value));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 Reduction reduction = reducer.Reduce(n); 124 Reduction reduction = reducer.Reduce(n);
124 CHECK(reduction.Changed()); 125 CHECK(reduction.Changed());
125 CHECK_EQ(binop, reduction.replacement()->op()); 126 CHECK_EQ(binop, reduction.replacement()->op());
126 CHECK_EQ(left_expect, reduction.replacement()->InputAt(0)); 127 CHECK_EQ(left_expect, reduction.replacement()->InputAt(0));
127 CHECK_EQ(right_expect, reduction.replacement()->InputAt(1)); 128 CHECK_EQ(right_expect, reduction.replacement()->InputAt(1));
128 } 129 }
129 130
130 // Check that the reduction of this binop applied to {left} and {right} yields 131 // Check that the reduction of this binop applied to {left} and {right} yields
131 // the {op_expect} applied to {left_expect} and {right_expect}. 132 // the {op_expect} applied to {left_expect} and {right_expect}.
132 template <typename T> 133 template <typename T>
133 void CheckFoldBinop(volatile T left_expect, Operator* op_expect, 134 void CheckFoldBinop(volatile T left_expect, const Operator* op_expect,
134 Node* right_expect, Node* left, Node* right) { 135 Node* right_expect, Node* left, Node* right) {
135 CHECK_NE(NULL, binop); 136 CHECK_NE(NULL, binop);
136 Node* n = graph.NewNode(binop, left, right); 137 Node* n = graph.NewNode(binop, left, right);
137 MachineOperatorReducer reducer(&jsgraph); 138 MachineOperatorReducer reducer(&jsgraph);
138 Reduction r = reducer.Reduce(n); 139 Reduction r = reducer.Reduce(n);
139 CHECK(r.Changed()); 140 CHECK(r.Changed());
140 CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode()); 141 CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode());
141 CHECK_EQ(left_expect, ValueOf<T>(r.replacement()->InputAt(0)->op())); 142 CHECK_EQ(left_expect, ValueOf<T>(r.replacement()->InputAt(0)->op()));
142 CHECK_EQ(right_expect, r.replacement()->InputAt(1)); 143 CHECK_EQ(right_expect, r.replacement()->InputAt(1));
143 } 144 }
144 145
145 // Check that the reduction of this binop applied to {left} and {right} yields 146 // Check that the reduction of this binop applied to {left} and {right} yields
146 // the {op_expect} applied to {left_expect} and {right_expect}. 147 // the {op_expect} applied to {left_expect} and {right_expect}.
147 template <typename T> 148 template <typename T>
148 void CheckFoldBinop(Node* left_expect, Operator* op_expect, 149 void CheckFoldBinop(Node* left_expect, const Operator* op_expect,
149 volatile T right_expect, Node* left, Node* right) { 150 volatile T right_expect, Node* left, Node* right) {
150 CHECK_NE(NULL, binop); 151 CHECK_NE(NULL, binop);
151 Node* n = graph.NewNode(binop, left, right); 152 Node* n = graph.NewNode(binop, left, right);
152 MachineOperatorReducer reducer(&jsgraph); 153 MachineOperatorReducer reducer(&jsgraph);
153 Reduction r = reducer.Reduce(n); 154 Reduction r = reducer.Reduce(n);
154 CHECK(r.Changed()); 155 CHECK(r.Changed());
155 CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode()); 156 CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode());
156 CHECK_EQ(left_expect, r.replacement()->InputAt(0)); 157 CHECK_EQ(left_expect, r.replacement()->InputAt(0));
157 CHECK_EQ(right_expect, ValueOf<T>(r.replacement()->InputAt(1)->op())); 158 CHECK_EQ(right_expect, ValueOf<T>(r.replacement()->InputAt(1)->op()));
158 } 159 }
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 // TODO(titzer): test MachineOperatorReducer for Int64Mul 798 // TODO(titzer): test MachineOperatorReducer for Int64Mul
798 // TODO(titzer): test MachineOperatorReducer for Int64UMul 799 // TODO(titzer): test MachineOperatorReducer for Int64UMul
799 // TODO(titzer): test MachineOperatorReducer for Int64Div 800 // TODO(titzer): test MachineOperatorReducer for Int64Div
800 // TODO(titzer): test MachineOperatorReducer for Int64UDiv 801 // TODO(titzer): test MachineOperatorReducer for Int64UDiv
801 // TODO(titzer): test MachineOperatorReducer for Int64Mod 802 // TODO(titzer): test MachineOperatorReducer for Int64Mod
802 // TODO(titzer): test MachineOperatorReducer for Int64UMod 803 // TODO(titzer): test MachineOperatorReducer for Int64UMod
803 // TODO(titzer): test MachineOperatorReducer for Int64Neg 804 // TODO(titzer): test MachineOperatorReducer for Int64Neg
804 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 805 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64
805 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 806 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32
806 // TODO(titzer): test MachineOperatorReducer for Float64Compare 807 // TODO(titzer): test MachineOperatorReducer for Float64Compare
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698