David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 1 | /* |
| 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 Srbecky | 2faab00 | 2019-02-12 16:35:48 +0000 | [diff] [blame] | 17 | #ifndef ART_LIBELFFILE_DWARF_REGISTER_H_ |
| 18 | #define ART_LIBELFFILE_DWARF_REGISTER_H_ |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 19 | |
| 20 | namespace art { |
| 21 | namespace dwarf { |
| 22 | |
| 23 | // Represents DWARF register. |
| 24 | class 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 Levillain | 91d65e0 | 2016-01-19 15:59:16 +0000 | [diff] [blame] | 32 | // mapping we cannot easily say S0 is spilled and S1 is not. |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 33 | // 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 Srbecky | 8a813f7 | 2015-04-20 16:43:52 +0100 | [diff] [blame] | 36 | // libunwind might struggle with the new mapping as well. |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 37 | |
David Srbecky | 0fd295f | 2015-11-16 16:39:10 +0000 | [diff] [blame] | 38 | static Reg ArmCore(int num) { return Reg(num); } // R0-R15. |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 39 | static Reg ArmFp(int num) { return Reg(64 + num); } // S0–S31. |
David Srbecky | 0fd295f | 2015-11-16 16:39:10 +0000 | [diff] [blame] | 40 | static Reg ArmDp(int num) { return Reg(256 + num); } // D0–D31. |
| 41 | static Reg Arm64Core(int num) { return Reg(num); } // X0-X31. |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 42 | static Reg Arm64Fp(int num) { return Reg(64 + num); } // V0-V31. |
David Srbecky | 15c1975 | 2015-03-31 14:53:55 +0000 | [diff] [blame] | 43 | 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 Srbecky | 2faab00 | 2019-02-12 16:35:48 +0000 | [diff] [blame] | 58 | #endif // ART_LIBELFFILE_DWARF_REGISTER_H_ |