OLD | NEW |
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 <stdarg.h> | 5 #include <stdarg.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #if V8_TARGET_ARCH_PPC | 9 #if V8_TARGET_ARCH_PPC |
10 | 10 |
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 } | 2695 } |
2696 | 2696 |
2697 | 2697 |
2698 void Simulator::ExecuteExt3(Instruction* instr) { | 2698 void Simulator::ExecuteExt3(Instruction* instr) { |
2699 int opcode = instr->Bits(10, 1) << 1; | 2699 int opcode = instr->Bits(10, 1) << 1; |
2700 switch (opcode) { | 2700 switch (opcode) { |
2701 case FCFID: { | 2701 case FCFID: { |
2702 // fcfids | 2702 // fcfids |
2703 int frt = instr->RTValue(); | 2703 int frt = instr->RTValue(); |
2704 int frb = instr->RBValue(); | 2704 int frb = instr->RBValue(); |
2705 double t_val = get_double_from_d_register(frb); | 2705 int64_t frb_val = get_d_register(frb); |
2706 int64_t* frb_val_p = reinterpret_cast<int64_t*>(&t_val); | 2706 double frt_val = static_cast<float>(frb_val); |
2707 double frt_val = static_cast<float>(*frb_val_p); | |
2708 set_d_register_from_double(frt, frt_val); | 2707 set_d_register_from_double(frt, frt_val); |
2709 return; | 2708 return; |
2710 } | 2709 } |
2711 } | 2710 } |
2712 UNIMPLEMENTED(); // Not used by V8. | 2711 UNIMPLEMENTED(); // Not used by V8. |
2713 } | 2712 } |
2714 | 2713 |
2715 | 2714 |
2716 void Simulator::ExecuteExt4(Instruction* instr) { | 2715 void Simulator::ExecuteExt4(Instruction* instr) { |
2717 switch (instr->Bits(5, 1) << 1) { | 2716 switch (instr->Bits(5, 1) << 1) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 double frt_val = static_cast<float>(frb_val); | 2878 double frt_val = static_cast<float>(frb_val); |
2880 set_d_register_from_double(frt, frt_val); | 2879 set_d_register_from_double(frt, frt_val); |
2881 if (instr->Bit(0)) { // RC bit set | 2880 if (instr->Bit(0)) { // RC bit set |
2882 // UNIMPLEMENTED(); | 2881 // UNIMPLEMENTED(); |
2883 } | 2882 } |
2884 return; | 2883 return; |
2885 } | 2884 } |
2886 case FCFID: { | 2885 case FCFID: { |
2887 int frt = instr->RTValue(); | 2886 int frt = instr->RTValue(); |
2888 int frb = instr->RBValue(); | 2887 int frb = instr->RBValue(); |
2889 double t_val = get_double_from_d_register(frb); | 2888 int64_t frb_val = get_d_register(frb); |
2890 int64_t* frb_val_p = reinterpret_cast<int64_t*>(&t_val); | 2889 double frt_val = static_cast<double>(frb_val); |
2891 double frt_val = static_cast<double>(*frb_val_p); | |
2892 set_d_register_from_double(frt, frt_val); | 2890 set_d_register_from_double(frt, frt_val); |
2893 return; | 2891 return; |
2894 } | 2892 } |
2895 case FCFIDU: { | 2893 case FCFIDU: { |
2896 int frt = instr->RTValue(); | 2894 int frt = instr->RTValue(); |
2897 int frb = instr->RBValue(); | 2895 int frb = instr->RBValue(); |
2898 double t_val = get_double_from_d_register(frb); | 2896 uint64_t frb_val = get_d_register(frb); |
2899 uint64_t* frb_val_p = reinterpret_cast<uint64_t*>(&t_val); | 2897 double frt_val = static_cast<double>(frb_val); |
2900 double frt_val = static_cast<double>(*frb_val_p); | |
2901 set_d_register_from_double(frt, frt_val); | 2898 set_d_register_from_double(frt, frt_val); |
2902 return; | 2899 return; |
2903 } | 2900 } |
2904 case FCTID: { | 2901 case FCTID: { |
2905 int frt = instr->RTValue(); | 2902 int frt = instr->RTValue(); |
2906 int frb = instr->RBValue(); | 2903 int frb = instr->RBValue(); |
2907 double frb_val = get_double_from_d_register(frb); | 2904 double frb_val = get_double_from_d_register(frb); |
2908 int64_t frt_val; | 2905 int64_t frt_val; |
2909 int64_t one = 1; // work-around gcc | 2906 int64_t one = 1; // work-around gcc |
2910 int64_t kMinLongLong = (one << 63); | 2907 int64_t kMinLongLong = (one << 63); |
(...skipping 13 matching lines...) Expand all Loading... |
2924 break; | 2921 break; |
2925 case kRoundToMinusInf: | 2922 case kRoundToMinusInf: |
2926 frt_val = (int64_t)std::floor(frb_val); | 2923 frt_val = (int64_t)std::floor(frb_val); |
2927 break; | 2924 break; |
2928 default: | 2925 default: |
2929 frt_val = (int64_t)frb_val; | 2926 frt_val = (int64_t)frb_val; |
2930 UNIMPLEMENTED(); // Not used by V8. | 2927 UNIMPLEMENTED(); // Not used by V8. |
2931 break; | 2928 break; |
2932 } | 2929 } |
2933 } | 2930 } |
2934 double* p = reinterpret_cast<double*>(&frt_val); | 2931 set_d_register(frt, frt_val); |
2935 set_d_register_from_double(frt, *p); | |
2936 return; | 2932 return; |
2937 } | 2933 } |
2938 case FCTIDZ: { | 2934 case FCTIDZ: { |
2939 int frt = instr->RTValue(); | 2935 int frt = instr->RTValue(); |
2940 int frb = instr->RBValue(); | 2936 int frb = instr->RBValue(); |
2941 double frb_val = get_double_from_d_register(frb); | 2937 double frb_val = get_double_from_d_register(frb); |
2942 int64_t frt_val; | 2938 int64_t frt_val; |
2943 int64_t one = 1; // work-around gcc | 2939 int64_t one = 1; // work-around gcc |
2944 int64_t kMinLongLong = (one << 63); | 2940 int64_t kMinLongLong = (one << 63); |
2945 int64_t kMaxLongLong = kMinLongLong - 1; | 2941 int64_t kMaxLongLong = kMinLongLong - 1; |
2946 | 2942 |
2947 if (frb_val > kMaxLongLong) { | 2943 if (frb_val > kMaxLongLong) { |
2948 frt_val = kMaxLongLong; | 2944 frt_val = kMaxLongLong; |
2949 } else if (frb_val < kMinLongLong) { | 2945 } else if (frb_val < kMinLongLong) { |
2950 frt_val = kMinLongLong; | 2946 frt_val = kMinLongLong; |
2951 } else { | 2947 } else { |
2952 frt_val = (int64_t)frb_val; | 2948 frt_val = (int64_t)frb_val; |
2953 } | 2949 } |
2954 double* p = reinterpret_cast<double*>(&frt_val); | 2950 set_d_register(frt, frt_val); |
2955 set_d_register_from_double(frt, *p); | |
2956 return; | 2951 return; |
2957 } | 2952 } |
2958 case FCTIW: | 2953 case FCTIW: |
2959 case FCTIWZ: { | 2954 case FCTIWZ: { |
2960 int frt = instr->RTValue(); | 2955 int frt = instr->RTValue(); |
2961 int frb = instr->RBValue(); | 2956 int frb = instr->RBValue(); |
2962 double frb_val = get_double_from_d_register(frb); | 2957 double frb_val = get_double_from_d_register(frb); |
2963 int64_t frt_val; | 2958 int64_t frt_val; |
2964 if (frb_val > kMaxInt) { | 2959 if (frb_val > kMaxInt) { |
2965 frt_val = kMaxInt; | 2960 frt_val = kMaxInt; |
(...skipping 23 matching lines...) Expand all Loading... |
2989 } | 2984 } |
2990 | 2985 |
2991 break; | 2986 break; |
2992 default: | 2987 default: |
2993 DCHECK(false); | 2988 DCHECK(false); |
2994 frt_val = (int64_t)frb_val; | 2989 frt_val = (int64_t)frb_val; |
2995 break; | 2990 break; |
2996 } | 2991 } |
2997 } | 2992 } |
2998 } | 2993 } |
2999 double* p = reinterpret_cast<double*>(&frt_val); | 2994 set_d_register(frt, frt_val); |
3000 set_d_register_from_double(frt, *p); | |
3001 return; | 2995 return; |
3002 } | 2996 } |
3003 case FNEG: { | 2997 case FNEG: { |
3004 int frt = instr->RTValue(); | 2998 int frt = instr->RTValue(); |
3005 int frb = instr->RBValue(); | 2999 int frb = instr->RBValue(); |
3006 double frb_val = get_double_from_d_register(frb); | 3000 double frb_val = get_double_from_d_register(frb); |
3007 double frt_val = -frb_val; | 3001 double frt_val = -frb_val; |
3008 set_d_register_from_double(frt, frt_val); | 3002 set_d_register_from_double(frt, frt_val); |
3009 return; | 3003 return; |
3010 } | 3004 } |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3954 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 3948 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
3955 uintptr_t address = *stack_slot; | 3949 uintptr_t address = *stack_slot; |
3956 set_register(sp, current_sp + sizeof(uintptr_t)); | 3950 set_register(sp, current_sp + sizeof(uintptr_t)); |
3957 return address; | 3951 return address; |
3958 } | 3952 } |
3959 } // namespace internal | 3953 } // namespace internal |
3960 } // namespace v8 | 3954 } // namespace v8 |
3961 | 3955 |
3962 #endif // USE_SIMULATOR | 3956 #endif // USE_SIMULATOR |
3963 #endif // V8_TARGET_ARCH_PPC | 3957 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |