Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | /* Register names and numbers for AArch64 DWARF. |
| 2 | Copyright (C) 2013, 2014 Red Hat, Inc. |
| 3 | This file is part of elfutils. |
| 4 | |
| 5 | This file is free software; you can redistribute it and/or modify |
| 6 | it under the terms of either |
| 7 | |
| 8 | * the GNU Lesser General Public License as published by the Free |
| 9 | Software Foundation; either version 3 of the License, or (at |
| 10 | your option) any later version |
| 11 | |
| 12 | or |
| 13 | |
| 14 | * the GNU General Public License as published by the Free |
| 15 | Software Foundation; either version 2 of the License, or (at |
| 16 | your option) any later version |
| 17 | |
| 18 | or both in parallel, as here. |
| 19 | |
| 20 | elfutils is distributed in the hope that it will be useful, but |
| 21 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 | General Public License for more details. |
| 24 | |
| 25 | You should have received copies of the GNU General Public License and |
| 26 | the GNU Lesser General Public License along with this program. If |
| 27 | not, see <http://www.gnu.org/licenses/>. */ |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_H |
| 30 | # include <config.h> |
| 31 | #endif |
| 32 | |
| 33 | #include <stdio.h> |
| 34 | #include <string.h> |
| 35 | #include <dwarf.h> |
| 36 | #include <stdarg.h> |
| 37 | |
| 38 | #define BACKEND aarch64_ |
| 39 | #include "libebl_CPU.h" |
| 40 | |
| 41 | __attribute__ ((format (printf, 7, 8))) |
| 42 | static ssize_t |
| 43 | do_regtype (const char *setname, int type, |
| 44 | const char **setnamep, int *typep, |
| 45 | char *name, size_t namelen, const char *fmt, ...) |
| 46 | { |
| 47 | *setnamep = setname; |
| 48 | *typep = type; |
| 49 | |
| 50 | va_list ap; |
| 51 | va_start (ap, fmt); |
| 52 | int s = vsnprintf (name, namelen, fmt, ap); |
| 53 | va_end(ap); |
| 54 | |
| 55 | if (s < 0 || (unsigned) s >= namelen) |
| 56 | return -1; |
| 57 | return s + 1; |
| 58 | } |
| 59 | |
| 60 | ssize_t |
| 61 | aarch64_register_info (Ebl *ebl __attribute__ ((unused)), |
| 62 | int regno, char *name, size_t namelen, |
| 63 | const char **prefix, const char **setnamep, |
| 64 | int *bits, int *typep) |
| 65 | { |
| 66 | if (name == NULL) |
| 67 | return 128; |
| 68 | |
| 69 | |
| 70 | *prefix = ""; |
| 71 | *bits = 64; |
| 72 | |
| 73 | #define regtype(setname, type, ...) \ |
| 74 | do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__) |
| 75 | |
| 76 | switch (regno) |
| 77 | { |
| 78 | case 0 ... 30: |
| 79 | return regtype ("integer", DW_ATE_signed, "x%d", regno); |
| 80 | |
| 81 | case 31: |
| 82 | return regtype ("integer", DW_ATE_address, "sp"); |
| 83 | |
| 84 | case 32: |
| 85 | return 0; |
| 86 | |
| 87 | case 33: |
| 88 | return regtype ("integer", DW_ATE_address, "elr"); |
| 89 | |
| 90 | case 34 ... 63: |
| 91 | return 0; |
| 92 | |
| 93 | case 64 ... 95: |
| 94 | /* FP/SIMD register file supports a variety of data types--it |
| 95 | can be thought of as a register holding a single integer or |
| 96 | floating-point value, or a vector of 8-, 16-, 32- or 64-bit |
| 97 | integers. 128-bit quad-word is the only singular value that |
| 98 | covers the whole register, so mark the register thus. */ |
| 99 | *bits = 128; |
| 100 | return regtype ("FP/SIMD", DW_ATE_unsigned, "v%d", regno - 64); |
| 101 | |
| 102 | case 96 ... 127: |
| 103 | return 0; |
| 104 | |
| 105 | default: |
| 106 | return -1; |
| 107 | } |
| 108 | } |