Patchwork [Java] Tidy bultins and add __bultin_unreachable

login
register
mail settings
Submitter Jan Hubicka
Date Oct. 16, 2012, 3:17 p.m.
Message ID <20121016151746.GC4090@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/191815/
State New
Headers show

Comments

Jan Hubicka - Oct. 16, 2012, 3:17 p.m.
Hi,
this patch udpates Java frontend to declare __bulitin_unreachable and also
fixes flags of synchronize bulitins to match ones from C FE.

Regtested x86_64-linux, OK?

Honza
	* builtins.c (define_builtin): Accept ECF flags and
	use set_call_expr_flags.
	(initialize_builtins): Update; add BULIT_IN_UNREACHALE.

	* calls.c (set_call_expr_flags): New.
	* tree.h (set_call_expr_flags): Declare.
Tom Tromey - Oct. 16, 2012, 4:43 p.m.
>>>>> "Jan" == Jan Hubicka <hubicka@ucw.cz> writes:

Jan> this patch udpates Java frontend to declare __bulitin_unreachable
Jan> and also fixes flags of synchronize bulitins to match ones from C
Jan> FE.

Jan> Regtested x86_64-linux, OK?

The java bits are ok.

Jan> +  /* Looping const or pure is imlpies by noreturn.

Typo, should be "implied".

Tom
Jan Hubicka - Oct. 16, 2012, 4:48 p.m.
> >>>>> "Jan" == Jan Hubicka <hubicka@ucw.cz> writes:
> 
> Jan> this patch udpates Java frontend to declare __bulitin_unreachable
> Jan> and also fixes flags of synchronize bulitins to match ones from C
> Jan> FE.
> 
> Jan> Regtested x86_64-linux, OK?
> 
> The java bits are ok.
> 
> Jan> +  /* Looping const or pure is imlpies by noreturn.
> 
> Typo, should be "implied".

Thanks,
as per Iant comment I will remove the bits adding __buliltin_unreachable
and put it into build_common_builtin_nodes

Honza
Andrew Haley - Oct. 16, 2012, 6:04 p.m.
On 10/16/2012 08:17 AM, Jan Hubicka wrote:
> 	* builtins.c (define_builtin): Accept ECF flags and
> 	use set_call_expr_flags.
> 	(initialize_builtins): Update; add BULIT_IN_UNREACHALE.
> 
> 	* calls.c (set_call_expr_flags): New.
> 	* tree.h (set_call_expr_flags): Declare.

OK, thanks.

Andrew.

Patch

Index: java/builtins.c
===================================================================
--- java/builtins.c	(revision 192483)
+++ java/builtins.c	(working copy)
@@ -451,8 +451,6 @@  VMSupportsCS8_builtin (tree method_retur
 
 
 
-#define BUILTIN_NOTHROW 1
-#define BUILTIN_CONST 2
 /* Define a single builtin.  */
 static void
 define_builtin (enum built_in_function val,
@@ -471,10 +469,7 @@  define_builtin (enum built_in_function v
   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;
+  set_call_expr_flags (decl, flags);
 
   set_builtin_decl (val, decl, true);
 }
@@ -488,6 +483,7 @@  initialize_builtins (void)
   tree double_ftype_double, double_ftype_double_double;
   tree float_ftype_float_float;
   tree boolean_ftype_boolean_boolean;
+  tree void_ftype;
   int i;
 
   for (i = 0; java_builtins[i].builtin_code != END_BUILTINS; ++i)
@@ -512,49 +508,49 @@  initialize_builtins (void)
 				double_type_node, double_type_node, NULL_TREE);
 
   define_builtin (BUILT_IN_FMOD, "__builtin_fmod",
-		  double_ftype_double_double, "fmod", BUILTIN_CONST);
+		  double_ftype_double_double, "fmod", ECF_CONST);
   define_builtin (BUILT_IN_FMODF, "__builtin_fmodf",
-		  float_ftype_float_float, "fmodf", BUILTIN_CONST);
+		  float_ftype_float_float, "fmodf", ECF_CONST);
 
   define_builtin (BUILT_IN_ACOS, "__builtin_acos",
 		  double_ftype_double, "_ZN4java4lang4Math4acosEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_ASIN, "__builtin_asin",
 		  double_ftype_double, "_ZN4java4lang4Math4asinEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_ATAN, "__builtin_atan",
 		  double_ftype_double, "_ZN4java4lang4Math4atanEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_ATAN2, "__builtin_atan2",
 		  double_ftype_double_double, "_ZN4java4lang4Math5atan2EJddd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_CEIL, "__builtin_ceil",
 		  double_ftype_double, "_ZN4java4lang4Math4ceilEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_COS, "__builtin_cos",
 		  double_ftype_double, "_ZN4java4lang4Math3cosEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_EXP, "__builtin_exp",
 		  double_ftype_double, "_ZN4java4lang4Math3expEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_FLOOR, "__builtin_floor",
 		  double_ftype_double, "_ZN4java4lang4Math5floorEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_LOG, "__builtin_log",
 		  double_ftype_double, "_ZN4java4lang4Math3logEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_POW, "__builtin_pow",
 		  double_ftype_double_double, "_ZN4java4lang4Math3powEJddd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_SIN, "__builtin_sin",
 		  double_ftype_double, "_ZN4java4lang4Math3sinEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_SQRT, "__builtin_sqrt",
 		  double_ftype_double, "_ZN4java4lang4Math4sqrtEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   define_builtin (BUILT_IN_TAN, "__builtin_tan",
 		  double_ftype_double, "_ZN4java4lang4Math3tanEJdd",
-		  BUILTIN_CONST);
+		  ECF_CONST);
   
   boolean_ftype_boolean_boolean
     = build_function_type_list (boolean_type_node,
@@ -563,28 +559,34 @@  initialize_builtins (void)
   define_builtin (BUILT_IN_EXPECT, "__builtin_expect", 
 		  boolean_ftype_boolean_boolean,
 		  "__builtin_expect",
-		  BUILTIN_CONST | BUILTIN_NOTHROW);
+		  ECF_CONST | ECF_NOTHROW);
+  void_ftype
+    = build_function_type (void_type_node, void_list_node);
+  define_builtin (BUILT_IN_UNREACHABLE, "__builtin_unreachable", 
+		  void_ftype,
+		  "__builtin_unreachable",
+		  ECF_CONST | ECF_NOTHROW | ECF_NORETURN | ECF_LEAF);
   define_builtin (BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4, 
 		  "__sync_bool_compare_and_swap_4",
 		  build_function_type_list (boolean_type_node,
 					    int_type_node, 
 					    build_pointer_type (int_type_node),
 					    int_type_node, NULL_TREE), 
-		  "__sync_bool_compare_and_swap_4", 0);
+		  "__sync_bool_compare_and_swap_4", ECF_NOTHROW | ECF_LEAF);
   define_builtin (BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8, 
 		  "__sync_bool_compare_and_swap_8",
 		  build_function_type_list (boolean_type_node,
 					    long_type_node, 
 					    build_pointer_type (long_type_node),
 					    int_type_node, NULL_TREE), 
-		  "__sync_bool_compare_and_swap_8", 0);
+		  "__sync_bool_compare_and_swap_8", ECF_NOTHROW | ECF_LEAF);
   define_builtin (BUILT_IN_SYNC_SYNCHRONIZE, "__sync_synchronize",
 		  build_function_type_list (void_type_node, NULL_TREE),
-		  "__sync_synchronize", BUILTIN_NOTHROW);
+		  "__sync_synchronize", ECF_NOTHROW | ECF_LEAF);
   
   define_builtin (BUILT_IN_RETURN_ADDRESS, "__builtin_return_address",
 		  build_function_type_list (ptr_type_node, int_type_node, NULL_TREE),
-		  "__builtin_return_address", BUILTIN_NOTHROW);
+		  "__builtin_return_address", ECF_NOTHROW | ECF_LEAF);
 
   build_common_builtin_nodes ();
 }
