• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_X86_QUICK_METHOD_FRAME_INFO_X86_H_
18 #define ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_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_x86.h"
26 
27 namespace art {
28 namespace x86 {
29 
30 enum XMM {
31   XMM0 = 0,
32   XMM1 = 1,
33   XMM2 = 2,
34   XMM3 = 3,
35   XMM4 = 4,
36   XMM5 = 5,
37   XMM6 = 6,
38   XMM7 = 7,
39 };
40 
41 static constexpr uint32_t kX86CalleeSaveAlwaysSpills =
42     (1 << art::x86::kNumberOfCpuRegisters);  // Fake return address callee save.
43 static constexpr uint32_t kX86CalleeSaveRefSpills =
44     (1 << art::x86::EBP) | (1 << art::x86::ESI) | (1 << art::x86::EDI);
45 static constexpr uint32_t kX86CalleeSaveArgSpills =
46     (1 << art::x86::ECX) | (1 << art::x86::EDX) | (1 << art::x86::EBX);
47 static constexpr uint32_t kX86CalleeSaveEverythingSpills =
48     (1 << art::x86::EAX) | (1 << art::x86::ECX) | (1 << art::x86::EDX) | (1 << art::x86::EBX);
49 
50 static constexpr uint32_t kX86CalleeSaveFpArgSpills =
51     (1 << art::x86::XMM0) | (1 << art::x86::XMM1) |
52     (1 << art::x86::XMM2) | (1 << art::x86::XMM3);
53 static constexpr uint32_t kX86CalleeSaveFpEverythingSpills =
54     (1 << art::x86::XMM0) | (1 << art::x86::XMM1) |
55     (1 << art::x86::XMM2) | (1 << art::x86::XMM3) |
56     (1 << art::x86::XMM4) | (1 << art::x86::XMM5) |
57     (1 << art::x86::XMM6) | (1 << art::x86::XMM7);
58 
X86CalleeSaveCoreSpills(CalleeSaveType type)59 constexpr uint32_t X86CalleeSaveCoreSpills(CalleeSaveType type) {
60   return kX86CalleeSaveAlwaysSpills | kX86CalleeSaveRefSpills |
61       (type == CalleeSaveType::kSaveRefsAndArgs ? kX86CalleeSaveArgSpills : 0) |
62       (type == CalleeSaveType::kSaveEverything ? kX86CalleeSaveEverythingSpills : 0);
63 }
64 
X86CalleeSaveFpSpills(CalleeSaveType type)65 constexpr uint32_t X86CalleeSaveFpSpills(CalleeSaveType type) {
66     return (type == CalleeSaveType::kSaveRefsAndArgs ? kX86CalleeSaveFpArgSpills : 0) |
67            (type == CalleeSaveType::kSaveEverything ? kX86CalleeSaveFpEverythingSpills : 0);
68 }
69 
X86CalleeSaveFrameSize(CalleeSaveType type)70 constexpr uint32_t X86CalleeSaveFrameSize(CalleeSaveType type) {
71   return RoundUp((POPCOUNT(X86CalleeSaveCoreSpills(type)) /* gprs */ +
72                   2 * POPCOUNT(X86CalleeSaveFpSpills(type)) /* fprs */ +
73                   1 /* Method* */) * static_cast<size_t>(kX86PointerSize), kStackAlignment);
74 }
75 
X86CalleeSaveMethodFrameInfo(CalleeSaveType type)76 constexpr QuickMethodFrameInfo X86CalleeSaveMethodFrameInfo(CalleeSaveType type) {
77   return QuickMethodFrameInfo(X86CalleeSaveFrameSize(type),
78                               X86CalleeSaveCoreSpills(type),
79                               X86CalleeSaveFpSpills(type));
80 }
81 
82 }  // namespace x86
83 }  // namespace art
84 
85 #endif  // ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_
86