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

Side by Side Diff: test/unittests/compiler/machine-operator-unittest.cc

Issue 681133004: [turbofan] Complete support for integer division/modulus in simplified lowering. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes Created 6 years, 1 month 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/test-simplified-lowering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "src/compiler/machine-operator.h" 5 #include "src/compiler/machine-operator.h"
6 #include "src/compiler/operator-properties-inl.h" 6 #include "src/compiler/operator-properties-inl.h"
7 #include "testing/gtest-support.h" 7 #include "testing/gtest-support.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // ----------------------------------------------------------------------------- 151 // -----------------------------------------------------------------------------
152 // Pure operators. 152 // Pure operators.
153 153
154 154
155 namespace { 155 namespace {
156 156
157 struct PureOperator { 157 struct PureOperator {
158 const Operator* (MachineOperatorBuilder::*constructor)(); 158 const Operator* (MachineOperatorBuilder::*constructor)();
159 IrOpcode::Value opcode; 159 IrOpcode::Value opcode;
160 int value_input_count; 160 int value_input_count;
161 int control_input_count;
161 int value_output_count; 162 int value_output_count;
162 }; 163 };
163 164
164 165
165 std::ostream& operator<<(std::ostream& os, const PureOperator& pop) { 166 std::ostream& operator<<(std::ostream& os, const PureOperator& pop) {
166 return os << IrOpcode::Mnemonic(pop.opcode); 167 return os << IrOpcode::Mnemonic(pop.opcode);
167 } 168 }
168 169
169 170
170 const PureOperator kPureOperators[] = { 171 const PureOperator kPureOperators[] = {
171 #define PURE(Name, input_count, output_count) \ 172 #define PURE(Name, value_input_count, control_input_count, value_output_count) \
172 { \ 173 { \
173 &MachineOperatorBuilder::Name, IrOpcode::k##Name, input_count, \ 174 &MachineOperatorBuilder::Name, IrOpcode::k##Name, value_input_count, \
174 output_count \ 175 control_input_count, value_output_count \
175 } 176 }
176 PURE(Word32And, 2, 1), PURE(Word32Or, 2, 1), 177 PURE(Word32And, 2, 0, 1), PURE(Word32Or, 2, 0, 1), PURE(Word32Xor, 2, 0, 1),
177 PURE(Word32Xor, 2, 1), PURE(Word32Shl, 2, 1), 178 PURE(Word32Shl, 2, 0, 1), PURE(Word32Shr, 2, 0, 1),
178 PURE(Word32Shr, 2, 1), PURE(Word32Sar, 2, 1), 179 PURE(Word32Sar, 2, 0, 1), PURE(Word32Ror, 2, 0, 1),
179 PURE(Word32Ror, 2, 1), PURE(Word32Equal, 2, 1), 180 PURE(Word32Equal, 2, 0, 1), PURE(Word64And, 2, 0, 1),
180 PURE(Word64And, 2, 1), PURE(Word64Or, 2, 1), 181 PURE(Word64Or, 2, 0, 1), PURE(Word64Xor, 2, 0, 1), PURE(Word64Shl, 2, 0, 1),
181 PURE(Word64Xor, 2, 1), PURE(Word64Shl, 2, 1), 182 PURE(Word64Shr, 2, 0, 1), PURE(Word64Sar, 2, 0, 1),
182 PURE(Word64Shr, 2, 1), PURE(Word64Sar, 2, 1), 183 PURE(Word64Ror, 2, 0, 1), PURE(Word64Equal, 2, 0, 1),
183 PURE(Word64Ror, 2, 1), PURE(Word64Equal, 2, 1), 184 PURE(Int32Add, 2, 0, 1), PURE(Int32AddWithOverflow, 2, 0, 2),
184 PURE(Int32Add, 2, 1), PURE(Int32AddWithOverflow, 2, 2), 185 PURE(Int32Sub, 2, 0, 1), PURE(Int32SubWithOverflow, 2, 0, 2),
185 PURE(Int32Sub, 2, 1), PURE(Int32SubWithOverflow, 2, 2), 186 PURE(Int32Mul, 2, 0, 1), PURE(Int32MulHigh, 2, 0, 1),
186 PURE(Int32Mul, 2, 1), PURE(Int32MulHigh, 2, 1), 187 PURE(Int32Div, 2, 1, 1), PURE(Uint32Div, 2, 1, 1), PURE(Int32Mod, 2, 1, 1),
187 PURE(Int32Div, 2, 1), PURE(Uint32Div, 2, 1), 188 PURE(Uint32Mod, 2, 1, 1), PURE(Int32LessThan, 2, 0, 1),
188 PURE(Int32Mod, 2, 1), PURE(Uint32Mod, 2, 1), 189 PURE(Int32LessThanOrEqual, 2, 0, 1), PURE(Uint32LessThan, 2, 0, 1),
189 PURE(Int32LessThan, 2, 1), PURE(Int32LessThanOrEqual, 2, 1), 190 PURE(Uint32LessThanOrEqual, 2, 0, 1), PURE(Int64Add, 2, 0, 1),
190 PURE(Uint32LessThan, 2, 1), PURE(Uint32LessThanOrEqual, 2, 1), 191 PURE(Int64Sub, 2, 0, 1), PURE(Int64Mul, 2, 0, 1), PURE(Int64Div, 2, 0, 1),
191 PURE(Int64Add, 2, 1), PURE(Int64Sub, 2, 1), 192 PURE(Uint64Div, 2, 0, 1), PURE(Int64Mod, 2, 0, 1), PURE(Uint64Mod, 2, 0, 1),
192 PURE(Int64Mul, 2, 1), PURE(Int64Div, 2, 1), 193 PURE(Int64LessThan, 2, 0, 1), PURE(Int64LessThanOrEqual, 2, 0, 1),
193 PURE(Uint64Div, 2, 1), PURE(Int64Mod, 2, 1), 194 PURE(Uint64LessThan, 2, 0, 1), PURE(ChangeFloat32ToFloat64, 1, 0, 1),
194 PURE(Uint64Mod, 2, 1), PURE(Int64LessThan, 2, 1), 195 PURE(ChangeFloat64ToInt32, 1, 0, 1), PURE(ChangeFloat64ToUint32, 1, 0, 1),
195 PURE(Int64LessThanOrEqual, 2, 1), PURE(Uint64LessThan, 2, 1), 196 PURE(ChangeInt32ToInt64, 1, 0, 1), PURE(ChangeUint32ToFloat64, 1, 0, 1),
196 PURE(ChangeFloat32ToFloat64, 1, 1), PURE(ChangeFloat64ToInt32, 1, 1), 197 PURE(ChangeUint32ToUint64, 1, 0, 1),
197 PURE(ChangeFloat64ToUint32, 1, 1), PURE(ChangeInt32ToInt64, 1, 1), 198 PURE(TruncateFloat64ToFloat32, 1, 0, 1),
198 PURE(ChangeUint32ToFloat64, 1, 1), PURE(ChangeUint32ToUint64, 1, 1), 199 PURE(TruncateFloat64ToInt32, 1, 0, 1), PURE(TruncateInt64ToInt32, 1, 0, 1),
199 PURE(TruncateFloat64ToFloat32, 1, 1), PURE(TruncateFloat64ToInt32, 1, 1), 200 PURE(Float64Add, 2, 0, 1), PURE(Float64Sub, 2, 0, 1),
200 PURE(TruncateInt64ToInt32, 1, 1), PURE(Float64Add, 2, 1), 201 PURE(Float64Mul, 2, 0, 1), PURE(Float64Div, 2, 0, 1),
201 PURE(Float64Sub, 2, 1), PURE(Float64Mul, 2, 1), 202 PURE(Float64Mod, 2, 0, 1), PURE(Float64Sqrt, 1, 0, 1),
202 PURE(Float64Div, 2, 1), PURE(Float64Mod, 2, 1), 203 PURE(Float64Equal, 2, 0, 1), PURE(Float64LessThan, 2, 0, 1),
203 PURE(Float64Sqrt, 1, 1), PURE(Float64Equal, 2, 1), 204 PURE(Float64LessThanOrEqual, 2, 0, 1), PURE(LoadStackPointer, 0, 0, 1),
204 PURE(Float64LessThan, 2, 1), PURE(Float64LessThanOrEqual, 2, 1), 205 PURE(Float64Floor, 1, 0, 1), PURE(Float64Ceil, 1, 0, 1),
205 PURE(LoadStackPointer, 0, 1), PURE(Float64Floor, 1, 1), 206 PURE(Float64RoundTruncate, 1, 0, 1), PURE(Float64RoundTiesAway, 1, 0, 1)
206 PURE(Float64Ceil, 1, 1), PURE(Float64RoundTruncate, 1, 1),
207 PURE(Float64RoundTiesAway, 1, 1),
208 #undef PURE 207 #undef PURE
209 }; 208 };
210 209
211 210
212 typedef MachineOperatorTestWithParam<PureOperator> MachinePureOperatorTest; 211 typedef MachineOperatorTestWithParam<PureOperator> MachinePureOperatorTest;
213 212
214 } // namespace 213 } // namespace
215 214
216 215
217 TEST_P(MachinePureOperatorTest, InstancesAreGloballyShared) { 216 TEST_P(MachinePureOperatorTest, InstancesAreGloballyShared) {
218 const PureOperator& pop = GetParam(); 217 const PureOperator& pop = GetParam();
219 MachineOperatorBuilder machine1(type()); 218 MachineOperatorBuilder machine1(type());
220 MachineOperatorBuilder machine2(type()); 219 MachineOperatorBuilder machine2(type());
221 EXPECT_EQ((machine1.*pop.constructor)(), (machine2.*pop.constructor)()); 220 EXPECT_EQ((machine1.*pop.constructor)(), (machine2.*pop.constructor)());
222 } 221 }
223 222
224 223
225 TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) { 224 TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) {
226 MachineOperatorBuilder machine(type()); 225 MachineOperatorBuilder machine(type());
227 const PureOperator& pop = GetParam(); 226 const PureOperator& pop = GetParam();
228 const Operator* op = (machine.*pop.constructor)(); 227 const Operator* op = (machine.*pop.constructor)();
229 228
230 EXPECT_EQ(pop.value_input_count, OperatorProperties::GetValueInputCount(op)); 229 EXPECT_EQ(pop.value_input_count, OperatorProperties::GetValueInputCount(op));
231 EXPECT_EQ(0, OperatorProperties::GetEffectInputCount(op)); 230 EXPECT_EQ(0, OperatorProperties::GetEffectInputCount(op));
232 EXPECT_EQ(0, OperatorProperties::GetControlInputCount(op)); 231 EXPECT_EQ(pop.control_input_count,
233 EXPECT_EQ(pop.value_input_count, OperatorProperties::GetTotalInputCount(op)); 232 OperatorProperties::GetControlInputCount(op));
233 EXPECT_EQ(pop.value_input_count + pop.control_input_count,
234 OperatorProperties::GetTotalInputCount(op));
234 235
235 EXPECT_EQ(pop.value_output_count, 236 EXPECT_EQ(pop.value_output_count,
236 OperatorProperties::GetValueOutputCount(op)); 237 OperatorProperties::GetValueOutputCount(op));
237 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 238 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op));
238 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 239 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
239 } 240 }
240 241
241 242
242 TEST_P(MachinePureOperatorTest, MarkedAsPure) { 243 TEST_P(MachinePureOperatorTest, MarkedAsPure) {
243 MachineOperatorBuilder machine(type()); 244 MachineOperatorBuilder machine(type());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_EQ(machine.Uint64Div(), machine.UintDiv()); 307 EXPECT_EQ(machine.Uint64Div(), machine.UintDiv());
307 EXPECT_EQ(machine.Int64Mod(), machine.IntMod()); 308 EXPECT_EQ(machine.Int64Mod(), machine.IntMod());
308 EXPECT_EQ(machine.Uint64Mod(), machine.UintMod()); 309 EXPECT_EQ(machine.Uint64Mod(), machine.UintMod());
309 EXPECT_EQ(machine.Int64LessThan(), machine.IntLessThan()); 310 EXPECT_EQ(machine.Int64LessThan(), machine.IntLessThan());
310 EXPECT_EQ(machine.Int64LessThanOrEqual(), machine.IntLessThanOrEqual()); 311 EXPECT_EQ(machine.Int64LessThanOrEqual(), machine.IntLessThanOrEqual());
311 } 312 }
312 313
313 } // namespace compiler 314 } // namespace compiler
314 } // namespace internal 315 } // namespace internal
315 } // namespace v8 316 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698