blob: 4bca318de143bdb4000a5d26294f12a346732758 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 */
Ian Rogers2c8f6532011-09-02 17:16:34 -070016
17#ifndef ART_SRC_CALLING_CONVENTION_X86_H_
18#define ART_SRC_CALLING_CONVENTION_X86_H_
19
20#include "calling_convention.h"
21
22namespace art {
23namespace x86 {
24
25class X86ManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention {
26 public:
Ian Rogers169c9a72011-11-13 20:13:17 -080027 explicit X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized,
28 const char* shorty) :
29 ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty) {}
Ian Rogers2c8f6532011-09-02 17:16:34 -070030 virtual ~X86ManagedRuntimeCallingConvention() {}
31 // Calling convention
32 virtual ManagedRegister ReturnRegister();
33 virtual ManagedRegister InterproceduralScratchRegister();
34 // Managed runtime calling convention
35 virtual ManagedRegister MethodRegister();
36 virtual bool IsCurrentParamInRegister();
37 virtual bool IsCurrentParamOnStack();
38 virtual ManagedRegister CurrentParamRegister();
39 virtual FrameOffset CurrentParamStackOffset();
Ian Rogersb5d09b22012-03-06 22:14:17 -080040 virtual const std::vector<ManagedRegister>& EntrySpills();
Ian Rogers2c8f6532011-09-02 17:16:34 -070041 private:
Ian Rogersb5d09b22012-03-06 22:14:17 -080042 std::vector<ManagedRegister> entry_spills_;
Ian Rogers2c8f6532011-09-02 17:16:34 -070043 DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention);
44};
45
46class X86JniCallingConvention : public JniCallingConvention {
47 public:
Ian Rogers169c9a72011-11-13 20:13:17 -080048 X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty) :
49 JniCallingConvention(is_static, is_synchronized, shorty) {}
Ian Rogers2c8f6532011-09-02 17:16:34 -070050 virtual ~X86JniCallingConvention() {}
51 // Calling convention
52 virtual ManagedRegister ReturnRegister();
53 virtual ManagedRegister InterproceduralScratchRegister();
54 // JNI calling convention
55 virtual size_t FrameSize();
Ian Rogers2c8f6532011-09-02 17:16:34 -070056 virtual size_t OutArgSize();
Ian Rogersbdb03912011-09-14 00:55:44 -070057 virtual const std::vector<ManagedRegister>& CalleeSaveRegisters() const {
58 DCHECK(callee_save_regs_.empty());
59 return callee_save_regs_;
60 }
Ian Rogersdc51b792011-09-22 20:41:37 -070061 virtual ManagedRegister ReturnScratchRegister() const;
Ian Rogersbdb03912011-09-14 00:55:44 -070062 virtual uint32_t CoreSpillMask() const {
63 return 0;
64 }
65 virtual uint32_t FpSpillMask() const {
66 return 0;
67 }
Ian Rogersad42e132011-09-17 20:23:33 -070068 virtual bool IsMethodRegisterClobberedPreCall();
Ian Rogers2c8f6532011-09-02 17:16:34 -070069 virtual bool IsCurrentParamInRegister();
70 virtual bool IsCurrentParamOnStack();
71 virtual ManagedRegister CurrentParamRegister();
72 virtual FrameOffset CurrentParamStackOffset();
73
74 protected:
75 virtual size_t NumberOfOutgoingStackArgs();
76
77 private:
Ian Rogersbdb03912011-09-14 00:55:44 -070078 static std::vector<ManagedRegister> callee_save_regs_;
79
Ian Rogers2c8f6532011-09-02 17:16:34 -070080 DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention);
81};
82
83} // namespace x86
84} // namespace art
85
86#endif // ART_SRC_CALLING_CONVENTION_X86_H_