GCC Middle and Back End API Reference
|
Variables | |
tree | sizetype_tab [(int) stk_type_kind_last] |
unsigned int | maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT |
static int | reference_types_internal = 0 |
static vec< tree, va_gc > * | size_functions |
tree bit_from_pos | ( | ) |
Return the combined bit position for the byte offset OFFSET and the bit position BITPOS. These functions operate on byte and bit positions present in FIELD_DECLs and assume that these expressions result in no (intermediate) overflow. This assumption is necessary to fold the expressions as much as possible, so as to avoid creating artificially variable-sized types in languages supporting variable-sized types like Ada.
Referenced by bit_position(), and rli_size_so_far().
tree byte_from_pos | ( | ) |
Return the combined truncated byte position for the byte offset OFFSET and the bit position BITPOS.
References tree_int_cst_equal().
Referenced by byte_position(), and rli_size_unit_so_far().
void compute_record_mode | ( | ) |
Compute the TYPE_MODE for the TYPE (which is a RECORD_TYPE).
References bit_position(), host_integerp(), integer_zerop(), mode_for_size_tree(), simple_cst_equal(), and targetm.
Referenced by finish_record_layout().
|
static |
Similar to copy_tree_r but do not copy component references involving PLACEHOLDER_EXPRs. These nodes are spotted in find_placeholder_in_expr and substituted in substitute_in_expr.
References copy_tree_r(), tcc_constant, tcc_declaration, and tcc_type.
Referenced by self_referential_size().
void debug_rli | ( | record_layout_info | ) |
DEBUG_FUNCTION void debug_rli | ( | ) |
Print debugging information about the information in RLI.
References record_layout_info_s::bitpos, debug_vec_tree(), record_layout_info_s::offset, record_layout_info_s::offset_align, record_layout_info_s::packed_maybe_necessary, record_layout_info_s::pending_statics, print_node_brief(), record_layout_info_s::record_align, record_layout_info_s::remaining_in_alignment, record_layout_info_s::t, targetm, record_layout_info_s::unpacked_align, and vec_safe_is_empty().
|
inlinestatic |
Subroutine of layout_decl: Force alignment required for the data type. But if the decl itself wants greater alignment, don't override that.
Referenced by layout_decl().
unsigned int element_precision | ( | ) |
Return the precision of the mode, or for a complex or vector mode the precision of the mode of its elements.
|
static |
A bitfield of SIZE with a required access alignment of ALIGN is allocated at BYTE_OFFSET / BIT_OFFSET. Return nonzero if the field would span more units of alignment than the underlying TYPE.
References HOST_WIDE_INT, offset, and tree_low_cst().
Referenced by place_field().
|
static |
Referenced by finish_record_layout().
|
static |
Assuming that all the fields have been laid out, this function uses RLI to compute the final TYPE_SIZE, TYPE_ALIGN, etc. for the type indicated by RLI.
References record_layout_info_s::bitpos, input_location, integer_zerop(), normalize_rli(), record_layout_info_s::offset_align, record_layout_info_s::packed_maybe_necessary, record_layout_info_s::record_align, rli_size_so_far(), rli_size_unit_so_far(), simple_cst_equal(), record_layout_info_s::t, record_layout_info_s::unpacked_align, and warning().
void finalize_size_functions | ( | void | ) |
Take, queue and compile all the size functions. It is essential that the size functions be gimplified at the very end of the compilation in order to guarantee transparent handling of self-referential sizes. Otherwise the GENERIC inliner would not be able to inline them back at each of their call sites, thus creating artificial non-constant size expressions which would trigger nasty problems later on.
References allocate_struct_function(), cgraph_finalize_function(), dump_function(), gimplify_function_tree(), set_cfun(), size_functions, TDI_generic, TDI_original, and vec_free().
Referenced by finalize_compilation_unit().
|
static |
Referenced by finish_record_layout(), and layout_type().
|
static |
Compute TYPE_SIZE and TYPE_ALIGN for TYPE, once it has been laid out.
References variable_size().
|
static |
Compute and set FIELD_DECLs for the underlying objects we should use for bitfield access for the structure laid out with RLI.
References finish_bitfield_representative(), host_integerp(), integer_zerop(), operand_equal_p(), start_bitfield_representative(), and record_layout_info_s::t.
Referenced by finish_record_layout().
|
static |
Finish up a bitfield group that was started by creating the underlying object REPR with the last field in the bitfield group FIELD.
References build_array_type_nelts(), host_integerp(), HOST_WIDE_INT, tree_low_cst(), lang_hooks_for_types::type_for_mode, and lang_hooks::types.
Referenced by finish_bitfield_layout().
Finish processing a builtin RECORD_TYPE type TYPE. It's name is NAME, its fields are chained in reverse on FIELDS. If ALIGN_TYPE is non-null, it is given the same alignment as ALIGN_TYPE.
References get_identifier(), layout_decl(), layout_type(), and type().
Referenced by build_fn_info_type(), and build_info_type().
void finish_record_layout | ( | ) |
Do all of the work required to layout the type indicated by RLI, once the fields have been laid out. This function will call `free' for RLI, unless FREE_P is false. Passing a value other than false for FREE_P is bad practice; this option only exists to support the G++ 3.2 ABI.
References compute_record_mode(), finalize_record_size(), finalize_type_size(), finish_bitfield_layout(), free(), layout_decl(), record_layout_info_s::pending_statics, record_layout_info_s::t, vec_free(), and vec_safe_is_empty().
Referenced by layout_type().
void fixup_signed_type | ( | ) |
Set the extreme values of TYPE based on its precision in bits, then lay it out. Used when make_signed_type won't do because the tree code is not INTEGER_TYPE. E.g. for Pascal, when the -fsigned-char option is given.
References layout_type(), and set_min_and_max_values_for_integral_type().
Referenced by build_nonstandard_integer_type(), and make_signed_type().
void fixup_unsigned_type | ( | ) |
Set the extreme values of TYPE based on its precision in bits, then lay it out. This is used both in `make_unsigned_type' and for enumeral types.
References layout_type(), and set_min_and_max_values_for_integral_type().
Referenced by build_nonstandard_integer_type(), and make_unsigned_type().
enum machine_mode get_best_mode | ( | int | bitsize, |
int | bitpos, | ||
unsigned HOST_WIDE_INT | bitregion_start, | ||
unsigned HOST_WIDE_INT | bitregion_end, | ||
unsigned int | align, | ||
enum machine_mode | largest_mode, | ||
bool | volatilep | ||
) |
Find the best machine mode to use when referencing a bit field of length BITSIZE bits starting at BITPOS. BITREGION_START is the bit position of the first bit in this sequence of bit fields. BITREGION_END is the last bit in this sequence. If these two fields are non-zero, we should restrict the memory access to that range. Otherwise, we are allowed to touch any adjacent non bit-fields. The underlying object is known to be aligned to a boundary of ALIGN bits. If LARGEST_MODE is not VOIDmode, it means that we should not use a mode larger than LARGEST_MODE (usually SImode). If no mode meets all these conditions, we return VOIDmode. If VOLATILEP is false and SLOW_BYTE_ACCESS is false, we return the smallest mode meeting these conditions. If VOLATILEP is false and SLOW_BYTE_ACCESS is true, we return the largest mode (but a mode no wider than UNITS_PER_WORD) that meets all the conditions. If VOLATILEP is true the narrow_volatile_bitfields target hook is used to decide which of the above modes should be used.
References bit_field_mode_iterator::next_mode(), and bit_field_mode_iterator::prefer_smaller_modes().
Referenced by extract_fixed_bit_field(), fold_truth_andor_1(), optimize_bit_field_compare(), optimize_bitfield_assignment_op(), store_bit_field(), and store_fixed_bit_field().
unsigned int get_mode_alignment | ( | ) |
Return the alignment of MODE. This will be bounded by 1 and BIGGEST_ALIGNMENT.
References mode_base_align.
void get_mode_bounds | ( | enum machine_mode | mode, |
int | sign, | ||
enum machine_mode | target_mode, | ||
rtx * | mmin, | ||
rtx * | mmax | ||
) |
Gets minimal and maximal values for MODE (signed or unsigned depending on SIGN). The returned constants are made to be usable in TARGET_MODE.
References gen_int_mode(), HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.
Referenced by determine_max_iter(), iv_number_of_iterations(), shorten_into_mode(), and simplify_const_relational_operation().
void initialize_sizetypes | ( | void | ) |
Initialize sizetypes so layout_type can use them.
References get_identifier(), make_signed_type(), set_min_and_max_values_for_integral_type(), and smallest_mode_for_size().
Referenced by build_common_tree_nodes().
enum machine_mode int_mode_for_mode | ( | ) |
Find an integer mode of the exact same size, or BLKmode on failure.
References mode_for_size().
void internal_reference_types | ( | void | ) |
Show that REFERENCE_TYPES are internal and should use address_mode. Called only by front end.
References reference_types_internal.
void layout_decl | ( | ) |
Set the size, mode and alignment of a ..._DECL node. TYPE_DECL does need this for C++. Note that LABEL_DECL and CONST_DECL nodes do not need this, and FUNCTION_DECL nodes have them set up in a special (and simple) way. Don't call layout_decl for them. KNOWN_ALIGN is the amount of alignment we can assume this decl has with no special effort. It is relevant only for FIELD_DECLs and depends on the previous fields. All that matters about KNOWN_ALIGN is which powers of 2 divide it. If KNOWN_ALIGN is 0, it means, "as much alignment as you like": the record will be aligned to suit.
References compare_tree_int(), do_type_align(), fold_convert_loc(), integer_zerop(), maximum_field_alignment, mode_for_size_tree(), set_mem_attributes(), size_binop_loc(), targetm, type(), variable_size(), and warning().
Referenced by assemble_variable(), build_decl_stat(), build_fake_var_decl(), expand_expr_real_1(), finalize_nesting_tree_1(), finish_builtin_struct(), finish_record_layout(), ipa_modify_formal_parameters(), place_field(), relayout_decl(), split_complex_args(), and update_alignment_for_field().
void layout_type | ( | ) |
Calculate the mode, size, and alignment for TYPE. For an array type, calculate the element separation as well. Record TYPE on the chain of permanent or temporary types so that dbxout will find out about it. TYPE_SIZE of a type is nonzero if the type has been laid out already. layout_type does nothing on such a type. If the type is incomplete, its TYPE_SIZE remains zero.
References build_int_cst(), build_pointer_type(), compare_tree_int(), double_int_to_tree(), error(), finalize_type_size(), finish_record_layout(), int_const_binop(), integer_zerop(), mode_for_array(), mode_for_size(), mode_for_vector(), nreverse(), place_field(), reference_types_internal, smallest_mode_for_size(), start_record_layout(), targetm, tree_int_cst_lt(), tree_int_cst_sgn(), and tree_to_double_int().
Referenced by asan_global_struct(), build_array_type_1(), build_common_tree_nodes(), build_complex_type(), build_function_type(), build_method_type_directly(), build_offset_type(), build_pointer_type_for_mode(), build_reference_type_for_mode(), finalize_nesting_tree_1(), finish_builtin_struct(), fixup_child_record_type(), fixup_signed_type(), fixup_unsigned_type(), get_emutls_object_type(), get_trampoline_type(), init_eh(), make_accum_type(), make_fract_type(), make_vector_type(), mf_make_mf_cache_struct_type(), scan_omp_parallel(), scan_omp_single(), scan_omp_task(), separate_decls_in_region(), task_copyfn_remap_type(), thunk_adjust(), and type_hash_lookup().
tree make_accum_type | ( | ) |
Create and return a type for accum of PRECISION bits, UNSIGNEDP, and SATP.
References layout_type(), mode_for_size(), and type().
Referenced by make_or_reuse_accum_type().
tree make_fract_type | ( | ) |
Create and return a type for fract of PRECISION bits, UNSIGNEDP, and SATP.
References layout_type(), mode_for_size(), and type().
Referenced by make_or_reuse_fract_type().
tree make_signed_type | ( | ) |
Create and return a type for signed integers of PRECISION bits.
References fixup_signed_type(), and type().
Referenced by build_common_tree_nodes(), initialize_sizetypes(), and make_or_reuse_type().
tree make_unsigned_type | ( | ) |
Create and return a type for unsigned integers of PRECISION bits.
References fixup_unsigned_type(), and type().
Referenced by build_common_tree_nodes(), and make_or_reuse_type().
|
static |
Return the natural mode of an array, given that it is SIZE bytes in total and has elements of type ELEM_TYPE.
References host_integerp(), HOST_WIDE_INT, mode_for_size_tree(), simple_cst_equal(), targetm, and tree_low_cst().
Referenced by layout_type().
enum machine_mode mode_for_size | ( | ) |
Return the machine mode to use for a nonscalar of SIZE bits. The mode must be in class MCLASS, and have exactly that many value bits; it may have padding as well. If LIMIT is nonzero, modes of wider than MAX_FIXED_MODE_SIZE will not be used.
enum machine_mode mode_for_size_tree | ( | ) |
Similar, except passed a tree node.
References host_integerp(), HOST_WIDE_INT, mode_for_size(), tree_low_cst(), and ui.
Referenced by compute_record_mode(), layout_decl(), and mode_for_array().
enum machine_mode mode_for_vector | ( | ) |
Find a mode that is suitable for representing a vector with NUNITS elements of mode INNERMODE. Returns BLKmode if there is no suitable mode.
References mode_for_size().
void normalize_offset | ( | ) |
Given a pointer to bit and byte offsets and an offset alignment, normalize the offsets so they are within the alignment.
References compare_tree_int(), offset, and pos_from_bit().
Referenced by normalize_rli().
void normalize_rli | ( | ) |
Given an RLI with a possibly-incremented BITPOS, adjust OFFSET and BITPOS if necessary to keep BITPOS below OFFSET_ALIGN.
References record_layout_info_s::bitpos, normalize_offset(), record_layout_info_s::offset, and record_layout_info_s::offset_align.
Referenced by finalize_record_size(), and place_field().
void place_field | ( | ) |
RLI contains information about the layout of a RECORD_TYPE. FIELD is a FIELD_DECL to be added after those fields already present in T. (FIELD is not actually added to the TYPE_FIELDS list here; callers that desire that behavior must manually perform that step.)
References record_layout_info_s::bitpos, excess_unit_span(), host_integerp(), HOST_WIDE_INT, inform(), input_location, integer_zerop(), layout_decl(), maximum_field_alignment, normalize_rli(), offset, record_layout_info_s::offset, record_layout_info_s::offset_align, record_layout_info_s::packed_maybe_necessary, record_layout_info_s::pending_statics, place_union_field(), record_layout_info_s::prev_field, record_layout_info_s::record_align, record_layout_info_s::remaining_in_alignment, simple_cst_equal(), record_layout_info_s::t, targetm, tree_low_cst(), update_alignment_for_field(), vec_safe_push(), and warning().
Referenced by layout_type().
|
static |
Referenced by place_field().
|
static |
Called from place_field to handle unions.
References record_layout_info_s::offset, record_layout_info_s::t, and update_alignment_for_field().
Split the bit position POS into a byte offset *POFFSET and a bit position *PBITPOS with the byte offset aligned to OFF_ALIGN bits.
References tree_int_cst_equal().
Referenced by normalize_offset().
void relayout_decl | ( | ) |
Given a VAR_DECL, PARM_DECL or RESULT_DECL, clears the results of a previous call to layout_decl and calls it again.
References layout_decl().
Referenced by decl_attributes(), and vectorize_loops().
tree rli_size_so_far | ( | ) |
Returns the size in bits allocated so far.
References bit_from_pos(), record_layout_info_s::bitpos, and record_layout_info_s::offset.
Referenced by finalize_record_size().
tree rli_size_unit_so_far | ( | ) |
Returns the size in bytes allocated so far.
References record_layout_info_s::bitpos, byte_from_pos(), and record_layout_info_s::offset.
Referenced by finalize_record_size().
Referenced by variable_size().
|
static |
Given a SIZE expression that is self-referential, return an equivalent expression to serve as the actual size expression for a type.
References build_call_expr_loc_vec(), build_function_type(), chainon(), copy_self_referential_tree_r(), find_placeholder_in_expr(), get_file_function_name(), get_identifier(), HOST_WIDE_INT, HOST_WIDE_INT_PRINT_UNSIGNED, input_location, nreverse(), size_functions, skip_simple_constant_arithmetic(), subst(), substitute_in_expr(), targetm, vec_alloc(), vec_safe_push(), and vNULL.
void set_min_and_max_values_for_integral_type | ( | tree | type, |
int | precision, | ||
bool | is_unsigned | ||
) |
TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE or BOOLEAN_TYPE. Set TYPE_MIN_VALUE and TYPE_MAX_VALUE for TYPE, based on the PRECISION and whether or not the TYPE IS_UNSIGNED. PRECISION need not correspond to a width supported natively by the hardware; for example, on a machine with 8-bit, 16-bit, and 32-bit register modes, PRECISION might be 7, 23, or 61.
References build_int_cst(), build_int_cst_wide(), HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.
Referenced by fixup_signed_type(), fixup_unsigned_type(), and initialize_sizetypes().
enum machine_mode smallest_mode_for_size | ( | ) |
Similar, but never return BLKmode; return the narrowest mode that contains at least the requested number of value bits.
|
static |
Return a new underlying object for a bitfield started with FIELD.
Referenced by finish_bitfield_layout().
record_layout_info start_record_layout | ( | ) |
Begin laying out type T, which may be a RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE. Return a pointer to a struct record_layout_info which is to be passed to all other layout functions for this record. It is the responsibility of the caller to call `free' for the storage returned. Note that garbage collection is not permitted until we finish laying out the record.
References record_layout_info_s::bitpos, maximum_field_alignment, record_layout_info_s::offset, record_layout_info_s::offset_align, record_layout_info_s::packed_maybe_necessary, record_layout_info_s::pending_statics, record_layout_info_s::prev_field, record_layout_info_s::record_align, record_layout_info_s::remaining_in_alignment, record_layout_info_s::t, and record_layout_info_s::unpacked_align.
Referenced by layout_type().
unsigned int update_alignment_for_field | ( | record_layout_info | rli, |
tree | field, | ||
unsigned int | known_align | ||
) |
FIELD is about to be added to RLI->T. The alignment (in bits) of the next available location within the record is given by KNOWN_ALIGN. Update the variable alignment fields in RLI, and return the alignment to give the FIELD.
References integer_zerop(), layout_decl(), maximum_field_alignment, record_layout_info_s::prev_field, record_layout_info_s::record_align, record_layout_info_s::t, targetm, and record_layout_info_s::unpacked_align.
Referenced by place_field(), and place_union_field().
tree variable_size | ( | ) |
Given a size SIZE that may not be a constant, return a SAVE_EXPR to serve as the actual size-expression for a type or decl.
References lang_hooks::decls, lang_hooks_for_decls::global_bindings_p, save_expr(), and self_referential_size().
Referenced by finalize_type_size(), layout_decl(), and store_one_arg().
enum machine_mode vector_type_mode | ( | ) |
Vector types need to re-check the target flags each time we report the machine mode. We need to do this because attribute target can change the result of vector_mode_supported_p and have_regs_of_mode on a per-function basis. Thus the TYPE_MODE of a VECTOR_TYPE can change on a per-function basis.
??? Possibly a better solution is to run through all the types referenced by a function and re-compute the TYPE_MODE once, rather than make the TYPE_MODE macro call a function.
References mode_for_size(), and targetm.
unsigned int maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT |
If nonzero, this is an upper limit on alignment of structure fields. The value is measured in bits.
Referenced by layout_decl(), place_field(), process_options(), start_record_layout(), and update_alignment_for_field().
|
static |
Nonzero if all REFERENCE_TYPEs are internal and hence should be allocated in the address spaces' address_mode, not pointer_mode. Set only by internal_reference_types called only by a front end.
Referenced by internal_reference_types(), and layout_type().
An array of functions used for self-referential size computation.
Referenced by finalize_size_functions(), and self_referential_size().
tree sizetype_tab[(int) stk_type_kind_last] |
@verbatim C-compiler utilities for types and variables storage layout
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
Data type for the expressions representing sizes of data types. It is the first integer type laid out.
Referenced by preload_common_nodes(), and size_int_kind().