GCC Middle and Back End API Reference
stor-layout.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "function.h"
#include "rtl.h"
#include "tree.h"
#include "memmodel.h"
#include "tm_p.h"
#include "stringpool.h"
#include "regs.h"
#include "emit-rtl.h"
#include "cgraph.h"
#include "diagnostic-core.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "varasm.h"
#include "print-tree.h"
#include "langhooks.h"
#include "tree-inline.h"
#include "dumpfile.h"
#include "gimplify.h"
#include "attribs.h"
#include "debug.h"
#include "calls.h"
#include "gt-stor-layout.h"
Include dependency graph for stor-layout.cc:


static tree self_referential_size (tree)
static void finalize_record_size (record_layout_info)
static void finalize_type_size (tree)
static void place_union_field (record_layout_info, tree)
static int excess_unit_span (HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT, tree)
void debug_rli (record_layout_info)
tree variable_size (tree size)
static bool self_referential_component_ref_p (tree t)
static tree copy_self_referential_tree_r (tree *tp, int *walk_subtrees, void *data)
void finalize_size_functions (void)
opt_machine_mode mode_for_size (poly_uint64 size, enum mode_class mclass, int limit)
opt_machine_mode mode_for_size_tree (const_tree size, enum mode_class mclass, int limit)
machine_mode smallest_mode_for_size (poly_uint64 size, enum mode_class mclass)
opt_scalar_int_mode int_mode_for_mode (machine_mode mode)
opt_machine_mode bitwise_mode_for_mode (machine_mode mode)
tree bitwise_type_for_mode (machine_mode mode)
opt_machine_mode bitwise_mode_for_size (poly_uint64 size)
opt_machine_mode mode_for_vector (scalar_mode innermode, poly_uint64 nunits)
opt_machine_mode related_vector_mode (machine_mode vector_mode, scalar_mode element_mode, poly_uint64 nunits)
opt_machine_mode related_int_vector_mode (machine_mode vector_mode)
unsigned int get_mode_alignment (machine_mode mode)
static machine_mode mode_for_array (tree elem_type, tree size)
static void do_type_align (tree type, tree decl)
void layout_decl (tree decl, unsigned int known_align)
void relayout_decl (tree decl)
record_layout_info start_record_layout (tree t)
static tree bits_from_bytes (tree x)
tree bit_from_pos (tree offset, tree bitpos)
tree byte_from_pos (tree offset, tree bitpos)
void pos_from_bit (tree *poffset, tree *pbitpos, unsigned int off_align, tree pos)
void normalize_offset (tree *poffset, tree *pbitpos, unsigned int off_align)
void normalize_rli (record_layout_info rli)
tree rli_size_unit_so_far (record_layout_info rli)
tree rli_size_so_far (record_layout_info rli)
unsigned int update_alignment_for_field (record_layout_info rli, tree field, unsigned int known_align)
static void handle_warn_if_not_align (tree field, unsigned int record_align)
void place_field (record_layout_info rli, tree field)
void compute_record_mode (tree type)
static tree start_bitfield_representative (tree field)
static void finish_bitfield_representative (tree repr, tree field)
void finish_bitfield_layout (tree t)
void finish_record_layout (record_layout_info rli, int free_p)
void finish_builtin_struct (tree type, const char *name, tree fields, tree align_type)
void layout_type (tree type)
unsigned int min_align_of_type (tree type)
tree make_signed_type (int precision)
tree make_unsigned_type (int precision)
tree make_fract_type (int precision, int unsignedp, int satp)
tree make_accum_type (int precision, int unsignedp, int satp)
void initialize_sizetypes (void)
void set_min_and_max_values_for_integral_type (tree type, int precision, signop sgn)
void fixup_signed_type (tree type)
void fixup_unsigned_type (tree type)
bool get_best_mode (int bitsize, int bitpos, poly_uint64 bitregion_start, poly_uint64 bitregion_end, unsigned int align, unsigned HOST_WIDE_INT largest_mode_bitsize, bool volatilep, scalar_int_mode *best_mode)
void get_mode_bounds (scalar_int_mode mode, int sign, scalar_int_mode target_mode, rtx *mmin, rtx *mmax)


tree sizetype_tab [(int) stk_type_kind_last]
unsigned int maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT
static vec< tree, va_gc > * size_functions

Function Documentation

◆ bit_from_pos()

