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
 
C 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_INTforce_shwi () const
 
poly_int< N, unsigned HOST_WIDE_INTforce_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, Cfrom (const poly_int< N, Ca > &, unsigned int, signop)
 
template<typename Ca >
static poly_int< N, Cfrom (const poly_int< N, Ca > &, signop)
 

Data Fields

C 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, ggc_alloc(), i, N, and POLY_SET_COEFF.

◆ poly_int() [4/9]

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

◆ poly_int() [5/9]

template<unsigned int N, typename C >
template<typename ... Cs>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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, ggc_alloc(), 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, ggc_alloc(), 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, ggc_alloc(), 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 aff_combination_add_product(), vec_perm_indices::all_in_range_p(), all_positions_needed_p(), ao_ref_alignment(), check_sibcall_argument_overlap(), compute_trims(), dse_step5(), expand_stack_vars(), expand_vector_ubsan_overflow(), extract_bit_field(), fold_const_aggregate_ref_1(), fold_read_from_vector(), fortran_common(), frame_offset_overflow(), fully_constant_vn_reference_p(), gen_int_mode(), get_constraint_for_component_ref(), get_load_store_type(), get_ref_base_and_extent_hwi(), get_stored_val(), immed_wide_int_const(), fixed_size_mode::includes_p(), 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(), vector_builder< T, Shape, Derived >::new_binary_operation(), vector_builder< T, Shape, Derived >::new_unary_operation(), vec_perm_indices::new_vector(), pp_wide_integer(), print_poly_int(), pseudo_reg_slot_compare(), record_store(), scan_stores(), set_usage_bits(), shift_amt_for_vec_perm_mask(), slsr_process_ref(), stack_region_maybe_used_p(), store_bit_field(), store_field(), vect_build_slp_instance(), vect_build_slp_tree_2(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_step(), vect_do_peeling(), vect_gen_vector_loop_niters(), vect_transform_loop(), vect_transform_loops(), vect_transform_slp_perm_load_1(), vectorizable_nonlinear_induction(), 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.   

References ggc_alloc().

◆ 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, ggc_alloc(), 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, ggc_alloc(), 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_vector_from_ctor(), 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(), extract_bit_field_1(), extract_integral_bit_field(), get_cfa_from_loc_descr(), gimple_build_vector(), 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_vector_constructor(), store_bit_field_1(), store_constructor(), store_field(), subreg_get_info(), 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(), 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
Return true if the coefficients of this generic_wide_int-based
polynomial can be represented as signed HOST_WIDE_INTs without loss
of precision.  Store the HOST_WIDE_INT representation in *R if so.   

References poly_int< N, C >::coeffs, wi::fits_shwi_p(), ggc_alloc(), i, N, and r.

Referenced by ao_ref_init_from_vn_reference(), copy_reference_ops_from_ref(), modref_access_node::get_ao_ref(), get_constraint_for_component_ref(), get_inner_reference(), get_ref_base_and_extent(), modref_access_node::update2(), and valueize_refs_1().

◆ 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(), ggc_alloc(), i, N, and r.

Referenced by pointer_may_wrap_p().

Field Documentation

◆ coeffs


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