GCC Middle and Back End API 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"
Functions | |
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) |
opt_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 | compute_array_mode (tree 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) |
Variables | |
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 |
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().
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().
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().
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().
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().
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().
void compute_array_mode | ( | tree | type | ) |
Compute TYPE_MODE for TYPE (which is ARRAY_TYPE).
References gcc_assert, GET_MODE_ALIGNMENT, mode_for_array(), SET_TYPE_MODE, targetm, TREE_CODE, TREE_TYPE, TYPE_ALIGN, TYPE_MODE, TYPE_NO_FORCE_BLK, and TYPE_SIZE.
Referenced by layout_type(), and unpack_ts_type_common_value_fields().
void compute_record_mode | ( | tree | type | ) |
Compute the TYPE_MODE for the TYPE (which is a RECORD_TYPE).
References bit_position(), DECL_CHAIN, DECL_MODE, DECL_SIZE, opt_mode< T >::else_blk(), GET_MODE_ALIGNMENT, GET_MODE_BITSIZE(), GET_MODE_CLASS, GET_MODE_PRECISION(), integer_zerop(), known_eq, known_gt, mode_for_size_tree(), poly_int_tree_p(), SET_TYPE_MODE, targetm, TREE_CODE, tree_fits_poly_uint64_p(), TREE_TYPE, TYPE_ALIGN, TYPE_FIELDS, TYPE_MODE, TYPE_NO_FORCE_BLK, and TYPE_SIZE.
Referenced by finish_record_layout(), and unpack_ts_type_common_value_fields().
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().
|
extern |
Print debugging information about the information in RLI.
References debug, print_node_brief(), targetm, and vec_safe_is_empty().
Subroutine of layout_decl: Force alignment required for the data type. But if the decl itself wants greater alignment, don't override that.
References DECL_ALIGN, DECL_USER_ALIGN, DECL_WARN_IF_NOT_ALIGN, SET_DECL_ALIGN, SET_DECL_WARN_IF_NOT_ALIGN, TREE_CODE, TYPE_ALIGN, TYPE_USER_ALIGN, and TYPE_WARN_IF_NOT_ALIGN.
Referenced by layout_decl().
|
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 offset, tree_to_uhwi(), and TYPE_SIZE.
Referenced by place_field().
|
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 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().
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().
|
static |
Compute TYPE_SIZE and TYPE_ALIGN for TYPE, once it has been laid out.
References AGGREGATE_TYPE_P, bitsize_unit_node, empty_p(), fold_convert, GET_MODE_ALIGNMENT, MAX, NULL_TREE, round_up, SET_TYPE_ALIGN, SET_TYPE_MODE, size_binop, sizetype, targetm, TREE_CODE, TYPE_ALIGN, TYPE_ALIGN_UNIT, TYPE_EMPTY_P, TYPE_MAIN_VARIANT, TYPE_MODE, TYPE_NEXT_VARIANT, TYPE_PRECISION, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_TYPELESS_STORAGE, TYPE_USER_ALIGN, and variable_size().
Referenced by finish_record_layout(), and layout_type().
void finish_bitfield_layout | ( | tree | t | ) |
Compute and set FIELD_DECLs for the underlying objects we should use for bitfield access for the structure T.
References DECL_BIT_FIELD_REPRESENTATIVE, DECL_BIT_FIELD_TYPE, DECL_CHAIN, DECL_FIELD_OFFSET, DECL_SIZE, finish_bitfield_representative(), gcc_assert, integer_zerop(), NULL_TREE, operand_equal_p(), start_bitfield_representative(), TREE_CODE, tree_fits_uhwi_p(), and TYPE_FIELDS.
Referenced by finish_record_layout().
Finish up a bitfield group that was started by creating the underlying object REPR with the last field in the bitfield group FIELD.
References bitint_info::abi_limb_mode, as_a(), bitsize_int, build_array_type_nelts(), CEIL, DECL_CHAIN, DECL_CONTEXT, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_SIZE, DECL_SIZE_UNIT, error_mark_node, opt_mode< T >::exists(), FOR_EACH_MODE_IN_CLASS, gcc_assert, GET_MODE_BITSIZE(), GET_MODE_PRECISION(), bitint_info::limb_mode, MAX_FIXED_MODE_SIZE, NULL_TREE, opt_mode< T >::require(), SET_DECL_MODE, size_diffop, size_int, targetm, TREE_CODE, tree_fits_uhwi_p(), TREE_OPERAND, tree_to_uhwi(), TREE_TYPE, lang_hooks_for_types::type_for_mode, TYPE_PRECISION, lang_hooks::types, lang_hooks_for_types::unit_size_without_reusable_padding, and unsigned_char_type_node.
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 build_decl(), BUILTINS_LOCATION, DECL_CHAIN, DECL_FIELD_CONTEXT, fields, get_identifier(), layout_decl(), layout_type(), NULL_TREE, SET_TYPE_ALIGN, SET_TYPE_WARN_IF_NOT_ALIGN, type(), TYPE_ALIGN, TYPE_FIELDS, TYPE_NAME, TYPE_STUB_DECL, TYPE_USER_ALIGN, and TYPE_WARN_IF_NOT_ALIGN.
Referenced by build_fn_info_type(), build_info_type(), init_ic_make_global_vars(), and lhd_simulate_record_decl().
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().
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().
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().
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().
unsigned int get_mode_alignment | ( | machine_mode | mode | ) |
Return the alignment of MODE. This will be bounded by 1 and BIGGEST_ALIGNMENT.
References MAX, MIN, and mode_base_align.
Referenced by emit_move_complex().
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().
|
static |
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().
void initialize_sizetypes | ( | void | ) |
Initialize sizetypes so layout_type can use them.
References int_n_data_t::bitsize, bitsize_int, bitsizetype, gcc_unreachable, get_identifier(), GET_MODE_ALIGNMENT, GET_MODE_PRECISION(), GET_MODE_SIZE(), HOST_BITS_PER_DOUBLE_INT, i, int_n_data, int_n_enabled_p, INT_TYPE_SIZE, LONG_LONG_TYPE_SIZE, LONG_TYPE_SIZE, make_node(), make_signed_type(), MAX_FIXED_MODE_SIZE, MIN, opt_mode< T >::require(), require(), sbitsizetype, set_min_and_max_values_for_integral_type(), SET_TYPE_ALIGN, SET_TYPE_MODE, SHORT_TYPE_SIZE, size_int, SIZETYPE, sizetype, smallest_int_mode_for_size(), ssizetype, TYPE_MODE, TYPE_NAME, TYPE_PRECISION, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_UNSIGNED, and UNSIGNED.
Referenced by build_common_tree_nodes().
opt_scalar_int_mode int_mode_for_mode | ( | machine_mode | mode | ) |
Return an integer mode of exactly the same size as MODE, if one exists.
References as_a(), gcc_unreachable, GET_MODE_BITSIZE(), GET_MODE_CLASS, and int_mode_for_size().
Referenced by bitwise_mode_for_mode(), convert_extracted_bit_field(), convert_float_to_wider_int(), convert_wider_int_to_float(), emit_group_load_1(), emit_group_store(), emit_move_via_integer(), expand_builtin_issignaling(), expand_builtin_signbit(), expand_copysign_absneg(), expand_copysign_bit(), expand_debug_expr(), extract_bit_field_1(), extract_integral_bit_field(), extract_low_bits(), gen_lowpart_for_combine(), gen_lowpart_or_truncate(), get_absneg_bit_mode(), get_stored_val(), ifcvt_can_use_mask_load_store(), prepare_call_arguments(), related_int_vector_mode(), resolve_simple_move(), store_bit_field_1(), and store_integral_bit_field().
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().
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(), compute_array_mode(), 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_size_tree(), mode_for_vector(), nreverse(), NULL_TREE, place_field(), POINTER_SIZE, POINTER_SIZE_UNITS, RECORD_OR_UNION_TYPE_P, opt_mode< T >::require(), 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().
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().
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().
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().
tree make_unsigned_type | ( | int | precision | ) |
Create and return a type for unsigned integers of PRECISION bits.
References fixup_unsigned_type(), make_node(), type(), and TYPE_PRECISION.
Referenced by assemble_crc_table(), build_common_tree_nodes(), operator_cast::fold_range(), operator_cast::fold_range(), vect_create_epilog_for_reduction(), and vectorizable_reduction().
unsigned int min_align_of_type | ( | tree | type | ) |
Return the least alignment required for type TYPE.
References MIN, NULL_TREE, TYPE_ALIGN, and TYPE_USER_ALIGN.
Referenced by fold_unary_loc(), get_object_alignment_2(), gimple_fold_builtin_clear_padding(), and instrument_mem_ref().
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 compute_array_mode().
opt_machine_mode mode_for_size | ( | poly_uint64 | size, |
enum mode_class | mclass, | ||
int | limit ) |
Return a machine mode of class MCLASS with SIZE bits of precision, if one exists. The mode may have padding bits as well the SIZE value bits. If LIMIT is nonzero, disregard modes wider than MAX_FIXED_MODE_SIZE.
References FOR_EACH_MODE_IN_CLASS, GET_MODE_PRECISION(), i, int_n_data, int_n_enabled_p, known_eq, int_n_data_t::m, MAX_FIXED_MODE_SIZE, and maybe_gt.
Referenced by assemble_integer(), bitwise_mode_for_mode(), bitwise_mode_for_size(), decimal_float_mode_for_size(), default_secondary_memory_needed_mode(), extract_bit_field_1(), float_mode_for_size(), init_derived_machine_modes(), int_mode_for_size(), make_accum_type(), make_fract_type(), mode_for_size_tree(), replace_reg_with_saved_mem(), and simplify_subreg_concatn().
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().
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.
References FOR_EACH_MODE_FROM, GET_MODE_BITSIZE(), GET_MODE_CLASS, GET_MODE_INNER, GET_MODE_NUNITS(), have_regs_of_mode, int_mode_for_size(), known_eq, SCALAR_ACCUM_MODE_P, SCALAR_FLOAT_MODE_P, SCALAR_FRACT_MODE_P, SCALAR_UACCUM_MODE_P, SCALAR_UFRACT_MODE_P, and targetm.
Referenced by default_vectorize_related_mode(), get_related_vectype_for_scalar_type(), layout_type(), lto_read_tree_1(), simplify_vector_constructor(), and undistribute_bitref_for_vector().
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().
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().
void place_field | ( | record_layout_info | rli, |
tree | 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 AGGREGATE_TYPE_P, bitsize_int, bitsize_unit_node, bitsize_zero_node, bitsizetype, BUILTINS_LOCATION, DECL_BIT_FIELD, DECL_BIT_FIELD_TYPE, DECL_CHAIN, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_OFFSET_ALIGN, DECL_PACKED, DECL_SIZE, DECL_SIZE_UNIT, DECL_SOURCE_LOCATION, error_mark_node, excess_unit_span(), fold_convert, gcc_assert, handle_warn_if_not_align(), inform(), input_location, integer_zerop(), layout_decl(), least_bit_hwi(), MAX, maximum_field_alignment, MIN, multiple_of_p(), normalize_rli(), NULL, offset, PCC_BITFIELD_TYPE_MATTERS, place_union_field(), round_up, SET_DECL_OFFSET_ALIGN, SET_TYPE_WARN_IF_NOT_ALIGN, simple_cst_equal(), size_binop, sizetype, strip_array_types(), targetm, TREE_CODE, TREE_CONSTANT, tree_fits_shwi_p(), tree_fits_uhwi_p(), TREE_INT_CST_LOW, TREE_OVERFLOW, tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_ALIGN, TYPE_ARTIFICIAL, TYPE_PACKED, TYPE_SIZE, TYPE_TYPELESS_STORAGE, TYPE_USER_ALIGN, TYPE_WARN_IF_NOT_ALIGN, update_alignment_for_field(), VAR_P, variable_size(), vec_safe_push(), and warning().
Referenced by layout_type().
|
static |
Called from place_field to handle unions.
References AGGREGATE_TYPE_P, bitsize_zero_node, build_int_cst(), DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_QUALIFIER, DECL_SIZE_UNIT, fold_build3, handle_warn_if_not_align(), SET_DECL_OFFSET_ALIGN, size_binop, size_zero_node, sizetype, TREE_CODE, TREE_TYPE, TYPE_TYPELESS_STORAGE, and update_alignment_for_field().
Referenced by place_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 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().
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(), get_absneg_bit_mode(), and signed_or_unsigned_type_for().
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().
void relayout_decl | ( | tree | decl | ) |
Given a VAR_DECL, PARM_DECL, RESULT_DECL, or FIELD_DECL, clears the results of a previous call to layout_decl and calls it again.
References DECL_RTL_SET_P, DECL_SIZE, DECL_SIZE_UNIT, DECL_USER_ALIGN, layout_decl(), SET_DECL_ALIGN, SET_DECL_MODE, and SET_DECL_RTL.
Referenced by allocate_struct_function(), decl_attributes(), shrink_simd_arrays(), and simd_clone_adjust().
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().
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().
Return true if T is a self-referential component reference.
References REFERENCE_CLASS_P, TREE_CODE, and TREE_OPERAND.
Referenced by copy_self_referential_tree_r(), and self_referential_size().
Given a SIZE expression that is self-referential, return an equivalent expression to serve as the actual size expression for a type.
References BLOCK_SUPERCONTEXT, build1(), build2(), build_call_expr_loc_vec(), build_decl(), build_function_type(), chainon(), copy_self_referential_tree_r(), DECL_ARG_TYPE, DECL_ARGUMENTS, DECL_ARTIFICIAL, DECL_CHAIN, DECL_CONTEXT, DECL_DECLARED_INLINE_P, DECL_IGNORED_P, DECL_INITIAL, DECL_P, DECL_RESULT, DECL_SAVED_TREE, find_placeholder_in_expr(), FOR_EACH_VEC_ELT, gcc_assert, get_file_function_name(), get_identifier(), HOST_WIDE_INT_PRINT_UNSIGNED, i, input_location, make_node(), nreverse(), NULL, NULL_TREE, self_referential_component_ref_p(), size_functions, skip_simple_constant_arithmetic(), subst(), substitute_in_expr(), TREE_CODE, tree_cons(), TREE_NOTHROW, TREE_OPERAND, TREE_READONLY, TREE_STATIC, TREE_TYPE, UNKNOWN_LOCATION, vec_alloc(), vec_safe_push(), vNULL, void_type_node, and walk_tree.
Referenced by variable_size().
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 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().
opt_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, if such a mode exists.
References FOR_EACH_MODE_IN_CLASS, 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().
Return a new underlying object for a bitfield started with FIELD.
References bitsize_int, DECL_CONTEXT, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_NONADDRESSABLE_P, DECL_OFFSET_ALIGN, DECL_PACKED, DECL_SIZE, DECL_SIZE_UNIT, make_node(), SET_DECL_OFFSET_ALIGN, and size_binop.
Referenced by finish_bitfield_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().
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 DECL_ALIGN, DECL_BIT_FIELD_TYPE, DECL_NAME, DECL_PACKED, DECL_SIZE, DECL_USER_ALIGN, error_mark_node, integer_zerop(), layout_decl(), MAX, maximum_field_alignment, MIN, NULL_TREE, PCC_BITFIELD_TYPE_MATTERS, targetm, TREE_CODE, TREE_TYPE, TYPE_ALIGN, TYPE_SIZE, and TYPE_USER_ALIGN.
Referenced by place_field(), and place_union_field().
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().
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().
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] |
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 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().