From: Roger Sayle Date: Sun, 8 Jun 2003 18:17:53 +0000 (+0000) Subject: builtins.c (define_builtin_type, [...]): Delete. X-Git-Tag: releases/gcc-3.4.0~6043 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f158b4400a84d31b7180fbc96b1419264843328;p=thirdparty%2Fgcc.git builtins.c (define_builtin_type, [...]): Delete. * builtins.c (define_builtin_type, builtin_types): Delete. (define_builtin): Rewritten to take just the built-in code, the function's name, type and fallback library function name. All built-ins used by Java are implicit and BUILT_IN_NORMAL. (initialize_builtins): Overhaul to define the GCC builtins used by gcj manually, providing the Java run-time's implementations as the fallback library function. * libjava.lang/MathBuiltin.java: New test case. * libjava.lang/MathBuiltin.out: New file. From-SVN: r67632 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 23bc14bbc7f8..f4b5a7f44d6f 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,13 @@ +2003-06-08 Roger Sayle + + * builtins.c (define_builtin_type, builtin_types): Delete. + (define_builtin): Rewritten to take just the built-in code, + the function's name, type and fallback library function name. + All built-ins used by Java are implicit and BUILT_IN_NORMAL. + (initialize_builtins): Overhaul to define the GCC builtins + used by gcj manually, providing the Java run-time's + implementations as the fallback library function. + 2003-06-08 Anthony Green * parse.y (patch_cast): Fix conversions from floating-point to diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index c0df32326d6c..45e0b9e58c85 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -69,8 +69,7 @@ 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 *, - enum built_in_class, tree, int, int); -static tree define_builtin_type (int, int, int, int, int); + tree, const char *); @@ -114,10 +113,6 @@ static GTY(()) struct builtin_record java_builtins[] = { { NULL }, { NULL }, NULL, END_BUILTINS } }; -/* This is only used transiently, so we don't mark it as roots for the - GC. */ -static tree builtin_types[(int) BT_LAST]; - /* Internal functions which implement various builtin conversions. */ @@ -163,70 +158,22 @@ java_build_function_call_expr (tree fn, tree arglist) static void define_builtin (enum built_in_function val, const char *name, - enum built_in_class class, tree type, - int fallback_p, - int implicit) + const char *libname) { tree decl; - if (! name || ! type) - return; - - if (strncmp (name, "__builtin_", strlen ("__builtin_")) != 0) - abort (); decl = build_decl (FUNCTION_DECL, get_identifier (name), type); DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; - if (fallback_p) - SET_DECL_ASSEMBLER_NAME (decl, - get_identifier (name + strlen ("__builtin_"))); + SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname)); make_decl_rtl (decl, NULL); pushdecl (decl); - DECL_BUILT_IN_CLASS (decl) = class; + DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (decl) = val; - built_in_decls[val] = decl; - if (implicit) - implicit_built_in_decls[val] = decl; -} -/* Compute the type for a builtin. */ -static tree -define_builtin_type (int ret, int arg1, int arg2, int arg3, int arg4) -{ - tree args; - - if (builtin_types[ret] == NULL_TREE) - return NULL_TREE; - - args = void_list_node; - - if (arg4 != -1) - { - if (builtin_types[arg4] == NULL_TREE) - return NULL_TREE; - args = tree_cons (NULL_TREE, builtin_types[arg4], args); - } - if (arg3 != -1) - { - if (builtin_types[arg3] == NULL_TREE) - return NULL_TREE; - args = tree_cons (NULL_TREE, builtin_types[arg3], args); - } - if (arg2 != -1) - { - if (builtin_types[arg2] == NULL_TREE) - return NULL_TREE; - args = tree_cons (NULL_TREE, builtin_types[arg2], args); - } - if (arg1 != -1) - { - if (builtin_types[arg1] == NULL_TREE) - return NULL_TREE; - args = tree_cons (NULL_TREE, builtin_types[arg1], args); - } - - return build_function_type (builtin_types[ret], args); + implicit_built_in_decls[val] = decl; + built_in_decls[val] = decl; } @@ -235,6 +182,9 @@ define_builtin_type (int ret, int arg1, int arg2, int arg3, int arg4) void initialize_builtins (void) { + tree double_ftype_double, double_ftype_double_double; + tree float_ftype_float, float_ftype_float_float; + tree t; int i; for (i = 0; java_builtins[i].builtin_code != END_BUILTINS; ++i) @@ -248,48 +198,39 @@ initialize_builtins (void) void_list_node = end_params_node; - /* Work around C-specific junk in builtin-types.def. */ -#define intmax_type_node NULL_TREE -#define c_size_type_node NULL_TREE -#define const_string_type_node NULL_TREE -#define va_list_ref_type_node NULL_TREE -#define va_list_arg_type_node NULL_TREE -#define flag_isoc99 0 - -#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ - builtin_types[(int) ENUM] = VALUE; -#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ - builtin_types[(int) ENUM] \ - = define_builtin_type (RETURN, -1, -1, -1, -1); -#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ - builtin_types[(int) ENUM] \ - = define_builtin_type (RETURN, ARG1, -1, -1, -1); -#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ - builtin_types[(int) ENUM] \ - = define_builtin_type (RETURN, ARG1, ARG2, -1, -1); -#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ - builtin_types[(int) ENUM] \ - = define_builtin_type (RETURN, ARG1, ARG2, ARG3, -1); -#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ - builtin_types[(int) ENUM] \ - = define_builtin_type (RETURN, ARG1, ARG2, ARG3, ARG4); -#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ - builtin_types[(int) ENUM] = NULL_TREE; -#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ - builtin_types[(int) ENUM] = NULL_TREE; -#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ - builtin_types[(int) ENUM] = NULL_TREE; -#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ - builtin_types[(int) ENUM] = NULL_TREE; -#define DEF_POINTER_TYPE(ENUM, TYPE) \ - builtin_types[(int) ENUM] = NULL_TREE; - -#include "builtin-types.def" - -#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, \ - FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT) \ - define_builtin (ENUM, NAME, CLASS, builtin_types[TYPE], FALLBACK_P, IMPLICIT); -#include "builtins.def" + t = tree_cons (NULL_TREE, float_type_node, end_params_node); + float_ftype_float = build_function_type (float_type_node, t); + t = tree_cons (NULL_TREE, float_type_node, t); + float_ftype_float_float = build_function_type (float_type_node, t); + + t = tree_cons (NULL_TREE, double_type_node, end_params_node); + double_ftype_double = build_function_type (double_type_node, t); + t = tree_cons (NULL_TREE, double_type_node, t); + double_ftype_double_double = build_function_type (double_type_node, t); + + define_builtin (BUILT_IN_FMOD, "__builtin_fmod", + double_ftype_double_double, "fmod"); + define_builtin (BUILT_IN_FMODF, "__builtin_fmodf", + float_ftype_float_float, "fmodf"); + + define_builtin (BUILT_IN_ATAN, "__builtin_atan", + double_ftype_double, "_ZN4java4lang4Math4atanEd"); + define_builtin (BUILT_IN_ATAN2, "__builtin_atan2", + double_ftype_double_double, "_ZN4java4lang4Math5atan2Edd"); + define_builtin (BUILT_IN_COS, "__builtin_cos", + double_ftype_double, "_ZN4java4lang4Math3cosEd"); + define_builtin (BUILT_IN_EXP, "__builtin_exp", + double_ftype_double, "_ZN4java4lang4Math3expEd"); + define_builtin (BUILT_IN_LOG, "__builtin_log", + double_ftype_double, "_ZN4java4lang4Math3logEd"); + define_builtin (BUILT_IN_POW, "__builtin_pow", + double_ftype_double_double, "_ZN4java4lang4Math3powEdd"); + define_builtin (BUILT_IN_SIN, "__builtin_sin", + double_ftype_double, "_ZN4java4lang4Math3sinEd"); + define_builtin (BUILT_IN_SQRT, "__builtin_sqrt", + double_ftype_double, "_ZN4java4lang4Math4sqrtEd"); + define_builtin (BUILT_IN_TAN, "__builtin_tan", + double_ftype_double, "_ZN4java4lang4Math3tanEd"); } /* If the call matches a builtin, return the diff --git a/libjava/testsuite/ChangeLog b/libjava/testsuite/ChangeLog index 13020acf8ed4..ac9493bd357d 100644 --- a/libjava/testsuite/ChangeLog +++ b/libjava/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-06-08 Roger Sayle + + * libjava.lang/MathBuiltin.java: New test case. + * libjava.lang/MathBuiltin.out: New file. + 2003-06-05 Mark Wielaard * libjava.mauve/mauve.exp (test_mauve): Add -wno-deprecated to GCJ. diff --git a/libjava/testsuite/libjava.lang/MathBuiltin.java b/libjava/testsuite/libjava.lang/MathBuiltin.java new file mode 100644 index 000000000000..9a4c367a38ed --- /dev/null +++ b/libjava/testsuite/libjava.lang/MathBuiltin.java @@ -0,0 +1,70 @@ +class MathBuiltin +{ + static double abs(double x) + { + return Math.abs(x); + } + + static double atan(double x) + { + return Math.atan(x); + } + + static double atan2(double x, double y) + { + return Math.atan2(x,y); + } + + static double cos(double x) + { + return Math.cos(x); + } + + static double exp(double x) + { + return Math.exp(x); + } + + static double log(double x) + { + return Math.log(x); + } + + static double max(double x, double y) + { + return Math.max(x,y); + } + + static double min(double x, double y) + { + return Math.min(x,y); + } + + static double pow(double x, double y) + { + return Math.pow(x,y); + } + + static double sin(double x) + { + return Math.sin(x); + } + + static double sqrt(double x) + { + return Math.sqrt(x); + } + + static double tan(double x) + { + return Math.tan(x); + } + + public static void main(String argv[]) + { + double sum = abs (1.0) + atan (1.0) + atan2 (1.0, 1.0) + cos (1.0) + + exp (1.0) + log(1.0) + max(1.0, 1.0) + min (1.0, 1.0) + + pow (1.0, 1.0) + sin (1.0) + sqrt(1.0) + tan(1.0); + } +} + diff --git a/libjava/testsuite/libjava.lang/MathBuiltin.out b/libjava/testsuite/libjava.lang/MathBuiltin.out new file mode 100644 index 000000000000..e69de29bb2d1