xref: /dflybsd-src/contrib/gcc-8.0/gcc/int-vector-builder.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj /* A class for building vector integer constants.
2*38fd1498Szrj    Copyright (C) 2017-2018 Free Software Foundation, Inc.
3*38fd1498Szrj 
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj 
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj 
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj 
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3.  If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>.  */
19*38fd1498Szrj 
20*38fd1498Szrj #ifndef GCC_INT_VECTOR_BUILDER_H
21*38fd1498Szrj #define GCC_INT_VECTOR_BUILDER_H 1
22*38fd1498Szrj 
23*38fd1498Szrj #include "vector-builder.h"
24*38fd1498Szrj 
25*38fd1498Szrj /* This class is used to build vectors of integer type T using the same
26*38fd1498Szrj    encoding as tree and rtx constants.  See vector_builder for more
27*38fd1498Szrj    details.  */
28*38fd1498Szrj template<typename T>
29*38fd1498Szrj class int_vector_builder : public vector_builder<T, int_vector_builder<T> >
30*38fd1498Szrj {
31*38fd1498Szrj   typedef vector_builder<T, int_vector_builder> parent;
32*38fd1498Szrj   friend class vector_builder<T, int_vector_builder>;
33*38fd1498Szrj 
34*38fd1498Szrj public:
int_vector_builder()35*38fd1498Szrj   int_vector_builder () {}
36*38fd1498Szrj   int_vector_builder (poly_uint64, unsigned int, unsigned int);
37*38fd1498Szrj 
38*38fd1498Szrj   using parent::new_vector;
39*38fd1498Szrj 
40*38fd1498Szrj private:
41*38fd1498Szrj   bool equal_p (T, T) const;
allow_steps_p()42*38fd1498Szrj   bool allow_steps_p () const { return true; }
integral_p(T)43*38fd1498Szrj   bool integral_p (T) const { return true; }
44*38fd1498Szrj   T step (T, T) const;
45*38fd1498Szrj   T apply_step (T, unsigned int, T) const;
can_elide_p(T)46*38fd1498Szrj   bool can_elide_p (T) const { return true; }
note_representative(T *,T)47*38fd1498Szrj   void note_representative (T *, T) {}
48*38fd1498Szrj };
49*38fd1498Szrj 
50*38fd1498Szrj /* Create a new builder for a vector with FULL_NELTS elements.
51*38fd1498Szrj    Initially encode the value as NPATTERNS interleaved patterns with
52*38fd1498Szrj    NELTS_PER_PATTERN elements each.  */
53*38fd1498Szrj 
54*38fd1498Szrj template<typename T>
55*38fd1498Szrj inline
int_vector_builder(poly_uint64 full_nelts,unsigned int npatterns,unsigned int nelts_per_pattern)56*38fd1498Szrj int_vector_builder<T>::int_vector_builder (poly_uint64 full_nelts,
57*38fd1498Szrj 					   unsigned int npatterns,
58*38fd1498Szrj 					   unsigned int nelts_per_pattern)
59*38fd1498Szrj {
60*38fd1498Szrj   new_vector (full_nelts, npatterns, nelts_per_pattern);
61*38fd1498Szrj }
62*38fd1498Szrj 
63*38fd1498Szrj /* Return true if elements ELT1 and ELT2 are equal.  */
64*38fd1498Szrj 
65*38fd1498Szrj template<typename T>
66*38fd1498Szrj inline bool
equal_p(T elt1,T elt2)67*38fd1498Szrj int_vector_builder<T>::equal_p (T elt1, T elt2) const
68*38fd1498Szrj {
69*38fd1498Szrj   return known_eq (elt1, elt2);
70*38fd1498Szrj }
71*38fd1498Szrj 
72*38fd1498Szrj /* Return the value of element ELT2 minus the value of element ELT1.  */
73*38fd1498Szrj 
74*38fd1498Szrj template<typename T>
75*38fd1498Szrj inline T
step(T elt1,T elt2)76*38fd1498Szrj int_vector_builder<T>::step (T elt1, T elt2) const
77*38fd1498Szrj {
78*38fd1498Szrj   return elt2 - elt1;
79*38fd1498Szrj }
80*38fd1498Szrj 
81*38fd1498Szrj /* Return a vector element with the value BASE + FACTOR * STEP.  */
82*38fd1498Szrj 
83*38fd1498Szrj template<typename T>
84*38fd1498Szrj inline T
apply_step(T base,unsigned int factor,T step)85*38fd1498Szrj int_vector_builder<T>::apply_step (T base, unsigned int factor, T step) const
86*38fd1498Szrj {
87*38fd1498Szrj   return base + factor * step;
88*38fd1498Szrj }
89*38fd1498Szrj 
90*38fd1498Szrj #endif
91