blob: 8eb0d33f56d79e0c49793f7c9875e7dc92e0532d [file] [log] [blame]
Roland McGrath994b4892005-12-05 22:46:21 +00001/* Register names and numbers for x86-64 DWARF.
Roland McGrath5f6a41a2007-04-01 23:11:40 +00002 Copyright (C) 2005, 2006, 2007 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>
Roland McGrath5f6a41a2007-04-01 23:11:40 +000032#include <string.h>
Roland McGrath994b4892005-12-05 22:46:21 +000033
34#define BACKEND x86_64_
35#include "libebl_CPU.h"
36
37ssize_t
Roland McGrathc373d852006-10-10 00:25:21 +000038x86_64_register_info (Ebl *ebl __attribute__ ((unused)),
Roland McGrath994b4892005-12-05 22:46:21 +000039 int regno, char *name, size_t namelen,
Roland McGrathc373d852006-10-10 00:25:21 +000040 const char **prefix, const char **setname,
41 int *bits, int *type)
Roland McGrath994b4892005-12-05 22:46:21 +000042{
43 if (name == NULL)
Roland McGrath5f6a41a2007-04-01 23:11:40 +000044 return 67;
Roland McGrath994b4892005-12-05 22:46:21 +000045
Roland McGrath5f6a41a2007-04-01 23:11:40 +000046 if (regno < 0 || regno > 66 || namelen < 7)
Roland McGrath994b4892005-12-05 22:46:21 +000047 return -1;
48
49 *prefix = "%";
Roland McGrathc373d852006-10-10 00:25:21 +000050 *bits = 64;
51 *type = DW_ATE_unsigned;
Roland McGrath994b4892005-12-05 22:46:21 +000052 if (regno < 17)
Roland McGrathc373d852006-10-10 00:25:21 +000053 {
54 *setname = "integer";
Roland McGrath5f6a41a2007-04-01 23:11:40 +000055 *type = DW_ATE_signed;
Roland McGrathc373d852006-10-10 00:25:21 +000056 }
Roland McGrath994b4892005-12-05 22:46:21 +000057 else if (regno < 33)
Roland McGrathc373d852006-10-10 00:25:21 +000058 {
59 *setname = "SSE";
60 *bits = 128;
61 }
Roland McGrath994b4892005-12-05 22:46:21 +000062 else if (regno < 41)
Roland McGrathc373d852006-10-10 00:25:21 +000063 {
64 *setname = "x87";
65 *type = DW_ATE_float;
66 *bits = 80;
67 }
Roland McGrath5f6a41a2007-04-01 23:11:40 +000068 else if (regno < 49)
69 *setname = "MMX";
70 else if (regno > 49 && regno < 60)
Roland McGrathc373d852006-10-10 00:25:21 +000071 {
Roland McGrath5f6a41a2007-04-01 23:11:40 +000072 *setname = "segment";
73 *bits = 16;
Roland McGrathc373d852006-10-10 00:25:21 +000074 }
Roland McGrath5f6a41a2007-04-01 23:11:40 +000075 else
76 *setname = "control";
Roland McGrath994b4892005-12-05 22:46:21 +000077
78 switch (regno)
79 {
80 static const char baseregs[][2] =
81 {
82 "ax", "dx", "cx", "bx", "si", "di", "bp", "sp"
83 };
84
Roland McGrath5f6a41a2007-04-01 23:11:40 +000085 case 6 ... 7:
86 *type = DW_ATE_address;
87 case 0 ... 5:
Roland McGrath994b4892005-12-05 22:46:21 +000088 name[0] = 'r';
89 name[1] = baseregs[regno][0];
90 name[2] = baseregs[regno][1];
91 namelen = 3;
92 break;
93
94 case 8 ... 9:
95 name[0] = 'r';
96 name[1] = regno - 8 + '8';
97 namelen = 2;
98 break;
99
100 case 10 ... 15:
101 name[0] = 'r';
102 name[1] = '1';
103 name[2] = regno - 10 + '0';
104 namelen = 3;
105 break;
106
107 case 16:
Roland McGrath5f6a41a2007-04-01 23:11:40 +0000108 *type = DW_ATE_address;
Roland McGrath994b4892005-12-05 22:46:21 +0000109 name[0] = 'r';
110 name[1] = 'i';
111 name[2] = 'p';
112 namelen = 3;
113 break;
114
115 case 17 ... 26:
116 name[0] = 'x';
117 name[1] = 'm';
118 name[2] = 'm';
119 name[3] = regno - 17 + '0';
120 namelen = 4;
121 break;
122
123 case 27 ... 32:
124 name[0] = 'x';
125 name[1] = 'm';
126 name[2] = 'm';
127 name[3] = '1';
128 name[4] = regno - 27 + '0';
129 namelen = 5;
130 break;
131
132 case 33 ... 40:
133 name[0] = 's';
134 name[1] = 't';
135 name[2] = regno - 33 + '0';
136 namelen = 3;
137 break;
138
139 case 41 ... 48:
140 name[0] = 'm';
141 name[1] = 'm';
142 name[2] = regno - 41 + '0';
143 namelen = 3;
144 break;
Roland McGrath5f6a41a2007-04-01 23:11:40 +0000145
146 case 50 ... 55:
147 name[0] = "ecsdfg"[regno - 50];
148 name[1] = 's';
149 namelen = 2;
150 break;
151
152 case 58 ... 59:
153 *type = DW_ATE_address;
154 *bits = 64;
155 name[0] = regno - 58 + 'f';
156 return stpcpy (&name[1], "s.base") + 1 - name;
157
158 case 49:
Roland McGrathcb6d8652007-08-23 08:10:54 +0000159 *setname = "integer";
Roland McGrath5f6a41a2007-04-01 23:11:40 +0000160 return stpcpy (name, "rflags") + 1 - name;
161 case 62:
162 return stpcpy (name, "tr") + 1 - name;
163 case 63:
164 return stpcpy (name, "ldtr") + 1 - name;
165 case 64:
166 return stpcpy (name, "mxcsr") + 1 - name;
167
168 case 65 ... 66:
Roland McGrath4be15242007-04-25 03:09:33 +0000169 *bits = 16;
Roland McGrath5f6a41a2007-04-01 23:11:40 +0000170 name[0] = 'f';
171 name[1] = "cs"[regno - 65];
172 name[2] = 'w';
173 namelen = 3;
174 break;
175
176 default:
177 return 0;
Roland McGrath994b4892005-12-05 22:46:21 +0000178 }
179
180 name[namelen++] = '\0';
181 return namelen;
182}