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.

From-SVN: r63411
This commit is contained in:
Aldy Hernandez 2003-02-25 17:06:41 +00:00 committed by Aldy Hernandez
parent 7d9f2df263
commit c8e4f0e96e
8 changed files with 80 additions and 43 deletions

View File

@ -1,3 +1,37 @@
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

View File

@ -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;

View File

@ -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 <spe.h> accordingly. */
return t1 == V2SI_type_node || t2 == V2SI_type_node;
}
#include "gt-rs6000.h"

View File

@ -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;

View File

@ -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})

View File

@ -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, \

View File

@ -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

View File

@ -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;
}