Home | History | Annotate | Download | only in arm
      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_ARM_CALLING_CONVENTION_ARM_H_
     18 #define ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
     19 
     20 #include "jni/quick/calling_convention.h"
     21 
     22 namespace art {
     23 namespace arm {
     24 
     25 constexpr size_t kFramePointerSize = 4;
     26 
     27 class ArmManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
     28  public:
     29   ArmManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
     30       : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {}
     31   ~ArmManagedRuntimeCallingConvention() 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(ArmManagedRuntimeCallingConvention);
     47 };
     48 
     49 class ArmJniCallingConvention FINAL : public JniCallingConvention {
     50  public:
     51   ArmJniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
     52   ~ArmJniCallingConvention() 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   bool IsCurrentParamInRegister() OVERRIDE;
     68   bool IsCurrentParamOnStack() OVERRIDE;
     69   ManagedRegister CurrentParamRegister() OVERRIDE;
     70   FrameOffset CurrentParamStackOffset() OVERRIDE;
     71 
     72   // AAPCS mandates return values are extended.
     73   bool RequiresSmallResultTypeExtension() const OVERRIDE {
     74     return false;
     75   }
     76 
     77  protected:
     78   size_t NumberOfOutgoingStackArgs() OVERRIDE;
     79 
     80  private:
     81   // TODO: these values aren't unique and can be shared amongst instances
     82   std::vector<ManagedRegister> callee_save_regs_;
     83 
     84   // Padding to ensure longs and doubles are not split in AAPCS
     85   size_t padding_;
     86 
     87   DISALLOW_COPY_AND_ASSIGN(ArmJniCallingConvention);
     88 };
     89 
     90 }  // namespace arm
     91 }  // namespace art
     92 
     93 #endif  // ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
     94