OSDN Git Service

dwarf2out: Move insn scanning out of final.c.
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.h
1 /* dwarf2out.h - Various declarations for functions found in dwarf2out.c
2    Copyright (C) 1998, 1999, 2000, 2003, 2007, 2010, 2011
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3.  If not see
19 <http://www.gnu.org/licenses/>.  */
20
21 #ifndef GCC_DWARF2OUT_H
22 #define GCC_DWARF2OUT_H 1
23
24 #include "dwarf2.h"     /* ??? Remove this once only used by dwarf2foo.c.  */
25
26 typedef struct die_struct *dw_die_ref;
27 typedef const struct die_struct *const_dw_die_ref;
28
29 typedef struct dw_val_struct *dw_val_ref;
30 typedef struct dw_cfi_struct *dw_cfi_ref;
31 typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
32 typedef struct dw_loc_list_struct *dw_loc_list_ref;
33
34
35 /* Call frames are described using a sequence of Call Frame
36    Information instructions.  The register number, offset
37    and address fields are provided as possible operands;
38    their use is selected by the opcode field.  */
39
40 enum dw_cfi_oprnd_type {
41   dw_cfi_oprnd_unused,
42   dw_cfi_oprnd_reg_num,
43   dw_cfi_oprnd_offset,
44   dw_cfi_oprnd_addr,
45   dw_cfi_oprnd_loc
46 };
47
48 typedef union GTY(()) dw_cfi_oprnd_struct {
49   unsigned int GTY ((tag ("dw_cfi_oprnd_reg_num"))) dw_cfi_reg_num;
50   HOST_WIDE_INT GTY ((tag ("dw_cfi_oprnd_offset"))) dw_cfi_offset;
51   const char * GTY ((tag ("dw_cfi_oprnd_addr"))) dw_cfi_addr;
52   struct dw_loc_descr_struct * GTY ((tag ("dw_cfi_oprnd_loc"))) dw_cfi_loc;
53 }
54 dw_cfi_oprnd;
55
56 typedef struct GTY(()) dw_cfi_struct {
57   enum dwarf_call_frame_info dw_cfi_opc;
58   dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd1_desc (%1.dw_cfi_opc)")))
59     dw_cfi_oprnd1;
60   dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd2_desc (%1.dw_cfi_opc)")))
61     dw_cfi_oprnd2;
62 }
63 dw_cfi_node;
64
65 DEF_VEC_P (dw_cfi_ref);
66 DEF_VEC_ALLOC_P (dw_cfi_ref, heap);
67 DEF_VEC_ALLOC_P (dw_cfi_ref, gc);
68
69 typedef VEC(dw_cfi_ref, gc) *cfi_vec;
70
71 typedef struct dw_fde_struct *dw_fde_ref;
72
73 /* All call frame descriptions (FDE's) in the GCC generated DWARF
74    refer to a single Common Information Entry (CIE), defined at
75    the beginning of the .debug_frame section.  This use of a single
76    CIE obviates the need to keep track of multiple CIE's
77    in the DWARF generation routines below.  */
78
79 typedef struct GTY(()) dw_fde_struct {
80   tree decl;
81   const char *dw_fde_begin;
82   const char *dw_fde_current_label;
83   const char *dw_fde_end;
84   const char *dw_fde_vms_end_prologue;
85   const char *dw_fde_vms_begin_epilogue;
86   const char *dw_fde_second_begin;
87   const char *dw_fde_second_end;
88   cfi_vec dw_fde_cfi;
89   int dw_fde_switch_cfi_index; /* Last CFI before switching sections.  */
90   HOST_WIDE_INT stack_realignment;
91   unsigned funcdef_number;
92   /* Dynamic realign argument pointer register.  */
93   unsigned int drap_reg;
94   /* Virtual dynamic realign argument pointer register.  */
95   unsigned int vdrap_reg;
96   /* These 3 flags are copied from rtl_data in function.h.  */
97   unsigned all_throwers_are_sibcalls : 1;
98   unsigned uses_eh_lsda : 1;
99   unsigned nothrow : 1;
100   /* Whether we did stack realign in this call frame.  */
101   unsigned stack_realign : 1;
102   /* Whether dynamic realign argument pointer register has been saved.  */
103   unsigned drap_reg_saved: 1;
104   /* True iff dw_fde_begin label is in text_section or cold_text_section.  */
105   unsigned in_std_section : 1;
106   /* True iff dw_fde_second_begin label is in text_section or
107      cold_text_section.  */
108   unsigned second_in_std_section : 1;
109 }
110 dw_fde_node;
111
112
113 /* This is how we define the location of the CFA. We use to handle it
114    as REG + OFFSET all the time,  but now it can be more complex.
115    It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
116    Instead of passing around REG and OFFSET, we pass a copy
117    of this structure.  */
118 typedef struct cfa_loc {
119   HOST_WIDE_INT offset;
120   HOST_WIDE_INT base_offset;
121   unsigned int reg;
122   BOOL_BITFIELD indirect : 1;  /* 1 if CFA is accessed via a dereference.  */
123   BOOL_BITFIELD in_use : 1;    /* 1 if a saved cfa is stored here.  */
124 } dw_cfa_location;
125
126
127 /* Each DIE may have a series of attribute/value pairs.  Values
128    can take on several forms.  The forms that are used in this
129    implementation are listed below.  */
130
131 enum dw_val_class
132 {
133   dw_val_class_addr,
134   dw_val_class_offset,
135   dw_val_class_loc,
136   dw_val_class_loc_list,
137   dw_val_class_range_list,
138   dw_val_class_const,
139   dw_val_class_unsigned_const,
140   dw_val_class_const_double,
141   dw_val_class_vec,
142   dw_val_class_flag,
143   dw_val_class_die_ref,
144   dw_val_class_fde_ref,
145   dw_val_class_lbl_id,
146   dw_val_class_lineptr,
147   dw_val_class_str,
148   dw_val_class_macptr,
149   dw_val_class_file,
150   dw_val_class_data8,
151   dw_val_class_decl_ref,
152   dw_val_class_vms_delta
153 };
154
155 /* Describe a floating point constant value, or a vector constant value.  */
156
157 typedef struct GTY(()) dw_vec_struct {
158   unsigned char * GTY((length ("%h.length"))) array;
159   unsigned length;
160   unsigned elt_size;
161 }
162 dw_vec_const;
163
164 /* The dw_val_node describes an attribute's value, as it is
165    represented internally.  */
166
167 typedef struct GTY(()) dw_val_struct {
168   enum dw_val_class val_class;
169   union dw_val_struct_union
170     {
171       rtx GTY ((tag ("dw_val_class_addr"))) val_addr;
172       unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_offset"))) val_offset;
173       dw_loc_list_ref GTY ((tag ("dw_val_class_loc_list"))) val_loc_list;
174       dw_loc_descr_ref GTY ((tag ("dw_val_class_loc"))) val_loc;
175       HOST_WIDE_INT GTY ((default)) val_int;
176       unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned;
177       double_int GTY ((tag ("dw_val_class_const_double"))) val_double;
178       dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec;
179       struct dw_val_die_union
180         {
181           dw_die_ref die;
182           int external;
183         } GTY ((tag ("dw_val_class_die_ref"))) val_die_ref;
184       unsigned GTY ((tag ("dw_val_class_fde_ref"))) val_fde_index;
185       struct indirect_string_node * GTY ((tag ("dw_val_class_str"))) val_str;
186       char * GTY ((tag ("dw_val_class_lbl_id"))) val_lbl_id;
187       unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
188       struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
189       unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
190       tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
191       struct dw_val_vms_delta_union
192         {
193           char * lbl1;
194           char * lbl2;
195         } GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
196     }
197   GTY ((desc ("%1.val_class"))) v;
198 }
199 dw_val_node;
200
201 /* Locations in memory are described using a sequence of stack machine
202    operations.  */
203
204 typedef struct GTY(()) dw_loc_descr_struct {
205   dw_loc_descr_ref dw_loc_next;
206   ENUM_BITFIELD (dwarf_location_atom) dw_loc_opc : 8;
207   /* Used to distinguish DW_OP_addr with a direct symbol relocation
208      from DW_OP_addr with a dtp-relative symbol relocation.  */
209   unsigned int dtprel : 1;
210   int dw_loc_addr;
211   dw_val_node dw_loc_oprnd1;
212   dw_val_node dw_loc_oprnd2;
213 }
214 dw_loc_descr_node;
215
216
217 /* Interface from dwarf2out.c to dwarf2cfi.c.  */
218 extern dw_fde_ref current_fde (void);
219 extern struct dw_loc_descr_struct *build_cfa_loc
220   (dw_cfa_location *, HOST_WIDE_INT);
221 extern struct dw_loc_descr_struct *build_cfa_aligned_loc
222   (dw_cfa_location *, HOST_WIDE_INT offset, HOST_WIDE_INT alignment);
223 extern struct dw_loc_descr_struct *mem_loc_descriptor
224   (rtx, enum machine_mode mode, enum machine_mode mem_mode,
225    enum var_init_status);
226 extern enum machine_mode get_address_mode (rtx mem);
227
228 /* Interface from dwarf2cfi.c to dwarf2out.c.  */
229 extern void dwarf2cfi_frame_init (void);
230 extern void dwarf2cfi_function_init (void);
231 extern void lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc,
232                           dw_cfa_location *remember);
233 extern bool cfa_equal_p (const dw_cfa_location *, const dw_cfa_location *);
234
235 extern GTY(()) cfi_vec cie_cfi_vec;
236
237 /* Interface from dwarf2*.c to the rest of the compiler.  */
238 extern enum dw_cfi_oprnd_type dw_cfi_oprnd1_desc
239   (enum dwarf_call_frame_info cfi);
240 extern enum dw_cfi_oprnd_type dw_cfi_oprnd2_desc
241   (enum dwarf_call_frame_info cfi);
242
243 extern void dwarf2out_decl (tree);
244 extern void dwarf2out_frame_debug (rtx, bool);
245 extern void dwarf2out_frame_debug_init (void);
246 extern void dwarf2out_emit_cfi (dw_cfi_ref cfi);
247
248 extern void debug_dwarf (void);
249 struct die_struct;
250 extern void debug_dwarf_die (struct die_struct *);
251 extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
252 #ifdef VMS_DEBUGGING_INFO
253 extern void dwarf2out_vms_debug_main_pointer (void);
254 #endif
255
256 struct array_descr_info
257 {
258   int ndimensions;
259   tree element_type;
260   tree base_decl;
261   tree data_location;
262   tree allocated;
263   tree associated;
264   struct array_descr_dimen
265     {
266       tree lower_bound;
267       tree upper_bound;
268       tree stride;
269     } dimen[10];
270 };
271
272 #endif /* GCC_DWARF2OUT_H */