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 "quick/quick_method_frame_info.h"
     21 #include "registers_mips.h"
     22 #include "runtime.h"  // for Runtime::CalleeSaveType.
     23 
     24 namespace art {
     25 namespace mips {
     26 
     27 static constexpr uint32_t kMipsCalleeSaveRefSpills =
     28     (1 << art::mips::S2) | (1 << art::mips::S3) | (1 << art::mips::S4) | (1 << art::mips::S5) |
     29     (1 << art::mips::S6) | (1 << art::mips::S7) | (1 << art::mips::GP) | (1 << art::mips::FP);
     30 static constexpr uint32_t kMipsCalleeSaveArgSpills =
     31     (1 << art::mips::A1) | (1 << art::mips::A2) | (1 << art::mips::A3);
     32 static constexpr uint32_t kMipsCalleeSaveAllSpills =
     33     (1 << art::mips::S0) | (1 << art::mips::S1);
     34 
     35 constexpr uint32_t MipsCalleeSaveCoreSpills(Runtime::CalleeSaveType type) {
     36   return kMipsCalleeSaveRefSpills |
     37       (type == Runtime::kRefsAndArgs ? kMipsCalleeSaveArgSpills : 0) |
     38       (type == Runtime::kSaveAll ? kMipsCalleeSaveAllSpills : 0) | (1 << art::mips::RA);
     39 }
     40 
     41 constexpr uint32_t MipsCalleeSaveFrameSize(Runtime::CalleeSaveType type) {
     42   return RoundUp((POPCOUNT(MipsCalleeSaveCoreSpills(type)) /* gprs */ +
     43                   (type == Runtime::kRefsAndArgs ? 0 : 3) + 1 /* Method* */) *
     44                  kMipsPointerSize, kStackAlignment);
     45 }
     46 
     47 constexpr QuickMethodFrameInfo MipsCalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) {
     48   return QuickMethodFrameInfo(MipsCalleeSaveFrameSize(type),
     49                               MipsCalleeSaveCoreSpills(type),
     50                               0u);
     51 }
     52 
     53 }  // namespace mips
     54 }  // namespace art
     55 
     56 #endif  // ART_RUNTIME_ARCH_MIPS_QUICK_METHOD_FRAME_INFO_MIPS_H_
     57