#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "cpplib.h"
#include "tree.h"
#include "c-tree.h"
#include "c-pragma.h"
#include "function.h"
#include "rtl.h"
#include "expr.h"
#include "errors.h"
#include "tm_p.h"
#include "langhooks.h"
#include "insn-config.h"
#include "insn-codes.h"
#include "recog.h"
#include "optabs.h"
#include "spu-builtins.h"
tree
spu_resolve_overloaded_builtin (tree fndecl, tree fnargs)
{
#define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \
|| SCALAR_FLOAT_TYPE_P (t) \
|| POINTER_TYPE_P (t))
spu_function_code new_fcode, fcode =
DECL_FUNCTION_CODE (fndecl) - END_BUILTINS;
struct spu_builtin_description *desc;
tree match = NULL_TREE;
gcc_assert (!flag_preprocess_only);
desc = &spu_builtins[fcode];
if (desc->type != B_OVERLOAD)
return NULL_TREE;
for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL;
new_fcode++)
{
tree decl = spu_builtins[new_fcode].fndecl;
tree params = TYPE_ARG_TYPES (TREE_TYPE (decl));
tree arg, param;
int p;
for (param = params, arg = fnargs, p = 0;
param != void_list_node;
param = TREE_CHAIN (param), arg = TREE_CHAIN (arg), p++)
{
tree var, arg_type, param_type = TREE_VALUE (param);
if (!arg)
{
error ("insufficient arguments to overloaded function %s",
desc->name);
return error_mark_node;
}
var = TREE_VALUE (arg);
if (TREE_CODE (var) == NON_LVALUE_EXPR)
var = TREE_OPERAND (var, 0);
if (TREE_CODE (var) == ERROR_MARK)
return NULL_TREE;
arg_type = TREE_TYPE (var);
if ((!SCALAR_TYPE_P (param_type)
|| !SCALAR_TYPE_P (arg_type)
|| ((fcode == SPU_SPLATS || fcode == SPU_PROMOTE
|| fcode == SPU_HCMPEQ || fcode == SPU_HCMPGT
|| fcode == SPU_MASKB || fcode == SPU_MASKH
|| fcode == SPU_MASKW) && p == 0))
&& !comptypes (TYPE_MAIN_VARIANT (param_type),
TYPE_MAIN_VARIANT (arg_type)))
break;
}
if (param == void_list_node)
{
if (arg)
{
error ("too many arguments to overloaded function %s",
desc->name);
return error_mark_node;
}
match = decl;
break;
}
}
if (match == NULL_TREE)
{
error ("parameter list does not match a valid signature for %s()",
desc->name);
return error_mark_node;
}
return build_function_call (match, fnargs);
#undef SCALAR_TYPE_P
}
void
spu_cpu_cpp_builtins (struct cpp_reader *pfile)
{
builtin_define_std ("__SPU__");
cpp_assert (pfile, "cpu=spu");
cpp_assert (pfile, "machine=spu");
builtin_define_std ("__vector=__attribute__((__spu_vector__))");
}
void
spu_c_common_override_options (void)
{
if (!TARGET_STD_MAIN)
{
warn_main = 0;
}
}