Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 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 | */ |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_CALLING_CONVENTION_X86_H_ |
| 18 | #define ART_SRC_CALLING_CONVENTION_X86_H_ |
| 19 | |
| 20 | #include "calling_convention.h" |
| 21 | |
| 22 | namespace art { |
| 23 | namespace x86 { |
| 24 | |
| 25 | class X86ManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention { |
| 26 | public: |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 27 | explicit X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, |
| 28 | const char* shorty) : |
| 29 | ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty) {} |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 30 | 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 Rogers | b5d09b2 | 2012-03-06 22:14:17 -0800 | [diff] [blame] | 40 | virtual const std::vector<ManagedRegister>& EntrySpills(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 41 | private: |
Ian Rogers | b5d09b2 | 2012-03-06 22:14:17 -0800 | [diff] [blame] | 42 | std::vector<ManagedRegister> entry_spills_; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 43 | DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); |
| 44 | }; |
| 45 | |
| 46 | class X86JniCallingConvention : public JniCallingConvention { |
| 47 | public: |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 48 | X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty) : |
| 49 | JniCallingConvention(is_static, is_synchronized, shorty) {} |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 50 | virtual ~X86JniCallingConvention() {} |
| 51 | // Calling convention |
| 52 | virtual ManagedRegister ReturnRegister(); |
| 53 | virtual ManagedRegister InterproceduralScratchRegister(); |
| 54 | // JNI calling convention |
| 55 | virtual size_t FrameSize(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 56 | virtual size_t OutArgSize(); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 57 | virtual const std::vector<ManagedRegister>& CalleeSaveRegisters() const { |
| 58 | DCHECK(callee_save_regs_.empty()); |
| 59 | return callee_save_regs_; |
| 60 | } |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 61 | virtual ManagedRegister ReturnScratchRegister() const; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 62 | virtual uint32_t CoreSpillMask() const { |
| 63 | return 0; |
| 64 | } |
| 65 | virtual uint32_t FpSpillMask() const { |
| 66 | return 0; |
| 67 | } |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 68 | virtual bool IsMethodRegisterClobberedPreCall(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 69 | 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 Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 78 | static std::vector<ManagedRegister> callee_save_regs_; |
| 79 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 80 | DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); |
| 81 | }; |
| 82 | |
| 83 | } // namespace x86 |
| 84 | } // namespace art |
| 85 | |
| 86 | #endif // ART_SRC_CALLING_CONVENTION_X86_H_ |