GCC Middle and Back End API Reference

#include <vectorbuilder.h>
Public Member Functions  
vector_builder ()  
poly_uint64  full_nelts () const 
unsigned int  npatterns () const 
unsigned int  nelts_per_pattern () const 
unsigned int  encoded_nelts () const 
bool  encoded_full_vector_p () const 
T  elt (unsigned int) const 
unsigned int  count_dups (int, int, int) const 
bool  operator== (const Derived &) const 
bool  operator!= (const Derived &x) const 
bool  new_unary_operation (Shape, T, bool) 
bool  new_binary_operation (Shape, T, T, bool) 
void  finalize () 
vec< T, va_heap >  to_vec_legacy () 
Static Public Member Functions  
static unsigned int  binary_encoded_nelts (T, T) 
Protected Member Functions  
void  new_vector (poly_uint64, unsigned int, unsigned int) 
void  reshape (unsigned int, unsigned int) 
bool  repeating_sequence_p (unsigned int, unsigned int, unsigned int) 
bool  stepped_sequence_p (unsigned int, unsigned int, unsigned int) 
bool  try_npatterns (unsigned int) 
Private Member Functions  
vector_builder (const vector_builder &)  
vector_builder &  operator= (const vector_builder &) 
Derived *  derived () 
const Derived *  derived () const 
Private Attributes  
poly_uint64  m_full_nelts 
unsigned int  m_npatterns 
unsigned int  m_nelts_per_pattern 
vec< T, va_heap, vl_embed >  m_auto 
unsigned char  m_data [sizeof(T) *N] 
A class for building vector constant patterns. Copyright (C) 20172024 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 class is a wrapper around auto_vec<T> for building vectors of T. It aims to encode each vector as npatterns interleaved patterns, where each pattern represents a sequence: { BASE0, BASE1, BASE1 + STEP, BASE1 + STEP*2, BASE1 + STEP*3, ... } The first three elements in each pattern provide enough information to derive the other elements. If all patterns have a STEP of zero, we only need to encode the first two elements in each pattern. If BASE1 is also equal to BASE0 for all patterns, we only need to encode the first element in each pattern. The number of encoded elements per pattern is given by nelts_per_pattern. The class can be used in two ways: 1. It can be used to build a full image of the vector, which is then canonicalized by finalize (). In this case npatterns is initially the number of elements in the vector and nelts_per_pattern is initially 1. 2. It can be used to build a vector that already has a known encoding. This is preferred since it is more efficient and copes with variablelength vectors. finalize () then canonicalizes the encoding to a simpler form if possible. Shape is the type that specifies the number of elements in the vector and (where relevant) the type of each element. The derived class Derived provides the functionality of this class for specific Ts. Derived needs to provide the following interface: bool equal_p (T elt1, T elt2) const; Return true if elements ELT1 and ELT2 are equal. bool allow_steps_p () const; Return true if a stepped representation is OK. We don't allow linear series for anything other than integers, to avoid problems with rounding. bool integral_p (T elt) const; Return true if element ELT can be interpreted as an integer. StepType step (T elt1, T elt2) const; Return the value of element ELT2 minus the value of element ELT1, given integral_p (ELT1) && integral_p (ELT2). There is no fixed choice of StepType. T apply_step (T base, unsigned int factor, StepType step) const; Return a vector element with the value BASE + FACTOR * STEP. bool can_elide_p (T elt) const; Return true if we can drop element ELT, even if the retained elements are different. This is provided for TREE_OVERFLOW handling. void note_representative (T *elt1_ptr, T elt2); Record that ELT2 is being elided, given that ELT1_PTR points to the last encoded element for the containing pattern. This is again provided for TREE_OVERFLOW handling. static poly_uint64 shape_nelts (Shape shape); Return the number of elements in SHAPE. The class provides additional functionality for the case in which T can describe a vector constant as well as an individual element. This functionality requires: static poly_uint64 nelts_of (T x); Return the number of elements in vector constant X. static unsigned int npatterns_of (T x); Return the number of patterns used to encode vector constant X. static unsigned int nelts_per_pattern_of (T x); Return the number of elements used to encode each pattern in vector constant X.

inline 

private 

static 
Return the number of elements that the caller needs to operate on in order to handle a binary operation on vector constants VEC1 and VEC2. This static function is used instead of new_binary_operation if the result of the operation is not a constant vector.
References gcc_assert, poly_int< N, C >::is_constant(), known_eq, least_common_multiple(), MAX, and MIN.
unsigned int vector_builder< T, Shape, Derived >::count_dups  (  int  start, 
int  end,  
int  step ) const 
Return the number of leading duplicate elements in the range [START:END:STEP]. The value is always at least 1.
References end(), gcc_assert, and i.

inlineprivate 

inlineprivate 
T vector_builder< T, Shape, Derived >::elt  (  unsigned int  i  )  const 
Return the value of vector element I, which might or might not be encoded explicitly.
References count, gcc_checking_assert, and i.
Referenced by gimple_build_vector(), vec_perm_indices::new_vector(), vec_perm_indices::operator[](), and vec_perm_indices::series_p().

