X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fjava%2Fbuiltins.c;h=2ea9e5787848caf909128231d5e8b14c82ee6453;hb=72a6b07c4c8afddb3a5b5db4b1334a65dd713abf;hp=5219f23bcc8f9c601238fbf1bafbb1184016bd5c;hpb=b2c4af5e79a1c17df9214775988a66dac92f2667;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 5219f23bcc8..2ea9e578784 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -1,5 +1,5 @@ /* Built-in and inline functions for gcj - Copyright (C) 2001, 2003 + Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GCC. @@ -16,8 +16,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. @@ -41,8 +41,6 @@ static tree min_builtin (tree, tree); static tree abs_builtin (tree, tree); static tree java_build_function_call_expr (tree, tree); -static void define_builtin (enum built_in_function, const char *, - tree, const char *); @@ -96,24 +94,24 @@ static GTY(()) struct builtin_record java_builtins[] = static tree max_builtin (tree method_return_type, tree method_arguments) { - return fold (build2 (MAX_EXPR, method_return_type, - TREE_VALUE (method_arguments), - TREE_VALUE (TREE_CHAIN (method_arguments)))); + return fold_build2 (MAX_EXPR, method_return_type, + TREE_VALUE (method_arguments), + TREE_VALUE (TREE_CHAIN (method_arguments))); } static tree min_builtin (tree method_return_type, tree method_arguments) { - return fold (build2 (MIN_EXPR, method_return_type, - TREE_VALUE (method_arguments), - TREE_VALUE (TREE_CHAIN (method_arguments)))); + return fold_build2 (MIN_EXPR, method_return_type, + TREE_VALUE (method_arguments), + TREE_VALUE (TREE_CHAIN (method_arguments))); } static tree abs_builtin (tree method_return_type, tree method_arguments) { - return fold (build1 (ABS_EXPR, method_return_type, - TREE_VALUE (method_arguments))); + return fold_build1 (ABS_EXPR, method_return_type, + TREE_VALUE (method_arguments)); } /* Mostly copied from ../builtins.c. */ @@ -123,20 +121,21 @@ java_build_function_call_expr (tree fn, tree arglist) tree call_expr; call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn); - call_expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)), + return fold_build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)), call_expr, arglist, NULL_TREE); - TREE_SIDE_EFFECTS (call_expr) = 1; - return fold (call_expr); } +#define BUILTIN_NOTHROW 1 +#define BUILTIN_CONST 2 /* Define a single builtin. */ static void define_builtin (enum built_in_function val, const char *name, tree type, - const char *libname) + const char *libname, + int flags) { tree decl; @@ -144,10 +143,13 @@ define_builtin (enum built_in_function val, DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname)); - make_decl_rtl (decl); pushdecl (decl); DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (decl) = val; + if (flags & BUILTIN_NOTHROW) + TREE_NOTHROW (decl) = 1; + if (flags & BUILTIN_CONST) + TREE_READONLY (decl) = 1; implicit_built_in_decls[val] = decl; built_in_decls[val] = decl; @@ -161,6 +163,7 @@ initialize_builtins (void) { tree double_ftype_double, double_ftype_double_double; tree float_ftype_float, float_ftype_float_float; + tree boolean_ftype_boolean_boolean; tree t; int i; @@ -186,36 +189,59 @@ initialize_builtins (void) double_ftype_double_double = build_function_type (double_type_node, t); define_builtin (BUILT_IN_FMOD, "__builtin_fmod", - double_ftype_double_double, "fmod"); + double_ftype_double_double, "fmod", BUILTIN_CONST); define_builtin (BUILT_IN_FMODF, "__builtin_fmodf", - float_ftype_float_float, "fmodf"); + float_ftype_float_float, "fmodf", BUILTIN_CONST); define_builtin (BUILT_IN_ACOS, "__builtin_acos", - double_ftype_double, "_ZN4java4lang4Math4acosEd"); + double_ftype_double, "_ZN4java4lang4Math4acosEd", + BUILTIN_CONST); define_builtin (BUILT_IN_ASIN, "__builtin_asin", - double_ftype_double, "_ZN4java4lang4Math4asinEd"); + double_ftype_double, "_ZN4java4lang4Math4asinEd", + BUILTIN_CONST); define_builtin (BUILT_IN_ATAN, "__builtin_atan", - double_ftype_double, "_ZN4java4lang4Math4atanEd"); + double_ftype_double, "_ZN4java4lang4Math4atanEd", + BUILTIN_CONST); define_builtin (BUILT_IN_ATAN2, "__builtin_atan2", - double_ftype_double_double, "_ZN4java4lang4Math5atan2Edd"); + double_ftype_double_double, "_ZN4java4lang4Math5atan2Edd", + BUILTIN_CONST); define_builtin (BUILT_IN_CEIL, "__builtin_ceil", - double_ftype_double, "_ZN4java4lang4Math4ceilEd"); + double_ftype_double, "_ZN4java4lang4Math4ceilEd", + BUILTIN_CONST); define_builtin (BUILT_IN_COS, "__builtin_cos", - double_ftype_double, "_ZN4java4lang4Math3cosEd"); + double_ftype_double, "_ZN4java4lang4Math3cosEd", + BUILTIN_CONST); define_builtin (BUILT_IN_EXP, "__builtin_exp", - double_ftype_double, "_ZN4java4lang4Math3expEd"); + double_ftype_double, "_ZN4java4lang4Math3expEd", + BUILTIN_CONST); define_builtin (BUILT_IN_FLOOR, "__builtin_floor", - double_ftype_double, "_ZN4java4lang4Math5floorEd"); + double_ftype_double, "_ZN4java4lang4Math5floorEd", + BUILTIN_CONST); define_builtin (BUILT_IN_LOG, "__builtin_log", - double_ftype_double, "_ZN4java4lang4Math3logEd"); + double_ftype_double, "_ZN4java4lang4Math3logEd", + BUILTIN_CONST); define_builtin (BUILT_IN_POW, "__builtin_pow", - double_ftype_double_double, "_ZN4java4lang4Math3powEdd"); + double_ftype_double_double, "_ZN4java4lang4Math3powEdd", + BUILTIN_CONST); define_builtin (BUILT_IN_SIN, "__builtin_sin", - double_ftype_double, "_ZN4java4lang4Math3sinEd"); + double_ftype_double, "_ZN4java4lang4Math3sinEd", + BUILTIN_CONST); define_builtin (BUILT_IN_SQRT, "__builtin_sqrt", - double_ftype_double, "_ZN4java4lang4Math4sqrtEd"); + double_ftype_double, "_ZN4java4lang4Math4sqrtEd", + BUILTIN_CONST); define_builtin (BUILT_IN_TAN, "__builtin_tan", - double_ftype_double, "_ZN4java4lang4Math3tanEd"); + double_ftype_double, "_ZN4java4lang4Math3tanEd", + BUILTIN_CONST); + + t = tree_cons (NULL_TREE, boolean_type_node, end_params_node); + t = tree_cons (NULL_TREE, boolean_type_node, t); + boolean_ftype_boolean_boolean = build_function_type (boolean_type_node, t); + define_builtin (BUILT_IN_EXPECT, "__builtin_expect", + boolean_ftype_boolean_boolean, + "__builtin_expect", + BUILTIN_CONST | BUILTIN_NOTHROW); + + build_common_builtin_nodes (); } /* If the call matches a builtin, return the