diff options
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 4e2f1cd9a8..c29e283850 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -1002,6 +1002,11 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 break; } + case Instruction::INT_TO_BYTE: { + Conversion_12x(instruction, Primitive::kPrimInt, Primitive::kPrimByte); + break; + } + case Instruction::ADD_INT: { Binop_23x<HAdd>(instruction, Primitive::kPrimInt); break; diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index be326dcece..0403c5e666 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -1348,6 +1348,22 @@ void LocationsBuilderARM::VisitTypeConversion(HTypeConversion* conversion) { Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + 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: @@ -1410,6 +1426,21 @@ void InstructionCodeGeneratorARM::VisitTypeConversion(HTypeConversion* conversio Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + __ sbfx(out.As<Register>(), in.As<Register>(), 0, 8); + 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 904e6272c1..0944f4c38f 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -1282,6 +1282,22 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + 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: @@ -1344,6 +1360,29 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + if (in.IsRegister()) { + __ movsxb(out.As<Register>(), in.As<ByteRegister>()); + } else if (in.IsStackSlot()) { + __ movsxb(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<int8_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 f94c28fd22..a827f99995 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -1280,6 +1280,22 @@ void LocationsBuilderX86_64::VisitTypeConversion(HTypeConversion* conversion) { Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + 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: @@ -1344,6 +1360,30 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver Primitive::Type result_type = conversion->GetResultType(); Primitive::Type input_type = conversion->GetInputType(); switch (result_type) { + case Primitive::kPrimByte: + switch (input_type) { + case Primitive::kPrimShort: + case Primitive::kPrimInt: + case Primitive::kPrimChar: + // int-to-byte conversion. + if (in.IsRegister()) { + __ movsxb(out.As<CpuRegister>(), in.As<CpuRegister>()); + } else if (in.IsStackSlot()) { + __ movsxb(out.As<CpuRegister>(), + Address(CpuRegister(RSP), in.GetStackIndex())); + } else { + DCHECK(in.GetConstant()->IsIntConstant()); + __ movl(out.As<CpuRegister>(), + Immediate(static_cast<int8_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: |