inline 
Return true if every element of the vector is explicitly encoded.
References known_eq.

inline 
Return the number of elements that are explicitly encoded. The vec starts with these explicitlyencoded elements and may contain additional elided elements.
Referenced by const_binop(), const_unop(), const_vector_from_tree(), const_vector_mask_from_tree(), drop_tree_overflow(), exact_inverse(), expand_vector_divmod(), fold_const_vec_convert(), fold_convert_const(), fold_negate_expr_1(), fold_relational_const(), gimple_build_vector(), make_tree(), native_decode_vector_rtx(), native_interpret_vector_part(), vec_perm_indices::new_expanded_vector(), vec_perm_indices::new_shrunk_vector(), vec_perm_indices::new_vector(), simplify_const_binary_operation(), simplify_const_unary_operation(), vec_perm_indices_to_rtx(), and vec_perm_indices_to_tree().
void vector_builder< T, Shape, Derived >::finalize  (  ) 
Replace the current encoding with the canonical form.
References gcc_assert, i, and pow2p_hwi().
Referenced by vec_perm_indices::new_expanded_vector(), vec_perm_indices::new_shrunk_vector(), and vec_perm_indices::new_vector().

inline 
References vector_builder< T, Shape, Derived >::m_full_nelts.
Referenced by vec_perm_indices::all_in_range_p(), int_vector_builder< T >::int_vector_builder(), vec_perm_indices::length(), vec_perm_indices::new_expanded_vector(), vec_perm_indices::new_shrunk_vector(), vec_perm_indices::new_vector(), and vec_perm_indices::series_p().

inline 
References vector_builder< T, Shape, Derived >::m_nelts_per_pattern.
Referenced by vec_perm_indices::all_in_range_p(), fold_vec_perm_cst(), gimple_build_vector(), int_vector_builder< T >::int_vector_builder(), vec_perm_indices::new_expanded_vector(), vec_perm_indices::new_shrunk_vector(), vec_perm_indices::new_vector(), and valid_mask_for_fold_vec_perm_cst_p().
bool vector_builder< T, Shape, Derived >::new_binary_operation  (  Shape  shape, 
T  vec1,  
T  vec2,  
bool  allow_stepped_p ) 
Try to start building a new vector of shape SHAPE that holds the result of a binary operation on vector constants VEC1 and VEC2. ALLOW_STEPPED_P is true if the operation can handle stepped encodings directly, without having to expand the full sequence. Return true if the operation is possible. Leave the builder unchanged otherwise.
References gcc_assert, poly_int< N, C >::is_constant(), known_eq, least_common_multiple(), MAX, and poly_int< N, C >::to_constant().
Referenced by const_binop(), fold_relational_const(), and simplify_const_binary_operation().
bool vector_builder< T, Shape, Derived >::new_unary_operation  (  Shape  shape, 
T  vec,  
bool  allow_stepped_p ) 
Try to start building a new vector of shape SHAPE that holds the result of a unary operation on vector constant VEC. ALLOW_STEPPED_P is true if the operation can handle stepped encodings directly, without having to expand the full sequence. Return true if the operation is possible, which it always is when ALLOW_STEPPED_P is true. Leave the builder unchanged otherwise.
References gcc_assert, poly_int< N, C >::is_constant(), known_eq, and poly_int< N, C >::to_constant().
Referenced by const_binop(), const_unop(), drop_tree_overflow(), exact_inverse(), expand_vector_divmod(), fold_const_vec_convert(), fold_convert_const(), fold_negate_expr_1(), and simplify_const_unary_operation().

protected 
Start building a vector that has FULL_NELTS elements. Initially encode it using NPATTERNS patterns with NELTS_PER_PATTERN each.
Referenced by int_vector_builder< T >::int_vector_builder().

inline 
References vector_builder< T, Shape, Derived >::m_npatterns.
Referenced by vec_perm_indices::all_in_range_p(), fold_vec_perm_cst(), int_vector_builder< T >::int_vector_builder(), vec_perm_indices::new_expanded_vector(), vec_perm_indices::new_shrunk_vector(), vec_perm_indices::new_vector(), vec_perm_indices::series_p(), and valid_mask_for_fold_vec_perm_cst_p().

inline 

private 
bool vector_builder< T, Shape, Derived >::operator==  (  const Derived &  other  )  const 
Return true if this vector and OTHER have the same elements and are encoded in the same way.
References i.
Referenced by vector_builder< T, Shape, Derived >::operator!=().

protected 

protected 
Change the encoding to NPATTERNS patterns of NELTS_PER_PATTERN each, but without changing the underlying vector.
References gcc_checking_assert, and i.

protected 

protected 
Try to change the number of encoded patterns to NPATTERNS, returning true on success.
References gcc_unreachable.

private 
Referenced by vector_builder< T, Shape, Derived >::full_nelts().

private 
Referenced by vector_builder< T, Shape, Derived >::nelts_per_pattern().

private 
Referenced by vector_builder< T, Shape, Derived >::npatterns().