Ben Cheng | 25b3c04 | 2013-11-20 14:45:36 -0800 | [diff] [blame] | 1 | /* Register names and numbers for Alpha DWARF. |
| 2 | Copyright (C) 2007 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 | #include <dwarf.h> |
| 32 | |
| 33 | #define BACKEND alpha_ |
| 34 | #include "libebl_CPU.h" |
| 35 | |
| 36 | ssize_t |
| 37 | alpha_register_info (Ebl *ebl __attribute__ ((unused)), |
| 38 | int regno, char *name, size_t namelen, |
| 39 | const char **prefix, const char **setname, |
| 40 | int *bits, int *type) |
| 41 | { |
| 42 | if (name == NULL) |
| 43 | return 67; |
| 44 | |
| 45 | if (regno < 0 || regno > 66 || namelen < 7) |
| 46 | return -1; |
| 47 | |
| 48 | *prefix = "$"; |
| 49 | |
| 50 | *bits = 64; |
| 51 | *type = DW_ATE_signed; |
| 52 | *setname = "integer"; |
| 53 | if (regno >= 32 && regno < 64) |
| 54 | { |
| 55 | *setname = "FPU"; |
| 56 | *type = DW_ATE_float; |
| 57 | } |
| 58 | |
| 59 | switch (regno) |
| 60 | { |
| 61 | case 0: |
| 62 | name[0] = 'v'; |
| 63 | name[1] = '0'; |
| 64 | namelen = 2; |
| 65 | break; |
| 66 | |
| 67 | case 1 ... 8: |
| 68 | name[0] = 't'; |
| 69 | name[1] = regno - 1 + '0'; |
| 70 | namelen = 2; |
| 71 | break; |
| 72 | |
| 73 | case 9 ... 15: |
| 74 | name[0] = 's'; |
| 75 | name[1] = regno - 9 + '0'; |
| 76 | namelen = 2; |
| 77 | break; |
| 78 | |
| 79 | case 16 ... 21: |
| 80 | name[0] = 'a'; |
| 81 | name[1] = regno - 16 + '0'; |
| 82 | namelen = 2; |
| 83 | break; |
| 84 | |
| 85 | case 22 ... 23: |
| 86 | name[0] = 't'; |
| 87 | name[1] = regno - 22 + '8'; |
| 88 | namelen = 2; |
| 89 | break; |
| 90 | |
| 91 | case 24 ... 25: |
| 92 | name[0] = 't'; |
| 93 | name[1] = '1'; |
| 94 | name[2] = regno - 24 + '0'; |
| 95 | namelen = 3; |
| 96 | break; |
| 97 | |
| 98 | case 26: |
| 99 | *type = DW_ATE_address; |
| 100 | return stpcpy (name, "ra") + 1 - name; |
| 101 | |
| 102 | case 27: |
| 103 | return stpcpy (name, "t12") + 1 - name; |
| 104 | |
| 105 | case 28: |
| 106 | return stpcpy (name, "at") + 1 - name; |
| 107 | |
| 108 | case 29: |
| 109 | *type = DW_ATE_address; |
| 110 | return stpcpy (name, "gp") + 1 - name; |
| 111 | |
| 112 | case 30: |
| 113 | *type = DW_ATE_address; |
| 114 | return stpcpy (name, "sp") + 1 - name; |
| 115 | |
| 116 | case 31: |
| 117 | return stpcpy (name, "zero") + 1 - name; |
| 118 | |
| 119 | case 32 ... 32 + 9: |
| 120 | name[0] = 'f'; |
| 121 | name[1] = regno - 32 + '0'; |
| 122 | namelen = 2; |
| 123 | break; |
| 124 | |
| 125 | case 32 + 10 ... 32 + 19: |
| 126 | name[0] = 'f'; |
| 127 | name[1] = '1'; |
| 128 | name[2] = regno - 32 - 10 + '0'; |
| 129 | namelen = 3; |
| 130 | break; |
| 131 | |
| 132 | case 32 + 20 ... 32 + 29: |
| 133 | name[0] = 'f'; |
| 134 | name[1] = '2'; |
| 135 | name[2] = regno - 32 - 20 + '0'; |
| 136 | namelen = 3; |
| 137 | break; |
| 138 | |
| 139 | case 32 + 30: |
| 140 | return stpcpy (name, "f30") + 1 - name; |
| 141 | |
| 142 | case 32 + 31: |
| 143 | *type = DW_ATE_unsigned; |
| 144 | return stpcpy (name, "fpcr") + 1 - name; |
| 145 | |
| 146 | case 64: |
| 147 | *type = DW_ATE_address; |
| 148 | return stpcpy (name, "pc") + 1 - name; |
| 149 | |
| 150 | case 66: |
| 151 | *type = DW_ATE_address; |
| 152 | return stpcpy (name, "unique") + 1 - name; |
| 153 | |
| 154 | default: |
| 155 | *setname = NULL; |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | name[namelen++] = '\0'; |
| 160 | return namelen; |
| 161 | } |