OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 IsInt32Constant(low_word_value(2)), | 294 IsInt32Constant(low_word_value(2)), |
295 IsInt32Constant(high_word_value(2)), start(), start()), | 295 IsInt32Constant(high_word_value(2)), start(), start()), |
296 start(), start())); | 296 start(), start())); |
297 | 297 |
298 CompareCallDescriptors( | 298 CompareCallDescriptors( |
299 OpParameter<const CallDescriptor*>( | 299 OpParameter<const CallDescriptor*>( |
300 graph()->end()->InputAt(1)->InputAt(0)), | 300 graph()->end()->InputAt(1)->InputAt(0)), |
301 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); | 301 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); |
302 } | 302 } |
303 | 303 |
304 // todo(ahaas): I added a list of missing instructions here to make merging | |
305 // easier when I do them one by one. | |
306 // kExprI64Add: | |
307 TEST_F(Int64LoweringTest, Int64Add) { | 304 TEST_F(Int64LoweringTest, Int64Add) { |
308 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), | 305 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), |
309 Int64Constant(value(1))), | 306 Int64Constant(value(1))), |
310 MachineRepresentation::kWord64); | 307 MachineRepresentation::kWord64); |
311 | 308 |
312 Capture<Node*> add; | 309 Capture<Node*> add; |
313 Matcher<Node*> add_matcher = IsInt32PairAdd( | 310 Matcher<Node*> add_matcher = IsInt32PairAdd( |
314 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 311 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
315 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); | 312 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); |
316 | 313 |
317 EXPECT_THAT(graph()->end()->InputAt(1), | 314 EXPECT_THAT(graph()->end()->InputAt(1), |
318 IsReturn2(IsProjection(0, AllOf(CaptureEq(&add), add_matcher)), | 315 IsReturn2(IsProjection(0, AllOf(CaptureEq(&add), add_matcher)), |
319 IsProjection(1, AllOf(CaptureEq(&add), add_matcher)), | 316 IsProjection(1, AllOf(CaptureEq(&add), add_matcher)), |
320 start(), start())); | 317 start(), start())); |
321 } | 318 } |
322 // kExprI64Sub: | 319 |
323 TEST_F(Int64LoweringTest, Int64Sub) { | 320 TEST_F(Int64LoweringTest, Int64Sub) { |
324 LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)), | 321 LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)), |
325 Int64Constant(value(1))), | 322 Int64Constant(value(1))), |
326 MachineRepresentation::kWord64); | 323 MachineRepresentation::kWord64); |
327 | 324 |
328 Capture<Node*> sub; | 325 Capture<Node*> sub; |
329 Matcher<Node*> sub_matcher = IsInt32PairSub( | 326 Matcher<Node*> sub_matcher = IsInt32PairSub( |
330 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 327 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
331 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); | 328 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); |
332 | 329 |
333 EXPECT_THAT(graph()->end()->InputAt(1), | 330 EXPECT_THAT(graph()->end()->InputAt(1), |
334 IsReturn2(IsProjection(0, AllOf(CaptureEq(&sub), sub_matcher)), | 331 IsReturn2(IsProjection(0, AllOf(CaptureEq(&sub), sub_matcher)), |
335 IsProjection(1, AllOf(CaptureEq(&sub), sub_matcher)), | 332 IsProjection(1, AllOf(CaptureEq(&sub), sub_matcher)), |
336 start(), start())); | 333 start(), start())); |
337 } | 334 } |
338 | 335 |
339 // kExprI64Mul: | |
340 TEST_F(Int64LoweringTest, Int64Mul) { | 336 TEST_F(Int64LoweringTest, Int64Mul) { |
341 LowerGraph(graph()->NewNode(machine()->Int64Mul(), Int64Constant(value(0)), | 337 LowerGraph(graph()->NewNode(machine()->Int64Mul(), Int64Constant(value(0)), |
342 Int64Constant(value(1))), | 338 Int64Constant(value(1))), |
343 MachineRepresentation::kWord64); | 339 MachineRepresentation::kWord64); |
344 | 340 |
345 Capture<Node*> mul_capture; | 341 Capture<Node*> mul_capture; |
346 Matcher<Node*> mul_matcher = IsInt32PairMul( | 342 Matcher<Node*> mul_matcher = IsInt32PairMul( |
347 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 343 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
348 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); | 344 IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1))); |
349 | 345 |
350 EXPECT_THAT( | 346 EXPECT_THAT( |
351 graph()->end()->InputAt(1), | 347 graph()->end()->InputAt(1), |
352 IsReturn2(IsProjection(0, AllOf(CaptureEq(&mul_capture), mul_matcher)), | 348 IsReturn2(IsProjection(0, AllOf(CaptureEq(&mul_capture), mul_matcher)), |
353 IsProjection(1, AllOf(CaptureEq(&mul_capture), mul_matcher)), | 349 IsProjection(1, AllOf(CaptureEq(&mul_capture), mul_matcher)), |
354 start(), start())); | 350 start(), start())); |
355 } | 351 } |
356 | 352 |
357 // kExprI64DivS: | |
358 // kExprI64DivU: | |
359 // kExprI64RemS: | |
360 // kExprI64RemU: | |
361 // kExprI64Ior: | |
362 TEST_F(Int64LoweringTest, Int64Ior) { | 353 TEST_F(Int64LoweringTest, Int64Ior) { |
363 LowerGraph(graph()->NewNode(machine()->Word64Or(), Int64Constant(value(0)), | 354 LowerGraph(graph()->NewNode(machine()->Word64Or(), Int64Constant(value(0)), |
364 Int64Constant(value(1))), | 355 Int64Constant(value(1))), |
365 MachineRepresentation::kWord64); | 356 MachineRepresentation::kWord64); |
366 EXPECT_THAT(graph()->end()->InputAt(1), | 357 EXPECT_THAT(graph()->end()->InputAt(1), |
367 IsReturn2(IsWord32Or(IsInt32Constant(low_word_value(0)), | 358 IsReturn2(IsWord32Or(IsInt32Constant(low_word_value(0)), |
368 IsInt32Constant(low_word_value(1))), | 359 IsInt32Constant(low_word_value(1))), |
369 IsWord32Or(IsInt32Constant(high_word_value(0)), | 360 IsWord32Or(IsInt32Constant(high_word_value(0)), |
370 IsInt32Constant(high_word_value(1))), | 361 IsInt32Constant(high_word_value(1))), |
371 start(), start())); | 362 start(), start())); |
372 } | 363 } |
373 | 364 |
374 // kExprI64Xor: | |
375 TEST_F(Int64LoweringTest, Int64Xor) { | 365 TEST_F(Int64LoweringTest, Int64Xor) { |
376 LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)), | 366 LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)), |
377 Int64Constant(value(1))), | 367 Int64Constant(value(1))), |
378 MachineRepresentation::kWord64); | 368 MachineRepresentation::kWord64); |
379 EXPECT_THAT(graph()->end()->InputAt(1), | 369 EXPECT_THAT(graph()->end()->InputAt(1), |
380 IsReturn2(IsWord32Xor(IsInt32Constant(low_word_value(0)), | 370 IsReturn2(IsWord32Xor(IsInt32Constant(low_word_value(0)), |
381 IsInt32Constant(low_word_value(1))), | 371 IsInt32Constant(low_word_value(1))), |
382 IsWord32Xor(IsInt32Constant(high_word_value(0)), | 372 IsWord32Xor(IsInt32Constant(high_word_value(0)), |
383 IsInt32Constant(high_word_value(1))), | 373 IsInt32Constant(high_word_value(1))), |
384 start(), start())); | 374 start(), start())); |
385 } | 375 } |
386 // kExprI64Shl: | 376 |
387 TEST_F(Int64LoweringTest, Int64Shl) { | 377 TEST_F(Int64LoweringTest, Int64Shl) { |
388 LowerGraph(graph()->NewNode(machine()->Word64Shl(), Int64Constant(value(0)), | 378 LowerGraph(graph()->NewNode(machine()->Word64Shl(), Int64Constant(value(0)), |
389 Int64Constant(value(1))), | 379 Int64Constant(value(1))), |
390 MachineRepresentation::kWord64); | 380 MachineRepresentation::kWord64); |
391 | 381 |
392 Capture<Node*> shl; | 382 Capture<Node*> shl; |
393 Matcher<Node*> shl_matcher = IsWord32PairShl( | 383 Matcher<Node*> shl_matcher = IsWord32PairShl( |
394 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 384 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
395 IsInt32Constant(low_word_value(1))); | 385 IsInt32Constant(low_word_value(1))); |
396 | 386 |
397 EXPECT_THAT(graph()->end()->InputAt(1), | 387 EXPECT_THAT(graph()->end()->InputAt(1), |
398 IsReturn2(IsProjection(0, AllOf(CaptureEq(&shl), shl_matcher)), | 388 IsReturn2(IsProjection(0, AllOf(CaptureEq(&shl), shl_matcher)), |
399 IsProjection(1, AllOf(CaptureEq(&shl), shl_matcher)), | 389 IsProjection(1, AllOf(CaptureEq(&shl), shl_matcher)), |
400 start(), start())); | 390 start(), start())); |
401 } | 391 } |
402 // kExprI64ShrU: | 392 |
403 TEST_F(Int64LoweringTest, Int64ShrU) { | 393 TEST_F(Int64LoweringTest, Int64ShrU) { |
404 LowerGraph(graph()->NewNode(machine()->Word64Shr(), Int64Constant(value(0)), | 394 LowerGraph(graph()->NewNode(machine()->Word64Shr(), Int64Constant(value(0)), |
405 Int64Constant(value(1))), | 395 Int64Constant(value(1))), |
406 MachineRepresentation::kWord64); | 396 MachineRepresentation::kWord64); |
407 | 397 |
408 Capture<Node*> shr; | 398 Capture<Node*> shr; |
409 Matcher<Node*> shr_matcher = IsWord32PairShr( | 399 Matcher<Node*> shr_matcher = IsWord32PairShr( |
410 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 400 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
411 IsInt32Constant(low_word_value(1))); | 401 IsInt32Constant(low_word_value(1))); |
412 | 402 |
413 EXPECT_THAT(graph()->end()->InputAt(1), | 403 EXPECT_THAT(graph()->end()->InputAt(1), |
414 IsReturn2(IsProjection(0, AllOf(CaptureEq(&shr), shr_matcher)), | 404 IsReturn2(IsProjection(0, AllOf(CaptureEq(&shr), shr_matcher)), |
415 IsProjection(1, AllOf(CaptureEq(&shr), shr_matcher)), | 405 IsProjection(1, AllOf(CaptureEq(&shr), shr_matcher)), |
416 start(), start())); | 406 start(), start())); |
417 } | 407 } |
418 // kExprI64ShrS: | 408 |
419 TEST_F(Int64LoweringTest, Int64ShrS) { | 409 TEST_F(Int64LoweringTest, Int64ShrS) { |
420 LowerGraph(graph()->NewNode(machine()->Word64Sar(), Int64Constant(value(0)), | 410 LowerGraph(graph()->NewNode(machine()->Word64Sar(), Int64Constant(value(0)), |
421 Int64Constant(value(1))), | 411 Int64Constant(value(1))), |
422 MachineRepresentation::kWord64); | 412 MachineRepresentation::kWord64); |
423 | 413 |
424 Capture<Node*> sar; | 414 Capture<Node*> sar; |
425 Matcher<Node*> sar_matcher = IsWord32PairSar( | 415 Matcher<Node*> sar_matcher = IsWord32PairSar( |
426 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 416 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
427 IsInt32Constant(low_word_value(1))); | 417 IsInt32Constant(low_word_value(1))); |
428 | 418 |
429 EXPECT_THAT(graph()->end()->InputAt(1), | 419 EXPECT_THAT(graph()->end()->InputAt(1), |
430 IsReturn2(IsProjection(0, AllOf(CaptureEq(&sar), sar_matcher)), | 420 IsReturn2(IsProjection(0, AllOf(CaptureEq(&sar), sar_matcher)), |
431 IsProjection(1, AllOf(CaptureEq(&sar), sar_matcher)), | 421 IsProjection(1, AllOf(CaptureEq(&sar), sar_matcher)), |
432 start(), start())); | 422 start(), start())); |
433 } | 423 } |
434 // kExprI64Eq: | 424 |
435 TEST_F(Int64LoweringTest, Int64Eq) { | 425 TEST_F(Int64LoweringTest, Int64Eq) { |
436 LowerGraph(graph()->NewNode(machine()->Word64Equal(), Int64Constant(value(0)), | 426 LowerGraph(graph()->NewNode(machine()->Word64Equal(), Int64Constant(value(0)), |
437 Int64Constant(value(1))), | 427 Int64Constant(value(1))), |
438 MachineRepresentation::kWord32); | 428 MachineRepresentation::kWord32); |
439 EXPECT_THAT( | 429 EXPECT_THAT( |
440 graph()->end()->InputAt(1), | 430 graph()->end()->InputAt(1), |
441 IsReturn(IsWord32Equal( | 431 IsReturn(IsWord32Equal( |
442 IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)), | 432 IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)), |
443 IsInt32Constant(low_word_value(1))), | 433 IsInt32Constant(low_word_value(1))), |
444 IsWord32Xor(IsInt32Constant(high_word_value(0)), | 434 IsWord32Xor(IsInt32Constant(high_word_value(0)), |
445 IsInt32Constant(high_word_value(1)))), | 435 IsInt32Constant(high_word_value(1)))), |
446 IsInt32Constant(0)), | 436 IsInt32Constant(0)), |
447 start(), start())); | 437 start(), start())); |
448 } | 438 } |
449 | 439 |
450 // kExprI64LtS: | |
451 TEST_F(Int64LoweringTest, Int64LtS) { | 440 TEST_F(Int64LoweringTest, Int64LtS) { |
452 TestComparison(machine()->Int64LessThan(), IsInt32LessThan, IsUint32LessThan); | 441 TestComparison(machine()->Int64LessThan(), IsInt32LessThan, IsUint32LessThan); |
453 } | 442 } |
454 // kExprI64LeS: | 443 |
455 TEST_F(Int64LoweringTest, Int64LeS) { | 444 TEST_F(Int64LoweringTest, Int64LeS) { |
456 TestComparison(machine()->Int64LessThanOrEqual(), IsInt32LessThan, | 445 TestComparison(machine()->Int64LessThanOrEqual(), IsInt32LessThan, |
457 IsUint32LessThanOrEqual); | 446 IsUint32LessThanOrEqual); |
458 } | 447 } |
459 // kExprI64LtU: | 448 |
460 TEST_F(Int64LoweringTest, Int64LtU) { | 449 TEST_F(Int64LoweringTest, Int64LtU) { |
461 TestComparison(machine()->Uint64LessThan(), IsUint32LessThan, | 450 TestComparison(machine()->Uint64LessThan(), IsUint32LessThan, |
462 IsUint32LessThan); | 451 IsUint32LessThan); |
463 } | 452 } |
464 // kExprI64LeU: | 453 |
465 TEST_F(Int64LoweringTest, Int64LeU) { | 454 TEST_F(Int64LoweringTest, Int64LeU) { |
466 TestComparison(machine()->Uint64LessThanOrEqual(), IsUint32LessThan, | 455 TestComparison(machine()->Uint64LessThanOrEqual(), IsUint32LessThan, |
467 IsUint32LessThanOrEqual); | 456 IsUint32LessThanOrEqual); |
468 } | 457 } |
469 | 458 |
470 // kExprI32ConvertI64: | |
471 TEST_F(Int64LoweringTest, I32ConvertI64) { | 459 TEST_F(Int64LoweringTest, I32ConvertI64) { |
472 LowerGraph(graph()->NewNode(machine()->TruncateInt64ToInt32(), | 460 LowerGraph(graph()->NewNode(machine()->TruncateInt64ToInt32(), |
473 Int64Constant(value(0))), | 461 Int64Constant(value(0))), |
474 MachineRepresentation::kWord32); | 462 MachineRepresentation::kWord32); |
475 EXPECT_THAT(graph()->end()->InputAt(1), | 463 EXPECT_THAT(graph()->end()->InputAt(1), |
476 IsReturn(IsInt32Constant(low_word_value(0)), start(), start())); | 464 IsReturn(IsInt32Constant(low_word_value(0)), start(), start())); |
477 } | 465 } |
478 // kExprI64SConvertI32: | 466 |
479 TEST_F(Int64LoweringTest, I64SConvertI32) { | 467 TEST_F(Int64LoweringTest, I64SConvertI32) { |
480 LowerGraph(graph()->NewNode(machine()->ChangeInt32ToInt64(), | 468 LowerGraph(graph()->NewNode(machine()->ChangeInt32ToInt64(), |
481 Int32Constant(low_word_value(0))), | 469 Int32Constant(low_word_value(0))), |
482 MachineRepresentation::kWord64); | 470 MachineRepresentation::kWord64); |
483 | 471 |
484 EXPECT_THAT(graph()->end()->InputAt(1), | 472 EXPECT_THAT(graph()->end()->InputAt(1), |
485 IsReturn2(IsInt32Constant(low_word_value(0)), | 473 IsReturn2(IsInt32Constant(low_word_value(0)), |
486 IsWord32Sar(IsInt32Constant(low_word_value(0)), | 474 IsWord32Sar(IsInt32Constant(low_word_value(0)), |
487 IsInt32Constant(31)), | 475 IsInt32Constant(31)), |
488 start(), start())); | 476 start(), start())); |
489 } | 477 } |
490 | 478 |
491 TEST_F(Int64LoweringTest, I64SConvertI32_2) { | 479 TEST_F(Int64LoweringTest, I64SConvertI32_2) { |
492 LowerGraph( | 480 LowerGraph( |
493 graph()->NewNode(machine()->ChangeInt32ToInt64(), | 481 graph()->NewNode(machine()->ChangeInt32ToInt64(), |
494 graph()->NewNode(machine()->TruncateInt64ToInt32(), | 482 graph()->NewNode(machine()->TruncateInt64ToInt32(), |
495 Int64Constant(value(0)))), | 483 Int64Constant(value(0)))), |
496 MachineRepresentation::kWord64); | 484 MachineRepresentation::kWord64); |
497 | 485 |
498 EXPECT_THAT(graph()->end()->InputAt(1), | 486 EXPECT_THAT(graph()->end()->InputAt(1), |
499 IsReturn2(IsInt32Constant(low_word_value(0)), | 487 IsReturn2(IsInt32Constant(low_word_value(0)), |
500 IsWord32Sar(IsInt32Constant(low_word_value(0)), | 488 IsWord32Sar(IsInt32Constant(low_word_value(0)), |
501 IsInt32Constant(31)), | 489 IsInt32Constant(31)), |
502 start(), start())); | 490 start(), start())); |
503 } | 491 } |
504 // kExprI64UConvertI32: | 492 |
505 TEST_F(Int64LoweringTest, I64UConvertI32) { | 493 TEST_F(Int64LoweringTest, I64UConvertI32) { |
506 LowerGraph(graph()->NewNode(machine()->ChangeUint32ToUint64(), | 494 LowerGraph(graph()->NewNode(machine()->ChangeUint32ToUint64(), |
507 Int32Constant(low_word_value(0))), | 495 Int32Constant(low_word_value(0))), |
508 MachineRepresentation::kWord64); | 496 MachineRepresentation::kWord64); |
509 | 497 |
510 EXPECT_THAT(graph()->end()->InputAt(1), | 498 EXPECT_THAT(graph()->end()->InputAt(1), |
511 IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0), | 499 IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0), |
512 start(), start())); | 500 start(), start())); |
513 } | 501 } |
514 | 502 |
515 TEST_F(Int64LoweringTest, I64UConvertI32_2) { | 503 TEST_F(Int64LoweringTest, I64UConvertI32_2) { |
516 LowerGraph( | 504 LowerGraph( |
517 graph()->NewNode(machine()->ChangeUint32ToUint64(), | 505 graph()->NewNode(machine()->ChangeUint32ToUint64(), |
518 graph()->NewNode(machine()->TruncateInt64ToInt32(), | 506 graph()->NewNode(machine()->TruncateInt64ToInt32(), |
519 Int64Constant(value(0)))), | 507 Int64Constant(value(0)))), |
520 MachineRepresentation::kWord64); | 508 MachineRepresentation::kWord64); |
521 | 509 |
522 EXPECT_THAT(graph()->end()->InputAt(1), | 510 EXPECT_THAT(graph()->end()->InputAt(1), |
523 IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0), | 511 IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0), |
524 start(), start())); | 512 start(), start())); |
525 } | 513 } |
526 // kExprF64ReinterpretI64: | 514 |
527 TEST_F(Int64LoweringTest, F64ReinterpretI64) { | 515 TEST_F(Int64LoweringTest, F64ReinterpretI64) { |
528 LowerGraph(graph()->NewNode(machine()->BitcastInt64ToFloat64(), | 516 LowerGraph(graph()->NewNode(machine()->BitcastInt64ToFloat64(), |
529 Int64Constant(value(0))), | 517 Int64Constant(value(0))), |
530 MachineRepresentation::kFloat64); | 518 MachineRepresentation::kFloat64); |
531 | 519 |
532 Capture<Node*> stack_slot_capture; | 520 Capture<Node*> stack_slot_capture; |
533 Matcher<Node*> stack_slot_matcher = | 521 Matcher<Node*> stack_slot_matcher = |
534 IsStackSlot(MachineRepresentation::kWord64); | 522 IsStackSlot(MachineRepresentation::kWord64); |
535 | 523 |
536 Capture<Node*> store_capture; | 524 Capture<Node*> store_capture; |
(...skipping 10 matching lines...) Expand all Loading... |
547 start()); | 535 start()); |
548 | 536 |
549 EXPECT_THAT( | 537 EXPECT_THAT( |
550 graph()->end()->InputAt(1), | 538 graph()->end()->InputAt(1), |
551 IsReturn(IsLoad(MachineType::Float64(), | 539 IsReturn(IsLoad(MachineType::Float64(), |
552 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), | 540 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), |
553 IsInt32Constant(0), | 541 IsInt32Constant(0), |
554 AllOf(CaptureEq(&store_capture), store_matcher), start()), | 542 AllOf(CaptureEq(&store_capture), store_matcher), start()), |
555 start(), start())); | 543 start(), start())); |
556 } | 544 } |
557 // kExprI64ReinterpretF64: | 545 |
558 TEST_F(Int64LoweringTest, I64ReinterpretF64) { | 546 TEST_F(Int64LoweringTest, I64ReinterpretF64) { |
559 LowerGraph(graph()->NewNode(machine()->BitcastFloat64ToInt64(), | 547 LowerGraph(graph()->NewNode(machine()->BitcastFloat64ToInt64(), |
560 Float64Constant(bit_cast<double>(value(0)))), | 548 Float64Constant(bit_cast<double>(value(0)))), |
561 MachineRepresentation::kWord64); | 549 MachineRepresentation::kWord64); |
562 | 550 |
563 Capture<Node*> stack_slot; | 551 Capture<Node*> stack_slot; |
564 Matcher<Node*> stack_slot_matcher = | 552 Matcher<Node*> stack_slot_matcher = |
565 IsStackSlot(MachineRepresentation::kWord64); | 553 IsStackSlot(MachineRepresentation::kWord64); |
566 | 554 |
567 Capture<Node*> store; | 555 Capture<Node*> store; |
568 Matcher<Node*> store_matcher = IsStore( | 556 Matcher<Node*> store_matcher = IsStore( |
569 StoreRepresentation(MachineRepresentation::kFloat64, | 557 StoreRepresentation(MachineRepresentation::kFloat64, |
570 WriteBarrierKind::kNoWriteBarrier), | 558 WriteBarrierKind::kNoWriteBarrier), |
571 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), IsInt32Constant(0), | 559 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), IsInt32Constant(0), |
572 IsFloat64Constant(bit_cast<double>(value(0))), start(), start()); | 560 IsFloat64Constant(bit_cast<double>(value(0))), start(), start()); |
573 | 561 |
574 EXPECT_THAT( | 562 EXPECT_THAT( |
575 graph()->end()->InputAt(1), | 563 graph()->end()->InputAt(1), |
576 IsReturn2(IsLoad(MachineType::Int32(), | 564 IsReturn2(IsLoad(MachineType::Int32(), |
577 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), | 565 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), |
578 IsInt32Constant(0), | 566 IsInt32Constant(0), |
579 AllOf(CaptureEq(&store), store_matcher), start()), | 567 AllOf(CaptureEq(&store), store_matcher), start()), |
580 IsLoad(MachineType::Int32(), | 568 IsLoad(MachineType::Int32(), |
581 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), | 569 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), |
582 IsInt32Constant(0x4), | 570 IsInt32Constant(0x4), |
583 AllOf(CaptureEq(&store), store_matcher), start()), | 571 AllOf(CaptureEq(&store), store_matcher), start()), |
584 start(), start())); | 572 start(), start())); |
585 } | 573 } |
586 // kExprI64Clz: | 574 |
587 TEST_F(Int64LoweringTest, I64Clz) { | 575 TEST_F(Int64LoweringTest, I64Clz) { |
588 LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))), | 576 LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))), |
589 MachineRepresentation::kWord64); | 577 MachineRepresentation::kWord64); |
590 | 578 |
591 Capture<Node*> branch_capture; | 579 Capture<Node*> branch_capture; |
592 Matcher<Node*> branch_matcher = IsBranch( | 580 Matcher<Node*> branch_matcher = IsBranch( |
593 IsWord32Equal(IsInt32Constant(high_word_value(0)), IsInt32Constant(0)), | 581 IsWord32Equal(IsInt32Constant(high_word_value(0)), IsInt32Constant(0)), |
594 start()); | 582 start()); |
595 | 583 |
596 EXPECT_THAT( | 584 EXPECT_THAT( |
597 graph()->end()->InputAt(1), | 585 graph()->end()->InputAt(1), |
598 IsReturn2( | 586 IsReturn2( |
599 IsPhi(MachineRepresentation::kWord32, | 587 IsPhi(MachineRepresentation::kWord32, |
600 IsInt32Add(IsWord32Clz(IsInt32Constant(low_word_value(0))), | 588 IsInt32Add(IsWord32Clz(IsInt32Constant(low_word_value(0))), |
601 IsInt32Constant(32)), | 589 IsInt32Constant(32)), |
602 IsWord32Clz(IsInt32Constant(high_word_value(0))), | 590 IsWord32Clz(IsInt32Constant(high_word_value(0))), |
603 IsMerge( | 591 IsMerge( |
604 IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)), | 592 IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)), |
605 IsIfFalse( | 593 IsIfFalse( |
606 AllOf(CaptureEq(&branch_capture), branch_matcher)))), | 594 AllOf(CaptureEq(&branch_capture), branch_matcher)))), |
607 IsInt32Constant(0), start(), start())); | 595 IsInt32Constant(0), start(), start())); |
608 } | 596 } |
609 // kExprI64Ctz: | 597 |
610 TEST_F(Int64LoweringTest, I64Ctz) { | 598 TEST_F(Int64LoweringTest, I64Ctz) { |
611 LowerGraph(graph()->NewNode(machine()->Word64CtzPlaceholder(), | 599 LowerGraph(graph()->NewNode(machine()->Word64CtzPlaceholder(), |
612 Int64Constant(value(0))), | 600 Int64Constant(value(0))), |
613 MachineRepresentation::kWord64); | 601 MachineRepresentation::kWord64); |
614 Capture<Node*> branch_capture; | 602 Capture<Node*> branch_capture; |
615 Matcher<Node*> branch_matcher = IsBranch( | 603 Matcher<Node*> branch_matcher = IsBranch( |
616 IsWord32Equal(IsInt32Constant(low_word_value(0)), IsInt32Constant(0)), | 604 IsWord32Equal(IsInt32Constant(low_word_value(0)), IsInt32Constant(0)), |
617 start()); | 605 start()); |
618 EXPECT_THAT( | 606 EXPECT_THAT( |
619 graph()->end()->InputAt(1), | 607 graph()->end()->InputAt(1), |
620 IsReturn2( | 608 IsReturn2( |
621 IsPhi(MachineRepresentation::kWord32, | 609 IsPhi(MachineRepresentation::kWord32, |
622 IsInt32Add(IsWord32Ctz(IsInt32Constant(high_word_value(0))), | 610 IsInt32Add(IsWord32Ctz(IsInt32Constant(high_word_value(0))), |
623 IsInt32Constant(32)), | 611 IsInt32Constant(32)), |
624 IsWord32Ctz(IsInt32Constant(low_word_value(0))), | 612 IsWord32Ctz(IsInt32Constant(low_word_value(0))), |
625 IsMerge( | 613 IsMerge( |
626 IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)), | 614 IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)), |
627 IsIfFalse( | 615 IsIfFalse( |
628 AllOf(CaptureEq(&branch_capture), branch_matcher)))), | 616 AllOf(CaptureEq(&branch_capture), branch_matcher)))), |
629 IsInt32Constant(0), start(), start())); | 617 IsInt32Constant(0), start(), start())); |
630 } | 618 } |
631 // kExprI64Popcnt: | |
632 | 619 |
633 TEST_F(Int64LoweringTest, Dfs) { | 620 TEST_F(Int64LoweringTest, Dfs) { |
634 Node* common = Int64Constant(value(0)); | 621 Node* common = Int64Constant(value(0)); |
635 LowerGraph(graph()->NewNode(machine()->Word64And(), common, | 622 LowerGraph(graph()->NewNode(machine()->Word64And(), common, |
636 graph()->NewNode(machine()->Word64And(), common, | 623 graph()->NewNode(machine()->Word64And(), common, |
637 Int64Constant(value(1)))), | 624 Int64Constant(value(1)))), |
638 MachineRepresentation::kWord64); | 625 MachineRepresentation::kWord64); |
639 | 626 |
640 EXPECT_THAT( | 627 EXPECT_THAT( |
641 graph()->end()->InputAt(1), | 628 graph()->end()->InputAt(1), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 Float32Constant(2.5)); | 783 Float32Constant(2.5)); |
797 } | 784 } |
798 | 785 |
799 TEST_F(Int64LoweringTest, I64PhiWord32) { | 786 TEST_F(Int64LoweringTest, I64PhiWord32) { |
800 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), | 787 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), |
801 Float32Constant(2)); | 788 Float32Constant(2)); |
802 } | 789 } |
803 } // namespace compiler | 790 } // namespace compiler |
804 } // namespace internal | 791 } // namespace internal |
805 } // namespace v8 | 792 } // namespace v8 |
OLD | NEW |