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