1 /*
2  * Copyright (C) 2011 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_MIPS_CALLING_CONVENTION_MIPS_H_
18 #define ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace mips {
25 
26 constexpr size_t kFramePointerSize = 4;
27 static_assert(kFramePointerSize == static_cast<size_t>(PointerSize::k32),
28               "Invalid frame pointer size");
29 
30 class MipsManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
31  public:
MipsManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)32   MipsManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
33       : ManagedRuntimeCallingConvention(is_static,
34                                         is_synchronized,
35                                         shorty,
36                                         PointerSize::k32) {}
~MipsManagedRuntimeCallingConvention()37   ~MipsManagedRuntimeCallingConvention() 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(MipsManagedRuntimeCallingConvention);
53 };
54 
55 class MipsJniCallingConvention FINAL : public JniCallingConvention {
56  public:
57   MipsJniCallingConvention(bool is_static,
58                            bool is_synchronized,
59                            bool is_critical_native,
60                            const char* shorty);
~MipsJniCallingConvention()61   ~MipsJniCallingConvention() OVERRIDE {}
62   // Calling convention
63   ManagedRegister ReturnRegister() OVERRIDE;
64   ManagedRegister IntReturnRegister() OVERRIDE;
65   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
66   // JNI calling convention
67   void Next() OVERRIDE;  // Override default behavior for o32.
68   size_t FrameSize() OVERRIDE;
69   size_t OutArgSize() OVERRIDE;
70   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const OVERRIDE;
71   ManagedRegister ReturnScratchRegister() const OVERRIDE;
72   uint32_t CoreSpillMask() const OVERRIDE;
73   uint32_t FpSpillMask() const OVERRIDE;
74   bool IsCurrentParamInRegister() OVERRIDE;
75   bool IsCurrentParamOnStack() OVERRIDE;
76   ManagedRegister CurrentParamRegister() OVERRIDE;
77   FrameOffset CurrentParamStackOffset() OVERRIDE;
78 
79   // Mips does not need to extend small return types.
RequiresSmallResultTypeExtension()80   bool RequiresSmallResultTypeExtension() const OVERRIDE {
81     return false;
82   }
83 
84  protected:
85   size_t NumberOfOutgoingStackArgs() OVERRIDE;
86 
87  private:
88   // Padding to ensure longs and doubles are not split in o32.
89   size_t padding_;
90   size_t use_fp_arg_registers_;
91 
92   DISALLOW_COPY_AND_ASSIGN(MipsJniCallingConvention);
93 };
94 
95 }  // namespace mips
96 }  // namespace art
97 
98 #endif  // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_
99