diff options
author | Roland Levillain <rpl@google.com> | 2014-12-05 12:06:01 +0000 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2014-12-05 12:06:01 +0000 |
commit | 4c0b61f506644bb6b647be05d02c5fb45b9ceb48 (patch) | |
tree | 26ff4e14af3cae5f9b30f65177be258d8259ecee /compiler/optimizing/code_generator_arm.cc | |
parent | 7c8ce29e97fb7873160ab8895d847e9643a1f8f6 (diff) | |
download | android_art-4c0b61f506644bb6b647be05d02c5fb45b9ceb48.tar.gz android_art-4c0b61f506644bb6b647be05d02c5fb45b9ceb48.tar.bz2 android_art-4c0b61f506644bb6b647be05d02c5fb45b9ceb48.zip |
Add support for double-to-int & double-to-long in optimizing.
- Add support for the double-to-int and double-to-long Dex
instructions in the optimizing compiler.
- Add S1 to the list of ARM FPU parameter registers so that
a double value can be passed as parameter during a call
to the runtime through D0.
- Have art::x86_64::X86_64Assembler::cvttsd2si work with
64-bit operands.
- Generate x86, x86-64 and ARM (but not ARM64) code for
double to int and double to long HTypeConversion nodes.
- Add related tests to test/422-type-conversion.
Change-Id: Ic93b9ec6630c26e940f7966a3346ad3fd5a2ab3a
Diffstat (limited to 'compiler/optimizing/code_generator_arm.cc')
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 5076c85885..36af393e3b 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -44,7 +44,7 @@ static constexpr int kCurrentMethodStackOffset = 0; static constexpr Register kRuntimeParameterCoreRegisters[] = { R0, R1, R2, R3 }; static constexpr size_t kRuntimeParameterCoreRegistersLength = arraysize(kRuntimeParameterCoreRegisters); -static constexpr SRegister kRuntimeParameterFpuRegisters[] = { S0 }; +static constexpr SRegister kRuntimeParameterFpuRegisters[] = { S0, S1 }; static constexpr size_t kRuntimeParameterFpuRegistersLength = arraysize(kRuntimeParameterFpuRegisters); @@ -1365,9 +1365,11 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { Primitive::Type input_type = conversion->GetInputType(); DCHECK_NE(result_type, input_type); - // Float-to-long conversions invoke the runtime. + // The float-to-long and double-to-long type conversions rely on a + // call to the runtime. LocationSummary::CallKind call_kind = - (input_type == Primitive::kPrimFloat && result_type == Primitive::kPrimLong) + ((input_type == Primitive::kPrimFloat || input_type == Primitive::kPrimDouble) + && result_type == Primitive::kPrimLong) ? LocationSummary::kCall : LocationSummary::kNoCall; LocationSummary* locations = @@ -1422,8 +1424,10 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { break; case Primitive::kPrimDouble: - LOG(FATAL) << "Type conversion from " << input_type - << " to " << result_type << " not yet implemented"; + // Processing a Dex `double-to-int' instruction. + locations->SetInAt(0, Location::RequiresFpuRegister()); + locations->SetOut(Location::RequiresRegister()); + locations->AddTemp(Location::RequiresFpuRegister()); break; default: @@ -1452,10 +1456,15 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { break; } - case Primitive::kPrimDouble: - LOG(FATAL) << "Type conversion from " << input_type << " to " - << result_type << " not yet implemented"; + case Primitive::kPrimDouble: { + // Processing a Dex `double-to-long' instruction. + InvokeRuntimeCallingConvention calling_convention; + locations->SetInAt(0, Location::FpuRegisterPairLocation( + calling_convention.GetFpuRegisterAt(0), + calling_convention.GetFpuRegisterAt(1))); + locations->SetOut(Location::RegisterPairLocation(R0, R1)); break; + } default: LOG(FATAL) << "Unexpected type conversion from " << input_type @@ -1614,10 +1623,15 @@ void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversio break; } - case Primitive::kPrimDouble: - LOG(FATAL) << "Type conversion from " << input_type - << " to " << result_type << " not yet implemented"; + case Primitive::kPrimDouble: { + // Processing a Dex `double-to-int' instruction. + SRegister temp_s = locations->GetTemp(0).AsFpuRegisterPairLow<SRegister>(); + DRegister temp_d = FromLowSToD(temp_s); + __ vmovd(temp_d, FromLowSToD(in.AsFpuRegisterPairLow<SRegister>())); + __ vcvtid(temp_s, temp_d); + __ vmovrs(out.AsRegister<Register>(), temp_s); break; + } default: LOG(FATAL) << "Unexpected type conversion from " << input_type @@ -1643,15 +1657,16 @@ void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversio case Primitive::kPrimFloat: // Processing a Dex `float-to-long' instruction. - // This call does not actually record PC information. codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pF2l), conversion, conversion->GetDexPc()); break; case Primitive::kPrimDouble: - LOG(FATAL) << "Type conversion from " << input_type << " to " - << result_type << " not yet implemented"; + // Processing a Dex `double-to-long' instruction. + codegen_->InvokeRuntime(QUICK_ENTRY_POINT(pD2l), + conversion, + conversion->GetDexPc()); break; default: |