1/* libunwind - a platform-independent unwind library
2   Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
3   Copyright (C) 2013 Linaro Limited
4
5This file is part of libunwind.
6
7Permission is hereby granted, free of charge, to any person obtaining
8a copy of this software and associated documentation files (the
9"Software"), to deal in the Software without restriction, including
10without limitation the rights to use, copy, modify, merge, publish,
11distribute, sublicense, and/or sell copies of the Software, and to
12permit persons to whom the Software is furnished to do so, subject to
13the following conditions:
14
15The above copyright notice and this permission notice shall be
16included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25
26#include "unwind_i.h"
27
28static const char *const regname[] =
29  {
30    [UNW_AARCH64_X0] = "x0",
31    [UNW_AARCH64_X1] = "x1",
32    [UNW_AARCH64_X2] = "x2",
33    [UNW_AARCH64_X3] = "x3",
34    [UNW_AARCH64_X4] = "x4",
35    [UNW_AARCH64_X5] = "x5",
36    [UNW_AARCH64_X6] = "x6",
37    [UNW_AARCH64_X7] = "x7",
38    [UNW_AARCH64_X8] = "x8",
39    [UNW_AARCH64_X9] = "x9",
40    [UNW_AARCH64_X10] = "x10",
41    [UNW_AARCH64_X11] = "x11",
42    [UNW_AARCH64_X12] = "x12",
43    [UNW_AARCH64_X13] = "x13",
44    [UNW_AARCH64_X14] = "x14",
45    [UNW_AARCH64_X15] = "x15",
46    [UNW_AARCH64_X16] = "ip0",
47    [UNW_AARCH64_X17] = "ip1",
48    [UNW_AARCH64_X18] = "x18",
49    [UNW_AARCH64_X19] = "x19",
50    [UNW_AARCH64_X20] = "x20",
51    [UNW_AARCH64_X21] = "x21",
52    [UNW_AARCH64_X22] = "x22",
53    [UNW_AARCH64_X23] = "x23",
54    [UNW_AARCH64_X24] = "x24",
55    [UNW_AARCH64_X25] = "x25",
56    [UNW_AARCH64_X26] = "x26",
57    [UNW_AARCH64_X27] = "x27",
58    [UNW_AARCH64_X28] = "x28",
59    [UNW_AARCH64_X29] = "fp",
60    [UNW_AARCH64_X30] = "lr",
61    [UNW_AARCH64_SP] = "sp",
62    [UNW_AARCH64_PC] = "pc",
63    [UNW_AARCH64_V0] = "v0",
64    [UNW_AARCH64_V1] = "v1",
65    [UNW_AARCH64_V2] = "v2",
66    [UNW_AARCH64_V3] = "v3",
67    [UNW_AARCH64_V4] = "v4",
68    [UNW_AARCH64_V5] = "v5",
69    [UNW_AARCH64_V6] = "v6",
70    [UNW_AARCH64_V7] = "v7",
71    [UNW_AARCH64_V8] = "v8",
72    [UNW_AARCH64_V9] = "v9",
73    [UNW_AARCH64_V10] = "v10",
74    [UNW_AARCH64_V11] = "v11",
75    [UNW_AARCH64_V12] = "v12",
76    [UNW_AARCH64_V13] = "v13",
77    [UNW_AARCH64_V14] = "v14",
78    [UNW_AARCH64_V15] = "v15",
79    [UNW_AARCH64_V16] = "v16",
80    [UNW_AARCH64_V17] = "v17",
81    [UNW_AARCH64_V18] = "v18",
82    [UNW_AARCH64_V19] = "v19",
83    [UNW_AARCH64_V20] = "v20",
84    [UNW_AARCH64_V21] = "v21",
85    [UNW_AARCH64_V22] = "v22",
86    [UNW_AARCH64_V23] = "v23",
87    [UNW_AARCH64_V24] = "v24",
88    [UNW_AARCH64_V25] = "v25",
89    [UNW_AARCH64_V26] = "v26",
90    [UNW_AARCH64_V27] = "v27",
91    [UNW_AARCH64_V28] = "v28",
92    [UNW_AARCH64_V29] = "v29",
93    [UNW_AARCH64_V30] = "v30",
94    [UNW_AARCH64_V31] = "v31",
95    [UNW_AARCH64_FPSR] = "fpsr",
96    [UNW_AARCH64_FPCR] = "fpcr",
97  };
98
99PROTECTED const char *
100unw_regname (unw_regnum_t reg)
101{
102  if (reg < (unw_regnum_t) ARRAY_SIZE (regname) && regname[reg] != NULL)
103    return regname[reg];
104  else
105    return "???";
106}
107