Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | /* Register names and numbers for SPARC DWARF. |
| 2 | Copyright (C) 2005, 2006, 2015 Red Hat, Inc. |
| 3 | This file is part of elfutils. |
| 4 | |
| 5 | This file is free software; you can redistribute it and/or modify |
| 6 | it under the terms of either |
| 7 | |
| 8 | * the GNU Lesser General Public License as published by the Free |
| 9 | Software Foundation; either version 3 of the License, or (at |
| 10 | your option) any later version |
| 11 | |
| 12 | or |
| 13 | |
| 14 | * the GNU General Public License as published by the Free |
| 15 | Software Foundation; either version 2 of the License, or (at |
| 16 | your option) any later version |
| 17 | |
| 18 | or both in parallel, as here. |
| 19 | |
| 20 | elfutils is distributed in the hope that it will be useful, but |
| 21 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 | General Public License for more details. |
| 24 | |
| 25 | You should have received copies of the GNU General Public License and |
| 26 | the GNU Lesser General Public License along with this program. If |
| 27 | not, see <http://www.gnu.org/licenses/>. */ |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_H |
| 30 | # include <config.h> |
| 31 | #endif |
| 32 | |
| 33 | #include <string.h> |
| 34 | #include <dwarf.h> |
| 35 | |
| 36 | #define BACKEND sparc_ |
| 37 | #include "libebl_CPU.h" |
| 38 | |
| 39 | ssize_t |
| 40 | sparc_register_info (Ebl *ebl, |
| 41 | int regno, char *name, size_t namelen, |
| 42 | const char **prefix, const char **setname, |
| 43 | int *bits, int *type) |
| 44 | { |
| 45 | const int nfp = 32 + (ebl->class == ELFCLASS32 ? 0 : 16); |
| 46 | const int nspec = ebl->class == ELFCLASS32 ? 8 : 6; |
| 47 | |
| 48 | if (name == NULL) |
| 49 | return 32 + nfp + nspec; |
| 50 | |
| 51 | if (regno < 0 || regno >= 32 + nfp + nspec || namelen < 6) |
| 52 | return -1; |
| 53 | |
| 54 | *bits = ebl->class == ELFCLASS32 ? 32 : 64; |
| 55 | *type = DW_ATE_signed; |
| 56 | |
| 57 | *prefix = "%"; |
| 58 | |
| 59 | if (regno >= 32 + nfp) |
| 60 | { |
| 61 | regno -= 32 + nfp; |
| 62 | static const char names[2][8][6] = |
| 63 | { |
| 64 | { "y", "psr", "wim", "tbr", "pc", "npc", "fsr", "csr" }, /* v8 */ |
| 65 | { "pc", "npc", "state", "fsr", "fprs", "y" } /* v9 */ |
| 66 | }; |
| 67 | *setname = "control"; |
| 68 | *type = DW_ATE_unsigned; |
| 69 | if ((ebl->class == ELFCLASS64 ? 0 : 4) + 1 - (unsigned int) regno <= 1) |
| 70 | *type = DW_ATE_address; |
| 71 | return stpncpy (name, names[ebl->class == ELFCLASS64][regno], |
| 72 | namelen) + 1 - name; |
| 73 | } |
| 74 | |
| 75 | if (regno < 32) |
| 76 | { |
| 77 | *setname = "integer"; |
| 78 | name[0] = "goli"[regno >> 3]; |
| 79 | name[1] = (regno & 7) + '0'; |
| 80 | namelen = 2; |
| 81 | if ((regno & 8) && (regno & 7) == 6) |
| 82 | *type = DW_ATE_address; |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | *setname = "FPU"; |
| 87 | *type = DW_ATE_float; |
| 88 | |
| 89 | regno -= 32; |
| 90 | if (regno >= 32) |
| 91 | regno = 32 + 2 * (regno - 32); |
| 92 | else |
| 93 | *bits = 32; |
| 94 | |
| 95 | name[0] = 'f'; |
| 96 | if (regno < 10) |
| 97 | { |
| 98 | name[1] = regno + '0'; |
| 99 | namelen = 2; |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | name[1] = regno / 10 + '0'; |
| 104 | name[2] = regno % 10 + '0'; |
| 105 | namelen = 3; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | name[namelen++] = '\0'; |
| 110 | return namelen; |
| 111 | } |