ia64-frame.h 8.2 KB

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