diff options
author | Roland Levillain <rpl@google.com> | 2014-11-14 11:47:14 +0000 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2014-11-14 11:51:41 +0000 |
commit | 981e45424f52735b1c61ae0eac7e299ed313f8db (patch) | |
tree | b52598c87d7e1cd030e570da2a59ee26199ae481 /compiler/optimizing/code_generator_x86.cc | |
parent | 4594ad627a48e249ee1680e954558dea15f0d133 (diff) | |
download | android_art-981e45424f52735b1c61ae0eac7e299ed313f8db.tar.gz android_art-981e45424f52735b1c61ae0eac7e299ed313f8db.tar.bz2 android_art-981e45424f52735b1c61ae0eac7e299ed313f8db.zip |
Add support for int-to-char in the optimizing compiler.
- Add support for the int-to-char Dex instruction in the
optimizing compiler.
- Implement the ARM and Thumb-2 UBFX instructions and add
tests for them.
- Generate x86, x86-64 and ARM (but not ARM64) code for
byte to char, short to char, int to char (and char to
char!) HTypeConversion nodes.
- Add related tests to test/422-type-conversion.
Change-Id: I5cd4c6d86f0f6a966c059715b98db35cc8f9de76
Diffstat (limited to 'compiler/optimizing/code_generator_x86.cc')
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 6e1abbf076..8a8fec2609 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -1295,7 +1295,7 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { case Primitive::kPrimShort: case Primitive::kPrimInt: case Primitive::kPrimChar: - // int-to-byte conversion. + // Processing a Dex `int-to-byte' instruction. locations->SetInAt(0, Location::Any()); locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); break; @@ -1309,7 +1309,7 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { case Primitive::kPrimInt: switch (input_type) { case Primitive::kPrimLong: - // long-to-int conversion. + // Processing a Dex `long-to-int' instruction. locations->SetInAt(0, Location::Any()); locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); break; @@ -1332,7 +1332,7 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { case Primitive::kPrimShort: case Primitive::kPrimInt: case Primitive::kPrimChar: - // int-to-long conversion. + // Processing a Dex `int-to-long' instruction. locations->SetInAt(0, Location::RegisterLocation(EAX)); locations->SetOut(Location::RegisterPairLocation(EAX, EDX)); break; @@ -1349,6 +1349,23 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { } break; + case Primitive::kPrimChar: + switch (input_type) { + case Primitive::kPrimByte: + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // Processing a Dex `int-to-char' instruction. + locations->SetInAt(0, Location::Any()); + locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimFloat: case Primitive::kPrimDouble: LOG(FATAL) << "Type conversion from " << input_type @@ -1373,7 +1390,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio case Primitive::kPrimShort: case Primitive::kPrimInt: case Primitive::kPrimChar: - // int-to-byte conversion. + // Processing a Dex `int-to-byte' instruction. if (in.IsRegister()) { __ movsxb(out.As<Register>(), in.As<ByteRegister>()); } else if (in.IsStackSlot()) { @@ -1394,7 +1411,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio case Primitive::kPrimInt: switch (input_type) { case Primitive::kPrimLong: - // long-to-int conversion. + // Processing a Dex `long-to-int' instruction. if (in.IsRegisterPair()) { __ movl(out.As<Register>(), in.AsRegisterPairLow<Register>()); } else if (in.IsDoubleStackSlot()) { @@ -1425,7 +1442,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio case Primitive::kPrimShort: case Primitive::kPrimInt: case Primitive::kPrimChar: - // int-to-long conversion. + // Processing a Dex `int-to-long' instruction. DCHECK_EQ(out.AsRegisterPairLow<Register>(), EAX); DCHECK_EQ(out.AsRegisterPairHigh<Register>(), EDX); DCHECK_EQ(in.As<Register>(), EAX); @@ -1444,6 +1461,30 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio } break; + case Primitive::kPrimChar: + switch (input_type) { + case Primitive::kPrimByte: + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // Processing a Dex `Process a Dex `int-to-char'' instruction. + if (in.IsRegister()) { + __ movzxw(out.As<Register>(), in.As<Register>()); + } else if (in.IsStackSlot()) { + __ movzxw(out.As<Register>(), Address(ESP, in.GetStackIndex())); + } else { + DCHECK(in.GetConstant()->IsIntConstant()); + int32_t value = in.GetConstant()->AsIntConstant()->GetValue(); + __ movl(out.As<Register>(), Immediate(static_cast<uint16_t>(value))); + } + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimFloat: case Primitive::kPrimDouble: LOG(FATAL) << "Type conversion from " << input_type |