tree bit_from_pos ( tree offset,
tree bitpos )
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.   

References bits_from_bytes(), bitsize_unit_node, offset, and size_binop.

Referenced by add_data_member_location_attribute(), bit_position(), eliminate_dom_walker::eliminate_stmt(), and rli_size_so_far().

◆ bits_from_bytes()

static tree bits_from_bytes ( tree x)
Fold sizetype value X to bitsizetype, given that X represents a type
size or offset.   

References bitsizetype, build_poly_int_cst(), fold_convert, poly_int< N, C >::from(), gcc_checking_assert, POLY_INT_CST_P, poly_int_cst_value(), TREE_TYPE, TYPE_PRECISION, and TYPE_SIGN.

Referenced by bit_from_pos(), and layout_type().

◆ bitwise_mode_for_mode()

opt_machine_mode bitwise_mode_for_mode ( machine_mode mode)
Find a mode that can be used for efficient bitwise operations on MODE,
if one exists.   

References COMPLEX_MODE_P, gcc_checking_assert, GET_MODE_BITSIZE(), GET_MODE_CLASS, GET_MODE_INNER, have_regs_of_mode, int_mode_for_mode(), is_a(), MAX_FIXED_MODE_SIZE, maybe_gt, mode_for_size(), targetm, and VECTOR_MODE_P.

Referenced by bitwise_type_for_mode().

◆ bitwise_mode_for_size()

opt_machine_mode bitwise_mode_for_size ( poly_uint64 size)
Find a mode that can be used for efficient bitwise operations on SIZE
bits, if one exists.   

References FOR_EACH_MODE_FROM, GET_MODE_BITSIZE(), GET_MODE_INNER, have_regs_of_mode, known_eq, known_le, MAX_FIXED_MODE_SIZE, mode_for_size(), and targetm.

Referenced by gimple_fold_builtin_memory_op().

◆ bitwise_type_for_mode()

tree bitwise_type_for_mode ( machine_mode mode)
Find a type that can be used for efficient bitwise operations on MODE.
Return null if no such mode exists.   

References bitwise_mode_for_mode(), build_complex_type(), build_nonstandard_integer_type(), build_vector_type_for_mode(), COMPLEX_MODE_P, gcc_checking_assert, GET_MODE_INNER, GET_MODE_UNIT_BITSIZE, NULL_TREE, and VECTOR_MODE_P.

Referenced by gimple_fold_builtin_memory_op().

◆ byte_from_pos()

tree byte_from_pos ( tree offset,
tree bitpos )
Return the combined truncated byte position for the byte offset OFFSET and
the bit position BITPOS.   

References bitsize_unit_node, fold_convert, offset, size_binop, sizetype, TREE_CODE, tree_int_cst_equal(), and TREE_OPERAND.

Referenced by byte_position(), and rli_size_unit_so_far().

◆ compute_record_mode()

◆ copy_self_referential_tree_r()

static tree copy_self_referential_tree_r ( tree * tp,
int * walk_subtrees,
void * data )
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(), error_mark_node, gcc_unreachable, NULL_TREE, self_referential_component_ref_p(), tcc_constant, tcc_declaration, tcc_type, TREE_CODE, TREE_CODE_CLASS, and TREE_OPERAND.

Referenced by self_referential_size().

◆ debug_rli()

DEBUG_FUNCTION void debug_rli ( record_layout_info rli)
Print debugging information about the information in RLI.   

References debug, print_node_brief(), targetm, and vec_safe_is_empty().

◆ do_type_align()

static void do_type_align ( tree type,
tree decl )
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().

◆ excess_unit_span()

static int excess_unit_span ( HOST_WIDE_INT byte_offset,
HOST_WIDE_INT bit_offset,
tree type )
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 offset, tree_to_uhwi(), and TYPE_SIZE.

Referenced by place_field().

◆ finalize_record_size()

static void finalize_record_size ( record_layout_info rli)
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 BUILTINS_LOCATION, DECL_NAME, input_location, integer_zerop(), MAX, normalize_rli(), rli_size_so_far(), rli_size_unit_so_far(), round_up, SET_TYPE_ALIGN, simple_cst_equal(), size_binop, size_one_node, TREE_CODE, TREE_CONSTANT, TYPE_ALIGN, TYPE_ALIGN_UNIT, TYPE_ARTIFICIAL, TYPE_NAME, TYPE_PACKED, TYPE_SIZE, TYPE_SIZE_UNIT, and warning().

