/src/elfutils/backends/csky_regs.c
Line | Count | Source (jump to first uncovered line) |
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 |
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 | 0 | { |
45 | 0 | if (name == NULL) |
46 | 0 | return 38; |
47 | | |
48 | 0 | *prefix = ""; |
49 | 0 | *bits = 32; |
50 | 0 | *type = DW_ATE_signed; |
51 | 0 | *setname = "integer"; |
52 | |
|
53 | 0 | switch (regno) |
54 | 0 | { |
55 | 0 | case 0 ... 9: |
56 | 0 | name[0] = 'r'; |
57 | 0 | name[1] = regno + '0'; |
58 | 0 | namelen = 2; |
59 | 0 | break; |
60 | | |
61 | 0 | case 10 ... 13: |
62 | 0 | case 16 ... 30: |
63 | 0 | name[0] = 'r'; |
64 | 0 | name[1] = regno / 10 + '0'; |
65 | 0 | name[2] = regno % 10 + '0'; |
66 | 0 | namelen = 3; |
67 | 0 | break; |
68 | | |
69 | 0 | case 14: |
70 | 0 | stpcpy (name, "sp"); |
71 | 0 | namelen = 2; |
72 | 0 | break; |
73 | | |
74 | 0 | case 15: |
75 | 0 | stpcpy (name, "lr"); |
76 | 0 | namelen = 2; |
77 | 0 | break; |
78 | | |
79 | 0 | case 31: |
80 | 0 | stpcpy (name, "tls"); |
81 | 0 | namelen = 3; |
82 | 0 | break; |
83 | | |
84 | 0 | case 36: |
85 | 0 | stpcpy (name, "hi"); |
86 | 0 | namelen = 2; |
87 | 0 | break; |
88 | | |
89 | 0 | case 37: |
90 | 0 | stpcpy (name, "lo"); |
91 | 0 | namelen = 2; |
92 | 0 | break; |
93 | | |
94 | 0 | default: |
95 | 0 | *setname = NULL; |
96 | 0 | return 0; |
97 | 0 | } |
98 | | |
99 | 0 | name[namelen++] = '\0'; |
100 | 0 | return namelen; |
101 | 0 | } |