tree-object-size: use size_for_offset in more cases
[official-gcc.git] / gcc / coretypes.h
blob88f11202b57a0ad78681e2a08128e8c70aa52890
1 /* GCC core type declarations.
2 Copyright (C) 2002-2024 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 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* Provide forward declarations of core types which are referred to by
26 most of the compiler. This allows header files to use these types
27 (e.g. in function prototypes) without concern for whether the full
28 definitions are visible. Some other declarations that need to be
29 universally visible are here, too.
31 In the context of tconfig.h, most of these have special definitions
32 which prevent them from being used except in further type
33 declarations. This is a kludge; the right thing is to avoid
34 including the "tm.h" header set in the context of tconfig.h, but
35 we're not there yet. */
37 #ifndef GCC_CORETYPES_H
38 #define GCC_CORETYPES_H
40 #ifndef GTY
41 #define GTY(x) /* nothing - marker for gengtype */
42 #endif
44 #ifndef USED_FOR_TARGET
46 typedef int64_t gcov_type;
47 typedef uint64_t gcov_type_unsigned;
49 struct bitmap_obstack;
50 class bitmap_head;
51 typedef class bitmap_head *bitmap;
52 typedef const class bitmap_head *const_bitmap;
53 struct simple_bitmap_def;
54 typedef struct simple_bitmap_def *sbitmap;
55 typedef const struct simple_bitmap_def *const_sbitmap;
56 struct rtx_def;
57 typedef struct rtx_def *rtx;
58 typedef const struct rtx_def *const_rtx;
59 class scalar_mode;
60 class scalar_int_mode;
61 class scalar_float_mode;
62 class complex_mode;
63 class fixed_size_mode;
64 template<typename> class opt_mode;
65 typedef opt_mode<scalar_mode> opt_scalar_mode;
66 typedef opt_mode<scalar_int_mode> opt_scalar_int_mode;
67 typedef opt_mode<scalar_float_mode> opt_scalar_float_mode;
68 template<typename> struct pod_mode;
69 typedef pod_mode<scalar_mode> scalar_mode_pod;
70 typedef pod_mode<scalar_int_mode> scalar_int_mode_pod;
71 typedef pod_mode<fixed_size_mode> fixed_size_mode_pod;
73 /* Subclasses of rtx_def, using indentation to show the class
74 hierarchy, along with the relevant invariant.
75 Where possible, keep this list in the same order as in rtl.def. */
76 struct rtx_def;
77 struct rtx_expr_list; /* GET_CODE (X) == EXPR_LIST */
78 struct rtx_insn_list; /* GET_CODE (X) == INSN_LIST */
79 struct rtx_sequence; /* GET_CODE (X) == SEQUENCE */
80 struct rtx_insn;
81 struct rtx_debug_insn; /* DEBUG_INSN_P (X) */
82 struct rtx_nonjump_insn; /* NONJUMP_INSN_P (X) */
83 struct rtx_jump_insn; /* JUMP_P (X) */
84 struct rtx_call_insn; /* CALL_P (X) */
85 struct rtx_jump_table_data; /* JUMP_TABLE_DATA_P (X) */
86 struct rtx_barrier; /* BARRIER_P (X) */
87 struct rtx_code_label; /* LABEL_P (X) */
88 struct rtx_note; /* NOTE_P (X) */
90 struct rtvec_def;
91 typedef struct rtvec_def *rtvec;
92 typedef const struct rtvec_def *const_rtvec;
93 struct hwivec_def;
94 typedef struct hwivec_def *hwivec;
95 typedef const struct hwivec_def *const_hwivec;
96 union tree_node;
97 typedef union tree_node *tree;
98 typedef const union tree_node *const_tree;
99 struct gimple;
100 typedef gimple *gimple_seq;
101 struct gimple_stmt_iterator;
102 class code_helper;
103 enum tree_index : unsigned;
105 /* Forward declare rtx_code, so that we can use it in target hooks without
106 needing to pull in rtl.h. */
107 enum rtx_code : unsigned;
109 /* Forward decls for leaf gimple subclasses (for individual gimple codes).
110 Keep this in the same order as the corresponding codes in gimple.def. */
112 struct gcond;
113 struct gdebug;
114 struct ggoto;
115 struct glabel;
116 struct gswitch;
117 struct gassign;
118 struct gasm;
119 struct gcall;
120 struct gtransaction;
121 struct greturn;
122 struct gbind;
123 struct gcatch;
124 struct geh_filter;
125 struct geh_mnt;
126 struct geh_else;
127 struct gresx;
128 struct geh_dispatch;
129 struct gphi;
130 struct gtry;
131 struct gomp_atomic_load;
132 struct gomp_atomic_store;
133 struct gomp_continue;
134 struct gomp_critical;
135 struct gomp_ordered;
136 struct gomp_for;
137 struct gomp_parallel;
138 struct gomp_task;
139 struct gomp_sections;
140 struct gomp_single;
141 struct gomp_target;
142 struct gomp_teams;
144 /* Forward declaration of CFI's and DWARF's types. */
145 struct dw_cfi_node;
146 using dw_cfi_ref = struct dw_cfi_node *;
147 enum dw_cfi_oprnd_type: int;
148 enum dwarf_call_frame_info: int;
150 /* Subclasses of symtab_node, using indentation to show the class
151 hierarchy. */
153 struct symtab_node;
154 struct cgraph_node;
155 struct varpool_node;
156 struct cgraph_edge;
158 union section;
159 typedef union section section;
160 struct gcc_options;
161 struct cl_target_option;
162 struct cl_optimization;
163 struct cl_option;
164 struct cl_decoded_option;
165 struct cl_option_handlers;
166 class rich_location;
167 class diagnostic_context;
168 class diagnostic_text_output_format;
169 class pretty_printer;
170 class diagnostic_event_id_t;
171 typedef const char * (*diagnostic_input_charset_callback)(const char *);
172 namespace pp_markup { class element; }
173 typedef pp_markup::element pp_element;
175 template<typename T> struct array_traits;
177 /* Provides a read-only bitmap view of a single integer bitmask or an
178 array of integer bitmasks, or of a wrapper around such bitmasks. */
179 template<typename T, typename Traits = array_traits<T>,
180 bool has_constant_size = Traits::has_constant_size>
181 class bitmap_view;
183 /* Address space number for named address space support. */
184 typedef unsigned char addr_space_t;
186 /* The value of addr_space_t that represents the generic address space. */
187 #define ADDR_SPACE_GENERIC 0
188 #define ADDR_SPACE_GENERIC_P(AS) ((AS) == ADDR_SPACE_GENERIC)
190 /* The major intermediate representations of GCC. */
191 enum ir_type {
192 IR_GIMPLE,
193 IR_RTL_CFGRTL,
194 IR_RTL_CFGLAYOUT
197 /* Provide forward struct declaration so that we don't have to include
198 all of cpplib.h whenever a random prototype includes a pointer.
199 Note that the cpp_reader and cpp_token typedefs remain part of
200 cpplib.h. */
202 struct cpp_reader;
203 struct cpp_token;
205 /* The thread-local storage model associated with a given VAR_DECL
206 or SYMBOL_REF. This isn't used much, but both trees and RTL refer
207 to it, so it's here. */
208 enum tls_model {
209 TLS_MODEL_NONE,
210 TLS_MODEL_EMULATED,
211 TLS_MODEL_REAL,
212 TLS_MODEL_GLOBAL_DYNAMIC = TLS_MODEL_REAL,
213 TLS_MODEL_LOCAL_DYNAMIC,
214 TLS_MODEL_INITIAL_EXEC,
215 TLS_MODEL_LOCAL_EXEC
218 /* Types of trampoline implementation. */
219 enum trampoline_impl {
220 TRAMPOLINE_IMPL_STACK,
221 TRAMPOLINE_IMPL_HEAP
224 /* Types of ABI for an offload compiler. */
225 enum offload_abi {
226 OFFLOAD_ABI_UNSET,
227 OFFLOAD_ABI_LP64,
228 OFFLOAD_ABI_ILP32
231 /* Types of profile update methods. */
232 enum profile_update {
233 PROFILE_UPDATE_SINGLE,
234 PROFILE_UPDATE_ATOMIC,
235 PROFILE_UPDATE_PREFER_ATOMIC
238 /* Type of profile reproducibility methods. */
239 enum profile_reproducibility {
240 PROFILE_REPRODUCIBILITY_SERIAL,
241 PROFILE_REPRODUCIBILITY_PARALLEL_RUNS,
242 PROFILE_REPRODUCIBILITY_MULTITHREADED
245 /* Type of -fstack-protector-*. */
246 enum stack_protector {
247 SPCT_FLAG_DEFAULT = 1,
248 SPCT_FLAG_ALL = 2,
249 SPCT_FLAG_STRONG = 3,
250 SPCT_FLAG_EXPLICIT = 4
253 /* Types of unwind/exception handling info that can be generated.
254 Note that a UI_TARGET (or larger) setting is considered to be
255 incompatible with -freorder-blocks-and-partition. */
257 enum unwind_info_type
259 UI_NONE,
260 UI_SJLJ,
261 UI_DWARF2,
262 UI_SEH,
263 UI_TARGET
266 /* Callgraph node profile representation. */
267 enum node_frequency {
268 /* This function most likely won't be executed at all.
269 (set only when profile feedback is available or via function attribute). */
270 NODE_FREQUENCY_UNLIKELY_EXECUTED,
271 /* For functions that are known to be executed once (i.e. constructors, destructors
272 and main function. */
273 NODE_FREQUENCY_EXECUTED_ONCE,
274 /* The default value. */
275 NODE_FREQUENCY_NORMAL,
276 /* Optimize this function hard
277 (set only when profile feedback is available or via function attribute). */
278 NODE_FREQUENCY_HOT
281 /* Ways of optimizing code. */
282 enum optimization_type {
283 /* Prioritize speed over size. */
284 OPTIMIZE_FOR_SPEED,
286 /* Only do things that are good for both size and speed. */
287 OPTIMIZE_FOR_BOTH,
289 /* Prioritize size over speed. */
290 OPTIMIZE_FOR_SIZE
293 /* Enumerates a padding direction. */
294 enum pad_direction {
295 /* No padding is required. */
296 PAD_NONE,
298 /* Insert padding above the data, i.e. at higher memeory addresses
299 when dealing with memory, and at the most significant end when
300 dealing with registers. */
301 PAD_UPWARD,
303 /* Insert padding below the data, i.e. at lower memeory addresses
304 when dealing with memory, and at the least significant end when
305 dealing with registers. */
306 PAD_DOWNWARD
309 /* Possible initialization status of a variable. When requested
310 by the user, this information is tracked and recorded in the DWARF
311 debug information, along with the variable's location. */
312 enum var_init_status
314 VAR_INIT_STATUS_UNKNOWN,
315 VAR_INIT_STATUS_UNINITIALIZED,
316 VAR_INIT_STATUS_INITIALIZED
319 /* Names for the different levels of -Wstrict-overflow=N. The numeric
320 values here correspond to N. */
321 enum warn_strict_overflow_code
323 /* Overflow warning that should be issued with -Wall: a questionable
324 construct that is easy to avoid even when using macros. Example:
325 folding (x + CONSTANT > x) to 1. */
326 WARN_STRICT_OVERFLOW_ALL = 1,
327 /* Overflow warning about folding a comparison to a constant because
328 of undefined signed overflow, other than cases covered by
329 WARN_STRICT_OVERFLOW_ALL. Example: folding (abs (x) >= 0) to 1
330 (this is false when x == INT_MIN). */
331 WARN_STRICT_OVERFLOW_CONDITIONAL = 2,
332 /* Overflow warning about changes to comparisons other than folding
333 them to a constant. Example: folding (x + 1 > 1) to (x > 0). */
334 WARN_STRICT_OVERFLOW_COMPARISON = 3,
335 /* Overflow warnings not covered by the above cases. Example:
336 folding ((x * 10) / 5) to (x * 2). */
337 WARN_STRICT_OVERFLOW_MISC = 4,
338 /* Overflow warnings about reducing magnitude of constants in
339 comparison. Example: folding (x + 2 > y) to (x + 1 >= y). */
340 WARN_STRICT_OVERFLOW_MAGNITUDE = 5
343 /* The type of an alias set. Code currently assumes that variables of
344 this type can take the values 0 (the alias set which aliases
345 everything) and -1 (sometimes indicating that the alias set is
346 unknown, sometimes indicating a memory barrier) and -2 (indicating
347 that the alias set should be set to a unique value but has not been
348 set yet). */
349 typedef int alias_set_type;
351 class edge_def;
352 typedef class edge_def *edge;
353 typedef const class edge_def *const_edge;
354 struct basic_block_def;
355 typedef struct basic_block_def *basic_block;
356 typedef const struct basic_block_def *const_basic_block;
358 #if !defined (GENERATOR_FILE)
359 # define OBSTACK_CHUNK_SIZE memory_block_pool::block_size
360 # define obstack_chunk_alloc mempool_obstack_chunk_alloc
361 # define obstack_chunk_free mempool_obstack_chunk_free
362 #else
363 # define OBSTACK_CHUNK_SIZE 0
364 # define obstack_chunk_alloc xmalloc
365 # define obstack_chunk_free free
366 #endif
368 #define gcc_obstack_init(OBSTACK) \
369 obstack_specify_allocation ((OBSTACK), OBSTACK_CHUNK_SIZE, 0, \
370 obstack_chunk_alloc, \
371 obstack_chunk_free)
373 /* enum reg_class is target specific, so it should not appear in
374 target-independent code or interfaces, like the target hook declarations
375 in target.h. */
376 typedef int reg_class_t;
378 class rtl_opt_pass;
380 namespace gcc {
381 class context;
384 typedef std::pair <tree, tree> tree_pair;
385 typedef std::pair <const char *, int> string_int_pair;
387 /* Define a name->value mapping. */
388 template <typename ValueType>
389 struct kv_pair
391 const char *const name; /* the name of the value */
392 const ValueType value; /* the value of the name */
395 #else
397 struct _dont_use_rtx_here_;
398 struct _dont_use_rtvec_here_;
399 struct _dont_use_rtx_insn_here_;
400 union _dont_use_tree_here_;
401 #define rtx struct _dont_use_rtx_here_ *
402 #define const_rtx struct _dont_use_rtx_here_ *
403 #define rtvec struct _dont_use_rtvec_here *
404 #define const_rtvec struct _dont_use_rtvec_here *
405 #define rtx_insn struct _dont_use_rtx_insn_here_
406 #define tree union _dont_use_tree_here_ *
407 #define const_tree union _dont_use_tree_here_ *
409 typedef struct scalar_mode scalar_mode;
410 typedef struct scalar_int_mode scalar_int_mode;
411 typedef struct scalar_float_mode scalar_float_mode;
412 typedef struct complex_mode complex_mode;
414 #endif
416 /* Classes of functions that compiler needs to check
417 whether they are present at the runtime or not. */
418 enum function_class {
419 function_c94,
420 function_c99_misc,
421 function_c99_math_complex,
422 function_sincos,
423 function_c11_misc,
424 function_c23_misc
427 /* Enumerate visibility settings. This is deliberately ordered from most
428 to least visibility. */
429 enum symbol_visibility
431 VISIBILITY_DEFAULT,
432 VISIBILITY_PROTECTED,
433 VISIBILITY_HIDDEN,
434 VISIBILITY_INTERNAL
437 /* enums used by the targetm.excess_precision hook. */
439 enum flt_eval_method
441 FLT_EVAL_METHOD_UNPREDICTABLE = -1,
442 FLT_EVAL_METHOD_PROMOTE_TO_FLOAT = 0,
443 FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE = 1,
444 FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE = 2,
445 FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 = 16
448 enum excess_precision_type
450 EXCESS_PRECISION_TYPE_IMPLICIT,
451 EXCESS_PRECISION_TYPE_STANDARD,
452 EXCESS_PRECISION_TYPE_FAST,
453 EXCESS_PRECISION_TYPE_FLOAT16
456 /* Level of size optimization. */
458 enum optimize_size_level
460 /* Do not optimize for size. */
461 OPTIMIZE_SIZE_NO,
462 /* Optimize for size but not at extreme performance costs. */
463 OPTIMIZE_SIZE_BALANCED,
464 /* Optimize for size as much as possible. */
465 OPTIMIZE_SIZE_MAX
468 /* Support for user-provided GGC and PCH markers. The first parameter
469 is a pointer to a pointer, the second either NULL if the pointer to
470 pointer points into a GC object or the actual pointer address if
471 the first argument points to a temporary and the third a cookie. */
472 typedef void (*gt_pointer_operator) (void *, void *, void *);
474 #if !defined (HAVE_UCHAR)
475 typedef unsigned char uchar;
476 #endif
478 /* Most source files will require the following headers. */
479 #if !defined (USED_FOR_TARGET)
480 #include "insn-modes.h"
481 #include "signop.h"
482 #include "wide-int.h"
483 #include "wide-int-print.h"
485 /* On targets that don't need polynomial offsets, target-specific code
486 should be able to treat poly_int like a normal constant, with a
487 conversion operator going from the former to the latter. We also
488 allow this for gencondmd.cc for all targets, so that we can treat
489 machine_modes as enums without causing build failures. */
490 #if (defined (IN_TARGET_CODE) \
491 && (defined (USE_ENUM_MODES) || NUM_POLY_INT_COEFFS == 1))
492 #define POLY_INT_CONVERSION 1
493 #else
494 #define POLY_INT_CONVERSION 0
495 #endif
497 #include "poly-int.h"
498 #include "poly-int-types.h"
499 #include "insn-modes-inline.h"
500 #include "machmode.h"
501 #include "double-int.h"
502 #include "align.h"
503 /* Most host source files will require the following headers. */
504 #if !defined (GENERATOR_FILE)
505 #include "iterator-utils.h"
506 #include "real.h"
507 #include "fixed-value.h"
508 #include "hash-table.h"
509 #include "hash-set.h"
510 #include "input.h"
511 #include "is-a.h"
512 #include "memory-block.h"
513 #include "dumpfile.h"
514 #endif
515 #endif /* GENERATOR_FILE && !USED_FOR_TARGET */
517 #endif /* coretypes.h */