1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_COMPILER_JNI_QUICK_MIPS64_CALLING_CONVENTION_MIPS64_H_
18 #define ART_COMPILER_JNI_QUICK_MIPS64_CALLING_CONVENTION_MIPS64_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace mips64 {
25 
26 constexpr size_t kFramePointerSize = 8;
27 static_assert(kFramePointerSize == static_cast<size_t>(PointerSize::k64),
28               "Invalid frame pointer size");
29 
30 class Mips64ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention {
31  public:
Mips64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)32   Mips64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
33       : ManagedRuntimeCallingConvention(is_static,
34                                         is_synchronized,
35                                         shorty,
36                                         PointerSize::k64) {}
~Mips64ManagedRuntimeCallingConvention()37   ~Mips64ManagedRuntimeCallingConvention() override {}
38   // Calling convention
39   ManagedRegister ReturnRegister() override;
40   ManagedRegister InterproceduralScratchRegister() override;
41   // Managed runtime calling convention
42   ManagedRegister MethodRegister() override;
43   bool IsCurrentParamInRegister() override;
44   bool IsCurrentParamOnStack() override;
45   ManagedRegister CurrentParamRegister() override;
46   FrameOffset CurrentParamStackOffset() override;
47   const ManagedRegisterEntrySpills& EntrySpills() override;
48 
49  private:
50   ManagedRegisterEntrySpills entry_spills_;
51 
52   DISALLOW_COPY_AND_ASSIGN(Mips64ManagedRuntimeCallingConvention);
53 };
54 
55 class Mips64JniCallingConvention final : public JniCallingConvention {
56  public:
57   Mips64JniCallingConvention(bool is_static,
58                              bool is_synchronized,
59                              bool is_critical_native,
60                              const char* shorty);
~Mips64JniCallingConvention()61   ~Mips64JniCallingConvention() override {}
62   // Calling convention
63   ManagedRegister ReturnRegister() override;
64   ManagedRegister IntReturnRegister() override;
65   ManagedRegister InterproceduralScratchRegister() override;
66   // JNI calling convention
67   size_t FrameSize() override;
68   size_t OutArgSize() override;
69   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override;
70   ManagedRegister ReturnScratchRegister() const override;
71   uint32_t CoreSpillMask() const override;
72   uint32_t FpSpillMask() const override;
73   bool IsCurrentParamInRegister() override;
74   bool IsCurrentParamOnStack() override;
75   ManagedRegister CurrentParamRegister() override;
76   FrameOffset CurrentParamStackOffset() override;
77 
78   // Mips64 does not need to extend small return types.
RequiresSmallResultTypeExtension()79   bool RequiresSmallResultTypeExtension() const override {
80     return false;
81   }
82 
83  protected:
84   size_t NumberOfOutgoingStackArgs() override;
85 
86  private:
87   DISALLOW_COPY_AND_ASSIGN(Mips64JniCallingConvention);
88 };
89 
90 }  // namespace mips64
91 }  // namespace art
92 
93 #endif  // ART_COMPILER_JNI_QUICK_MIPS64_CALLING_CONVENTION_MIPS64_H_
94