diff options
author | pfg <pfg@FreeBSD.org> | 2013-12-05 21:22:51 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-12-05 21:22:51 +0000 |
commit | 267b1cd42f9a0824207447b133ac4792ea6c5c9e (patch) | |
tree | 4da6429b3d6623f5aaa3bd773de3ab87596752dd /contrib/gcc/c-common.c | |
parent | e47dbd1e3fc086df23b88a81477b8e1e61e5961b (diff) | |
download | FreeBSD-src-267b1cd42f9a0824207447b133ac4792ea6c5c9e.zip FreeBSD-src-267b1cd42f9a0824207447b133ac4792ea6c5c9e.tar.gz |
gcc: Add -flax-vector-conversions
Obtained from: gcc 4.3 (rev. 120572, 120688; GPLv2)
Diffstat (limited to 'contrib/gcc/c-common.c')
-rw-r--r-- | contrib/gcc/c-common.c | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/contrib/gcc/c-common.c b/contrib/gcc/c-common.c index fa89614..d358a79 100644 --- a/contrib/gcc/c-common.c +++ b/contrib/gcc/c-common.c @@ -254,6 +254,10 @@ int flag_short_double; int flag_short_wchar; +/* Nonzero means allow implicit conversions between vectors with + differing numbers of subparts and/or differing element types. */ +int flag_lax_vector_conversions; + /* Nonzero means allow Microsoft extensions without warnings or errors. */ int flag_ms_extensions; @@ -1095,18 +1099,45 @@ constant_fits_type_p (tree c, tree type) return !TREE_OVERFLOW (c); } -/* Nonzero if vector types T1 and T2 can be converted to each other - without an explicit cast. */ -int -vector_types_convertible_p (tree t1, tree t2) -{ - return targetm.vector_opaque_p (t1) - || targetm.vector_opaque_p (t2) - || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)) - && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE || - TYPE_PRECISION (t1) == TYPE_PRECISION (t2)) - && INTEGRAL_TYPE_P (TREE_TYPE (t1)) - == INTEGRAL_TYPE_P (TREE_TYPE (t2))); + +/* True if vector types T1 and T2 can be converted to each other + without an explicit cast. If EMIT_LAX_NOTE is true, and T1 and T2 + can only be converted with -flax-vector-conversions yet that is not + in effect, emit a note telling the user about that option if such + a note has not previously been emitted. */ +bool +vector_types_convertible_p (tree t1, tree t2, bool emit_lax_note) +{ + static bool emitted_lax_note = false; + bool convertible_lax; + + if ((targetm.vector_opaque_p (t1) || targetm.vector_opaque_p (t2)) + && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))) + return true; + + convertible_lax = + (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)) + && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE || + TYPE_PRECISION (t1) == TYPE_PRECISION (t2)) + && (INTEGRAL_TYPE_P (TREE_TYPE (t1)) + == INTEGRAL_TYPE_P (TREE_TYPE (t2)))); + + if (!convertible_lax || flag_lax_vector_conversions) + return convertible_lax; + + if (TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2) + && comptypes (TREE_TYPE (t1), TREE_TYPE (t2))) + return true; + + if (emit_lax_note && !emitted_lax_note) + { + emitted_lax_note = true; + inform ("use -flax-vector-conversions to permit " + "conversions between vectors with differing " + "element types or numbers of subparts"); + } + + return false; } /* Convert EXPR to TYPE, warning about conversion problems with constants. |