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 */ 16 17 #ifndef ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ 18 #define ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ 19 20 #include "jni/quick/calling_convention.h" 21 22 namespace art { 23 namespace mips { 24 class MipsManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention { 25 public: 26 MipsManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty) 27 : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty) {} 28 virtual ~MipsManagedRuntimeCallingConvention() {} 29 // Calling convention 30 virtual ManagedRegister ReturnRegister(); 31 virtual ManagedRegister InterproceduralScratchRegister(); 32 // Managed runtime calling convention 33 virtual ManagedRegister MethodRegister(); 34 virtual bool IsCurrentParamInRegister(); 35 virtual bool IsCurrentParamOnStack(); 36 virtual ManagedRegister CurrentParamRegister(); 37 virtual FrameOffset CurrentParamStackOffset(); 38 virtual const std::vector<ManagedRegister>& EntrySpills(); 39 40 private: 41 std::vector<ManagedRegister> entry_spills_; 42 43 DISALLOW_COPY_AND_ASSIGN(MipsManagedRuntimeCallingConvention); 44 }; 45 46 class MipsJniCallingConvention : public JniCallingConvention { 47 public: 48 explicit MipsJniCallingConvention(bool is_static, bool is_synchronized, const char* shorty); 49 virtual ~MipsJniCallingConvention() {} 50 // Calling convention 51 virtual ManagedRegister ReturnRegister(); 52 virtual ManagedRegister IntReturnRegister(); 53 virtual ManagedRegister InterproceduralScratchRegister(); 54 // JNI calling convention 55 virtual void Next(); // Override default behavior for AAPCS 56 virtual size_t FrameSize(); 57 virtual size_t OutArgSize(); 58 virtual const std::vector<ManagedRegister>& CalleeSaveRegisters() const { 59 return callee_save_regs_; 60 } 61 virtual ManagedRegister ReturnScratchRegister() const; 62 virtual uint32_t CoreSpillMask() const; 63 virtual uint32_t FpSpillMask() const { 64 return 0; // Floats aren't spilled in JNI down call 65 } 66 virtual bool IsCurrentParamInRegister(); 67 virtual bool IsCurrentParamOnStack(); 68 virtual ManagedRegister CurrentParamRegister(); 69 virtual FrameOffset CurrentParamStackOffset(); 70 71 protected: 72 virtual size_t NumberOfOutgoingStackArgs(); 73 74 private: 75 // TODO: these values aren't unique and can be shared amongst instances 76 std::vector<ManagedRegister> callee_save_regs_; 77 78 // Padding to ensure longs and doubles are not split in AAPCS 79 size_t padding_; 80 81 DISALLOW_COPY_AND_ASSIGN(MipsJniCallingConvention); 82 }; 83 } // namespace mips 84 } // namespace art 85 86 #endif // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ 87