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