1 /* 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 20 #include "arch/instruction_set.h" 21 #include "base/bit_utils.h" 22 #include "base/callee_save_type.h" 23 #include "base/enums.h" 24 #include "quick/quick_method_frame_info.h" 25 #include "registers_mips64.h" 26 27 namespace art { 28 namespace mips64 { 29 30 static constexpr uint32_t kMips64CalleeSaveAlwaysSpills = 31 (1 << art::mips64::RA); 32 static constexpr uint32_t kMips64CalleeSaveRefSpills = 33 (1 << art::mips64::S2) | (1 << art::mips64::S3) | (1 << art::mips64::S4) | 34 (1 << art::mips64::S5) | (1 << art::mips64::S6) | (1 << art::mips64::S7) | 35 (1 << art::mips64::GP) | (1 << art::mips64::S8); 36 static constexpr uint32_t kMips64CalleeSaveArgSpills = 37 (1 << art::mips64::A1) | (1 << art::mips64::A2) | (1 << art::mips64::A3) | 38 (1 << art::mips64::A4) | (1 << art::mips64::A5) | (1 << art::mips64::A6) | 39 (1 << art::mips64::A7); 40 static constexpr uint32_t kMips64CalleeSaveAllSpills = 41 (1 << art::mips64::S0) | (1 << art::mips64::S1); 42 static constexpr uint32_t kMips64CalleeSaveEverythingSpills = 43 (1 << art::mips64::AT) | (1 << art::mips64::V0) | (1 << art::mips64::V1) | 44 (1 << art::mips64::A0) | (1 << art::mips64::A1) | (1 << art::mips64::A2) | 45 (1 << art::mips64::A3) | (1 << art::mips64::A4) | (1 << art::mips64::A5) | 46 (1 << art::mips64::A6) | (1 << art::mips64::A7) | (1 << art::mips64::T0) | 47 (1 << art::mips64::T1) | (1 << art::mips64::T2) | (1 << art::mips64::T3) | 48 (1 << art::mips64::S0) | (1 << art::mips64::S1) | (1 << art::mips64::T8) | 49 (1 << art::mips64::T9); 50 51 static constexpr uint32_t kMips64CalleeSaveFpRefSpills = 0; 52 static constexpr uint32_t kMips64CalleeSaveFpArgSpills = 53 (1 << art::mips64::F12) | (1 << art::mips64::F13) | (1 << art::mips64::F14) | 54 (1 << art::mips64::F15) | (1 << art::mips64::F16) | (1 << art::mips64::F17) | 55 (1 << art::mips64::F18) | (1 << art::mips64::F19); 56 // F12 should not be necessary to spill, as A0 is always in use. 57 static constexpr uint32_t kMips64CalleeSaveFpAllSpills = 58 (1 << art::mips64::F24) | (1 << art::mips64::F25) | (1 << art::mips64::F26) | 59 (1 << art::mips64::F27) | (1 << art::mips64::F28) | (1 << art::mips64::F29) | 60 (1 << art::mips64::F30) | (1 << art::mips64::F31); 61 static constexpr uint32_t kMips64CalleeSaveFpEverythingSpills = 62 (1 << art::mips64::F0) | (1 << art::mips64::F1) | (1 << art::mips64::F2) | 63 (1 << art::mips64::F3) | (1 << art::mips64::F4) | (1 << art::mips64::F5) | 64 (1 << art::mips64::F6) | (1 << art::mips64::F7) | (1 << art::mips64::F8) | 65 (1 << art::mips64::F9) | (1 << art::mips64::F10) | (1 << art::mips64::F11) | 66 (1 << art::mips64::F12) | (1 << art::mips64::F13) | (1 << art::mips64::F14) | 67 (1 << art::mips64::F15) | (1 << art::mips64::F16) | (1 << art::mips64::F17) | 68 (1 << art::mips64::F18) | (1 << art::mips64::F19) | (1 << art::mips64::F20) | 69 (1 << art::mips64::F21) | (1 << art::mips64::F22) | (1 << art::mips64::F23) | 70 (1 << art::mips64::F24) | (1 << art::mips64::F25) | (1 << art::mips64::F26) | 71 (1 << art::mips64::F27) | (1 << art::mips64::F28) | (1 << art::mips64::F29) | 72 (1 << art::mips64::F30) | (1 << art::mips64::F31); 73 Mips64CalleeSaveCoreSpills(CalleeSaveType type)74constexpr uint32_t Mips64CalleeSaveCoreSpills(CalleeSaveType type) { 75 type = GetCanonicalCalleeSaveType(type); 76 return kMips64CalleeSaveAlwaysSpills | kMips64CalleeSaveRefSpills | 77 (type == CalleeSaveType::kSaveRefsAndArgs ? kMips64CalleeSaveArgSpills : 0) | 78 (type == CalleeSaveType::kSaveAllCalleeSaves ? kMips64CalleeSaveAllSpills : 0) | 79 (type == CalleeSaveType::kSaveEverything ? kMips64CalleeSaveEverythingSpills : 0); 80 } 81 Mips64CalleeSaveFpSpills(CalleeSaveType type)82constexpr uint32_t Mips64CalleeSaveFpSpills(CalleeSaveType type) { 83 type = GetCanonicalCalleeSaveType(type); 84 return kMips64CalleeSaveFpRefSpills | 85 (type == CalleeSaveType::kSaveRefsAndArgs ? kMips64CalleeSaveFpArgSpills : 0) | 86 (type == CalleeSaveType::kSaveAllCalleeSaves ? kMips64CalleeSaveFpAllSpills : 0) | 87 (type == CalleeSaveType::kSaveEverything ? kMips64CalleeSaveFpEverythingSpills : 0); 88 } 89 Mips64CalleeSaveFrameSize(CalleeSaveType type)90constexpr uint32_t Mips64CalleeSaveFrameSize(CalleeSaveType type) { 91 type = GetCanonicalCalleeSaveType(type); 92 return RoundUp((POPCOUNT(Mips64CalleeSaveCoreSpills(type)) /* gprs */ + 93 POPCOUNT(Mips64CalleeSaveFpSpills(type)) /* fprs */ + 94 + 1 /* Method* */) * static_cast<size_t>(kMips64PointerSize), kStackAlignment); 95 } 96 Mips64CalleeSaveMethodFrameInfo(CalleeSaveType type)97constexpr QuickMethodFrameInfo Mips64CalleeSaveMethodFrameInfo(CalleeSaveType type) { 98 type = GetCanonicalCalleeSaveType(type); 99 return QuickMethodFrameInfo(Mips64CalleeSaveFrameSize(type), 100 Mips64CalleeSaveCoreSpills(type), 101 Mips64CalleeSaveFpSpills(type)); 102 } 103 104 } // namespace mips64 105 } // namespace art 106 107 #endif // ART_RUNTIME_ARCH_MIPS64_QUICK_METHOD_FRAME_INFO_MIPS64_H_ 108