blob: 076609db41d7db2936becca06db58d663ddac93e [file] [log] [blame]
Roland McGrath95024622006-07-21 10:06:31 +00001/* Register names and numbers for IA64 DWARF.
2 Copyright (C) 2006 Red Hat, Inc.
3 This file is part of Red Hat elfutils.
4
5 Red Hat elfutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by the
7 Free Software Foundation; version 2 of the License.
8
9 Red Hat elfutils is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with Red Hat elfutils; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
17
18 Red Hat elfutils is an included package of the Open Invention Network.
19 An included package of the Open Invention Network is a package for which
20 Open Invention Network licensees cross-license their patents. No patent
21 license is granted, either expressly or impliedly, by designation as an
22 included package. Should you wish to participate in the Open Invention
23 Network licensing program, please visit www.openinventionnetwork.com
24 <http://www.openinventionnetwork.com>. */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <string.h>
31
32#define BACKEND i386_
33#include "libebl_CPU.h"
34
35ssize_t
36ia64_register_name (Ebl *ebl __attribute__ ((unused)),
37 int regno, char *name, size_t namelen,
38 const char **prefix, const char **setname)
39{
40 if (name == NULL)
41 return 687 + 64;
42
43 if (regno < 0 || regno > 687 + 63 || namelen < 12)
44 return -1;
45
Roland McGrath42a177c2006-07-21 12:17:27 +000046 *prefix = "ar.";
Roland McGrath95024622006-07-21 10:06:31 +000047 *setname = "application";
48 switch (regno)
49 {
50 case 0 ... 9:
51 name[0] = 'r';
52 name[1] = (regno - 0) + '0';
53 namelen = 2;
54 *setname = "integer";
Roland McGrath42a177c2006-07-21 12:17:27 +000055 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +000056 break;
57
58 case 10 ... 99:
59 name[0] = 'r';
60 name[1] = (regno - 0) / 10 + '0';
61 name[2] = (regno - 0) % 10 + '0';
62 namelen = 3;
63 *setname = "integer";
Roland McGrath42a177c2006-07-21 12:17:27 +000064 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +000065 break;
66
67 case 100 ... 127:
68 name[0] = 'r';
69 name[1] = '1';
70 name[2] = (regno - 100) / 10 + '0';
71 name[3] = (regno - 0) % 10 + '0';
72 namelen = 4;
73 *setname = "integer";
Roland McGrath42a177c2006-07-21 12:17:27 +000074 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +000075 break;
76
77 case 128 + 0 ... 128 + 9:
78 name[0] = 'f';
79 name[1] = (regno - 128) + '0';
80 namelen = 2;
81 *setname = "FPU";
Roland McGrath42a177c2006-07-21 12:17:27 +000082 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +000083 break;
84
85 case 128 + 10 ... 128 + 99:
86 name[0] = 'f';
87 name[1] = (regno - 128) / 10 + '0';
88 name[2] = (regno - 128) % 10 + '0';
89 namelen = 3;
90 *setname = "FPU";
Roland McGrath42a177c2006-07-21 12:17:27 +000091 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +000092 break;
93
94 case 128 + 100 ... 128 + 127:
95 name[0] = 'f';
96 name[1] = '1';
97 name[2] = (regno - 128 - 100) / 10 + '0';
98 name[3] = (regno - 128) % 10 + '0';
99 namelen = 4;
100 *setname = "FPU";
Roland McGrath42a177c2006-07-21 12:17:27 +0000101 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000102 break;
103
104 case 320 + 0 ... 320 + 7:
105 name[0] = 'b';
106 name[1] = (regno - 320) + '0';
107 namelen = 2;
108 *setname = "branch";
Roland McGrath42a177c2006-07-21 12:17:27 +0000109 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000110 break;
111
Roland McGrath42a177c2006-07-21 12:17:27 +0000112 case 328 ... 333:
113 {
114 static const char named_special[][5] =
115 {
116 "vfp", "vrap", "pr", "ip", "psr", "cfm"
117 };
118 *setname = "special";
119 *prefix = "";
120 return stpcpy (name, named_special[regno - 328]) + 1 - name;
121 }
122
123 case 590:
124 *setname = "special";
125 *prefix = "";
126 return stpcpy (name, "bof") + 1 - name;
Roland McGrath95024622006-07-21 10:06:31 +0000127
128 case 334 + 0 ... 334 + 7:
129 name[0] = 'k';
130 name[1] = 'r';
131 name[2] = (regno - 334) + '0';
132 namelen = 3;
Roland McGrath42a177c2006-07-21 12:17:27 +0000133 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000134 break;
135
Roland McGrath42a177c2006-07-21 12:17:27 +0000136 case 334 + 8 ... 334 + 127:
137 {
138 static const char named_ar[][9] =
139 {
140 [16 - 8] = "rsc",
141 [17 - 8] = "bsp",
142 [18 - 8] = "bspstore",
143 [19 - 8] = "rnat",
144 [21 - 8] = "fcr",
145 [24 - 8] = "eflag",
146 [25 - 8] = "csd",
147 [26 - 8] = "ssd",
148 [27 - 8] = "cflg",
149 [28 - 8] = "fsr",
150 [29 - 8] = "fir",
151 [30 - 8] = "fdr",
152 [32 - 8] = "ccv",
153 [36 - 8] = "unat",
154 [40 - 8] = "fpsr",
155 [44 - 8] = "itc",
156 [64 - 8] = "pfs",
157 [65 - 8] = "lc",
158 [66 - 8] = "ec",
159 };
160 const size_t idx = regno - (334 + 8);
161 if (idx < sizeof named_ar / sizeof named_ar[0]
162 && named_ar[idx][0] != '\0')
163 return stpcpy (name, named_ar[idx]) + 1 - name;
164
165 name[0] = 'a';
166 name[1] = 'r';
167 switch (regno - 334)
168 {
169 case 0 ... 9:
170 name[2] = (regno - 334) + '0';
171 namelen = 3;
172 break;
173 case 10 ... 99:
174 name[2] = (regno - 334) / 10 + '0';
175 name[3] = (regno - 334) % 10 + '0';
176 namelen = 4;
177 break;
178 case 100 ... 127:
179 name[2] = '1';
180 name[3] = (regno - 334 - 100) / 10 + '0';
181 name[4] = (regno - 334) % 10 + '0';
182 namelen = 5;
183 break;
184 }
185 *prefix = "";
186 break;
187 }
Roland McGrath95024622006-07-21 10:06:31 +0000188
189 case 462 + 0 ... 462 + 9:
190 name[0] = 'n';
191 name[1] = 'a';
192 name[2] = 't';
193 name[3] = (regno - 462) + '0';
194 namelen = 4;
195 *setname = "NAT";
Roland McGrath42a177c2006-07-21 12:17:27 +0000196 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000197 break;
198
199 case 462 + 10 ... 462 + 99:
200 name[0] = 'n';
201 name[1] = 'a';
202 name[2] = 't';
203 name[3] = (regno - 462) / 10 + '0';
204 name[4] = (regno - 462) % 10 + '0';
205 namelen = 5;
206 *setname = "NAT";
Roland McGrath42a177c2006-07-21 12:17:27 +0000207 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000208 break;
209
210 case 462 + 100 ... 462 + 127:
211 name[0] = 'n';
212 name[1] = 'a';
213 name[2] = 't';
Roland McGrath42a177c2006-07-21 12:17:27 +0000214 name[3] = '1';
215 name[4] = (regno - 462 - 100) / 10 + '0';
216 name[5] = (regno - 462) % 10 + '0';
217 namelen = 6;
Roland McGrath95024622006-07-21 10:06:31 +0000218 *setname = "NAT";
Roland McGrath42a177c2006-07-21 12:17:27 +0000219 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000220 break;
221
Roland McGrath95024622006-07-21 10:06:31 +0000222 case 687 + 0 ... 687 + 9:
223 name[0] = 'p';
224 name[1] = (regno - 687) + '0';
225 namelen = 2;
226 *setname = "predicate";
Roland McGrath42a177c2006-07-21 12:17:27 +0000227 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000228 break;
229
230 case 687 + 10 ... 687 + 63:
231 name[0] = 'p';
232 name[1] = (regno - 687) / 10 + '0';
233 name[2] = (regno - 687) % 10 + '0';
234 namelen = 3;
235 *setname = "predicate";
Roland McGrath42a177c2006-07-21 12:17:27 +0000236 *prefix = "";
Roland McGrath95024622006-07-21 10:06:31 +0000237 break;
238
239 default:
240 *setname = NULL;
241 return 0;
242 }
243
244 name[namelen++] = '\0';
245 return namelen;
246}