/src/elfutils/backends/sh_regs.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Register names and numbers for SH DWARF. |
2 | | Copyright (C) 2010 Red Hat, Inc. |
3 | | This file is part of elfutils. |
4 | | Contributed by Matt Fleming <matt@console-pimps.org>. |
5 | | |
6 | | This file is free software; you can redistribute it and/or modify |
7 | | it under the terms of either |
8 | | |
9 | | * the GNU Lesser General Public License as published by the Free |
10 | | Software Foundation; either version 3 of the License, or (at |
11 | | your option) any later version |
12 | | |
13 | | or |
14 | | |
15 | | * the GNU General Public License as published by the Free |
16 | | Software Foundation; either version 2 of the License, or (at |
17 | | your option) any later version |
18 | | |
19 | | or both in parallel, as here. |
20 | | |
21 | | elfutils is distributed in the hope that it will be useful, but |
22 | | WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24 | | General Public License for more details. |
25 | | |
26 | | You should have received copies of the GNU General Public License and |
27 | | the GNU Lesser General Public License along with this program. If |
28 | | not, see <http://www.gnu.org/licenses/>. */ |
29 | | |
30 | | #ifdef HAVE_CONFIG_H |
31 | | # include <config.h> |
32 | | #endif |
33 | | |
34 | | #include <assert.h> |
35 | | #include <dwarf.h> |
36 | | #include <string.h> |
37 | | |
38 | | #define BACKEND sh_ |
39 | | #include "libebl_CPU.h" |
40 | | |
41 | | ssize_t |
42 | | sh_register_info (Ebl *ebl __attribute__ ((unused)), |
43 | | int regno, char *name, size_t namelen, |
44 | | const char **prefix, const char **setname, |
45 | | int *bits, int *type) |
46 | 0 | { |
47 | 0 | if (name == NULL) |
48 | 0 | return 104; |
49 | | |
50 | 0 | if (regno < 0 || regno > 103 || namelen < 6) |
51 | 0 | return -1; |
52 | | |
53 | 0 | *prefix = ""; |
54 | 0 | *bits = 32; |
55 | 0 | *type = DW_ATE_signed; |
56 | |
|
57 | 0 | switch (regno) |
58 | 0 | { |
59 | 0 | case 0 ... 9: |
60 | 0 | *setname = "integer"; |
61 | 0 | name[0] = 'r'; |
62 | 0 | name[1] = regno + '0'; |
63 | 0 | namelen = 2; |
64 | 0 | break; |
65 | | |
66 | 0 | case 10 ... 15: |
67 | 0 | *setname = "integer"; |
68 | 0 | name[0] = 'r'; |
69 | 0 | name[1] = '1'; |
70 | 0 | name[2] = regno - 10 + '0'; |
71 | 0 | namelen = 3; |
72 | 0 | break; |
73 | | |
74 | 0 | case 16: |
75 | 0 | *setname = "system"; |
76 | 0 | *type = DW_ATE_address; |
77 | 0 | name[0] = 'p'; |
78 | 0 | name[1] = 'c'; |
79 | 0 | namelen = 2; |
80 | 0 | break; |
81 | | |
82 | 0 | case 17: |
83 | 0 | *setname = "system"; |
84 | 0 | *type = DW_ATE_address; |
85 | 0 | name[0] = 'p'; |
86 | 0 | name[1] = 'r'; |
87 | 0 | namelen = 2; |
88 | 0 | break; |
89 | | |
90 | 0 | case 18: |
91 | 0 | *setname = "control"; |
92 | 0 | *type = DW_ATE_unsigned; |
93 | 0 | name[0] = 's'; |
94 | 0 | name[1] = 'r'; |
95 | 0 | namelen = 2; |
96 | 0 | break; |
97 | | |
98 | 0 | case 19: |
99 | 0 | *setname = "control"; |
100 | 0 | *type = DW_ATE_unsigned; |
101 | 0 | name[0] = 'g'; |
102 | 0 | name[1] = 'b'; |
103 | 0 | name[2] = 'r'; |
104 | 0 | namelen = 3; |
105 | 0 | break; |
106 | | |
107 | 0 | case 20: |
108 | 0 | *setname = "system"; |
109 | 0 | name[0] = 'm'; |
110 | 0 | name[1] = 'a'; |
111 | 0 | name[2] = 'c'; |
112 | 0 | name[3] = 'h'; |
113 | 0 | namelen = 4; |
114 | 0 | break; |
115 | | |
116 | 0 | case 21: |
117 | 0 | *setname = "system"; |
118 | 0 | name[0] = 'm'; |
119 | 0 | name[1] = 'a'; |
120 | 0 | name[2] = 'c'; |
121 | 0 | name[3] = 'l'; |
122 | 0 | namelen = 4; |
123 | |
|
124 | 0 | break; |
125 | | |
126 | 0 | case 23: |
127 | 0 | *setname = "system"; |
128 | 0 | *type = DW_ATE_unsigned; |
129 | 0 | name[0] = 'f'; |
130 | 0 | name[1] = 'p'; |
131 | 0 | name[2] = 'u'; |
132 | 0 | name[3] = 'l'; |
133 | 0 | namelen = 4; |
134 | 0 | break; |
135 | | |
136 | 0 | case 24: |
137 | 0 | *setname = "system"; |
138 | 0 | *type = DW_ATE_unsigned; |
139 | 0 | name[0] = 'f'; |
140 | 0 | name[1] = 'p'; |
141 | 0 | name[2] = 's'; |
142 | 0 | name[3] = 'c'; |
143 | 0 | name[4] = 'r'; |
144 | 0 | namelen = 5; |
145 | 0 | break; |
146 | | |
147 | 0 | case 25 ... 34: |
148 | 0 | *setname = "fpu"; |
149 | 0 | *type = DW_ATE_float; |
150 | 0 | name[0] = 'f'; |
151 | 0 | name[1] = 'r'; |
152 | 0 | name[2] = regno - 25 + '0'; |
153 | 0 | namelen = 3; |
154 | 0 | break; |
155 | | |
156 | 0 | case 35 ... 40: |
157 | 0 | *setname = "fpu"; |
158 | 0 | *type = DW_ATE_float; |
159 | 0 | name[0] = 'f'; |
160 | 0 | name[1] = 'r'; |
161 | 0 | name[2] = '1'; |
162 | 0 | name[3] = regno - 35 + '0'; |
163 | 0 | namelen = 4; |
164 | 0 | break; |
165 | | |
166 | 0 | case 87 ... 96: |
167 | 0 | *type = DW_ATE_float; |
168 | 0 | *setname = "fpu"; |
169 | 0 | name[0] = 'x'; |
170 | 0 | name[1] = 'f'; |
171 | 0 | name[2] = regno - 87 + '0'; |
172 | 0 | namelen = 3; |
173 | 0 | break; |
174 | | |
175 | 0 | case 97 ... 103: |
176 | 0 | *type = DW_ATE_float; |
177 | 0 | *setname = "fpu"; |
178 | 0 | name[0] = 'x'; |
179 | 0 | name[1] = 'f'; |
180 | 0 | name[2] = '1'; |
181 | 0 | name[3] = regno - 97 + '0'; |
182 | 0 | namelen = 4; |
183 | 0 | break; |
184 | | |
185 | 0 | default: |
186 | 0 | return 0; |
187 | 0 | } |
188 | | |
189 | 0 | name[namelen++] = '\0'; |
190 | 0 | return namelen; |
191 | 0 | } |