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