Home | History | Annotate | Download | only in mips
      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_MIPS_QUICK_METHOD_FRAME_INFO_MIPS_H_
     18 #define ART_RUNTIME_ARCH_MIPS_QUICK_METHOD_FRAME_INFO_MIPS_H_
     19 
     20 #include "base/bit_utils.h"
     21 #include "quick/quick_method_frame_info.h"
     22 #include "registers_mips.h"
     23 #include "runtime.h"  // for Runtime::CalleeSaveType.
     24 
     25 namespace art {
     26 namespace mips {
     27 
     28 static constexpr uint32_t kMipsCalleeSaveAlwaysSpills =
     29     (1u << art::mips::RA);
     30 static constexpr uint32_t kMipsCalleeSaveRefSpills =
     31     (1 << art::mips::S2) | (1 << art::mips::S3) | (1 << art::mips::S4) | (1 << art::mips::S5) |
     32     (1 << art::mips::S6) | (1 << art::mips::S7) | (1 << art::mips::GP) | (1 << art::mips::FP);
     33 static constexpr uint32_t kMipsCalleeSaveArgSpills =
     34     (1 << art::mips::A1) | (1 << art::mips::A2) | (1 << art::mips::A3) | (1 << art::mips::T0) |
     35     (1 << art::mips::T1);
     36 static constexpr uint32_t kMipsCalleeSaveAllSpills =
     37     (1 << art::mips::S0) | (1 << art::mips::S1);
     38 static constexpr uint32_t kMipsCalleeSaveEverythingSpills =
     39     (1 << art::mips::AT) | (1 << art::mips::V0) | (1 << art::mips::V1) |
     40     (1 << art::mips::A0) | (1 << art::mips::A1) | (1 << art::mips::A2) | (1 << art::mips::A3) |
     41     (1 << art::mips::T0) | (1 << art::mips::T1) | (1 << art::mips::T2) | (1 << art::mips::T3) |
     42     (1 << art::mips::T4) | (1 << art::mips::T5) | (1 << art::mips::T6) | (1 << art::mips::T7) |
     43     (1 << art::mips::S0) | (1 << art::mips::S1) | (1 << art::mips::T8) | (1 << art::mips::T9);
     44 
     45 static constexpr uint32_t kMipsCalleeSaveFpAlwaysSpills = 0;
     46 static constexpr uint32_t kMipsCalleeSaveFpRefSpills = 0;
     47 static constexpr uint32_t kMipsCalleeSaveFpArgSpills =
     48     (1 << art::mips::F8) | (1 << art::mips::F9) | (1 << art::mips::F10) | (1 << art::mips::F11) |
     49     (1 << art::mips::F12) | (1 << art::mips::F13) | (1 << art::mips::F14) | (1 << art::mips::F15) |
     50     (1 << art::mips::F16) | (1 << art::mips::F17) | (1 << art::mips::F18) | (1 << art::mips::F19);
     51 static constexpr uint32_t kMipsCalleeSaveAllFPSpills =
     52     (1 << art::mips::F20) | (1 << art::mips::F21) | (1 << art::mips::F22) | (1 << art::mips::F23) |
     53     (1 << art::mips::F24) | (1 << art::mips::F25) | (1 << art::mips::F26) | (1 << art::mips::F27) |
     54     (1 << art::mips::F28) | (1 << art::mips::F29) | (1 << art::mips::F30) | (1u << art::mips::F31);
     55 static constexpr uint32_t kMipsCalleeSaveFpEverythingSpills =
     56     (1 << art::mips::F0) | (1 << art::mips::F1) | (1 << art::mips::F2) | (1 << art::mips::F3) |
     57     (1 << art::mips::F4) | (1 << art::mips::F5) | (1 << art::mips::F6) | (1 << art::mips::F7) |
     58     (1 << art::mips::F8) | (1 << art::mips::F9) | (1 << art::mips::F10) | (1 << art::mips::F11) |
     59     (1 << art::mips::F12) | (1 << art::mips::F13) | (1 << art::mips::F14) | (1 << art::mips::F15) |
     60     (1 << art::mips::F16) | (1 << art::mips::F17) | (1 << art::mips::F18) | (1 << art::mips::F19) |
     61     (1 << art::mips::F20) | (1 << art::mips::F21) | (1 << art::mips::F22) | (1 << art::mips::F23) |
     62     (1 << art::mips::F24) | (1 << art::mips::F25) | (1 << art::mips::F26) | (1 << art::mips::F27) |
     63     (1 << art::mips::F28) | (1 << art::mips::F29) | (1 << art::mips::F30) | (1u << art::mips::F31);
     64 
     65 constexpr uint32_t MipsCalleeSaveCoreSpills(Runtime::CalleeSaveType type) {
     66   return kMipsCalleeSaveAlwaysSpills | kMipsCalleeSaveRefSpills |
     67       (type == Runtime::kSaveRefsAndArgs ? kMipsCalleeSaveArgSpills : 0) |
     68       (type == Runtime::kSaveAllCalleeSaves ? kMipsCalleeSaveAllSpills : 0) |
     69       (type == Runtime::kSaveEverything ? kMipsCalleeSaveEverythingSpills : 0);
     70 }
     71 
     72 constexpr uint32_t MipsCalleeSaveFPSpills(Runtime::CalleeSaveType type) {
     73   return kMipsCalleeSaveFpAlwaysSpills | kMipsCalleeSaveFpRefSpills |
     74       (type == Runtime::kSaveRefsAndArgs ? kMipsCalleeSaveFpArgSpills : 0) |
     75       (type == Runtime::kSaveAllCalleeSaves ? kMipsCalleeSaveAllFPSpills : 0) |
     76       (type == Runtime::kSaveEverything ? kMipsCalleeSaveFpEverythingSpills : 0);
     77 }
     78 
     79 constexpr uint32_t MipsCalleeSaveFrameSize(Runtime::CalleeSaveType type) {
     80   return RoundUp((POPCOUNT(MipsCalleeSaveCoreSpills(type)) /* gprs */ +
     81                   POPCOUNT(MipsCalleeSaveFPSpills(type))   /* fprs */ +
     82                   1 /* Method* */) * static_cast<size_t>(kMipsPointerSize), kStackAlignment);
     83 }
     84 
     85 constexpr QuickMethodFrameInfo MipsCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) {
     86   return QuickMethodFrameInfo(MipsCalleeSaveFrameSize(type),
     87                               MipsCalleeSaveCoreSpills(type),
     88                               MipsCalleeSaveFPSpills(type));
     89 }
     90 
     91 }  // namespace mips
     92 }  // namespace art
     93 
     94 #endif  // ART_RUNTIME_ARCH_MIPS_QUICK_METHOD_FRAME_INFO_MIPS_H_
     95