OSDN Git Service

* parse.y (check_static_final_variable_assignment_flag): Fix spelling.
[pf3gnuchains/gcc-fork.git] / gcc / frame.h
1 /* Header file for unwinding stack frames for exception handling.  */
2 /* Compile this one with gcc.  */
3 /* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4    Contributed by Jason Merrill <jason@cygnus.com>.
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23
24 #ifndef DWARF_FRAME_REGISTERS
25 #define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER
26 #endif
27
28 typedef struct frame_state
29 {
30   void *cfa;
31   void *eh_ptr;
32   long cfa_offset;
33   long args_size;
34   long reg_or_offset[DWARF_FRAME_REGISTERS+1];
35   unsigned short cfa_reg;
36   unsigned short retaddr_column;
37   char saved[DWARF_FRAME_REGISTERS+1];
38   long base_offset;
39   char indirect;
40 } frame_state;
41
42 /* Values for 'saved' above.  */
43 #define REG_UNSAVED 0
44 #define REG_SAVED_OFFSET 1
45 #define REG_SAVED_REG 2
46
47 /* The representation for an "object" to be searched for frame unwind info.
48    For targets with named sections, one object is an executable or shared
49    library; for other targets, one object is one translation unit.
50
51    A copy of this structure declaration is printed by collect2.c;
52    keep the copies synchronized!  */
53
54 struct object {
55 #ifdef IA64_UNWIND_INFO
56   void *pc_base;        /* This field will be set by find_fde. */
57 #endif
58   void *pc_begin;
59   void *pc_end;
60   struct dwarf_fde *fde_begin;
61 #ifdef IA64_UNWIND_INFO
62   struct dwarf_fde *fde_end;
63 #endif
64   struct dwarf_fde **fde_array;
65   size_t count;
66   struct object *next;
67 };
68
69 /* Note the following routines are exported interfaces from libgcc; do not
70    change these interfaces.  Instead create new interfaces.  Also note
71    references to these functions may be made weak in files where they
72    are referenced.  */
73
74 extern void __register_frame (void * );
75 extern void __register_frame_table (void *);
76 extern void __deregister_frame (void *);
77
78 /* Called either from crtbegin.o or a static constructor to register the
79    unwind info for an object or translation unit, respectively.  */
80
81 extern void __register_frame_info (void *, struct object *);
82
83 /* Similar, but BEGIN is actually a pointer to a table of unwind entries
84    for different translation units.  Called from the file generated by
85    collect2.  */
86 extern void __register_frame_info_table (void *, struct object *);
87
88 /* Called from crtend.o to deregister the unwind info for an object.  */
89
90 extern void *__deregister_frame_info (void *);
91
92 /* Called from __throw to find the registers to restore for a given
93    PC_TARGET.  The caller should allocate a local variable of `struct
94    frame_state' (declared in frame.h) and pass its address to STATE_IN.
95    Returns NULL on failure, otherwise returns STATE_IN.  */
96
97 extern struct frame_state *__frame_state_for (void *, struct frame_state *);
98
99 #ifdef IA64_UNWIND_INFO
100
101 /* This is the information required for unwind records in an ia64
102    object file. This is required by GAS and the compiler runtime. */
103
104 /* These are the starting point masks for the various types of
105    unwind records. To create a record of type R3 for instance, one
106    starts by using the value UNW_R3 and or-ing in any other required values. 
107    These values are also unique (in context), so they can be used to identify 
108    the various record types as well. UNW_Bx and some UNW_Px do have the
109    same value, but Px can only occur in a prologue context, and Bx in
110    a body context.  */
111
112 #define UNW_R1  0x00
113 #define UNW_R2  0x40
114 #define UNW_R3  0x60
115 #define UNW_P1  0x80
116 #define UNW_P2  0xA0
117 #define UNW_P3  0xB0
118 #define UNW_P4  0xB8
119 #define UNW_P5  0xB9
120 #define UNW_P6  0xC0
121 #define UNW_P7  0xE0
122 #define UNW_P8  0xF0
123 #define UNW_P9  0xF1
124 #define UNW_P10 0xFF
125 #define UNW_X1  0xF9
126 #define UNW_X2  0xFA
127 #define UNW_X3  0xFB
128 #define UNW_X4  0xFC
129 #define UNW_B1  0x80
130 #define UNW_B2  0xC0
131 #define UNW_B3  0xE0
132 #define UNW_B4  0xF0
133
134 /* These are all the various types of unwind records.  */
135
136 typedef enum
137 {
138   prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel,
139   rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel,
140   pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel,
141   fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask,
142   unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel,
143   lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel, 
144   priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel, 
145   priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when,
146   bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr,
147   rnat_psprel, rnat_sprel, epilogue, label_state, copy_state,
148   spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p,
149   spill_reg_p
150 } unw_record_type;
151
152
153 /* These structures declare the fields that can be used in each of the 
154    4 record formats, R, P, B and X.  */
155
156 typedef struct unw_r_record
157 {
158   unsigned long rlen;
159   unsigned short mask;
160   unsigned short grsave;
161 } unw_r_record;
162
163 typedef struct unw_p_record
164 {
165   void *imask;
166   unsigned long t;
167   unsigned long size;
168   unsigned long spoff;
169   unsigned long br;
170   unsigned long pspoff;
171   unsigned short gr;
172   unsigned short rmask;
173   unsigned short grmask;
174   unsigned long frmask;
175   unsigned short brmask;
176 } unw_p_record;
177
178 typedef struct unw_b_record
179 {
180   unsigned long t;
181   unsigned long label;
182   unsigned short ecount;
183 } unw_b_record;
184
185 typedef struct unw_x_record
186 {
187   unsigned long t;
188   unsigned long spoff;
189   unsigned long pspoff;
190   unsigned short reg;
191   unsigned short treg;
192   unsigned short qp;
193   unsigned short xy;   /* Value of the XY field..  */
194 } unw_x_record;
195
196 /* This structure is used to determine the specific record type and 
197    its fields.  */
198 typedef struct unwind_record
199 {
200   unw_record_type type;
201   union {
202     unw_r_record r;
203     unw_p_record p;
204     unw_b_record b;
205     unw_x_record x;
206   } record;
207 } unwind_record;
208
209 #define IA64_UNW_LOC_TYPE_NONE          0
210 #define IA64_UNW_LOC_TYPE_MEM           1
211 #define IA64_UNW_LOC_TYPE_GR            2
212 #define IA64_UNW_LOC_TYPE_FR            3
213 #define IA64_UNW_LOC_TYPE_BR            4
214 #define IA64_UNW_LOC_TYPE_SPOFF         5
215 #define IA64_UNW_LOC_TYPE_PSPOFF        6
216 #define IA64_UNW_LOC_TYPE_OFFSET        7
217 #define IA64_UNW_LOC_TYPE_SPILLBASE     8
218
219 typedef struct ia64_reg_loc 
220 {
221   long when;            /* PC relative offset from start of function. */
222   union {               /* In memory or another register?  */
223     void *mem;
224     int regno;
225     int offset;
226   } l;
227   short loc_type;       /* Where to find value.  */
228   short reg_size;
229 } ia64_reg_loc;
230
231 /* Frame information record.  */
232
233 typedef struct ia64_frame_state
234 {
235   ia64_reg_loc gr[4];   /* gr4 to  gr7.  */
236   ia64_reg_loc fr[20];  /* fr2 to fr5, fr16 to fr31.  */
237   ia64_reg_loc br[5];   /* br1 to  br5.  */
238   ia64_reg_loc rp;
239   ia64_reg_loc fpsr;
240   ia64_reg_loc bsp;
241   ia64_reg_loc bspstore;
242   ia64_reg_loc rnat;
243   ia64_reg_loc pfs;
244   ia64_reg_loc unat;
245   ia64_reg_loc lc;
246   ia64_reg_loc pr;
247   ia64_reg_loc priunat;
248   ia64_reg_loc sp;
249   ia64_reg_loc psp;
250   ia64_reg_loc spill_base;
251   void *my_psp;
252   void *my_sp;
253   void *my_bsp;
254 } ia64_frame_state;
255
256 /* This structure represents the start of an unwind information pointer.  
257    'unwind_descriptors' is the beginninng of the unwind descriptors, which
258    use up 'length' bytes of storage.  */
259
260 typedef struct unwind_info_ptr 
261 {
262   unsigned long header; /* version, flags, & length */
263   unsigned char unwind_descriptors[1];
264 } unwind_info_ptr;
265
266 #define IA64_UNW_HDR_LENGTH(x)  ((x) & 0x00000000ffffffffUL)
267 #define IA64_UNW_HDR_FLAGS(x)   (((x) >> 32) & 0xffffUL)
268 #define IA64_UNW_HDR_VERSION(x) (((x) >> 48) & 0xffffUL)
269
270 /* Header flag bits, after extraction by IA64_UNW_HDR_FLAGS.  */
271 #define IA64_UNW_EHANDLER       0x1
272 #define IA64_UNW_UHANDLER       0x2
273
274 extern unwind_info_ptr *__build_ia64_frame_state (unsigned char *, 
275                                                   ia64_frame_state *,
276                                                   void *, void *,
277                                                   void **);
278 extern void *__get_real_reg_value (ia64_reg_loc *);
279 extern void *__get_personality (unwind_info_ptr *);
280 extern void *__get_except_table (unwind_info_ptr *);
281 extern void __set_real_reg_value (ia64_reg_loc *, void *);
282 void *__calc_caller_bsp (long, unsigned char *);
283 void __copy_saved_reg_state (ia64_frame_state *, ia64_frame_state *);
284 #endif   /* IA64_UNWIND_INFO  */
285