Index: calls.c
===================================================================
--- calls.c	(revision 192483)
+++ calls.c	(working copy)
@@ -802,6 +802,36 @@  call_expr_flags (const_tree t)
   return flags;
 }
 
+/* Modify DECL for given flags.  */
+void
+set_call_expr_flags (tree decl, int flags)
+{
+  if (flags & ECF_NOTHROW)
+    TREE_NOTHROW (decl) = 1;
+  if (flags & ECF_CONST)
+    TREE_READONLY (decl) = 1;
+  if (flags & ECF_PURE)
+    DECL_PURE_P (decl) = 1;
+  if (flags & ECF_NOVOPS)
+    DECL_IS_NOVOPS (decl) = 1;
+  if (flags & ECF_NORETURN)
+    TREE_THIS_VOLATILE (decl) = 1;
+  if (flags & ECF_MALLOC)
+    DECL_IS_MALLOC (decl) = 1;
+  if (flags & ECF_RETURNS_TWICE)
+    DECL_IS_RETURNS_TWICE (decl) = 1;
+  if (flags & ECF_LEAF)
+    DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
+					NULL, DECL_ATTRIBUTES (decl));
+  if (flags & ECF_TM_PURE)
+    DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("transaction_pure"),
+					NULL, DECL_ATTRIBUTES (decl));
+  /* Looping const or pure is imlpies by noreturn.
+     There is currently no way to declare looping const or looping pure alone.  */
+  gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE)
+	      || ((flags & ECF_NORETURN) && (flags & (ECF_CONST | ECF_PURE))));
+}
+
 /* Precompute all register parameters as described by ARGS, storing values
    into fields within the ARGS array.
 
Index: tree.h
===================================================================
--- tree.h	(revision 192483)
+++ tree.h	(working copy)
@@ -6025,6 +6025,7 @@  extern tree build_duplicate_type (tree);
 
 extern int flags_from_decl_or_type (const_tree);
 extern int call_expr_flags (const_tree);
+extern void set_call_expr_flags (tree, int);
 
 /* Call argument flags.  */