diff --git a/gcc/common.opt b/gcc/common.opt index 6e369e551020c67e33929bcafcc36c9031883900..a4358b5ea50d8b54cedc048fdac8283f56ed2c6d 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -266,7 +266,13 @@ Common Separate ; ; 1: The version of the ABI first used in G++ 3.2. ; -; 2: The version of the ABI first used in G++ 3.4. +; 2: The version of the ABI first used in G++ 3.4 (and current default). +; +; 3: The version of the ABI that fixes the missing underscore +; in template non-type arguments of pointer type. +; +; 4: The version of the ABI that introduces unambiguous mangling of +; vector types. ; ; Additional positive integers will be assigned as new versions of ; the ABI become the default version of the ABI. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b122aecbe54ad35d54ad12a420cda2f2630c12b3..c3b1bdc2a6073ca244e90fc394e2b07d80a159d9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-03 Jason Merrill <jason@redhat.com> + + PR c++/12909 + * mangle.c (write_type) [VECTOR_TYPE]: Change mangling with + -fabi-version=4. + 2010-02-02 Jason Merrill <jason@redhat.com> PR c++/41090 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c14f5b7d844e66764e76585a95b5216f08574ee8..37293f1b4db26254b6773b8a07ac9e53522f2360 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1850,7 +1850,16 @@ write_type (tree type) break; case VECTOR_TYPE: - write_string ("U8__vector"); + if (abi_version_at_least (4)) + { + write_string ("Dv"); + /* Non-constant vector size would be encoded with + _ expression, but we don't support that yet. */ + write_unsigned_number (TYPE_VECTOR_SUBPARTS (type)); + write_char ('_'); + } + else + write_string ("U8__vector"); write_type (TREE_TYPE (type)); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2244bb8d007361a4aa933e87bcc8da870f19f7a1..0c849b9298e954df7651a05cddf587512fed5835 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-02-03 Jason Merrill <jason@redhat.com> + PR c++/12909 + * g++.dg/abi/mangle36.C: New. + PR c++/35652 * g++.dg/warn/string1.C: New. diff --git a/gcc/testsuite/g++.dg/abi/mangle36.C b/gcc/testsuite/g++.dg/abi/mangle36.C new file mode 100644 index 0000000000000000000000000000000000000000..aaace6570a2510090c32a7ec6c60b3e39c3816de --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle36.C @@ -0,0 +1,9 @@ +// PR c++/41959 +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-mavx -fabi-version=4" } +// { dg-final { scan-assembler "_Z1fDv4_f" } } +// { dg-final { scan-assembler "_Z1fDv8_f" } } + +#include <x86intrin.h> +void f(__m128) { } +void f(__m256) { } diff --git a/include/demangle.h b/include/demangle.h index 2ab27602be15d26fbce3659888b517a9d75622c1..8ad073de53205f760efcd8b79da7229d5ed6f3a6 100644 --- a/include/demangle.h +++ b/include/demangle.h @@ -326,6 +326,9 @@ enum demangle_component_type DEMANGLE_COMPONENT_PTRMEM_TYPE, /* A fixed-point type. */ DEMANGLE_COMPONENT_FIXED_TYPE, + /* A vector type. The left subtree is the number of elements, + the right subtree is the element type. */ + DEMANGLE_COMPONENT_VECTOR_TYPE, /* An argument list. The left subtree is the current argument, and the right subtree is either NULL or another ARGLIST node. */ DEMANGLE_COMPONENT_ARGLIST, @@ -378,6 +381,8 @@ enum demangle_component_type DEMANGLE_COMPONENT_COMPOUND_NAME, /* A name formed by a single character. */ DEMANGLE_COMPONENT_CHARACTER, + /* A number. */ + DEMANGLE_COMPONENT_NUMBER, /* A decltype type. */ DEMANGLE_COMPONENT_DECLTYPE, /* Global constructors keyed to name. */ diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index fcbef269c8777426a8de1fe94b98b20ca5e21dd4..d4a43ec33e8f41aef739a26ff0d3c973c117ec45 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2010-02-03 Jason Merrill <jason@redhat.com> + + PR c++/12909 + * cp-demangle.c (d_number_component, d_vector_type): New. + (cplus_demangle_type, d_print_comp, d_print_mod): Handle vectors. + 2010-01-25 Ian Lance Taylor <iant@google.com> * cp-demangle.c (cplus_demangle_type): Check for invalid type diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 2f4d0cc9a30ff253d1c4a21f3c02cdc214bec11b..75706b3bd2a4c444aa7e3baeb680415619044d26 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -389,6 +389,8 @@ d_class_enum_type (struct d_info *); static struct demangle_component *d_array_type (struct d_info *); +static struct demangle_component *d_vector_type (struct d_info *); + static struct demangle_component * d_pointer_to_member_type (struct d_info *); @@ -796,6 +798,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL_NEG: case DEMANGLE_COMPONENT_COMPOUND_NAME: + case DEMANGLE_COMPONENT_VECTOR_TYPE: if (left == NULL || right == NULL) return NULL; break; @@ -1442,6 +1445,20 @@ d_number (struct d_info *di) } } +/* Like d_number, but returns a demangle_component. */ + +static struct demangle_component * +d_number_component (struct d_info *di) +{ + struct demangle_component *ret = d_make_empty (di); + if (ret) + { + ret->type = DEMANGLE_COMPONENT_NUMBER; + ret->u.s_number.number = d_number (di); + } + return ret; +} + /* identifier ::= <(unqualified source code identifier)> */ static struct demangle_component * @@ -2200,6 +2217,10 @@ cplus_demangle_type (struct d_info *di) ret->u.s_fixed.sat = (peek == 's'); break; + case 'v': + ret = d_vector_type (di); + break; + default: return NULL; } @@ -2418,6 +2439,34 @@ d_array_type (struct d_info *di) cplus_demangle_type (di)); } +/* <vector-type> ::= Dv <number> _ <type> + ::= Dv _ <expression> _ <type> */ + +static struct demangle_component * +d_vector_type (struct d_info *di) +{ + char peek; + struct demangle_component *dim; + + peek = d_peek_char (di); + if (peek == '_') + { + d_advance (di, 1); + dim = d_expression (di); + } + else + dim = d_number_component (di); + + if (dim == NULL) + return NULL; + + if (! d_check_char (di, '_')) + return NULL; + + return d_make_comp (di, DEMANGLE_COMPONENT_VECTOR_TYPE, dim, + cplus_demangle_type (di)); +} + /* <pointer-to-member-type> ::= M <(class) type> <(member) type> */ static struct demangle_component * @@ -3930,6 +3979,7 @@ d_print_comp (struct d_print_info *dpi, } case DEMANGLE_COMPONENT_PTRMEM_TYPE: + case DEMANGLE_COMPONENT_VECTOR_TYPE: { struct d_print_mod dpm; @@ -3944,11 +3994,7 @@ d_print_comp (struct d_print_info *dpi, /* If the modifier didn't get printed by the type, print it now. */ if (! dpm.printed) - { - d_append_char (dpi, ' '); - d_print_comp (dpi, d_left (dc)); - d_append_string (dpi, "::*"); - } + d_print_mod (dpi, dc); dpi->modifiers = dpm.next; @@ -4168,6 +4214,10 @@ d_print_comp (struct d_print_info *dpi, } return; + case DEMANGLE_COMPONENT_NUMBER: + d_append_num (dpi, dc->u.s_number.number); + return; + case DEMANGLE_COMPONENT_JAVA_RESOURCE: d_append_string (dpi, "java resource "); d_print_comp (dpi, d_left (dc)); @@ -4440,6 +4490,12 @@ d_print_mod (struct d_print_info *dpi, case DEMANGLE_COMPONENT_TYPED_NAME: d_print_comp (dpi, d_left (mod)); return; + case DEMANGLE_COMPONENT_VECTOR_TYPE: + d_append_string (dpi, " vector["); + d_print_comp (dpi, d_left (mod)); + d_append_char (dpi, ']'); + return; + default: /* Otherwise, we have something that won't go back on the modifier stack, so we can just print it. */ diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index eaa7ca9c9e581723796056af4777972f92d5dee8..3662f163063fca714293f65fd6b5b5792dca5dca 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3926,6 +3926,12 @@ S<int>::x::{lambda()#3}::operator()() const --format=gnu-v3 _Z1fN1SUt_E f(S::{unnamed type#1}) +--format=gnu-v3 +_Z1fDv32_f +f(float vector[32]) +--format=gnu-v3 +_Z1fIfLi4EEvDv_T0__T_ +void f<float, 4>(float vector[4]) # # Ada (GNAT) tests. #