hooks.c (hook_constcharptr_tree_null): New hook.

[gcc/ChangeLog]
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.

[gcc/cp/ChangeLog]
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.

[gcc/testsuite/ChangeLog]
2004-03-23  Ziemowit Laski  <zlaski@apple.com>

        * g++.dg/ext/altivec-7.C: New test.

From-SVN: r79885
This commit is contained in:
Ziemowit Laski 2004-03-24 00:13:33 +00:00 committed by Ziemowit Laski
parent 1b1d85bda3
commit f18eca824c
12 changed files with 133 additions and 2 deletions

View file

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

View file

@ -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. */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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" } } */