diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-01-02 18:27:50 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-01-02 18:27:50 +0000 |
commit | 3877c560656f4961cc50952c3bba3c40812c36c3 (patch) | |
tree | 6a597b75586e86b045125cf698b9b23ec15e2d4a /gcc/rtl.h | |
parent | 8eff75e0d2a3495c5bc182324644a080d47205ac (diff) | |
download | gcc-3877c560656f4961cc50952c3bba3c40812c36c3.zip gcc-3877c560656f4961cc50952c3bba3c40812c36c3.tar.gz gcc-3877c560656f4961cc50952c3bba3c40812c36c3.tar.bz2 |
New CONST_VECTOR layout
This patch makes CONST_VECTOR use the same encoding as VECTOR_CST.
One problem that occurs in RTL but not at the tree level is that a fair
amount of code uses XVEC and XVECEXP directly on CONST_VECTORs (which is
valid, just with looser checking). This is complicated by the fact that
vectors are also represented as PARALLELs in some target interfaces,
so using XVECEXP is a good polymorphic way of handling both forms.
Rather than try to untangle all that, the best approach seemed to be to
continue to encode every element in a fixed-length vector. That way only
target-independent and AArch64 code need to be precise about using
CONST_VECTOR_ELT over XVECEXP.
After this change is no longer valid to modify CONST_VECTORs in-place.
This needed some fix-up in the powerpc backends.
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* doc/rtl.texi (const_vector): Describe new encoding scheme.
* Makefile.in (OBJS): Add rtx-vector-builder.o.
* rtx-vector-builder.h: New file.
* rtx-vector-builder.c: Likewise.
* rtl.h (rtx_def::u2): Add a const_vector field.
(CONST_VECTOR_NPATTERNS): New macro.
(CONST_VECTOR_NELTS_PER_PATTERN): Likewise.
(CONST_VECTOR_DUPLICATE_P): Likewise.
(CONST_VECTOR_STEPPED_P): Likewise.
(CONST_VECTOR_ENCODED_ELT): Likewise.
(const_vec_duplicate_p): Check for a duplicated vector encoding.
(unwrap_const_vec_duplicate): Likewise.
(const_vec_series_p): Check for a non-duplicated vector encoding.
Say that the function only returns true for integer vectors.
* emit-rtl.c: Include rtx-vector-builder.h.
(gen_const_vec_duplicate_1): Delete.
(gen_const_vector): Call gen_const_vec_duplicate instead of
gen_const_vec_duplicate_1.
(const_vec_series_p_1): Operate directly on the CONST_VECTOR encoding.
(gen_const_vec_duplicate): Use rtx_vector_builder.
(gen_const_vec_series): Likewise.
(gen_rtx_CONST_VECTOR): Likewise.
* config/powerpcspe/powerpcspe.c: Include rtx-vector-builder.h.
(swap_const_vector_halves): Take an rtx pointer rather than rtx.
Build a new vector rather than modifying a CONST_VECTOR in-place.
(handle_special_swappables): Update call accordingly.
* config/rs6000/rs6000-p8swap.c: Include rtx-vector-builder.h.
(swap_const_vector_halves): Take an rtx pointer rather than rtx.
Build a new vector rather than modifying a CONST_VECTOR in-place.
(handle_special_swappables): Update call accordingly.
From-SVN: r256102
Diffstat (limited to 'gcc/rtl.h')
-rw-r--r-- | gcc/rtl.h | 53 |
1 files changed, 45 insertions, 8 deletions
@@ -418,6 +418,19 @@ struct GTY((desc("0"), tag("0"), /* In a CONST_WIDE_INT (aka hwivec_def), this is the number of HOST_WIDE_INTs in the hwivec_def. */ unsigned int num_elem; + + /* Information about a CONST_VECTOR. */ + struct + { + /* The value of CONST_VECTOR_NPATTERNS. */ + unsigned int npatterns : 16; + + /* The value of CONST_VECTOR_NELTS_PER_PATTERN. */ + unsigned int nelts_per_pattern : 8; + + /* For future expansion. */ + unsigned int unused : 8; + } const_vector; } GTY ((skip)) u2; /* The first element of the operands of this rtx. @@ -1958,6 +1971,23 @@ set_regno_raw (rtx x, unsigned int regno, unsigned int nregs) /* For a CONST_VECTOR, return element #n. */ #define CONST_VECTOR_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR) +/* See rtl.texi for a description of these macros. */ +#define CONST_VECTOR_NPATTERNS(RTX) \ + (RTL_FLAG_CHECK1 ("CONST_VECTOR_NPATTERNS", (RTX), CONST_VECTOR) \ + ->u2.const_vector.npatterns) + +#define CONST_VECTOR_NELTS_PER_PATTERN(RTX) \ + (RTL_FLAG_CHECK1 ("CONST_VECTOR_NELTS_PER_PATTERN", (RTX), CONST_VECTOR) \ + ->u2.const_vector.nelts_per_pattern) + +#define CONST_VECTOR_DUPLICATE_P(RTX) \ + (CONST_VECTOR_NELTS_PER_PATTERN (RTX) == 1) + +#define CONST_VECTOR_STEPPED_P(RTX) \ + (CONST_VECTOR_NELTS_PER_PATTERN (RTX) == 3) + +#define CONST_VECTOR_ENCODED_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR) + /* For a CONST_VECTOR, return the number of elements in a vector. */ #define CONST_VECTOR_NUNITS(RTX) XCVECLEN (RTX, 0, CONST_VECTOR) @@ -2910,7 +2940,9 @@ const_vec_p (const_rtx x) inline bool const_vec_duplicate_p (const_rtx x) { - return ((GET_CODE (x) == CONST_VECTOR && rtvec_all_equal_p (XVEC (x, 0))) + return ((GET_CODE (x) == CONST_VECTOR + && CONST_VECTOR_NPATTERNS (x) == 1 + && CONST_VECTOR_DUPLICATE_P (x)) || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE)); } @@ -2922,9 +2954,11 @@ template <typename T> inline bool const_vec_duplicate_p (T x, T *elt) { - if (GET_CODE (x) == CONST_VECTOR && rtvec_all_equal_p (XVEC (x, 0))) + if (GET_CODE (x) == CONST_VECTOR + && CONST_VECTOR_NPATTERNS (x) == 1 + && CONST_VECTOR_DUPLICATE_P (x)) { - *elt = CONST_VECTOR_ELT (x, 0); + *elt = CONST_VECTOR_ENCODED_ELT (x, 0); return true; } if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE) @@ -2957,8 +2991,10 @@ template <typename T> inline T unwrap_const_vec_duplicate (T x) { - if (GET_CODE (x) == CONST_VECTOR && rtvec_all_equal_p (XVEC (x, 0))) - return CONST_VECTOR_ELT (x, 0); + if (GET_CODE (x) == CONST_VECTOR + && CONST_VECTOR_NPATTERNS (x) == 1 + && CONST_VECTOR_DUPLICATE_P (x)) + return CONST_VECTOR_ENCODED_ELT (x, 0); if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE) return XEXP (XEXP (x, 0), 0); return x; @@ -2967,8 +3003,8 @@ unwrap_const_vec_duplicate (T x) /* In emit-rtl.c. */ extern bool const_vec_series_p_1 (const_rtx, rtx *, rtx *); -/* Return true if X is a constant vector that contains a linear series - of the form: +/* Return true if X is an integer constant vector that contains a linear + series of the form: { B, B + S, B + 2 * S, B + 3 * S, ... } @@ -2978,7 +3014,8 @@ inline bool const_vec_series_p (const_rtx x, rtx *base_out, rtx *step_out) { if (GET_CODE (x) == CONST_VECTOR - && GET_MODE_CLASS (GET_MODE (x)) == MODE_VECTOR_INT) + && CONST_VECTOR_NPATTERNS (x) == 1 + && !CONST_VECTOR_DUPLICATE_P (x)) return const_vec_series_p_1 (x, base_out, step_out); if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_SERIES) { |