summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/rs6000/rs6000.c19
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/Make-lang.in3
-rw-r--r--gcc/cp/mangle.c13
-rw-r--r--gcc/doc/tm.texi28
-rw-r--r--gcc/hooks.c7
-rw-r--r--gcc/hooks.h2
-rw-r--r--gcc/target-def.h2
-rw-r--r--gcc/target.h5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/ext/altivec-7.C35
12 files changed, 133 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a16e70cb6c0..e38cf9c0e4a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2004-03-23 Ziemowit Laski <zlaski@apple.com>
+
+ * hooks.c (hook_constcharptr_tree_null): New hook.
+ * hooks.h (hook_constcharptr_tree_null): New prototype.
+ * target-def.h (TARGET_MANGLE_FUNDAMENTAL_TYPE): New target hook.
+ * target.h (mangle_fundamental_type): New target hook.
+ * config/rs6000/rs6000.c (TARGET_MANGLE_FUNDAMENTAL_TYPE): Point
+ target hook at rs6000_mangle_fundamental_type.
+ (rs6000_mangle_fundamental_type): New function.
+ * doc/tm.texi (TARGET_MANGLE_FUNDAMENTAL_TYPE): Document.
+
2004-03-23 Zack Weinberg <zack@codesourcery.com>
PR 12267, 12391, 12560, 13129, 14114, 14133
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8fa0ae6ab03..09bc1b9606c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -309,6 +309,7 @@ static void rs6000_assemble_visibility (tree, int);
static int rs6000_ra_ever_killed (void);
static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *);
static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *);
+static const char *rs6000_mangle_fundamental_type (tree);
extern const struct attribute_spec rs6000_attribute_table[];
static void rs6000_set_default_type_attributes (tree);
static void rs6000_output_function_prologue (FILE *, HOST_WIDE_INT);
@@ -582,6 +583,9 @@ static const char alt_reg_names[][8] =
#undef TARGET_EXPAND_BUILTIN
#define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
+#undef TARGET_MANGLE_FUNDAMENTAL_TYPE
+#define TARGET_MANGLE_FUNDAMENTAL_TYPE rs6000_mangle_fundamental_type
+
#undef TARGET_INIT_LIBFUNCS
#define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs
@@ -14903,6 +14907,21 @@ rs6000_handle_altivec_attribute (tree *node, tree name, tree args,
return NULL_TREE;
}
+/* AltiVec defines four built-in scalar types that serve as vector
+ elements; we must teach the compiler how to mangle them. */
+
+static const char *
+rs6000_mangle_fundamental_type (tree type)
+{
+ if (type == bool_char_type_node) return "U6__boolc";
+ if (type == bool_short_type_node) return "U6__bools";
+ if (type == pixel_type_node) return "u7__pixel";
+ if (type == bool_int_type_node) return "U6__booli";
+
+ /* For all other types, use normal C++ mangling. */
+ return NULL;
+}
+
/* Handle a "longcall" or "shortcall" attribute; arguments as in
struct attribute_spec.handler. */
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6ccd4b0e3f4..a1a6d6829af 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-23 Ziemowit Laski <zlaski@apple.com>
+
+ * Make-lang.in (cp/mangle.o): Depend on $(TARGET_H).
+ * mangle.c (write_type): Add call to 'mangle_fundamental_type'
+ target hook.
+
2004-03-23 Zack Weinberg <zack@codesourcery.com>
PR 12267, 12391, 12560, 13129, 14114, 14133
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 1d4d918be2d..0f934f225a3 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -258,7 +258,8 @@ cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) cp/lex.h except.h toplev.h
cp/dump.o: cp/dump.c $(CXX_TREE_H) $(TM_H) tree-dump.h
cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h integrate.h insn-config.h \
input.h $(PARAMS_H) debug.h tree-inline.h
-cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h real.h gt-cp-mangle.h $(TM_P_H)
+cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h real.h gt-cp-mangle.h \
+ $(TARGET_H) $(TM_P_H)
cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) diagnostic.h gt-cp-parser.h \
output.h
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 2580d39866f..d8c615b7848 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -59,6 +59,7 @@
#include "toplev.h"
#include "varray.h"
#include "flags.h"
+#include "target.h"
/* Debugging support. */
@@ -1501,12 +1502,24 @@ write_type (tree type)
case BOOLEAN_TYPE:
case INTEGER_TYPE: /* Includes wchar_t. */
case REAL_TYPE:
+ {
+ /* Handle any target-specific fundamental types. */
+ const char *target_mangling
+ = targetm.mangle_fundamental_type (type);
+
+ if (target_mangling)
+ {
+ write_string (target_mangling);
+ return;
+ }
+
/* If this is a typedef, TYPE may not be one of
the standard builtin type nodes, but an alias of one. Use
TYPE_MAIN_VARIANT to get to the underlying builtin type. */
write_builtin_type (TYPE_MAIN_VARIANT (type));
++is_builtin_type;
break;
+ }
case COMPLEX_TYPE:
write_char ('C');
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f78b9621c1f..e8b6d9dacfd 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1514,6 +1514,34 @@ precedence for that field, but the alignment of the rest of the structure
may affect its placement.
@end deftypefn
+@deftypefn {Target Hook} {const char *} TARGET_MANGLE_FUNDAMENTAL_TYPE (tree @var{type})
+If your target defines any fundamental types, define this hook to
+return the appropriate encoding for these types as part of a C++
+mangled name. The @var{type} argument is the tree structure
+representing the type to be mangled. The hook may be applied to trees
+which are not target-specific fundamental types; it should return
+@code{NULL} for all such types, as well as arguments it does not
+recognize. If the return value is not @code{NULL}, it must point to
+a statically-allocated string constant.
+
+Target-specific fundamental types might be new fundamental types or
+qualified versions of ordinary fundamental types. Encode new
+fundamental types as @samp{@w{u @var{n} @var{name}}}, where @var{name}
+is the name used for the type in source code, and @var{n} is the
+length of @var{name} in decimal. Encode qualified versions of
+ordinary types as @samp{@w{U @var{n} @var{name} @var{code}}}, where
+@var{name} is the name used for the type qualifier in source code,
+@var{n} is the length of @var{name} as above, and @var{code} is the
+code used to represent the unqualified version of this type. (See
+@code{write_builtin_type} in @file{cp/mangle.c} for the list of
+codes.) In both cases the spaces are for clarity; do not include any
+spaces in your string.
+
+The default version of this hook always returns @code{NULL}, which is
+appropriate for a target that does not define any new fundamental
+types.
+@end deftypefn
+
@node Type Layout
@section Layout of Source Language Data Types
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 5b9bb653996..e37d58e9723 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -211,3 +211,10 @@ hook_tree_tree_identity (tree a)
{
return a;
}
+
+/* Generic hook that takes a tree and returns a NULL string. */
+const char *
+hook_constcharptr_tree_null (tree t ATTRIBUTE_UNUSED)
+{
+ return NULL;
+}
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 824683b4cf4..aab83a81620 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -58,5 +58,5 @@ extern rtx hook_rtx_rtx_identity (rtx);
extern rtx hook_rtx_rtx_null (rtx);
extern rtx hook_rtx_tree_int_null (tree, int);
extern tree hook_tree_tree_identity (tree a);
-
+extern const char *hook_constcharptr_tree_null (tree);
#endif
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 930fba64b10..62060abebf2 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -311,6 +311,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P hook_bool_tree_false
#define TARGET_MS_BITFIELD_LAYOUT_P hook_bool_tree_false
#define TARGET_RTX_COSTS hook_bool_rtx_int_int_intp_false
+#define TARGET_MANGLE_FUNDAMENTAL_TYPE hook_constcharptr_tree_null
#ifndef TARGET_INIT_LIBFUNCS
#define TARGET_INIT_LIBFUNCS hook_void_void
@@ -385,6 +386,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_MS_BITFIELD_LAYOUT_P, \
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
+ TARGET_MANGLE_FUNDAMENTAL_TYPE, \
TARGET_INIT_LIBFUNCS, \
TARGET_SECTION_TYPE_FLAGS, \
TARGET_CANNOT_MODIFY_JUMPS_P, \
diff --git a/gcc/target.h b/gcc/target.h
index 5dea29a8204..c122adbcdfa 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -314,6 +314,11 @@ struct gcc_target
rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget,
enum machine_mode mode, int ignore);
+ /* For a vendor-specific fundamental TYPE, return a pointer to
+ a statically-allocated string containing the C++ mangling for
+ TYPE. In all other cases, return NULL. */
+ const char * (* mangle_fundamental_type) (tree type);
+
/* Make any adjustments to libfunc names needed for this target. */
void (* init_libfuncs) (void);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8fb6722e567..8fcef832664 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-03-23 Ziemowit Laski <zlaski@apple.com>
+
+ * g++.dg/ext/altivec-7.C: New test.
+
2004-03-23 Zack Weinberg <zack@codesourcery.com>
PR 12267, 12391, 12560, 13129, 14114, 14133
diff --git a/gcc/testsuite/g++.dg/ext/altivec-7.C b/gcc/testsuite/g++.dg/ext/altivec-7.C
new file mode 100644
index 00000000000..b09593e3e49
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/altivec-7.C
@@ -0,0 +1,35 @@
+/* Test for AltiVec type overloading and name mangling. */
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-options "-maltivec" } */
+
+#include <altivec.h>
+
+void foo(vector unsigned char) { }
+void foo(vector signed char) { }
+void foo(vector bool char) { }
+void foo(vector unsigned short) { }
+void foo(vector signed short) { }
+void foo(vector bool short) { }
+void foo(vector unsigned long) { } /* { dg-warning "use of .long. in AltiVec types is deprecated. use .int." } */
+void foo(vector signed long) { } /* { dg-warning "use of .long. in AltiVec types is deprecated. use .int." } */
+void foo(vector bool long) { } /* { dg-warning "use of .long. in AltiVec types is deprecated. use .int." } */
+void foo(vector float) { }
+void foo(vector pixel) { }
+void foo(int) { }
+void foo(unsigned int) { }
+void foo(float) { }
+
+/* { dg-final { scan-assembler "_Z3fooU8__vectorh" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectora" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectorU6__boolc" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectort" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectors" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectorU6__bools" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectorj" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectori" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectorU6__booli" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectorf" } } */
+/* { dg-final { scan-assembler "_Z3fooU8__vectoru7__pixel" } } */
+/* { dg-final { scan-assembler "_Z3fooi" } } */
+/* { dg-final { scan-assembler "_Z3fooj" } } */
+/* { dg-final { scan-assembler "_Z3foof" } } */