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

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

Issue 1424983003: [turbofan] Cleanup RawMachineAssembler::Store interface. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 5 years, 1 month 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
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/cctest/compiler/test-run-native-calls.cc » ('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. Use of this 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 // TODO(jochen): Remove this after the setting is turned on globally. 5 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <functional> 9 #include <functional>
10 #include <limits> 10 #include <limits>
11 11
12 #include "src/base/bits.h" 12 #include "src/base/bits.h"
13 #include "src/base/utils/random-number-generator.h" 13 #include "src/base/utils/random-number-generator.h"
14 #include "src/codegen.h" 14 #include "src/codegen.h"
15 #include "test/cctest/cctest.h" 15 #include "test/cctest/cctest.h"
16 #include "test/cctest/compiler/codegen-tester.h" 16 #include "test/cctest/compiler/codegen-tester.h"
17 #include "test/cctest/compiler/graph-builder-tester.h" 17 #include "test/cctest/compiler/graph-builder-tester.h"
18 #include "test/cctest/compiler/value-helper.h" 18 #include "test/cctest/compiler/value-helper.h"
19 19
20 using namespace v8::base; 20 using namespace v8::base;
21 using namespace v8::internal; 21 using namespace v8::internal;
22 using namespace v8::internal::compiler; 22 using namespace v8::internal::compiler;
23 23
24 typedef RawMachineAssembler::Label MLabel; 24 typedef RawMachineAssembler::Label MLabel;
25 25
26 26
27 StoreRepresentation StoreRepForType(MachineType type) {
28 return StoreRepresentation(type, kNoWriteBarrier);
29 }
30
31
32 TEST(RunInt32Add) { 27 TEST(RunInt32Add) {
33 RawMachineAssemblerTester<int32_t> m; 28 RawMachineAssemblerTester<int32_t> m;
34 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 29 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
35 m.Return(add); 30 m.Return(add);
36 CHECK_EQ(1, m.Call()); 31 CHECK_EQ(1, m.Call());
37 } 32 }
38 33
39 34
40 void TestWord32Ctz(int32_t value, int32_t expected) { 35 void TestWord32Ctz(int32_t value, int32_t expected) {
41 RawMachineAssemblerTester<int32_t> m; 36 RawMachineAssemblerTester<int32_t> m;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 796
802 FOR_INT32_INPUTS(i) { 797 FOR_INT32_INPUTS(i) {
803 int32_t magic = 0x2342aabb + *i * 3; 798 int32_t magic = 0x2342aabb + *i * 3;
804 RawMachineAssemblerTester<int32_t> m; 799 RawMachineAssemblerTester<int32_t> m;
805 int32_t offset = *i; 800 int32_t offset = *i;
806 byte* from = reinterpret_cast<byte*>(&p1) - offset; 801 byte* from = reinterpret_cast<byte*>(&p1) - offset;
807 byte* to = reinterpret_cast<byte*>(&p2) - offset; 802 byte* to = reinterpret_cast<byte*>(&p2) - offset;
808 // generate load [#base + #index] 803 // generate load [#base + #index]
809 Node* load = 804 Node* load =
810 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset)); 805 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset));
811 m.Store(StoreRepresentation(kMachFloat32, kNoWriteBarrier), 806 m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), load,
812 m.PointerConstant(to), m.IntPtrConstant(offset), load); 807 kNoWriteBarrier);
813 m.Return(m.Int32Constant(magic)); 808 m.Return(m.Int32Constant(magic));
814 809
815 FOR_FLOAT32_INPUTS(j) { 810 FOR_FLOAT32_INPUTS(j) {
816 p1 = *j; 811 p1 = *j;
817 p2 = *j - 5; 812 p2 = *j - 5;
818 CHECK_EQ(magic, m.Call()); 813 CHECK_EQ(magic, m.Call());
819 CheckDoubleEq(p1, p2); 814 CheckDoubleEq(p1, p2);
820 } 815 }
821 } 816 }
822 } 817 }
823 818
824 819
825 TEST(RunLoadStoreFloat64Offset) { 820 TEST(RunLoadStoreFloat64Offset) {
826 double p1 = 0; // loads directly from this location. 821 double p1 = 0; // loads directly from this location.
827 double p2 = 0; // and stores directly into this location. 822 double p2 = 0; // and stores directly into this location.
828 823
829 FOR_INT32_INPUTS(i) { 824 FOR_INT32_INPUTS(i) {
830 int32_t magic = 0x2342aabb + *i * 3; 825 int32_t magic = 0x2342aabb + *i * 3;
831 RawMachineAssemblerTester<int32_t> m; 826 RawMachineAssemblerTester<int32_t> m;
832 int32_t offset = *i; 827 int32_t offset = *i;
833 byte* from = reinterpret_cast<byte*>(&p1) - offset; 828 byte* from = reinterpret_cast<byte*>(&p1) - offset;
834 byte* to = reinterpret_cast<byte*>(&p2) - offset; 829 byte* to = reinterpret_cast<byte*>(&p2) - offset;
835 // generate load [#base + #index] 830 // generate load [#base + #index]
836 Node* load = 831 Node* load =
837 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset)); 832 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset));
838 m.Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier), 833 m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), load,
839 m.PointerConstant(to), m.IntPtrConstant(offset), load); 834 kNoWriteBarrier);
840 m.Return(m.Int32Constant(magic)); 835 m.Return(m.Int32Constant(magic));
841 836
842 FOR_FLOAT64_INPUTS(j) { 837 FOR_FLOAT64_INPUTS(j) {
843 p1 = *j; 838 p1 = *j;
844 p2 = *j - 5; 839 p2 = *j - 5;
845 CHECK_EQ(magic, m.Call()); 840 CHECK_EQ(magic, m.Call());
846 CheckDoubleEq(p1, p2); 841 CheckDoubleEq(p1, p2);
847 } 842 }
848 } 843 }
849 } 844 }
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 for (size_t i = 0; i < sizeof(buffer); i++) { 3205 for (size_t i = 0; i < sizeof(buffer); i++) {
3211 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 3206 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
3212 } 3207 }
3213 3208
3214 RawMachineAssemblerTester<int32_t> m; 3209 RawMachineAssemblerTester<int32_t> m;
3215 int32_t OK = 0x29000 + x; 3210 int32_t OK = 0x29000 + x;
3216 Node* base = m.PointerConstant(buffer); 3211 Node* base = m.PointerConstant(buffer);
3217 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); 3212 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0]));
3218 Node* load = m.Load(rep, base, index0); 3213 Node* load = m.Load(rep, base, index0);
3219 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); 3214 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0]));
3220 StoreRepresentation store_rep(rep, kNoWriteBarrier); 3215 m.Store(rep, base, index1, load, kNoWriteBarrier);
3221 m.Store(StoreRepForType(rep), base, index1, load);
3222 m.Return(m.Int32Constant(OK)); 3216 m.Return(m.Int32Constant(OK));
3223 3217
3224 CHECK(buffer[x] != buffer[y]); 3218 CHECK(buffer[x] != buffer[y]);
3225 CHECK_EQ(OK, m.Call()); 3219 CHECK_EQ(OK, m.Call());
3226 CHECK(buffer[x] == buffer[y]); 3220 CHECK(buffer[x] == buffer[y]);
3227 } 3221 }
3228 } 3222 }
3229 3223
3230 3224
3231 TEST(RunLoadStore) { 3225 TEST(RunLoadStore) {
(...skipping 30 matching lines...) Expand all
3262 NULL}; 3256 NULL};
3263 3257
3264 for (int i = 0; ops[i] != NULL; i++) { 3258 for (int i = 0; ops[i] != NULL; i++) {
3265 for (int j = 0; inputs[j] != NULL; j += 2) { 3259 for (int j = 0; inputs[j] != NULL; j += 2) {
3266 RawMachineAssemblerTester<int32_t> m; 3260 RawMachineAssemblerTester<int32_t> m;
3267 Node* a = m.AddNode(inputs[j]); 3261 Node* a = m.AddNode(inputs[j]);
3268 Node* b = m.AddNode(inputs[j + 1]); 3262 Node* b = m.AddNode(inputs[j + 1]);
3269 Node* binop = m.AddNode(ops[i], a, b); 3263 Node* binop = m.AddNode(ops[i], a, b);
3270 Node* base = m.PointerConstant(&result); 3264 Node* base = m.PointerConstant(&result);
3271 Node* zero = m.IntPtrConstant(0); 3265 Node* zero = m.IntPtrConstant(0);
3272 m.Store(StoreRepForType(kMachFloat32), base, zero, binop); 3266 m.Store(kMachFloat32, base, zero, binop, kNoWriteBarrier);
3273 m.Return(m.Int32Constant(i + j)); 3267 m.Return(m.Int32Constant(i + j));
3274 CHECK_EQ(i + j, m.Call()); 3268 CHECK_EQ(i + j, m.Call());
3275 } 3269 }
3276 } 3270 }
3277 } 3271 }
3278 3272
3279 3273
3280 TEST(RunFloat64Binop) { 3274 TEST(RunFloat64Binop) {
3281 RawMachineAssemblerTester<int32_t> m; 3275 RawMachineAssemblerTester<int32_t> m;
3282 double result; 3276 double result;
(...skipping 15 matching lines...) Expand all
3298 NULL}; 3292 NULL};
3299 3293
3300 for (int i = 0; ops[i] != NULL; i++) { 3294 for (int i = 0; ops[i] != NULL; i++) {
3301 for (int j = 0; inputs[j] != NULL; j += 2) { 3295 for (int j = 0; inputs[j] != NULL; j += 2) {
3302 RawMachineAssemblerTester<int32_t> m; 3296 RawMachineAssemblerTester<int32_t> m;
3303 Node* a = m.AddNode(inputs[j]); 3297 Node* a = m.AddNode(inputs[j]);
3304 Node* b = m.AddNode(inputs[j + 1]); 3298 Node* b = m.AddNode(inputs[j + 1]);
3305 Node* binop = m.AddNode(ops[i], a, b); 3299 Node* binop = m.AddNode(ops[i], a, b);
3306 Node* base = m.PointerConstant(&result); 3300 Node* base = m.PointerConstant(&result);
3307 Node* zero = m.Int32Constant(0); 3301 Node* zero = m.Int32Constant(0);
3308 m.Store(StoreRepForType(kMachFloat64), base, zero, binop); 3302 m.Store(kMachFloat64, base, zero, binop, kNoWriteBarrier);
3309 m.Return(m.Int32Constant(i + j)); 3303 m.Return(m.Int32Constant(i + j));
3310 CHECK_EQ(i + j, m.Call()); 3304 CHECK_EQ(i + j, m.Call());
3311 } 3305 }
3312 } 3306 }
3313 } 3307 }
3314 3308
3315 3309
3316 TEST(RunDeadFloat32Binops) { 3310 TEST(RunDeadFloat32Binops) {
3317 RawMachineAssemblerTester<int32_t> m; 3311 RawMachineAssemblerTester<int32_t> m;
3318 3312
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3393 3387
3394 3388
3395 TEST(RunFloat32SubImm1) { 3389 TEST(RunFloat32SubImm1) {
3396 float input = 0.0f; 3390 float input = 0.0f;
3397 float output = 0.0f; 3391 float output = 0.0f;
3398 3392
3399 FOR_FLOAT32_INPUTS(i) { 3393 FOR_FLOAT32_INPUTS(i) {
3400 RawMachineAssemblerTester<int32_t> m; 3394 RawMachineAssemblerTester<int32_t> m;
3401 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); 3395 Node* t0 = m.LoadFromPointer(&input, kMachFloat32);
3402 Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0); 3396 Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0);
3403 m.StoreToPointer(&output, StoreRepForType(kMachFloat32), t1); 3397 m.StoreToPointer(&output, kMachFloat32, t1);
3404 m.Return(m.Int32Constant(0)); 3398 m.Return(m.Int32Constant(0));
3405 FOR_FLOAT32_INPUTS(j) { 3399 FOR_FLOAT32_INPUTS(j) {
3406 input = *j; 3400 input = *j;
3407 float expected = *i - input; 3401 float expected = *i - input;
3408 CHECK_EQ(0, m.Call()); 3402 CHECK_EQ(0, m.Call());
3409 CheckFloatEq(expected, output); 3403 CheckFloatEq(expected, output);
3410 } 3404 }
3411 } 3405 }
3412 } 3406 }
3413 3407
3414 3408
3415 TEST(RunFloat32SubImm2) { 3409 TEST(RunFloat32SubImm2) {
3416 float input = 0.0f; 3410 float input = 0.0f;
3417 float output = 0.0f; 3411 float output = 0.0f;
3418 3412
3419 FOR_FLOAT32_INPUTS(i) { 3413 FOR_FLOAT32_INPUTS(i) {
3420 RawMachineAssemblerTester<int32_t> m; 3414 RawMachineAssemblerTester<int32_t> m;
3421 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); 3415 Node* t0 = m.LoadFromPointer(&input, kMachFloat32);
3422 Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i)); 3416 Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i));
3423 m.StoreToPointer(&output, StoreRepForType(kMachFloat32), t1); 3417 m.StoreToPointer(&output, kMachFloat32, t1);
3424 m.Return(m.Int32Constant(0)); 3418 m.Return(m.Int32Constant(0));
3425 FOR_FLOAT32_INPUTS(j) { 3419 FOR_FLOAT32_INPUTS(j) {
3426 input = *j; 3420 input = *j;
3427 float expected = input - *i; 3421 float expected = input - *i;
3428 CHECK_EQ(0, m.Call()); 3422 CHECK_EQ(0, m.Call());
3429 CheckFloatEq(expected, output); 3423 CheckFloatEq(expected, output);
3430 } 3424 }
3431 } 3425 }
3432 } 3426 }
3433 3427
(...skipping 14 matching lines...) Expand all
3448 3442
3449 3443
3450 TEST(RunFloat64SubImm1) { 3444 TEST(RunFloat64SubImm1) {
3451 double input = 0.0; 3445 double input = 0.0;
3452 double output = 0.0; 3446 double output = 0.0;
3453 3447
3454 FOR_FLOAT64_INPUTS(i) { 3448 FOR_FLOAT64_INPUTS(i) {
3455 RawMachineAssemblerTester<int32_t> m; 3449 RawMachineAssemblerTester<int32_t> m;
3456 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3450 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3457 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); 3451 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0);
3458 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1); 3452 m.StoreToPointer(&output, kMachFloat64, t1);
3459 m.Return(m.Int32Constant(0)); 3453 m.Return(m.Int32Constant(0));
3460 FOR_FLOAT64_INPUTS(j) { 3454 FOR_FLOAT64_INPUTS(j) {
3461 input = *j; 3455 input = *j;
3462 double expected = *i - input; 3456 double expected = *i - input;
3463 CHECK_EQ(0, m.Call()); 3457 CHECK_EQ(0, m.Call());
3464 CheckDoubleEq(expected, output); 3458 CheckDoubleEq(expected, output);
3465 } 3459 }
3466 } 3460 }
3467 } 3461 }
3468 3462
3469 3463
3470 TEST(RunFloat64SubImm2) { 3464 TEST(RunFloat64SubImm2) {
3471 double input = 0.0; 3465 double input = 0.0;
3472 double output = 0.0; 3466 double output = 0.0;
3473 3467
3474 FOR_FLOAT64_INPUTS(i) { 3468 FOR_FLOAT64_INPUTS(i) {
3475 RawMachineAssemblerTester<int32_t> m; 3469 RawMachineAssemblerTester<int32_t> m;
3476 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3470 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3477 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); 3471 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i));
3478 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1); 3472 m.StoreToPointer(&output, kMachFloat64, t1);
3479 m.Return(m.Int32Constant(0)); 3473 m.Return(m.Int32Constant(0));
3480 FOR_FLOAT64_INPUTS(j) { 3474 FOR_FLOAT64_INPUTS(j) {
3481 input = *j; 3475 input = *j;
3482 double expected = input - *i; 3476 double expected = input - *i;
3483 CHECK_EQ(0, m.Call()); 3477 CHECK_EQ(0, m.Call());
3484 CheckDoubleEq(expected, output); 3478 CheckDoubleEq(expected, output);
3485 } 3479 }
3486 } 3480 }
3487 } 3481 }
3488 3482
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3521 double input_a = 0.0; 3515 double input_a = 0.0;
3522 double input_b = 0.0; 3516 double input_b = 0.0;
3523 double input_c = 0.0; 3517 double input_c = 0.0;
3524 double output = 0.0; 3518 double output = 0.0;
3525 3519
3526 { 3520 {
3527 RawMachineAssemblerTester<int32_t> m; 3521 RawMachineAssemblerTester<int32_t> m;
3528 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3522 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3529 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3523 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3530 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3524 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3531 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), 3525 m.StoreToPointer(&output, kMachFloat64,
3532 m.Float64Add(m.Float64Mul(a, b), c)); 3526 m.Float64Add(m.Float64Mul(a, b), c));
3533 m.Return(m.Int32Constant(0)); 3527 m.Return(m.Int32Constant(0));
3534 FOR_FLOAT64_INPUTS(i) { 3528 FOR_FLOAT64_INPUTS(i) {
3535 FOR_FLOAT64_INPUTS(j) { 3529 FOR_FLOAT64_INPUTS(j) {
3536 FOR_FLOAT64_INPUTS(k) { 3530 FOR_FLOAT64_INPUTS(k) {
3537 input_a = *i; 3531 input_a = *i;
3538 input_b = *j; 3532 input_b = *j;
3539 input_c = *k; 3533 input_c = *k;
3540 volatile double temp = input_a * input_b; 3534 volatile double temp = input_a * input_b;
3541 volatile double expected = temp + input_c; 3535 volatile double expected = temp + input_c;
3542 CHECK_EQ(0, m.Call()); 3536 CHECK_EQ(0, m.Call());
3543 CheckDoubleEq(expected, output); 3537 CheckDoubleEq(expected, output);
3544 } 3538 }
3545 } 3539 }
3546 } 3540 }
3547 } 3541 }
3548 { 3542 {
3549 RawMachineAssemblerTester<int32_t> m; 3543 RawMachineAssemblerTester<int32_t> m;
3550 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3544 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3551 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3545 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3552 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3546 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3553 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), 3547 m.StoreToPointer(&output, kMachFloat64,
3554 m.Float64Add(a, m.Float64Mul(b, c))); 3548 m.Float64Add(a, m.Float64Mul(b, c)));
3555 m.Return(m.Int32Constant(0)); 3549 m.Return(m.Int32Constant(0));
3556 FOR_FLOAT64_INPUTS(i) { 3550 FOR_FLOAT64_INPUTS(i) {
3557 FOR_FLOAT64_INPUTS(j) { 3551 FOR_FLOAT64_INPUTS(j) {
3558 FOR_FLOAT64_INPUTS(k) { 3552 FOR_FLOAT64_INPUTS(k) {
3559 input_a = *i; 3553 input_a = *i;
3560 input_b = *j; 3554 input_b = *j;
3561 input_c = *k; 3555 input_c = *k;
3562 volatile double temp = input_b * input_c; 3556 volatile double temp = input_b * input_c;
3563 volatile double expected = input_a + temp; 3557 volatile double expected = input_a + temp;
3564 CHECK_EQ(0, m.Call()); 3558 CHECK_EQ(0, m.Call());
3565 CheckDoubleEq(expected, output); 3559 CheckDoubleEq(expected, output);
3566 } 3560 }
3567 } 3561 }
3568 } 3562 }
3569 } 3563 }
3570 } 3564 }
3571 3565
3572 3566
3573 TEST(RunFloat64MulAndFloat64SubP) { 3567 TEST(RunFloat64MulAndFloat64SubP) {
3574 double input_a = 0.0; 3568 double input_a = 0.0;
3575 double input_b = 0.0; 3569 double input_b = 0.0;
3576 double input_c = 0.0; 3570 double input_c = 0.0;
3577 double output = 0.0; 3571 double output = 0.0;
3578 3572
3579 RawMachineAssemblerTester<int32_t> m; 3573 RawMachineAssemblerTester<int32_t> m;
3580 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3574 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3581 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3575 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3582 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3576 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3583 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), 3577 m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c)));
3584 m.Float64Sub(a, m.Float64Mul(b, c)));
3585 m.Return(m.Int32Constant(0)); 3578 m.Return(m.Int32Constant(0));
3586 3579
3587 FOR_FLOAT64_INPUTS(i) { 3580 FOR_FLOAT64_INPUTS(i) {
3588 FOR_FLOAT64_INPUTS(j) { 3581 FOR_FLOAT64_INPUTS(j) {
3589 FOR_FLOAT64_INPUTS(k) { 3582 FOR_FLOAT64_INPUTS(k) {
3590 input_a = *i; 3583 input_a = *i;
3591 input_b = *j; 3584 input_b = *j;
3592 input_c = *k; 3585 input_c = *k;
3593 volatile double temp = input_b * input_c; 3586 volatile double temp = input_b * input_c;
3594 volatile double expected = input_a - temp; 3587 volatile double expected = input_a - temp;
3595 CHECK_EQ(0, m.Call()); 3588 CHECK_EQ(0, m.Call());
3596 CheckDoubleEq(expected, output); 3589 CheckDoubleEq(expected, output);
3597 } 3590 }
3598 } 3591 }
3599 } 3592 }
3600 } 3593 }
3601 3594
3602 3595
3603 TEST(RunFloat64MulImm) { 3596 TEST(RunFloat64MulImm) {
3604 double input = 0.0; 3597 double input = 0.0;
3605 double output = 0.0; 3598 double output = 0.0;
3606 3599
3607 { 3600 {
3608 FOR_FLOAT64_INPUTS(i) { 3601 FOR_FLOAT64_INPUTS(i) {
3609 RawMachineAssemblerTester<int32_t> m; 3602 RawMachineAssemblerTester<int32_t> m;
3610 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3603 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3611 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); 3604 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0);
3612 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1); 3605 m.StoreToPointer(&output, kMachFloat64, t1);
3613 m.Return(m.Int32Constant(0)); 3606 m.Return(m.Int32Constant(0));
3614 FOR_FLOAT64_INPUTS(j) { 3607 FOR_FLOAT64_INPUTS(j) {
3615 input = *j; 3608 input = *j;
3616 double expected = *i * input; 3609 double expected = *i * input;
3617 CHECK_EQ(0, m.Call()); 3610 CHECK_EQ(0, m.Call());
3618 CheckDoubleEq(expected, output); 3611 CheckDoubleEq(expected, output);
3619 } 3612 }
3620 } 3613 }
3621 } 3614 }
3622 { 3615 {
3623 FOR_FLOAT64_INPUTS(i) { 3616 FOR_FLOAT64_INPUTS(i) {
3624 RawMachineAssemblerTester<int32_t> m; 3617 RawMachineAssemblerTester<int32_t> m;
3625 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3618 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3626 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); 3619 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i));
3627 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1); 3620 m.StoreToPointer(&output, kMachFloat64, t1);
3628 m.Return(m.Int32Constant(0)); 3621 m.Return(m.Int32Constant(0));
3629 FOR_FLOAT64_INPUTS(j) { 3622 FOR_FLOAT64_INPUTS(j) {
3630 input = *j; 3623 input = *j;
3631 double expected = input * *i; 3624 double expected = input * *i;
3632 CHECK_EQ(0, m.Call()); 3625 CHECK_EQ(0, m.Call());
3633 CheckDoubleEq(expected, output); 3626 CheckDoubleEq(expected, output);
3634 } 3627 }
3635 } 3628 }
3636 } 3629 }
3637 } 3630 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 } 3675 }
3683 } 3676 }
3684 3677
3685 3678
3686 TEST(RunChangeInt32ToFloat64_A) { 3679 TEST(RunChangeInt32ToFloat64_A) {
3687 RawMachineAssemblerTester<int32_t> m; 3680 RawMachineAssemblerTester<int32_t> m;
3688 int32_t magic = 0x986234; 3681 int32_t magic = 0x986234;
3689 double result = 0; 3682 double result = 0;
3690 3683
3691 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic)); 3684 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic));
3692 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result), 3685 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(0), convert,
3693 m.Int32Constant(0), convert); 3686 kNoWriteBarrier);
3694 m.Return(m.Int32Constant(magic)); 3687 m.Return(m.Int32Constant(magic));
3695 3688
3696 CHECK_EQ(magic, m.Call()); 3689 CHECK_EQ(magic, m.Call());
3697 CHECK_EQ(static_cast<double>(magic), result); 3690 CHECK_EQ(static_cast<double>(magic), result);
3698 } 3691 }
3699 3692
3700 3693
3701 TEST(RunChangeInt32ToFloat64_B) { 3694 TEST(RunChangeInt32ToFloat64_B) {
3702 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3695 RawMachineAssemblerTester<int32_t> m(kMachInt32);
3703 double output = 0; 3696 double output = 0;
3704 3697
3705 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0)); 3698 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0));
3706 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&output), 3699 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert,
3707 m.Int32Constant(0), convert); 3700 kNoWriteBarrier);
3708 m.Return(m.Parameter(0)); 3701 m.Return(m.Parameter(0));
3709 3702
3710 FOR_INT32_INPUTS(i) { 3703 FOR_INT32_INPUTS(i) {
3711 int32_t expect = *i; 3704 int32_t expect = *i;
3712 CHECK_EQ(expect, m.Call(expect)); 3705 CHECK_EQ(expect, m.Call(expect));
3713 CHECK_EQ(static_cast<double>(expect), output); 3706 CHECK_EQ(static_cast<double>(expect), output);
3714 } 3707 }
3715 } 3708 }
3716 3709
3717 3710
3718 TEST(RunChangeUint32ToFloat64_B) { 3711 TEST(RunChangeUint32ToFloat64_B) {
3719 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 3712 RawMachineAssemblerTester<uint32_t> m(kMachUint32);
3720 double output = 0; 3713 double output = 0;
3721 3714
3722 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); 3715 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0));
3723 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&output), 3716 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert,
3724 m.Int32Constant(0), convert); 3717 kNoWriteBarrier);
3725 m.Return(m.Parameter(0)); 3718 m.Return(m.Parameter(0));
3726 3719
3727 FOR_UINT32_INPUTS(i) { 3720 FOR_UINT32_INPUTS(i) {
3728 uint32_t expect = *i; 3721 uint32_t expect = *i;
3729 CHECK_EQ(expect, m.Call(expect)); 3722 CHECK_EQ(expect, m.Call(expect));
3730 CHECK_EQ(static_cast<double>(expect), output); 3723 CHECK_EQ(static_cast<double>(expect), output);
3731 } 3724 }
3732 } 3725 }
3733 3726
3734 3727
3735 TEST(RunChangeUint32ToFloat64_spilled) { 3728 TEST(RunChangeUint32ToFloat64_spilled) {
3736 RawMachineAssemblerTester<int32_t> m; 3729 RawMachineAssemblerTester<int32_t> m;
3737 const int kNumInputs = 32; 3730 const int kNumInputs = 32;
3738 int32_t magic = 0x786234; 3731 int32_t magic = 0x786234;
3739 uint32_t input[kNumInputs]; 3732 uint32_t input[kNumInputs];
3740 double result[kNumInputs]; 3733 double result[kNumInputs];
3741 Node* input_node[kNumInputs]; 3734 Node* input_node[kNumInputs];
3742 3735
3743 for (int i = 0; i < kNumInputs; i++) { 3736 for (int i = 0; i < kNumInputs; i++) {
3744 input_node[i] = 3737 input_node[i] =
3745 m.Load(kMachUint32, m.PointerConstant(&input), m.Int32Constant(i * 4)); 3738 m.Load(kMachUint32, m.PointerConstant(&input), m.Int32Constant(i * 4));
3746 } 3739 }
3747 3740
3748 for (int i = 0; i < kNumInputs; i++) { 3741 for (int i = 0; i < kNumInputs; i++) {
3749 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result), 3742 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8),
3750 m.Int32Constant(i * 8), m.ChangeUint32ToFloat64(input_node[i])); 3743 m.ChangeUint32ToFloat64(input_node[i]), kNoWriteBarrier);
3751 } 3744 }
3752 3745
3753 m.Return(m.Int32Constant(magic)); 3746 m.Return(m.Int32Constant(magic));
3754 3747
3755 for (int i = 0; i < kNumInputs; i++) { 3748 for (int i = 0; i < kNumInputs; i++) {
3756 input[i] = 100 + i; 3749 input[i] = 100 + i;
3757 } 3750 }
3758 3751
3759 CHECK_EQ(magic, m.Call()); 3752 CHECK_EQ(magic, m.Call());
3760 3753
3761 for (int i = 0; i < kNumInputs; i++) { 3754 for (int i = 0; i < kNumInputs; i++) {
3762 CHECK_EQ(result[i], static_cast<double>(100 + i)); 3755 CHECK_EQ(result[i], static_cast<double>(100 + i));
3763 } 3756 }
3764 } 3757 }
3765 3758
3766 3759
3767 TEST(RunChangeFloat64ToInt32_A) { 3760 TEST(RunChangeFloat64ToInt32_A) {
3768 RawMachineAssemblerTester<int32_t> m; 3761 RawMachineAssemblerTester<int32_t> m;
3769 int32_t magic = 0x786234; 3762 int32_t magic = 0x786234;
3770 double input = 11.1; 3763 double input = 11.1;
3771 int32_t result = 0; 3764 int32_t result = 0;
3772 3765
3773 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&result), 3766 m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(0),
3774 m.Int32Constant(0), m.ChangeFloat64ToInt32(m.Float64Constant(input))); 3767 m.ChangeFloat64ToInt32(m.Float64Constant(input)), kNoWriteBarrier);
3775 m.Return(m.Int32Constant(magic)); 3768 m.Return(m.Int32Constant(magic));
3776 3769
3777 CHECK_EQ(magic, m.Call()); 3770 CHECK_EQ(magic, m.Call());
3778 CHECK_EQ(static_cast<int32_t>(input), result); 3771 CHECK_EQ(static_cast<int32_t>(input), result);
3779 } 3772 }
3780 3773
3781 3774
3782 TEST(RunChangeFloat64ToInt32_B) { 3775 TEST(RunChangeFloat64ToInt32_B) {
3783 RawMachineAssemblerTester<int32_t> m; 3776 RawMachineAssemblerTester<int32_t> m;
3784 double input = 0; 3777 double input = 0;
3785 int32_t output = 0; 3778 int32_t output = 0;
3786 3779
3787 Node* load = 3780 Node* load =
3788 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 3781 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0));
3789 Node* convert = m.ChangeFloat64ToInt32(load); 3782 Node* convert = m.ChangeFloat64ToInt32(load);
3790 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&output), 3783 m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert,
3791 m.Int32Constant(0), convert); 3784 kNoWriteBarrier);
3792 m.Return(convert); 3785 m.Return(convert);
3793 3786
3794 { 3787 {
3795 FOR_INT32_INPUTS(i) { 3788 FOR_INT32_INPUTS(i) {
3796 input = *i; 3789 input = *i;
3797 int32_t expect = *i; 3790 int32_t expect = *i;
3798 CHECK_EQ(expect, m.Call()); 3791 CHECK_EQ(expect, m.Call());
3799 CHECK_EQ(expect, output); 3792 CHECK_EQ(expect, output);
3800 } 3793 }
3801 } 3794 }
(...skipping 20 matching lines...) Expand all
3822 3815
3823 3816
3824 TEST(RunChangeFloat64ToUint32_B) { 3817 TEST(RunChangeFloat64ToUint32_B) {
3825 RawMachineAssemblerTester<int32_t> m; 3818 RawMachineAssemblerTester<int32_t> m;
3826 double input = 0; 3819 double input = 0;
3827 int32_t output = 0; 3820 int32_t output = 0;
3828 3821
3829 Node* load = 3822 Node* load =
3830 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 3823 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0));
3831 Node* convert = m.ChangeFloat64ToUint32(load); 3824 Node* convert = m.ChangeFloat64ToUint32(load);
3832 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&output), 3825 m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert,
3833 m.Int32Constant(0), convert); 3826 kNoWriteBarrier);
3834 m.Return(convert); 3827 m.Return(convert);
3835 3828
3836 { 3829 {
3837 FOR_UINT32_INPUTS(i) { 3830 FOR_UINT32_INPUTS(i) {
3838 input = *i; 3831 input = *i;
3839 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t. 3832 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t.
3840 int32_t expect = static_cast<int32_t>(*i); 3833 int32_t expect = static_cast<int32_t>(*i);
3841 CHECK_EQ(expect, m.Call()); 3834 CHECK_EQ(expect, m.Call());
3842 CHECK_EQ(expect, output); 3835 CHECK_EQ(expect, output);
3843 } 3836 }
(...skipping 27 matching lines...) Expand all
3871 double input[kNumInputs]; 3864 double input[kNumInputs];
3872 int32_t result[kNumInputs]; 3865 int32_t result[kNumInputs];
3873 Node* input_node[kNumInputs]; 3866 Node* input_node[kNumInputs];
3874 3867
3875 for (int i = 0; i < kNumInputs; i++) { 3868 for (int i = 0; i < kNumInputs; i++) {
3876 input_node[i] = 3869 input_node[i] =
3877 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3870 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3878 } 3871 }
3879 3872
3880 for (int i = 0; i < kNumInputs; i++) { 3873 for (int i = 0; i < kNumInputs; i++) {
3881 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&result), 3874 m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(i * 4),
3882 m.Int32Constant(i * 4), m.ChangeFloat64ToInt32(input_node[i])); 3875 m.ChangeFloat64ToInt32(input_node[i]), kNoWriteBarrier);
3883 } 3876 }
3884 3877
3885 m.Return(m.Int32Constant(magic)); 3878 m.Return(m.Int32Constant(magic));
3886 3879
3887 for (int i = 0; i < kNumInputs; i++) { 3880 for (int i = 0; i < kNumInputs; i++) {
3888 input[i] = 100.9 + i; 3881 input[i] = 100.9 + i;
3889 } 3882 }
3890 3883
3891 CHECK_EQ(magic, m.Call()); 3884 CHECK_EQ(magic, m.Call());
3892 3885
(...skipping 10 matching lines...) Expand all
3903 double input[kNumInputs]; 3896 double input[kNumInputs];
3904 uint32_t result[kNumInputs]; 3897 uint32_t result[kNumInputs];
3905 Node* input_node[kNumInputs]; 3898 Node* input_node[kNumInputs];
3906 3899
3907 for (int i = 0; i < kNumInputs; i++) { 3900 for (int i = 0; i < kNumInputs; i++) {
3908 input_node[i] = 3901 input_node[i] =
3909 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3902 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3910 } 3903 }
3911 3904
3912 for (int i = 0; i < kNumInputs; i++) { 3905 for (int i = 0; i < kNumInputs; i++) {
3913 m.Store(StoreRepForType(kMachUint32), m.PointerConstant(&result), 3906 m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4),
3914 m.Int32Constant(i * 4), m.ChangeFloat64ToUint32(input_node[i])); 3907 m.ChangeFloat64ToUint32(input_node[i]), kNoWriteBarrier);
3915 } 3908 }
3916 3909
3917 m.Return(m.Int32Constant(magic)); 3910 m.Return(m.Int32Constant(magic));
3918 3911
3919 for (int i = 0; i < kNumInputs; i++) { 3912 for (int i = 0; i < kNumInputs; i++) {
3920 if (i % 2) { 3913 if (i % 2) {
3921 input[i] = 100 + i + 2147483648u; 3914 input[i] = 100 + i + 2147483648u;
3922 } else { 3915 } else {
3923 input[i] = 100 + i; 3916 input[i] = 100 + i;
3924 } 3917 }
(...skipping 18 matching lines...) Expand all
3943 double input[kNumInputs]; 3936 double input[kNumInputs];
3944 float result[kNumInputs]; 3937 float result[kNumInputs];
3945 Node* input_node[kNumInputs]; 3938 Node* input_node[kNumInputs];
3946 3939
3947 for (int i = 0; i < kNumInputs; i++) { 3940 for (int i = 0; i < kNumInputs; i++) {
3948 input_node[i] = 3941 input_node[i] =
3949 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3942 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3950 } 3943 }
3951 3944
3952 for (int i = 0; i < kNumInputs; i++) { 3945 for (int i = 0; i < kNumInputs; i++) {
3953 m.Store(StoreRepForType(kMachFloat32), m.PointerConstant(&result), 3946 m.Store(kMachFloat32, m.PointerConstant(&result), m.Int32Constant(i * 4),
3954 m.Int32Constant(i * 4), m.TruncateFloat64ToFloat32(input_node[i])); 3947 m.TruncateFloat64ToFloat32(input_node[i]), kNoWriteBarrier);
3955 } 3948 }
3956 3949
3957 m.Return(m.Int32Constant(magic)); 3950 m.Return(m.Int32Constant(magic));
3958 3951
3959 for (int i = 0; i < kNumInputs; i++) { 3952 for (int i = 0; i < kNumInputs; i++) {
3960 input[i] = 0.1 + i; 3953 input[i] = 0.1 + i;
3961 } 3954 }
3962 3955
3963 CHECK_EQ(magic, m.Call()); 3956 CHECK_EQ(magic, m.Call());
3964 3957
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 MLabel blocka, blockb, end; 4012 MLabel blocka, blockb, end;
4020 Node* k1 = m.Float32Constant(constant); 4013 Node* k1 = m.Float32Constant(constant);
4021 Node* k2 = m.Float32Constant(0 - constant); 4014 Node* k2 = m.Float32Constant(0 - constant);
4022 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4015 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4023 m.Bind(&blocka); 4016 m.Bind(&blocka);
4024 m.Goto(&end); 4017 m.Goto(&end);
4025 m.Bind(&blockb); 4018 m.Bind(&blockb);
4026 m.Goto(&end); 4019 m.Goto(&end);
4027 m.Bind(&end); 4020 m.Bind(&end);
4028 Node* phi = m.Phi(kMachFloat32, k2, k1); 4021 Node* phi = m.Phi(kMachFloat32, k2, k1);
4029 m.Store(StoreRepForType(kMachFloat32), m.PointerConstant(&buffer), 4022 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi,
4030 m.IntPtrConstant(0), phi); 4023 kNoWriteBarrier);
4031 m.Return(m.Int32Constant(magic)); 4024 m.Return(m.Int32Constant(magic));
4032 4025
4033 CHECK_EQ(magic, m.Call()); 4026 CHECK_EQ(magic, m.Call());
4034 CHECK(constant == buffer); 4027 CHECK(constant == buffer);
4035 } 4028 }
4036 4029
4037 4030
4038 TEST(RunDoubleDiamond) { 4031 TEST(RunDoubleDiamond) {
4039 RawMachineAssemblerTester<int32_t> m; 4032 RawMachineAssemblerTester<int32_t> m;
4040 4033
4041 const int magic = 99645; 4034 const int magic = 99645;
4042 double buffer = 0.1; 4035 double buffer = 0.1;
4043 double constant = 99.99; 4036 double constant = 99.99;
4044 4037
4045 MLabel blocka, blockb, end; 4038 MLabel blocka, blockb, end;
4046 Node* k1 = m.Float64Constant(constant); 4039 Node* k1 = m.Float64Constant(constant);
4047 Node* k2 = m.Float64Constant(0 - constant); 4040 Node* k2 = m.Float64Constant(0 - constant);
4048 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4041 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4049 m.Bind(&blocka); 4042 m.Bind(&blocka);
4050 m.Goto(&end); 4043 m.Goto(&end);
4051 m.Bind(&blockb); 4044 m.Bind(&blockb);
4052 m.Goto(&end); 4045 m.Goto(&end);
4053 m.Bind(&end); 4046 m.Bind(&end);
4054 Node* phi = m.Phi(kMachFloat64, k2, k1); 4047 Node* phi = m.Phi(kMachFloat64, k2, k1);
4055 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&buffer), 4048 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi,
4056 m.Int32Constant(0), phi); 4049 kNoWriteBarrier);
4057 m.Return(m.Int32Constant(magic)); 4050 m.Return(m.Int32Constant(magic));
4058 4051
4059 CHECK_EQ(magic, m.Call()); 4052 CHECK_EQ(magic, m.Call());
4060 CHECK_EQ(constant, buffer); 4053 CHECK_EQ(constant, buffer);
4061 } 4054 }
4062 4055
4063 4056
4064 TEST(RunRefDiamond) { 4057 TEST(RunRefDiamond) {
4065 RawMachineAssemblerTester<int32_t> m; 4058 RawMachineAssemblerTester<int32_t> m;
4066 4059
4067 const int magic = 99644; 4060 const int magic = 99644;
4068 Handle<String> rexpected = 4061 Handle<String> rexpected =
4069 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); 4062 CcTest::i_isolate()->factory()->InternalizeUtf8String("A");
4070 String* buffer; 4063 String* buffer;
4071 4064
4072 MLabel blocka, blockb, end; 4065 MLabel blocka, blockb, end;
4073 Node* k1 = m.StringConstant("A"); 4066 Node* k1 = m.StringConstant("A");
4074 Node* k2 = m.StringConstant("B"); 4067 Node* k2 = m.StringConstant("B");
4075 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4068 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4076 m.Bind(&blocka); 4069 m.Bind(&blocka);
4077 m.Goto(&end); 4070 m.Goto(&end);
4078 m.Bind(&blockb); 4071 m.Bind(&blockb);
4079 m.Goto(&end); 4072 m.Goto(&end);
4080 m.Bind(&end); 4073 m.Bind(&end);
4081 Node* phi = m.Phi(kMachAnyTagged, k2, k1); 4074 Node* phi = m.Phi(kMachAnyTagged, k2, k1);
4082 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&buffer), 4075 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi,
4083 m.Int32Constant(0), phi); 4076 kNoWriteBarrier);
4084 m.Return(m.Int32Constant(magic)); 4077 m.Return(m.Int32Constant(magic));
4085 4078
4086 CHECK_EQ(magic, m.Call()); 4079 CHECK_EQ(magic, m.Call());
4087 CHECK(rexpected->SameValue(buffer)); 4080 CHECK(rexpected->SameValue(buffer));
4088 } 4081 }
4089 4082
4090 4083
4091 TEST(RunDoubleRefDiamond) { 4084 TEST(RunDoubleRefDiamond) {
4092 RawMachineAssemblerTester<int32_t> m; 4085 RawMachineAssemblerTester<int32_t> m;
4093 4086
(...skipping 10 matching lines...) Expand all
4104 Node* r1 = m.StringConstant("AX"); 4097 Node* r1 = m.StringConstant("AX");
4105 Node* r2 = m.StringConstant("BX"); 4098 Node* r2 = m.StringConstant("BX");
4106 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4099 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4107 m.Bind(&blocka); 4100 m.Bind(&blocka);
4108 m.Goto(&end); 4101 m.Goto(&end);
4109 m.Bind(&blockb); 4102 m.Bind(&blockb);
4110 m.Goto(&end); 4103 m.Goto(&end);
4111 m.Bind(&end); 4104 m.Bind(&end);
4112 Node* dphi = m.Phi(kMachFloat64, d2, d1); 4105 Node* dphi = m.Phi(kMachFloat64, d2, d1);
4113 Node* rphi = m.Phi(kMachAnyTagged, r2, r1); 4106 Node* rphi = m.Phi(kMachAnyTagged, r2, r1);
4114 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&dbuffer), 4107 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi,
4115 m.Int32Constant(0), dphi); 4108 kNoWriteBarrier);
4116 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&rbuffer), 4109 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi,
4117 m.Int32Constant(0), rphi); 4110 kNoWriteBarrier);
4118 m.Return(m.Int32Constant(magic)); 4111 m.Return(m.Int32Constant(magic));
4119 4112
4120 CHECK_EQ(magic, m.Call()); 4113 CHECK_EQ(magic, m.Call());
4121 CHECK_EQ(dconstant, dbuffer); 4114 CHECK_EQ(dconstant, dbuffer);
4122 CHECK(rexpected->SameValue(rbuffer)); 4115 CHECK(rexpected->SameValue(rbuffer));
4123 } 4116 }
4124 4117
4125 4118
4126 TEST(RunDoubleRefDoubleDiamond) { 4119 TEST(RunDoubleRefDoubleDiamond) {
4127 RawMachineAssemblerTester<int32_t> m; 4120 RawMachineAssemblerTester<int32_t> m;
(...skipping 21 matching lines...) Expand all
4149 m.Branch(m.Int32Constant(0), &blockd, &blocke); 4142 m.Branch(m.Int32Constant(0), &blockd, &blocke);
4150 4143
4151 m.Bind(&blockd); 4144 m.Bind(&blockd);
4152 m.Goto(&end); 4145 m.Goto(&end);
4153 m.Bind(&blocke); 4146 m.Bind(&blocke);
4154 m.Goto(&end); 4147 m.Goto(&end);
4155 m.Bind(&end); 4148 m.Bind(&end);
4156 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); 4149 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1);
4157 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); 4150 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1);
4158 4151
4159 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&dbuffer), 4152 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2,
4160 m.Int32Constant(0), dphi2); 4153 kNoWriteBarrier);
4161 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&rbuffer), 4154 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0),
4162 m.Int32Constant(0), rphi2); 4155 rphi2, kNoWriteBarrier);
4163 m.Return(m.Int32Constant(magic)); 4156 m.Return(m.Int32Constant(magic));
4164 4157
4165 CHECK_EQ(magic, m.Call()); 4158 CHECK_EQ(magic, m.Call());
4166 CHECK_EQ(dconstant, dbuffer); 4159 CHECK_EQ(dconstant, dbuffer);
4167 CHECK(rexpected->SameValue(rbuffer)); 4160 CHECK(rexpected->SameValue(rbuffer));
4168 } 4161 }
4169 4162
4170 4163
4171 TEST(RunDoubleLoopPhi) { 4164 TEST(RunDoubleLoopPhi) {
4172 RawMachineAssemblerTester<int32_t> m; 4165 RawMachineAssemblerTester<int32_t> m;
4173 MLabel header, body, end; 4166 MLabel header, body, end;
4174 4167
4175 int magic = 99773; 4168 int magic = 99773;
4176 double buffer = 0.99; 4169 double buffer = 0.99;
4177 double dconstant = 777.1; 4170 double dconstant = 777.1;
4178 4171
4179 Node* zero = m.Int32Constant(0); 4172 Node* zero = m.Int32Constant(0);
4180 Node* dk = m.Float64Constant(dconstant); 4173 Node* dk = m.Float64Constant(dconstant);
4181 4174
4182 m.Goto(&header); 4175 m.Goto(&header);
4183 m.Bind(&header); 4176 m.Bind(&header);
4184 Node* phi = m.Phi(kMachFloat64, dk, dk); 4177 Node* phi = m.Phi(kMachFloat64, dk, dk);
4185 phi->ReplaceInput(1, phi); 4178 phi->ReplaceInput(1, phi);
4186 m.Branch(zero, &body, &end); 4179 m.Branch(zero, &body, &end);
4187 m.Bind(&body); 4180 m.Bind(&body);
4188 m.Goto(&header); 4181 m.Goto(&header);
4189 m.Bind(&end); 4182 m.Bind(&end);
4190 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&buffer), 4183 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi,
4191 m.Int32Constant(0), phi); 4184 kNoWriteBarrier);
4192 m.Return(m.Int32Constant(magic)); 4185 m.Return(m.Int32Constant(magic));
4193 4186
4194 CHECK_EQ(magic, m.Call()); 4187 CHECK_EQ(magic, m.Call());
4195 } 4188 }
4196 4189
4197 4190
4198 TEST(RunCountToTenAccRaw) { 4191 TEST(RunCountToTenAccRaw) {
4199 RawMachineAssemblerTester<int32_t> m; 4192 RawMachineAssemblerTester<int32_t> m;
4200 4193
4201 Node* zero = m.Int32Constant(0); 4194 Node* zero = m.Int32Constant(0);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 } 4468 }
4476 4469
4477 4470
4478 template <typename IntType, MachineType kRepresentation> 4471 template <typename IntType, MachineType kRepresentation>
4479 static void LoadStoreTruncation() { 4472 static void LoadStoreTruncation() {
4480 IntType input; 4473 IntType input;
4481 4474
4482 RawMachineAssemblerTester<int32_t> m; 4475 RawMachineAssemblerTester<int32_t> m;
4483 Node* a = m.LoadFromPointer(&input, kRepresentation); 4476 Node* a = m.LoadFromPointer(&input, kRepresentation);
4484 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); 4477 Node* ap1 = m.Int32Add(a, m.Int32Constant(1));
4485 m.StoreToPointer(&input, StoreRepForType(kRepresentation), ap1); 4478 m.StoreToPointer(&input, kRepresentation, ap1);
4486 m.Return(ap1); 4479 m.Return(ap1);
4487 4480
4488 const IntType max = std::numeric_limits<IntType>::max(); 4481 const IntType max = std::numeric_limits<IntType>::max();
4489 const IntType min = std::numeric_limits<IntType>::min(); 4482 const IntType min = std::numeric_limits<IntType>::min();
4490 4483
4491 // Test upper bound. 4484 // Test upper bound.
4492 input = max; 4485 input = max;
4493 CHECK_EQ(max + 1, m.Call()); 4486 CHECK_EQ(max + 1, m.Call());
4494 CHECK_EQ(min, input); 4487 CHECK_EQ(min, input);
4495 4488
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4578 int32_t outputs[kInputSize]; 4571 int32_t outputs[kInputSize];
4579 for (int i = 0; i < kInputSize; i++) { 4572 for (int i = 0; i < kInputSize; i++) {
4580 inputs[i] = i; 4573 inputs[i] = i;
4581 outputs[i] = -1; 4574 outputs[i] = -1;
4582 } 4575 }
4583 RawMachineAssemblerTester<int32_t*> m; 4576 RawMachineAssemblerTester<int32_t*> m;
4584 Node* input = m.PointerConstant(&inputs[0]); 4577 Node* input = m.PointerConstant(&inputs[0]);
4585 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); 4578 Node* output = m.PointerConstant(&outputs[kInputSize - 1]);
4586 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); 4579 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0]));
4587 for (int i = 0; i < kInputSize; i++) { 4580 for (int i = 0; i < kInputSize; i++) {
4588 m.Store(StoreRepForType(kMachInt32), output, m.Load(kMachInt32, input)); 4581 m.Store(kMachInt32, output, m.Load(kMachInt32, input), kNoWriteBarrier);
4589 input = m.IntPtrAdd(input, elem_size); 4582 input = m.IntPtrAdd(input, elem_size);
4590 output = m.IntPtrSub(output, elem_size); 4583 output = m.IntPtrSub(output, elem_size);
4591 } 4584 }
4592 m.Return(input); 4585 m.Return(input);
4593 CHECK_EQ(&inputs[kInputSize], m.Call()); 4586 CHECK_EQ(&inputs[kInputSize], m.Call());
4594 for (int i = 0; i < kInputSize; i++) { 4587 for (int i = 0; i < kInputSize; i++) {
4595 CHECK_EQ(i, inputs[i]); 4588 CHECK_EQ(i, inputs[i]);
4596 CHECK_EQ(kInputSize - i - 1, outputs[i]); 4589 CHECK_EQ(kInputSize - i - 1, outputs[i]);
4597 } 4590 }
4598 } 4591 }
4599 4592
4600 4593
4601 TEST(RunSpillLotsOfThings) { 4594 TEST(RunSpillLotsOfThings) {
4602 static const int kInputSize = 1000; 4595 static const int kInputSize = 1000;
4603 RawMachineAssemblerTester<int32_t> m; 4596 RawMachineAssemblerTester<int32_t> m;
4604 Node* accs[kInputSize]; 4597 Node* accs[kInputSize];
4605 int32_t outputs[kInputSize]; 4598 int32_t outputs[kInputSize];
4606 Node* one = m.Int32Constant(1); 4599 Node* one = m.Int32Constant(1);
4607 Node* acc = one; 4600 Node* acc = one;
4608 for (int i = 0; i < kInputSize; i++) { 4601 for (int i = 0; i < kInputSize; i++) {
4609 acc = m.Int32Add(acc, one); 4602 acc = m.Int32Add(acc, one);
4610 accs[i] = acc; 4603 accs[i] = acc;
4611 } 4604 }
4612 for (int i = 0; i < kInputSize; i++) { 4605 for (int i = 0; i < kInputSize; i++) {
4613 m.StoreToPointer(&outputs[i], StoreRepForType(kMachInt32), accs[i]); 4606 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]);
4614 } 4607 }
4615 m.Return(one); 4608 m.Return(one);
4616 m.Call(); 4609 m.Call();
4617 for (int i = 0; i < kInputSize; i++) { 4610 for (int i = 0; i < kInputSize; i++) {
4618 CHECK_EQ(outputs[i], i + 2); 4611 CHECK_EQ(outputs[i], i + 2);
4619 } 4612 }
4620 } 4613 }
4621 4614
4622 4615
4623 TEST(RunSpillConstantsAndParameters) { 4616 TEST(RunSpillConstantsAndParameters) {
4624 static const int kInputSize = 1000; 4617 static const int kInputSize = 1000;
4625 static const int32_t kBase = 987; 4618 static const int32_t kBase = 987;
4626 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 4619 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
4627 int32_t outputs[kInputSize]; 4620 int32_t outputs[kInputSize];
4628 Node* csts[kInputSize]; 4621 Node* csts[kInputSize];
4629 Node* accs[kInputSize]; 4622 Node* accs[kInputSize];
4630 Node* acc = m.Int32Constant(0); 4623 Node* acc = m.Int32Constant(0);
4631 for (int i = 0; i < kInputSize; i++) { 4624 for (int i = 0; i < kInputSize; i++) {
4632 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); 4625 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i));
4633 } 4626 }
4634 for (int i = 0; i < kInputSize; i++) { 4627 for (int i = 0; i < kInputSize; i++) {
4635 acc = m.Int32Add(acc, csts[i]); 4628 acc = m.Int32Add(acc, csts[i]);
4636 accs[i] = acc; 4629 accs[i] = acc;
4637 } 4630 }
4638 for (int i = 0; i < kInputSize; i++) { 4631 for (int i = 0; i < kInputSize; i++) {
4639 m.StoreToPointer(&outputs[i], StoreRepForType(kMachInt32), accs[i]); 4632 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]);
4640 } 4633 }
4641 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); 4634 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1))));
4642 FOR_INT32_INPUTS(i) { 4635 FOR_INT32_INPUTS(i) {
4643 FOR_INT32_INPUTS(j) { 4636 FOR_INT32_INPUTS(j) {
4644 int32_t expected = *i + *j; 4637 int32_t expected = *i + *j;
4645 for (int k = 0; k < kInputSize; k++) { 4638 for (int k = 0; k < kInputSize; k++) {
4646 expected += kBase + k; 4639 expected += kBase + k;
4647 } 4640 }
4648 CHECK_EQ(expected, m.Call(*i, *j)); 4641 CHECK_EQ(expected, m.Call(*i, *j));
4649 expected = 0; 4642 expected = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 } 4674 }
4682 4675
4683 4676
4684 TEST(RunInt32AddWithOverflowP) { 4677 TEST(RunInt32AddWithOverflowP) {
4685 int32_t actual_val = -1; 4678 int32_t actual_val = -1;
4686 RawMachineAssemblerTester<int32_t> m; 4679 RawMachineAssemblerTester<int32_t> m;
4687 Int32BinopTester bt(&m); 4680 Int32BinopTester bt(&m);
4688 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 4681 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
4689 Node* val = m.Projection(0, add); 4682 Node* val = m.Projection(0, add);
4690 Node* ovf = m.Projection(1, add); 4683 Node* ovf = m.Projection(1, add);
4691 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4684 m.StoreToPointer(&actual_val, kMachInt32, val);
4692 bt.AddReturn(ovf); 4685 bt.AddReturn(ovf);
4693 FOR_INT32_INPUTS(i) { 4686 FOR_INT32_INPUTS(i) {
4694 FOR_INT32_INPUTS(j) { 4687 FOR_INT32_INPUTS(j) {
4695 int32_t expected_val; 4688 int32_t expected_val;
4696 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4689 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4697 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4690 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4698 CHECK_EQ(expected_val, actual_val); 4691 CHECK_EQ(expected_val, actual_val);
4699 } 4692 }
4700 } 4693 }
4701 } 4694 }
4702 4695
4703 4696
4704 TEST(RunInt32AddWithOverflowImm) { 4697 TEST(RunInt32AddWithOverflowImm) {
4705 int32_t actual_val = -1, expected_val = 0; 4698 int32_t actual_val = -1, expected_val = 0;
4706 FOR_INT32_INPUTS(i) { 4699 FOR_INT32_INPUTS(i) {
4707 { 4700 {
4708 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4701 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4709 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4702 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4710 Node* val = m.Projection(0, add); 4703 Node* val = m.Projection(0, add);
4711 Node* ovf = m.Projection(1, add); 4704 Node* ovf = m.Projection(1, add);
4712 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4705 m.StoreToPointer(&actual_val, kMachInt32, val);
4713 m.Return(ovf); 4706 m.Return(ovf);
4714 FOR_INT32_INPUTS(j) { 4707 FOR_INT32_INPUTS(j) {
4715 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4708 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4716 CHECK_EQ(expected_ovf, m.Call(*j)); 4709 CHECK_EQ(expected_ovf, m.Call(*j));
4717 CHECK_EQ(expected_val, actual_val); 4710 CHECK_EQ(expected_val, actual_val);
4718 } 4711 }
4719 } 4712 }
4720 { 4713 {
4721 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4714 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4722 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4715 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4723 Node* val = m.Projection(0, add); 4716 Node* val = m.Projection(0, add);
4724 Node* ovf = m.Projection(1, add); 4717 Node* ovf = m.Projection(1, add);
4725 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4718 m.StoreToPointer(&actual_val, kMachInt32, val);
4726 m.Return(ovf); 4719 m.Return(ovf);
4727 FOR_INT32_INPUTS(j) { 4720 FOR_INT32_INPUTS(j) {
4728 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4721 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4729 CHECK_EQ(expected_ovf, m.Call(*j)); 4722 CHECK_EQ(expected_ovf, m.Call(*j));
4730 CHECK_EQ(expected_val, actual_val); 4723 CHECK_EQ(expected_val, actual_val);
4731 } 4724 }
4732 } 4725 }
4733 FOR_INT32_INPUTS(j) { 4726 FOR_INT32_INPUTS(j) {
4734 RawMachineAssemblerTester<int32_t> m; 4727 RawMachineAssemblerTester<int32_t> m;
4735 Node* add = 4728 Node* add =
4736 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4729 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4737 Node* val = m.Projection(0, add); 4730 Node* val = m.Projection(0, add);
4738 Node* ovf = m.Projection(1, add); 4731 Node* ovf = m.Projection(1, add);
4739 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4732 m.StoreToPointer(&actual_val, kMachInt32, val);
4740 m.Return(ovf); 4733 m.Return(ovf);
4741 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4734 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4742 CHECK_EQ(expected_ovf, m.Call()); 4735 CHECK_EQ(expected_ovf, m.Call());
4743 CHECK_EQ(expected_val, actual_val); 4736 CHECK_EQ(expected_val, actual_val);
4744 } 4737 }
4745 } 4738 }
4746 } 4739 }
4747 4740
4748 4741
4749 TEST(RunInt32AddWithOverflowInBranchP) { 4742 TEST(RunInt32AddWithOverflowInBranchP) {
(...skipping 19 matching lines...) Expand all
4769 } 4762 }
4770 4763
4771 4764
4772 TEST(RunInt32SubWithOverflowP) { 4765 TEST(RunInt32SubWithOverflowP) {
4773 int32_t actual_val = -1; 4766 int32_t actual_val = -1;
4774 RawMachineAssemblerTester<int32_t> m; 4767 RawMachineAssemblerTester<int32_t> m;
4775 Int32BinopTester bt(&m); 4768 Int32BinopTester bt(&m);
4776 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); 4769 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1);
4777 Node* val = m.Projection(0, add); 4770 Node* val = m.Projection(0, add);
4778 Node* ovf = m.Projection(1, add); 4771 Node* ovf = m.Projection(1, add);
4779 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4772 m.StoreToPointer(&actual_val, kMachInt32, val);
4780 bt.AddReturn(ovf); 4773 bt.AddReturn(ovf);
4781 FOR_INT32_INPUTS(i) { 4774 FOR_INT32_INPUTS(i) {
4782 FOR_INT32_INPUTS(j) { 4775 FOR_INT32_INPUTS(j) {
4783 int32_t expected_val; 4776 int32_t expected_val;
4784 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4777 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4785 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4778 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4786 CHECK_EQ(expected_val, actual_val); 4779 CHECK_EQ(expected_val, actual_val);
4787 } 4780 }
4788 } 4781 }
4789 } 4782 }
4790 4783
4791 4784
4792 TEST(RunInt32SubWithOverflowImm) { 4785 TEST(RunInt32SubWithOverflowImm) {
4793 int32_t actual_val = -1, expected_val = 0; 4786 int32_t actual_val = -1, expected_val = 0;
4794 FOR_INT32_INPUTS(i) { 4787 FOR_INT32_INPUTS(i) {
4795 { 4788 {
4796 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4789 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4797 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4790 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4798 Node* val = m.Projection(0, add); 4791 Node* val = m.Projection(0, add);
4799 Node* ovf = m.Projection(1, add); 4792 Node* ovf = m.Projection(1, add);
4800 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4793 m.StoreToPointer(&actual_val, kMachInt32, val);
4801 m.Return(ovf); 4794 m.Return(ovf);
4802 FOR_INT32_INPUTS(j) { 4795 FOR_INT32_INPUTS(j) {
4803 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4796 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4804 CHECK_EQ(expected_ovf, m.Call(*j)); 4797 CHECK_EQ(expected_ovf, m.Call(*j));
4805 CHECK_EQ(expected_val, actual_val); 4798 CHECK_EQ(expected_val, actual_val);
4806 } 4799 }
4807 } 4800 }
4808 { 4801 {
4809 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4802 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4810 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4803 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4811 Node* val = m.Projection(0, add); 4804 Node* val = m.Projection(0, add);
4812 Node* ovf = m.Projection(1, add); 4805 Node* ovf = m.Projection(1, add);
4813 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4806 m.StoreToPointer(&actual_val, kMachInt32, val);
4814 m.Return(ovf); 4807 m.Return(ovf);
4815 FOR_INT32_INPUTS(j) { 4808 FOR_INT32_INPUTS(j) {
4816 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); 4809 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val);
4817 CHECK_EQ(expected_ovf, m.Call(*j)); 4810 CHECK_EQ(expected_ovf, m.Call(*j));
4818 CHECK_EQ(expected_val, actual_val); 4811 CHECK_EQ(expected_val, actual_val);
4819 } 4812 }
4820 } 4813 }
4821 FOR_INT32_INPUTS(j) { 4814 FOR_INT32_INPUTS(j) {
4822 RawMachineAssemblerTester<int32_t> m; 4815 RawMachineAssemblerTester<int32_t> m;
4823 Node* add = 4816 Node* add =
4824 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4817 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4825 Node* val = m.Projection(0, add); 4818 Node* val = m.Projection(0, add);
4826 Node* ovf = m.Projection(1, add); 4819 Node* ovf = m.Projection(1, add);
4827 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val); 4820 m.StoreToPointer(&actual_val, kMachInt32, val);
4828 m.Return(ovf); 4821 m.Return(ovf);
4829 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4822 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4830 CHECK_EQ(expected_ovf, m.Call()); 4823 CHECK_EQ(expected_ovf, m.Call());
4831 CHECK_EQ(expected_val, actual_val); 4824 CHECK_EQ(expected_val, actual_val);
4832 } 4825 }
4833 } 4826 }
4834 } 4827 }
4835 4828
4836 4829
4837 TEST(RunInt32SubWithOverflowInBranchP) { 4830 TEST(RunInt32SubWithOverflowInBranchP) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4874 CHECK_EQ(2, m.Call()); 4867 CHECK_EQ(2, m.Call());
4875 input = V8_INT64_C(0x100000000); 4868 input = V8_INT64_C(0x100000000);
4876 CHECK_EQ(2, m.Call()); 4869 CHECK_EQ(2, m.Call());
4877 } 4870 }
4878 4871
4879 4872
4880 TEST(RunChangeInt32ToInt64P) { 4873 TEST(RunChangeInt32ToInt64P) {
4881 if (kPointerSize < 8) return; 4874 if (kPointerSize < 8) return;
4882 int64_t actual = -1; 4875 int64_t actual = -1;
4883 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4876 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4884 m.StoreToPointer(&actual, StoreRepForType(kMachInt64), 4877 m.StoreToPointer(&actual, kMachInt64, m.ChangeInt32ToInt64(m.Parameter(0)));
4885 m.ChangeInt32ToInt64(m.Parameter(0)));
4886 m.Return(m.Int32Constant(0)); 4878 m.Return(m.Int32Constant(0));
4887 FOR_INT32_INPUTS(i) { 4879 FOR_INT32_INPUTS(i) {
4888 int64_t expected = *i; 4880 int64_t expected = *i;
4889 CHECK_EQ(0, m.Call(*i)); 4881 CHECK_EQ(0, m.Call(*i));
4890 CHECK_EQ(expected, actual); 4882 CHECK_EQ(expected, actual);
4891 } 4883 }
4892 } 4884 }
4893 4885
4894 4886
4895 TEST(RunChangeUint32ToUint64P) { 4887 TEST(RunChangeUint32ToUint64P) {
4896 if (kPointerSize < 8) return; 4888 if (kPointerSize < 8) return;
4897 int64_t actual = -1; 4889 int64_t actual = -1;
4898 RawMachineAssemblerTester<int32_t> m(kMachUint32); 4890 RawMachineAssemblerTester<int32_t> m(kMachUint32);
4899 m.StoreToPointer(&actual, StoreRepForType(kMachUint64), 4891 m.StoreToPointer(&actual, kMachUint64,
4900 m.ChangeUint32ToUint64(m.Parameter(0))); 4892 m.ChangeUint32ToUint64(m.Parameter(0)));
4901 m.Return(m.Int32Constant(0)); 4893 m.Return(m.Int32Constant(0));
4902 FOR_UINT32_INPUTS(i) { 4894 FOR_UINT32_INPUTS(i) {
4903 int64_t expected = static_cast<uint64_t>(*i); 4895 int64_t expected = static_cast<uint64_t>(*i);
4904 CHECK_EQ(0, m.Call(*i)); 4896 CHECK_EQ(0, m.Call(*i));
4905 CHECK_EQ(expected, actual); 4897 CHECK_EQ(expected, actual);
4906 } 4898 }
4907 } 4899 }
4908 4900
4909 4901
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 CHECK_EQ(static_cast<int>(expected), m.Call()); 4982 CHECK_EQ(static_cast<int>(expected), m.Call());
4991 } 4983 }
4992 } 4984 }
4993 4985
4994 4986
4995 TEST(RunChangeFloat32ToFloat64) { 4987 TEST(RunChangeFloat32ToFloat64) {
4996 double actual = 0.0f; 4988 double actual = 0.0f;
4997 float expected = 0.0; 4989 float expected = 0.0;
4998 RawMachineAssemblerTester<int32_t> m; 4990 RawMachineAssemblerTester<int32_t> m;
4999 m.StoreToPointer( 4991 m.StoreToPointer(
5000 &actual, StoreRepForType(kMachFloat64), 4992 &actual, kMachFloat64,
5001 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); 4993 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32)));
5002 m.Return(m.Int32Constant(0)); 4994 m.Return(m.Int32Constant(0));
5003 FOR_FLOAT32_INPUTS(i) { 4995 FOR_FLOAT32_INPUTS(i) {
5004 expected = *i; 4996 expected = *i;
5005 CHECK_EQ(0, m.Call()); 4997 CHECK_EQ(0, m.Call());
5006 CHECK_EQ(static_cast<double>(expected), actual); 4998 CHECK_EQ(static_cast<double>(expected), actual);
5007 } 4999 }
5008 } 5000 }
5009 5001
5010 5002
5011 TEST(RunChangeFloat32ToFloat64_spilled) { 5003 TEST(RunChangeFloat32ToFloat64_spilled) {
5012 RawMachineAssemblerTester<int32_t> m; 5004 RawMachineAssemblerTester<int32_t> m;
5013 const int kNumInputs = 32; 5005 const int kNumInputs = 32;
5014 int32_t magic = 0x786234; 5006 int32_t magic = 0x786234;
5015 float input[kNumInputs]; 5007 float input[kNumInputs];
5016 double result[kNumInputs]; 5008 double result[kNumInputs];
5017 Node* input_node[kNumInputs]; 5009 Node* input_node[kNumInputs];
5018 5010
5019 for (int i = 0; i < kNumInputs; i++) { 5011 for (int i = 0; i < kNumInputs; i++) {
5020 input_node[i] = 5012 input_node[i] =
5021 m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4)); 5013 m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4));
5022 } 5014 }
5023 5015
5024 for (int i = 0; i < kNumInputs; i++) { 5016 for (int i = 0; i < kNumInputs; i++) {
5025 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result), 5017 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8),
5026 m.Int32Constant(i * 8), m.ChangeFloat32ToFloat64(input_node[i])); 5018 m.ChangeFloat32ToFloat64(input_node[i]), kNoWriteBarrier);
5027 } 5019 }
5028 5020
5029 m.Return(m.Int32Constant(magic)); 5021 m.Return(m.Int32Constant(magic));
5030 5022
5031 for (int i = 0; i < kNumInputs; i++) { 5023 for (int i = 0; i < kNumInputs; i++) {
5032 input[i] = 100.9f + i; 5024 input[i] = 100.9f + i;
5033 } 5025 }
5034 5026
5035 CHECK_EQ(magic, m.Call()); 5027 CHECK_EQ(magic, m.Call());
5036 5028
5037 for (int i = 0; i < kNumInputs; i++) { 5029 for (int i = 0; i < kNumInputs; i++) {
5038 CHECK_EQ(result[i], static_cast<double>(input[i])); 5030 CHECK_EQ(result[i], static_cast<double>(input[i]));
5039 } 5031 }
5040 } 5032 }
5041 5033
5042 5034
5043 TEST(RunTruncateFloat64ToFloat32) { 5035 TEST(RunTruncateFloat64ToFloat32) {
5044 float actual = 0.0f; 5036 float actual = 0.0f;
5045 double input = 0.0; 5037 double input = 0.0;
5046 RawMachineAssemblerTester<int32_t> m; 5038 RawMachineAssemblerTester<int32_t> m;
5047 m.StoreToPointer( 5039 m.StoreToPointer(
5048 &actual, StoreRepForType(kMachFloat32), 5040 &actual, kMachFloat32,
5049 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); 5041 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64)));
5050 m.Return(m.Int32Constant(0)); 5042 m.Return(m.Int32Constant(0));
5051 FOR_FLOAT64_INPUTS(i) { 5043 FOR_FLOAT64_INPUTS(i) {
5052 input = *i; 5044 input = *i;
5053 volatile double expected = DoubleToFloat32(input); 5045 volatile double expected = DoubleToFloat32(input);
5054 CHECK_EQ(0, m.Call()); 5046 CHECK_EQ(0, m.Call());
5055 CheckDoubleEq(expected, actual); 5047 CheckDoubleEq(expected, actual);
5056 } 5048 }
5057 } 5049 }
5058 5050
5059 5051
5060 TEST(RunFloat32Constant) { 5052 TEST(RunFloat32Constant) {
5061 FOR_FLOAT32_INPUTS(i) { 5053 FOR_FLOAT32_INPUTS(i) {
5062 float expected = *i; 5054 float expected = *i;
5063 float actual = *i; 5055 float actual = *i;
5064 RawMachineAssemblerTester<int32_t> m; 5056 RawMachineAssemblerTester<int32_t> m;
5065 m.StoreToPointer(&actual, StoreRepForType(kMachFloat32), 5057 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected));
5066 m.Float32Constant(expected));
5067 m.Return(m.Int32Constant(0)); 5058 m.Return(m.Int32Constant(0));
5068 CHECK_EQ(0, m.Call()); 5059 CHECK_EQ(0, m.Call());
5069 CHECK_EQ(expected, actual); 5060 CHECK_EQ(expected, actual);
5070 } 5061 }
5071 } 5062 }
5072 5063
5073 5064
5074 TEST(RunFloat64ExtractLowWord32) { 5065 TEST(RunFloat64ExtractLowWord32) {
5075 uint64_t input = 0; 5066 uint64_t input = 0;
5076 RawMachineAssemblerTester<int32_t> m; 5067 RawMachineAssemblerTester<int32_t> m;
(...skipping 16 matching lines...) Expand all
5093 CHECK_EQ(expected, m.Call()); 5084 CHECK_EQ(expected, m.Call());
5094 } 5085 }
5095 } 5086 }
5096 5087
5097 5088
5098 TEST(RunFloat64InsertLowWord32) { 5089 TEST(RunFloat64InsertLowWord32) {
5099 uint64_t input = 0; 5090 uint64_t input = 0;
5100 uint64_t result = 0; 5091 uint64_t result = 0;
5101 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5092 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5102 m.StoreToPointer( 5093 m.StoreToPointer(
5103 &result, StoreRepForType(kMachFloat64), 5094 &result, kMachFloat64,
5104 m.Float64InsertLowWord32(m.LoadFromPointer(&input, kMachFloat64), 5095 m.Float64InsertLowWord32(m.LoadFromPointer(&input, kMachFloat64),
5105 m.Parameter(0))); 5096 m.Parameter(0)));
5106 m.Return(m.Int32Constant(0)); 5097 m.Return(m.Int32Constant(0));
5107 FOR_FLOAT64_INPUTS(i) { 5098 FOR_FLOAT64_INPUTS(i) {
5108 FOR_INT32_INPUTS(j) { 5099 FOR_INT32_INPUTS(j) {
5109 input = bit_cast<uint64_t>(*i); 5100 input = bit_cast<uint64_t>(*i);
5110 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF))) | 5101 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF))) |
5111 (static_cast<uint64_t>(bit_cast<uint32_t>(*j))); 5102 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)));
5112 CHECK_EQ(0, m.Call(*j)); 5103 CHECK_EQ(0, m.Call(*j));
5113 CHECK_EQ(expected, result); 5104 CHECK_EQ(expected, result);
5114 } 5105 }
5115 } 5106 }
5116 } 5107 }
5117 5108
5118 5109
5119 TEST(RunFloat64InsertHighWord32) { 5110 TEST(RunFloat64InsertHighWord32) {
5120 uint64_t input = 0; 5111 uint64_t input = 0;
5121 uint64_t result = 0; 5112 uint64_t result = 0;
5122 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5113 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5123 m.StoreToPointer( 5114 m.StoreToPointer(
5124 &result, StoreRepForType(kMachFloat64), 5115 &result, kMachFloat64,
5125 m.Float64InsertHighWord32(m.LoadFromPointer(&input, kMachFloat64), 5116 m.Float64InsertHighWord32(m.LoadFromPointer(&input, kMachFloat64),
5126 m.Parameter(0))); 5117 m.Parameter(0)));
5127 m.Return(m.Int32Constant(0)); 5118 m.Return(m.Int32Constant(0));
5128 FOR_FLOAT64_INPUTS(i) { 5119 FOR_FLOAT64_INPUTS(i) {
5129 FOR_INT32_INPUTS(j) { 5120 FOR_INT32_INPUTS(j) {
5130 input = bit_cast<uint64_t>(*i); 5121 input = bit_cast<uint64_t>(*i);
5131 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) | 5122 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) |
5132 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32); 5123 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32);
5133 CHECK_EQ(0, m.Call(*j)); 5124 CHECK_EQ(0, m.Call(*j));
5134 CHECK_EQ(expected, result); 5125 CHECK_EQ(expected, result);
5135 } 5126 }
5136 } 5127 }
5137 } 5128 }
5138 5129
5139 5130
5140 TEST(RunFloat32Abs) { 5131 TEST(RunFloat32Abs) {
5141 float input = -1.0; 5132 float input = -1.0;
5142 float result = 0.0; 5133 float result = 0.0;
5143 RawMachineAssemblerTester<int32_t> m; 5134 RawMachineAssemblerTester<int32_t> m;
5144 m.StoreToPointer(&result, StoreRepForType(kMachFloat32), 5135 m.StoreToPointer(&result, kMachFloat32,
5145 m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32))); 5136 m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32)));
5146 m.Return(m.Int32Constant(0)); 5137 m.Return(m.Int32Constant(0));
5147 FOR_FLOAT32_INPUTS(i) { 5138 FOR_FLOAT32_INPUTS(i) {
5148 input = *i; 5139 input = *i;
5149 float expected = std::abs(input); 5140 float expected = std::abs(input);
5150 CHECK_EQ(0, m.Call()); 5141 CHECK_EQ(0, m.Call());
5151 CheckFloatEq(expected, result); 5142 CheckFloatEq(expected, result);
5152 } 5143 }
5153 } 5144 }
5154 5145
5155 5146
5156 TEST(RunFloat64Abs) { 5147 TEST(RunFloat64Abs) {
5157 double input = -1.0; 5148 double input = -1.0;
5158 double result = 0.0; 5149 double result = 0.0;
5159 RawMachineAssemblerTester<int32_t> m; 5150 RawMachineAssemblerTester<int32_t> m;
5160 m.StoreToPointer(&result, StoreRepForType(kMachFloat64), 5151 m.StoreToPointer(&result, kMachFloat64,
5161 m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64))); 5152 m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64)));
5162 m.Return(m.Int32Constant(0)); 5153 m.Return(m.Int32Constant(0));
5163 FOR_FLOAT64_INPUTS(i) { 5154 FOR_FLOAT64_INPUTS(i) {
5164 input = *i; 5155 input = *i;
5165 double expected = std::abs(input); 5156 double expected = std::abs(input);
5166 CHECK_EQ(0, m.Call()); 5157 CHECK_EQ(0, m.Call());
5167 CheckDoubleEq(expected, result); 5158 CheckDoubleEq(expected, result);
5168 } 5159 }
5169 } 5160 }
5170 5161
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 -two_52 + 1 - 0.1, 5256 -two_52 + 1 - 0.1,
5266 -two_52 + 1 - 0.5, 5257 -two_52 + 1 - 0.5,
5267 -two_52 + 1 - 0.7}; 5258 -two_52 + 1 - 0.7};
5268 5259
5269 5260
5270 TEST(RunFloat64RoundDown1) { 5261 TEST(RunFloat64RoundDown1) {
5271 double input = -1.0; 5262 double input = -1.0;
5272 double result = 0.0; 5263 double result = 0.0;
5273 RawMachineAssemblerTester<int32_t> m; 5264 RawMachineAssemblerTester<int32_t> m;
5274 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5265 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5275 m.StoreToPointer(&result, StoreRepForType(kMachFloat64), 5266 m.StoreToPointer(&result, kMachFloat64,
5276 m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64))); 5267 m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64)));
5277 m.Return(m.Int32Constant(0)); 5268 m.Return(m.Int32Constant(0));
5278 for (size_t i = 0; i < arraysize(kValues); ++i) { 5269 for (size_t i = 0; i < arraysize(kValues); ++i) {
5279 input = kValues[i]; 5270 input = kValues[i];
5280 CHECK_EQ(0, m.Call()); 5271 CHECK_EQ(0, m.Call());
5281 double expected = std::floor(kValues[i]); 5272 double expected = std::floor(kValues[i]);
5282 CHECK_EQ(expected, result); 5273 CHECK_EQ(expected, result);
5283 } 5274 }
5284 } 5275 }
5285 5276
5286 5277
5287 TEST(RunFloat64RoundDown2) { 5278 TEST(RunFloat64RoundDown2) {
5288 double input = -1.0; 5279 double input = -1.0;
5289 double result = 0.0; 5280 double result = 0.0;
5290 RawMachineAssemblerTester<int32_t> m; 5281 RawMachineAssemblerTester<int32_t> m;
5291 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5282 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5292 m.StoreToPointer(&result, StoreRepForType(kMachFloat64), 5283 m.StoreToPointer(&result, kMachFloat64,
5293 m.Float64Sub(m.Float64Constant(-0.0), 5284 m.Float64Sub(m.Float64Constant(-0.0),
5294 m.Float64RoundDown(m.Float64Sub( 5285 m.Float64RoundDown(m.Float64Sub(
5295 m.Float64Constant(-0.0), 5286 m.Float64Constant(-0.0),
5296 m.LoadFromPointer(&input, kMachFloat64))))); 5287 m.LoadFromPointer(&input, kMachFloat64)))));
5297 m.Return(m.Int32Constant(0)); 5288 m.Return(m.Int32Constant(0));
5298 for (size_t i = 0; i < arraysize(kValues); ++i) { 5289 for (size_t i = 0; i < arraysize(kValues); ++i) {
5299 input = kValues[i]; 5290 input = kValues[i];
5300 CHECK_EQ(0, m.Call()); 5291 CHECK_EQ(0, m.Call());
5301 double expected = std::ceil(kValues[i]); 5292 double expected = std::ceil(kValues[i]);
5302 CHECK_EQ(expected, result); 5293 CHECK_EQ(expected, result);
5303 } 5294 }
5304 } 5295 }
5305 5296
5306 5297
5307 TEST(RunFloat64RoundTruncate) { 5298 TEST(RunFloat64RoundTruncate) {
5308 double input = -1.0; 5299 double input = -1.0;
5309 double result = 0.0; 5300 double result = 0.0;
5310 RawMachineAssemblerTester<int32_t> m; 5301 RawMachineAssemblerTester<int32_t> m;
5311 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; 5302 if (!m.machine()->Float64RoundTruncate().IsSupported()) return;
5312 m.StoreToPointer( 5303 m.StoreToPointer(
5313 &result, StoreRepForType(kMachFloat64), 5304 &result, kMachFloat64,
5314 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64))); 5305 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64)));
5315 m.Return(m.Int32Constant(0)); 5306 m.Return(m.Int32Constant(0));
5316 for (size_t i = 0; i < arraysize(kValues); ++i) { 5307 for (size_t i = 0; i < arraysize(kValues); ++i) {
5317 input = kValues[i]; 5308 input = kValues[i];
5318 CHECK_EQ(0, m.Call()); 5309 CHECK_EQ(0, m.Call());
5319 double expected = trunc(kValues[i]); 5310 double expected = trunc(kValues[i]);
5320 CHECK_EQ(expected, result); 5311 CHECK_EQ(expected, result);
5321 } 5312 }
5322 } 5313 }
5323 5314
5324 5315
5325 TEST(RunFloat64RoundTiesAway) { 5316 TEST(RunFloat64RoundTiesAway) {
5326 double input = -1.0; 5317 double input = -1.0;
5327 double result = 0.0; 5318 double result = 0.0;
5328 RawMachineAssemblerTester<int32_t> m; 5319 RawMachineAssemblerTester<int32_t> m;
5329 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return; 5320 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return;
5330 m.StoreToPointer( 5321 m.StoreToPointer(
5331 &result, StoreRepForType(kMachFloat64), 5322 &result, kMachFloat64,
5332 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); 5323 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64)));
5333 m.Return(m.Int32Constant(0)); 5324 m.Return(m.Int32Constant(0));
5334 for (size_t i = 0; i < arraysize(kValues); ++i) { 5325 for (size_t i = 0; i < arraysize(kValues); ++i) {
5335 input = kValues[i]; 5326 input = kValues[i];
5336 CHECK_EQ(0, m.Call()); 5327 CHECK_EQ(0, m.Call());
5337 double expected = round(kValues[i]); 5328 double expected = round(kValues[i]);
5338 CHECK_EQ(expected, result); 5329 CHECK_EQ(expected, result);
5339 } 5330 }
5340 } 5331 }
5341 5332
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5461 CHECK_EQ(write, buffer[0]); 5452 CHECK_EQ(write, buffer[0]);
5462 CHECK_EQ(write, buffer[1]); 5453 CHECK_EQ(write, buffer[1]);
5463 } 5454 }
5464 5455
5465 5456
5466 TEST(RunBitcastInt64ToFloat64) { 5457 TEST(RunBitcastInt64ToFloat64) {
5467 int64_t input = 1; 5458 int64_t input = 1;
5468 double output = 0.0; 5459 double output = 0.0;
5469 RawMachineAssemblerTester<int32_t> m; 5460 RawMachineAssemblerTester<int32_t> m;
5470 m.StoreToPointer( 5461 m.StoreToPointer(
5471 &output, StoreRepForType(kMachFloat64), 5462 &output, kMachFloat64,
5472 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64))); 5463 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64)));
5473 m.Return(m.Int32Constant(11)); 5464 m.Return(m.Int32Constant(11));
5474 FOR_INT64_INPUTS(i) { 5465 FOR_INT64_INPUTS(i) {
5475 input = *i; 5466 input = *i;
5476 CHECK_EQ(11, m.Call()); 5467 CHECK_EQ(11, m.Call());
5477 double expected = bit_cast<double>(input); 5468 double expected = bit_cast<double>(input);
5478 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); 5469 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
5479 } 5470 }
5480 } 5471 }
5481 5472
5482 5473
5483 TEST(RunBitcastFloat64ToInt64) { 5474 TEST(RunBitcastFloat64ToInt64) {
5484 double input = 0; 5475 double input = 0;
5485 int64_t output = 0; 5476 int64_t output = 0;
5486 RawMachineAssemblerTester<int32_t> m; 5477 RawMachineAssemblerTester<int32_t> m;
5487 m.StoreToPointer( 5478 m.StoreToPointer(
5488 &output, StoreRepForType(kMachInt64), 5479 &output, kMachInt64,
5489 m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64))); 5480 m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64)));
5490 m.Return(m.Int32Constant(11)); 5481 m.Return(m.Int32Constant(11));
5491 FOR_FLOAT64_INPUTS(i) { 5482 FOR_FLOAT64_INPUTS(i) {
5492 input = *i; 5483 input = *i;
5493 CHECK_EQ(11, m.Call()); 5484 CHECK_EQ(11, m.Call());
5494 double expected = bit_cast<int64_t>(input); 5485 double expected = bit_cast<int64_t>(input);
5495 CHECK_EQ(expected, output); 5486 CHECK_EQ(expected, output);
5496 } 5487 }
5497 } 5488 }
5498 #endif 5489 #endif
5499 5490
5500 5491
5501 TEST(RunBitcastFloat32ToInt32) { 5492 TEST(RunBitcastFloat32ToInt32) {
5502 float input = 32.25; 5493 float input = 32.25;
5503 RawMachineAssemblerTester<int32_t> m; 5494 RawMachineAssemblerTester<int32_t> m;
5504 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); 5495 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32)));
5505 FOR_FLOAT32_INPUTS(i) { 5496 FOR_FLOAT32_INPUTS(i) {
5506 input = *i; 5497 input = *i;
5507 int32_t expected = bit_cast<int32_t>(input); 5498 int32_t expected = bit_cast<int32_t>(input);
5508 CHECK_EQ(expected, m.Call()); 5499 CHECK_EQ(expected, m.Call());
5509 } 5500 }
5510 } 5501 }
5511 5502
5512 5503
5513 TEST(RunBitcastInt32ToFloat32) { 5504 TEST(RunBitcastInt32ToFloat32) {
5514 int32_t input = 1; 5505 int32_t input = 1;
5515 float output = 0.0; 5506 float output = 0.0;
5516 RawMachineAssemblerTester<int32_t> m; 5507 RawMachineAssemblerTester<int32_t> m;
5517 m.StoreToPointer( 5508 m.StoreToPointer(
5518 &output, StoreRepForType(kMachFloat32), 5509 &output, kMachFloat32,
5519 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); 5510 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32)));
5520 m.Return(m.Int32Constant(11)); 5511 m.Return(m.Int32Constant(11));
5521 FOR_INT32_INPUTS(i) { 5512 FOR_INT32_INPUTS(i) {
5522 input = *i; 5513 input = *i;
5523 CHECK_EQ(11, m.Call()); 5514 CHECK_EQ(11, m.Call());
5524 float expected = bit_cast<float>(input); 5515 float expected = bit_cast<float>(input);
5525 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); 5516 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
5526 } 5517 }
5527 } 5518 }
5528 5519
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5569 c->CalleeSavedRegisters(), // callee saved 5560 c->CalleeSavedRegisters(), // callee saved
5570 c->CalleeSavedFPRegisters(), // callee saved FP 5561 c->CalleeSavedFPRegisters(), // callee saved FP
5571 CallDescriptor::kNoFlags, // flags 5562 CallDescriptor::kNoFlags, // flags
5572 "c-call-as-code"); 5563 "c-call-as-code");
5573 Node* call = r.AddNode(r.common()->Call(desc), phi); 5564 Node* call = r.AddNode(r.common()->Call(desc), phi);
5574 r.Return(call); 5565 r.Return(call);
5575 5566
5576 CHECK_EQ(33, r.Call(1)); 5567 CHECK_EQ(33, r.Call(1));
5577 CHECK_EQ(44, r.Call(0)); 5568 CHECK_EQ(44, r.Call(0));
5578 } 5569 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/cctest/compiler/test-run-native-calls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698