Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 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 | |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame^] | 20 | #include "base/bit_utils.h" |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 21 | #include "quick/quick_method_frame_info.h" |
| 22 | #include "registers_arm.h" |
| 23 | #include "runtime.h" // for Runtime::CalleeSaveType. |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 24 | |
| 25 | namespace art { |
| 26 | namespace arm { |
| 27 | |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 28 | static constexpr uint32_t kArmCalleeSaveAlwaysSpills = |
| 29 | (1 << art::arm::LR); |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 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); |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 37 | |
| 38 | static constexpr uint32_t kArmCalleeSaveFpAlwaysSpills = 0; |
| 39 | static constexpr uint32_t kArmCalleeSaveFpRefSpills = 0; |
| 40 | static constexpr uint32_t kArmCalleeSaveFpArgSpills = |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 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) | |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 44 | (1 << art::arm::S12) | (1 << art::arm::S13) | (1 << art::arm::S14) | (1 << art::arm::S15); |
| 45 | static constexpr uint32_t kArmCalleeSaveFpAllSpills = |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 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 | |
| 51 | constexpr uint32_t ArmCalleeSaveCoreSpills(Runtime::CalleeSaveType type) { |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 52 | return kArmCalleeSaveAlwaysSpills | kArmCalleeSaveRefSpills | |
| 53 | (type == Runtime::kRefsAndArgs ? kArmCalleeSaveArgSpills : 0) | |
| 54 | (type == Runtime::kSaveAll ? kArmCalleeSaveAllSpills : 0); |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | constexpr uint32_t ArmCalleeSaveFpSpills(Runtime::CalleeSaveType type) { |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 58 | return kArmCalleeSaveFpAlwaysSpills | kArmCalleeSaveFpRefSpills | |
| 59 | (type == Runtime::kRefsAndArgs ? kArmCalleeSaveFpArgSpills: 0) | |
| 60 | (type == Runtime::kSaveAll ? kArmCalleeSaveFpAllSpills : 0); |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | constexpr 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 | |
| 69 | constexpr QuickMethodFrameInfo ArmCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) { |
| 70 | return QuickMethodFrameInfo(ArmCalleeSaveFrameSize(type), |
| 71 | ArmCalleeSaveCoreSpills(type), |
| 72 | ArmCalleeSaveFpSpills(type)); |
| 73 | } |
| 74 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 75 | constexpr size_t ArmCalleeSaveFpr1Offset(Runtime::CalleeSaveType type) { |
| 76 | return ArmCalleeSaveFrameSize(type) - |
| 77 | (POPCOUNT(ArmCalleeSaveCoreSpills(type)) + |
| 78 | POPCOUNT(ArmCalleeSaveFpSpills(type))) * kArmPointerSize; |
| 79 | } |
| 80 | |
| 81 | constexpr size_t ArmCalleeSaveGpr1Offset(Runtime::CalleeSaveType type) { |
| 82 | return ArmCalleeSaveFrameSize(type) - |
| 83 | POPCOUNT(ArmCalleeSaveCoreSpills(type)) * kArmPointerSize; |
| 84 | } |
| 85 | |
| 86 | constexpr size_t ArmCalleeSaveLrOffset(Runtime::CalleeSaveType type) { |
| 87 | return ArmCalleeSaveFrameSize(type) - |
| 88 | POPCOUNT(ArmCalleeSaveCoreSpills(type) & (-(1 << LR))) * kArmPointerSize; |
| 89 | } |
| 90 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 91 | } // namespace arm |
| 92 | } // namespace art |
| 93 | |
| 94 | #endif // ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ |