diff options
| author | 2014-11-17 10:24:03 +0000 | |
|---|---|---|
| committer | 2014-11-17 10:24:03 +0000 | |
| commit | 610b21cc7f62c61fcb7d88c1ffcc74bfa9ca5ef8 (patch) | |
| tree | 85314ec6521fd5e8be6b4f75f1dab3ecc16e5a02 /compiler/optimizing | |
| parent | 1ad824c1e2b91196fa5d6a4827322923c3046833 (diff) | |
| parent | 01a8d7135c59b4a664d1e0c0e4d8db343d4118ef (diff) | |
Merge "Add support for int-to-short in the optimizing compiler."
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/builder.cc | 5 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 31 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 39 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 40 |
4 files changed, 115 insertions, 0 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index b51b6e7d25..b5aff4b576 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -1007,6 +1007,11 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 break; } + case Instruction::INT_TO_SHORT: { + Conversion_12x(instruction, Primitive::kPrimInt, Primitive::kPrimShort); + break; + } + case Instruction::INT_TO_CHAR: { Conversion_12x(instruction, Primitive::kPrimInt, Primitive::kPrimChar); break; diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index bb2f899886..c17142d7c9 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -1367,6 +1367,22 @@ void LocationsBuilderARM::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::RequiresRegister()); + 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: @@ -1461,6 +1477,21 @@ void InstructionCodeGeneratorARM::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. + __ sbfx(out.As<Register>(), in.As<Register>(), 0, 16); + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimInt: switch (input_type) { case Primitive::kPrimLong: diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 2ba2501f50..c486580216 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -1310,6 +1310,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: @@ -1412,6 +1428,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: diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 159b54690a..735addba4b 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -1304,6 +1304,22 @@ void LocationsBuilderX86_64::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: @@ -1409,6 +1425,30 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver } 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<CpuRegister>(), in.As<CpuRegister>()); + } else if (in.IsStackSlot()) { + __ movsxw(out.As<CpuRegister>(), + Address(CpuRegister(RSP), in.GetStackIndex())); + } else { + DCHECK(in.GetConstant()->IsIntConstant()); + __ movl(out.As<CpuRegister>(), + Immediate(static_cast<int16_t>(in.GetConstant()->AsIntConstant()->GetValue()))); + } + break; + + default: + LOG(FATAL) << "Unexpected type conversion from " << input_type + << " to " << result_type; + } + break; + case Primitive::kPrimInt: switch (input_type) { case Primitive::kPrimLong: |