Commit 58646b77 by Paolo Bonzini Committed by Paolo Bonzini

c-common.c (resolve_overloaded_builtin): Forward to target hook for BUILT_IN_MD built-ins.

2005-05-02  Paolo Bonzini  <bonzini@gnu.org>

        * c-common.c (resolve_overloaded_builtin): Forward to target
        hook for BUILT_IN_MD built-ins.
        * c-typeck.c (finish_call_expr): Call resolve_overloaded_builtin
        for all types of built-in.
        * target-def.h (TARGET_RESOLVE_OVERLOADED_BUILTIN): New.  Use it
        in the definition of the target hooks struct.
        * target.h (struct gcc_target): Add resolve_overloaded_builtin.
        * config/rs6000/altivec.h: Rewritten.
        * config/rs6000/rs6000-c.c (struct altivec_builtin_types,
        altivec_resolve_overloaded_builtin, altivec_build_resolved_builtin,
        rs6000_builtin_type, rs6000_builtin_type_compatible,
        altivec_overloaded_builtins, rs6000_builtin_type,
        rs6000_builtin_type_compatible): New.
        * config/rs6000/rs6000.c (rs6000_builtin_types, rs6000_builtin_decls):
        New.
        (def_builtin): Turn into a function.  Check for duplicates and store
        the builtin into rs6000_builtin_decls.
        (bdesc_3arg, bdesc_dst, bdesc_altivec_preds, bdesc_2arg,
        bdesc_1arg): Add overloaded builtins.
        (altivec_expand_builtin): Check for unresolved overloaded builtins,
        do not support ALTIVEC_COMPILETIME_ERROR.
        (rs6000_init_builtins): Add opaque 128-bit vector, and internal
        nodes to represent front-end types.
        (altivec_init_builtins, rs6000_common_init_builtins): Create builtins
        with opaque arguments and/or return values.
        * config/rs6000/rs6000.h (enum rs6000_builtins): Remove
        ALTIVEC_COMPILETIME_ERROR and add Altivec overloaded builtins.
        (rs6000_builtin_type_index): New.
        (is_ev64_opaque_type): Rename to...
        (rs6000_is_opaque_type): ... this.
        (rs6000_cpu_cpp_builtins): Install the resolve_overloaded_builtin
        target hook.

cp:
2005-05-02  Paolo Bonzini  <bonzini@gnu.org>

        * semantics.c (finish_call_expr): Call resolve_overloaded_builtin
        for BUILT_IN_MD built-ins.

testsuite:
2005-05-02  Paolo Bonzini  <bonzini@gnu.org>

        * gcc.dg/altivec-3.c (vec_store): Do not use the old
        __builtin_altivec_st_internal_4si built-in.

