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

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

Issue 435923002: TF: Rename ConvertXToY machine operators to ChangeXToY. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-representation-change.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h" 9 #include "test/cctest/compiler/codegen-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 m.Bind(&header); 476 m.Bind(&header);
477 Node* phi = m.Phi(minus_3, ten); 477 Node* phi = m.Phi(minus_3, ten);
478 m.Branch(m.Float64LessThan(phi, ten), &body, end); 478 m.Branch(m.Float64LessThan(phi, ten), &body, end);
479 479
480 m.Bind(&body); 480 m.Bind(&body);
481 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); 481 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5)));
482 m.Goto(&header); 482 m.Goto(&header);
483 483
484 m.Bind(end); 484 m.Bind(end);
485 m.Return(m.ConvertFloat64ToInt32(phi)); 485 m.Return(m.ChangeFloat64ToInt32(phi));
486 486
487 CHECK_EQ(10, m.Call()); 487 CHECK_EQ(10, m.Call());
488 } 488 }
489 489
490 490
491 TEST(RunLoadInt32) { 491 TEST(RunLoadInt32) {
492 RawMachineAssemblerTester<int32_t> m; 492 RawMachineAssemblerTester<int32_t> m;
493 493
494 int32_t p1 = 0; // loads directly from this location. 494 int32_t p1 = 0; // loads directly from this location.
495 m.Return(m.LoadFromPointer(&p1, kMachineWord32)); 495 m.Return(m.LoadFromPointer(&p1, kMachineWord32));
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 FOR_FLOAT64_INPUTS(i) { 2851 FOR_FLOAT64_INPUTS(i) {
2852 FOR_FLOAT64_INPUTS(j) { 2852 FOR_FLOAT64_INPUTS(j) {
2853 double expected = modulo(*i, *j); 2853 double expected = modulo(*i, *j);
2854 double found = bt.call(*i, *j); 2854 double found = bt.call(*i, *j);
2855 CHECK_EQ(expected, found); 2855 CHECK_EQ(expected, found);
2856 } 2856 }
2857 } 2857 }
2858 } 2858 }
2859 2859
2860 2860
2861 TEST(RunConvertInt32ToFloat64_A) { 2861 TEST(RunChangeInt32ToFloat64_A) {
2862 RawMachineAssemblerTester<int32_t> m; 2862 RawMachineAssemblerTester<int32_t> m;
2863 int32_t magic = 0x986234; 2863 int32_t magic = 0x986234;
2864 double result = 0; 2864 double result = 0;
2865 2865
2866 Node* convert = m.ConvertInt32ToFloat64(m.Int32Constant(magic)); 2866 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic));
2867 m.Store(kMachineFloat64, m.PointerConstant(&result), m.Int32Constant(0), 2867 m.Store(kMachineFloat64, m.PointerConstant(&result), m.Int32Constant(0),
2868 convert); 2868 convert);
2869 m.Return(m.Int32Constant(magic)); 2869 m.Return(m.Int32Constant(magic));
2870 2870
2871 CHECK_EQ(magic, m.Call()); 2871 CHECK_EQ(magic, m.Call());
2872 CHECK_EQ(static_cast<double>(magic), result); 2872 CHECK_EQ(static_cast<double>(magic), result);
2873 } 2873 }
2874 2874
2875 2875
2876 TEST(RunConvertInt32ToFloat64_B) { 2876 TEST(RunChangeInt32ToFloat64_B) {
2877 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2877 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2878 double output = 0; 2878 double output = 0;
2879 2879
2880 Node* convert = m.ConvertInt32ToFloat64(m.Parameter(0)); 2880 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0));
2881 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), 2881 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0),
2882 convert); 2882 convert);
2883 m.Return(m.Parameter(0)); 2883 m.Return(m.Parameter(0));
2884 2884
2885 FOR_INT32_INPUTS(i) { 2885 FOR_INT32_INPUTS(i) {
2886 int32_t expect = *i; 2886 int32_t expect = *i;
2887 CHECK_EQ(expect, m.Call(expect)); 2887 CHECK_EQ(expect, m.Call(expect));
2888 CHECK_EQ(static_cast<double>(expect), output); 2888 CHECK_EQ(static_cast<double>(expect), output);
2889 } 2889 }
2890 } 2890 }
2891 2891
2892 2892
2893 TEST(RunConvertUint32ToFloat64_B) { 2893 TEST(RunChangeUint32ToFloat64_B) {
2894 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2894 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2895 double output = 0; 2895 double output = 0;
2896 2896
2897 Node* convert = m.ConvertUint32ToFloat64(m.Parameter(0)); 2897 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0));
2898 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), 2898 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0),
2899 convert); 2899 convert);
2900 m.Return(m.Parameter(0)); 2900 m.Return(m.Parameter(0));
2901 2901
2902 FOR_UINT32_INPUTS(i) { 2902 FOR_UINT32_INPUTS(i) {
2903 uint32_t expect = *i; 2903 uint32_t expect = *i;
2904 CHECK_EQ(expect, m.Call(expect)); 2904 CHECK_EQ(expect, m.Call(expect));
2905 CHECK_EQ(static_cast<double>(expect), output); 2905 CHECK_EQ(static_cast<double>(expect), output);
2906 } 2906 }
2907 } 2907 }
2908 2908
2909 2909
2910 TEST(RunConvertFloat64ToInt32_A) { 2910 TEST(RunChangeFloat64ToInt32_A) {
2911 RawMachineAssemblerTester<int32_t> m; 2911 RawMachineAssemblerTester<int32_t> m;
2912 int32_t magic = 0x786234; 2912 int32_t magic = 0x786234;
2913 double input = 11.1; 2913 double input = 11.1;
2914 int32_t result = 0; 2914 int32_t result = 0;
2915 2915
2916 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(0), 2916 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(0),
2917 m.ConvertFloat64ToInt32(m.Float64Constant(input))); 2917 m.ChangeFloat64ToInt32(m.Float64Constant(input)));
2918 m.Return(m.Int32Constant(magic)); 2918 m.Return(m.Int32Constant(magic));
2919 2919
2920 CHECK_EQ(magic, m.Call()); 2920 CHECK_EQ(magic, m.Call());
2921 CHECK_EQ(static_cast<int32_t>(input), result); 2921 CHECK_EQ(static_cast<int32_t>(input), result);
2922 } 2922 }
2923 2923
2924 2924
2925 TEST(RunConvertFloat64ToInt32_B) { 2925 TEST(RunChangeFloat64ToInt32_B) {
2926 RawMachineAssemblerTester<int32_t> m; 2926 RawMachineAssemblerTester<int32_t> m;
2927 double input = 0; 2927 double input = 0;
2928 int32_t output = 0; 2928 int32_t output = 0;
2929 2929
2930 Node* load = 2930 Node* load =
2931 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 2931 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2932 Node* convert = m.ConvertFloat64ToInt32(load); 2932 Node* convert = m.ChangeFloat64ToInt32(load);
2933 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), 2933 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0),
2934 convert); 2934 convert);
2935 m.Return(convert); 2935 m.Return(convert);
2936 2936
2937 { 2937 {
2938 FOR_INT32_INPUTS(i) { 2938 FOR_INT32_INPUTS(i) {
2939 input = *i; 2939 input = *i;
2940 int32_t expect = *i; 2940 int32_t expect = *i;
2941 CHECK_EQ(expect, m.Call()); 2941 CHECK_EQ(expect, m.Call());
2942 CHECK_EQ(expect, output); 2942 CHECK_EQ(expect, output);
(...skipping 14 matching lines...) Expand all
2957 int32_t expect = static_cast<int32_t>(input); 2957 int32_t expect = static_cast<int32_t>(input);
2958 CHECK_EQ(expect, m.Call()); 2958 CHECK_EQ(expect, m.Call());
2959 CHECK_EQ(expect, output); 2959 CHECK_EQ(expect, output);
2960 } 2960 }
2961 } 2961 }
2962 // Note we don't check fractional inputs, because these Convert operators 2962 // Note we don't check fractional inputs, because these Convert operators
2963 // really should be Change operators. 2963 // really should be Change operators.
2964 } 2964 }
2965 2965
2966 2966
2967 TEST(RunConvertFloat64ToUint32_B) { 2967 TEST(RunChangeFloat64ToUint32_B) {
2968 RawMachineAssemblerTester<int32_t> m; 2968 RawMachineAssemblerTester<int32_t> m;
2969 double input = 0; 2969 double input = 0;
2970 int32_t output = 0; 2970 int32_t output = 0;
2971 2971
2972 Node* load = 2972 Node* load =
2973 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 2973 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2974 Node* convert = m.ConvertFloat64ToUint32(load); 2974 Node* convert = m.ChangeFloat64ToUint32(load);
2975 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), 2975 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0),
2976 convert); 2976 convert);
2977 m.Return(convert); 2977 m.Return(convert);
2978 2978
2979 { 2979 {
2980 FOR_UINT32_INPUTS(i) { 2980 FOR_UINT32_INPUTS(i) {
2981 input = *i; 2981 input = *i;
2982 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t. 2982 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t.
2983 int32_t expect = static_cast<int32_t>(*i); 2983 int32_t expect = static_cast<int32_t>(*i);
2984 CHECK_EQ(expect, m.Call()); 2984 CHECK_EQ(expect, m.Call());
(...skipping 15 matching lines...) Expand all
3000 int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input)); 3000 int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input));
3001 CHECK_EQ(expect, m.Call()); 3001 CHECK_EQ(expect, m.Call());
3002 CHECK_EQ(expect, output); 3002 CHECK_EQ(expect, output);
3003 } 3003 }
3004 } 3004 }
3005 // Note we don't check fractional inputs, because these Convert operators 3005 // Note we don't check fractional inputs, because these Convert operators
3006 // really should be Change operators. 3006 // really should be Change operators.
3007 } 3007 }
3008 3008
3009 3009
3010 TEST(RunConvertFloat64ToInt32_spilled) { 3010 TEST(RunChangeFloat64ToInt32_spilled) {
3011 RawMachineAssemblerTester<int32_t> m; 3011 RawMachineAssemblerTester<int32_t> m;
3012 const int kNumInputs = 32; 3012 const int kNumInputs = 32;
3013 int32_t magic = 0x786234; 3013 int32_t magic = 0x786234;
3014 double input[kNumInputs]; 3014 double input[kNumInputs];
3015 int32_t result[kNumInputs]; 3015 int32_t result[kNumInputs];
3016 Node* input_node[kNumInputs]; 3016 Node* input_node[kNumInputs];
3017 3017
3018 for (int i = 0; i < kNumInputs; i++) { 3018 for (int i = 0; i < kNumInputs; i++) {
3019 input_node[i] = m.Load(kMachineFloat64, m.PointerConstant(&input), 3019 input_node[i] = m.Load(kMachineFloat64, m.PointerConstant(&input),
3020 m.Int32Constant(i * 8)); 3020 m.Int32Constant(i * 8));
3021 } 3021 }
3022 3022
3023 for (int i = 0; i < kNumInputs; i++) { 3023 for (int i = 0; i < kNumInputs; i++) {
3024 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(i * 4), 3024 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(i * 4),
3025 m.ConvertFloat64ToInt32(input_node[i])); 3025 m.ChangeFloat64ToInt32(input_node[i]));
3026 } 3026 }
3027 3027
3028 m.Return(m.Int32Constant(magic)); 3028 m.Return(m.Int32Constant(magic));
3029 3029
3030 for (int i = 0; i < kNumInputs; i++) { 3030 for (int i = 0; i < kNumInputs; i++) {
3031 input[i] = 100.9 + i; 3031 input[i] = 100.9 + i;
3032 } 3032 }
3033 3033
3034 CHECK_EQ(magic, m.Call()); 3034 CHECK_EQ(magic, m.Call());
3035 3035
3036 for (int i = 0; i < kNumInputs; i++) { 3036 for (int i = 0; i < kNumInputs; i++) {
3037 CHECK_EQ(result[i], 100 + i); 3037 CHECK_EQ(result[i], 100 + i);
3038 } 3038 }
3039 } 3039 }
3040 3040
3041 3041
3042 TEST(RunDeadConvertFloat64ToInt32) { 3042 TEST(RunDeadChangeFloat64ToInt32) {
3043 RawMachineAssemblerTester<int32_t> m; 3043 RawMachineAssemblerTester<int32_t> m;
3044 const int magic = 0x88abcda4; 3044 const int magic = 0x88abcda4;
3045 m.ConvertFloat64ToInt32(m.Float64Constant(999.78)); 3045 m.ChangeFloat64ToInt32(m.Float64Constant(999.78));
3046 m.Return(m.Int32Constant(magic)); 3046 m.Return(m.Int32Constant(magic));
3047 CHECK_EQ(magic, m.Call()); 3047 CHECK_EQ(magic, m.Call());
3048 } 3048 }
3049 3049
3050 3050
3051 TEST(RunDeadConvertInt32ToFloat64) { 3051 TEST(RunDeadChangeInt32ToFloat64) {
3052 RawMachineAssemblerTester<int32_t> m; 3052 RawMachineAssemblerTester<int32_t> m;
3053 const int magic = 0x8834abcd; 3053 const int magic = 0x8834abcd;
3054 m.ConvertInt32ToFloat64(m.Int32Constant(magic - 6888)); 3054 m.ChangeInt32ToFloat64(m.Int32Constant(magic - 6888));
3055 m.Return(m.Int32Constant(magic)); 3055 m.Return(m.Int32Constant(magic));
3056 CHECK_EQ(magic, m.Call()); 3056 CHECK_EQ(magic, m.Call());
3057 } 3057 }
3058 3058
3059 3059
3060 TEST(RunLoopPhiInduction2) { 3060 TEST(RunLoopPhiInduction2) {
3061 RawMachineAssemblerTester<int32_t> m; 3061 RawMachineAssemblerTester<int32_t> m;
3062 3062
3063 int false_val = 0x10777; 3063 int false_val = 0x10777;
3064 3064
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 FOR_UINT32_INPUTS(i) { 3966 FOR_UINT32_INPUTS(i) {
3967 FOR_UINT32_INPUTS(j) { 3967 FOR_UINT32_INPUTS(j) {
3968 int32_t expected; 3968 int32_t expected;
3969 if (sadd_overflow(*i, *j, &expected)) expected = ~expected; 3969 if (sadd_overflow(*i, *j, &expected)) expected = ~expected;
3970 CHECK_EQ(expected, bt.call(*i, *j)); 3970 CHECK_EQ(expected, bt.call(*i, *j));
3971 } 3971 }
3972 } 3972 }
3973 } 3973 }
3974 3974
3975 #endif // V8_TURBOFAN_TARGET 3975 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-representation-change.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698