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 ssize_t
aarch64_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setnamep,int * bits,int * typep)42 aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
43 int regno, char *name, size_t namelen,
44 const char **prefix, const char **setnamep,
45 int *bits, int *typep)
46 {
47 if (name == NULL)
48 return 128;
49
50 __attribute__ ((format (printf, 3, 4)))
51 ssize_t
52 regtype (const char *setname, int type, const char *fmt, ...)
53 {
54 *setnamep = setname;
55 *typep = type;
56
57 va_list ap;
58 va_start (ap, fmt);
59 int s = vsnprintf (name, namelen, fmt, ap);
60 va_end(ap);
61
62 if (s < 0 || (unsigned) s >= namelen)
63 return -1;
64 return s + 1;
65 }
66
67 *prefix = "";
68 *bits = 64;
69
70 switch (regno)
71 {
72 case 0 ... 30:
73 return regtype ("integer", DW_ATE_signed, "x%d", regno);
74
75 case 31:
76 return regtype ("integer", DW_ATE_address, "sp");
77
78 case 32:
79 return 0;
80
81 case 33:
82 return regtype ("integer", DW_ATE_address, "elr");
83
84 case 34 ... 63:
85 return 0;
86
87 case 64 ... 95:
88 /* FP/SIMD register file supports a variety of data types--it
89 can be thought of as a register holding a single integer or
90 floating-point value, or a vector of 8-, 16-, 32- or 64-bit
91 integers. 128-bit quad-word is the only singular value that
92 covers the whole register, so mark the register thus. */
93 *bits = 128;
94 return regtype ("FP/SIMD", DW_ATE_unsigned, "v%d", regno - 64);
95
96 case 96 ... 127:
97 return 0;
98
99 default:
100 return -1;
101 }
102 }
103