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

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

Issue 469213002: [turbofan] Introduce WordRor machine operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix BUILD.gn 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 | « test/base-unittests/bits-unittest.cc ('k') | test/compiler-unittests/compiler-unittests.gyp » ('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 <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/base/bits.h"
8 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h" 10 #include "test/cctest/compiler/codegen-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 11 #include "test/cctest/compiler/value-helper.h"
11 12
12 #if V8_TURBOFAN_TARGET 13 #if V8_TURBOFAN_TARGET
13 14
15 using namespace v8::base;
14 using namespace v8::internal; 16 using namespace v8::internal;
15 using namespace v8::internal::compiler; 17 using namespace v8::internal::compiler;
16 18
17 typedef RawMachineAssembler::Label MLabel; 19 typedef RawMachineAssembler::Label MLabel;
18 20
19 TEST(RunInt32Add) { 21 TEST(RunInt32Add) {
20 RawMachineAssemblerTester<int32_t> m; 22 RawMachineAssemblerTester<int32_t> m;
21 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 23 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
22 m.Return(add); 24 m.Return(add);
23 CHECK_EQ(1, m.Call()); 25 CHECK_EQ(1, m.Call());
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 FOR_INT32_SHIFTS(shift) { 2277 FOR_INT32_SHIFTS(shift) {
2276 int32_t expected = *i >> shift; 2278 int32_t expected = *i >> shift;
2277 CHECK_EQ(expected, bt.call(*i, shift)); 2279 CHECK_EQ(expected, bt.call(*i, shift));
2278 } 2280 }
2279 } 2281 }
2280 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15)); 2282 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15));
2281 } 2283 }
2282 } 2284 }
2283 2285
2284 2286
2287 TEST(RunWord32RorP) {
2288 {
2289 FOR_UINT32_SHIFTS(shift) {
2290 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2291 m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)));
2292 FOR_UINT32_INPUTS(j) {
2293 int32_t expected = bits::RotateRight32(*j, shift);
2294 CHECK_EQ(expected, m.Call(*j));
2295 }
2296 }
2297 }
2298 {
2299 RawMachineAssemblerTester<int32_t> m;
2300 Int32BinopTester bt(&m);
2301 bt.AddReturn(m.Word32Ror(bt.param0, bt.param1));
2302 FOR_UINT32_INPUTS(i) {
2303 FOR_UINT32_SHIFTS(shift) {
2304 int32_t expected = bits::RotateRight32(*i, shift);
2305 CHECK_EQ(expected, bt.call(*i, shift));
2306 }
2307 }
2308 }
2309 }
2310
2311
2285 TEST(RunWord32NotP) { 2312 TEST(RunWord32NotP) {
2286 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2313 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2287 m.Return(m.Word32Not(m.Parameter(0))); 2314 m.Return(m.Word32Not(m.Parameter(0)));
2288 FOR_UINT32_INPUTS(i) { 2315 FOR_UINT32_INPUTS(i) {
2289 int expected = ~(*i); 2316 int expected = ~(*i);
2290 CHECK_EQ(expected, m.Call(*i)); 2317 CHECK_EQ(expected, m.Call(*i));
2291 } 2318 }
2292 } 2319 }
2293 2320
2294 2321
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 CHECK_EQ(constant, m.Call(0)); 2459 CHECK_EQ(constant, m.Call(0));
2433 } 2460 }
2434 } 2461 }
2435 } 2462 }
2436 2463
2437 2464
2438 TEST(RunDeadInt32Binops) { 2465 TEST(RunDeadInt32Binops) {
2439 RawMachineAssemblerTester<int32_t> m; 2466 RawMachineAssemblerTester<int32_t> m;
2440 2467
2441 Operator* ops[] = { 2468 Operator* ops[] = {
2442 m.machine()->Word32And(), m.machine()->Word32Or(), 2469 m.machine()->Word32And(), m.machine()->Word32Or(),
2443 m.machine()->Word32Xor(), m.machine()->Word32Shl(), 2470 m.machine()->Word32Xor(), m.machine()->Word32Shl(),
2444 m.machine()->Word32Shr(), m.machine()->Word32Sar(), 2471 m.machine()->Word32Shr(), m.machine()->Word32Sar(),
2445 m.machine()->Word32Equal(), m.machine()->Int32Add(), 2472 m.machine()->Word32Ror(), m.machine()->Word32Equal(),
2446 m.machine()->Int32Sub(), m.machine()->Int32Mul(), 2473 m.machine()->Int32Add(), m.machine()->Int32Sub(),
2447 m.machine()->Int32Div(), m.machine()->Int32UDiv(), 2474 m.machine()->Int32Mul(), m.machine()->Int32Div(),
2448 m.machine()->Int32Mod(), m.machine()->Int32UMod(), 2475 m.machine()->Int32UDiv(), m.machine()->Int32Mod(),
2449 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), 2476 m.machine()->Int32UMod(), m.machine()->Int32LessThan(),
2450 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), 2477 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(),
2451 NULL}; 2478 m.machine()->Uint32LessThanOrEqual(), NULL};
2452 2479
2453 for (int i = 0; ops[i] != NULL; i++) { 2480 for (int i = 0; ops[i] != NULL; i++) {
2454 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 2481 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
2455 int constant = 0x55555 + i; 2482 int constant = 0x55555 + i;
2456 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); 2483 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1));
2457 m.Return(m.Int32Constant(constant)); 2484 m.Return(m.Int32Constant(constant));
2458 2485
2459 CHECK_EQ(constant, m.Call(1, 1)); 2486 CHECK_EQ(constant, m.Call(1, 1));
2460 } 2487 }
2461 } 2488 }
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 } 3709 }
3683 m.Return(input); 3710 m.Return(input);
3684 CHECK_EQ(&inputs[kInputSize], m.Call()); 3711 CHECK_EQ(&inputs[kInputSize], m.Call());
3685 for (int i = 0; i < kInputSize; i++) { 3712 for (int i = 0; i < kInputSize; i++) {
3686 CHECK_EQ(i, inputs[i]); 3713 CHECK_EQ(i, inputs[i]);
3687 CHECK_EQ(kInputSize - i - 1, outputs[i]); 3714 CHECK_EQ(kInputSize - i - 1, outputs[i]);
3688 } 3715 }
3689 } 3716 }
3690 3717
3691 3718
3692 static inline uint32_t rotr32(uint32_t i, uint32_t j) {
3693 return (i >> j) | (i << (32 - j));
3694 }
3695
3696
3697 TEST(RunTestInt32RotateRightP) {
3698 {
3699 RawMachineAssemblerTester<int32_t> m;
3700 Int32BinopTester bt(&m);
3701 bt.AddReturn(m.Word32Or(
3702 m.Word32Shr(bt.param0, bt.param1),
3703 m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1))));
3704 bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32);
3705 }
3706 {
3707 RawMachineAssemblerTester<int32_t> m;
3708 Int32BinopTester bt(&m);
3709 bt.AddReturn(m.Word32Or(
3710 m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1)),
3711 m.Word32Shr(bt.param0, bt.param1)));
3712 bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32);
3713 }
3714 }
3715
3716
3717 TEST(RunTestInt32RotateRightImm) {
3718 FOR_INPUTS(uint32_t, ror, i) {
3719 {
3720 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
3721 Node* value = m.Parameter(0);
3722 m.Return(m.Word32Or(m.Word32Shr(value, m.Int32Constant(*i)),
3723 m.Word32Shl(value, m.Int32Constant(32 - *i))));
3724 m.Run(ValueHelper::uint32_vector(),
3725 std::bind2nd(std::ptr_fun(&rotr32), *i));
3726 }
3727 {
3728 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
3729 Node* value = m.Parameter(0);
3730 m.Return(m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - *i)),
3731 m.Word32Shr(value, m.Int32Constant(*i))));
3732 m.Run(ValueHelper::uint32_vector(),
3733 std::bind2nd(std::ptr_fun(&rotr32), *i));
3734 }
3735 }
3736 }
3737
3738
3739 TEST(RunSpillLotsOfThings) { 3719 TEST(RunSpillLotsOfThings) {
3740 static const int kInputSize = 1000; 3720 static const int kInputSize = 1000;
3741 RawMachineAssemblerTester<void> m; 3721 RawMachineAssemblerTester<void> m;
3742 Node* accs[kInputSize]; 3722 Node* accs[kInputSize];
3743 int32_t outputs[kInputSize]; 3723 int32_t outputs[kInputSize];
3744 Node* one = m.Int32Constant(1); 3724 Node* one = m.Int32Constant(1);
3745 Node* acc = one; 3725 Node* acc = one;
3746 for (int i = 0; i < kInputSize; i++) { 3726 for (int i = 0; i < kInputSize; i++) {
3747 acc = m.Int32Add(acc, one); 3727 acc = m.Int32Add(acc, one);
3748 accs[i] = acc; 3728 accs[i] = acc;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 FOR_UINT32_INPUTS(i) { 4017 FOR_UINT32_INPUTS(i) {
4038 FOR_UINT32_INPUTS(j) { 4018 FOR_UINT32_INPUTS(j) {
4039 int32_t expected; 4019 int32_t expected;
4040 if (ssub_overflow(*i, *j, &expected)) expected = constant; 4020 if (ssub_overflow(*i, *j, &expected)) expected = constant;
4041 CHECK_EQ(expected, bt.call(*i, *j)); 4021 CHECK_EQ(expected, bt.call(*i, *j));
4042 } 4022 }
4043 } 4023 }
4044 } 4024 }
4045 4025
4046 #endif // V8_TURBOFAN_TARGET 4026 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/base-unittests/bits-unittest.cc ('k') | test/compiler-unittests/compiler-unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698