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