builtins.c (define_builtin): Accept new flags parameter.
authorJan Hubicka <jh@suse.cz>
Sat, 25 Jun 2005 11:22:50 +0000 (13:22 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 25 Jun 2005 11:22:50 +0000 (11:22 +0000)
* builtins.c (define_builtin): Accept new flags parameter.
(initialize_builtins): Mark the builtins const and nothrow accordingly.

From-SVN: r101319

gcc/java/ChangeLog
gcc/java/builtins.c

index 08bebbccd28e704a47459261dd989ccff33c48b8..229845e076010c302651ac78ffda901a4a3c6523 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-25  Jan Hubicka  <jh@suse.cz>
+
+       * builtins.c (define_builtin): Accept new flags parameter.
+       (initialize_builtins): Mark the builtins const and nothrow accordingly.
+
 2005-06-25  Kelley Cook  <kcook@gcc.gnu.org>
 
        * all files: Update FSF address in copyright headers.
index 09aa5bd21500a2752cb43ab85ac8833d14146024..68f0b95f1b5f58faacf80895c2bc1939affdcb4d 100644 (file)
@@ -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 *);
 
 \f
 
@@ -131,12 +129,15 @@ java_build_function_call_expr (tree fn, tree arglist)
 
 \f
 
+#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;
 
@@ -147,6 +148,10 @@ define_builtin (enum built_in_function val,
   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;
@@ -186,43 +191,57 @@ 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_expect",
+                 BUILTIN_CONST | BUILTIN_NOTHROW);
                  
   build_common_builtin_nodes ();
 }