Ben Cheng | 25b3c04 | 2013-11-20 14:45:36 -0800 | [diff] [blame] | 1 | /* Register names and numbers for S/390 DWARF. |
| 2 | Copyright (C) 2006 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 s390_ |
| 34 | #include "libebl_CPU.h" |
| 35 | |
| 36 | |
| 37 | /* |
| 38 | zseries (64) |
| 39 | |
| 40 | 0-15 gpr0-gpr15 x |
| 41 | 16-19 fpr[0246] |
| 42 | 20-24 fpr[13578] |
| 43 | 25-27 fpr1[024] |
| 44 | 28 fpr9 |
| 45 | 29-31 fpr1[135] |
| 46 | 32-47 cr0-cr15 x |
| 47 | 48-63 ar0-ar15 x |
| 48 | 64 psw_mask |
| 49 | 65 psw_address |
| 50 | */ |
| 51 | |
| 52 | |
| 53 | ssize_t |
| 54 | s390_register_info (Ebl *ebl __attribute__ ((unused)), |
| 55 | int regno, char *name, size_t namelen, |
| 56 | const char **prefix, const char **setname, |
| 57 | int *bits, int *type) |
| 58 | { |
| 59 | if (name == NULL) |
| 60 | return 66; |
| 61 | |
| 62 | if (regno < 0 || regno > 65 || namelen < 7) |
| 63 | return -1; |
| 64 | |
| 65 | *prefix = "%"; |
| 66 | |
| 67 | *bits = ebl->class == ELFCLASS64 ? 64 : 32; |
| 68 | *type = DW_ATE_unsigned; |
| 69 | if (regno < 16) |
| 70 | { |
| 71 | *setname = "integer"; |
| 72 | *type = DW_ATE_signed; |
| 73 | } |
| 74 | else if (regno < 32) |
| 75 | { |
| 76 | *setname = "FPU"; |
| 77 | *type = DW_ATE_float; |
| 78 | *bits = 64; |
| 79 | } |
| 80 | else if (regno < 48 || regno > 63) |
| 81 | *setname = "control"; |
| 82 | else |
| 83 | { |
| 84 | *setname = "access"; |
| 85 | *bits = 32; |
| 86 | } |
| 87 | |
| 88 | switch (regno) |
| 89 | { |
| 90 | case 0 ... 9: |
| 91 | name[0] = 'r'; |
| 92 | name[1] = regno + '0'; |
| 93 | namelen = 2; |
| 94 | break; |
| 95 | |
| 96 | case 10 ... 15: |
| 97 | name[0] = 'r'; |
| 98 | name[1] = '1'; |
| 99 | name[2] = regno - 10 + '0'; |
| 100 | namelen = 3; |
| 101 | break; |
| 102 | |
| 103 | case 16 ... 31: |
| 104 | name[0] = 'f'; |
| 105 | regno = (regno & 8) | ((regno & 4) >> 2) | ((regno & 3) << 1); |
| 106 | namelen = 1; |
| 107 | if (regno >= 10) |
| 108 | { |
| 109 | regno -= 10; |
| 110 | name[namelen++] = '1'; |
| 111 | } |
| 112 | name[namelen++] = regno + '0'; |
| 113 | break; |
| 114 | |
| 115 | case 32 + 0 ... 32 + 9: |
| 116 | case 48 + 0 ... 48 + 9: |
| 117 | name[0] = regno < 48 ? 'c' : 'a'; |
| 118 | name[1] = (regno & 15) + '0'; |
| 119 | namelen = 2; |
| 120 | break; |
| 121 | |
| 122 | case 32 + 10 ... 32 + 15: |
| 123 | case 48 + 10 ... 48 + 15: |
| 124 | name[0] = regno < 48 ? 'c' : 'a'; |
| 125 | name[1] = '1'; |
| 126 | name[2] = (regno & 15) - 10 + '0'; |
| 127 | namelen = 3; |
| 128 | break; |
| 129 | |
| 130 | case 64: |
| 131 | return stpcpy (name, "pswm") + 1 - name; |
| 132 | case 65: |
| 133 | *type = DW_ATE_address; |
| 134 | return stpcpy (name, "pswa") + 1 - name; |
| 135 | |
| 136 | default: |
| 137 | *setname = NULL; |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | name[namelen++] = '\0'; |
| 142 | return namelen; |
| 143 | } |