From 647b96f29cb81832e698f863884fdba06674c9de Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Tue, 11 Nov 2014 12:26:26 +0000 Subject: Add support for long-to-int in the optimizing compiler. - Add support for the long-to-int Dex instruction in the optimizing compiler. - Generate x86, x86-64 and ARM (but not ARM64) code for long-to-int HTypeConversion nodes. - Add related tests to test/422-type-conversion. - Also fix comments in test/415-optimizing-arith-neg and in test/416-optimizing-arith-not. Change-Id: I3084af30f2a495d178362ae1154dc7ceb7bf3a58 --- compiler/optimizing/code_generator_arm.cc | 54 +++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'compiler/optimizing/code_generator_arm.cc') diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 467c2a6c29..7f3ebf46db 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -22,9 +22,10 @@ #include "mirror/art_method.h" #include "mirror/class.h" #include "thread.h" -#include "utils/assembler.h" +#include "utils.h" #include "utils/arm/assembler_arm.h" #include "utils/arm/managed_register_arm.h" +#include "utils/assembler.h" #include "utils/stack_checks.h" namespace art { @@ -1333,6 +1334,26 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimInt: + switch (input_type) { + case Primitive::kPrimLong: + // long-to-int conversion. + locations->SetInAt(0, Location::Any()); + locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); + break; + + case Primitive::kPrimFloat: + case Primitive::kPrimDouble: + LOG(FATAL) << "Type conversion from " << input_type + << " to " << result_type << " not yet implemented"; + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimLong: switch (input_type) { case Primitive::kPrimByte: @@ -1356,7 +1377,6 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { } break; - case Primitive::kPrimInt: case Primitive::kPrimFloat: case Primitive::kPrimDouble: LOG(FATAL) << "Type conversion from " << input_type @@ -1376,6 +1396,35 @@ void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversio Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimInt: + switch (input_type) { + case Primitive::kPrimLong: + // long-to-int conversion. + DCHECK(out.IsRegister()); + if (in.IsRegisterPair()) { + __ Mov(out.As(), in.AsRegisterPairLow()); + } else if (in.IsDoubleStackSlot()) { + __ LoadFromOffset(kLoadWord, out.As(), SP, in.GetStackIndex()); + } else { + DCHECK(in.IsConstant()); + DCHECK(in.GetConstant()->IsLongConstant()); + __ LoadImmediate(out.As(), + Low32Bits(in.GetConstant()->AsLongConstant()->GetValue())); + } + break; + + case Primitive::kPrimFloat: + case Primitive::kPrimDouble: + LOG(FATAL) << "Type conversion from " << input_type + << " to " << result_type << " not yet implemented"; + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimLong: switch (input_type) { case Primitive::kPrimByte: @@ -1404,7 +1453,6 @@ void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversio } break; - case Primitive::kPrimInt: case Primitive::kPrimFloat: case Primitive::kPrimDouble: LOG(FATAL) << "Type conversion from " << input_type -- cgit v1.2.3