Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_CALLING_CONVENTION_X86_H_ |
| 4 | #define ART_SRC_CALLING_CONVENTION_X86_H_ |
| 5 | |
| 6 | #include "calling_convention.h" |
| 7 | |
| 8 | namespace art { |
| 9 | namespace x86 { |
| 10 | |
| 11 | class X86ManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention { |
| 12 | public: |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 13 | explicit X86ManagedRuntimeCallingConvention(const Method* method) : |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 14 | ManagedRuntimeCallingConvention(method) {} |
| 15 | virtual ~X86ManagedRuntimeCallingConvention() {} |
| 16 | // Calling convention |
| 17 | virtual ManagedRegister ReturnRegister(); |
| 18 | virtual ManagedRegister InterproceduralScratchRegister(); |
| 19 | // Managed runtime calling convention |
| 20 | virtual ManagedRegister MethodRegister(); |
| 21 | virtual bool IsCurrentParamInRegister(); |
| 22 | virtual bool IsCurrentParamOnStack(); |
| 23 | virtual ManagedRegister CurrentParamRegister(); |
| 24 | virtual FrameOffset CurrentParamStackOffset(); |
| 25 | |
| 26 | private: |
| 27 | DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); |
| 28 | }; |
| 29 | |
| 30 | class X86JniCallingConvention : public JniCallingConvention { |
| 31 | public: |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 32 | explicit X86JniCallingConvention(const Method* method) : |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 33 | JniCallingConvention(method) {} |
| 34 | virtual ~X86JniCallingConvention() {} |
| 35 | // Calling convention |
| 36 | virtual ManagedRegister ReturnRegister(); |
| 37 | virtual ManagedRegister InterproceduralScratchRegister(); |
| 38 | // JNI calling convention |
| 39 | virtual size_t FrameSize(); |
| 40 | virtual size_t ReturnPcOffset(); |
| 41 | virtual size_t OutArgSize(); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 42 | virtual const std::vector<ManagedRegister>& CalleeSaveRegisters() const { |
| 43 | DCHECK(callee_save_regs_.empty()); |
| 44 | return callee_save_regs_; |
| 45 | } |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 46 | virtual ManagedRegister ReturnScratchRegister() const; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 47 | virtual uint32_t CoreSpillMask() const { |
| 48 | return 0; |
| 49 | } |
| 50 | virtual uint32_t FpSpillMask() const { |
| 51 | return 0; |
| 52 | } |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 53 | virtual bool IsMethodRegisterClobberedPreCall(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 54 | virtual bool IsCurrentParamInRegister(); |
| 55 | virtual bool IsCurrentParamOnStack(); |
| 56 | virtual ManagedRegister CurrentParamRegister(); |
| 57 | virtual FrameOffset CurrentParamStackOffset(); |
| 58 | |
| 59 | protected: |
| 60 | virtual size_t NumberOfOutgoingStackArgs(); |
| 61 | |
| 62 | private: |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 63 | static std::vector<ManagedRegister> callee_save_regs_; |
| 64 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 65 | DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); |
| 66 | }; |
| 67 | |
| 68 | } // namespace x86 |
| 69 | } // namespace art |
| 70 | |
| 71 | #endif // ART_SRC_CALLING_CONVENTION_X86_H_ |