From-SVN: r99103
parent 985484fd
2005-05-02 Paolo Bonzini <bonzini@gnu.org>
* c-common.c (resolve_overloaded_builtin): Forward to target
hook for BUILT_IN_MD built-ins.
* c-typeck.c (finish_call_expr): Call resolve_overloaded_builtin
for all types of built-in.
* target-def.h (TARGET_RESOLVE_OVERLOADED_BUILTIN): New. Use it
in the definition of the target hooks struct.
* target.h (struct gcc_target): Add resolve_overloaded_builtin.
* config/rs6000/altivec.h: Rewritten.
* config/rs6000/rs6000-c.c (struct altivec_builtin_types,
altivec_resolve_overloaded_builtin, altivec_build_resolved_builtin,
rs6000_builtin_type, rs6000_builtin_type_compatible,
altivec_overloaded_builtins, rs6000_builtin_type,
rs6000_builtin_type_compatible): New.
* config/rs6000/rs6000.c (rs6000_builtin_types, rs6000_builtin_decls):
New.
(def_builtin): Turn into a function. Check for duplicates and store
the builtin into rs6000_builtin_decls.
(bdesc_3arg, bdesc_dst, bdesc_altivec_preds, bdesc_2arg,
bdesc_1arg): Add overloaded builtins.
(altivec_expand_builtin): Check for unresolved overloaded builtins,
do not support ALTIVEC_COMPILETIME_ERROR.
(rs6000_init_builtins): Add opaque 128-bit vector, and internal
nodes to represent front-end types.
(altivec_init_builtins, rs6000_common_init_builtins): Create builtins
with opaque arguments and/or return values.
* config/rs6000/rs6000.h (enum rs6000_builtins): Remove
ALTIVEC_COMPILETIME_ERROR and add Altivec overloaded builtins.
(rs6000_builtin_type_index): New.
(is_ev64_opaque_type): Rename to...
(rs6000_is_opaque_type): ... this.
(rs6000_cpu_cpp_builtins): Install the resolve_overloaded_builtin
target hook.
2005-05-02 Kazu Hirata <kazu@cs.umass.edu>
* function.c (reorder_blocks, reorder_blocks_1): Use VEC
......
......@@ -5979,6 +5979,20 @@ tree
resolve_overloaded_builtin (tree function, tree params)
{
enum built_in_function orig_code = DECL_FUNCTION_CODE (function);
switch (DECL_BUILT_IN_CLASS (function))
{
case BUILT_IN_NORMAL:
break;
case BUILT_IN_MD:
if (targetm.resolve_overloaded_builtin)
return targetm.resolve_overloaded_builtin (function, params);
else
return NULL_TREE;
default:
return NULL_TREE;
}
/* Handle BUILT_IN_NORMAL here. */
switch (orig_code)
{
case BUILT_IN_FETCH_AND_ADD_N:
......@@ -6017,7 +6031,7 @@ resolve_overloaded_builtin (tree function, tree params)
}
default:
return NULL;
return NULL_TREE;
}
}
......
......@@ -1979,12 +1979,13 @@ build_function_call (tree function, tree params)
/* Convert anything with function type to a pointer-to-function. */
if (TREE_CODE (function) == FUNCTION_DECL)
{
if (DECL_BUILT_IN_CLASS (function) == BUILT_IN_NORMAL)
{
tem = resolve_overloaded_builtin (function, params);
if (tem)
return tem;
}
/* Implement type-directed function overloading for builtins.
resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
handle all the type checking. The result is a complete expression
that implements this function call. */
tem = resolve_overloaded_builtin (function, params);
if (tem)
return tem;
name = DECL_NAME (function);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
2005-05-02 Paolo Bonzini <bonzini@gnu.org>
* semantics.c (finish_call_expr): Call resolve_overloaded_builtin
for BUILT_IN_MD built-ins.
2005-05-02 Michael Matz <matz@suse.de>
PR c++/19542
......
......@@ -1837,7 +1837,8 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
{
/* If the function is an overloaded builtin, resolve it. */
if (TREE_CODE (fn) == FUNCTION_DECL
&& DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL)
&& (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
|| DECL_BUILT_IN_CLASS (fn) == BUILT_IN_MD))
result = resolve_overloaded_builtin (fn, args);
if (!result)
......
......@@ -296,6 +296,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* In builtins.c. */
#define TARGET_INIT_BUILTINS hook_void_void
#define TARGET_EXPAND_BUILTIN default_expand_builtin
#define TARGET_RESOLVE_OVERLOADED_BUILTIN NULL
#define TARGET_FOLD_BUILTIN hook_tree_tree_tree_bool_null
/* In varasm.c. */
......@@ -515,6 +516,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_ALIGN_ANON_BITFIELD, \
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
TARGET_RESOLVE_OVERLOADED_BUILTIN, \
TARGET_FOLD_BUILTIN, \
TARGET_MANGLE_FUNDAMENTAL_TYPE, \
TARGET_INIT_LIBFUNCS, \
......
......@@ -345,9 +345,15 @@ struct gcc_target
rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget,
enum machine_mode mode, int ignore);
/* Select a replacement for a target-specific builtin. This is done
*before* regular type checking, and so allows the target to implement
a crude form of function overloading. The result is a complete
expression that implements the operation. */
tree (*resolve_overloaded_builtin) (tree decl, tree params);
/* Fold a target-specific builtin. */
tree (* fold_builtin) (tree fndecl, tree arglist, bool 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. */
......
2005-05-02 Paolo Bonzini <bonzini@gnu.org>
* gcc.dg/altivec-3.c (vec_store): Do not use the old
__builtin_altivec_st_internal_4si built-in.
2005-05-02 Mark Mitchell <mark@codesourcery.com>
PR c++/15875
......
......@@ -19,7 +19,7 @@ float h3[4] __attribute__((aligned(16)));
float g3[4] __attribute__((aligned(16)));
#define vec_store(dst, src) \
__builtin_altivec_st_internal_4si ((int *) dst, (int4) src)
__builtin_vec_st (src, 0, (__typeof__ (src) *) dst)
#define vec_add_int4(x, y) \
__builtin_altivec_vaddsws (x, y)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment