]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/tools/gdb_regofs/ia64.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / tools / gdb_regofs / ia64.c
1 /*
2  * Copyright (c) 2004 Marcel Moolenaar
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <stddef.h>
31 #include <machine/reg.h>
32
33 #define PRESERVED(x)    offsetof(struct reg, r_preserved)       \
34                         + offsetof(struct _callee_saved, x)
35 #define SCRATCH(x)      offsetof(struct reg, r_scratch)         \
36                         + offsetof(struct _caller_saved, x)
37 #define SPECIAL(x)      offsetof(struct reg, r_special)         \
38                         + offsetof(struct _special, x)
39
40 #define HIGH_FP(x)      offsetof(struct fpreg, fpr_high)        \
41                         + offsetof(struct _high_fp, x)
42 #define PRESERVED_FP(x) offsetof(struct fpreg, fpr_preserved)   \
43                         + offsetof(struct _callee_saved_fp, x)
44 #define SCRATCH_FP(x)   offsetof(struct fpreg, fpr_scratch)     \
45                         + offsetof(struct _caller_saved_fp, x)
46
47 static int regofs[] = {
48         /*
49          * General registers (0-127)
50          */
51         -1,             /* gr0 */
52         SPECIAL(gp),
53         SCRATCH(gr2),   SCRATCH(gr3),
54         PRESERVED(gr4), PRESERVED(gr5), PRESERVED(gr6), PRESERVED(gr7),
55         SCRATCH(gr8),   SCRATCH(gr9),   SCRATCH(gr10),  SCRATCH(gr11),
56         SPECIAL(sp),    SPECIAL(tp),
57         SCRATCH(gr14),  SCRATCH(gr15),  SCRATCH(gr16),  SCRATCH(gr17),
58         SCRATCH(gr18),  SCRATCH(gr19),  SCRATCH(gr20),  SCRATCH(gr21),
59         SCRATCH(gr22),  SCRATCH(gr23),  SCRATCH(gr24),  SCRATCH(gr25),
60         SCRATCH(gr26),  SCRATCH(gr27),  SCRATCH(gr28),  SCRATCH(gr29),
61         SCRATCH(gr30),  SCRATCH(gr31),
62         /*
63          * gr32 through gr127 are not directly available as they are
64          * stacked registers.
65          */
66         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr32-gr39 */
67         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr40-gr47 */
68         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr48-gr55 */
69         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr56-gr63 */
70         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr64-gr71 */
71         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr72-gr79 */
72         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr80-gr87 */
73         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr88-gr95 */
74         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr96-gr103 */
75         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr104-gr111 */
76         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr112-gr119 */
77         -1, -1, -1, -1, -1, -1, -1, -1,         /* gr120-gr127 */
78         /*
79          * Floating-point registers (128-255)
80          */
81         -1,             /* fr0: constant 0.0 */
82         -1,             /* fr1: constant 1.0 */
83         PRESERVED_FP(fr2),      PRESERVED_FP(fr3),
84         PRESERVED_FP(fr4),      PRESERVED_FP(fr5),
85         SCRATCH_FP(fr6),        SCRATCH_FP(fr7),
86         SCRATCH_FP(fr8),        SCRATCH_FP(fr9),
87         SCRATCH_FP(fr10),       SCRATCH_FP(fr11),
88         SCRATCH_FP(fr12),       SCRATCH_FP(fr13),
89         SCRATCH_FP(fr14),       SCRATCH_FP(fr15),
90         PRESERVED_FP(fr16),     PRESERVED_FP(fr17),
91         PRESERVED_FP(fr18),     PRESERVED_FP(fr19),
92         PRESERVED_FP(fr20),     PRESERVED_FP(fr21),
93         PRESERVED_FP(fr22),     PRESERVED_FP(fr23),
94         PRESERVED_FP(fr24),     PRESERVED_FP(fr25),
95         PRESERVED_FP(fr26),     PRESERVED_FP(fr27),
96         PRESERVED_FP(fr28),     PRESERVED_FP(fr29),
97         PRESERVED_FP(fr30),     PRESERVED_FP(fr31),
98         HIGH_FP(fr32),  HIGH_FP(fr33),  HIGH_FP(fr34),  HIGH_FP(fr35),
99         HIGH_FP(fr36),  HIGH_FP(fr37),  HIGH_FP(fr38),  HIGH_FP(fr39),
100         HIGH_FP(fr40),  HIGH_FP(fr41),  HIGH_FP(fr42),  HIGH_FP(fr43),
101         HIGH_FP(fr44),  HIGH_FP(fr45),  HIGH_FP(fr46),  HIGH_FP(fr47),
102         HIGH_FP(fr48),  HIGH_FP(fr49),  HIGH_FP(fr50),  HIGH_FP(fr51),
103         HIGH_FP(fr52),  HIGH_FP(fr53),  HIGH_FP(fr54),  HIGH_FP(fr55),
104         HIGH_FP(fr56),  HIGH_FP(fr57),  HIGH_FP(fr58),  HIGH_FP(fr59),
105         HIGH_FP(fr60),  HIGH_FP(fr61),  HIGH_FP(fr62),  HIGH_FP(fr63),
106         HIGH_FP(fr64),  HIGH_FP(fr65),  HIGH_FP(fr66),  HIGH_FP(fr67),
107         HIGH_FP(fr68),  HIGH_FP(fr69),  HIGH_FP(fr70),  HIGH_FP(fr71),
108         HIGH_FP(fr72),  HIGH_FP(fr73),  HIGH_FP(fr74),  HIGH_FP(fr75),
109         HIGH_FP(fr76),  HIGH_FP(fr77),  HIGH_FP(fr78),  HIGH_FP(fr79),
110         HIGH_FP(fr80),  HIGH_FP(fr81),  HIGH_FP(fr82),  HIGH_FP(fr83),
111         HIGH_FP(fr84),  HIGH_FP(fr85),  HIGH_FP(fr86),  HIGH_FP(fr87),
112         HIGH_FP(fr88),  HIGH_FP(fr89),  HIGH_FP(fr90),  HIGH_FP(fr91),
113         HIGH_FP(fr92),  HIGH_FP(fr93),  HIGH_FP(fr94),  HIGH_FP(fr95),
114         HIGH_FP(fr96),  HIGH_FP(fr97),  HIGH_FP(fr98),  HIGH_FP(fr99),
115         HIGH_FP(fr100), HIGH_FP(fr101), HIGH_FP(fr102), HIGH_FP(fr103),
116         HIGH_FP(fr104), HIGH_FP(fr105), HIGH_FP(fr106), HIGH_FP(fr107),
117         HIGH_FP(fr108), HIGH_FP(fr109), HIGH_FP(fr110), HIGH_FP(fr111),
118         HIGH_FP(fr112), HIGH_FP(fr113), HIGH_FP(fr114), HIGH_FP(fr115),
119         HIGH_FP(fr116), HIGH_FP(fr117), HIGH_FP(fr118), HIGH_FP(fr119),
120         HIGH_FP(fr120), HIGH_FP(fr121), HIGH_FP(fr122), HIGH_FP(fr123),
121         HIGH_FP(fr124), HIGH_FP(fr125), HIGH_FP(fr126), HIGH_FP(fr127),
122         /*
123          * Predicate registers (256-319)
124          * These are not individually available. Predicates are
125          * in the pr register.
126          */
127         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr0-pr7 */
128         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr8-pr15 */
129         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr16-pr23 */
130         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr24-pr31 */
131         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr32-pr39 */
132         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr40-pr47 */
133         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr48-pr55 */
134         -1, -1, -1, -1, -1, -1, -1, -1,         /* pr56-pr63 */
135         /*
136          * Branch registers (320-327)
137          */
138         SPECIAL(rp),
139         PRESERVED(br1), PRESERVED(br2), PRESERVED(br3), PRESERVED(br4),
140         PRESERVED(br5),
141         SCRATCH(br6),   SCRATCH(br7),
142         /*
143          * Misc other registers (328-333)
144          */
145         -1, -1,
146         SPECIAL(pr),
147         SPECIAL(iip),
148         SPECIAL(psr),
149         SPECIAL(cfm),
150         /*
151          * Application registers (334-461)
152          */
153         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar.k0-ar.k7 */
154         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar8-ar15 (reserved) */
155         SPECIAL(rsc),                           /* ar.rsc */
156         SPECIAL(ndirty),                        /* ar.bsp !!YEDI!! */
157         SPECIAL(bspstore),                      /* ar.bspstore */
158         SPECIAL(rnat),                          /* ar.rnat */
159         -1,                                     /* ar20 (reserved) */
160         -1,                                     /* ar.fcr */
161         -1, -1,                                 /* ar22-ar23 (reserved) */
162         -1,                                     /* ar.eflag */
163         SCRATCH(csd),                           /* ar.csd */
164         SCRATCH(ssd),                           /* ar.ssd */
165         -1,                                     /* ar.cflg */
166         -1,                                     /* ar.fsr */
167         -1,                                     /* ar.fir */
168         -1,                                     /* ar.fdr */
169         -1,                                     /* ar31 (reserved) */
170         SCRATCH(ccv),                           /* ar.ccv */
171         -1, -1, -1,                             /* ar33-ar35 (reserved) */
172         SPECIAL(unat),                          /* ar.unat */
173         -1, -1, -1,                             /* ar37-ar39 (reserved) */
174         SPECIAL(fpsr),                          /* ar.fpsr */
175         -1, -1, -1,                             /* ar41-ar43 (reserved) */
176         -1,                                     /* ar.itc */
177         -1, -1, -1,                             /* ar45-ar47 (reserved) */
178         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar48-ar55 (ignored) */
179         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar56-ar63 (ignored) */
180         SPECIAL(pfs),                           /* ar.pfs */
181         PRESERVED(lc),                          /* ar.lc */
182         -1,                                     /* ar.ec */
183         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar67-ar74 (reserved) */
184         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar75-ar82 (reserved) */
185         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar83-ar90 (reserved) */
186         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar91-ar98 (reserved) */
187         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar99-ar106 (reserved) */
188         -1, -1, -1, -1, -1,                     /* ar107-ar111 (reserved) */
189         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar112-ar119 (ignored) */
190         -1, -1, -1, -1, -1, -1, -1, -1,         /* ar120-ar127 (ignored) */
191 };
192
193 int
194 main()
195 {
196         int elem, nelems;
197
198         nelems = sizeof(regofs)/sizeof(regofs[0]);
199         printf("static int reg_offset[%d] = {", nelems);
200         for (elem = 0; elem < nelems; elem++) {
201                 if ((elem & 7) == 0)
202                         printf("\n  ");
203                 printf("%4d", regofs[elem]);
204                 if (elem < nelems - 1)
205                         putchar(',');
206                 if ((elem & 7) != 7)
207                         putchar(' ');
208                 else
209                         printf("\t/* Regs %d-%d. */", elem - 7, elem);
210         }
211         printf("\n};");
212         return (0);
213 }