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

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

Issue 505713002: [turbofan] Add backend support for signed loads. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix x64. 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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 2665 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
2666 int constant = 0x55555 + i; 2666 int constant = 0x55555 + i;
2667 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); 2667 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1));
2668 m.Return(m.Int32Constant(constant)); 2668 m.Return(m.Int32Constant(constant));
2669 2669
2670 CHECK_EQ(constant, m.Call(1, 1)); 2670 CHECK_EQ(constant, m.Call(1, 1));
2671 } 2671 }
2672 } 2672 }
2673 2673
2674 2674
2675 template <typename Type, typename CType> 2675 template <typename Type>
2676 static void RunLoadImmIndex(MachineType rep) { 2676 static void RunLoadImmIndex(MachineType rep) {
2677 const int kNumElems = 3; 2677 const int kNumElems = 3;
2678 CType buffer[kNumElems]; 2678 Type buffer[kNumElems];
2679 2679
2680 // initialize the buffer with raw data. 2680 // initialize the buffer with raw data.
2681 byte* raw = reinterpret_cast<byte*>(buffer); 2681 byte* raw = reinterpret_cast<byte*>(buffer);
2682 for (size_t i = 0; i < sizeof(buffer); i++) { 2682 for (size_t i = 0; i < sizeof(buffer); i++) {
2683 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 2683 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
2684 } 2684 }
2685 2685
2686 // Test with various large and small offsets. 2686 // Test with various large and small offsets.
2687 for (int offset = -1; offset <= 200000; offset *= -5) { 2687 for (int offset = -1; offset <= 200000; offset *= -5) {
2688 for (int i = 0; i < kNumElems; i++) { 2688 for (int i = 0; i < kNumElems; i++) {
2689 RawMachineAssemblerTester<Type> m; 2689 RawMachineAssemblerTester<Type> m;
2690 Node* base = m.PointerConstant(buffer - offset); 2690 Node* base = m.PointerConstant(buffer - offset);
2691 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); 2691 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0]));
2692 m.Return(m.Load(rep, base, index)); 2692 m.Return(m.Load(rep, base, index));
2693 2693
2694 Type expected = buffer[i]; 2694 Type expected = buffer[i];
2695 Type actual = static_cast<CType>(m.Call()); 2695 Type actual = m.Call();
2696 CHECK_EQ(expected, actual); 2696 CHECK(expected == actual);
2697 printf("XXX\n");
2698 } 2697 }
2699 } 2698 }
2700 } 2699 }
2701 2700
2702 2701
2703 TEST(RunLoadImmIndex) { 2702 TEST(RunLoadImmIndex) {
2704 RunLoadImmIndex<int8_t, uint8_t>(kMachInt8); 2703 RunLoadImmIndex<int8_t>(kMachInt8);
2705 RunLoadImmIndex<int16_t, uint16_t>(kMachInt16); 2704 RunLoadImmIndex<uint8_t>(kMachUint8);
2706 RunLoadImmIndex<int32_t, uint32_t>(kMachInt32); 2705 RunLoadImmIndex<int16_t>(kMachInt16);
2707 RunLoadImmIndex<int32_t*, int32_t*>(kMachAnyTagged); 2706 RunLoadImmIndex<uint16_t>(kMachUint16);
2707 RunLoadImmIndex<int32_t>(kMachInt32);
2708 RunLoadImmIndex<uint32_t>(kMachUint32);
2709 RunLoadImmIndex<int32_t*>(kMachAnyTagged);
2708 2710
2709 // TODO(titzer): test kRepBit loads 2711 // TODO(titzer): test kRepBit loads
2710 // TODO(titzer): test kMachFloat64 loads 2712 // TODO(titzer): test kMachFloat64 loads
2711 // TODO(titzer): test various indexing modes. 2713 // TODO(titzer): test various indexing modes.
2712 } 2714 }
2713 2715
2714 2716
2715 template <typename CType> 2717 template <typename CType>
2716 static void RunLoadStore(MachineType rep) { 2718 static void RunLoadStore(MachineType rep) {
2717 const int kNumElems = 4; 2719 const int kNumElems = 4;
2718 CType buffer[kNumElems]; 2720 CType buffer[kNumElems];
2719 2721
2720 for (int32_t x = 0; x < kNumElems; x++) { 2722 for (int32_t x = 0; x < kNumElems; x++) {
2721 int32_t y = kNumElems - x - 1; 2723 int32_t y = kNumElems - x - 1;
2722 // initialize the buffer with raw data. 2724 // initialize the buffer with raw data.
2723 byte* raw = reinterpret_cast<byte*>(buffer); 2725 byte* raw = reinterpret_cast<byte*>(buffer);
2724 for (size_t i = 0; i < sizeof(buffer); i++) { 2726 for (size_t i = 0; i < sizeof(buffer); i++) {
2725 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 2727 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
2726 } 2728 }
2727 2729
2728 RawMachineAssemblerTester<int32_t> m; 2730 RawMachineAssemblerTester<int32_t> m;
2729 int32_t OK = 0x29000 + x; 2731 int32_t OK = 0x29000 + x;
2730 Node* base = m.PointerConstant(buffer); 2732 Node* base = m.PointerConstant(buffer);
2731 Node* index0 = m.Int32Constant(x * sizeof(buffer[0])); 2733 Node* index0 = m.Int32Constant(x * sizeof(buffer[0]));
2732 Node* load = m.Load(rep, base, index0); 2734 Node* load = m.Load(rep, base, index0);
2733 Node* index1 = m.Int32Constant(y * sizeof(buffer[0])); 2735 Node* index1 = m.Int32Constant(y * sizeof(buffer[0]));
2734 m.Store(rep, base, index1, load); 2736 m.Store(rep, base, index1, load);
2735 m.Return(m.Int32Constant(OK)); 2737 m.Return(m.Int32Constant(OK));
2736 2738
2737 CHECK_NE(buffer[x], buffer[y]); 2739 CHECK(buffer[x] != buffer[y]);
2738 CHECK_EQ(OK, m.Call()); 2740 CHECK_EQ(OK, m.Call());
2739 CHECK_EQ(buffer[x], buffer[y]); 2741 CHECK(buffer[x] == buffer[y]);
2740 } 2742 }
2741 } 2743 }
2742 2744
2743 2745
2744 TEST(RunLoadStore) { 2746 TEST(RunLoadStore) {
2745 RunLoadStore<int8_t>(kMachInt8); 2747 RunLoadStore<int8_t>(kMachInt8);
2748 RunLoadStore<uint8_t>(kMachUint8);
2746 RunLoadStore<int16_t>(kMachInt16); 2749 RunLoadStore<int16_t>(kMachInt16);
2750 RunLoadStore<uint16_t>(kMachUint16);
2747 RunLoadStore<int32_t>(kMachInt32); 2751 RunLoadStore<int32_t>(kMachInt32);
2752 RunLoadStore<uint32_t>(kMachUint32);
2748 RunLoadStore<void*>(kMachAnyTagged); 2753 RunLoadStore<void*>(kMachAnyTagged);
2749 RunLoadStore<double>(kMachFloat64); 2754 RunLoadStore<double>(kMachFloat64);
2750 } 2755 }
2751 2756
2752 2757
2753 TEST(RunFloat64Binop) { 2758 TEST(RunFloat64Binop) {
2754 RawMachineAssemblerTester<int32_t> m; 2759 RawMachineAssemblerTester<int32_t> m;
2755 double result; 2760 double result;
2756 2761
2757 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), 2762 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 const IntType max = std::numeric_limits<IntType>::max(); 3790 const IntType max = std::numeric_limits<IntType>::max();
3786 const IntType min = std::numeric_limits<IntType>::min(); 3791 const IntType min = std::numeric_limits<IntType>::min();
3787 3792
3788 // Test upper bound. 3793 // Test upper bound.
3789 input = max; 3794 input = max;
3790 CHECK_EQ(max + 1, m.Call()); 3795 CHECK_EQ(max + 1, m.Call());
3791 CHECK_EQ(min, input); 3796 CHECK_EQ(min, input);
3792 3797
3793 // Test lower bound. 3798 // Test lower bound.
3794 input = min; 3799 input = min;
3795 CHECK_EQ(max + 2, m.Call()); 3800 CHECK_EQ(static_cast<IntType>(max + 2), m.Call());
3796 CHECK_EQ(min + 1, input); 3801 CHECK_EQ(min + 1, input);
3797 3802
3798 // Test all one byte values that are not one byte bounds. 3803 // Test all one byte values that are not one byte bounds.
3799 for (int i = -127; i < 127; i++) { 3804 for (int i = -127; i < 127; i++) {
3800 input = i; 3805 input = i;
3801 int expected = i >= 0 ? i + 1 : max + (i - min) + 2; 3806 int expected = i >= 0 ? i + 1 : max + (i - min) + 2;
3802 CHECK_EQ(expected, m.Call()); 3807 CHECK_EQ(static_cast<IntType>(expected), m.Call());
3803 CHECK_EQ(i + 1, input); 3808 CHECK_EQ(static_cast<IntType>(i + 1), input);
3804 } 3809 }
3805 } 3810 }
3806 3811
3807 3812
3808 TEST(RunLoadStoreTruncation) { 3813 TEST(RunLoadStoreTruncation) {
3809 LoadStoreTruncation<int8_t, kMachInt8>(); 3814 LoadStoreTruncation<int8_t, kMachInt8>();
3810 LoadStoreTruncation<int16_t, kMachInt16>(); 3815 LoadStoreTruncation<int16_t, kMachInt16>();
3811 } 3816 }
3812 3817
3813 3818
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 RawMachineAssemblerTester<int32_t> m; 4315 RawMachineAssemblerTester<int32_t> m;
4311 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); 4316 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64)));
4312 for (size_t i = 0; i < ARRAY_SIZE(kValues); ++i) { 4317 for (size_t i = 0; i < ARRAY_SIZE(kValues); ++i) {
4313 input = kValues[i].from; 4318 input = kValues[i].from;
4314 uint64_t expected = static_cast<int64_t>(kValues[i].raw); 4319 uint64_t expected = static_cast<int64_t>(kValues[i].raw);
4315 CHECK_EQ(static_cast<int>(expected), m.Call()); 4320 CHECK_EQ(static_cast<int>(expected), m.Call());
4316 } 4321 }
4317 } 4322 }
4318 4323
4319 #endif // V8_TURBOFAN_TARGET 4324 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/compiler-unittests/arm/instruction-selector-arm-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698