GCC Middle and Back End API Reference
poly_int< N, C > Struct Template Reference

#include <poly-int.h>

Inheritance diagram for poly_int< N, C >:

Public Member Functions

 poly_int ()=default
 
 poly_int (const poly_int &)=default
 
template<typename Ca >
 poly_int (const poly_int< N, Ca > &)
 
template<typename ... Cs>
constexpr poly_int (const Cs &...)
 
poly_intoperator= (const poly_int &)=default
 
template<typename Ca >
poly_intoperator= (const poly_int< N, Ca > &)
 
template<typename Ca >
if_nonpoly< Ca, poly_int >::typeoperator= (const Ca &)
 
template<typename Ca >
poly_intoperator+= (const poly_int< N, Ca > &)
 
template<typename Ca >
if_nonpoly< Ca, poly_int >::typeoperator+= (const Ca &)
 
template<typename Ca >
poly_intoperator-= (const poly_int< N, Ca > &)
 
template<typename Ca >
if_nonpoly< Ca, poly_int >::typeoperator-= (const Ca &)
 
template<typename Ca >
if_nonpoly< Ca, poly_int >::typeoperator*= (const Ca &)
 
poly_intoperator<<= (unsigned int)
 
bool is_constant () const
 
template<typename T >
if_lossless< T, C, bool >::type is_constant (T *) const
 
to_constant () const
 
bool to_shwi (poly_int< N, HOST_WIDE_INT > *) const
 
bool to_uhwi (poly_int< N, unsigned HOST_WIDE_INT > *) const
 
poly_int< N, HOST_WIDE_INT > force_shwi () const
 
poly_int< N, unsigned HOST_WIDE_INT > force_uhwi () const
 
template<typename ... Cs>
constexpr poly_int (const Cs &... cs)
 
template<typename C0 , typename ... Cs>
constexpr poly_int (poly_int_hungry, const C0 &c0, const Cs &... cs)
 
template<typename ... Cs>
constexpr poly_int (poly_int_full, const Cs &... cs)
 
template<typename Ca >
poly_int< N, C > & operator= (const poly_int< N, Ca > &a)
 
template<typename Ca >
poly_int< N, C > & operator+= (const poly_int< N, Ca > &a)
 
template<typename Ca >
poly_int< N, C > & operator-= (const poly_int< N, Ca > &a)
 

Static Public Member Functions

template<typename Ca >
static poly_int< N, C > from (const poly_int< N, Ca > &, unsigned int, signop)
 
template<typename Ca >
static poly_int< N, C > from (const poly_int< N, Ca > &, signop)
 

Data Fields

coeffs [N]
 

Private Member Functions

template<typename ... Cs>
constexpr poly_int (poly_int_full, const Cs &...)
 
template<typename C0 , typename ... Cs>
constexpr poly_int (poly_int_hungry, const C0 &, const Cs &...)
 

Detailed Description

template<unsigned int N, typename C>
struct poly_int< N, C >
Polynomial integer classes.
   Copyright (C) 2014-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/>.   
This file provides a representation of sizes and offsets whose exact
values depend on certain runtime properties.  The motivating example
is the Arm SVE ISA, in which the number of vector elements is only
known at runtime.  See doc/poly-int.texi for more details.

Tests for poly-int.h are located in testsuite/gcc.dg/plugin,
since they are too expensive (in terms of binary size) to be
included as selftests.   
A class containing polynomial integers.  The polynomial has N coefficients
of type C, and N - 1 indeterminates.   

Constructor & Destructor Documentation

◆ poly_int() [1/9]

template<unsigned int N, typename C >
poly_int< N, C >::poly_int ( )
default

◆ poly_int() [2/9]

template<unsigned int N, typename C >
poly_int< N, C >::poly_int ( const poly_int< N, C > & )
default

◆ poly_int() [3/9]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C >::poly_int ( const poly_int< N, Ca > & a)
inline

References a, i, N, and POLY_SET_COEFF.

