diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2006-10-13 15:59:03 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2006-10-13 15:59:03 +0000 |
commit | ca58211b7de19f4fc94944836891f6e275e74412 (patch) | |
tree | e0e884867515d0a183ff624faa1b1cb6826bbf92 | |
parent | e1bb14caf9a04993d5158e9bdcee8524ea6f32db (diff) | |
download | gcc-ca58211b7de19f4fc94944836891f6e275e74412.zip gcc-ca58211b7de19f4fc94944836891f6e275e74412.tar.gz gcc-ca58211b7de19f4fc94944836891f6e275e74412.tar.bz2 |
../svn-commit.tmp
From-SVN: r117696
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/simd-5.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/simd-6.c | 7 | ||||
-rw-r--r-- | gcc/tree.c | 49 |
6 files changed, 66 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4185745..d62801b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2006-10-13 Paolo Bonzini <bonzini@gnu.org> + + PR c/29092 + + * c-typeck.c (digest_init): Always allow initializing vectors + that have static storage duration with compound literals. + * tree.c (build_type_attribute_qual_variant): New, based on + build_type_attribute_variant. + (build_type_attribute_variant): Rewrite using the former. + (make_vector_type): Use build_type_attribute_qual_variant to build + type variants. Use type_hash_canon on the others. + 2006-10-13 Daniel Berlin <dberlin@dberlin.org> Ramana Radhakrishnan <ramana.radhakrishnan@celunite.com> diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 89bfed1..2534c25 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4719,12 +4719,14 @@ digest_init (tree type, tree init, bool strict_string, int require_constant) conversion. */ inside_init = convert (type, inside_init); - if (require_constant && !flag_isoc99 + if (require_constant + && (code == VECTOR_TYPE || !flag_isoc99) && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR) { /* As an extension, allow initializing objects with static storage duration with compound literals (which are then treated just as - the brace enclosed list they contain). */ + the brace enclosed list they contain). Also allow this for + vectors, as we can only assign them with compound literals. */ tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init); inside_init = DECL_INITIAL (decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe584c2..bd4013b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-10-13 Paolo Bonzini <bonzini@gnu.org> + + * gcc.dg/simd-5.c, gcc.dg/simd-6: New testcases. + 2006-10-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/29373 diff --git a/gcc/testsuite/gcc.dg/simd-5.c b/gcc/testsuite/gcc.dg/simd-5.c new file mode 100644 index 0000000..31a13d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/simd-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu89" } */ + +/* Ensure that we don't need a typedef to initialize a vector type. */ +#define vector __attribute__ ((vector_size (8))) +vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */ +vector char y = (vector short) {1,2,3,4}; /* { dg-error "initializer" } */ diff --git a/gcc/testsuite/gcc.dg/simd-6.c b/gcc/testsuite/gcc.dg/simd-6.c new file mode 100644 index 0000000..b1d244a --- /dev/null +++ b/gcc/testsuite/gcc.dg/simd-6.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99" } */ + +/* Ensure that we don't need a typedef to initialize a vector type. */ +#define vector __attribute__ ((vector_size (8))) +vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */ +vector char y = (vector short) {1,2,3,4}; /* { dg-error "initializer" } */ @@ -165,7 +165,6 @@ static int int_cst_hash_eq (const void *, const void *); static void print_type_hash_statistics (void); static void print_debug_expr_statistics (void); static void print_value_expr_statistics (void); -static tree make_vector_type (tree, int, enum machine_mode); static int type_hash_marked_p (const void *); static unsigned int type_hash_list (tree, hashval_t); static unsigned int attribute_hash_list (tree, hashval_t); @@ -3356,12 +3355,12 @@ iterative_hash_host_wide_int (HOST_WIDE_INT val, hashval_t val2) } /* Return a type like TTYPE except that its TYPE_ATTRIBUTE - is ATTRIBUTE. + is ATTRIBUTE and its qualifiers are QUALS. Record such modified types already made so we don't make duplicates. */ -tree -build_type_attribute_variant (tree ttype, tree attribute) +static tree +build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) { if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute)) { @@ -3412,13 +3411,25 @@ build_type_attribute_variant (tree ttype, tree attribute) } ntype = type_hash_canon (hashcode, ntype); - ttype = build_qualified_type (ntype, TYPE_QUALS (ttype)); + ttype = build_qualified_type (ntype, quals); } return ttype; } +/* Return a type like TTYPE except that its TYPE_ATTRIBUTE + is ATTRIBUTE. + + Record such modified types already made so we don't make duplicates. */ + +tree +build_type_attribute_variant (tree ttype, tree attribute) +{ + return build_type_attribute_qual_variant (ttype, attribute, + TYPE_QUALS (ttype)); +} + /* Return nonzero if IDENT is a valid name for attribute ATTR, or zero if not. @@ -6384,8 +6395,18 @@ omp_clause_operand_check_failed (int idx, tree t, const char *file, static tree make_vector_type (tree innertype, int nunits, enum machine_mode mode) { - tree t = make_node (VECTOR_TYPE); + tree t; + hashval_t hashcode = 0; + + /* Build a main variant, based on the main variant of the inner type, then + use it to build the variant we return. */ + if (TYPE_ATTRIBUTES (innertype) || TYPE_QUALS (innertype)) + return build_type_attribute_qual_variant ( + make_vector_type (TYPE_MAIN_VARIANT (innertype), nunits, mode), + TYPE_ATTRIBUTES (innertype), + TYPE_QUALS (innertype)); + t = make_node (VECTOR_TYPE); TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype); SET_TYPE_VECTOR_SUBPARTS (t, nunits); TYPE_MODE (t) = mode; @@ -6410,17 +6431,10 @@ make_vector_type (tree innertype, int nunits, enum machine_mode mode) TYPE_UID (rt) = TYPE_UID (t); } - /* Build our main variant, based on the main variant of the inner type. */ - if (TYPE_MAIN_VARIANT (innertype) != innertype) - { - tree innertype_main_variant = TYPE_MAIN_VARIANT (innertype); - unsigned int hash = TYPE_HASH (innertype_main_variant); - TYPE_MAIN_VARIANT (t) - = type_hash_canon (hash, make_vector_type (innertype_main_variant, - nunits, mode)); - } - - return t; + hashcode = iterative_hash_host_wide_int (VECTOR_TYPE, hashcode); + hashcode = iterative_hash_host_wide_int (mode, hashcode); + hashcode = iterative_hash_object (TYPE_HASH (innertype), hashcode); + return type_hash_canon (hashcode, t); } static tree @@ -6883,6 +6897,7 @@ build_vector_type (tree innertype, int nunits) return make_vector_type (innertype, nunits, VOIDmode); } + /* Build RESX_EXPR with given REGION_NUMBER. */ tree build_resx (int region_number) |