From ad92037a0defae40f46ee012e85e7caa00adc7e7 Mon Sep 17 00:00:00 2001 From: aldyh Date: Tue, 25 Feb 2003 17:06:41 +0000 Subject: [PATCH] 003-02-20 Aldy Hernandez * doc/tm.texi: Document Rename TARGET_VECTOR_TYPES_COMPATIBLE to TARGET_VECTOR_OPAQUE_P. Document accordingly. * testsuite/gcc.dg/20030218-1.c: Check that initialization of opaque types fail. * c-typeck.c (comptypes): Change call to vector_types_compatible to vector_opaque_p. (convert_for_assignment): Call vector_opaque_p instead of vector_types_compatible. (really_start_incremental_init): Disallow initialization of opaque types. * target-def.h: Remove TARGET_VECTOR_TYPES_COMPATIBLE. Define TARGET_VECTOR_OPAQUE_P. (TARGET_INITIALIZER): Same. * target.h (struct gcc_target): Remove vector_types_compatible. Add vector_opaque_p. * config/rs6000/rs6000.c (rs6000_spe_vector_types_compatible): Remove. (is_ev64_opaque_type): Check for TARGET_SPE and make sure type is a vector type. Change return type to bool. (TARGET_VECTOR_TYPES_COMPATIBLE): Remove. (TARGET_VECTOR_OPAQUE_P): Define. * cp/parser.c (cp_parser_init_declarator): Call vector_opaque_p target hook. Include target.h. (cp_parser_init_declarator): Fix typo in function comments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63411 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 34 ++++++++++++++++++++++++++++++++++ gcc/c-typeck.c | 9 +++++++-- gcc/config/rs6000/rs6000.c | 33 +++++++-------------------------- gcc/cp/parser.c | 12 +++++++++--- gcc/doc/tm.texi | 10 ++++++---- gcc/target-def.h | 6 +++--- gcc/target.h | 4 ++-- gcc/testsuite/gcc.dg/20030218-1.c | 15 ++++++++++++--- 8 files changed, 80 insertions(+), 43 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 66e788246e3..ceca00fa137 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,37 @@ +003-02-20 Aldy Hernandez + + * doc/tm.texi: Document Rename TARGET_VECTOR_TYPES_COMPATIBLE to + TARGET_VECTOR_OPAQUE_P. Document accordingly. + + * testsuite/gcc.dg/20030218-1.c: Check that initialization of + opaque types fail. + + * c-typeck.c (comptypes): Change call to vector_types_compatible + to vector_opaque_p. + (convert_for_assignment): Call vector_opaque_p instead of + vector_types_compatible. + (really_start_incremental_init): Disallow initialization of opaque + types. + + * target-def.h: Remove TARGET_VECTOR_TYPES_COMPATIBLE. + Define TARGET_VECTOR_OPAQUE_P. + (TARGET_INITIALIZER): Same. + + * target.h (struct gcc_target): Remove vector_types_compatible. + Add vector_opaque_p. + + * config/rs6000/rs6000.c (rs6000_spe_vector_types_compatible): + Remove. + (is_ev64_opaque_type): Check for TARGET_SPE and make sure type is + a vector type. Change return type to bool. + (TARGET_VECTOR_TYPES_COMPATIBLE): Remove. + (TARGET_VECTOR_OPAQUE_P): Define. + + * cp/parser.c (cp_parser_init_declarator): Call vector_opaque_p + target hook. + Include target.h. + (cp_parser_init_declarator): Fix typo in function comments. + Tue Feb 25 12:35:34 CET 2003 Jan Hubicka * Makefile.in (lcm.o): Add dependency on function.h diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index d784d3e11a3..01a7c92a665 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -576,7 +576,8 @@ comptypes (type1, type2) case VECTOR_TYPE: /* The target might allow certain vector types to be compatible. */ - val = (*targetm.vector_types_compatible) (t1, t2); + val = (*targetm.vector_opaque_p) (t1) + || (*targetm.vector_opaque_p) (t2); break; default: @@ -4071,7 +4072,8 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) } /* Some types can interconvert without explicit casts. */ else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE - && (*targetm.vector_types_compatible) (type, rhstype)) + && ((*targetm.vector_opaque_p) (type) + || (*targetm.vector_opaque_p) (rhstype))) return convert (type, rhs); /* Arithmetic types all interconvert, and enum is treated like int. */ else if ((codel == INTEGER_TYPE || codel == REAL_TYPE @@ -5158,6 +5160,9 @@ really_start_incremental_init (type) if (type == 0) type = TREE_TYPE (constructor_decl); + if ((*targetm.vector_opaque_p) (type)) + error ("opaque vector types cannot be initialized"); + p->type = constructor_type; p->fields = constructor_fields; p->index = constructor_index; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 500af598e99..c26c4463b34 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -268,8 +268,7 @@ static void is_altivec_return_reg PARAMS ((rtx, void *)); static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int)); static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT)); static int easy_vector_constant PARAMS ((rtx)); -static int is_ev64_opaque_type PARAMS ((tree)); -static bool rs6000_spe_vector_types_compatible PARAMS ((tree, tree)); +static bool is_ev64_opaque_type PARAMS ((tree)); /* Hash table stuff for keeping track of TOC entries. */ @@ -422,8 +421,8 @@ static const char alt_reg_names[][8] = #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST hook_int_rtx_0 -#undef TARGET_VECTOR_TYPES_COMPATIBLE -#define TARGET_VECTOR_TYPES_COMPATIBLE rs6000_spe_vector_types_compatible +#undef TARGET_VECTOR_OPAQUE_P +#define TARGET_VECTOR_OPAQUE_P is_ev64_opaque_type struct gcc_target targetm = TARGET_INITIALIZER; @@ -13599,35 +13598,17 @@ rs6000_memory_move_cost (mode, class, in) /* Return true if TYPE is of type __ev64_opaque__. */ -static int +static bool is_ev64_opaque_type (type) tree type; { - return (TYPE_NAME (type) + return (TARGET_SPE + && TREE_CODE (type) == VECTOR_TYPE + && TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && DECL_NAME (TYPE_NAME (type)) && strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))), "__ev64_opaque__") == 0); } -/* Return true if vector type1 can be converted into vector type2. */ - -static bool -rs6000_spe_vector_types_compatible (t1, t2) - tree t1; - tree t2; -{ - if (!TARGET_SPE - || TREE_CODE (t1) != VECTOR_TYPE || TREE_CODE (t2) != VECTOR_TYPE) - return 0; - - if (TYPE_NAME (t1) || TYPE_NAME (t2)) - return is_ev64_opaque_type (t1) || is_ev64_opaque_type (t2); - - /* FIXME: We assume V2SI is the opaque type, so we accidentally - allow inter conversion to and from V2SI modes. We could use - V1D1, and rewrite accordingly. */ - return t1 == V2SI_type_node || t2 == V2SI_type_node; -} - #include "gt-rs6000.h" diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 17b7224cb6e..9ff6ab52bac 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -34,6 +34,7 @@ #include "diagnostic.h" #include "toplev.h" #include "output.h" +#include "target.h" /* The lexer. */ @@ -9503,7 +9504,7 @@ cp_parser_asm_definition (cp_parser* parser) declarator asm-specification [opt] attributes [opt] initializer [opt] The DECL_SPECIFIERS and PREFIX_ATTRIBUTES apply to this declarator. - Returns a reprsentation of the entity declared. If MEMBER_P is TRUE, + Returns a representation of the entity declared. If MEMBER_P is TRUE, then this declarator appears in a class scope. The new DECL created by this declarator is returned. @@ -9702,8 +9703,13 @@ cp_parser_init_declarator (cp_parser* parser, /* Parse the initializer. */ if (is_initialized) - initializer = cp_parser_initializer (parser, - &is_parenthesized_init); + { + if ((*targetm.vector_opaque_p) (TREE_TYPE (decl))) + cp_parser_error (parser, "opaque vector types cannot be initialized"); + + initializer = cp_parser_initializer (parser, + &is_parenthesized_init); + } else { initializer = NULL_TREE; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 4fd314bce6d..a3c68a2923a 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -1452,10 +1452,12 @@ floating-point arithmetic. The default definition of this macro returns false for all sizes. @end table -@deftypefn {Target Hook} bool TARGET_VECTOR_TYPES_COMPATIBLE (tree @var{type1}, tree @var{type2}) -This target hook should return @code{true} if no cast is needed when -copying a vector value of type @var{type1} into a vector lvalue of -type @var{type2}. The default is that there are no such types. +@deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type}) +This target hook should return @code{true} a vector is opaque. That +is, if no cast is needed when copying a vector value of type +@var{type} into another vector lvalue of the same size. Vector opaque +types cannot be initialized. The default is that there are no such +types. @end deftypefn @deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type}) diff --git a/gcc/target-def.h b/gcc/target-def.h index 57d6e98e80a..a7f84c165eb 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -256,8 +256,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_VALID_POINTER_MODE default_valid_pointer_mode #endif -#ifndef TARGET_VECTOR_TYPES_COMPATIBLE -#define TARGET_VECTOR_TYPES_COMPATIBLE hook_bool_tree_tree_false +#ifndef TARGET_VECTOR_OPAQUE_P +#define TARGET_VECTOR_OPAQUE_P hook_bool_tree_false #endif /* In hook.c. */ @@ -307,7 +307,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_ENCODE_SECTION_INFO, \ TARGET_STRIP_NAME_ENCODING, \ TARGET_VALID_POINTER_MODE, \ - TARGET_VECTOR_TYPES_COMPATIBLE, \ + TARGET_VECTOR_OPAQUE_P, \ TARGET_RTX_COSTS, \ TARGET_ADDRESS_COST, \ TARGET_HAVE_NAMED_SECTIONS, \ diff --git a/gcc/target.h b/gcc/target.h index 90660d97672..95c97b4e224 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -320,8 +320,8 @@ struct gcc_target /* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */ bool (* valid_pointer_mode) PARAMS ((enum machine_mode mode)); - /* True if two vector types can be copied without an explicit cast. */ - bool (* vector_types_compatible) PARAMS ((tree, tree)); + /* True if a vector is opaque. */ + bool (* vector_opaque_p) PARAMS ((tree)); /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be diff --git a/gcc/testsuite/gcc.dg/20030218-1.c b/gcc/testsuite/gcc.dg/20030218-1.c index 665b6abe47e..e41152c21c1 100644 --- a/gcc/testsuite/gcc.dg/20030218-1.c +++ b/gcc/testsuite/gcc.dg/20030218-1.c @@ -3,15 +3,24 @@ /* Test vectors that can interconvert without a cast. */ -int vint __attribute__((mode(V2SI))); +typedef int __attribute__((mode(V2SI))) __ev64_opaque__; + +__ev64_opaque__ opp; +int vint __attribute__((mode(V2SI))); int vshort __attribute__((mode(V4HI))); int vfloat __attribute__((mode(V2SF))); int main (void) { - vint = vfloat; - vshort = vint; + __ev64_opaque__ george = { 1, 2 }; /* { dg-error "opaque vector types cannot be initialized" } */ + + opp = vfloat; + vshort = opp; vfloat = vshort; /* { dg-error "incompatible types in assignment" } */ + + /* Just because this is a V2SI, it doesn't make it an opaque. */ + vint = vshort; /* { dg-error "incompatible types in assignment" } */ + return 0; } -- 2.11.4.GIT