Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 1 | /* Register names and numbers for x86-64 DWARF. |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 2 | Copyright (C) 2005, 2006, 2007 Red Hat, Inc. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 3 | This file is part of Red Hat elfutils. |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 4 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 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. |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 8 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 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, |
Ulrich Drepper | 1e9ef50 | 2006-04-04 22:29:06 +0000 | [diff] [blame] | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 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>. */ |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 25 | |
| 26 | #ifdef HAVE_CONFIG_H |
| 27 | # include <config.h> |
| 28 | #endif |
| 29 | |
| 30 | #include <assert.h> |
| 31 | #include <dwarf.h> |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 32 | #include <string.h> |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 33 | |
| 34 | #define BACKEND x86_64_ |
| 35 | #include "libebl_CPU.h" |
| 36 | |
| 37 | ssize_t |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 38 | x86_64_register_info (Ebl *ebl __attribute__ ((unused)), |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 39 | int regno, char *name, size_t namelen, |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 40 | const char **prefix, const char **setname, |
| 41 | int *bits, int *type) |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 42 | { |
| 43 | if (name == NULL) |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 44 | return 67; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 45 | |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 46 | if (regno < 0 || regno > 66 || namelen < 7) |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 47 | return -1; |
| 48 | |
| 49 | *prefix = "%"; |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 50 | *bits = 64; |
| 51 | *type = DW_ATE_unsigned; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 52 | if (regno < 17) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 53 | { |
| 54 | *setname = "integer"; |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 55 | *type = DW_ATE_signed; |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 56 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 57 | else if (regno < 33) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 58 | { |
| 59 | *setname = "SSE"; |
| 60 | *bits = 128; |
| 61 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 62 | else if (regno < 41) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 63 | { |
| 64 | *setname = "x87"; |
| 65 | *type = DW_ATE_float; |
| 66 | *bits = 80; |
| 67 | } |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 68 | else if (regno < 49) |
| 69 | *setname = "MMX"; |
| 70 | else if (regno > 49 && regno < 60) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 71 | { |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 72 | *setname = "segment"; |
| 73 | *bits = 16; |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 74 | } |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 75 | else |
| 76 | *setname = "control"; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 77 | |
| 78 | switch (regno) |
| 79 | { |
| 80 | static const char baseregs[][2] = |
| 81 | { |
| 82 | "ax", "dx", "cx", "bx", "si", "di", "bp", "sp" |
| 83 | }; |
| 84 | |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 85 | case 6 ... 7: |
| 86 | *type = DW_ATE_address; |
| 87 | case 0 ... 5: |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 88 | 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 McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 108 | *type = DW_ATE_address; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 109 | 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 McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 145 | |
| 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 McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 159 | *setname = "integer"; |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 160 | 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 McGrath | 4be1524 | 2007-04-25 03:09:33 +0000 | [diff] [blame] | 169 | *bits = 16; |
Roland McGrath | 5f6a41a | 2007-04-01 23:11:40 +0000 | [diff] [blame] | 170 | 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 McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | name[namelen++] = '\0'; |
| 181 | return namelen; |
| 182 | } |