* 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
+003-02-20 Aldy Hernandez <aldyh@redhat.com>
+
+ * 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 <jh@suse.cz>
* Makefile.in (lcm.o): Add dependency on function.h
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:
}
/* 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
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;
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. */
#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;
\f
/* 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 <spe.h> accordingly. */
- return t1 == V2SI_type_node || t2 == V2SI_type_node;
-}
-
#include "gt-rs6000.h"
#include "diagnostic.h"
#include "toplev.h"
#include "output.h"
+#include "target.h"
\f
/* The lexer. */
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.
/* 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;
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})
#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. */
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, \
/* 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
/* 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;
}