◆ poly_int() [4/9]

template<unsigned int N, typename C >
template<typename ... Cs>
poly_int< N, C >::poly_int ( const Cs & ...)
constexpr

◆ poly_int() [5/9]

template<unsigned int N, typename C >
template<typename ... Cs>
poly_int< N, C >::poly_int ( poly_int_full ,
const Cs & ... )
constexprprivate

◆ poly_int() [6/9]

template<unsigned int N, typename C >
template<typename C0 , typename ... Cs>
poly_int< N, C >::poly_int ( poly_int_hungry ,
const C0 & ,
const Cs & ... )
constexprprivate

◆ poly_int() [7/9]

template<unsigned int N, typename C >
template<typename ... Cs>
poly_int< N, C >::poly_int ( const Cs &... cs)
inlineconstexpr

◆ poly_int() [8/9]

template<unsigned int N, typename C >
template<typename C0 , typename ... Cs>
poly_int< N, C >::poly_int ( poly_int_hungry ,
const C0 & c0,
const Cs &... cs )
inlineconstexpr
Initialize with c0, cs..., and some trailing zeros.   

◆ poly_int() [9/9]

template<unsigned int N, typename C >
template<typename ... Cs>
poly_int< N, C >::poly_int ( poly_int_full ,
const Cs &... cs )
inlineconstexpr
Initialize with cs... directly, casting where necessary.   

Member Function Documentation

◆ force_shwi()

template<unsigned int N, typename C >
poly_int< N, HOST_WIDE_INT > poly_int< N, C >::force_shwi ( ) const
inline

◆ force_uhwi()

template<unsigned int N, typename C >
poly_int< N, unsigned HOST_WIDE_INT > poly_int< N, C >::force_uhwi ( ) const
inline
Force a generic_wide_int-based constant to unsigned HOST_WIDE_INT precision,
truncating if necessary.   

References poly_int< N, C >::coeffs, i, N, and r.

◆ from() [1/2]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C > poly_int< N, C >::from ( const poly_int< N, Ca > & a,
signop sgn )
inlinestatic
Convert X to a fixed_wide_int-based polynomial, extending according
to SGN.   

References a, i, N, POLY_SET_COEFF, and r.

◆ from() [2/2]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C > poly_int< N, C >::from ( const poly_int< N, Ca > & a,
unsigned int bitsize,
signop sgn )
inlinestatic
Convert X to a wide_int-based polynomial in which each coefficient
has BITSIZE bits.  If X's coefficients are smaller than BITSIZE,
extend them according to SGN.   

References a, i, N, POLY_SET_COEFF, and r.

Referenced by addr_for_mem_ref(), bits_from_bytes(), build_poly_int_cst(), fold_convert_const(), force_fit_type(), gen_int_mode(), immed_wide_int_const(), mem_ref_offset(), fold_using_range::range_of_address(), simplify_context::simplify_subreg(), vn_reference_fold_indirect(), vn_reference_lookup_3(), and vn_reference_maybe_forwprop_address().

◆ is_constant() [1/2]

template<unsigned int N, typename C >
bool poly_int< N, C >::is_constant ( ) const
inline
Return true if the polynomial value is a compile-time constant.   

References i, and N.

