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_ARM_H_ |
| 4 | #define ART_SRC_CALLING_CONVENTION_ARM_H_ |
| 5 | |
| 6 | #include "calling_convention.h" |
| 7 | |
| 8 | namespace art { |
| 9 | namespace arm { |
| 10 | |
| 11 | class ArmManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention { |
| 12 | public: |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 13 | explicit ArmManagedRuntimeCallingConvention(const Method* method) : |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 14 | ManagedRuntimeCallingConvention(method) {} |
| 15 | virtual ~ArmManagedRuntimeCallingConvention() {} |
| 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(ArmManagedRuntimeCallingConvention); |
| 28 | }; |
| 29 | |
| 30 | class ArmJniCallingConvention : public JniCallingConvention { |
| 31 | public: |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 32 | explicit ArmJniCallingConvention(const Method* method); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 33 | virtual ~ArmJniCallingConvention() {} |
| 34 | // Calling convention |
| 35 | virtual ManagedRegister ReturnRegister(); |
| 36 | virtual ManagedRegister InterproceduralScratchRegister(); |
| 37 | // JNI calling convention |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 38 | virtual void Next(); // Override default behavior for AAPCS |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 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 | return callee_save_regs_; |
| 44 | } |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 45 | virtual ManagedRegister ReturnScratchRegister() const; |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 46 | virtual uint32_t CoreSpillMask() const; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 47 | virtual uint32_t FpSpillMask() const { |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 48 | return 0; // Floats aren't spilled in JNI down call |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 49 | } |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 50 | virtual bool IsMethodRegisterClobberedPreCall(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 51 | virtual bool IsCurrentParamInRegister(); |
| 52 | virtual bool IsCurrentParamOnStack(); |
| 53 | virtual ManagedRegister CurrentParamRegister(); |
| 54 | virtual FrameOffset CurrentParamStackOffset(); |
| 55 | |
| 56 | protected: |
| 57 | virtual size_t NumberOfOutgoingStackArgs(); |
| 58 | |
| 59 | private: |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 60 | // TODO: these values aren't unique and can be shared amongst instances |
| 61 | std::vector<ManagedRegister> callee_save_regs_; |
| 62 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 63 | // Padding to ensure longs and doubles are not split in AAPCS |
| 64 | size_t padding_; |
| 65 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 66 | DISALLOW_COPY_AND_ASSIGN(ArmJniCallingConvention); |
| 67 | }; |
| 68 | |
| 69 | } // namespace arm |
| 70 | } // namespace art |
| 71 | |
| 72 | #endif // ART_SRC_CALLING_CONVENTION_ARM_H_ |