calling_convention_arm64.h revision 25ff0048a70c79272884d5d0f8e9b9861a451afe
1b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith/*
2b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * Copyright (C) 2014 The Android Open Source Project
3b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith *
4b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * Licensed under the Apache License, Version 2.0 (the "License");
5b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * you may not use this file except in compliance with the License.
6b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * You may obtain a copy of the License at
7b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith *
8b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith *      http://www.apache.org/licenses/LICENSE-2.0
9b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith *
10b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * Unless required by applicable law or agreed to in writing, software
11b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * distributed under the License is distributed on an "AS IS" BASIS,
12b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * See the License for the specific language governing permissions and
14b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith * limitations under the License.
15b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith */
16b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
17b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith#ifndef ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_
18b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith#define ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_
19b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
20b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith#include "jni/quick/calling_convention.h"
21b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
22b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteithnamespace art {
23b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteithnamespace arm64 {
24b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
2525ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampeclass Arm64ManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
26b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith public:
27b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  Arm64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
28b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith      : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty) {}
2925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ~Arm64ManagedRuntimeCallingConvention() OVERRIDE {}
30b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // Calling convention
3125ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister ReturnRegister() OVERRIDE;
3225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister InterproceduralScratchRegister() OVERRIDE;
33b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // Managed runtime calling convention
3425ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister MethodRegister() OVERRIDE;
3525ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  bool IsCurrentParamInRegister() OVERRIDE;
3625ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  bool IsCurrentParamOnStack() OVERRIDE;
3725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister CurrentParamRegister() OVERRIDE;
3825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  FrameOffset CurrentParamStackOffset() OVERRIDE;
3925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  const std::vector<ManagedRegister>& EntrySpills() OVERRIDE;
40b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
41b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith private:
42b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  std::vector<ManagedRegister> entry_spills_;
43b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
44b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  DISALLOW_COPY_AND_ASSIGN(Arm64ManagedRuntimeCallingConvention);
45b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith};
46b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
4725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampeclass Arm64JniCallingConvention FINAL : public JniCallingConvention {
48b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith public:
49b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  explicit Arm64JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
5025ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ~Arm64JniCallingConvention() OVERRIDE {}
51b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // Calling convention
5225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister ReturnRegister() OVERRIDE;
5325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister IntReturnRegister() OVERRIDE;
5425ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister InterproceduralScratchRegister() OVERRIDE;
55b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // JNI calling convention
5625ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  void Next() OVERRIDE;  // Override default behavior for AAPCS
5725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  size_t FrameSize() OVERRIDE;
5825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  size_t OutArgSize() OVERRIDE;
5925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE {
60b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith    return callee_save_regs_;
61b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  }
6225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister ReturnScratchRegister() const OVERRIDE;
6325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  uint32_t CoreSpillMask() const OVERRIDE;
6425ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  uint32_t FpSpillMask() const OVERRIDE {
65b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith    return 0;  // Floats aren't spilled in JNI down call
66b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  }
6725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  bool IsCurrentParamInRegister() OVERRIDE;
6825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  bool IsCurrentParamOnStack() OVERRIDE;
6925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  ManagedRegister CurrentParamRegister() OVERRIDE;
7025ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  FrameOffset CurrentParamStackOffset() OVERRIDE;
71b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
72b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith protected:
7325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe  size_t NumberOfOutgoingStackArgs() OVERRIDE;
74b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
75b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith private:
76b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // TODO: these values aren't unique and can be shared amongst instances
77b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  std::vector<ManagedRegister> callee_save_regs_;
78b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
79b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  // Padding to ensure longs and doubles are not split in AAPCS
80b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  size_t padding_;
81b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
82b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith  DISALLOW_COPY_AND_ASSIGN(Arm64JniCallingConvention);
83b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith};
84b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
85b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith}  // namespace arm64
86b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith}  // namespace art
87b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith
88b95a5345ae4217b70ca36f0cced92f68dda7caf5Stuart Monteith#endif  // ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_
89