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

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

Issue 1773513002: x87: fix the use of CheckFloatEq and CheckDoubleEq in test. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use a do { .. } while(false) to be a good macro citizen. Created 4 years, 9 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
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 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from), 1190 Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from),
1191 m.IntPtrConstant(offset)); 1191 m.IntPtrConstant(offset));
1192 m.Store(MachineRepresentation::kFloat32, m.PointerConstant(to), 1192 m.Store(MachineRepresentation::kFloat32, m.PointerConstant(to),
1193 m.IntPtrConstant(offset), load, kNoWriteBarrier); 1193 m.IntPtrConstant(offset), load, kNoWriteBarrier);
1194 m.Return(m.Int32Constant(magic)); 1194 m.Return(m.Int32Constant(magic));
1195 1195
1196 FOR_FLOAT32_INPUTS(j) { 1196 FOR_FLOAT32_INPUTS(j) {
1197 p1 = *j; 1197 p1 = *j;
1198 p2 = *j - 5; 1198 p2 = *j - 5;
1199 CHECK_EQ(magic, m.Call()); 1199 CHECK_EQ(magic, m.Call());
1200 CheckDoubleEq(p1, p2); 1200 CHECK_DOUBLE_EQ(p1, p2);
1201 } 1201 }
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 1205
1206 TEST(RunLoadStoreFloat64Offset) { 1206 TEST(RunLoadStoreFloat64Offset) {
1207 double p1 = 0; // loads directly from this location. 1207 double p1 = 0; // loads directly from this location.
1208 double p2 = 0; // and stores directly into this location. 1208 double p2 = 0; // and stores directly into this location.
1209 1209
1210 FOR_INT32_INPUTS(i) { 1210 FOR_INT32_INPUTS(i) {
1211 int32_t magic = 0x2342aabb + *i * 3; 1211 int32_t magic = 0x2342aabb + *i * 3;
1212 RawMachineAssemblerTester<int32_t> m; 1212 RawMachineAssemblerTester<int32_t> m;
1213 int32_t offset = *i; 1213 int32_t offset = *i;
1214 byte* from = reinterpret_cast<byte*>(&p1) - offset; 1214 byte* from = reinterpret_cast<byte*>(&p1) - offset;
1215 byte* to = reinterpret_cast<byte*>(&p2) - offset; 1215 byte* to = reinterpret_cast<byte*>(&p2) - offset;
1216 // generate load [#base + #index] 1216 // generate load [#base + #index]
1217 Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from), 1217 Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from),
1218 m.IntPtrConstant(offset)); 1218 m.IntPtrConstant(offset));
1219 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(to), 1219 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(to),
1220 m.IntPtrConstant(offset), load, kNoWriteBarrier); 1220 m.IntPtrConstant(offset), load, kNoWriteBarrier);
1221 m.Return(m.Int32Constant(magic)); 1221 m.Return(m.Int32Constant(magic));
1222 1222
1223 FOR_FLOAT64_INPUTS(j) { 1223 FOR_FLOAT64_INPUTS(j) {
1224 p1 = *j; 1224 p1 = *j;
1225 p2 = *j - 5; 1225 p2 = *j - 5;
1226 CHECK_EQ(magic, m.Call()); 1226 CHECK_EQ(magic, m.Call());
1227 CheckDoubleEq(p1, p2); 1227 CHECK_DOUBLE_EQ(p1, p2);
1228 } 1228 }
1229 } 1229 }
1230 } 1230 }
1231 1231
1232 1232
1233 TEST(RunInt32AddP) { 1233 TEST(RunInt32AddP) {
1234 RawMachineAssemblerTester<int32_t> m; 1234 RawMachineAssemblerTester<int32_t> m;
1235 Int32BinopTester bt(&m); 1235 Int32BinopTester bt(&m);
1236 1236
1237 bt.AddReturn(m.Int32Add(bt.param0, bt.param1)); 1237 bt.AddReturn(m.Int32Add(bt.param0, bt.param1));
(...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after
3651 RunLoadStore<double>(MachineType::Float64()); 3651 RunLoadStore<double>(MachineType::Float64());
3652 } 3652 }
3653 3653
3654 3654
3655 TEST(RunFloat32Add) { 3655 TEST(RunFloat32Add) {
3656 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), 3656 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3657 MachineType::Float32()); 3657 MachineType::Float32());
3658 m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1))); 3658 m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1)));
3659 3659
3660 FOR_FLOAT32_INPUTS(i) { 3660 FOR_FLOAT32_INPUTS(i) {
3661 FOR_FLOAT32_INPUTS(j) { 3661 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i + *j, m.Call(*i, *j)); }
3662 volatile float expected = *i + *j;
3663 CheckFloatEq(expected, m.Call(*i, *j));
3664 }
3665 } 3662 }
3666 } 3663 }
3667 3664
3668 3665
3669 TEST(RunFloat32Sub) { 3666 TEST(RunFloat32Sub) {
3670 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), 3667 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3671 MachineType::Float32()); 3668 MachineType::Float32());
3672 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); 3669 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1)));
3673 3670
3674 FOR_FLOAT32_INPUTS(i) { 3671 FOR_FLOAT32_INPUTS(i) {
3675 FOR_FLOAT32_INPUTS(j) { 3672 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*i, *j)); }
3676 volatile float expected = *i - *j;
3677 CheckFloatEq(expected, m.Call(*i, *j));
3678 }
3679 } 3673 }
3680 } 3674 }
3681 3675
3682 3676
3683 TEST(RunFloat32Mul) { 3677 TEST(RunFloat32Mul) {
3684 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), 3678 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3685 MachineType::Float32()); 3679 MachineType::Float32());
3686 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); 3680 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1)));
3687 3681
3688 FOR_FLOAT32_INPUTS(i) { 3682 FOR_FLOAT32_INPUTS(i) {
3689 FOR_FLOAT32_INPUTS(j) { 3683 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*i, *j)); }
3690 volatile float expected = *i * *j;
3691 CheckFloatEq(expected, m.Call(*i, *j));
3692 }
3693 } 3684 }
3694 } 3685 }
3695 3686
3696 3687
3697 TEST(RunFloat32Div) { 3688 TEST(RunFloat32Div) {
3698 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), 3689 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3699 MachineType::Float32()); 3690 MachineType::Float32());
3700 m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1))); 3691 m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1)));
3701 3692
3702 FOR_FLOAT32_INPUTS(i) { 3693 FOR_FLOAT32_INPUTS(i) {
3703 FOR_FLOAT32_INPUTS(j) { 3694 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i / *j, m.Call(*i, *j)); }
3704 volatile float expected = *i / *j;
3705 CheckFloatEq(expected, m.Call(*i, *j));
3706 }
3707 } 3695 }
3708 } 3696 }
3709 3697
3710 3698
3711 TEST(RunFloat64Add) { 3699 TEST(RunFloat64Add) {
3712 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 3700 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3713 MachineType::Float64()); 3701 MachineType::Float64());
3714 m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1))); 3702 m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1)));
3715 3703
3716 FOR_FLOAT64_INPUTS(i) { 3704 FOR_FLOAT64_INPUTS(i) {
3717 FOR_FLOAT64_INPUTS(j) { 3705 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i + *j, m.Call(*i, *j)); }
3718 volatile double expected = *i + *j;
3719 CheckDoubleEq(expected, m.Call(*i, *j));
3720 }
3721 } 3706 }
3722 } 3707 }
3723 3708
3724 3709
3725 TEST(RunFloat64Sub) { 3710 TEST(RunFloat64Sub) {
3726 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 3711 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3727 MachineType::Float64()); 3712 MachineType::Float64());
3728 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); 3713 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1)));
3729 3714
3730 FOR_FLOAT64_INPUTS(i) { 3715 FOR_FLOAT64_INPUTS(i) {
3731 FOR_FLOAT64_INPUTS(j) { 3716 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i - *j, m.Call(*i, *j)); }
3732 volatile double expected = *i - *j;
3733 CheckDoubleEq(expected, m.Call(*i, *j));
3734 }
3735 } 3717 }
3736 } 3718 }
3737 3719
3738 3720
3739 TEST(RunFloat64Mul) { 3721 TEST(RunFloat64Mul) {
3740 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 3722 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3741 MachineType::Float64()); 3723 MachineType::Float64());
3742 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); 3724 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1)));
3743 3725
3744 FOR_FLOAT64_INPUTS(i) { 3726 FOR_FLOAT64_INPUTS(i) {
3745 FOR_FLOAT64_INPUTS(j) { 3727 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i * *j, m.Call(*i, *j)); }
3746 volatile double expected = *i * *j;
3747 CheckDoubleEq(expected, m.Call(*i, *j));
3748 }
3749 } 3728 }
3750 } 3729 }
3751 3730
3752 3731
3753 TEST(RunFloat64Div) { 3732 TEST(RunFloat64Div) {
3754 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 3733 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3755 MachineType::Float64()); 3734 MachineType::Float64());
3756 m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1))); 3735 m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1)));
3757 3736
3758 FOR_FLOAT64_INPUTS(i) { 3737 FOR_FLOAT64_INPUTS(i) {
3759 FOR_FLOAT64_INPUTS(j) { 3738 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(*i / *j, m.Call(*i, *j)); }
3760 volatile double expected = *i / *j;
3761 CheckDoubleEq(expected, m.Call(*i, *j));
3762 }
3763 } 3739 }
3764 } 3740 }
3765 3741
3766 3742
3767 TEST(RunFloat64Mod) { 3743 TEST(RunFloat64Mod) {
3768 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 3744 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3769 MachineType::Float64()); 3745 MachineType::Float64());
3770 m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1))); 3746 m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1)));
3771 3747
3772 FOR_FLOAT64_INPUTS(i) { 3748 FOR_FLOAT64_INPUTS(i) {
3773 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); } 3749 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(modulo(*i, *j), m.Call(*i, *j)); }
3774 } 3750 }
3775 } 3751 }
3776 3752
3777 3753
3778 TEST(RunDeadFloat32Binops) { 3754 TEST(RunDeadFloat32Binops) {
3779 RawMachineAssemblerTester<int32_t> m; 3755 RawMachineAssemblerTester<int32_t> m;
3780 3756
3781 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(), 3757 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(),
3782 m.machine()->Float32Mul(), m.machine()->Float32Div(), 3758 m.machine()->Float32Mul(), m.machine()->Float32Div(),
3783 NULL}; 3759 NULL};
(...skipping 25 matching lines...) Expand all
3809 } 3785 }
3810 3786
3811 3787
3812 TEST(RunFloat32AddP) { 3788 TEST(RunFloat32AddP) {
3813 RawMachineAssemblerTester<int32_t> m; 3789 RawMachineAssemblerTester<int32_t> m;
3814 Float32BinopTester bt(&m); 3790 Float32BinopTester bt(&m);
3815 3791
3816 bt.AddReturn(m.Float32Add(bt.param0, bt.param1)); 3792 bt.AddReturn(m.Float32Add(bt.param0, bt.param1));
3817 3793
3818 FOR_FLOAT32_INPUTS(pl) { 3794 FOR_FLOAT32_INPUTS(pl) {
3819 FOR_FLOAT32_INPUTS(pr) { 3795 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl + *pr, bt.call(*pl, *pr)); }
3820 float expected = *pl + *pr;
3821 CheckFloatEq(expected, bt.call(*pl, *pr));
3822 }
3823 } 3796 }
3824 } 3797 }
3825 3798
3826 3799
3827 TEST(RunFloat64AddP) { 3800 TEST(RunFloat64AddP) {
3828 RawMachineAssemblerTester<int32_t> m; 3801 RawMachineAssemblerTester<int32_t> m;
3829 Float64BinopTester bt(&m); 3802 Float64BinopTester bt(&m);
3830 3803
3831 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); 3804 bt.AddReturn(m.Float64Add(bt.param0, bt.param1));
3832 3805
3833 FOR_FLOAT64_INPUTS(pl) { 3806 FOR_FLOAT64_INPUTS(pl) {
3834 FOR_FLOAT64_INPUTS(pr) { 3807 FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl + *pr, bt.call(*pl, *pr)); }
3835 double expected = *pl + *pr;
3836 CheckDoubleEq(expected, bt.call(*pl, *pr));
3837 }
3838 } 3808 }
3839 } 3809 }
3840 3810
3841 3811
3842 TEST(RunFloa32MaxP) { 3812 TEST(RunFloa32MaxP) {
3843 RawMachineAssemblerTester<int32_t> m; 3813 RawMachineAssemblerTester<int32_t> m;
3844 Float32BinopTester bt(&m); 3814 Float32BinopTester bt(&m);
3845 if (!m.machine()->Float32Max().IsSupported()) return; 3815 if (!m.machine()->Float32Max().IsSupported()) return;
3846 3816
3847 bt.AddReturn(m.Float32Max(bt.param0, bt.param1)); 3817 bt.AddReturn(m.Float32Max(bt.param0, bt.param1));
3848 3818
3849 FOR_FLOAT32_INPUTS(pl) { 3819 FOR_FLOAT32_INPUTS(pl) {
3850 FOR_FLOAT32_INPUTS(pr) { 3820 FOR_FLOAT32_INPUTS(pr) {
3851 double expected = *pl > *pr ? *pl : *pr; 3821 CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr));
3852 CheckDoubleEq(expected, bt.call(*pl, *pr));
3853 } 3822 }
3854 } 3823 }
3855 } 3824 }
3856 3825
3857 3826
3858 TEST(RunFloat64MaxP) { 3827 TEST(RunFloat64MaxP) {
3859 RawMachineAssemblerTester<int32_t> m; 3828 RawMachineAssemblerTester<int32_t> m;
3860 Float64BinopTester bt(&m); 3829 Float64BinopTester bt(&m);
3861 if (!m.machine()->Float64Max().IsSupported()) return; 3830 if (!m.machine()->Float64Max().IsSupported()) return;
3862 3831
3863 bt.AddReturn(m.Float64Max(bt.param0, bt.param1)); 3832 bt.AddReturn(m.Float64Max(bt.param0, bt.param1));
3864 3833
3865 FOR_FLOAT64_INPUTS(pl) { 3834 FOR_FLOAT64_INPUTS(pl) {
3866 FOR_FLOAT64_INPUTS(pr) { 3835 FOR_FLOAT64_INPUTS(pr) {
3867 double expected = *pl > *pr ? *pl : *pr; 3836 CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr));
3868 CheckDoubleEq(expected, bt.call(*pl, *pr));
3869 } 3837 }
3870 } 3838 }
3871 } 3839 }
3872 3840
3873 3841
3874 TEST(RunFloat32MinP) { 3842 TEST(RunFloat32MinP) {
3875 RawMachineAssemblerTester<int32_t> m; 3843 RawMachineAssemblerTester<int32_t> m;
3876 Float32BinopTester bt(&m); 3844 Float32BinopTester bt(&m);
3877 if (!m.machine()->Float32Min().IsSupported()) return; 3845 if (!m.machine()->Float32Min().IsSupported()) return;
3878 3846
3879 bt.AddReturn(m.Float32Min(bt.param0, bt.param1)); 3847 bt.AddReturn(m.Float32Min(bt.param0, bt.param1));
3880 3848
3881 FOR_FLOAT32_INPUTS(pl) { 3849 FOR_FLOAT32_INPUTS(pl) {
3882 FOR_FLOAT32_INPUTS(pr) { 3850 FOR_FLOAT32_INPUTS(pr) {
3883 double expected = *pl < *pr ? *pl : *pr; 3851 CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr));
3884 CheckDoubleEq(expected, bt.call(*pl, *pr));
3885 } 3852 }
3886 } 3853 }
3887 } 3854 }
3888 3855
3889 3856
3890 TEST(RunFloat64MinP) { 3857 TEST(RunFloat64MinP) {
3891 RawMachineAssemblerTester<int32_t> m; 3858 RawMachineAssemblerTester<int32_t> m;
3892 Float64BinopTester bt(&m); 3859 Float64BinopTester bt(&m);
3893 if (!m.machine()->Float64Min().IsSupported()) return; 3860 if (!m.machine()->Float64Min().IsSupported()) return;
3894 3861
3895 bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); 3862 bt.AddReturn(m.Float64Min(bt.param0, bt.param1));
3896 3863
3897 FOR_FLOAT64_INPUTS(pl) { 3864 FOR_FLOAT64_INPUTS(pl) {
3898 FOR_FLOAT64_INPUTS(pr) { 3865 FOR_FLOAT64_INPUTS(pr) {
3899 double expected = *pl < *pr ? *pl : *pr; 3866 CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr));
3900 CheckDoubleEq(expected, bt.call(*pl, *pr));
3901 } 3867 }
3902 } 3868 }
3903 } 3869 }
3904 3870
3905 3871
3906 TEST(RunFloat32SubP) { 3872 TEST(RunFloat32SubP) {
3907 RawMachineAssemblerTester<int32_t> m; 3873 RawMachineAssemblerTester<int32_t> m;
3908 Float32BinopTester bt(&m); 3874 Float32BinopTester bt(&m);
3909 3875
3910 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); 3876 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1));
3911 3877
3912 FOR_FLOAT32_INPUTS(pl) { 3878 FOR_FLOAT32_INPUTS(pl) {
3913 FOR_FLOAT32_INPUTS(pr) { 3879 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl - *pr, bt.call(*pl, *pr)); }
3914 float expected = *pl - *pr;
3915 CheckFloatEq(expected, bt.call(*pl, *pr));
3916 }
3917 } 3880 }
3918 } 3881 }
3919 3882
3920 3883
3921 TEST(RunFloat32SubImm1) { 3884 TEST(RunFloat32SubImm1) {
3922 FOR_FLOAT32_INPUTS(i) { 3885 FOR_FLOAT32_INPUTS(i) {
3923 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 3886 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
3924 m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0))); 3887 m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0)));
3925 3888
3926 FOR_FLOAT32_INPUTS(j) { 3889 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*j)); }
3927 volatile float expected = *i - *j;
3928 CheckFloatEq(expected, m.Call(*j));
3929 }
3930 } 3890 }
3931 } 3891 }
3932 3892
3933 3893
3934 TEST(RunFloat32SubImm2) { 3894 TEST(RunFloat32SubImm2) {
3935 FOR_FLOAT32_INPUTS(i) { 3895 FOR_FLOAT32_INPUTS(i) {
3936 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 3896 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
3937 m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i))); 3897 m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i)));
3938 3898
3939 FOR_FLOAT32_INPUTS(j) { 3899 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*j - *i, m.Call(*j)); }
3940 volatile float expected = *j - *i;
3941 CheckFloatEq(expected, m.Call(*j));
3942 }
3943 } 3900 }
3944 } 3901 }
3945 3902
3946 3903
3947 TEST(RunFloat64SubImm1) { 3904 TEST(RunFloat64SubImm1) {
3948 FOR_FLOAT64_INPUTS(i) { 3905 FOR_FLOAT64_INPUTS(i) {
3949 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 3906 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3950 m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0))); 3907 m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0)));
3951 3908
3952 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); } 3909 FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, m.Call(*j)); }
3953 } 3910 }
3954 } 3911 }
3955 3912
3956 3913
3957 TEST(RunFloat64SubImm2) { 3914 TEST(RunFloat64SubImm2) {
3958 FOR_FLOAT64_INPUTS(i) { 3915 FOR_FLOAT64_INPUTS(i) {
3959 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 3916 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3960 m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i))); 3917 m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i)));
3961 3918
3962 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); } 3919 FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*j - *i, m.Call(*j)); }
3963 } 3920 }
3964 } 3921 }
3965 3922
3966 3923
3967 TEST(RunFloat64SubP) { 3924 TEST(RunFloat64SubP) {
3968 RawMachineAssemblerTester<int32_t> m; 3925 RawMachineAssemblerTester<int32_t> m;
3969 Float64BinopTester bt(&m); 3926 Float64BinopTester bt(&m);
3970 3927
3971 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); 3928 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1));
3972 3929
3973 FOR_FLOAT64_INPUTS(pl) { 3930 FOR_FLOAT64_INPUTS(pl) {
3974 FOR_FLOAT64_INPUTS(pr) { 3931 FOR_FLOAT64_INPUTS(pr) {
3975 double expected = *pl - *pr; 3932 double expected = *pl - *pr;
3976 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3933 CHECK_DOUBLE_EQ(expected, bt.call(*pl, *pr));
3977 } 3934 }
3978 } 3935 }
3979 } 3936 }
3980 3937
3981 3938
3982 TEST(RunFloat32MulP) { 3939 TEST(RunFloat32MulP) {
3983 RawMachineAssemblerTester<int32_t> m; 3940 RawMachineAssemblerTester<int32_t> m;
3984 Float32BinopTester bt(&m); 3941 Float32BinopTester bt(&m);
3985 3942
3986 bt.AddReturn(m.Float32Mul(bt.param0, bt.param1)); 3943 bt.AddReturn(m.Float32Mul(bt.param0, bt.param1));
3987 3944
3988 FOR_FLOAT32_INPUTS(pl) { 3945 FOR_FLOAT32_INPUTS(pl) {
3989 FOR_FLOAT32_INPUTS(pr) { 3946 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl * *pr, bt.call(*pl, *pr)); }
3990 float expected = *pl * *pr;
3991 CheckFloatEq(expected, bt.call(*pl, *pr));
3992 }
3993 } 3947 }
3994 } 3948 }
3995 3949
3996 3950
3997 TEST(RunFloat64MulP) { 3951 TEST(RunFloat64MulP) {
3998 RawMachineAssemblerTester<int32_t> m; 3952 RawMachineAssemblerTester<int32_t> m;
3999 Float64BinopTester bt(&m); 3953 Float64BinopTester bt(&m);
4000 3954
4001 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1)); 3955 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1));
4002 3956
4003 FOR_FLOAT64_INPUTS(pl) { 3957 FOR_FLOAT64_INPUTS(pl) {
4004 FOR_FLOAT64_INPUTS(pr) { 3958 FOR_FLOAT64_INPUTS(pr) {
4005 double expected = *pl * *pr; 3959 double expected = *pl * *pr;
4006 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3960 CHECK_DOUBLE_EQ(expected, bt.call(*pl, *pr));
4007 } 3961 }
4008 } 3962 }
4009 } 3963 }
4010 3964
4011 3965
4012 TEST(RunFloat64MulAndFloat64Add1) { 3966 TEST(RunFloat64MulAndFloat64Add1) {
4013 BufferedRawMachineAssemblerTester<double> m( 3967 BufferedRawMachineAssemblerTester<double> m(
4014 MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); 3968 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
4015 m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)), 3969 m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)),
4016 m.Parameter(2))); 3970 m.Parameter(2)));
4017 3971
4018 FOR_FLOAT64_INPUTS(i) { 3972 FOR_FLOAT64_INPUTS(i) {
4019 FOR_FLOAT64_INPUTS(j) { 3973 FOR_FLOAT64_INPUTS(j) {
4020 FOR_FLOAT64_INPUTS(k) { 3974 FOR_FLOAT64_INPUTS(k) {
4021 CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k)); 3975 CHECK_DOUBLE_EQ((*i * *j) + *k, m.Call(*i, *j, *k));
4022 } 3976 }
4023 } 3977 }
4024 } 3978 }
4025 } 3979 }
4026 3980
4027 3981
4028 TEST(RunFloat64MulAndFloat64Add2) { 3982 TEST(RunFloat64MulAndFloat64Add2) {
4029 BufferedRawMachineAssemblerTester<double> m( 3983 BufferedRawMachineAssemblerTester<double> m(
4030 MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); 3984 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
4031 m.Return(m.Float64Add(m.Parameter(0), 3985 m.Return(m.Float64Add(m.Parameter(0),
4032 m.Float64Mul(m.Parameter(1), m.Parameter(2)))); 3986 m.Float64Mul(m.Parameter(1), m.Parameter(2))));
4033 3987
4034 FOR_FLOAT64_INPUTS(i) { 3988 FOR_FLOAT64_INPUTS(i) {
4035 FOR_FLOAT64_INPUTS(j) { 3989 FOR_FLOAT64_INPUTS(j) {
4036 FOR_FLOAT64_INPUTS(k) { 3990 FOR_FLOAT64_INPUTS(k) {
4037 CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k)); 3991 CHECK_DOUBLE_EQ(*i + (*j * *k), m.Call(*i, *j, *k));
4038 } 3992 }
4039 } 3993 }
4040 } 3994 }
4041 } 3995 }
4042 3996
4043 3997
4044 TEST(RunFloat64MulAndFloat64Sub1) { 3998 TEST(RunFloat64MulAndFloat64Sub1) {
4045 BufferedRawMachineAssemblerTester<double> m( 3999 BufferedRawMachineAssemblerTester<double> m(
4046 MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); 4000 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
4047 m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)), 4001 m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)),
4048 m.Parameter(2))); 4002 m.Parameter(2)));
4049 4003
4050 FOR_FLOAT64_INPUTS(i) { 4004 FOR_FLOAT64_INPUTS(i) {
4051 FOR_FLOAT64_INPUTS(j) { 4005 FOR_FLOAT64_INPUTS(j) {
4052 FOR_FLOAT64_INPUTS(k) { 4006 FOR_FLOAT64_INPUTS(k) {
4053 CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k)); 4007 CHECK_DOUBLE_EQ((*i * *j) - *k, m.Call(*i, *j, *k));
4054 } 4008 }
4055 } 4009 }
4056 } 4010 }
4057 } 4011 }
4058 4012
4059 4013
4060 TEST(RunFloat64MulAndFloat64Sub2) { 4014 TEST(RunFloat64MulAndFloat64Sub2) {
4061 BufferedRawMachineAssemblerTester<double> m( 4015 BufferedRawMachineAssemblerTester<double> m(
4062 MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); 4016 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
4063 m.Return(m.Float64Sub(m.Parameter(0), 4017 m.Return(m.Float64Sub(m.Parameter(0),
4064 m.Float64Mul(m.Parameter(1), m.Parameter(2)))); 4018 m.Float64Mul(m.Parameter(1), m.Parameter(2))));
4065 4019
4066 FOR_FLOAT64_INPUTS(i) { 4020 FOR_FLOAT64_INPUTS(i) {
4067 FOR_FLOAT64_INPUTS(j) { 4021 FOR_FLOAT64_INPUTS(j) {
4068 FOR_FLOAT64_INPUTS(k) { 4022 FOR_FLOAT64_INPUTS(k) {
4069 CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k)); 4023 CHECK_DOUBLE_EQ(*i - (*j * *k), m.Call(*i, *j, *k));
4070 } 4024 }
4071 } 4025 }
4072 } 4026 }
4073 } 4027 }
4074 4028
4075 4029
4076 TEST(RunFloat64MulImm1) { 4030 TEST(RunFloat64MulImm1) {
4077 FOR_FLOAT64_INPUTS(i) { 4031 FOR_FLOAT64_INPUTS(i) {
4078 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 4032 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
4079 m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0))); 4033 m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0)));
4080 4034
4081 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); } 4035 FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*i * *j, m.Call(*j)); }
4082 } 4036 }
4083 } 4037 }
4084 4038
4085 4039
4086 TEST(RunFloat64MulImm2) { 4040 TEST(RunFloat64MulImm2) {
4087 FOR_FLOAT64_INPUTS(i) { 4041 FOR_FLOAT64_INPUTS(i) {
4088 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 4042 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
4089 m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i))); 4043 m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i)));
4090 4044
4091 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); } 4045 FOR_FLOAT64_INPUTS(j) { CHECK_FLOAT_EQ(*j * *i, m.Call(*j)); }
4092 } 4046 }
4093 } 4047 }
4094 4048
4095 4049
4096 TEST(RunFloat32DivP) { 4050 TEST(RunFloat32DivP) {
4097 RawMachineAssemblerTester<int32_t> m; 4051 RawMachineAssemblerTester<int32_t> m;
4098 Float32BinopTester bt(&m); 4052 Float32BinopTester bt(&m);
4099 4053
4100 bt.AddReturn(m.Float32Div(bt.param0, bt.param1)); 4054 bt.AddReturn(m.Float32Div(bt.param0, bt.param1));
4101 4055
4102 FOR_FLOAT32_INPUTS(pl) { 4056 FOR_FLOAT32_INPUTS(pl) {
4103 FOR_FLOAT32_INPUTS(pr) { 4057 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl / *pr, bt.call(*pl, *pr)); }
4104 float expected = *pl / *pr;
4105 CheckFloatEq(expected, bt.call(*pl, *pr));
4106 }
4107 } 4058 }
4108 } 4059 }
4109 4060
4110 4061
4111 TEST(RunFloat64DivP) { 4062 TEST(RunFloat64DivP) {
4112 RawMachineAssemblerTester<int32_t> m; 4063 RawMachineAssemblerTester<int32_t> m;
4113 Float64BinopTester bt(&m); 4064 Float64BinopTester bt(&m);
4114 4065
4115 bt.AddReturn(m.Float64Div(bt.param0, bt.param1)); 4066 bt.AddReturn(m.Float64Div(bt.param0, bt.param1));
4116 4067
4117 FOR_FLOAT64_INPUTS(pl) { 4068 FOR_FLOAT64_INPUTS(pl) {
4118 FOR_FLOAT64_INPUTS(pr) { 4069 FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl / *pr, bt.call(*pl, *pr)); }
4119 double expected = *pl / *pr;
4120 CheckDoubleEq(expected, bt.call(*pl, *pr));
4121 }
4122 } 4070 }
4123 } 4071 }
4124 4072
4125 4073
4126 TEST(RunFloat64ModP) { 4074 TEST(RunFloat64ModP) {
4127 RawMachineAssemblerTester<int32_t> m; 4075 RawMachineAssemblerTester<int32_t> m;
4128 Float64BinopTester bt(&m); 4076 Float64BinopTester bt(&m);
4129 4077
4130 bt.AddReturn(m.Float64Mod(bt.param0, bt.param1)); 4078 bt.AddReturn(m.Float64Mod(bt.param0, bt.param1));
4131 4079
4132 FOR_FLOAT64_INPUTS(i) { 4080 FOR_FLOAT64_INPUTS(i) {
4133 FOR_FLOAT64_INPUTS(j) { 4081 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(modulo(*i, *j), bt.call(*i, *j)); }
4134 double expected = modulo(*i, *j);
4135 double found = bt.call(*i, *j);
4136 CheckDoubleEq(expected, found);
4137 }
4138 } 4082 }
4139 } 4083 }
4140 4084
4141 4085
4142 TEST(RunChangeInt32ToFloat64_A) { 4086 TEST(RunChangeInt32ToFloat64_A) {
4143 int32_t magic = 0x986234; 4087 int32_t magic = 0x986234;
4144 BufferedRawMachineAssemblerTester<double> m; 4088 BufferedRawMachineAssemblerTester<double> m;
4145 m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic))); 4089 m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic)));
4146 CheckDoubleEq(static_cast<double>(magic), m.Call()); 4090 CHECK_DOUBLE_EQ(static_cast<double>(magic), m.Call());
4147 } 4091 }
4148 4092
4149 4093
4150 TEST(RunChangeInt32ToFloat64_B) { 4094 TEST(RunChangeInt32ToFloat64_B) {
4151 BufferedRawMachineAssemblerTester<double> m(MachineType::Int32()); 4095 BufferedRawMachineAssemblerTester<double> m(MachineType::Int32());
4152 m.Return(m.ChangeInt32ToFloat64(m.Parameter(0))); 4096 m.Return(m.ChangeInt32ToFloat64(m.Parameter(0)));
4153 4097
4154 FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 4098 FOR_INT32_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i)); }
4155 } 4099 }
4156 4100
4157 4101
4158 TEST(RunChangeUint32ToFloat64) { 4102 TEST(RunChangeUint32ToFloat64) {
4159 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32()); 4103 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32());
4160 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); 4104 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0)));
4161 4105
4162 FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 4106 FOR_UINT32_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i)); }
4163 } 4107 }
4164 4108
4165 4109
4166 TEST(RunTruncateFloat32ToInt32) { 4110 TEST(RunTruncateFloat32ToInt32) {
4167 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float32()); 4111 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float32());
4168 m.Return(m.TruncateFloat32ToInt32(m.Parameter(0))); 4112 m.Return(m.TruncateFloat32ToInt32(m.Parameter(0)));
4169 FOR_FLOAT32_INPUTS(i) { 4113 FOR_FLOAT32_INPUTS(i) {
4170 if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) && 4114 if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) &&
4171 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { 4115 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) {
4172 CheckFloatEq(static_cast<int32_t>(*i), m.Call(*i)); 4116 CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i));
4173 } 4117 }
4174 } 4118 }
4175 } 4119 }
4176 4120
4177 4121
4178 TEST(RunTruncateFloat32ToUint32) { 4122 TEST(RunTruncateFloat32ToUint32) {
4179 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); 4123 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32());
4180 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); 4124 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0)));
4181 { 4125 {
4182 FOR_UINT32_INPUTS(i) { 4126 FOR_UINT32_INPUTS(i) {
4183 float input = static_cast<float>(*i); 4127 float input = static_cast<float>(*i);
4184 // This condition on 'input' is required because 4128 // This condition on 'input' is required because
4185 // static_cast<float>(std::numeric_limits<uint32_t>::max()) results in a 4129 // static_cast<float>(std::numeric_limits<uint32_t>::max()) results in a
4186 // value outside uint32 range. 4130 // value outside uint32 range.
4187 if (input < static_cast<float>(std::numeric_limits<uint32_t>::max())) { 4131 if (input < static_cast<float>(std::numeric_limits<uint32_t>::max())) {
4188 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); 4132 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input));
4189 } 4133 }
4190 } 4134 }
4191 } 4135 }
4192 { 4136 {
4193 FOR_FLOAT32_INPUTS(i) { 4137 FOR_FLOAT32_INPUTS(i) {
4194 if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) && 4138 if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) &&
4195 *i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) { 4139 *i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) {
4196 CheckFloatEq(static_cast<uint32_t>(*i), m.Call(*i)); 4140 CHECK_FLOAT_EQ(static_cast<uint32_t>(*i), m.Call(*i));
4197 } 4141 }
4198 } 4142 }
4199 } 4143 }
4200 } 4144 }
4201 4145
4202 4146
4203 TEST(RunChangeFloat64ToInt32_A) { 4147 TEST(RunChangeFloat64ToInt32_A) {
4204 BufferedRawMachineAssemblerTester<int32_t> m; 4148 BufferedRawMachineAssemblerTester<int32_t> m;
4205 double magic = 11.1; 4149 double magic = 11.1;
4206 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); 4150 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic)));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 // Note we don't check fractional inputs, because these Convert operators 4187 // Note we don't check fractional inputs, because these Convert operators
4244 // really should be Change operators. 4188 // really should be Change operators.
4245 } 4189 }
4246 4190
4247 4191
4248 TEST(RunTruncateFloat64ToFloat32) { 4192 TEST(RunTruncateFloat64ToFloat32) {
4249 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64()); 4193 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64());
4250 4194
4251 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); 4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
4252 4196
4253 FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); } 4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); }
4254 } 4198 }
4255 4199
4256 4200
4257 TEST(RunDeadChangeFloat64ToInt32) { 4201 TEST(RunDeadChangeFloat64ToInt32) {
4258 RawMachineAssemblerTester<int32_t> m; 4202 RawMachineAssemblerTester<int32_t> m;
4259 const int magic = 0x88abcda4; 4203 const int magic = 0x88abcda4;
4260 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); 4204 m.ChangeFloat64ToInt32(m.Float64Constant(999.78));
4261 m.Return(m.Int32Constant(magic)); 4205 m.Return(m.Int32Constant(magic));
4262 CHECK_EQ(magic, m.Call()); 4206 CHECK_EQ(magic, m.Call());
4263 } 4207 }
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
5291 CHECK_EQ(static_cast<int>(expected), m.Call()); 5235 CHECK_EQ(static_cast<int>(expected), m.Call());
5292 } 5236 }
5293 } 5237 }
5294 5238
5295 5239
5296 TEST(RunChangeFloat32ToFloat64) { 5240 TEST(RunChangeFloat32ToFloat64) {
5297 BufferedRawMachineAssemblerTester<double> m(MachineType::Float32()); 5241 BufferedRawMachineAssemblerTester<double> m(MachineType::Float32());
5298 5242
5299 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); 5243 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0)));
5300 5244
5301 FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 5245 FOR_FLOAT32_INPUTS(i) {
5246 CHECK_DOUBLE_EQ(static_cast<double>(*i), m.Call(*i));
5247 }
5302 } 5248 }
5303 5249
5304 5250
5305 TEST(RunFloat32Constant) { 5251 TEST(RunFloat32Constant) {
5306 FOR_FLOAT32_INPUTS(i) { 5252 FOR_FLOAT32_INPUTS(i) {
5307 BufferedRawMachineAssemblerTester<float> m; 5253 BufferedRawMachineAssemblerTester<float> m;
5308 m.Return(m.Float32Constant(*i)); 5254 m.Return(m.Float32Constant(*i));
5309 CheckFloatEq(*i, m.Call()); 5255 CHECK_FLOAT_EQ(*i, m.Call());
5310 } 5256 }
5311 } 5257 }
5312 5258
5313 5259
5314 TEST(RunFloat64ExtractLowWord32) { 5260 TEST(RunFloat64ExtractLowWord32) {
5315 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64()); 5261 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64());
5316 m.Return(m.Float64ExtractLowWord32(m.Parameter(0))); 5262 m.Return(m.Float64ExtractLowWord32(m.Parameter(0)));
5317 FOR_FLOAT64_INPUTS(i) { 5263 FOR_FLOAT64_INPUTS(i) {
5318 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i)); 5264 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i));
5319 CHECK_EQ(expected, m.Call(*i)); 5265 CHECK_EQ(expected, m.Call(*i));
(...skipping 13 matching lines...) Expand all
5333 5279
5334 TEST(RunFloat64InsertLowWord32) { 5280 TEST(RunFloat64InsertLowWord32) {
5335 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 5281 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
5336 MachineType::Int32()); 5282 MachineType::Int32());
5337 m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1))); 5283 m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1)));
5338 FOR_FLOAT64_INPUTS(i) { 5284 FOR_FLOAT64_INPUTS(i) {
5339 FOR_INT32_INPUTS(j) { 5285 FOR_INT32_INPUTS(j) {
5340 double expected = bit_cast<double>( 5286 double expected = bit_cast<double>(
5341 (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) | 5287 (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) |
5342 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)))); 5288 (static_cast<uint64_t>(bit_cast<uint32_t>(*j))));
5343 CheckDoubleEq(expected, m.Call(*i, *j)); 5289 CHECK_DOUBLE_EQ(expected, m.Call(*i, *j));
5344 } 5290 }
5345 } 5291 }
5346 } 5292 }
5347 5293
5348 5294
5349 TEST(RunFloat64InsertHighWord32) { 5295 TEST(RunFloat64InsertHighWord32) {
5350 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), 5296 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
5351 MachineType::Uint32()); 5297 MachineType::Uint32());
5352 m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1))); 5298 m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1)));
5353 FOR_FLOAT64_INPUTS(i) { 5299 FOR_FLOAT64_INPUTS(i) {
5354 FOR_UINT32_INPUTS(j) { 5300 FOR_UINT32_INPUTS(j) {
5355 uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) | 5301 uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) |
5356 (static_cast<uint64_t>(*j) << 32); 5302 (static_cast<uint64_t>(*j) << 32);
5357 5303
5358 CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j)); 5304 CHECK_DOUBLE_EQ(bit_cast<double>(expected), m.Call(*i, *j));
5359 } 5305 }
5360 } 5306 }
5361 } 5307 }
5362 5308
5363 5309
5364 TEST(RunFloat32Abs) { 5310 TEST(RunFloat32Abs) {
5365 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 5311 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5366 m.Return(m.Float32Abs(m.Parameter(0))); 5312 m.Return(m.Float32Abs(m.Parameter(0)));
5367 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); } 5313 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(std::abs(*i), m.Call(*i)); }
5368 } 5314 }
5369 5315
5370 5316
5371 TEST(RunFloat64Abs) { 5317 TEST(RunFloat64Abs) {
5372 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5318 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5373 m.Return(m.Float64Abs(m.Parameter(0))); 5319 m.Return(m.Float64Abs(m.Parameter(0)));
5374 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); } 5320 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(std::abs(*i), m.Call(*i)); }
5375 } 5321 }
5376 5322
5377 5323
5378 static double two_30 = 1 << 30; // 2^30 is a smi boundary. 5324 static double two_30 = 1 << 30; // 2^30 is a smi boundary.
5379 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. 5325 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary.
5380 static double kValues[] = {0.1, 5326 static double kValues[] = {0.1,
5381 0.2, 5327 0.2,
5382 0.49999999999999994, 5328 0.49999999999999994,
5383 0.5, 5329 0.5,
5384 0.7, 5330 0.7,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5472 -two_52 + 1 - 0.5, 5418 -two_52 + 1 - 0.5,
5473 -two_52 + 1 - 0.7}; 5419 -two_52 + 1 - 0.7};
5474 5420
5475 5421
5476 TEST(RunFloat32RoundDown) { 5422 TEST(RunFloat32RoundDown) {
5477 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 5423 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5478 if (!m.machine()->Float32RoundDown().IsSupported()) return; 5424 if (!m.machine()->Float32RoundDown().IsSupported()) return;
5479 5425
5480 m.Return(m.Float32RoundDown(m.Parameter(0))); 5426 m.Return(m.Float32RoundDown(m.Parameter(0)));
5481 5427
5482 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } 5428 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), m.Call(*i)); }
5483 } 5429 }
5484 5430
5485 5431
5486 TEST(RunFloat64RoundDown1) { 5432 TEST(RunFloat64RoundDown1) {
5487 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5433 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5488 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5434 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5489 5435
5490 m.Return(m.Float64RoundDown(m.Parameter(0))); 5436 m.Return(m.Float64RoundDown(m.Parameter(0)));
5491 5437
5492 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } 5438 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(floor(*i), m.Call(*i)); }
5493 } 5439 }
5494 5440
5495 5441
5496 TEST(RunFloat64RoundDown2) { 5442 TEST(RunFloat64RoundDown2) {
5497 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5443 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5498 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5444 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5499 m.Return(m.Float64Sub(m.Float64Constant(-0.0), 5445 m.Return(m.Float64Sub(m.Float64Constant(-0.0),
5500 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), 5446 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0),
5501 m.Parameter(0))))); 5447 m.Parameter(0)))));
5502 5448
5503 for (size_t i = 0; i < arraysize(kValues); ++i) { 5449 for (size_t i = 0; i < arraysize(kValues); ++i) {
5504 CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i])); 5450 CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i]));
5505 } 5451 }
5506 } 5452 }
5507 5453
5508 5454
5509 TEST(RunFloat32RoundUp) { 5455 TEST(RunFloat32RoundUp) {
5510 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 5456 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5511 if (!m.machine()->Float32RoundUp().IsSupported()) return; 5457 if (!m.machine()->Float32RoundUp().IsSupported()) return;
5512 m.Return(m.Float32RoundUp(m.Parameter(0))); 5458 m.Return(m.Float32RoundUp(m.Parameter(0)));
5513 5459
5514 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); } 5460 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(ceilf(*i), m.Call(*i)); }
5515 } 5461 }
5516 5462
5517 5463
5518 TEST(RunFloat64RoundUp) { 5464 TEST(RunFloat64RoundUp) {
5519 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5465 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5520 if (!m.machine()->Float64RoundUp().IsSupported()) return; 5466 if (!m.machine()->Float64RoundUp().IsSupported()) return;
5521 m.Return(m.Float64RoundUp(m.Parameter(0))); 5467 m.Return(m.Float64RoundUp(m.Parameter(0)));
5522 5468
5523 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); } 5469 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ceil(*i), m.Call(*i)); }
5524 } 5470 }
5525 5471
5526 5472
5527 TEST(RunFloat32RoundTiesEven) { 5473 TEST(RunFloat32RoundTiesEven) {
5528 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 5474 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5529 if (!m.machine()->Float32RoundTiesEven().IsSupported()) return; 5475 if (!m.machine()->Float32RoundTiesEven().IsSupported()) return;
5530 m.Return(m.Float32RoundTiesEven(m.Parameter(0))); 5476 m.Return(m.Float32RoundTiesEven(m.Parameter(0)));
5531 5477
5532 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(nearbyint(*i), m.Call(*i)); } 5478 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(nearbyint(*i), m.Call(*i)); }
5533 } 5479 }
5534 5480
5535 5481
5536 TEST(RunFloat64RoundTiesEven) { 5482 TEST(RunFloat64RoundTiesEven) {
5537 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5483 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5538 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; 5484 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return;
5539 m.Return(m.Float64RoundTiesEven(m.Parameter(0))); 5485 m.Return(m.Float64RoundTiesEven(m.Parameter(0)));
5540 5486
5541 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); } 5487 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(nearbyint(*i), m.Call(*i)); }
5542 } 5488 }
5543 5489
5544 5490
5545 TEST(RunFloat32RoundTruncate) { 5491 TEST(RunFloat32RoundTruncate) {
5546 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); 5492 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5547 if (!m.machine()->Float32RoundTruncate().IsSupported()) return; 5493 if (!m.machine()->Float32RoundTruncate().IsSupported()) return;
5548 5494
5549 m.Return(m.Float32RoundTruncate(m.Parameter(0))); 5495 m.Return(m.Float32RoundTruncate(m.Parameter(0)));
5550 5496
5551 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); } 5497 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(truncf(*i), m.Call(*i)); }
5552 } 5498 }
5553 5499
5554 5500
5555 TEST(RunFloat64RoundTruncate) { 5501 TEST(RunFloat64RoundTruncate) {
5556 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); 5502 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5557 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; 5503 if (!m.machine()->Float64RoundTruncate().IsSupported()) return;
5558 m.Return(m.Float64RoundTruncate(m.Parameter(0))); 5504 m.Return(m.Float64RoundTruncate(m.Parameter(0)));
5559 for (size_t i = 0; i < arraysize(kValues); ++i) { 5505 for (size_t i = 0; i < arraysize(kValues); ++i) {
5560 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i])); 5506 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i]));
5561 } 5507 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
6181 r.Goto(&merge); 6127 r.Goto(&merge);
6182 r.Bind(&merge); 6128 r.Bind(&merge);
6183 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6129 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6184 r.Return(phi); 6130 r.Return(phi);
6185 CHECK_EQ(1, r.Call(1)); 6131 CHECK_EQ(1, r.Call(1));
6186 } 6132 }
6187 6133
6188 } // namespace compiler 6134 } // namespace compiler
6189 } // namespace internal 6135 } // namespace internal
6190 } // namespace v8 6136 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-calls-to-external-references.cc ('k') | test/cctest/compiler/value-helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698