1 /* Register names and numbers for C-SKY DWARF.
2 Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
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 csky_
37 #include "libebl_CPU.h"
38
39 ssize_t
csky_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setname,int * bits,int * type)40 csky_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 {
45 if (name == NULL)
46 return 38;
47
48 *prefix = "";
49 *bits = 32;
50 *type = DW_ATE_signed;
51 *setname = "integer";
52
53 switch (regno)
54 {
55 case 0 ... 9:
56 name[0] = 'r';
57 name[1] = regno + '0';
58 namelen = 2;
59 break;
60
61 case 10 ... 13:
62 case 16 ... 30:
63 name[0] = 'r';
64 name[1] = regno / 10 + '0';
65 name[2] = regno % 10 + '0';
66 namelen = 3;
67 break;
68
69 case 14:
70 stpcpy (name, "sp");
71 namelen = 2;
72 break;
73
74 case 15:
75 stpcpy (name, "lr");
76 namelen = 2;
77 break;
78
79 case 31:
80 stpcpy (name, "tls");
81 namelen = 3;
82 break;
83
84 case 36:
85 stpcpy (name, "hi");
86 namelen = 2;
87 break;
88
89 case 37:
90 stpcpy (name, "lo");
91 namelen = 2;
92 break;
93
94 default:
95 *setname = NULL;
96 return 0;
97 }
98
99 name[namelen++] = '\0';
100 return namelen;
101 }
102