RISCV: [Codegen] Add VisitInvokeStaticOrDirect

Test: m test-art-host-gtest
Bug: 283082089
Signed-off-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Wendong Wang <wangwd@xcvmbyte.com>
Change-Id: If7ff995eb3a13785e6b524247ca951d3777baea7
diff --git a/compiler/optimizing/code_generator_riscv64.cc b/compiler/optimizing/code_generator_riscv64.cc
index 9ef2771..2f25388 100644
--- a/compiler/optimizing/code_generator_riscv64.cc
+++ b/compiler/optimizing/code_generator_riscv64.cc
@@ -2073,14 +2073,44 @@
 }
 
 void LocationsBuilderRISCV64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* instruction) {
-  UNUSED(instruction);
-  LOG(FATAL) << "Unimplemented";
+  // Explicit clinit checks triggered by static invokes must have been pruned by
+  // art::PrepareForRegisterAllocation.
+  DCHECK(!instruction->IsStaticWithExplicitClinitCheck());
+
+  IntrinsicLocationsBuilderRISCV64 intrinsic(GetGraph()->GetAllocator(), codegen_);
+  if (intrinsic.TryDispatch(instruction)) {
+    return;
+  }
+
+  if (instruction->GetCodePtrLocation() == CodePtrLocation::kCallCriticalNative) {
+    CriticalNativeCallingConventionVisitorRiscv64 calling_convention_visitor(
+        /*for_register_allocation=*/ true);
+    CodeGenerator::CreateCommonInvokeLocationSummary(instruction, &calling_convention_visitor);
+  } else {
+    HandleInvoke(instruction);
+  }
+}
+
+static bool TryGenerateIntrinsicCode(HInvoke* invoke, CodeGeneratorRISCV64* codegen) {
+  // TODO(riscv64): Implement intrinsics later
+  UNUSED(invoke);
+  UNUSED(codegen);
+  return false;
 }
 
 void InstructionCodeGeneratorRISCV64::VisitInvokeStaticOrDirect(
     HInvokeStaticOrDirect* instruction) {
-  UNUSED(instruction);
-  LOG(FATAL) << "Unimplemented";
+  // Explicit clinit checks triggered by static invokes must have been pruned by
+  // art::PrepareForRegisterAllocation.
+  DCHECK(!instruction->IsStaticWithExplicitClinitCheck());
+
+  if (TryGenerateIntrinsicCode(instruction, codegen_)) {
+    return;
+  }
+
+  LocationSummary* locations = instruction->GetLocations();
+  codegen_->GenerateStaticOrDirectCall(
+      instruction, locations->HasTemps() ? locations->GetTemp(0) : Location::NoLocation());
 }
 
 void LocationsBuilderRISCV64::VisitInvokeVirtual(HInvokeVirtual* instruction) {