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