RISCV: [Codegen] Define instrinsics but not implemented

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: I7180559a5c43ac89d5794e25275045d76a8a7e32
diff --git a/compiler/optimizing/code_generator_riscv64.cc b/compiler/optimizing/code_generator_riscv64.cc
index 1534b0d..9ef2771 100644
--- a/compiler/optimizing/code_generator_riscv64.cc
+++ b/compiler/optimizing/code_generator_riscv64.cc
@@ -25,6 +25,7 @@
 #include "dwarf/register.h"
 #include "heap_poisoning.h"
 #include "intrinsics_list.h"
+#include "intrinsics_riscv64.h"
 #include "jit/profiling_info.h"
 #include "mirror/class-inl.h"
 #include "optimizing/nodes.h"
@@ -33,7 +34,7 @@
 #include "utils/riscv64/assembler_riscv64.h"
 #include "utils/stack_checks.h"
 
-namespace art {
+namespace art HIDDEN {
 namespace riscv64 {
 
 static constexpr XRegister kCoreCalleeSaves[] = {
diff --git a/compiler/optimizing/code_generator_riscv64.h b/compiler/optimizing/code_generator_riscv64.h
index 9aedcdf..39348c3 100644
--- a/compiler/optimizing/code_generator_riscv64.h
+++ b/compiler/optimizing/code_generator_riscv64.h
@@ -27,8 +27,7 @@
 #include "parallel_move_resolver.h"
 #include "utils/riscv64/assembler_riscv64.h"
 
-namespace art {
-
+namespace art HIDDEN {
 namespace riscv64 {
 
 // InvokeDexCallingConvention registers
diff --git a/compiler/optimizing/intrinsics_riscv64.h b/compiler/optimizing/intrinsics_riscv64.h
new file mode 100644
index 0000000..6c5ecaf
--- /dev/null
+++ b/compiler/optimizing/intrinsics_riscv64.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_
+#define ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_
+
+#include "base/macros.h"
+#include "intrinsics.h"
+#include "intrinsics_list.h"
+
+namespace art HIDDEN {
+
+class ArenaAllocator;
+class HInvokeStaticOrDirect;
+class HInvokeVirtual;
+
+namespace riscv64 {
+
+class CodeGeneratorRISCV64;
+class Riscv64Assembler;
+
+class IntrinsicLocationsBuilderRISCV64 final : public IntrinsicVisitor {
+ public:
+  explicit IntrinsicLocationsBuilderRISCV64(ArenaAllocator* allocator,
+                                            CodeGeneratorRISCV64* codegen)
+      : allocator_(allocator), codegen_(codegen) {}
+
+  // Define visitor methods.
+
+  // TODO(riscv64): Implement in `intrinsics_riscv64.cc`.
+#define OPTIMIZING_INTRINSICS(                                             \
+    Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \
+  void Visit##Name(HInvoke* invoke) override {                             \
+    UNUSED(invoke);                                                        \
+    LOG(FATAL) << "Unimplemented";                                         \
+  }
+  ART_INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
+#undef OPTIMIZING_INTRINSICS
+
+  // Check whether an invoke is an intrinsic, and if so, create a location summary. Returns whether
+  // a corresponding LocationSummary with the intrinsified_ flag set was generated and attached to
+  // the invoke.
+  bool TryDispatch(HInvoke* invoke) {
+    // TODO(riscv64): Implement in `intrinsics_riscv64.cc`.
+    UNUSED(invoke);
+    // Avoid compiling failed with "not used"
+    UNUSED(codegen_);
+    UNUSED(allocator_);
+    return false;
+  }
+
+ private:
+  ArenaAllocator* const allocator_;
+  CodeGeneratorRISCV64* const codegen_;
+
+  DISALLOW_COPY_AND_ASSIGN(IntrinsicLocationsBuilderRISCV64);
+};
+
+class IntrinsicCodeGeneratorRISCV64 final : public IntrinsicVisitor {
+ public:
+  explicit IntrinsicCodeGeneratorRISCV64(CodeGeneratorRISCV64* codegen) : codegen_(codegen) {}
+
+  // Define visitor methods.
+
+  // TODO(riscv64): Implement in `intrinsics_riscv64.cc`.
+#define OPTIMIZING_INTRINSICS(                                             \
+    Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \
+  void Visit##Name(HInvoke* invoke) override {                             \
+    UNUSED(invoke);                                                        \
+    LOG(FATAL) << "Unimplemented";                                         \
+  }
+  ART_INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
+#undef OPTIMIZING_INTRINSICS
+
+ private:
+  Riscv64Assembler* GetAssembler();
+
+  ArenaAllocator* GetAllocator();
+
+  CodeGeneratorRISCV64* const codegen_;
+
+  DISALLOW_COPY_AND_ASSIGN(IntrinsicCodeGeneratorRISCV64);
+};
+
+}  // namespace riscv64
+}  // namespace art
+
+#endif  // ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_