]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/dwarf2out.h
x86: Remove "%!" before ret
[thirdparty/gcc.git] / gcc / dwarf2out.h
CommitLineData
76ead72b 1/* dwarf2out.h - Various declarations for functions found in dwarf2out.c
99dee823 2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
76ead72b 3
1322177d 4This file is part of GCC.
76ead72b 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
76ead72b 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
76ead72b
RL
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
76ead72b 19
647a1567
RH
20#ifndef GCC_DWARF2OUT_H
21#define GCC_DWARF2OUT_H 1
22
23#include "dwarf2.h" /* ??? Remove this once only used by dwarf2foo.c. */
24
25typedef struct die_struct *dw_die_ref;
26typedef const struct die_struct *const_dw_die_ref;
27
84562394
OE
28typedef struct dw_val_node *dw_val_ref;
29typedef struct dw_cfi_node *dw_cfi_ref;
30typedef struct dw_loc_descr_node *dw_loc_descr_ref;
647a1567 31typedef struct dw_loc_list_struct *dw_loc_list_ref;
986ccd21 32typedef struct dw_discr_list_node *dw_discr_list_ref;
807e902e 33typedef wide_int *wide_int_ptr;
647a1567
RH
34
35
36/* Call frames are described using a sequence of Call Frame
37 Information instructions. The register number, offset
38 and address fields are provided as possible operands;
39 their use is selected by the opcode field. */
40
41enum dw_cfi_oprnd_type {
42 dw_cfi_oprnd_unused,
43 dw_cfi_oprnd_reg_num,
44 dw_cfi_oprnd_offset,
45 dw_cfi_oprnd_addr,
21810de4
RS
46 dw_cfi_oprnd_loc,
47 dw_cfi_oprnd_cfa_loc
647a1567
RH
48};
49
84562394 50typedef union GTY(()) {
647a1567
RH
51 unsigned int GTY ((tag ("dw_cfi_oprnd_reg_num"))) dw_cfi_reg_num;
52 HOST_WIDE_INT GTY ((tag ("dw_cfi_oprnd_offset"))) dw_cfi_offset;
53 const char * GTY ((tag ("dw_cfi_oprnd_addr"))) dw_cfi_addr;
84562394 54 struct dw_loc_descr_node * GTY ((tag ("dw_cfi_oprnd_loc"))) dw_cfi_loc;
21810de4
RS
55 struct dw_cfa_location * GTY ((tag ("dw_cfi_oprnd_cfa_loc")))
56 dw_cfi_cfa_loc;
84562394 57} dw_cfi_oprnd;
647a1567 58
84562394 59struct GTY(()) dw_cfi_node {
647a1567
RH
60 enum dwarf_call_frame_info dw_cfi_opc;
61 dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd1_desc (%1.dw_cfi_opc)")))
62 dw_cfi_oprnd1;
63 dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd2_desc (%1.dw_cfi_opc)")))
64 dw_cfi_oprnd2;
84562394 65};
647a1567 66
647a1567 67
9771b263 68typedef vec<dw_cfi_ref, va_gc> *cfi_vec;
647a1567 69
84562394 70typedef struct dw_fde_node *dw_fde_ref;
647a1567
RH
71
72/* All call frame descriptions (FDE's) in the GCC generated DWARF
73 refer to a single Common Information Entry (CIE), defined at
74 the beginning of the .debug_frame section. This use of a single
75 CIE obviates the need to keep track of multiple CIE's
76 in the DWARF generation routines below. */
77
84562394 78struct GTY(()) dw_fde_node {
647a1567
RH
79 tree decl;
80 const char *dw_fde_begin;
81 const char *dw_fde_current_label;
82 const char *dw_fde_end;
83 const char *dw_fde_vms_end_prologue;
84 const char *dw_fde_vms_begin_epilogue;
85 const char *dw_fde_second_begin;
86 const char *dw_fde_second_end;
87 cfi_vec dw_fde_cfi;
88 int dw_fde_switch_cfi_index; /* Last CFI before switching sections. */
89 HOST_WIDE_INT stack_realignment;
a518b996 90
647a1567 91 unsigned funcdef_number;
a518b996
RH
92 unsigned fde_index;
93
647a1567
RH
94 /* Dynamic realign argument pointer register. */
95 unsigned int drap_reg;
96 /* Virtual dynamic realign argument pointer register. */
97 unsigned int vdrap_reg;
98 /* These 3 flags are copied from rtl_data in function.h. */
99 unsigned all_throwers_are_sibcalls : 1;
100 unsigned uses_eh_lsda : 1;
101 unsigned nothrow : 1;
102 /* Whether we did stack realign in this call frame. */
103 unsigned stack_realign : 1;
104 /* Whether dynamic realign argument pointer register has been saved. */
105 unsigned drap_reg_saved: 1;
106 /* True iff dw_fde_begin label is in text_section or cold_text_section. */
107 unsigned in_std_section : 1;
108 /* True iff dw_fde_second_begin label is in text_section or
109 cold_text_section. */
110 unsigned second_in_std_section : 1;
1cdfc98a
JJ
111 /* True if Rule 18 described in dwarf2cfi.c is in action, i.e. for dynamic
112 stack realignment in between pushing of hard frame pointer to stack
113 and setting hard frame pointer to stack pointer. The register save for
114 hard frame pointer register should be emitted only on the latter
115 instruction. */
116 unsigned rule18 : 1;
e69ac020
BE
117 /* True if this function is to be ignored by debugger. */
118 unsigned ignored_debug : 1;
84562394 119};
647a1567
RH
120
121
122/* This is how we define the location of the CFA. We use to handle it
123 as REG + OFFSET all the time, but now it can be more complex.
124 It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
125 Instead of passing around REG and OFFSET, we pass a copy
126 of this structure. */
84562394 127struct GTY(()) dw_cfa_location {
21810de4
RS
128 poly_int64_pod offset;
129 poly_int64_pod base_offset;
7263c6d7 130 /* REG is in DWARF_FRAME_REGNUM space, *not* normal REGNO space. */
647a1567
RH
131 unsigned int reg;
132 BOOL_BITFIELD indirect : 1; /* 1 if CFA is accessed via a dereference. */
133 BOOL_BITFIELD in_use : 1; /* 1 if a saved cfa is stored here. */
84562394 134};
647a1567
RH
135
136
137/* Each DIE may have a series of attribute/value pairs. Values
138 can take on several forms. The forms that are used in this
139 implementation are listed below. */
140
141enum dw_val_class
142{
57e16c96 143 dw_val_class_none,
647a1567
RH
144 dw_val_class_addr,
145 dw_val_class_offset,
146 dw_val_class_loc,
147 dw_val_class_loc_list,
148 dw_val_class_range_list,
149 dw_val_class_const,
150 dw_val_class_unsigned_const,
151 dw_val_class_const_double,
807e902e 152 dw_val_class_wide_int,
647a1567
RH
153 dw_val_class_vec,
154 dw_val_class_flag,
155 dw_val_class_die_ref,
156 dw_val_class_fde_ref,
157 dw_val_class_lbl_id,
158 dw_val_class_lineptr,
159 dw_val_class_str,
160 dw_val_class_macptr,
2a3d56bf 161 dw_val_class_loclistsptr,
647a1567
RH
162 dw_val_class_file,
163 dw_val_class_data8,
164 dw_val_class_decl_ref,
413de8e5 165 dw_val_class_vms_delta,
986ccd21
PMR
166 dw_val_class_high_pc,
167 dw_val_class_discr_value,
f04c1e0a
JJ
168 dw_val_class_discr_list,
169 dw_val_class_const_implicit,
170 dw_val_class_unsigned_const_implicit,
bd2b9f1e 171 dw_val_class_file_implicit,
7b602c4d
AO
172 dw_val_class_view_list,
173 dw_val_class_symview
647a1567
RH
174};
175
176/* Describe a floating point constant value, or a vector constant value. */
177
84562394 178struct GTY(()) dw_vec_const {
edca997e 179 void * GTY((atomic)) array;
647a1567
RH
180 unsigned length;
181 unsigned elt_size;
84562394 182};
647a1567 183
986ccd21
PMR
184/* Describe a single value that a discriminant can match.
185
186 Discriminants (in the "record variant part" meaning) are scalars.
187 dw_discr_list_ref and dw_discr_value are a mean to describe a set of
188 discriminant values that are matched by a particular variant.
189
190 Discriminants can be signed or unsigned scalars, and can be discriminants
191 values. Both have to be consistent, though. */
192
193struct GTY(()) dw_discr_value {
194 int pos; /* Whether the discriminant value is positive (unsigned). */
195 union
196 {
197 HOST_WIDE_INT GTY ((tag ("0"))) sval;
198 unsigned HOST_WIDE_INT GTY ((tag ("1"))) uval;
199 }
200 GTY ((desc ("%1.pos"))) v;
201};
202
50686850 203struct addr_table_entry;
99ea153e 204
647a1567
RH
205/* The dw_val_node describes an attribute's value, as it is
206 represented internally. */
207
84562394 208struct GTY(()) dw_val_node {
647a1567 209 enum dw_val_class val_class;
50686850 210 struct addr_table_entry * GTY(()) val_entry;
647a1567
RH
211 union dw_val_struct_union
212 {
213 rtx GTY ((tag ("dw_val_class_addr"))) val_addr;
214 unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_offset"))) val_offset;
215 dw_loc_list_ref GTY ((tag ("dw_val_class_loc_list"))) val_loc_list;
bd2b9f1e 216 dw_die_ref GTY ((tag ("dw_val_class_view_list"))) val_view_list;
647a1567
RH
217 dw_loc_descr_ref GTY ((tag ("dw_val_class_loc"))) val_loc;
218 HOST_WIDE_INT GTY ((default)) val_int;
f04c1e0a
JJ
219 unsigned HOST_WIDE_INT
220 GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned;
647a1567 221 double_int GTY ((tag ("dw_val_class_const_double"))) val_double;
807e902e 222 wide_int_ptr GTY ((tag ("dw_val_class_wide_int"))) val_wide;
647a1567
RH
223 dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec;
224 struct dw_val_die_union
225 {
226 dw_die_ref die;
227 int external;
228 } GTY ((tag ("dw_val_class_die_ref"))) val_die_ref;
229 unsigned GTY ((tag ("dw_val_class_fde_ref"))) val_fde_index;
230 struct indirect_string_node * GTY ((tag ("dw_val_class_str"))) val_str;
231 char * GTY ((tag ("dw_val_class_lbl_id"))) val_lbl_id;
232 unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
233 struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
f04c1e0a
JJ
234 struct dwarf_file_data *
235 GTY ((tag ("dw_val_class_file_implicit"))) val_file_implicit;
647a1567
RH
236 unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
237 tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
238 struct dw_val_vms_delta_union
239 {
240 char * lbl1;
241 char * lbl2;
242 } GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
986ccd21
PMR
243 dw_discr_value GTY ((tag ("dw_val_class_discr_value"))) val_discr_value;
244 dw_discr_list_ref GTY ((tag ("dw_val_class_discr_list"))) val_discr_list;
7b602c4d 245 char * GTY ((tag ("dw_val_class_symview"))) val_symbolic_view;
647a1567
RH
246 }
247 GTY ((desc ("%1.val_class"))) v;
84562394 248};
647a1567
RH
249
250/* Locations in memory are described using a sequence of stack machine
251 operations. */
252
bd849fe6 253struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
647a1567
RH
254 dw_loc_descr_ref dw_loc_next;
255 ENUM_BITFIELD (dwarf_location_atom) dw_loc_opc : 8;
256 /* Used to distinguish DW_OP_addr with a direct symbol relocation
257 from DW_OP_addr with a dtp-relative symbol relocation. */
258 unsigned int dtprel : 1;
5cea3ad6
JJ
259 /* For DW_OP_pick, DW_OP_dup and DW_OP_over operations: true iff.
260 it targets a DWARF prodecure argument. In this case, it needs to be
261 relocated according to the current frame offset. */
986ccd21 262 unsigned int frame_offset_rel : 1;
647a1567
RH
263 int dw_loc_addr;
264 dw_val_node dw_loc_oprnd1;
265 dw_val_node dw_loc_oprnd2;
84562394 266};
647a1567 267
986ccd21
PMR
268/* A variant (inside a record variant part) is selected when the corresponding
269 discriminant matches its set of values (see the comment for dw_discr_value).
270 The following datastructure holds such matching information. */
271
272struct GTY(()) dw_discr_list_node {
273 dw_discr_list_ref dw_discr_next;
274
275 dw_discr_value dw_discr_lower_bound;
276 dw_discr_value dw_discr_upper_bound;
277 /* This node represents only the value in dw_discr_lower_bound when it's
278 zero. It represents the range between the two fields (bounds included)
279 otherwise. */
280 int dw_discr_range;
281};
647a1567
RH
282
283/* Interface from dwarf2out.c to dwarf2cfi.c. */
84562394 284extern struct dw_loc_descr_node *build_cfa_loc
74c74aa0 285 (dw_cfa_location *, poly_int64);
84562394 286extern struct dw_loc_descr_node *build_cfa_aligned_loc
74c74aa0 287 (dw_cfa_location *, poly_int64, HOST_WIDE_INT);
84562394 288extern struct dw_loc_descr_node *mem_loc_descriptor
ef4bddc2 289 (rtx, machine_mode mode, machine_mode mem_mode,
647a1567 290 enum var_init_status);
57e16c96 291extern bool loc_descr_equal_p (dw_loc_descr_ref, dw_loc_descr_ref);
a518b996 292extern dw_fde_ref dwarf2out_alloc_current_fde (void);
647a1567 293
948d330e
RH
294extern unsigned long size_of_locs (dw_loc_descr_ref);
295extern void output_loc_sequence (dw_loc_descr_ref, int);
296extern void output_loc_sequence_raw (dw_loc_descr_ref);
297
647a1567 298/* Interface from dwarf2cfi.c to dwarf2out.c. */
647a1567
RH
299extern void lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc,
300 dw_cfa_location *remember);
301extern bool cfa_equal_p (const dw_cfa_location *, const dw_cfa_location *);
302
948d330e 303extern void output_cfi (dw_cfi_ref, dw_fde_ref, int);
948d330e 304
647a1567
RH
305extern GTY(()) cfi_vec cie_cfi_vec;
306
307/* Interface from dwarf2*.c to the rest of the compiler. */
308extern enum dw_cfi_oprnd_type dw_cfi_oprnd1_desc
309 (enum dwarf_call_frame_info cfi);
310extern enum dw_cfi_oprnd_type dw_cfi_oprnd2_desc
311 (enum dwarf_call_frame_info cfi);
312
84562394 313extern void output_cfi_directive (FILE *f, struct dw_cfi_node *cfi);
2867fa7c 314
bc5612ed 315extern void dwarf2out_emit_cfi (dw_cfi_ref cfi);
83d2b3b9 316
7080f735 317extern void debug_dwarf (void);
79a2acc8 318struct die_struct;
7080f735 319extern void debug_dwarf_die (struct die_struct *);
f08649c0 320extern void debug_dwarf_loc_descr (dw_loc_descr_ref);
7b3b6ae4
LC
321extern void debug (die_struct &ref);
322extern void debug (die_struct *ptr);
7080f735 323extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
8e7745dc
DR
324#ifdef VMS_DEBUGGING_INFO
325extern void dwarf2out_vms_debug_main_pointer (void);
326#endif
fad0afd7 327
616743a8
PMR
328enum array_descr_ordering
329{
330 array_descr_ordering_default,
331 array_descr_ordering_row_major,
332 array_descr_ordering_column_major
333};
334
98088266
PMR
335#define DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN 16
336
fad0afd7
JJ
337struct array_descr_info
338{
339 int ndimensions;
616743a8 340 enum array_descr_ordering ordering;
fad0afd7
JJ
341 tree element_type;
342 tree base_decl;
343 tree data_location;
344 tree allocated;
345 tree associated;
eb59e428 346 tree stride;
5cea3ad6 347 tree rank;
eb59e428 348 bool stride_in_bits;
fad0afd7
JJ
349 struct array_descr_dimen
350 {
616743a8
PMR
351 /* GCC uses sizetype for array indices, so lower_bound and upper_bound
352 will likely be "sizetype" values. However, bounds may have another
353 type in the original source code. */
354 tree bounds_type;
fad0afd7
JJ
355 tree lower_bound;
356 tree upper_bound;
eb59e428
PMR
357
358 /* Only Fortran uses more than one dimension for array types. For other
359 languages, the stride can be rather specified for the whole array. */
fad0afd7 360 tree stride;
98088266 361 } dimen[DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN];
fad0afd7 362};
647a1567 363
2971780e
PMR
364enum fixed_point_scale_factor
365{
366 fixed_point_scale_factor_binary,
367 fixed_point_scale_factor_decimal,
368 fixed_point_scale_factor_arbitrary
369};
370
371struct fixed_point_type_info
372{
43a0debd
EB
373 /* The scale factor is the value one has to multiply the actual data with
374 to get the fixed point value. We support three ways to encode it. */
2971780e
PMR
375 enum fixed_point_scale_factor scale_factor_kind;
376 union
377 {
43a0debd 378 /* For a binary scale factor, the scale factor is 2 ** binary. */
2971780e 379 int binary;
43a0debd 380 /* For a decimal scale factor, the scale factor is 10 ** decimal. */
2971780e 381 int decimal;
43a0debd 382 /* For an arbitrary scale factor, the scale factor is the ratio
2971780e 383 numerator / denominator. */
43a0debd 384 struct { tree numerator; tree denominator; } arbitrary;
2971780e
PMR
385 } scale_factor;
386};
387
3edf64aa
DM
388void dwarf2out_c_finalize (void);
389
5783a0cc
IB
390/* Some DWARF internals are exposed for the needs of DWARF-based debug
391 formats. */
392
393/* Each DIE attribute has a field specifying the attribute kind,
394 a link to the next attribute in the chain, and an attribute value.
395 Attributes are typically linked below the DIE they modify. */
396
397typedef struct GTY(()) dw_attr_struct {
398 enum dwarf_attribute dw_attr;
399 dw_val_node dw_attr_val;
400}
401dw_attr_node;
402
403extern dw_attr_node *get_AT (dw_die_ref, enum dwarf_attribute);
404extern HOST_WIDE_INT AT_int (dw_attr_node *);
405extern unsigned HOST_WIDE_INT AT_unsigned (dw_attr_node *a);
406extern dw_loc_descr_ref AT_loc (dw_attr_node *);
407extern dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute);
408extern const char *get_AT_string (dw_die_ref, enum dwarf_attribute);
409extern enum dw_val_class AT_class (dw_attr_node *);
410extern unsigned HOST_WIDE_INT AT_unsigned (dw_attr_node *);
411extern unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute);
412extern int get_AT_flag (dw_die_ref, enum dwarf_attribute);
413
414extern void add_name_attribute (dw_die_ref, const char *);
415
416extern dw_die_ref new_die_raw (enum dwarf_tag);
417extern dw_die_ref base_type_die (tree, bool);
418
419extern dw_die_ref lookup_decl_die (tree);
81eced21 420extern dw_die_ref lookup_type_die (tree);
5783a0cc
IB
421
422extern dw_die_ref dw_get_die_child (dw_die_ref);
423extern dw_die_ref dw_get_die_sib (dw_die_ref);
424extern enum dwarf_tag dw_get_die_tag (dw_die_ref);
425
426/* Data about a single source file. */
427struct GTY((for_user)) dwarf_file_data {
7cc2df08 428 const char * key;
5783a0cc
IB
429 const char * filename;
430 int emitted_number;
431};
432
433extern struct dwarf_file_data *get_AT_file (dw_die_ref,
434 enum dwarf_attribute);
435
647a1567 436#endif /* GCC_DWARF2OUT_H */