1/* Register names and numbers for ARM DWARF.
2   Copyright (C) 2009 Red Hat, Inc.
3   This file is part of Red Hat elfutils.
4
5   Red Hat elfutils is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by the
7   Free Software Foundation; version 2 of the License.
8
9   Red Hat elfutils is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   General Public License for more details.
13
14   You should have received a copy of the GNU General Public License along
15   with Red Hat elfutils; if not, write to the Free Software Foundation,
16   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
17
18   Red Hat elfutils is an included package of the Open Invention Network.
19   An included package of the Open Invention Network is a package for which
20   Open Invention Network licensees cross-license their patents.  No patent
21   license is granted, either expressly or impliedly, by designation as an
22   included package.  Should you wish to participate in the Open Invention
23   Network licensing program, please visit www.openinventionnetwork.com
24   <http://www.openinventionnetwork.com>.  */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30#include <string.h>
31#include <dwarf.h>
32
33#define BACKEND arm_
34#include "libebl_CPU.h"
35
36ssize_t
37arm_register_info (Ebl *ebl __attribute__ ((unused)),
38		   int regno, char *name, size_t namelen,
39		   const char **prefix, const char **setname,
40		   int *bits, int *type)
41{
42  if (name == NULL)
43    return 320;
44
45  if (regno < 0 || regno > 320 || namelen < 5)
46    return -1;
47
48  *prefix = NULL;
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 ... 12:
62      name[0] = 'r';
63      name[1] = '1';
64      name[2] = regno % 10 + '0';
65      namelen = 3;
66      break;
67
68    case 13 ... 15:
69      *type = DW_ATE_address;
70      name[0] = "slp"[regno - 13];
71      name[1] = "prc"[regno - 13];
72      namelen = 2;
73      break;
74
75    case 16 + 0 ... 16 + 7:
76      regno += 96 - 16;
77      /* Fall through.  */
78    case 96 + 0 ... 96 + 7:
79      *setname = "FPA";
80      *type = DW_ATE_float;
81      *bits = 96;
82      name[0] = 'f';
83      name[1] = regno - 96 + '0';
84      namelen = 2;
85      break;
86
87    case 128:
88      *type = DW_ATE_unsigned;
89      return stpcpy (name, "spsr") + 1 - name;
90
91    case 256 + 0 ... 256 + 9:
92      *setname = "VFP";
93      *type = DW_ATE_float;
94      *bits = 64;
95      name[0] = 'd';
96      name[1] = regno - 256 + '0';
97      namelen = 2;
98      break;
99
100    case 256 + 10 ... 256 + 31:
101      *setname = "VFP";
102      *type = DW_ATE_float;
103      *bits = 64;
104      name[0] = 'd';
105      name[1] = (regno - 256) / 10 + '0';
106      name[2] = (regno - 256) % 10 + '0';
107      namelen = 3;
108      break;
109
110    default:
111      *setname = NULL;
112      return 0;
113    }
114
115  name[namelen++] = '\0';
116  return namelen;
117}
118