/src/elfutils/backends/ppc_regs.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Register names and numbers for PowerPC DWARF. |
2 | | Copyright (C) 2005, 2006, 2007 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 ppc_ |
37 | | #include "libebl_CPU.h" |
38 | | |
39 | | ssize_t |
40 | | ppc_register_info (Ebl *ebl __attribute__ ((unused)), |
41 | | int regno, char *name, size_t namelen, |
42 | | const char **prefix, const char **setname, |
43 | | int *bits, int *type) |
44 | 0 | { |
45 | 0 | if (name == NULL) |
46 | 0 | return 1156; |
47 | | |
48 | 0 | if (regno < 0 || regno > 1155 || namelen < 8) |
49 | 0 | return -1; |
50 | | |
51 | 0 | *prefix = ""; |
52 | 0 | *bits = ebl->machine == EM_PPC64 ? 64 : 32; |
53 | 0 | *type = (regno < 32 ? DW_ATE_signed |
54 | 0 | : regno < 64 ? DW_ATE_float : DW_ATE_unsigned); |
55 | |
|
56 | 0 | if (regno < 32 || regno == 64 || regno == 66) |
57 | 0 | *setname = "integer"; |
58 | 0 | else if (regno < 64 || regno == 65) |
59 | 0 | { |
60 | 0 | *setname = "FPU"; |
61 | 0 | if (ebl->machine != EM_PPC64 && regno < 64) |
62 | 0 | *bits = 64; |
63 | 0 | } |
64 | 0 | else if (regno == 67 || regno == 356 || regno == 612 || regno >= 1124) |
65 | 0 | { |
66 | 0 | *setname = "vector"; |
67 | 0 | *bits = regno >= 1124 ? 128 : 32; |
68 | 0 | } |
69 | 0 | else |
70 | 0 | *setname = "privileged"; |
71 | |
|
72 | 0 | switch (regno) |
73 | 0 | { |
74 | 0 | case 0 ... 9: |
75 | 0 | name[0] = 'r'; |
76 | 0 | name[1] = regno + '0'; |
77 | 0 | namelen = 2; |
78 | 0 | break; |
79 | | |
80 | 0 | case 10 ... 31: |
81 | 0 | name[0] = 'r'; |
82 | 0 | name[1] = regno / 10 + '0'; |
83 | 0 | name[2] = regno % 10 + '0'; |
84 | 0 | namelen = 3; |
85 | 0 | break; |
86 | | |
87 | 0 | case 32 + 0 ... 32 + 9: |
88 | 0 | name[0] = 'f'; |
89 | 0 | name[1] = (regno - 32) + '0'; |
90 | 0 | namelen = 2; |
91 | 0 | break; |
92 | | |
93 | 0 | case 32 + 10 ... 32 + 31: |
94 | 0 | name[0] = 'f'; |
95 | 0 | name[1] = (regno - 32) / 10 + '0'; |
96 | 0 | name[2] = (regno - 32) % 10 + '0'; |
97 | 0 | namelen = 3; |
98 | 0 | break; |
99 | | |
100 | 0 | case 64: |
101 | 0 | return stpcpy (name, "cr") + 1 - name; |
102 | 0 | case 65: |
103 | 0 | return stpcpy (name, "fpscr") + 1 - name; |
104 | 0 | case 66: |
105 | 0 | return stpcpy (name, "msr") + 1 - name; |
106 | 0 | case 67: /* XXX unofficial assignment */ |
107 | 0 | return stpcpy (name, "vscr") + 1 - name; |
108 | | |
109 | 0 | case 70 + 0 ... 70 + 9: |
110 | 0 | name[0] = 's'; |
111 | 0 | name[1] = 'r'; |
112 | 0 | name[2] = (regno - 70) + '0'; |
113 | 0 | namelen = 3; |
114 | 0 | break; |
115 | | |
116 | 0 | case 70 + 10 ... 70 + 15: |
117 | 0 | name[0] = 's'; |
118 | 0 | name[1] = 'r'; |
119 | 0 | name[2] = (regno - 70) / 10 + '0'; |
120 | 0 | name[3] = (regno - 70) % 10 + '0'; |
121 | 0 | namelen = 4; |
122 | 0 | break; |
123 | | |
124 | 0 | case 101: |
125 | 0 | return stpcpy (name, "xer") + 1 - name; |
126 | 0 | case 108: |
127 | 0 | return stpcpy (name, "lr") + 1 - name; |
128 | 0 | case 109: |
129 | 0 | return stpcpy (name, "ctr") + 1 - name; |
130 | 0 | case 118: |
131 | 0 | return stpcpy (name, "dsisr") + 1 - name; |
132 | 0 | case 119: |
133 | 0 | return stpcpy (name, "dar") + 1 - name; |
134 | 0 | case 122: |
135 | 0 | return stpcpy (name, "dec") + 1 - name; |
136 | 0 | case 356: |
137 | 0 | return stpcpy (name, "vrsave") + 1 - name; |
138 | 0 | case 612: |
139 | 0 | return stpcpy (name, "spefscr") + 1 - name; |
140 | 0 | case 100: |
141 | 0 | if (*bits == 32) |
142 | 0 | return stpcpy (name, "mq") + 1 - name; |
143 | 0 | FALLTHROUGH; |
144 | 0 | case 102 ... 107: |
145 | 0 | name[0] = 's'; |
146 | 0 | name[1] = 'p'; |
147 | 0 | name[2] = 'r'; |
148 | 0 | name[3] = (regno - 100) + '0'; |
149 | 0 | namelen = 4; |
150 | 0 | break; |
151 | | |
152 | 0 | case 114: |
153 | 0 | return stpcpy (name, "tfhar") + 1 - name; |
154 | 0 | case 115: |
155 | 0 | return stpcpy (name, "tfiar") + 1 - name; |
156 | 0 | case 116: |
157 | 0 | return stpcpy (name, "texasr") + 1 - name; |
158 | | |
159 | 0 | case 110 ... 113: |
160 | 0 | case 117: |
161 | 0 | case 120 ... 121: |
162 | 0 | case 123 ... 199: |
163 | 0 | name[0] = 's'; |
164 | 0 | name[1] = 'p'; |
165 | 0 | name[2] = 'r'; |
166 | 0 | name[3] = (regno - 100) / 10 + '0'; |
167 | 0 | name[4] = (regno - 100) % 10 + '0'; |
168 | 0 | namelen = 5; |
169 | 0 | break; |
170 | | |
171 | 0 | case 200 ... 355: |
172 | 0 | case 357 ... 611: |
173 | 0 | case 613 ... 999: |
174 | 0 | name[0] = 's'; |
175 | 0 | name[1] = 'p'; |
176 | 0 | name[2] = 'r'; |
177 | 0 | name[3] = (regno - 100) / 100 + '0'; |
178 | 0 | name[4] = ((regno - 100) % 100 / 10) + '0'; |
179 | 0 | name[5] = (regno - 100) % 10 + '0'; |
180 | 0 | namelen = 6; |
181 | 0 | break; |
182 | | |
183 | 0 | case 1124 + 0 ... 1124 + 9: |
184 | 0 | name[0] = 'v'; |
185 | 0 | name[1] = 'r'; |
186 | 0 | name[2] = (regno - 1124) + '0'; |
187 | 0 | namelen = 3; |
188 | 0 | break; |
189 | | |
190 | 0 | case 1124 + 10 ... 1124 + 31: |
191 | 0 | name[0] = 'v'; |
192 | 0 | name[1] = 'r'; |
193 | 0 | name[2] = (regno - 1124) / 10 + '0'; |
194 | 0 | name[3] = (regno - 1124) % 10 + '0'; |
195 | 0 | namelen = 4; |
196 | 0 | break; |
197 | | |
198 | 0 | default: |
199 | 0 | *setname = NULL; |
200 | 0 | return 0; |
201 | 0 | } |
202 | | |
203 | 0 | name[namelen++] = '\0'; |
204 | 0 | return namelen; |
205 | 0 | } |
206 | | |
207 | | __typeof (ppc_register_info) |
208 | | ppc64_register_info __attribute__ ((alias ("ppc_register_info"))); |