GCC Middle and Back End API Reference
rtx-vector-builder.h
Go to the documentation of this file.
1/* A class for building vector rtx constants.
2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
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_RTX_VECTOR_BUILDER_H
21#define GCC_RTX_VECTOR_BUILDER_H
22
23#include "vector-builder.h"
24
25/* This class is used to build VECTOR_CSTs from a sequence of elements.
26 See vector_builder for more details. */
27class rtx_vector_builder : public vector_builder<rtx, machine_mode,
28 rtx_vector_builder>
29{
31 friend class vector_builder<rtx, machine_mode, rtx_vector_builder>;
32
33public:
35 rtx_vector_builder (machine_mode, unsigned int, unsigned int);
36 rtx build (rtvec);
37 rtx build ();
38
39 machine_mode mode () const { return m_mode; }
40
41 void new_vector (machine_mode, unsigned int, unsigned int);
42
43private:
44 bool equal_p (rtx, rtx) const;
45 bool allow_steps_p () const;
46 bool integral_p (rtx) const;
47 poly_wide_int step (rtx, rtx) const;
48 rtx apply_step (rtx, unsigned int, const poly_wide_int &) const;
49 bool can_elide_p (rtx) const { return true; }
51
52 static poly_uint64 shape_nelts (machine_mode mode)
53 { return GET_MODE_NUNITS (mode); }
55 { return CONST_VECTOR_NUNITS (x); }
56 static unsigned int npatterns_of (const_rtx x)
57 { return CONST_VECTOR_NPATTERNS (x); }
58 static unsigned int nelts_per_pattern_of (const_rtx x)
59 { return CONST_VECTOR_NELTS_PER_PATTERN (x); }
60
62
63 machine_mode m_mode;
64};
65
66/* Create a new builder for a vector of mode MODE. Initially encode the
67 value as NPATTERNS interleaved patterns with NELTS_PER_PATTERN elements
68 each. */
69
70inline
72 unsigned int npatterns,
73 unsigned int nelts_per_pattern)
74{
76}
77
78/* Start building a new vector of mode MODE. Initially encode the value
79 as NPATTERNS interleaved patterns with NELTS_PER_PATTERN elements each. */
80
81inline void
88
89/* Return true if elements ELT1 and ELT2 are equal. */
90
91inline bool
93{
94 return rtx_equal_p (elt1, elt2);
95}
96
97/* Return true if a stepped representation is OK. We don't allow
98 linear series for anything other than integers, to avoid problems
99 with rounding. */
100
101inline bool
106
107/* Return true if element ELT can be interpreted as an integer. */
108
109inline bool
114
115/* Return the value of element ELT2 minus the value of element ELT1.
116 Both elements are known to be CONST_SCALAR_INT_Ps. */
117
118inline poly_wide_int
120{
121 return (wi::to_poly_wide (elt2, GET_MODE_INNER (m_mode))
123}
124
125#endif
Definition poly-int.h:374
Definition rtx-vector-builder.h:29
void new_vector(machine_mode, unsigned int, unsigned int)
Definition rtx-vector-builder.h:82
bool allow_steps_p() const
Definition rtx-vector-builder.h:102
bool integral_p(rtx) const
Definition rtx-vector-builder.h:110
poly_wide_int step(rtx, rtx) const
Definition rtx-vector-builder.h:119
machine_mode mode() const
Definition rtx-vector-builder.h:39
bool equal_p(rtx, rtx) const
Definition rtx-vector-builder.h:92
machine_mode m_mode
Definition rtx-vector-builder.h:63
rtx apply_step(rtx, unsigned int, const poly_wide_int &) const
Definition rtx-vector-builder.cc:48
rtx_vector_builder()
Definition rtx-vector-builder.h:34
rtx build()
Definition rtx-vector-builder.cc:60
void note_representative(rtx *, rtx)
Definition rtx-vector-builder.h:50
static unsigned int nelts_per_pattern_of(const_rtx x)
Definition rtx-vector-builder.h:58
rtx find_cached_value()
Definition rtx-vector-builder.cc:84
bool can_elide_p(rtx) const
Definition rtx-vector-builder.h:49
static poly_uint64 shape_nelts(machine_mode mode)
Definition rtx-vector-builder.h:52
static poly_uint64 nelts_of(const_rtx x)
Definition rtx-vector-builder.h:54
vector_builder< rtx, machine_mode, rtx_vector_builder > parent
Definition rtx-vector-builder.h:30
static unsigned int npatterns_of(const_rtx x)
Definition rtx-vector-builder.h:56
Definition vector-builder.h:113
void new_vector(poly_uint64, unsigned int, unsigned int)
Definition vector-builder.h:193
unsigned int nelts_per_pattern() const
Definition vector-builder.h:119
unsigned int npatterns() const
Definition vector-builder.h:118
T elt(unsigned int) const
Definition vector-builder.h:229
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
#define GET_MODE_INNER(MODE)
Definition machmode.h:740
ALWAYS_INLINE poly_uint16 GET_MODE_NUNITS(machine_mode mode)
Definition machmode.h:759
rtx_to_poly_wide_ref to_poly_wide(const_rtx, machine_mode)
Definition rtl.h:2377
bool rtx_equal_p(const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
Definition rtl.cc:422
#define CONST_VECTOR_NPATTERNS(RTX)
Definition rtl.h:2023
#define CONST_SCALAR_INT_P(X)
Definition rtl.h:825
#define CONST_VECTOR_NELTS_PER_PATTERN(RTX)
Definition rtl.h:2027
#define CONST_VECTOR_NUNITS(RTX)
Definition rtl.h:2048
Definition rtl.h:735
Definition rtl.h:311