diff options
author | 2023-08-01 11:02:17 +0000 | |
---|---|---|
committer | 2023-08-01 16:33:25 +0000 | |
commit | 93142b35bddd0bb0bb8defe946ea7a78dd82f172 (patch) | |
tree | fec6c2183e4c5b5b76f59d2b2769a5bd14e361d2 | |
parent | c8339d8126b995f4df2674730603b10cd1e2f152 (diff) |
riscv64: [codegen] Add VisitMul
Test: m test-art-host-gtest
Bug: 283082089
Change-Id: Ie7914ce253547881842ba3a4ea0f662ad943b83c
-rw-r--r-- | compiler/optimizing/code_generator_riscv64.cc | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/compiler/optimizing/code_generator_riscv64.cc b/compiler/optimizing/code_generator_riscv64.cc index b5adc001a5..bf4a893e22 100644 --- a/compiler/optimizing/code_generator_riscv64.cc +++ b/compiler/optimizing/code_generator_riscv64.cc @@ -2284,13 +2284,53 @@ void InstructionCodeGeneratorRISCV64::VisitMonitorOperation(HMonitorOperation* i } void LocationsBuilderRISCV64::VisitMul(HMul* instruction) { - UNUSED(instruction); - LOG(FATAL) << "Unimplemented"; + LocationSummary* locations = + new (GetGraph()->GetAllocator()) LocationSummary(instruction, LocationSummary::kNoCall); + switch (instruction->GetResultType()) { + case DataType::Type::kInt32: + case DataType::Type::kInt64: + locations->SetInAt(0, Location::RequiresRegister()); + locations->SetInAt(1, Location::RequiresRegister()); + locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); + break; + + case DataType::Type::kFloat32: + case DataType::Type::kFloat64: + locations->SetInAt(0, Location::RequiresFpuRegister()); + locations->SetInAt(1, Location::RequiresFpuRegister()); + locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap); + break; + + default: + LOG(FATAL) << "Unexpected mul type " << instruction->GetResultType(); + } } void InstructionCodeGeneratorRISCV64::VisitMul(HMul* instruction) { - UNUSED(instruction); - LOG(FATAL) << "Unimplemented"; + LocationSummary* locations = instruction->GetLocations(); + switch (instruction->GetResultType()) { + case DataType::Type::kInt32: + case DataType::Type::kInt64: + __ Mul(locations->Out().AsRegister<XRegister>(), + locations->InAt(0).AsRegister<XRegister>(), + locations->InAt(1).AsRegister<XRegister>()); + break; + + case DataType::Type::kFloat32: + __ FMulS(locations->Out().AsFpuRegister<FRegister>(), + locations->InAt(0).AsFpuRegister<FRegister>(), + locations->InAt(1).AsFpuRegister<FRegister>()); + break; + + case DataType::Type::kFloat64: + __ FMulD(locations->Out().AsFpuRegister<FRegister>(), + locations->InAt(0).AsFpuRegister<FRegister>(), + locations->InAt(1).AsFpuRegister<FRegister>()); + break; + + default: + LOG(FATAL) << "Unexpected mul type " << instruction->GetResultType(); + } } void LocationsBuilderRISCV64::VisitNeg(HNeg* instruction) { |