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_ARM_CALLING_CONVENTION_ARM_H_
18 #define ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace arm {
25 
26 class ArmManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention {
27  public:
ArmManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28   ArmManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
29       : ManagedRuntimeCallingConvention(is_static,
30                                         is_synchronized,
31                                         shorty,
32                                         PointerSize::k32),
33         gpr_index_(1u),  // Skip r0 for ArtMethod*
34         float_index_(0u),
35         double_index_(0u) {}
~ArmManagedRuntimeCallingConvention()36   ~ArmManagedRuntimeCallingConvention() override {}
37   // Calling convention
38   ManagedRegister ReturnRegister() override;
39   void ResetIterator(FrameOffset displacement) override;
40   // Managed runtime calling convention
41   ManagedRegister MethodRegister() override;
42   void Next() override;
43   bool IsCurrentParamInRegister() override;
44   bool IsCurrentParamOnStack() override;
45   ManagedRegister CurrentParamRegister() override;
46   FrameOffset CurrentParamStackOffset() override;
47 
48  private:
49   size_t gpr_index_;
50   size_t float_index_;
51   size_t double_index_;
52   DISALLOW_COPY_AND_ASSIGN(ArmManagedRuntimeCallingConvention);
53 };
54 
55 class ArmJniCallingConvention final : public JniCallingConvention {
56  public:
57   ArmJniCallingConvention(bool is_static,
58                           bool is_synchronized,
59                           bool is_critical_native,
60                           const char* shorty);
~ArmJniCallingConvention()61   ~ArmJniCallingConvention() override {}
62   // Calling convention
63   ManagedRegister ReturnRegister() override;
64   ManagedRegister IntReturnRegister() override;
65   // JNI calling convention
66   void Next() override;  // Override default behavior for AAPCS
67   size_t FrameSize() const override;
68   size_t OutFrameSize() const 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   // AAPCS mandates return values are extended.
RequiresSmallResultTypeExtension()79   bool RequiresSmallResultTypeExtension() const override {
80     return false;
81   }
82 
83   // Hidden argument register, used to pass the method pointer for @CriticalNative call.
84   ManagedRegister HiddenArgumentRegister() const override;
85 
86   // Whether to use tail call (used only for @CriticalNative).
87   bool UseTailCall() const override;
88 
89  private:
90   // Padding to ensure longs and doubles are not split in AAPCS
91   size_t padding_;
92 
93   DISALLOW_COPY_AND_ASSIGN(ArmJniCallingConvention);
94 };
95 
96 }  // namespace arm
97 }  // namespace art
98 
99 #endif  // ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
100