Referenced by finish_record_layout().

◆ finalize_size_functions()

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(), debug_hooks, dump_function(), cgraph_node::finalize_function(), gimplify_function_tree(), i, NULL, set_cfun(), gcc_debug_hooks::size_function, size_functions, TDI_original, and vec_free().

Referenced by symbol_table::finalize_compilation_unit().

◆ finalize_type_size()

◆ finish_bitfield_layout()

void finish_bitfield_layout ( tree t)

◆ finish_bitfield_representative()

◆ finish_builtin_struct()

void finish_builtin_struct ( tree type,
const char * name,
tree fields,
tree align_type )
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


Referenced by build_fn_info_type(), build_info_type(), init_ic_make_global_vars(), and lhd_simulate_record_decl().

◆ finish_record_layout()

void finish_record_layout ( record_layout_info rli,
int free_p )
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(), TYPE_NEXT_VARIANT, TYPE_PACKED, TYPE_REVERSE_STORAGE_ORDER, vec_free(), and vec_safe_is_empty().

Referenced by layout_type().

◆ fixup_signed_type()

void fixup_signed_type ( tree 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.   

References layout_type(), set_min_and_max_values_for_integral_type(), SIGNED, and TYPE_PRECISION.

Referenced by build_bitint_type(), build_nonstandard_boolean_type(), build_nonstandard_integer_type(), and make_signed_type().

◆ fixup_unsigned_type()

void fixup_unsigned_type ( tree 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(), set_min_and_max_values_for_integral_type(), TYPE_PRECISION, TYPE_UNSIGNED, and UNSIGNED.

Referenced by build_bitint_type(), build_nonstandard_integer_type(), and make_unsigned_type().

◆ get_best_mode()

bool get_best_mode ( int bitsize,
int bitpos,
poly_uint64 bitregion_start,
poly_uint64 bitregion_end,
unsigned int align,
unsigned HOST_WIDE_INT largest_mode_bitsize,
bool volatilep,
scalar_int_mode * best_mode )
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 chosen mode must have no more than LARGEST_MODE_BITSIZE bits.
INT_MAX is a suitable value for LARGEST_MODE_BITSIZE if the caller
doesn't want to apply a specific limit.

If no mode meets all these conditions, we return VOIDmode.

The underlying object is known to be aligned to a boundary of ALIGN bits.

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 GET_MODE_ALIGNMENT, GET_MODE_BITSIZE(), 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().

◆ get_mode_alignment()

unsigned int get_mode_alignment ( machine_mode mode)
Return the alignment of MODE. This will be bounded by 1 and

References MAX, MIN, and mode_base_align.

Referenced by emit_move_complex().

◆ get_mode_bounds()

void get_mode_bounds ( scalar_int_mode mode,
int sign,
scalar_int_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 gcc_assert, gen_int_mode(), GET_MODE_PRECISION(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_1U, and STORE_FLAG_VALUE.

Referenced by determine_max_iter(), iv_number_of_iterations(), shorten_into_mode(), and simplify_const_relational_operation().

◆ handle_warn_if_not_align()

static void handle_warn_if_not_align ( tree field,
unsigned int record_align )
Issue a warning if the record alignment, RECORD_ALIGN, is less than
the field alignment of FIELD or FIELD isn't aligned.  

References byte_position(), DECL_CONTEXT, DECL_WARN_IF_NOT_ALIGN, error_mark_node, lookup_attribute(), multiple_of_p(), size_int, TREE_CODE, TREE_TYPE, TYPE_ALIGN, TYPE_ATTRIBUTES, TYPE_WARN_IF_NOT_ALIGN, and warning().

Referenced by place_field(), and place_union_field().

◆ initialize_sizetypes()

◆ int_mode_for_mode()

◆ layout_decl()

void layout_decl ( tree decl,
unsigned int known_align )
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 bitsize_unit_node, compare_tree_int(), DECL_ALIGN, DECL_BIT_FIELD, DECL_BIT_FIELD_TYPE, DECL_EXTERNAL, DECL_FIELD_CONTEXT, DECL_MODE, DECL_NONLOCAL_FRAME, DECL_PACKED, DECL_RTL_IF_SET, DECL_SIZE, DECL_SIZE_UNIT, DECL_SOURCE_LOCATION, DECL_UNSIGNED, DECL_USER_ALIGN, do_type_align(), error_mark_node, fold_convert_loc(), gcc_assert, GET_MODE_ALIGNMENT, GET_MODE_CLASS, HOST_WIDE_INT_MAX, integer_zerop(), MAX, maximum_field_alignment, MEM_P, MIN, mode_for_size_tree(), NULL_RTX, PCC_BITFIELD_TYPE_MATTERS, ptrdiff_type_node, PUT_MODE(), SET_DECL_ALIGN, SET_DECL_MODE, SET_DECL_RTL, set_mem_attributes(), size_binop_loc(), sizetype, targetm, TREE_CODE, tree_to_shwi(), TREE_TYPE, type(), TYPE_ALIGN, TYPE_MAX_VALUE, TYPE_MODE, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_UNSIGNED, variable_size(), void_type_node, and warning().

Referenced by assemble_variable(), build_decl(), build_fake_var_decl(), ipa_param_body_adjustments::common_initialization(), expand_expr_real_1(), finalize_nesting_tree_1(), finish_builtin_struct(), finish_record_layout(), place_field(), relayout_decl(), split_complex_args(), and update_alignment_for_field().

◆ layout_type()

void layout_type ( tree 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 bitint_info::abi_limb_mode, AGGREGATE_TYPE_P, as_a(), bitint_info::big_endian, bits_from_bytes(), bitsize_int, build_int_cst(), CEIL, compare_tree_int(), DECL_CHAIN, opt_mode< T >::else_blk(), error(), error_mark_node, ffs_hwi(), finalize_type_size(), finish_record_layout(), float_mode_for_size(), fold_convert, gcc_assert, gcc_checking_assert, gcc_unreachable, GET_MODE_ALIGNMENT, GET_MODE_BITSIZE(), GET_MODE_COMPLEX_MODE, GET_MODE_PRECISION(), GET_MODE_SIZE(), int_const_binop(), int_mode_for_size(), integer_zerop(), bitint_info::limb_mode, MAX, mode_for_array(), mode_for_size_tree(), mode_for_vector(), nreverse(), NULL_TREE, place_field(), POINTER_SIZE, POINTER_SIZE_UNITS, RECORD_OR_UNION_TYPE_P, require(), SCALAR_INT_TYPE_MODE, SCALAR_TYPE_MODE, SET_TYPE_ALIGN, SET_TYPE_MODE, SET_TYPE_WARN_IF_NOT_ALIGN, SIGNED, size_binop, size_int, size_zero_node, sizetype, smallest_int_mode_for_size(), ssizetype, start_record_layout(), targetm, wi::to_wide(), TREE_CODE, tree_int_cst_lt(), TREE_OVERFLOW, TREE_TYPE, TYPE_ALIAS_SET_KNOWN_P, TYPE_ALIGN, TYPE_ALIGN_UNIT, TYPE_DOMAIN, TYPE_FIELDS, TYPE_MAIN_VARIANT, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_MODE, TYPE_NEXT_VARIANT, TYPE_NO_FORCE_BLK, TYPE_PRECISION, TYPE_SATURATING, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_TYPELESS_STORAGE, TYPE_UNSIGNED, TYPE_USER_ALIGN, TYPE_VECTOR_SUBPARTS(), TYPE_WARN_IF_NOT_ALIGN, VECTOR_BOOLEAN_TYPE_P, wide_int_to_tree(), and wi::zext().

Referenced by asan_global_struct(), build_array_type_1(), build_common_tree_nodes(), 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(), finish_taskreg_scan(), fixup_child_record_type(), fixup_signed_type(), fixup_unsigned_type(), get_descriptor_type(), get_emutls_object_type(), get_trampoline_type(), go_format_type(), init_eh(), lhd_simulate_enum_decl(), lower_omp_task_reductions(), make_accum_type(), make_fract_type(), make_vector_type(), oacc_do_neutering(), ompdevlow_adjust_simt_enter(), scan_omp_single(), scan_omp_target(), separate_decls_in_region(), task_copyfn_remap_type(), thunk_adjust(), type_hash_canon(), ubsan_create_data(), ubsan_get_source_location_type(), and ubsan_get_type_descriptor_type().

◆ make_accum_type()

tree make_accum_type ( int precision,
int unsignedp,
int satp )
Create and return a type for accum of PRECISION bits, UNSIGNEDP,
and SATP.   

References layout_type(), make_node(), mode_for_size(), require(), SET_TYPE_MODE, type(), TYPE_PRECISION, TYPE_SATURATING, and TYPE_UNSIGNED.

Referenced by make_or_reuse_accum_type().

◆ make_fract_type()

tree make_fract_type ( int precision,
int unsignedp,
int satp )
Create and return a type for fract of PRECISION bits, UNSIGNEDP,
and SATP.   

References layout_type(), make_node(), mode_for_size(), require(), SET_TYPE_MODE, type(), TYPE_PRECISION, TYPE_SATURATING, and TYPE_UNSIGNED.

Referenced by make_or_reuse_fract_type().

◆ make_signed_type()

tree make_signed_type ( int precision)
Create and return a type for signed integers of PRECISION bits.   

References fixup_signed_type(), make_node(), type(), and TYPE_PRECISION.

Referenced by build_common_tree_nodes(), and initialize_sizetypes().

◆ make_unsigned_type()

tree make_unsigned_type ( int precision)

◆ min_align_of_type()

unsigned int min_align_of_type ( tree type)
Return the least alignment required for type TYPE.   


Referenced by fold_unary_loc(), get_object_alignment_2(), gimple_fold_builtin_clear_padding(), and instrument_mem_ref().

◆ mode_for_array()

static machine_mode mode_for_array ( tree elem_type,
tree size )
Return the natural mode of an array, given that it is SIZE bytes in
total and has elements of type ELEM_TYPE.   

References opt_mode< T >::else_blk(), mode_for_size_tree(), poly_int_tree_p(), simple_cst_equal(), targetm, TYPE_MODE, and TYPE_SIZE.

Referenced by layout_type().

◆ mode_for_size()

opt_machine_mode mode_for_size ( poly_uint64 size,
enum mode_class mclass,
int limit )

◆ mode_for_size_tree()

opt_machine_mode mode_for_size_tree ( const_tree size,
enum mode_class mclass,
int limit )
Similar, except passed a tree node.   

References mode_for_size(), tree_fits_uhwi_p(), tree_to_uhwi(), and ui.

Referenced by compute_record_mode(), layout_decl(), layout_type(), and mode_for_array().

◆ mode_for_vector()

opt_machine_mode mode_for_vector ( scalar_mode innermode,
poly_uint64 nunits )
Find a mode that is suitable for representing a vector with NUNITS
elements of mode INNERMODE, if one exists.  The returned mode can be
either an integer mode or a vector mode.   


Referenced by default_vectorize_related_mode(), get_related_vectype_for_scalar_type(), layout_type(), simplify_vector_constructor(), and undistribute_bitref_for_vector().

◆ normalize_offset()

void normalize_offset ( tree * poffset,
tree * pbitpos,
unsigned int off_align )
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, pos_from_bit(), and size_binop.

Referenced by normalize_rli().

◆ normalize_rli()

void normalize_rli ( record_layout_info rli)
Given an RLI with a possibly-incremented BITPOS, adjust OFFSET and
BITPOS if necessary to keep BITPOS below OFFSET_ALIGN.   

References normalize_offset().

Referenced by finalize_record_size(), and place_field().

◆ place_field()

◆ place_union_field()

◆ pos_from_bit()

void pos_from_bit ( tree * poffset,
tree * pbitpos,
unsigned int off_align,
tree pos )
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 bitsize_int, bitsize_zero_node, fold_convert, size_binop, size_int, sizetype, TREE_CODE, tree_int_cst_equal(), and TREE_OPERAND.

Referenced by normalize_offset().

◆ related_int_vector_mode()

opt_machine_mode related_int_vector_mode ( machine_mode vector_mode)
If a piece of code is using vector mode VECTOR_MODE and also wants
to operate on integer vectors with the same element size and number
of elements, return the vector mode it should use.  Return an empty
opt_machine_mode if there is no supported vector mode with the
required properties.

Unlike mode_for_vector. any returned mode is guaranteed to satisfy
both VECTOR_MODE_P and targetm.vector_mode_supported_p.   

References gcc_assert, GET_MODE_INNER, GET_MODE_NUNITS(), int_mode_for_mode(), related_vector_mode(), and VECTOR_MODE_P.

Referenced by default_get_mask_mode(), expand_vec_perm_1(), expand_vec_perm_const(), and signed_or_unsigned_type_for().

◆ related_vector_mode()

opt_machine_mode related_vector_mode ( machine_mode vector_mode,
scalar_mode element_mode,
poly_uint64 nunits )
If a piece of code is using vector mode VECTOR_MODE and also wants
to operate on elements of mode ELEMENT_MODE, return the vector mode
it should use for those elements.  If NUNITS is nonzero, ensure that
the mode has exactly NUNITS elements, otherwise pick whichever vector
size pairs the most naturally with VECTOR_MODE; this may mean choosing
a mode with a different size and/or number of elements, depending on
what the target prefers.  Return an empty opt_machine_mode if there
is no supported vector mode with the required properties.

Unlike mode_for_vector. any returned mode is guaranteed to satisfy
both VECTOR_MODE_P and targetm.vector_mode_supported_p.   

References element_mode(), gcc_assert, targetm, and VECTOR_MODE_P.

Referenced by can_vec_extract(), can_vec_mask_load_store_p(), extract_bit_field_1(), get_len_load_store_mode(), get_related_vectype_for_scalar_type(), omp_clause_aligned_alignment(), qimode_for_vec_perm(), related_int_vector_mode(), vect_analyze_loop_1(), vect_chooses_same_modes_p(), vect_slp_region(), vector_vector_composition_type(), vectorizable_store(), and vectorized_internal_fn_supported_p().

◆ relayout_decl()

void relayout_decl ( tree decl)
results of a previous call to layout_decl and calls it again.   


Referenced by allocate_struct_function(), decl_attributes(), shrink_simd_arrays(), and simd_clone_adjust().

◆ rli_size_so_far()

tree rli_size_so_far ( record_layout_info rli)
Returns the size in bits allocated so far.   

References bit_from_pos().

Referenced by finalize_record_size().

◆ rli_size_unit_so_far()

tree rli_size_unit_so_far ( record_layout_info rli)
Returns the size in bytes allocated so far.   

References byte_from_pos().

Referenced by finalize_record_size().

◆ self_referential_component_ref_p()

static bool self_referential_component_ref_p ( tree t)
Return true if T is a self-referential component reference.   


Referenced by copy_self_referential_tree_r(), and self_referential_size().

◆ self_referential_size()

◆ set_min_and_max_values_for_integral_type()

void set_min_and_max_values_for_integral_type ( tree type,
int precision,
signop sgn )
TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE
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

References gcc_assert, wi::max_value(), wi::min_value(), TYPE_MAX_VALUE, TYPE_MIN_VALUE, WIDE_INT_MAX_PRECISION, and wide_int_to_tree().

Referenced by fixup_signed_type(), fixup_unsigned_type(), and initialize_sizetypes().

◆ smallest_mode_for_size()

machine_mode smallest_mode_for_size ( poly_uint64 size,
enum mode_class mclass )
Return the narrowest mode of class MCLASS that contains at least
SIZE bits.  Abort if no such mode exists.   

References FOR_EACH_MODE_IN_CLASS, gcc_assert, GET_MODE_PRECISION(), i, int_n_data, int_n_enabled_p, known_ge, known_lt, and int_n_data_t::m.

Referenced by smallest_int_mode_for_size().

◆ start_bitfield_representative()

static tree start_bitfield_representative ( tree field)

◆ start_record_layout()

record_layout_info start_record_layout ( tree t)
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 bitsize_zero_node, MAX, maximum_field_alignment, MIN, size_zero_node, TYPE_ALIGN, and TYPE_PACKED.

Referenced by layout_type().

◆ update_alignment_for_field()

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.   


Referenced by place_field(), and place_union_field().

◆ variable_size()

tree variable_size ( tree 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 CONTAINS_PLACEHOLDER_P, lang_hooks::decls, lang_hooks_for_decls::global_bindings_p, save_expr(), self_referential_size(), and TREE_CONSTANT.

Referenced by finalize_type_size(), layout_decl(), place_field(), and store_one_arg().

Variable Documentation

◆ maximum_field_alignment

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 compile_file(), layout_decl(), place_field(), process_options(), start_record_layout(), and update_alignment_for_field().

◆ size_functions

vec<tree, va_gc>* size_functions
An array of functions used for self-referential size computation.   

Referenced by finalize_size_functions(), and self_referential_size().

◆ sizetype_tab

tree sizetype_tab[(int) stk_type_kind_last]
C-compiler utilities for types and variables storage layout
   Copyright (C) 1987-2024 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

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
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
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().