xref: /aosp_15_r20/art/compiler/optimizing/intrinsics_riscv64.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
21*795d594fSAndroid Build Coastguard Worker #include "intrinsics.h"
22*795d594fSAndroid Build Coastguard Worker #include "intrinsics_list.h"
23*795d594fSAndroid Build Coastguard Worker 
24*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
25*795d594fSAndroid Build Coastguard Worker 
26*795d594fSAndroid Build Coastguard Worker class ArenaAllocator;
27*795d594fSAndroid Build Coastguard Worker class HInvokeStaticOrDirect;
28*795d594fSAndroid Build Coastguard Worker class HInvokeVirtual;
29*795d594fSAndroid Build Coastguard Worker 
30*795d594fSAndroid Build Coastguard Worker namespace riscv64 {
31*795d594fSAndroid Build Coastguard Worker 
32*795d594fSAndroid Build Coastguard Worker class CodeGeneratorRISCV64;
33*795d594fSAndroid Build Coastguard Worker class Riscv64Assembler;
34*795d594fSAndroid Build Coastguard Worker 
35*795d594fSAndroid Build Coastguard Worker class IntrinsicLocationsBuilderRISCV64 final : public IntrinsicVisitor {
36*795d594fSAndroid Build Coastguard Worker  public:
IntrinsicLocationsBuilderRISCV64(ArenaAllocator * allocator,CodeGeneratorRISCV64 * codegen)37*795d594fSAndroid Build Coastguard Worker   explicit IntrinsicLocationsBuilderRISCV64(ArenaAllocator* allocator,
38*795d594fSAndroid Build Coastguard Worker                                             CodeGeneratorRISCV64* codegen)
39*795d594fSAndroid Build Coastguard Worker       : allocator_(allocator), codegen_(codegen) {}
40*795d594fSAndroid Build Coastguard Worker 
41*795d594fSAndroid Build Coastguard Worker   // Define visitor methods.
42*795d594fSAndroid Build Coastguard Worker 
43*795d594fSAndroid Build Coastguard Worker #define OPTIMIZING_INTRINSICS(Name, ...) \
44*795d594fSAndroid Build Coastguard Worker   void Visit##Name(HInvoke* invoke) override;
45*795d594fSAndroid Build Coastguard Worker   ART_INTRINSICS_WITH_HINVOKE_LIST(OPTIMIZING_INTRINSICS)
46*795d594fSAndroid Build Coastguard Worker #undef OPTIMIZING_INTRINSICS
47*795d594fSAndroid Build Coastguard Worker 
48*795d594fSAndroid Build Coastguard Worker   // Check whether an invoke is an intrinsic, and if so, create a location summary. Returns whether
49*795d594fSAndroid Build Coastguard Worker   // a corresponding LocationSummary with the intrinsified_ flag set was generated and attached to
50*795d594fSAndroid Build Coastguard Worker   // the invoke.
51*795d594fSAndroid Build Coastguard Worker   bool TryDispatch(HInvoke* invoke);
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker  private:
54*795d594fSAndroid Build Coastguard Worker   ArenaAllocator* const allocator_;
55*795d594fSAndroid Build Coastguard Worker   CodeGeneratorRISCV64* const codegen_;
56*795d594fSAndroid Build Coastguard Worker 
57*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(IntrinsicLocationsBuilderRISCV64);
58*795d594fSAndroid Build Coastguard Worker };
59*795d594fSAndroid Build Coastguard Worker 
60*795d594fSAndroid Build Coastguard Worker class IntrinsicCodeGeneratorRISCV64 final : public IntrinsicVisitor {
61*795d594fSAndroid Build Coastguard Worker  public:
IntrinsicCodeGeneratorRISCV64(CodeGeneratorRISCV64 * codegen)62*795d594fSAndroid Build Coastguard Worker   explicit IntrinsicCodeGeneratorRISCV64(CodeGeneratorRISCV64* codegen) : codegen_(codegen) {}
63*795d594fSAndroid Build Coastguard Worker 
64*795d594fSAndroid Build Coastguard Worker   // Define visitor methods.
65*795d594fSAndroid Build Coastguard Worker 
66*795d594fSAndroid Build Coastguard Worker #define OPTIMIZING_INTRINSICS(Name, ...) \
67*795d594fSAndroid Build Coastguard Worker   void Visit##Name(HInvoke* invoke);
68*795d594fSAndroid Build Coastguard Worker   ART_INTRINSICS_WITH_HINVOKE_LIST(OPTIMIZING_INTRINSICS)
69*795d594fSAndroid Build Coastguard Worker #undef OPTIMIZING_INTRINSICS
70*795d594fSAndroid Build Coastguard Worker 
71*795d594fSAndroid Build Coastguard Worker  private:
72*795d594fSAndroid Build Coastguard Worker   Riscv64Assembler* GetAssembler();
73*795d594fSAndroid Build Coastguard Worker   ArenaAllocator* GetAllocator();
74*795d594fSAndroid Build Coastguard Worker 
75*795d594fSAndroid Build Coastguard Worker   void HandleValueOf(HInvoke* invoke,
76*795d594fSAndroid Build Coastguard Worker                      const IntrinsicVisitor::ValueOfInfo& info,
77*795d594fSAndroid Build Coastguard Worker                      DataType::Type type);
78*795d594fSAndroid Build Coastguard Worker 
79*795d594fSAndroid Build Coastguard Worker   CodeGeneratorRISCV64* const codegen_;
80*795d594fSAndroid Build Coastguard Worker 
81*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(IntrinsicCodeGeneratorRISCV64);
82*795d594fSAndroid Build Coastguard Worker };
83*795d594fSAndroid Build Coastguard Worker 
84*795d594fSAndroid Build Coastguard Worker }  // namespace riscv64
85*795d594fSAndroid Build Coastguard Worker }  // namespace art
86*795d594fSAndroid Build Coastguard Worker 
87*795d594fSAndroid Build Coastguard Worker #endif  // ART_COMPILER_OPTIMIZING_INTRINSICS_RISCV64_H_
88