Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 1 | /* Register names and numbers for i386 DWARF. |
Roland McGrath | 4be1524 | 2007-04-25 03:09:33 +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 <string.h> |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 31 | #include <dwarf.h> |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 32 | |
| 33 | #define BACKEND i386_ |
| 34 | #include "libebl_CPU.h" |
| 35 | |
| 36 | ssize_t |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 37 | i386_register_info (Ebl *ebl __attribute__ ((unused)), |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 38 | int regno, char *name, size_t namelen, |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 39 | const char **prefix, const char **setname, |
| 40 | int *bits, int *type) |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 41 | { |
| 42 | if (name == NULL) |
| 43 | return 46; |
| 44 | |
| 45 | if (regno < 0 || regno > 45 || namelen < 6) |
| 46 | return -1; |
| 47 | |
| 48 | *prefix = "%"; |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 49 | *bits = 32; |
| 50 | *type = DW_ATE_unsigned; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 51 | if (regno < 11) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 52 | { |
| 53 | *setname = "integer"; |
| 54 | if (regno < 9) |
| 55 | *type = DW_ATE_signed; |
| 56 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 57 | else if (regno < 19) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 58 | { |
| 59 | *setname = "x87"; |
| 60 | *type = DW_ATE_float; |
| 61 | *bits = 80; |
| 62 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 63 | else if (regno < 29) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 64 | { |
| 65 | *setname = "SSE"; |
| 66 | *bits = 128; |
| 67 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 68 | else if (regno < 37) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 69 | { |
| 70 | *setname = "MMX"; |
| 71 | *bits = 64; |
| 72 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 73 | else if (regno < 40) |
| 74 | *setname = "FPU-control"; |
| 75 | else |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 76 | { |
| 77 | *setname = "segment"; |
| 78 | *bits = 16; |
| 79 | } |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 80 | |
| 81 | switch (regno) |
| 82 | { |
| 83 | static const char baseregs[][2] = |
| 84 | { |
| 85 | "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip" |
| 86 | }; |
| 87 | |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 88 | case 4: |
| 89 | case 5: |
| 90 | case 8: |
| 91 | *type = DW_ATE_address; |
| 92 | case 0 ... 3: |
| 93 | case 6 ... 7: |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 94 | name[0] = 'e'; |
| 95 | name[1] = baseregs[regno][0]; |
| 96 | name[2] = baseregs[regno][1]; |
| 97 | namelen = 3; |
| 98 | break; |
| 99 | |
| 100 | case 9: |
Roland McGrath | 9502462 | 2006-07-21 10:06:31 +0000 | [diff] [blame] | 101 | return stpcpy (name, "eflags") + 1 - name; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 102 | case 10: |
Roland McGrath | 9502462 | 2006-07-21 10:06:31 +0000 | [diff] [blame] | 103 | return stpcpy (name, "trapno") + 1 - name; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 104 | |
| 105 | case 11 ... 18: |
| 106 | name[0] = 's'; |
| 107 | name[1] = 't'; |
| 108 | name[2] = regno - 11 + '0'; |
| 109 | namelen = 3; |
| 110 | break; |
| 111 | |
| 112 | case 21 ... 28: |
| 113 | name[0] = 'x'; |
| 114 | name[1] = 'm'; |
| 115 | name[2] = 'm'; |
| 116 | name[3] = regno - 21 + '0'; |
| 117 | namelen = 4; |
| 118 | break; |
| 119 | |
| 120 | case 29 ... 36: |
| 121 | name[0] = 'm'; |
| 122 | name[1] = 'm'; |
| 123 | name[2] = regno - 29 + '0'; |
| 124 | namelen = 3; |
| 125 | break; |
| 126 | |
| 127 | case 37: |
Roland McGrath | 4be1524 | 2007-04-25 03:09:33 +0000 | [diff] [blame] | 128 | *bits = 16; |
Roland McGrath | 9502462 | 2006-07-21 10:06:31 +0000 | [diff] [blame] | 129 | return stpcpy (name, "fctrl") + 1 - name; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 130 | case 38: |
Roland McGrath | 4be1524 | 2007-04-25 03:09:33 +0000 | [diff] [blame] | 131 | *bits = 16; |
Roland McGrath | 9502462 | 2006-07-21 10:06:31 +0000 | [diff] [blame] | 132 | return stpcpy (name, "fstat") + 1 - name; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 133 | case 39: |
Roland McGrath | 9502462 | 2006-07-21 10:06:31 +0000 | [diff] [blame] | 134 | return stpcpy (name, "mxcsr") + 1 - name; |
Roland McGrath | 994b489 | 2005-12-05 22:46:21 +0000 | [diff] [blame] | 135 | |
| 136 | case 40 ... 45: |
| 137 | name[0] = "ecsdfg"[regno - 40]; |
| 138 | name[1] = 's'; |
| 139 | namelen = 2; |
| 140 | break; |
| 141 | |
| 142 | default: |
| 143 | *setname = NULL; |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | name[namelen++] = '\0'; |
| 148 | return namelen; |
| 149 | } |