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     (1 << 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);
     35 static constexpr uint32_t kMipsCalleeSaveAllSpills =
     36     (1 << art::mips::S0) | (1 << art::mips::S1);
     37 
     38 static constexpr uint32_t kMipsCalleeSaveFpAlwaysSpills = 0;
     39 static constexpr uint32_t kMipsCalleeSaveFpRefSpills = 0;
     40 static constexpr uint32_t kMipsCalleeSaveFpArgSpills =
     41     (1 << art::mips::F12) | (1 << art::mips::F13) | (1 << art::mips::F14) | (1 << art::mips::F15);
     42 static constexpr uint32_t kMipsCalleeSaveAllFPSpills =
     43     (1 << art::mips::F20) | (1 << art::mips::F21) | (1 << art::mips::F22) | (1 << art::mips::F23) |
     44     (1 << art::mips::F24) | (1 << art::mips::F25) | (1 << art::mips::F26) | (1 << art::mips::F27) |
     45     (1 << art::mips::F28) | (1 << art::mips::F29) | (1 << art::mips::F30) | (1 << art::mips::F31);
     46 
     47 constexpr uint32_t MipsCalleeSaveCoreSpills(Runtime::CalleeSaveType type) {
     48   return kMipsCalleeSaveAlwaysSpills | kMipsCalleeSaveRefSpills |
     49       (type == Runtime::kRefsAndArgs ? kMipsCalleeSaveArgSpills : 0) |
     50       (type == Runtime::kSaveAll ? kMipsCalleeSaveAllSpills : 0);
     51 }
     52 
     53 constexpr uint32_t MipsCalleeSaveFPSpills(Runtime::CalleeSaveType type) {
     54   return kMipsCalleeSaveFpAlwaysSpills | kMipsCalleeSaveFpRefSpills |
     55       (type == Runtime::kRefsAndArgs ? kMipsCalleeSaveFpArgSpills : 0) |
     56       (type == Runtime::kSaveAll ? kMipsCalleeSaveAllFPSpills : 0);
     57 }
     58 
     59 constexpr uint32_t MipsCalleeSaveFrameSize(Runtime::CalleeSaveType type) {
     60   return RoundUp((POPCOUNT(MipsCalleeSaveCoreSpills(type)) /* gprs */ +
     61                   POPCOUNT(MipsCalleeSaveFPSpills(type))   /* fprs */ +
     62                   1 /* Method* */) * kMipsPointerSize, kStackAlignment);
     63 }
     64 
     65 constexpr QuickMethodFrameInfo MipsCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) {
     66   return QuickMethodFrameInfo(MipsCalleeSaveFrameSize(type),
     67                               MipsCalleeSaveCoreSpills(type),
     68                               MipsCalleeSaveFPSpills(type));
     69 }
     70 
     71 }  // namespace mips
     72 }  // namespace art
     73 
     74 #endif  // ART_RUNTIME_ARCH_MIPS_QUICK_METHOD_FRAME_INFO_MIPS_H_
     75