blob: f967be0e4c600ec41ef6b0064897b75c87be0cdd [file] [log] [blame]
Andreas Gampe57b34292015-01-14 15:45:59 -08001/*
2 * Copyright (C) 2014 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_RUNTIME_ARCH_MIPS64_QUICK_METHOD_FRAME_INFO_MIPS64_H_
18#define ART_RUNTIME_ARCH_MIPS64_QUICK_METHOD_FRAME_INFO_MIPS64_H_
19
Vladimir Marko80afd022015-05-19 18:08:00 +010020#include "base/bit_utils.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080021#include "quick/quick_method_frame_info.h"
22#include "registers_mips64.h"
23#include "runtime.h" // for Runtime::CalleeSaveType.
24
25namespace art {
26namespace mips64 {
27
28static constexpr uint32_t kMips64CalleeSaveRefSpills =
29 (1 << art::mips64::S2) | (1 << art::mips64::S3) | (1 << art::mips64::S4) |
30 (1 << art::mips64::S5) | (1 << art::mips64::S6) | (1 << art::mips64::S7) |
31 (1 << art::mips64::GP) | (1 << art::mips64::S8);
32static constexpr uint32_t kMips64CalleeSaveArgSpills =
33 (1 << art::mips64::A1) | (1 << art::mips64::A2) | (1 << art::mips64::A3) |
34 (1 << art::mips64::A4) | (1 << art::mips64::A5) | (1 << art::mips64::A6) |
35 (1 << art::mips64::A7);
36static constexpr uint32_t kMips64CalleeSaveAllSpills =
37 (1 << art::mips64::S0) | (1 << art::mips64::S1);
38
39static constexpr uint32_t kMips64CalleeSaveFpRefSpills = 0;
40static constexpr uint32_t kMips64CalleeSaveFpArgSpills =
41 (1 << art::mips64::F12) | (1 << art::mips64::F13) | (1 << art::mips64::F14) |
42 (1 << art::mips64::F15) | (1 << art::mips64::F16) | (1 << art::mips64::F17) |
43 (1 << art::mips64::F18) | (1 << art::mips64::F19);
Andreas Gampe1a5c4062015-01-15 12:10:47 -080044// F12 should not be necessary to spill, as A0 is always in use.
Andreas Gampe57b34292015-01-14 15:45:59 -080045static constexpr uint32_t kMips64CalleeSaveFpAllSpills =
46 (1 << art::mips64::F24) | (1 << art::mips64::F25) | (1 << art::mips64::F26) |
47 (1 << art::mips64::F27) | (1 << art::mips64::F28) | (1 << art::mips64::F29) |
48 (1 << art::mips64::F30) | (1 << art::mips64::F31);
49
50constexpr uint32_t Mips64CalleeSaveCoreSpills(Runtime::CalleeSaveType type) {
51 return kMips64CalleeSaveRefSpills |
52 (type == Runtime::kRefsAndArgs ? kMips64CalleeSaveArgSpills : 0) |
53 (type == Runtime::kSaveAll ? kMips64CalleeSaveAllSpills : 0) | (1 << art::mips64::RA);
54}
55
56constexpr uint32_t Mips64CalleeSaveFpSpills(Runtime::CalleeSaveType type) {
57 return kMips64CalleeSaveFpRefSpills |
58 (type == Runtime::kRefsAndArgs ? kMips64CalleeSaveFpArgSpills: 0) |
59 (type == Runtime::kSaveAll ? kMips64CalleeSaveFpAllSpills : 0);
60}
61
62constexpr uint32_t Mips64CalleeSaveFrameSize(Runtime::CalleeSaveType type) {
63 return RoundUp((POPCOUNT(Mips64CalleeSaveCoreSpills(type)) /* gprs */ +
64 POPCOUNT(Mips64CalleeSaveFpSpills(type)) /* fprs */ +
65 + 1 /* Method* */) * kMips64PointerSize, kStackAlignment);
66}
67
68constexpr QuickMethodFrameInfo Mips64CalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) {
69 return QuickMethodFrameInfo(Mips64CalleeSaveFrameSize(type),
70 Mips64CalleeSaveCoreSpills(type),
71 Mips64CalleeSaveFpSpills(type));
72}
73
74} // namespace mips64
75} // namespace art
76
77#endif // ART_RUNTIME_ARCH_MIPS64_QUICK_METHOD_FRAME_INFO_MIPS64_H_