1 /* Register names and numbers for IA64 DWARF.
2 Copyright (C) 2006 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 i386_
37 #include "libebl_CPU.h"
38
39 ssize_t
ia64_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setname,int * bits,int * type)40 ia64_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 687 + 64;
47
48 if (regno < 0 || regno > 687 + 63 || namelen < 12)
49 return -1;
50
51 *prefix = "ar.";
52 *setname = "application";
53 *bits = 64;
54 *type = DW_ATE_signed;
55 switch (regno)
56 {
57 case 0 ... 9:
58 name[0] = 'r';
59 name[1] = (regno - 0) + '0';
60 namelen = 2;
61 *setname = "integer";
62 *prefix = "";
63 break;
64
65 case 10 ... 99:
66 name[0] = 'r';
67 name[1] = (regno - 0) / 10 + '0';
68 name[2] = (regno - 0) % 10 + '0';
69 namelen = 3;
70 *setname = "integer";
71 *prefix = "";
72 break;
73
74 case 100 ... 127:
75 name[0] = 'r';
76 name[1] = '1';
77 name[2] = (regno - 100) / 10 + '0';
78 name[3] = (regno - 0) % 10 + '0';
79 namelen = 4;
80 *setname = "integer";
81 *prefix = "";
82 break;
83
84 case 128 + 0 ... 128 + 9:
85 name[0] = 'f';
86 name[1] = (regno - 128) + '0';
87 namelen = 2;
88 *type = DW_ATE_float;
89 *bits = 128;
90 *setname = "FPU";
91 *prefix = "";
92 break;
93
94 case 128 + 10 ... 128 + 99:
95 name[0] = 'f';
96 name[1] = (regno - 128) / 10 + '0';
97 name[2] = (regno - 128) % 10 + '0';
98 namelen = 3;
99 *setname = "FPU";
100 *prefix = "";
101 break;
102
103 case 128 + 100 ... 128 + 127:
104 name[0] = 'f';
105 name[1] = '1';
106 name[2] = (regno - 128 - 100) / 10 + '0';
107 name[3] = (regno - 128) % 10 + '0';
108 namelen = 4;
109 *type = DW_ATE_float;
110 *bits = 128;
111 *setname = "FPU";
112 *prefix = "";
113 break;
114
115 case 320 + 0 ... 320 + 7:
116 name[0] = 'b';
117 name[1] = (regno - 320) + '0';
118 namelen = 2;
119 *type = DW_ATE_address;
120 *setname = "branch";
121 *prefix = "";
122 break;
123
124 case 328 ... 333:
125 {
126 static const char named_special[][5] =
127 {
128 "vfp", "vrap", "pr", "ip", "psr", "cfm"
129 };
130 *setname = "special";
131 *prefix = "";
132 *type = regno == 331 ? DW_ATE_address : DW_ATE_unsigned;
133 return stpcpy (name, named_special[regno - 328]) + 1 - name;
134 }
135
136 case 590:
137 *setname = "special";
138 *prefix = "";
139 *type = DW_ATE_unsigned;
140 return stpcpy (name, "bof") + 1 - name;
141
142 case 334 + 0 ... 334 + 7:
143 name[0] = 'k';
144 name[1] = 'r';
145 name[2] = (regno - 334) + '0';
146 namelen = 3;
147 *prefix = "";
148 break;
149
150 case 334 + 8 ... 334 + 127:
151 {
152 static const char named_ar[][9] =
153 {
154 [16 - 8] = "rsc",
155 [17 - 8] = "bsp",
156 [18 - 8] = "bspstore",
157 [19 - 8] = "rnat",
158 [21 - 8] = "fcr",
159 [24 - 8] = "eflag",
160 [25 - 8] = "csd",
161 [26 - 8] = "ssd",
162 [27 - 8] = "cflg",
163 [28 - 8] = "fsr",
164 [29 - 8] = "fir",
165 [30 - 8] = "fdr",
166 [32 - 8] = "ccv",
167 [36 - 8] = "unat",
168 [40 - 8] = "fpsr",
169 [44 - 8] = "itc",
170 [64 - 8] = "pfs",
171 [65 - 8] = "lc",
172 [66 - 8] = "ec",
173 };
174 const size_t idx = regno - (334 + 8);
175 *type = DW_ATE_unsigned;
176 if (idx == 1 || idx == 2)
177 *type = DW_ATE_address;
178 if (idx < sizeof named_ar / sizeof named_ar[0]
179 && named_ar[idx][0] != '\0')
180 return stpcpy (name, named_ar[idx]) + 1 - name;
181
182 name[0] = 'a';
183 name[1] = 'r';
184 switch (regno - 334)
185 {
186 case 0 ... 9:
187 name[2] = (regno - 334) + '0';
188 namelen = 3;
189 break;
190 case 10 ... 99:
191 name[2] = (regno - 334) / 10 + '0';
192 name[3] = (regno - 334) % 10 + '0';
193 namelen = 4;
194 break;
195 case 100 ... 127:
196 name[2] = '1';
197 name[3] = (regno - 334 - 100) / 10 + '0';
198 name[4] = (regno - 334) % 10 + '0';
199 namelen = 5;
200 break;
201 }
202 *prefix = "";
203 break;
204 }
205
206 case 462 + 0 ... 462 + 9:
207 name[0] = 'n';
208 name[1] = 'a';
209 name[2] = 't';
210 name[3] = (regno - 462) + '0';
211 namelen = 4;
212 *setname = "NAT";
213 *type = DW_ATE_boolean;
214 *bits = 1;
215 *prefix = "";
216 break;
217
218 case 462 + 10 ... 462 + 99:
219 name[0] = 'n';
220 name[1] = 'a';
221 name[2] = 't';
222 name[3] = (regno - 462) / 10 + '0';
223 name[4] = (regno - 462) % 10 + '0';
224 namelen = 5;
225 *setname = "NAT";
226 *type = DW_ATE_boolean;
227 *bits = 1;
228 *prefix = "";
229 break;
230
231 case 462 + 100 ... 462 + 127:
232 name[0] = 'n';
233 name[1] = 'a';
234 name[2] = 't';
235 name[3] = '1';
236 name[4] = (regno - 462 - 100) / 10 + '0';
237 name[5] = (regno - 462) % 10 + '0';
238 namelen = 6;
239 *setname = "NAT";
240 *type = DW_ATE_boolean;
241 *bits = 1;
242 *prefix = "";
243 break;
244
245 case 687 + 0 ... 687 + 9:
246 name[0] = 'p';
247 name[1] = (regno - 687) + '0';
248 namelen = 2;
249 *setname = "predicate";
250 *type = DW_ATE_boolean;
251 *bits = 1;
252 *prefix = "";
253 break;
254
255 case 687 + 10 ... 687 + 63:
256 name[0] = 'p';
257 name[1] = (regno - 687) / 10 + '0';
258 name[2] = (regno - 687) % 10 + '0';
259 namelen = 3;
260 *setname = "predicate";
261 *type = DW_ATE_boolean;
262 *bits = 1;
263 *prefix = "";
264 break;
265
266 default:
267 *setname = NULL;
268 return 0;
269 }
270
271 name[namelen++] = '\0';
272 return namelen;
273 }
274