• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   bool 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