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