blob: 7742ec411eed957e68cd71055c5c1cd320780263 [file] [log] [blame]
David Srbecky15c19752015-03-31 14:53:55 +00001/*
2 * Copyright (C) 2015 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
David Srbecky2faab002019-02-12 16:35:48 +000017#ifndef ART_LIBELFFILE_DWARF_REGISTER_H_
18#define ART_LIBELFFILE_DWARF_REGISTER_H_
David Srbecky15c19752015-03-31 14:53:55 +000019
20namespace art {
21namespace dwarf {
22
23// Represents DWARF register.
24class Reg {
25 public:
26 explicit Reg(int reg_num) : num_(reg_num) { }
27 int num() const { return num_; }
28
29 // TODO: Arm S0–S31 register mapping is obsolescent.
30 // We should use VFP-v3/Neon D0-D31 mapping instead.
31 // However, D0 is aliased to pair of S0 and S1, so using that
Roland Levillain91d65e02016-01-19 15:59:16 +000032 // mapping we cannot easily say S0 is spilled and S1 is not.
David Srbecky15c19752015-03-31 14:53:55 +000033 // There are ways around this in DWARF but they are complex.
34 // It would be much simpler to always spill whole D registers.
35 // Arm64 mapping is correct since we already do this there.
David Srbecky8a813f72015-04-20 16:43:52 +010036 // libunwind might struggle with the new mapping as well.
David Srbecky15c19752015-03-31 14:53:55 +000037
David Srbecky0fd295f2015-11-16 16:39:10 +000038 static Reg ArmCore(int num) { return Reg(num); } // R0-R15.
David Srbecky15c19752015-03-31 14:53:55 +000039 static Reg ArmFp(int num) { return Reg(64 + num); } // S0–S31.
David Srbecky0fd295f2015-11-16 16:39:10 +000040 static Reg ArmDp(int num) { return Reg(256 + num); } // D0–D31.
41 static Reg Arm64Core(int num) { return Reg(num); } // X0-X31.
David Srbecky15c19752015-03-31 14:53:55 +000042 static Reg Arm64Fp(int num) { return Reg(64 + num); } // V0-V31.
David Srbecky15c19752015-03-31 14:53:55 +000043 static Reg X86Core(int num) { return Reg(num); }
44 static Reg X86Fp(int num) { return Reg(21 + num); }
45 static Reg X86_64Core(int num) {
46 static const int map[8] = {0, 2, 1, 3, 7, 6, 4, 5};
47 return Reg(num < 8 ? map[num] : num);
48 }
49 static Reg X86_64Fp(int num) { return Reg(17 + num); }
50
51 private:
52 int num_;
53};
54
55} // namespace dwarf
56} // namespace art
57
David Srbecky2faab002019-02-12 16:35:48 +000058#endif // ART_LIBELFFILE_DWARF_REGISTER_H_