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
sh_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setname,int * bits,int * type)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 {
47   if (name == NULL)
48     return 104;
49 
50   if (regno < 0 || regno > 103 || namelen < 6)
51     return -1;
52 
53   *prefix = "";
54   *bits = 32;
55   *type = DW_ATE_signed;
56 
57   switch (regno)
58     {
59     case 0 ... 9:
60       *setname = "integer";
61       name[0] = 'r';
62       name[1] = regno + '0';
63       namelen = 2;
64       break;
65 
66     case 10 ... 15:
67       *setname = "integer";
68       name[0] = 'r';
69       name[1] = '1';
70       name[2] = regno - 10 + '0';
71       namelen = 3;
72       break;
73 
74     case 16:
75       *setname = "system";
76       *type = DW_ATE_address;
77       name[0] = 'p';
78       name[1] = 'c';
79       namelen = 2;
80       break;
81 
82     case 17:
83       *setname = "system";
84       *type = DW_ATE_address;
85       name[0] = 'p';
86       name[1] = 'r';
87       namelen = 2;
88       break;
89 
90     case 18:
91       *setname = "control";
92       *type = DW_ATE_unsigned;
93       name[0] = 's';
94       name[1] = 'r';
95       namelen = 2;
96       break;
97 
98     case 19:
99       *setname = "control";
100       *type = DW_ATE_unsigned;
101       name[0] = 'g';
102       name[1] = 'b';
103       name[2] = 'r';
104       namelen = 3;
105       break;
106 
107     case 20:
108       *setname = "system";
109       name[0] = 'm';
110       name[1] = 'a';
111       name[2] = 'c';
112       name[3] = 'h';
113       namelen = 4;
114       break;
115 
116     case 21:
117       *setname = "system";
118       name[0] = 'm';
119       name[1] = 'a';
120       name[2] = 'c';
121       name[3] = 'l';
122       namelen = 4;
123 
124       break;
125 
126     case 23:
127       *setname = "system";
128       *type = DW_ATE_unsigned;
129       name[0] = 'f';
130       name[1] = 'p';
131       name[2] = 'u';
132       name[3] = 'l';
133       namelen = 4;
134       break;
135 
136     case 24:
137       *setname = "system";
138       *type = DW_ATE_unsigned;
139       name[0] = 'f';
140       name[1] = 'p';
141       name[2] = 's';
142       name[3] = 'c';
143       name[4] = 'r';
144       namelen = 5;
145       break;
146 
147     case 25 ... 34:
148       *setname = "fpu";
149       *type = DW_ATE_float;
150       name[0] = 'f';
151       name[1] = 'r';
152       name[2] = regno - 25 + '0';
153       namelen = 3;
154       break;
155 
156     case 35 ... 40:
157       *setname = "fpu";
158       *type = DW_ATE_float;
159       name[0] = 'f';
160       name[1] = 'r';
161       name[2] = '1';
162       name[3] = regno - 35 + '0';
163       namelen = 4;
164       break;
165 
166     case 87 ... 96:
167       *type = DW_ATE_float;
168       *setname = "fpu";
169       name[0] = 'x';
170       name[1] = 'f';
171       name[2] = regno - 87 + '0';
172       namelen = 3;
173       break;
174 
175     case 97 ... 103:
176       *type = DW_ATE_float;
177       *setname = "fpu";
178       name[0] = 'x';
179       name[1] = 'f';
180       name[2] = '1';
181       name[3] = regno - 97 + '0';
182       namelen = 4;
183       break;
184 
185     default:
186       return 0;
187     }
188 
189   name[namelen++] = '\0';
190   return namelen;
191 }
192