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

Side by Side Diff: test/cctest/compiler/test-instruction-selector-arm.cc

Issue 436593002: [turbofan] Add Int32AddWithOverflow machine operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add more tests. 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 | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | 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 <list> 5 #include <list>
6 6
7 #include "test/cctest/compiler/instruction-selector-tester.h" 7 #include "test/cctest/compiler/instruction-selector-tester.h"
8 #include "test/cctest/compiler/value-helper.h" 8 #include "test/cctest/compiler/value-helper.h"
9 9
10 using namespace v8::internal; 10 using namespace v8::internal;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 CHECK_EQ(1, m.code.size()); 218 CHECK_EQ(1, m.code.size());
219 CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); 219 CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode());
220 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); 220 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
221 } 221 }
222 } 222 }
223 } 223 }
224 } 224 }
225 } 225 }
226 226
227 227
228 TEST(InstructionSelectorInt32AddWithOverflowP) {
229 {
230 InstructionSelectorTester m;
231 Node* ovf;
232 m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1), NULL, &ovf);
233 m.Return(ovf);
234 m.SelectInstructions();
235 CHECK_EQ(1, m.code.size());
236 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
237 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
238 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
239 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
240 CHECK_EQ(2, m.code[0]->InputCount());
241 CHECK_EQ(1, m.code[0]->OutputCount());
242 }
243 {
244 InstructionSelectorTester m;
245 Node* val;
246 m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1), &val, NULL);
247 m.Return(val);
248 m.SelectInstructions();
249 CHECK_EQ(1, m.code.size());
250 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
251 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
252 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
253 CHECK_EQ(2, m.code[0]->InputCount());
254 CHECK_EQ(1, m.code[0]->OutputCount());
255 }
256 {
257 InstructionSelectorTester m;
258 Node* val, *ovf;
259 m.Int32AddWithOverflow(m.Parameter(0), m.Parameter(1), &val, &ovf);
260 m.Return(m.Word32Equal(val, ovf));
261 m.SelectInstructions();
262 CHECK_LE(1, m.code.size());
263 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
264 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
265 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
266 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
267 CHECK_EQ(2, m.code[0]->InputCount());
268 CHECK_EQ(2, m.code[0]->OutputCount());
269 }
270 }
271
272
273 TEST(InstructionSelectorInt32AddWithOverflowImm) {
274 Immediates immediates;
275 for (Immediates::const_iterator i = immediates.begin(); i != immediates.end();
276 ++i) {
277 int32_t imm = *i;
278 {
279 InstructionSelectorTester m;
280 Node* ovf;
281 m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm), NULL, &ovf);
282 m.Return(ovf);
283 m.SelectInstructions();
284 CHECK_EQ(1, m.code.size());
285 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
286 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
287 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
288 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
289 CHECK_EQ(2, m.code[0]->InputCount());
290 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
291 CHECK_EQ(1, m.code[0]->OutputCount());
292 }
293 {
294 InstructionSelectorTester m;
295 Node* ovf;
296 m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0), NULL, &ovf);
297 m.Return(ovf);
298 m.SelectInstructions();
299 CHECK_EQ(1, m.code.size());
300 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
301 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
302 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
303 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
304 CHECK_EQ(2, m.code[0]->InputCount());
305 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
306 CHECK_EQ(1, m.code[0]->OutputCount());
307 }
308 {
309 InstructionSelectorTester m;
310 Node* val;
311 m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm), &val, NULL);
312 m.Return(val);
313 m.SelectInstructions();
314 CHECK_EQ(1, m.code.size());
315 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
316 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
317 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
318 CHECK_EQ(2, m.code[0]->InputCount());
319 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
320 CHECK_EQ(1, m.code[0]->OutputCount());
321 }
322 {
323 InstructionSelectorTester m;
324 Node* val;
325 m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0), &val, NULL);
326 m.Return(val);
327 m.SelectInstructions();
328 CHECK_EQ(1, m.code.size());
329 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
330 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
331 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
332 CHECK_EQ(2, m.code[0]->InputCount());
333 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
334 CHECK_EQ(1, m.code[0]->OutputCount());
335 }
336 {
337 InstructionSelectorTester m;
338 Node* val, *ovf;
339 m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(imm), &val, &ovf);
340 m.Return(m.Word32Equal(val, ovf));
341 m.SelectInstructions();
342 CHECK_LE(1, m.code.size());
343 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
344 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
345 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
346 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
347 CHECK_EQ(2, m.code[0]->InputCount());
348 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
349 CHECK_EQ(2, m.code[0]->OutputCount());
350 }
351 {
352 InstructionSelectorTester m;
353 Node* val, *ovf;
354 m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0), &val, &ovf);
355 m.Return(m.Word32Equal(val, ovf));
356 m.SelectInstructions();
357 CHECK_LE(1, m.code.size());
358 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
359 CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode());
360 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
361 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
362 CHECK_EQ(2, m.code[0]->InputCount());
363 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1)));
364 CHECK_EQ(2, m.code[0]->OutputCount());
365 }
366 }
367 }
368
369
370 TEST(InstructionSelectorInt32AddWithOverflowAndShiftP) {
371 Shifts shifts;
372 for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) {
373 Shift shift = *i;
374 {
375 InstructionSelectorTester m;
376 Node* ovf;
377 m.Int32AddWithOverflow(
378 m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)),
379 NULL, &ovf);
380 m.Return(ovf);
381 m.SelectInstructions();
382 CHECK_EQ(1, m.code.size());
383 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
384 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
385 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
386 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
387 CHECK_EQ(3, m.code[0]->InputCount());
388 CHECK_EQ(1, m.code[0]->OutputCount());
389 }
390 {
391 InstructionSelectorTester m;
392 Node* ovf;
393 m.Int32AddWithOverflow(
394 m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), m.Parameter(2),
395 NULL, &ovf);
396 m.Return(ovf);
397 m.SelectInstructions();
398 CHECK_EQ(1, m.code.size());
399 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
400 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
401 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
402 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
403 CHECK_EQ(3, m.code[0]->InputCount());
404 CHECK_EQ(1, m.code[0]->OutputCount());
405 }
406 {
407 InstructionSelectorTester m;
408 Node* val;
409 m.Int32AddWithOverflow(
410 m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)),
411 &val, NULL);
412 m.Return(val);
413 m.SelectInstructions();
414 CHECK_EQ(1, m.code.size());
415 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
416 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
417 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
418 CHECK_EQ(3, m.code[0]->InputCount());
419 CHECK_EQ(1, m.code[0]->OutputCount());
420 }
421 {
422 InstructionSelectorTester m;
423 Node* val;
424 m.Int32AddWithOverflow(
425 m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), m.Parameter(2),
426 &val, NULL);
427 m.Return(val);
428 m.SelectInstructions();
429 CHECK_EQ(1, m.code.size());
430 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
431 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
432 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
433 CHECK_EQ(3, m.code[0]->InputCount());
434 CHECK_EQ(1, m.code[0]->OutputCount());
435 }
436 {
437 InstructionSelectorTester m;
438 Node* val, *ovf;
439 m.Int32AddWithOverflow(
440 m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)),
441 &val, &ovf);
442 m.Return(m.Word32Equal(val, ovf));
443 m.SelectInstructions();
444 CHECK_LE(1, m.code.size());
445 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
446 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
447 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
448 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
449 CHECK_EQ(3, m.code[0]->InputCount());
450 CHECK_EQ(2, m.code[0]->OutputCount());
451 }
452 {
453 InstructionSelectorTester m;
454 Node* val, *ovf;
455 m.Int32AddWithOverflow(
456 m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), m.Parameter(2),
457 &val, &ovf);
458 m.Return(m.Word32Equal(val, ovf));
459 m.SelectInstructions();
460 CHECK_LE(1, m.code.size());
461 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
462 CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode());
463 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
464 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
465 CHECK_EQ(3, m.code[0]->InputCount());
466 CHECK_EQ(2, m.code[0]->OutputCount());
467 }
468 }
469 }
470
471
472 TEST(InstructionSelectorInt32AddWithOverflowAndShiftImm) {
473 Shifts shifts;
474 for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) {
475 Shift shift = *i;
476 for (int32_t imm = shift.i_low; imm <= shift.i_high; ++imm) {
477 {
478 InstructionSelectorTester m;
479 Node* ovf;
480 m.Int32AddWithOverflow(
481 m.Parameter(0),
482 m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm)), NULL,
483 &ovf);
484 m.Return(ovf);
485 m.SelectInstructions();
486 CHECK_EQ(1, m.code.size());
487 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
488 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
489 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
490 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
491 CHECK_EQ(3, m.code[0]->InputCount());
492 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
493 CHECK_EQ(1, m.code[0]->OutputCount());
494 }
495 {
496 InstructionSelectorTester m;
497 Node* ovf;
498 m.Int32AddWithOverflow(
499 m.NewNode(shift.op, m.Parameter(0), m.Int32Constant(imm)),
500 m.Parameter(1), NULL, &ovf);
501 m.Return(ovf);
502 m.SelectInstructions();
503 CHECK_EQ(1, m.code.size());
504 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
505 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
506 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
507 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
508 CHECK_EQ(3, m.code[0]->InputCount());
509 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
510 CHECK_EQ(1, m.code[0]->OutputCount());
511 }
512 {
513 InstructionSelectorTester m;
514 Node* val;
515 m.Int32AddWithOverflow(
516 m.Parameter(0),
517 m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm)), &val,
518 NULL);
519 m.Return(val);
520 m.SelectInstructions();
521 CHECK_EQ(1, m.code.size());
522 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
523 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
524 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
525 CHECK_EQ(3, m.code[0]->InputCount());
526 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
527 CHECK_EQ(1, m.code[0]->OutputCount());
528 }
529 {
530 InstructionSelectorTester m;
531 Node* val;
532 m.Int32AddWithOverflow(
533 m.NewNode(shift.op, m.Parameter(0), m.Int32Constant(imm)),
534 m.Parameter(1), &val, NULL);
535 m.Return(val);
536 m.SelectInstructions();
537 CHECK_EQ(1, m.code.size());
538 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
539 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
540 CHECK_EQ(kFlags_none, m.code[0]->flags_mode());
541 CHECK_EQ(3, m.code[0]->InputCount());
542 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
543 CHECK_EQ(1, m.code[0]->OutputCount());
544 }
545 {
546 InstructionSelectorTester m;
547 Node* val, *ovf;
548 m.Int32AddWithOverflow(
549 m.Parameter(0),
550 m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm)), &val,
551 &ovf);
552 m.Return(m.Word32Equal(val, ovf));
553 m.SelectInstructions();
554 CHECK_LE(1, m.code.size());
555 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
556 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
557 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
558 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
559 CHECK_EQ(3, m.code[0]->InputCount());
560 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
561 CHECK_EQ(2, m.code[0]->OutputCount());
562 }
563 {
564 InstructionSelectorTester m;
565 Node* val, *ovf;
566 m.Int32AddWithOverflow(
567 m.NewNode(shift.op, m.Parameter(0), m.Int32Constant(imm)),
568 m.Parameter(1), &val, &ovf);
569 m.Return(m.Word32Equal(val, ovf));
570 m.SelectInstructions();
571 CHECK_LE(1, m.code.size());
572 CHECK_EQ(kArmAdd, m.code[0]->arch_opcode());
573 CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode());
574 CHECK_EQ(kFlags_set, m.code[0]->flags_mode());
575 CHECK_EQ(kOverflow, m.code[0]->flags_condition());
576 CHECK_EQ(3, m.code[0]->InputCount());
577 CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2)));
578 CHECK_EQ(2, m.code[0]->OutputCount());
579 }
580 }
581 }
582 }
583
584
228 TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1P) { 585 TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1P) {
229 { 586 {
230 InstructionSelectorTester m; 587 InstructionSelectorTester m;
231 m.Return(m.Word32And(m.Parameter(0), 588 m.Return(m.Word32And(m.Parameter(0),
232 m.Word32Xor(m.Int32Constant(-1), m.Parameter(1)))); 589 m.Word32Xor(m.Int32Constant(-1), m.Parameter(1))));
233 m.SelectInstructions(); 590 m.SelectInstructions();
234 CHECK_EQ(1, m.code.size()); 591 CHECK_EQ(1, m.code.size());
235 CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); 592 CHECK_EQ(kArmBic, m.code[0]->arch_opcode());
236 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); 593 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
237 } 594 }
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 m.Return(m.Int32Constant(0)); 1659 m.Return(m.Int32Constant(0));
1303 m.SelectInstructions(); 1660 m.SelectInstructions();
1304 CHECK_EQ(1, m.code.size()); 1661 CHECK_EQ(1, m.code.size());
1305 CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); 1662 CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode());
1306 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); 1663 CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode());
1307 CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); 1664 CHECK_EQ(kFlags_branch, m.code[0]->flags_mode());
1308 CHECK_EQ(kEqual, m.code[0]->flags_condition()); 1665 CHECK_EQ(kEqual, m.code[0]->flags_condition());
1309 } 1666 }
1310 } 1667 }
1311 } 1668 }
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698