Referenced by addr_stridxptr(), address_compare(), aff_combination_add_product(), aff_combination_mult(), vec_perm_indices::all_in_range_p(), all_positions_needed_p(), any_positions_needed_p(), ao_ref_alignment(), vector_costs::better_epilogue_loop_than_p(), vector_builder< T, Shape, Derived >::binary_encoded_nelts(), check_sibcall_argument_overlap(), compute_trims(), constant_byte_string(), constant_multiple_of(), create_access(), decode_field_reference(), def_cfa_0(), dse_step5(), expand_stack_vars(), expand_vector_ubsan_overflow(), extract_bit_field(), extract_bit_field_1(), fold_const_aggregate_ref_1(), fold_ctor_reference(), fold_read_from_vector(), fold_vec_perm(), force_fit_type(), fortran_common(), frame_offset_overflow(), fully_constant_vn_reference_p(), gather_mem_refs_stmt(), gen_int_mode(), get_access_for_expr(), get_addr_stridx(), get_constraint_for_component_ref(), get_group_load_store_type(), get_load_store_type(), get_range_strlen_dynamic(), get_ref_base_and_extent_hwi(), get_stored_val(), pair_fusion::get_viable_bases(), immed_wide_int_const(), fixed_size_mode::includes_p(), int_loc_descriptor(), isra_get_ref_base_and_offset(), loc_descr_plus_const(), loc_list_for_address_of_addr_expr_of_indirect_ref(), loc_list_from_tree_1(), make_extraction(), make_item_for_dump_dec(), mark_stack_region_used(), maybe_optimize_ubsan_ptr_ifn(), native_interpret_aggregate(), vector_builder< T, Shape, Derived >::new_binary_operation(), vector_builder< T, Shape, Derived >::new_unary_operation(), vec_perm_indices::new_vector(), optimize_bit_field_compare(), optimize_bitfield_assignment_op(), pp_wide_integer(), print_poly_int(), pseudo_reg_slot_compare(), record_operand_costs(), record_store(), scan_stores(), set_all_positions_unneeded(), set_usage_bits(), shift_amt_for_vec_perm_mask(), slsr_process_ref(), stack_region_maybe_used_p(), store_bit_field(), store_constructor(), store_field(), valid_mask_for_fold_vec_perm_cst_p(), vect_build_slp_instance(), vect_build_slp_tree_2(), vect_compute_data_ref_alignment(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_init(), vect_create_nonlinear_iv_step(), vect_do_peeling(), vect_gen_prolog_loop_niters(), vect_gen_vector_loop_niters(), vect_transform_loop(), vect_transform_loops(), vect_transform_slp_perm_load_1(), vectorizable_induction(), vectorizable_load(), vectorizable_nonlinear_induction(), vectorizable_reduction(), vectorizable_slp_permutation_1(), vectorizable_store(), verify_sra_access_forest(), vn_reference_lookup_2(), vn_reference_lookup_3(), and wide_int_to_tree().

◆ is_constant() [2/2]

template<unsigned int N, typename C >
template<typename T >
if_lossless< T, C, bool >::type poly_int< N, C >::is_constant ( T * const_value) const
inline
Return true if the polynomial value is a compile-time constant,
storing its value in CONST_VALUE if so.   

◆ operator*=()

template<unsigned int N, typename C >
template<typename Ca >
if_nonpoly< Ca, poly_int< N, C > >::type & poly_int< N, C >::operator*= ( const Ca & a)
inline

References a, i, and N.

◆ operator+=() [1/3]

template<unsigned int N, typename C >
template<typename Ca >
if_nonpoly< Ca, poly_int< N, C > >::type & poly_int< N, C >::operator+= ( const Ca & a)
inline

References a.

◆ operator+=() [2/3]

template<unsigned int N, typename C >
template<typename Ca >
poly_int & poly_int< N, C >::operator+= ( const poly_int< N, Ca > & )

◆ operator+=() [3/3]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C > & poly_int< N, C >::operator+= ( const poly_int< N, Ca > & a)
inline

References a, poly_int< N, C >::coeffs, i, and N.

◆ operator-=() [1/3]

template<unsigned int N, typename C >
template<typename Ca >
if_nonpoly< Ca, poly_int< N, C > >::type & poly_int< N, C >::operator-= ( const Ca & a)
inline

References a.

◆ operator-=() [2/3]

template<unsigned int N, typename C >
template<typename Ca >
poly_int & poly_int< N, C >::operator-= ( const poly_int< N, Ca > & )

◆ operator-=() [3/3]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C > & poly_int< N, C >::operator-= ( const poly_int< N, Ca > & a)
inline

References a, poly_int< N, C >::coeffs, i, and N.

◆ operator<<=()

template<unsigned int N, typename C >
poly_int< N, C > & poly_int< N, C >::operator<<= ( unsigned int a)
inline

◆ operator=() [1/4]

template<unsigned int N, typename C >
template<typename Ca >
if_nonpoly< Ca, poly_int< N, C > >::type & poly_int< N, C >::operator= ( const Ca & a)
inline

References a, i, N, and POLY_SET_COEFF.

◆ operator=() [2/4]

template<unsigned int N, typename C >
poly_int & poly_int< N, C >::operator= ( const poly_int< N, C > & )
default

◆ operator=() [3/4]

template<unsigned int N, typename C >
template<typename Ca >
poly_int & poly_int< N, C >::operator= ( const poly_int< N, Ca > & )

◆ operator=() [4/4]

template<unsigned int N, typename C >
template<typename Ca >
poly_int< N, C > & poly_int< N, C >::operator= ( const poly_int< N, Ca > & a)
inline

References a, i, N, and POLY_SET_COEFF.

◆ to_constant()

template<unsigned int N, typename C >
C poly_int< N, C >::to_constant ( ) const
inline
Return the value of a polynomial that is already known to be a
compile-time constant.

NOTE: When using this function, please add a comment above the call
explaining why we know the value is constant in that context.   

References gcc_checking_assert.

Referenced by add_cfi_args_size(), add_mask_and_len_args(), build_common_tree_nodes(), build_vector_from_ctor(), carry_backpropagate(), clear_padding_type(), default_class_max_nregs(), default_function_arg_padding(), do_compare_rtx_and_jump(), dwf_cfa_reg(), emit_move_multi_word(), emit_push_insn(), expand_fn_using_insn(), expand_used_vars(), ext_dce_process_sets(), ext_dce_process_uses(), extract_bit_field_1(), extract_integral_bit_field(), get_cfa_from_loc_descr(), pair_fusion::get_viable_bases(), gimple_build_vector(), immune_p(), lto_input_mode_table(), native_decode_rtx(), native_encode_rtx(), native_interpret_vector(), vector_builder< T, Shape, Derived >::new_binary_operation(), vector_builder< T, Shape, Derived >::new_unary_operation(), nunits_for_known_piecewise_op(), predicate_statements(), simd_clone_adjust(), simd_clone_mangle(), simplify_context::simplify_binary_operation_1(), simplify_const_binary_operation(), simplify_immed_subreg(), simplify_subreg_concatn(), simplify_vector_constructor(), store_bit_field_1(), store_constructor(), store_field(), subreg_get_info(), pair_fusion_bb_info::track_access(), pair_fusion_bb_info::track_via_mem_expr(), pair_fusion::try_promote_writeback(), undistribute_bitref_for_vector(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_step(), vect_create_partial_epilog(), vect_do_peeling(), vect_permute_load_chain(), vect_permute_store_chain(), vect_recog_bitfield_ref_pattern(), vect_set_loop_condition_partial_vectors_avx512(), vect_slp_check_for_roots(), vect_transform_slp_perm_load_1(), vectorizable_induction(), vectorizable_load(), vectorizable_slp_permutation_1(), and vectorizable_store().

◆ to_shwi()

template<unsigned int N, typename C >
bool poly_int< N, C >::to_shwi ( poly_int< N, HOST_WIDE_INT > * r) const
inline

◆ to_uhwi()

template<unsigned int N, typename C >
bool poly_int< N, C >::to_uhwi ( poly_int< N, unsigned HOST_WIDE_INT > * r) const
inline
Return true if the coefficients of this generic_wide_int-based
polynomial can be represented as unsigned HOST_WIDE_INTs without
loss of precision.  Store the unsigned HOST_WIDE_INT representation
in *R if so.   

References wi::fits_uhwi_p(), i, N, and r.

Referenced by constant_byte_string(), and pointer_may_wrap_p().

Field Documentation

◆ coeffs


The documentation for this struct was generated from the following file: