blob: e95a738f2fa684800b186c7ceff28e06eb6c2645 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_
18#define ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
Andreas Gampe542451c2016-07-26 09:02:02 -070020#include "base/enums.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070021#include "jni/quick/calling_convention.h"
22
23namespace art {
24namespace mips {
Ian Rogers790a6b72014-04-01 10:36:00 -070025
26constexpr size_t kFramePointerSize = 4;
Andreas Gampe542451c2016-07-26 09:02:02 -070027static_assert(kFramePointerSize == static_cast<size_t>(PointerSize::k32),
28 "Invalid frame pointer size");
Ian Rogers790a6b72014-04-01 10:36:00 -070029
Andreas Gampe25ff0042014-03-20 08:34:03 -070030class MipsManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
Brian Carlstrom7940e442013-07-12 13:46:57 -070031 public:
32 MipsManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
Andreas Gampe542451c2016-07-26 09:02:02 -070033 : ManagedRuntimeCallingConvention(is_static,
34 is_synchronized,
35 shorty,
36 PointerSize::k32) {}
Andreas Gampe25ff0042014-03-20 08:34:03 -070037 ~MipsManagedRuntimeCallingConvention() OVERRIDE {}
Brian Carlstrom7940e442013-07-12 13:46:57 -070038 // Calling convention
Andreas Gampe25ff0042014-03-20 08:34:03 -070039 ManagedRegister ReturnRegister() OVERRIDE;
40 ManagedRegister InterproceduralScratchRegister() OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070041 // Managed runtime calling convention
Andreas Gampe25ff0042014-03-20 08:34:03 -070042 ManagedRegister MethodRegister() OVERRIDE;
43 bool IsCurrentParamInRegister() OVERRIDE;
44 bool IsCurrentParamOnStack() OVERRIDE;
45 ManagedRegister CurrentParamRegister() OVERRIDE;
46 FrameOffset CurrentParamStackOffset() OVERRIDE;
Dmitry Petrochenkofca82202014-03-21 11:21:37 +070047 const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070048
49 private:
Dmitry Petrochenkofca82202014-03-21 11:21:37 +070050 ManagedRegisterEntrySpills entry_spills_;
Brian Carlstrom7940e442013-07-12 13:46:57 -070051
52 DISALLOW_COPY_AND_ASSIGN(MipsManagedRuntimeCallingConvention);
53};
54
Andreas Gampe25ff0042014-03-20 08:34:03 -070055class MipsJniCallingConvention FINAL : public JniCallingConvention {
Brian Carlstrom7940e442013-07-12 13:46:57 -070056 public:
Roland Levillain3887c462015-08-12 18:15:42 +010057 MipsJniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
Andreas Gampe25ff0042014-03-20 08:34:03 -070058 ~MipsJniCallingConvention() OVERRIDE {}
Brian Carlstrom7940e442013-07-12 13:46:57 -070059 // Calling convention
Andreas Gampe25ff0042014-03-20 08:34:03 -070060 ManagedRegister ReturnRegister() OVERRIDE;
61 ManagedRegister IntReturnRegister() OVERRIDE;
62 ManagedRegister InterproceduralScratchRegister() OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070063 // JNI calling convention
Andreas Gampe25ff0042014-03-20 08:34:03 -070064 void Next() OVERRIDE; // Override default behavior for AAPCS
65 size_t FrameSize() OVERRIDE;
66 size_t OutArgSize() OVERRIDE;
Vladimir Marko32248382016-05-19 10:37:24 +010067 ArrayRef<const ManagedRegister> CalleeSaveRegisters() const OVERRIDE;
Andreas Gampe25ff0042014-03-20 08:34:03 -070068 ManagedRegister ReturnScratchRegister() const OVERRIDE;
69 uint32_t CoreSpillMask() const OVERRIDE;
Vladimir Marko32248382016-05-19 10:37:24 +010070 uint32_t FpSpillMask() const OVERRIDE;
Andreas Gampe25ff0042014-03-20 08:34:03 -070071 bool IsCurrentParamInRegister() OVERRIDE;
72 bool IsCurrentParamOnStack() OVERRIDE;
73 ManagedRegister CurrentParamRegister() OVERRIDE;
74 FrameOffset CurrentParamStackOffset() OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070075
Andreas Gamped1104322014-05-01 14:38:56 -070076 // Mips does not need to extend small return types.
77 bool RequiresSmallResultTypeExtension() const OVERRIDE {
78 return false;
79 }
80
Brian Carlstrom7940e442013-07-12 13:46:57 -070081 protected:
Andreas Gampe25ff0042014-03-20 08:34:03 -070082 size_t NumberOfOutgoingStackArgs() OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070083
84 private:
Brian Carlstrom7940e442013-07-12 13:46:57 -070085 // Padding to ensure longs and doubles are not split in AAPCS
86 size_t padding_;
87
88 DISALLOW_COPY_AND_ASSIGN(MipsJniCallingConvention);
89};
Andreas Gampe25ff0042014-03-20 08:34:03 -070090
Brian Carlstrom7940e442013-07-12 13:46:57 -070091} // namespace mips
92} // namespace art
93
Brian Carlstromfc0e3212013-07-17 14:40:12 -070094#endif // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_