1 /* Register names and numbers for Alpha DWARF.
2 Copyright (C) 2007 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 <string.h>
34 #include <dwarf.h>
35
36 #define BACKEND alpha_
37 #include "libebl_CPU.h"
38
39 ssize_t
alpha_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setname,int * bits,int * type)40 alpha_register_info (Ebl *ebl __attribute__ ((unused)),
41 int regno, char *name, size_t namelen,
42 const char **prefix, const char **setname,
43 int *bits, int *type)
44 {
45 if (name == NULL)
46 return 67;
47
48 if (regno < 0 || regno > 66 || namelen < 7)
49 return -1;
50
51 *prefix = "$";
52
53 *bits = 64;
54 *type = DW_ATE_signed;
55 *setname = "integer";
56 if (regno >= 32 && regno < 64)
57 {
58 *setname = "FPU";
59 *type = DW_ATE_float;
60 }
61
62 switch (regno)
63 {
64 case 0:
65 name[0] = 'v';
66 name[1] = '0';
67 namelen = 2;
68 break;
69
70 case 1 ... 8:
71 name[0] = 't';
72 name[1] = regno - 1 + '0';
73 namelen = 2;
74 break;
75
76 case 9 ... 15:
77 name[0] = 's';
78 name[1] = regno - 9 + '0';
79 namelen = 2;
80 break;
81
82 case 16 ... 21:
83 name[0] = 'a';
84 name[1] = regno - 16 + '0';
85 namelen = 2;
86 break;
87
88 case 22 ... 23:
89 name[0] = 't';
90 name[1] = regno - 22 + '8';
91 namelen = 2;
92 break;
93
94 case 24 ... 25:
95 name[0] = 't';
96 name[1] = '1';
97 name[2] = regno - 24 + '0';
98 namelen = 3;
99 break;
100
101 case 26:
102 *type = DW_ATE_address;
103 return stpcpy (name, "ra") + 1 - name;
104
105 case 27:
106 return stpcpy (name, "t12") + 1 - name;
107
108 case 28:
109 return stpcpy (name, "at") + 1 - name;
110
111 case 29:
112 *type = DW_ATE_address;
113 return stpcpy (name, "gp") + 1 - name;
114
115 case 30:
116 *type = DW_ATE_address;
117 return stpcpy (name, "sp") + 1 - name;
118
119 case 31:
120 return stpcpy (name, "zero") + 1 - name;
121
122 case 32 ... 32 + 9:
123 name[0] = 'f';
124 name[1] = regno - 32 + '0';
125 namelen = 2;
126 break;
127
128 case 32 + 10 ... 32 + 19:
129 name[0] = 'f';
130 name[1] = '1';
131 name[2] = regno - 32 - 10 + '0';
132 namelen = 3;
133 break;
134
135 case 32 + 20 ... 32 + 29:
136 name[0] = 'f';
137 name[1] = '2';
138 name[2] = regno - 32 - 20 + '0';
139 namelen = 3;
140 break;
141
142 case 32 + 30:
143 return stpcpy (name, "f30") + 1 - name;
144
145 case 32 + 31:
146 *type = DW_ATE_unsigned;
147 return stpcpy (name, "fpcr") + 1 - name;
148
149 case 64:
150 *type = DW_ATE_address;
151 return stpcpy (name, "pc") + 1 - name;
152
153 case 66:
154 *type = DW_ATE_address;
155 return stpcpy (name, "unique") + 1 - name;
156
157 default:
158 *setname = NULL;
159 return 0;
160 }
161
162 name[namelen++] = '\0';
163 return namelen;
164 }
165