blob: 45ef94ea05d2fa04da5e5e7840f83554ccea7846 [file] [log] [blame]
Roland McGrath994b4892005-12-05 22:46:21 +00001/* Register names and numbers for x86-64 DWARF.
2 Copyright (C) 2005 Red Hat, Inc.
Ulrich Drepper361df7d2006-04-04 21:38:57 +00003 This file is part of Red Hat elfutils.
Roland McGrath994b4892005-12-05 22:46:21 +00004
Ulrich Drepper361df7d2006-04-04 21:38:57 +00005 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.
Roland McGrath994b4892005-12-05 22:46:21 +00008
Ulrich Drepper361df7d2006-04-04 21:38:57 +00009 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,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000016 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000017
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>. */
Roland McGrath994b4892005-12-05 22:46:21 +000025
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <assert.h>
31#include <dwarf.h>
32
33#define BACKEND x86_64_
34#include "libebl_CPU.h"
35
36ssize_t
37x86_64_register_name (Ebl *ebl __attribute__ ((unused)),
38 int regno, char *name, size_t namelen,
39 const char **prefix, const char **setname)
40{
41 if (name == NULL)
42 return 49;
43
44 if (regno < 0 || regno > 48 || namelen < 6)
45 return -1;
46
47 *prefix = "%";
48 if (regno < 17)
49 *setname = "integer";
50 else if (regno < 33)
51 *setname = "SSE";
52 else if (regno < 41)
53 *setname = "x87";
54 else
55 *setname = "MMX";
56
57 switch (regno)
58 {
59 static const char baseregs[][2] =
60 {
61 "ax", "dx", "cx", "bx", "si", "di", "bp", "sp"
62 };
63
64 case 0 ... 7:
65 name[0] = 'r';
66 name[1] = baseregs[regno][0];
67 name[2] = baseregs[regno][1];
68 namelen = 3;
69 break;
70
71 case 8 ... 9:
72 name[0] = 'r';
73 name[1] = regno - 8 + '8';
74 namelen = 2;
75 break;
76
77 case 10 ... 15:
78 name[0] = 'r';
79 name[1] = '1';
80 name[2] = regno - 10 + '0';
81 namelen = 3;
82 break;
83
84 case 16:
85 name[0] = 'r';
86 name[1] = 'i';
87 name[2] = 'p';
88 namelen = 3;
89 break;
90
91 case 17 ... 26:
92 name[0] = 'x';
93 name[1] = 'm';
94 name[2] = 'm';
95 name[3] = regno - 17 + '0';
96 namelen = 4;
97 break;
98
99 case 27 ... 32:
100 name[0] = 'x';
101 name[1] = 'm';
102 name[2] = 'm';
103 name[3] = '1';
104 name[4] = regno - 27 + '0';
105 namelen = 5;
106 break;
107
108 case 33 ... 40:
109 name[0] = 's';
110 name[1] = 't';
111 name[2] = regno - 33 + '0';
112 namelen = 3;
113 break;
114
115 case 41 ... 48:
116 name[0] = 'm';
117 name[1] = 'm';
118 name[2] = regno - 41 + '0';
119 namelen = 3;
120 break;
121 }
122
123 name[namelen++] = '\0';
124 return namelen;
125}