summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/code_generator_x86.cc
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2014-11-14 16:27:39 +0000
committerRoland Levillain <rpl@google.com>2014-11-14 16:27:39 +0000
commit01a8d7135c59b4a664d1e0c0e4d8db343d4118ef (patch)
tree2a7470f7320f015e67da880e3cf51fd9d616c17d /compiler/optimizing/code_generator_x86.cc
parentff5298ff1640b730ee62c90ca78fc96b7ee82ec4 (diff)
downloadandroid_art-01a8d7135c59b4a664d1e0c0e4d8db343d4118ef.tar.gz
android_art-01a8d7135c59b4a664d1e0c0e4d8db343d4118ef.tar.bz2
android_art-01a8d7135c59b4a664d1e0c0e4d8db343d4118ef.zip
Add support for int-to-short in the optimizing compiler.
- Add support for the int-to-short Dex instruction in the optimizing compiler. - Generate x86, x86-64 and ARM (but not ARM64) code for byte to short, int to short and char to short HTypeConversion nodes. - Add related tests to test/422-type-conversion. Change-Id: If1829549708d9c3473efaa641f7f0bcfa6080ae9
Diffstat (limited to 'compiler/optimizing/code_generator_x86.cc')
-rw-r--r--compiler/optimizing/code_generator_x86.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 8a8fec2609..b6549b21c3 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -1306,6 +1306,22 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) {
}
break;
+ case Primitive::kPrimShort:
+ switch (input_type) {
+ case Primitive::kPrimByte:
+ case Primitive::kPrimInt:
+ case Primitive::kPrimChar:
+ // Processing a Dex `int-to-short' 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::kPrimInt:
switch (input_type) {
case Primitive::kPrimLong:
@@ -1408,6 +1424,29 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
}
break;
+ case Primitive::kPrimShort:
+ switch (input_type) {
+ case Primitive::kPrimByte:
+ case Primitive::kPrimInt:
+ case Primitive::kPrimChar:
+ // Processing a Dex `int-to-short' instruction.
+ if (in.IsRegister()) {
+ __ movsxw(out.As<Register>(), in.As<Register>());
+ } else if (in.IsStackSlot()) {
+ __ movsxw(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<int16_t>(value)));
+ }
+ break;
+
+ default:
+ LOG(FATAL) << "Unexpected type conversion from " << input_type
+ << " to " << result_type;
+ }
+ break;
+
case Primitive::kPrimInt:
switch (input_type) {
case Primitive::kPrimLong: