* c-decl.c, tree-object-size.c, tree-vectorizer.c,
[official-gcc.git] / gcc / config / arm / unwind-arm.h
blob4d86407c73e3f95f4f1dd65c42588d9eaab44105
1 /* Header file for the ARM EABI unwinder
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3 Contributed by Paul Brook
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
17 executable.)
19 This file is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; see the file COPYING. If not, write to
26 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA. */
29 /* Language-independent unwinder header public defines. This contains both
30 ABI defined objects, and GNU support routines. */
32 #ifndef UNWIND_ARM_H
33 #define UNWIND_ARM_H
35 #define __ARM_EABI_UNWINDER__ 1
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 /* We add a prototype for abort here to avoid creating a dependency on
41 target headers. */
42 extern void abort();
44 typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
45 typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
46 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
47 typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
48 typedef _Unwind_Word _uw;
49 typedef unsigned _uw64 __attribute__((mode(__DI__)));
50 typedef unsigned _uw16 __attribute__((mode(__HI__)));
51 typedef unsigned _uw8 __attribute__((mode(__QI__)));
53 typedef enum
55 _URC_OK = 0, /* operation completed successfully */
56 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
57 _URC_HANDLER_FOUND = 6,
58 _URC_INSTALL_CONTEXT = 7,
59 _URC_CONTINUE_UNWIND = 8,
60 _URC_FAILURE = 9 /* unspecified failure of some kind */
62 _Unwind_Reason_Code;
64 typedef enum
66 _US_VIRTUAL_UNWIND_FRAME = 0,
67 _US_UNWIND_FRAME_STARTING = 1,
68 _US_UNWIND_FRAME_RESUME = 2
70 _Unwind_State;
72 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
73 typedef struct _Unwind_Context _Unwind_Context;
74 typedef _uw _Unwind_EHT_Header;
77 /* UCB: */
79 struct _Unwind_Control_Block
81 char exception_class[8];
82 void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
83 /* Unwinder cache, private fields for the unwinder's use */
84 struct
86 _uw reserved1; /* init reserved1 to 0, then don't touch */
87 _uw reserved2;
88 _uw reserved3;
89 _uw reserved4;
90 _uw reserved5;
92 unwinder_cache;
93 /* Propagation barrier cache (valid after phase 1): */
94 struct
96 _uw sp;
97 _uw bitpattern[5];
99 barrier_cache;
100 /* Cleanup cache (preserved over cleanup): */
101 struct
103 _uw bitpattern[4];
105 cleanup_cache;
106 /* Pr cache (for pr's benefit): */
107 struct
109 _uw fnstart; /* function start address */
110 _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
111 _uw additional; /* additional data */
112 _uw reserved1;
114 pr_cache;
115 long long int :0; /* Force alignment to 8-byte boundary */
118 /* Interface functions: */
119 _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
120 void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
121 void _Unwind_Complete(_Unwind_Control_Block *ucbp);
123 /* Virtual Register Set*/
125 typedef enum
127 _UVRSC_CORE = 0, /* integer register */
128 _UVRSC_VFP = 1, /* vfp */
129 _UVRSC_FPA = 2, /* fpa */
130 _UVRSC_WMMXD = 3, /* Intel WMMX data register */
131 _UVRSC_WMMXC = 4 /* Intel WMMX control register */
133 _Unwind_VRS_RegClass;
135 typedef enum
137 _UVRSD_UINT32 = 0,
138 _UVRSD_VFPX = 1,
139 _UVRSD_FPAX = 2,
140 _UVRSD_UINT64 = 3,
141 _UVRSD_FLOAT = 4,
142 _UVRSD_DOUBLE = 5
144 _Unwind_VRS_DataRepresentation;
146 typedef enum
148 _UVRSR_OK = 0,
149 _UVRSR_NOT_IMPLEMENTED = 1,
150 _UVRSR_FAILED = 2
152 _Unwind_VRS_Result;
154 /* Frame unwinding state. */
155 typedef struct
157 /* The current word (bytes packed msb first). */
158 _uw data;
159 /* Pointer to the next word of data. */
160 _uw *next;
161 /* The number of bytes left in this word. */
162 _uw8 bytes_left;
163 /* The number of words pointed to by ptr. */
164 _uw8 words_left;
166 __gnu_unwind_state;
168 typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
169 _Unwind_Control_Block *, _Unwind_Context *);
171 _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
172 _uw, _Unwind_VRS_DataRepresentation,
173 void *);
175 _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
176 _uw, _Unwind_VRS_DataRepresentation,
177 void *);
179 _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
180 _uw, _Unwind_VRS_DataRepresentation);
183 /* Support functions for the PR. */
184 #define _Unwind_Exception _Unwind_Control_Block
185 typedef char _Unwind_Exception_Class[8];
187 void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
188 _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
190 /* These two should never be used */
191 static inline _Unwind_Ptr
192 _Unwind_GetDataRelBase (_Unwind_Context * context __attribute__ ((unused)))
194 abort ();
197 static inline _Unwind_Ptr
198 _Unwind_GetTextRelBase (_Unwind_Context * context __attribute__ ((unused)))
200 abort ();
203 void _Unwind_DeleteException (_Unwind_Exception *);
205 _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
206 _Unwind_Context *);
207 _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
208 __gnu_unwind_state *);
210 /* Decode an R_ARM_TARGET2 relocation. */
211 static inline _Unwind_Word
212 _Unwind_decode_target2 (_Unwind_Word ptr)
214 _Unwind_Word tmp;
216 tmp = *(_Unwind_Word *) ptr;
217 /* Zero values are always NULL. */
218 if (!tmp)
219 return 0;
221 #if defined(linux) || defined(__NetBSD__)
222 /* Pc-relative indirect. */
223 tmp += ptr;
224 tmp = *(_Unwind_Word *) tmp;
225 #elif defined(__symbian__)
226 /* Absolute pointer. Nothing more to do. */
227 #else
228 /* Pc-relative pointer. */
229 tmp += ptr;
230 #endif
231 return tmp;
234 static inline _Unwind_Word
235 _Unwind_GetGR (_Unwind_Context *context, int regno)
237 _uw val;
238 _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
239 return val;
242 /* Return the address of the instruction, not the actual IP value. */
243 #define _Unwind_GetIP(context) \
244 (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
246 static inline void
247 _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
249 _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
252 /* The dwarf unwinder doesn't understand arm/thumb state. We assume the
253 landing pad uses the same instruction set as the call site. */
254 #define _Unwind_SetIP(context, val) \
255 _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
257 /* Provided only for for compatibility with existing code. */
258 typedef int _Unwind_Action;
259 #define _UA_SEARCH_PHASE 1
260 #define _UA_CLEANUP_PHASE 2
261 #define _UA_HANDLER_FRAME 4
262 #define _UA_FORCE_UNWIND 8
263 #define _UA_END_OF_STACK 16
265 #define _URC_NO_REASON _URC_OK
267 #ifdef __cplusplus
268 } /* extern "C" */
269 #endif
271 #endif /* defined UNWIND_ARM_H */