Home | History | Annotate | Download | only in mips
      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 
     25 constexpr size_t kFramePointerSize = 4;
     26 
     27 class MipsManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
     28  public:
     29   MipsManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
     30       : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {}
     31   ~MipsManagedRuntimeCallingConvention() OVERRIDE {}
     32   // Calling convention
     33   ManagedRegister ReturnRegister() OVERRIDE;
     34   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
     35   // Managed runtime calling convention
     36   ManagedRegister MethodRegister() OVERRIDE;
     37   bool IsCurrentParamInRegister() OVERRIDE;
     38   bool IsCurrentParamOnStack() OVERRIDE;
     39   ManagedRegister CurrentParamRegister() OVERRIDE;
     40   FrameOffset CurrentParamStackOffset() OVERRIDE;
     41   const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE;
     42 
     43  private:
     44   ManagedRegisterEntrySpills entry_spills_;
     45 
     46   DISALLOW_COPY_AND_ASSIGN(MipsManagedRuntimeCallingConvention);
     47 };
     48 
     49 class MipsJniCallingConvention FINAL : public JniCallingConvention {
     50  public:
     51   explicit MipsJniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
     52   ~MipsJniCallingConvention() OVERRIDE {}
     53   // Calling convention
     54   ManagedRegister ReturnRegister() OVERRIDE;
     55   ManagedRegister IntReturnRegister() OVERRIDE;
     56   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
     57   // JNI calling convention
     58   void Next() OVERRIDE;  // Override default behavior for AAPCS
     59   size_t FrameSize() OVERRIDE;
     60   size_t OutArgSize() OVERRIDE;
     61   const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE {
     62     return callee_save_regs_;
     63   }
     64   ManagedRegister ReturnScratchRegister() const OVERRIDE;
     65   uint32_t CoreSpillMask() const OVERRIDE;
     66   uint32_t FpSpillMask() const OVERRIDE {
     67     return 0;  // Floats aren't spilled in JNI down call
     68   }
     69   bool IsCurrentParamInRegister() OVERRIDE;
     70   bool IsCurrentParamOnStack() OVERRIDE;
     71   ManagedRegister CurrentParamRegister() OVERRIDE;
     72   FrameOffset CurrentParamStackOffset() OVERRIDE;
     73 
     74   // Mips does not need to extend small return types.
     75   bool RequiresSmallResultTypeExtension() const OVERRIDE {
     76     return false;
     77   }
     78 
     79  protected:
     80   size_t NumberOfOutgoingStackArgs() OVERRIDE;
     81 
     82  private:
     83   // TODO: these values aren't unique and can be shared amongst instances
     84   std::vector<ManagedRegister> callee_save_regs_;
     85 
     86   // Padding to ensure longs and doubles are not split in AAPCS
     87   size_t padding_;
     88 
     89   DISALLOW_COPY_AND_ASSIGN(MipsJniCallingConvention);
     90 };
     91 
     92 }  // namespace mips
     93 }  // namespace art
     94 
     95 #endif  // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_
     96