aboutsummaryrefslogtreecommitdiff
path: root/gcc/genmodes.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-03 21:43:02 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-03 21:43:02 +0000
commit5c0caeb37ff72cfd9153e164e9fd9eec7d56e969 (patch)
tree99f960801c55a722346016899054db7e08ba7b13 /gcc/genmodes.c
parentcf098191e47535b89373dccb9a2d3cc4a4ebaef7 (diff)
downloadgcc-5c0caeb37ff72cfd9153e164e9fd9eec7d56e969.zip
gcc-5c0caeb37ff72cfd9153e164e9fd9eec7d56e969.tar.gz
gcc-5c0caeb37ff72cfd9153e164e9fd9eec7d56e969.tar.bz2
Add support for MODE_VECTOR_BOOL
This patch adds a new mode class to represent vectors of booleans. GET_MODE_BITSIZE (m) / GET_MODE_NUNITS (m) determines the number of bits that are used to represent each boolean; this can be 1 for a fully-packed representation or greater than 1 for an unpacked representation. In the latter case, the value of bits other than the lowest is not significant. These are used by the SVE port to represent predicates. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * mode-classes.def (MODE_VECTOR_BOOL): New mode class. * machmode.h (INTEGRAL_MODE_P, VECTOR_MODE_P): Return true for MODE_VECTOR_BOOL. * machmode.def (VECTOR_BOOL_MODE): Document. * genmodes.c (VECTOR_BOOL_MODE): New macro. (make_vector_bool_mode): New function. (complete_mode, emit_mode_wider, emit_mode_adjustments): Handle MODE_VECTOR_BOOL. * lto-streamer-in.c (lto_input_mode_table): Likewise. * rtx-vector-builder.c (rtx_vector_builder::find_cached_value): Likewise. * stor-layout.c (int_mode_for_mode): Likewise. * tree.c (build_vector_type_for_mode): Likewise. * varasm.c (output_constant_pool_2): Likewise. * emit-rtl.c (init_emit_once): Make sure that CONST1_RTX (BImode) and CONSTM1_RTX (BImode) are the same thing. Initialize const_tiny_rtx for MODE_VECTOR_BOOL. * expr.c (expand_expr_real_1): Use VECTOR_MODE_P instead of a list of mode class checks. * tree-vect-generic.c (expand_vector_operation): Use VECTOR_MODE_P instead of a list of mode class checks. (expand_vector_scalar_condition): Likewise. (type_for_widest_vector_mode): Handle BImode as an inner mode. gcc/c-family/ * c-common.c (c_common_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/fortran/ * trans-types.c (gfc_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/lto/ * lto-lang.c (lto_type_for_mode): Handle MODE_VECTOR_BOOL. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256202
Diffstat (limited to 'gcc/genmodes.c')
-rw-r--r--gcc/genmodes.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index b134c1b..9e37d65 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -375,6 +375,10 @@ complete_mode (struct mode_data *m)
m->bytesize = 2 * m->component->bytesize;
break;
+ case MODE_VECTOR_BOOL:
+ validate_mode (m, UNSET, SET, SET, SET, UNSET);
+ break;
+
case MODE_VECTOR_INT:
case MODE_VECTOR_FLOAT:
case MODE_VECTOR_FRACT:
@@ -526,6 +530,28 @@ make_vector_modes (enum mode_class cl, unsigned int width,
}
}
+/* Create a vector of booleans called NAME with COUNT elements and
+ BYTESIZE bytes in total. */
+#define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \
+ make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__)
+static void ATTRIBUTE_UNUSED
+make_vector_bool_mode (const char *name, unsigned int count,
+ unsigned int bytesize, const char *file,
+ unsigned int line)
+{
+ struct mode_data *m = find_mode ("BI");
+ if (!m)
+ {
+ error ("%s:%d: no mode \"BI\"", file, line);
+ return;
+ }
+
+ struct mode_data *v = new_mode (MODE_VECTOR_BOOL, name, file, line);
+ v->component = m;
+ v->ncomponents = count;
+ v->bytesize = bytesize;
+}
+
/* Input. */
#define _SPECIAL_MODE(C, N) \
@@ -1438,7 +1464,8 @@ emit_mode_wider (void)
/* For vectors we want twice the number of components,
with the same element type. */
- if (m->cl == MODE_VECTOR_INT
+ if (m->cl == MODE_VECTOR_BOOL
+ || m->cl == MODE_VECTOR_INT
|| m->cl == MODE_VECTOR_FLOAT
|| m->cl == MODE_VECTOR_FRACT
|| m->cl == MODE_VECTOR_UFRACT
@@ -1657,6 +1684,7 @@ emit_mode_adjustments (void)
printf ("\n /* %s:%d */\n", a->file, a->line);
switch (a->mode->cl)
{
+ case MODE_VECTOR_BOOL:
case MODE_VECTOR_INT:
case MODE_VECTOR_FLOAT:
case MODE_VECTOR_FRACT:
@@ -1688,6 +1716,10 @@ emit_mode_adjustments (void)
m->name);
break;
+ case MODE_VECTOR_BOOL:
+ /* Changes to BImode should not affect vector booleans. */
+ break;
+
case MODE_VECTOR_INT:
case MODE_VECTOR_FLOAT:
case MODE_VECTOR_FRACT:
@@ -1728,6 +1760,10 @@ emit_mode_adjustments (void)
printf (" mode_base_align[E_%smode] = s;\n", m->name);
break;
+ case MODE_VECTOR_BOOL:
+ /* Changes to BImode should not affect vector booleans. */
+ break;
+
case MODE_VECTOR_INT:
case MODE_VECTOR_FLOAT:
case MODE_VECTOR_FRACT: