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

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

Issue 456333002: Move MachineRepresentation to machine-type.h and rename to MachineType in preparation for merging i… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h" 9 #include "test/cctest/compiler/codegen-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
(...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 int constant = 0x55555 + i; 2486 int constant = 0x55555 + i;
2487 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); 2487 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1));
2488 m.Return(m.Int32Constant(constant)); 2488 m.Return(m.Int32Constant(constant));
2489 2489
2490 CHECK_EQ(constant, m.Call(1, 1)); 2490 CHECK_EQ(constant, m.Call(1, 1));
2491 } 2491 }
2492 } 2492 }
2493 2493
2494 2494
2495 template <typename Type, typename CType> 2495 template <typename Type, typename CType>
2496 static void RunLoadImmIndex(MachineRepresentation rep) { 2496 static void RunLoadImmIndex(MachineType rep) {
2497 const int kNumElems = 3; 2497 const int kNumElems = 3;
2498 CType buffer[kNumElems]; 2498 CType buffer[kNumElems];
2499 2499
2500 // initialize the buffer with raw data. 2500 // initialize the buffer with raw data.
2501 byte* raw = reinterpret_cast<byte*>(buffer); 2501 byte* raw = reinterpret_cast<byte*>(buffer);
2502 for (size_t i = 0; i < sizeof(buffer); i++) { 2502 for (size_t i = 0; i < sizeof(buffer); i++) {
2503 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 2503 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
2504 } 2504 }
2505 2505
2506 // Test with various large and small offsets. 2506 // Test with various large and small offsets.
(...skipping 18 matching lines...) Expand all
2525 RunLoadImmIndex<int16_t, uint16_t>(kMachineWord16); 2525 RunLoadImmIndex<int16_t, uint16_t>(kMachineWord16);
2526 RunLoadImmIndex<int32_t, uint32_t>(kMachineWord32); 2526 RunLoadImmIndex<int32_t, uint32_t>(kMachineWord32);
2527 RunLoadImmIndex<int32_t*, int32_t*>(kMachineTagged); 2527 RunLoadImmIndex<int32_t*, int32_t*>(kMachineTagged);
2528 2528
2529 // TODO(titzer): test kMachineFloat64 loads 2529 // TODO(titzer): test kMachineFloat64 loads
2530 // TODO(titzer): test various indexing modes. 2530 // TODO(titzer): test various indexing modes.
2531 } 2531 }
2532 2532
2533 2533
2534 template <typename CType> 2534 template <typename CType>
2535 static void RunLoadStore(MachineRepresentation rep) { 2535 static void RunLoadStore(MachineType rep) {
2536 const int kNumElems = 4; 2536 const int kNumElems = 4;
2537 CType buffer[kNumElems]; 2537 CType buffer[kNumElems];
2538 2538
2539 for (int32_t x = 0; x < kNumElems; x++) { 2539 for (int32_t x = 0; x < kNumElems; x++) {
2540 int32_t y = kNumElems - x - 1; 2540 int32_t y = kNumElems - x - 1;
2541 // initialize the buffer with raw data. 2541 // initialize the buffer with raw data.
2542 byte* raw = reinterpret_cast<byte*>(buffer); 2542 byte* raw = reinterpret_cast<byte*>(buffer);
2543 for (size_t i = 0; i < sizeof(buffer); i++) { 2543 for (size_t i = 0; i < sizeof(buffer); i++) {
2544 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 2544 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
2545 } 2545 }
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 3344
3345 3345
3346 TEST(RunCallSeven) { 3346 TEST(RunCallSeven) {
3347 for (int i = 0; i < 2; i++) { 3347 for (int i = 0; i < 2; i++) {
3348 bool call_direct = i == 0; 3348 bool call_direct = i == 0;
3349 void* function_address = 3349 void* function_address =
3350 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); 3350 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3351 3351
3352 RawMachineAssemblerTester<int32_t> m; 3352 RawMachineAssemblerTester<int32_t> m;
3353 Node** args = NULL; 3353 Node** args = NULL;
3354 MachineRepresentation* arg_types = NULL; 3354 MachineType* arg_types = NULL;
3355 Node* function = 3355 Node* function =
3356 call_direct ? m.PointerConstant(function_address) 3356 call_direct ? m.PointerConstant(function_address)
3357 : m.LoadFromPointer(&function_address, 3357 : m.LoadFromPointer(&function_address,
3358 MachineOperatorBuilder::pointer_rep()); 3358 MachineOperatorBuilder::pointer_rep());
3359 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 0)); 3359 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 0));
3360 3360
3361 CHECK_EQ(7, m.Call()); 3361 CHECK_EQ(7, m.Call());
3362 } 3362 }
3363 } 3363 }
3364 3364
3365 3365
3366 TEST(RunCallUnaryMinus) { 3366 TEST(RunCallUnaryMinus) {
3367 for (int i = 0; i < 2; i++) { 3367 for (int i = 0; i < 2; i++) {
3368 bool call_direct = i == 0; 3368 bool call_direct = i == 0;
3369 void* function_address = 3369 void* function_address =
3370 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus)); 3370 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus));
3371 3371
3372 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3372 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
3373 Node* args[] = {m.Parameter(0)}; 3373 Node* args[] = {m.Parameter(0)};
3374 MachineRepresentation arg_types[] = {kMachineWord32}; 3374 MachineType arg_types[] = {kMachineWord32};
3375 Node* function = 3375 Node* function =
3376 call_direct ? m.PointerConstant(function_address) 3376 call_direct ? m.PointerConstant(function_address)
3377 : m.LoadFromPointer(&function_address, 3377 : m.LoadFromPointer(&function_address,
3378 MachineOperatorBuilder::pointer_rep()); 3378 MachineOperatorBuilder::pointer_rep());
3379 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 1)); 3379 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 1));
3380 3380
3381 FOR_INT32_INPUTS(i) { 3381 FOR_INT32_INPUTS(i) {
3382 int a = *i; 3382 int a = *i;
3383 CHECK_EQ(-a, m.Call(a)); 3383 CHECK_EQ(-a, m.Call(a));
3384 } 3384 }
3385 } 3385 }
3386 } 3386 }
3387 3387
3388 3388
3389 TEST(RunCallAPlusTwoB) { 3389 TEST(RunCallAPlusTwoB) {
3390 for (int i = 0; i < 2; i++) { 3390 for (int i = 0; i < 2; i++) {
3391 bool call_direct = i == 0; 3391 bool call_direct = i == 0;
3392 void* function_address = 3392 void* function_address =
3393 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB)); 3393 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB));
3394 3394
3395 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 3395 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
3396 Node* args[] = {m.Parameter(0), m.Parameter(1)}; 3396 Node* args[] = {m.Parameter(0), m.Parameter(1)};
3397 MachineRepresentation arg_types[] = {kMachineWord32, kMachineWord32}; 3397 MachineType arg_types[] = {kMachineWord32, kMachineWord32};
3398 Node* function = 3398 Node* function =
3399 call_direct ? m.PointerConstant(function_address) 3399 call_direct ? m.PointerConstant(function_address)
3400 : m.LoadFromPointer(&function_address, 3400 : m.LoadFromPointer(&function_address,
3401 MachineOperatorBuilder::pointer_rep()); 3401 MachineOperatorBuilder::pointer_rep());
3402 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 2)); 3402 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 2));
3403 3403
3404 FOR_INT32_INPUTS(i) { 3404 FOR_INT32_INPUTS(i) {
3405 FOR_INT32_INPUTS(j) { 3405 FOR_INT32_INPUTS(j) {
3406 int a = *i; 3406 int a = *i;
3407 int b = *j; 3407 int b = *j;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 FOR_FLOAT64_INPUTS(pr) { 3589 FOR_FLOAT64_INPUTS(pr) {
3590 input_a = *pl; 3590 input_a = *pl;
3591 input_b = *pr; 3591 input_b = *pr;
3592 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; 3592 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0;
3593 CHECK_EQ(expected, m.Call()); 3593 CHECK_EQ(expected, m.Call());
3594 } 3594 }
3595 } 3595 }
3596 } 3596 }
3597 3597
3598 3598
3599 template <typename IntType, MachineRepresentation kRepresentation> 3599 template <typename IntType, MachineType kRepresentation>
3600 static void LoadStoreTruncation() { 3600 static void LoadStoreTruncation() {
3601 IntType input; 3601 IntType input;
3602 3602
3603 RawMachineAssemblerTester<int32_t> m; 3603 RawMachineAssemblerTester<int32_t> m;
3604 Node* a = m.LoadFromPointer(&input, kRepresentation); 3604 Node* a = m.LoadFromPointer(&input, kRepresentation);
3605 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); 3605 Node* ap1 = m.Int32Add(a, m.Int32Constant(1));
3606 m.StoreToPointer(&input, kRepresentation, ap1); 3606 m.StoreToPointer(&input, kRepresentation, ap1);
3607 m.Return(ap1); 3607 m.Return(ap1);
3608 3608
3609 const IntType max = std::numeric_limits<IntType>::max(); 3609 const IntType max = std::numeric_limits<IntType>::max();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3860 Node* one = m.Int32Constant(1); 3860 Node* one = m.Int32Constant(1);
3861 Node* acc = one; 3861 Node* acc = one;
3862 for (int i = 0; i < kInputSize; i++) { 3862 for (int i = 0; i < kInputSize; i++) {
3863 acc = m.Int32Add(acc, one); 3863 acc = m.Int32Add(acc, one);
3864 accs[i] = acc; 3864 accs[i] = acc;
3865 } 3865 }
3866 // If the spill slot computation is wrong, it might load from the c frame 3866 // If the spill slot computation is wrong, it might load from the c frame
3867 { 3867 {
3868 void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); 3868 void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3869 Node** args = NULL; 3869 Node** args = NULL;
3870 MachineRepresentation* arg_types = NULL; 3870 MachineType* arg_types = NULL;
3871 m.CallC(m.PointerConstant(func), kMachineWord32, arg_types, args, 0); 3871 m.CallC(m.PointerConstant(func), kMachineWord32, arg_types, args, 0);
3872 } 3872 }
3873 for (int i = 0; i < kInputSize; i++) { 3873 for (int i = 0; i < kInputSize; i++) {
3874 m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); 3874 m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]);
3875 } 3875 }
3876 m.Return(one); 3876 m.Return(one);
3877 m.Call(); 3877 m.Call();
3878 for (int i = 0; i < kInputSize; i++) { 3878 for (int i = 0; i < kInputSize; i++) {
3879 CHECK_EQ(outputs[i], i + 2); 3879 CHECK_EQ(outputs[i], i + 2);
3880 } 3880 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 FOR_UINT32_INPUTS(i) { 4068 FOR_UINT32_INPUTS(i) {
4069 FOR_UINT32_INPUTS(j) { 4069 FOR_UINT32_INPUTS(j) {
4070 int32_t expected; 4070 int32_t expected;
4071 if (ssub_overflow(*i, *j, &expected)) expected = constant; 4071 if (ssub_overflow(*i, *j, &expected)) expected = constant;
4072 CHECK_EQ(expected, bt.call(*i, *j)); 4072 CHECK_EQ(expected, bt.call(*i, *j));
4073 } 4073 }
4074 } 4074 }
4075 } 4075 }
4076 4076
4077 #endif // V8_TURBOFAN_TARGET 4077 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-codegen-deopt.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698