Commit feda1845 by Roger Sayle Committed by Roger Sayle

builtins.c (builtin_mathfn_code): Generalize to check whether the call is to any…

builtins.c (builtin_mathfn_code): Generalize to check whether the call is to any built-in function by comparing...


	* builtins.c (builtin_mathfn_code): Generalize to check whether
	the call is to any built-in function by comparing the call's
	argument list against the builtin decl's function type.

From-SVN: r72327
parent dd0ba281
2003-10-10 Roger Sayle <roger@eyesopen.com> 2003-10-10 Roger Sayle <roger@eyesopen.com>
* builtins.c (builtin_mathfn_code): Generalize to check whether
the call is to any built-in function by comparing the call's
argument list against the builtin decl's function type.
2003-10-10 Roger Sayle <roger@eyesopen.com>
* cse.c (constant_pool_entries_regcost): New global variable to * cse.c (constant_pool_entries_regcost): New global variable to
hold the register cost component of constant_pool_entries_cost. hold the register cost component of constant_pool_entries_cost.
(fold_rtx): Calculate constant_pool_entries_regcost at the same (fold_rtx): Calculate constant_pool_entries_regcost at the same
......
...@@ -5318,15 +5318,16 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, ...@@ -5318,15 +5318,16 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
} }
/* Determine whether a tree node represents a call to a built-in /* Determine whether a tree node represents a call to a built-in
math function. If the tree T is a call to a built-in function function. If the tree T is a call to a built-in function with
taking a single real argument, then the return value is the the right number of arguments of the appropriate types, return
DECL_FUNCTION_CODE of the call, e.g. BUILT_IN_SQRT. Otherwise the DECL_FUNCTION_CODE of the call, e.g. BUILT_IN_SQRT.
the return value is END_BUILTINS. */ Otherwise the return value is END_BUILTINS. */
enum built_in_function enum built_in_function
builtin_mathfn_code (tree t) builtin_mathfn_code (tree t)
{ {
tree fndecl, arglist; tree fndecl, arglist, parmlist;
tree argtype, parmtype;
if (TREE_CODE (t) != CALL_EXPR if (TREE_CODE (t) != CALL_EXPR
|| TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR) || TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR)
...@@ -5334,36 +5335,57 @@ builtin_mathfn_code (tree t) ...@@ -5334,36 +5335,57 @@ builtin_mathfn_code (tree t)
fndecl = get_callee_fndecl (t); fndecl = get_callee_fndecl (t);
if (fndecl == NULL_TREE if (fndecl == NULL_TREE
|| TREE_CODE (fndecl) != FUNCTION_DECL
|| ! DECL_BUILT_IN (fndecl) || ! DECL_BUILT_IN (fndecl)
|| DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) || DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
return END_BUILTINS; return END_BUILTINS;
arglist = TREE_OPERAND (t, 1); arglist = TREE_OPERAND (t, 1);
if (! arglist parmlist = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
|| TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE) for (; parmlist; parmlist = TREE_CHAIN (parmlist))
return END_BUILTINS;
arglist = TREE_CHAIN (arglist);
switch (DECL_FUNCTION_CODE (fndecl))
{ {
case BUILT_IN_POW: /* If a function doesn't take a variable number of arguments,
case BUILT_IN_POWF: the last element in the list will have type `void'. */
case BUILT_IN_POWL: parmtype = TREE_VALUE (parmlist);
case BUILT_IN_ATAN2: if (VOID_TYPE_P (parmtype))
case BUILT_IN_ATAN2F: {
case BUILT_IN_ATAN2L: if (arglist)
if (! arglist return END_BUILTINS;
|| TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE return DECL_FUNCTION_CODE (fndecl);
|| TREE_CHAIN (arglist)) }
if (! arglist)
return END_BUILTINS; return END_BUILTINS;
break;
default: argtype = TREE_TYPE (TREE_VALUE (arglist));
if (arglist)
if (SCALAR_FLOAT_TYPE_P (parmtype))
{
if (! SCALAR_FLOAT_TYPE_P (argtype))
return END_BUILTINS;
}
else if (COMPLEX_FLOAT_TYPE_P (parmtype))
{
if (! COMPLEX_FLOAT_TYPE_P (argtype))
return END_BUILTINS;
}
else if (POINTER_TYPE_P (parmtype))
{
if (! POINTER_TYPE_P (argtype))
return END_BUILTINS;
}
else if (INTEGRAL_TYPE_P (parmtype))
{
if (! INTEGRAL_TYPE_P (argtype))
return END_BUILTINS;
}
else
return END_BUILTINS; return END_BUILTINS;
break;
arglist = TREE_CHAIN (arglist);
} }
/* Variable-length argument list. */
return DECL_FUNCTION_CODE (fndecl); return DECL_FUNCTION_CODE (fndecl);
} }
......
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