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_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 18 #define ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 19 20 #include "base/bit_utils.h" 21 #include "quick/quick_method_frame_info.h" 22 #include "registers_arm.h" 23 #include "runtime.h" // for Runtime::CalleeSaveType. 24 25 namespace art { 26 namespace arm { 27 28 static constexpr uint32_t kArmCalleeSaveAlwaysSpills = 29 (1 << art::arm::LR); 30 static constexpr uint32_t kArmCalleeSaveRefSpills = 31 (1 << art::arm::R5) | (1 << art::arm::R6) | (1 << art::arm::R7) | (1 << art::arm::R8) | 32 (1 << art::arm::R10) | (1 << art::arm::R11); 33 static constexpr uint32_t kArmCalleeSaveArgSpills = 34 (1 << art::arm::R1) | (1 << art::arm::R2) | (1 << art::arm::R3); 35 static constexpr uint32_t kArmCalleeSaveAllSpills = 36 (1 << art::arm::R4) | (1 << art::arm::R9); 37 38 static constexpr uint32_t kArmCalleeSaveFpAlwaysSpills = 0; 39 static constexpr uint32_t kArmCalleeSaveFpRefSpills = 0; 40 static constexpr uint32_t kArmCalleeSaveFpArgSpills = 41 (1 << art::arm::S0) | (1 << art::arm::S1) | (1 << art::arm::S2) | (1 << art::arm::S3) | 42 (1 << art::arm::S4) | (1 << art::arm::S5) | (1 << art::arm::S6) | (1 << art::arm::S7) | 43 (1 << art::arm::S8) | (1 << art::arm::S9) | (1 << art::arm::S10) | (1 << art::arm::S11) | 44 (1 << art::arm::S12) | (1 << art::arm::S13) | (1 << art::arm::S14) | (1 << art::arm::S15); 45 static constexpr uint32_t kArmCalleeSaveFpAllSpills = 46 (1 << art::arm::S16) | (1 << art::arm::S17) | (1 << art::arm::S18) | (1 << art::arm::S19) | 47 (1 << art::arm::S20) | (1 << art::arm::S21) | (1 << art::arm::S22) | (1 << art::arm::S23) | 48 (1 << art::arm::S24) | (1 << art::arm::S25) | (1 << art::arm::S26) | (1 << art::arm::S27) | 49 (1 << art::arm::S28) | (1 << art::arm::S29) | (1 << art::arm::S30) | (1 << art::arm::S31); 50 ArmCalleeSaveCoreSpills(Runtime::CalleeSaveType type)51constexpr uint32_t ArmCalleeSaveCoreSpills(Runtime::CalleeSaveType type) { 52 return kArmCalleeSaveAlwaysSpills | kArmCalleeSaveRefSpills | 53 (type == Runtime::kRefsAndArgs ? kArmCalleeSaveArgSpills : 0) | 54 (type == Runtime::kSaveAll ? kArmCalleeSaveAllSpills : 0); 55 } 56 ArmCalleeSaveFpSpills(Runtime::CalleeSaveType type)57constexpr uint32_t ArmCalleeSaveFpSpills(Runtime::CalleeSaveType type) { 58 return kArmCalleeSaveFpAlwaysSpills | kArmCalleeSaveFpRefSpills | 59 (type == Runtime::kRefsAndArgs ? kArmCalleeSaveFpArgSpills: 0) | 60 (type == Runtime::kSaveAll ? kArmCalleeSaveFpAllSpills : 0); 61 } 62 ArmCalleeSaveFrameSize(Runtime::CalleeSaveType type)63constexpr uint32_t ArmCalleeSaveFrameSize(Runtime::CalleeSaveType type) { 64 return RoundUp((POPCOUNT(ArmCalleeSaveCoreSpills(type)) /* gprs */ + 65 POPCOUNT(ArmCalleeSaveFpSpills(type)) /* fprs */ + 66 1 /* Method* */) * kArmPointerSize, kStackAlignment); 67 } 68 ArmCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type)69constexpr QuickMethodFrameInfo ArmCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) { 70 return QuickMethodFrameInfo(ArmCalleeSaveFrameSize(type), 71 ArmCalleeSaveCoreSpills(type), 72 ArmCalleeSaveFpSpills(type)); 73 } 74 ArmCalleeSaveFpr1Offset(Runtime::CalleeSaveType type)75constexpr size_t ArmCalleeSaveFpr1Offset(Runtime::CalleeSaveType type) { 76 return ArmCalleeSaveFrameSize(type) - 77 (POPCOUNT(ArmCalleeSaveCoreSpills(type)) + 78 POPCOUNT(ArmCalleeSaveFpSpills(type))) * kArmPointerSize; 79 } 80 ArmCalleeSaveGpr1Offset(Runtime::CalleeSaveType type)81constexpr size_t ArmCalleeSaveGpr1Offset(Runtime::CalleeSaveType type) { 82 return ArmCalleeSaveFrameSize(type) - 83 POPCOUNT(ArmCalleeSaveCoreSpills(type)) * kArmPointerSize; 84 } 85 ArmCalleeSaveLrOffset(Runtime::CalleeSaveType type)86constexpr size_t ArmCalleeSaveLrOffset(Runtime::CalleeSaveType type) { 87 return ArmCalleeSaveFrameSize(type) - 88 POPCOUNT(ArmCalleeSaveCoreSpills(type) & (-(1 << LR))) * kArmPointerSize; 89 } 90 91 } // namespace arm 92 } // namespace art 93 94 #endif // ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 95