1 /*
2  * Copyright (C) 2014 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_X86_64_CALLING_CONVENTION_X86_64_H_
18 #define ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace x86_64 {
25 
26 class X86_64ManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
27  public:
X86_64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28   X86_64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
29       : ManagedRuntimeCallingConvention(is_static,
30                                         is_synchronized,
31                                         shorty,
32                                         PointerSize::k64) {}
~X86_64ManagedRuntimeCallingConvention()33   ~X86_64ManagedRuntimeCallingConvention() OVERRIDE {}
34   // Calling convention
35   ManagedRegister ReturnRegister() OVERRIDE;
36   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
37   // Managed runtime calling convention
38   ManagedRegister MethodRegister() OVERRIDE;
39   bool IsCurrentParamInRegister() OVERRIDE;
40   bool IsCurrentParamOnStack() OVERRIDE;
41   ManagedRegister CurrentParamRegister() OVERRIDE;
42   FrameOffset CurrentParamStackOffset() OVERRIDE;
43   const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE;
44  private:
45   ManagedRegisterEntrySpills entry_spills_;
46   DISALLOW_COPY_AND_ASSIGN(X86_64ManagedRuntimeCallingConvention);
47 };
48 
49 class X86_64JniCallingConvention FINAL : public JniCallingConvention {
50  public:
51   X86_64JniCallingConvention(bool is_static,
52                              bool is_synchronized,
53                              bool is_critical_native,
54                              const char* shorty);
~X86_64JniCallingConvention()55   ~X86_64JniCallingConvention() OVERRIDE {}
56   // Calling convention
57   ManagedRegister ReturnRegister() OVERRIDE;
58   ManagedRegister IntReturnRegister() OVERRIDE;
59   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
60   // JNI calling convention
61   size_t FrameSize() OVERRIDE;
62   size_t OutArgSize() OVERRIDE;
63   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const OVERRIDE;
64   ManagedRegister ReturnScratchRegister() const OVERRIDE;
65   uint32_t CoreSpillMask() const OVERRIDE;
66   uint32_t FpSpillMask() const OVERRIDE;
67   bool IsCurrentParamInRegister() OVERRIDE;
68   bool IsCurrentParamOnStack() OVERRIDE;
69   ManagedRegister CurrentParamRegister() OVERRIDE;
70   FrameOffset CurrentParamStackOffset() OVERRIDE;
71 
72   // x86-64 needs to extend small return types.
RequiresSmallResultTypeExtension()73   bool RequiresSmallResultTypeExtension() const OVERRIDE {
74     return true;
75   }
76 
77  protected:
78   size_t NumberOfOutgoingStackArgs() OVERRIDE;
79 
80  private:
81   DISALLOW_COPY_AND_ASSIGN(X86_64JniCallingConvention);
82 };
83 
84 }  // namespace x86_64
85 }  // namespace art
86 
87 #endif  // ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_
88