riscv64: Let dex2oat run in verification mode (disable compilation).

There is no compiler support for RISC-V yet, but dex2oat can perform
verification and compile boot images and app images as though it was
running with compiler filter "verify". This allows us to re-enable
dexpreopt and speed up the first boot, as there is no need to verify
all the apps on device.

The change is done purely in ART by adding a workaround to turn off
compilation completely on RISC-V, as opposed to setting compiler filter
"verify" in the build system (e.g, we still keep compiler filter
"speed-profile" for boot images in RISC-V). This approach is chosen so
that fewer modifications are needed when adding compiler support.

Bug: b/271573990
Test: `lunch aosp_riscv64-userdebug && m`
      (with cherry-picked https://r.android.com/2511036)
Change-Id: If5dd798d043edc0c0ed321ad2ef5b841e68efe0f
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 74d081d..c8a41ce 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -115,7 +115,9 @@
   }
 
   bool IsAnyCompilationEnabled() const {
-    return CompilerFilter::IsAnyCompilationEnabled(compiler_filter_);
+    return CompilerFilter::IsAnyCompilationEnabled(compiler_filter_) &&
+           // TODO(riscv64): remove this when we have compiler support for RISC-V
+           GetInstructionSet() != InstructionSet::kRiscv64;
   }
 
   size_t GetHugeMethodThreshold() const {
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 7c188b5..cfba522 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -2259,8 +2259,10 @@
   offset = RoundUp(offset, kPageSize);
   oat_header_->SetExecutableOffset(offset);
   size_executable_offset_alignment_ = offset - old_offset;
-  if (GetCompilerOptions().IsBootImage() && primary_oat_file_) {
-    InstructionSet instruction_set = compiler_options_.GetInstructionSet();
+  InstructionSet instruction_set = compiler_options_.GetInstructionSet();
+  if (GetCompilerOptions().IsBootImage() && primary_oat_file_ &&
+      // TODO(riscv64): remove this when we have compiler support for RISC-V.
+      instruction_set != InstructionSet::kRiscv64) {
     const bool generate_debug_info = GetCompilerOptions().GenerateAnyDebugInfo();
     size_t adjusted_offset = offset;
 
@@ -3065,9 +3067,10 @@
 }
 
 size_t OatWriter::WriteCode(OutputStream* out, size_t file_offset, size_t relative_offset) {
-  if (GetCompilerOptions().IsBootImage() && primary_oat_file_) {
-    InstructionSet instruction_set = compiler_options_.GetInstructionSet();
-
+  InstructionSet instruction_set = compiler_options_.GetInstructionSet();
+  if (GetCompilerOptions().IsBootImage() && primary_oat_file_ &&
+      // TODO(riscv64): remove this when we have compiler support for RISC-V.
+      instruction_set != InstructionSet::kRiscv64) {
     #define DO_TRAMPOLINE(field) \
       do { \
         /* Pad with at least four 0xFFs so we can do DCHECKs in OatQuickMethodHeader */ \
diff --git a/runtime/nterp_helpers.cc b/runtime/nterp_helpers.cc
index fb2046c..36135fd 100644
--- a/runtime/nterp_helpers.cc
+++ b/runtime/nterp_helpers.cc
@@ -112,6 +112,11 @@
       core_spills = arm64::Arm64CalleeSaveFrame::GetCoreSpills(CalleeSaveType::kSaveAllCalleeSaves);
       fp_spills = arm64::Arm64CalleeSaveFrame::GetFpSpills(CalleeSaveType::kSaveAllCalleeSaves);
       break;
+    case InstructionSet::kRiscv64:
+      core_spills =
+          riscv64::Riscv64CalleeSaveFrame::GetCoreSpills(CalleeSaveType::kSaveAllCalleeSaves);
+      fp_spills = riscv64::Riscv64CalleeSaveFrame::GetFpSpills(CalleeSaveType::kSaveAllCalleeSaves);
+      break;
     default:
       InstructionSetAbort(isa);
   }