aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-06-08 18:17:53 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2003-06-08 18:17:53 +0000
commit5f158b4400a84d31b7180fbc96b1419264843328 (patch)
treedee5dc24a26ca2e2b97de7e17aacd6263f8d6a1c /gcc/java
parentf32c53c2153535de4c9016cd174330be4c9a6027 (diff)
downloadgcc-5f158b4400a84d31b7180fbc96b1419264843328.zip
gcc-5f158b4400a84d31b7180fbc96b1419264843328.tar.gz
gcc-5f158b4400a84d31b7180fbc96b1419264843328.tar.bz2
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
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog10
-rw-r--r--gcc/java/builtins.c143
2 files changed, 52 insertions, 101 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 23bc14b..f4b5a7f 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,13 @@
+2003-06-08 Roger Sayle <roger@eyesopen.com>
+
+ * 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 <green@redhat.com>
* parse.y (patch_cast): Fix conversions from floating-point to
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c
index c0df323..45e0b9e 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