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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 515173002: Add MachineSignature, which is an encapsulation of the machine types for parameters and return valu… (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 <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 3516 matching lines...) Expand 10 before | Expand all | Expand 10 after
3527 3527
3528 TEST(RunCallSeven) { 3528 TEST(RunCallSeven) {
3529 for (int i = 0; i < 2; i++) { 3529 for (int i = 0; i < 2; i++) {
3530 bool call_direct = i == 0; 3530 bool call_direct = i == 0;
3531 void* function_address = 3531 void* function_address =
3532 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); 3532 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3533 3533
3534 RawMachineAssemblerTester<int32_t> m; 3534 RawMachineAssemblerTester<int32_t> m;
3535 Node** args = NULL; 3535 Node** args = NULL;
3536 MachineType* arg_types = NULL; 3536 MachineType* arg_types = NULL;
3537 Node* function = 3537 Node* function = call_direct
3538 call_direct ? m.PointerConstant(function_address) 3538 ? m.PointerConstant(function_address)
3539 : m.LoadFromPointer(&function_address, 3539 : m.LoadFromPointer(&function_address, kMachPtr);
3540 MachineOperatorBuilder::pointer_rep());
3541 m.Return(m.CallC(function, kMachInt32, arg_types, args, 0)); 3540 m.Return(m.CallC(function, kMachInt32, arg_types, args, 0));
3542 3541
3543 CHECK_EQ(7, m.Call()); 3542 CHECK_EQ(7, m.Call());
3544 } 3543 }
3545 } 3544 }
3546 3545
3547 3546
3548 TEST(RunCallUnaryMinus) { 3547 TEST(RunCallUnaryMinus) {
3549 for (int i = 0; i < 2; i++) { 3548 for (int i = 0; i < 2; i++) {
3550 bool call_direct = i == 0; 3549 bool call_direct = i == 0;
3551 void* function_address = 3550 void* function_address =
3552 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus)); 3551 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus));
3553 3552
3554 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3553 RawMachineAssemblerTester<int32_t> m(kMachInt32);
3555 Node* args[] = {m.Parameter(0)}; 3554 Node* args[] = {m.Parameter(0)};
3556 MachineType arg_types[] = {kMachInt32}; 3555 MachineType arg_types[] = {kMachInt32};
3557 Node* function = 3556 Node* function = call_direct
3558 call_direct ? m.PointerConstant(function_address) 3557 ? m.PointerConstant(function_address)
3559 : m.LoadFromPointer(&function_address, 3558 : m.LoadFromPointer(&function_address, kMachPtr);
3560 MachineOperatorBuilder::pointer_rep());
3561 m.Return(m.CallC(function, kMachInt32, arg_types, args, 1)); 3559 m.Return(m.CallC(function, kMachInt32, arg_types, args, 1));
3562 3560
3563 FOR_INT32_INPUTS(i) { 3561 FOR_INT32_INPUTS(i) {
3564 int a = *i; 3562 int a = *i;
3565 CHECK_EQ(-a, m.Call(a)); 3563 CHECK_EQ(-a, m.Call(a));
3566 } 3564 }
3567 } 3565 }
3568 } 3566 }
3569 3567
3570 3568
3571 TEST(RunCallAPlusTwoB) { 3569 TEST(RunCallAPlusTwoB) {
3572 for (int i = 0; i < 2; i++) { 3570 for (int i = 0; i < 2; i++) {
3573 bool call_direct = i == 0; 3571 bool call_direct = i == 0;
3574 void* function_address = 3572 void* function_address =
3575 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB)); 3573 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB));
3576 3574
3577 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 3575 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
3578 Node* args[] = {m.Parameter(0), m.Parameter(1)}; 3576 Node* args[] = {m.Parameter(0), m.Parameter(1)};
3579 MachineType arg_types[] = {kMachInt32, kMachInt32}; 3577 MachineType arg_types[] = {kMachInt32, kMachInt32};
3580 Node* function = 3578 Node* function = call_direct
3581 call_direct ? m.PointerConstant(function_address) 3579 ? m.PointerConstant(function_address)
3582 : m.LoadFromPointer(&function_address, 3580 : m.LoadFromPointer(&function_address, kMachPtr);
3583 MachineOperatorBuilder::pointer_rep());
3584 m.Return(m.CallC(function, kMachInt32, arg_types, args, 2)); 3581 m.Return(m.CallC(function, kMachInt32, arg_types, args, 2));
3585 3582
3586 FOR_INT32_INPUTS(i) { 3583 FOR_INT32_INPUTS(i) {
3587 FOR_INT32_INPUTS(j) { 3584 FOR_INT32_INPUTS(j) {
3588 int a = *i; 3585 int a = *i;
3589 int b = *j; 3586 int b = *j;
3590 int result = m.Call(a, b); 3587 int result = m.Call(a, b);
3591 CHECK_EQ(a + 2 * b, result); 3588 CHECK_EQ(a + 2 * b, result);
3592 } 3589 }
3593 } 3590 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 3809
3813 3810
3814 TEST(RunLoadStoreTruncation) { 3811 TEST(RunLoadStoreTruncation) {
3815 LoadStoreTruncation<int8_t, kMachInt8>(); 3812 LoadStoreTruncation<int8_t, kMachInt8>();
3816 LoadStoreTruncation<int16_t, kMachInt16>(); 3813 LoadStoreTruncation<int16_t, kMachInt16>();
3817 } 3814 }
3818 3815
3819 3816
3820 static void IntPtrCompare(intptr_t left, intptr_t right) { 3817 static void IntPtrCompare(intptr_t left, intptr_t right) {
3821 for (int test = 0; test < 7; test++) { 3818 for (int test = 0; test < 7; test++) {
3822 RawMachineAssemblerTester<bool> m(MachineOperatorBuilder::pointer_rep(), 3819 RawMachineAssemblerTester<bool> m(kMachPtr, kMachPtr);
3823 MachineOperatorBuilder::pointer_rep());
3824 Node* p0 = m.Parameter(0); 3820 Node* p0 = m.Parameter(0);
3825 Node* p1 = m.Parameter(1); 3821 Node* p1 = m.Parameter(1);
3826 Node* res = NULL; 3822 Node* res = NULL;
3827 bool expected = false; 3823 bool expected = false;
3828 switch (test) { 3824 switch (test) {
3829 case 0: 3825 case 0:
3830 res = m.IntPtrLessThan(p0, p1); 3826 res = m.IntPtrLessThan(p0, p1);
3831 expected = true; 3827 expected = true;
3832 break; 3828 break;
3833 case 1: 3829 case 1:
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4316 RawMachineAssemblerTester<int32_t> m; 4312 RawMachineAssemblerTester<int32_t> m;
4317 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); 4313 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64)));
4318 for (size_t i = 0; i < arraysize(kValues); ++i) { 4314 for (size_t i = 0; i < arraysize(kValues); ++i) {
4319 input = kValues[i].from; 4315 input = kValues[i].from;
4320 uint64_t expected = static_cast<int64_t>(kValues[i].raw); 4316 uint64_t expected = static_cast<int64_t>(kValues[i].raw);
4321 CHECK_EQ(static_cast<int>(expected), m.Call()); 4317 CHECK_EQ(static_cast<int>(expected), m.Call());
4322 } 4318 }
4323 } 4319 }
4324 4320
4325 #endif // V8_TURBOFAN_TARGET 4321 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/instruction-selector-tester.h ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698