OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 // Restore sign if necessary. | 1037 // Restore sign if necessary. |
1038 mov(scratch, sign); | 1038 mov(scratch, sign); |
1039 result = sign; | 1039 result = sign; |
1040 sign = no_reg; | 1040 sign = no_reg; |
1041 Subu(result, zero_reg, input_high); | 1041 Subu(result, zero_reg, input_high); |
1042 movz(result, input_high, scratch); | 1042 movz(result, input_high, scratch); |
1043 bind(&done); | 1043 bind(&done); |
1044 } | 1044 } |
1045 | 1045 |
1046 | 1046 |
| 1047 void MacroAssembler::EmitECMATruncate(Register result, |
| 1048 FPURegister double_input, |
| 1049 FPURegister single_scratch, |
| 1050 Register scratch, |
| 1051 Register input_high, |
| 1052 Register input_low) { |
| 1053 CpuFeatures::Scope scope(FPU); |
| 1054 ASSERT(!input_high.is(result)); |
| 1055 ASSERT(!input_low.is(result)); |
| 1056 ASSERT(!input_low.is(input_high)); |
| 1057 ASSERT(!scratch.is(result) && |
| 1058 !scratch.is(input_high) && |
| 1059 !scratch.is(input_low)); |
| 1060 ASSERT(!single_scratch.is(double_input)); |
| 1061 |
| 1062 Label done; |
| 1063 Label manual; |
| 1064 |
| 1065 // Clear cumulative exception flags and save the FCSR. |
| 1066 Register scratch2 = input_high; |
| 1067 cfc1(scratch2, FCSR); |
| 1068 ctc1(zero_reg, FCSR); |
| 1069 // Try a conversion to a signed integer. |
| 1070 trunc_w_d(single_scratch, double_input); |
| 1071 mfc1(result, single_scratch); |
| 1072 // Retrieve and restore the FCSR. |
| 1073 cfc1(scratch, FCSR); |
| 1074 ctc1(scratch2, FCSR); |
| 1075 // Check for overflow and NaNs. |
| 1076 And(scratch, |
| 1077 scratch, |
| 1078 kFCSROverflowFlagMask | kFCSRUnderflowFlagMask | kFCSRInvalidOpFlagMask); |
| 1079 // If we had no exceptions we are done. |
| 1080 Branch(&done, eq, scratch, Operand(zero_reg)); |
| 1081 |
| 1082 // Load the double value and perform a manual truncation. |
| 1083 Move(input_low, input_high, double_input); |
| 1084 EmitOutOfInt32RangeTruncate(result, |
| 1085 input_high, |
| 1086 input_low, |
| 1087 scratch); |
| 1088 bind(&done); |
| 1089 } |
| 1090 |
| 1091 |
1047 void MacroAssembler::GetLeastBitsFromSmi(Register dst, | 1092 void MacroAssembler::GetLeastBitsFromSmi(Register dst, |
1048 Register src, | 1093 Register src, |
1049 int num_least_bits) { | 1094 int num_least_bits) { |
1050 Ext(dst, src, kSmiTagSize, num_least_bits); | 1095 Ext(dst, src, kSmiTagSize, num_least_bits); |
1051 } | 1096 } |
1052 | 1097 |
1053 | 1098 |
1054 void MacroAssembler::GetLeastBitsFromInt32(Register dst, | 1099 void MacroAssembler::GetLeastBitsFromInt32(Register dst, |
1055 Register src, | 1100 Register src, |
1056 int num_least_bits) { | 1101 int num_least_bits) { |
(...skipping 2982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 opcode == BGTZL); | 4084 opcode == BGTZL); |
4040 opcode = (cond == eq) ? BEQ : BNE; | 4085 opcode = (cond == eq) ? BEQ : BNE; |
4041 instr = (instr & ~kOpcodeMask) | opcode; | 4086 instr = (instr & ~kOpcodeMask) | opcode; |
4042 masm_.emit(instr); | 4087 masm_.emit(instr); |
4043 } | 4088 } |
4044 | 4089 |
4045 | 4090 |
4046 } } // namespace v8::internal | 4091 } } // namespace v8::internal |
4047 | 4092 |
4048 #endif // V8_TARGET_ARCH_MIPS | 4093 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |