Patchwork make Ada runtime function building use build_function_type_list

login
register
mail settings
Submitter Nathan Froyd
Date April 20, 2011, 5:08 p.m.
Message ID <20110420170821.GO23480@codesourcery.com>
Download mbox | patch
Permalink /patch/92249/
State New
Headers show

Comments

Nathan Froyd - April 20, 2011, 5:08 p.m.
This patch changes most of the uses of build_function_type in the Ada to
use build_function_type_list.  There are a handful of
build_function_type calls left; replacing those will have to wait until
we get a build_function_type_{n,vec} interface.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

	* gcc-interface/trans.c (gigi): Call build_function_type_list
	instead of build_function_type.  Adjust calls to...
	(build_raise_check): ...this.  Do not take a void_tree parameter.
	Call build_function_type_list instead of build_function_type.
Nathan Froyd - April 27, 2011, 12:47 p.m.
On Wed, Apr 20, 2011 at 10:08:21AM -0700, Nathan Froyd wrote:
> This patch changes most of the uses of build_function_type in the Ada to
> use build_function_type_list.  There are a handful of
> build_function_type calls left; replacing those will have to wait until
> we get a build_function_type_{n,vec} interface.
> 
> Tested on x86_64-unknown-linux-gnu.  OK to commit?

Ping.  http://gcc.gnu.org/ml/gcc-patches/2011-04/msg01675.html

-Nathan

Patch

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 378f88c..05e2842 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -214,7 +214,7 @@  static void set_expr_location_from_node (tree, Node_Id);
 static bool set_end_locus_from_node (tree, Node_Id);
 static void set_gnu_expr_location_from_node (tree, Node_Id);
 static int lvalue_required_p (Node_Id, tree, bool, bool, bool);
-static tree build_raise_check (int, tree, enum exception_info_kind);
+static tree build_raise_check (int, enum exception_info_kind);
 
 /* Hooks for debug info back-ends, only supported and used in a restricted set
    of configurations.  */
@@ -236,7 +236,7 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
       Entity_Id standard_exception_type, Int gigi_operating_mode)
 {
   Entity_Id gnat_literal;
-  tree long_long_float_type, exception_type, t;
+  tree long_long_float_type, exception_type, t, ftype;
   tree int64_type = gnat_type_for_size (64, 0);
   struct elab_info *info;
   int i;
@@ -344,47 +344,39 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
   DECL_IGNORED_P (t) = 1;
   save_gnu_tree (gnat_literal, t, false);
 
-  void_ftype = build_function_type (void_type_node, NULL_TREE);
+  void_ftype = build_function_type_list (void_type_node, NULL_TREE);
   ptr_void_ftype = build_pointer_type (void_ftype);
 
   /* Now declare run-time functions.  */
-  t = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
 
+  ftype = build_function_type_list (ptr_void_type_node, sizetype, NULL_TREE);
   /* malloc is a function declaration tree for a function to allocate
      memory.  */
   malloc_decl
     = create_subprog_decl (get_identifier ("__gnat_malloc"), NULL_TREE,
-			   build_function_type (ptr_void_type_node,
-						tree_cons (NULL_TREE,
-							   sizetype, t)),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IS_MALLOC (malloc_decl) = 1;
 
   /* malloc32 is a function declaration tree for a function to allocate
      32-bit memory on a 64-bit system.  Needed only on 64-bit VMS.  */
   malloc32_decl
     = create_subprog_decl (get_identifier ("__gnat_malloc32"), NULL_TREE,
-			   build_function_type (ptr_void_type_node,
-						tree_cons (NULL_TREE,
-							   sizetype, t)),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IS_MALLOC (malloc32_decl) = 1;
 
   /* free is a function declaration tree for a function to free memory.  */
+  ftype = build_function_type_list (void_type_node,
+				    ptr_void_type_node, NULL_TREE);
   free_decl
     = create_subprog_decl (get_identifier ("__gnat_free"), NULL_TREE,
-			   build_function_type (void_type_node,
-						tree_cons (NULL_TREE,
-							   ptr_void_type_node,
-							   t)),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
 
   /* This is used for 64-bit multiplication with overflow checking.  */
+  ftype = build_function_type_list (int64_type,
+				    int64_type, int64_type, NULL_TREE);
   mulv64_decl
     = create_subprog_decl (get_identifier ("__gnat_mulv64"), NULL_TREE,
-			   build_function_type_list (int64_type, int64_type,
-						     int64_type, NULL_TREE),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
 
   /* Name of the _Parent field in tagged record types.  */
   parent_name_id = get_identifier (Get_Name_String (Name_uParent));
@@ -401,61 +393,54 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
   jmpbuf_ptr_type = build_pointer_type (jmpbuf_type);
 
   /* Functions to get and set the jumpbuf pointer for the current thread.  */
+  ftype = build_function_type_list (jmpbuf_ptr_type, NULL_TREE);
   get_jmpbuf_decl
     = create_subprog_decl
     (get_identifier ("system__soft_links__get_jmpbuf_address_soft"),
-     NULL_TREE, build_function_type (jmpbuf_ptr_type, NULL_TREE),
-     NULL_TREE, false, true, true, NULL, Empty);
+     NULL_TREE, ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IGNORED_P (get_jmpbuf_decl) = 1;
 
+  ftype = build_function_type_list (void_type_node,
+				    jmpbuf_ptr_type, NULL_TREE);
   set_jmpbuf_decl
     = create_subprog_decl
     (get_identifier ("system__soft_links__set_jmpbuf_address_soft"),
-     NULL_TREE,
-     build_function_type (void_type_node,
-			  tree_cons (NULL_TREE, jmpbuf_ptr_type, t)),
-     NULL_TREE, false, true, true, NULL, Empty);
+     NULL_TREE, ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IGNORED_P (set_jmpbuf_decl) = 1;
 
   /* setjmp returns an integer and has one operand, which is a pointer to
      a jmpbuf.  */
+  ftype = build_function_type_list (integer_type_node,
+				    jmpbuf_ptr_type, NULL_TREE);
   setjmp_decl
     = create_subprog_decl
       (get_identifier ("__builtin_setjmp"), NULL_TREE,
-       build_function_type (integer_type_node,
-			    tree_cons (NULL_TREE,  jmpbuf_ptr_type, t)),
-       NULL_TREE, false, true, true, NULL, Empty);
+       ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_BUILT_IN_CLASS (setjmp_decl) = BUILT_IN_NORMAL;
   DECL_FUNCTION_CODE (setjmp_decl) = BUILT_IN_SETJMP;
 
   /* update_setjmp_buf updates a setjmp buffer from the current stack pointer
      address.  */
+  ftype = build_function_type_list (void_type_node,
+				    jmpbuf_ptr_type, NULL_TREE);
   update_setjmp_buf_decl
     = create_subprog_decl
       (get_identifier ("__builtin_update_setjmp_buf"), NULL_TREE,
-       build_function_type (void_type_node,
-			    tree_cons (NULL_TREE,  jmpbuf_ptr_type, t)),
-       NULL_TREE, false, true, true, NULL, Empty);
+       ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_BUILT_IN_CLASS (update_setjmp_buf_decl) = BUILT_IN_NORMAL;
   DECL_FUNCTION_CODE (update_setjmp_buf_decl) = BUILT_IN_UPDATE_SETJMP_BUF;
 
   /* Hooks to call when entering/leaving an exception handler.  */
+  ftype = build_function_type_list (void_type_node,
+				    ptr_void_type_node, NULL_TREE);
   begin_handler_decl
     = create_subprog_decl (get_identifier ("__gnat_begin_handler"), NULL_TREE,
-			   build_function_type (void_type_node,
-						tree_cons (NULL_TREE,
-							   ptr_void_type_node,
-							   t)),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IGNORED_P (begin_handler_decl) = 1;
 
   end_handler_decl
     = create_subprog_decl (get_identifier ("__gnat_end_handler"), NULL_TREE,
-			   build_function_type (void_type_node,
-						tree_cons (NULL_TREE,
-							   ptr_void_type_node,
-							   t)),
-			   NULL_TREE, false, true, true, NULL, Empty);
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
   DECL_IGNORED_P (end_handler_decl) = 1;
 
   /* If in no exception handlers mode, all raise statements are redirected to
@@ -466,13 +451,10 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
       tree decl
 	= create_subprog_decl
 	  (get_identifier ("__gnat_last_chance_handler"), NULL_TREE,
-	   build_function_type (void_type_node,
-				tree_cons (NULL_TREE,
-					   build_pointer_type
-					   (unsigned_char_type_node),
-					   tree_cons (NULL_TREE,
-						      integer_type_node,
-						      t))),
+	   build_function_type_list (void_type_node,
+				     build_pointer_type
+				     (unsigned_char_type_node),
+				     integer_type_node, NULL_TREE),
 	   NULL_TREE, false, true, true, NULL, Empty);
       TREE_THIS_VOLATILE (decl) = 1;
       TREE_SIDE_EFFECTS (decl) = 1;
@@ -485,10 +467,10 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
     {
       /* Otherwise, make one decl for each exception reason.  */
       for (i = 0; i < (int) ARRAY_SIZE (gnat_raise_decls); i++)
-	gnat_raise_decls[i] = build_raise_check (i, t, exception_simple);
+	gnat_raise_decls[i] = build_raise_check (i, exception_simple);
       for (i = 0; i < (int) ARRAY_SIZE (gnat_raise_decls_ext); i++)
 	gnat_raise_decls_ext[i]
-	  = build_raise_check (i, t,
+	  = build_raise_check (i,
 			       i == CE_Index_Check_Failed
 			       || i == CE_Range_Check_Failed
 			       || i == CE_Invalid_Data
@@ -501,21 +483,20 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
   except_type_node = TREE_TYPE (exception_type);
 
   /* Make other functions used for exception processing.  */
+  ftype = build_function_type_list (build_pointer_type (except_type_node),
+				    NULL_TREE);
   get_excptr_decl
     = create_subprog_decl
     (get_identifier ("system__soft_links__get_gnat_exception"),
-     NULL_TREE,
-     build_function_type (build_pointer_type (except_type_node), NULL_TREE),
-     NULL_TREE, false, true, true, NULL, Empty);
+     NULL_TREE, ftype, NULL_TREE, false, true, true, NULL, Empty);
 
+  ftype = build_function_type_list (void_type_node,
+				    build_pointer_type (except_type_node),
+				    NULL_TREE);
   raise_nodefer_decl
     = create_subprog_decl
       (get_identifier ("__gnat_raise_nodefer_with_msg"), NULL_TREE,
-       build_function_type (void_type_node,
-			    tree_cons (NULL_TREE,
-				       build_pointer_type (except_type_node),
-				       t)),
-       NULL_TREE, false, true, true, NULL, Empty);
+       ftype, NULL_TREE, false, true, true, NULL, Empty);
 
   /* Indicate that these never return.  */
   TREE_THIS_VOLATILE (raise_nodefer_decl) = 1;
@@ -642,45 +623,35 @@  gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
    true).  */
 
 static tree
-build_raise_check (int check, tree void_tree, enum exception_info_kind kind)
+build_raise_check (int check, enum exception_info_kind kind)
 {
   char name[21];
-  tree result;
+  tree result, ftype;
 
   if (kind != exception_simple)
     {
+      tree t;
       sprintf (name, "__gnat_rcheck_%.2d_ext", check);
-      result
-	= create_subprog_decl
-	  (get_identifier (name), NULL_TREE,
-	   build_function_type
-	   (void_type_node,
-	    tree_cons
-	    (NULL_TREE, build_pointer_type (unsigned_char_type_node),
-	     tree_cons (NULL_TREE, integer_type_node,
-			tree_cons (NULL_TREE, integer_type_node,
-				   kind == exception_column
-				   ? void_tree
-				   : tree_cons (NULL_TREE, integer_type_node,
-						tree_cons (NULL_TREE,
-							   integer_type_node,
-							   void_tree)))))),
-	   NULL_TREE, false, true, true, NULL, Empty);
+      t = (kind == exception_column ? NULL_TREE : integer_type_node);
+      ftype
+	= build_function_type_list (void_type_node,
+				    build_pointer_type
+				    (unsigned_char_type_node),
+				    integer_type_node, t, t, NULL_TREE);
     }
   else
     {
       sprintf (name, "__gnat_rcheck_%.2d", check);
-      result
-	= create_subprog_decl
-	  (get_identifier (name), NULL_TREE,
-	   build_function_type
-	   (void_type_node,
-	    tree_cons
-	    (NULL_TREE, build_pointer_type (unsigned_char_type_node),
-	     tree_cons (NULL_TREE, integer_type_node, void_tree))),
-	   NULL_TREE, false, true, true, NULL, Empty);
+      ftype
+	= build_function_type_list (void_type_node,
+				    build_pointer_type
+				    (unsigned_char_type_node),
+				    integer_type_node, NULL_TREE);
     }
 
+  result
+    = create_subprog_decl (get_identifier (name), NULL_TREE,
+			   ftype, NULL_TREE, false, true, true, NULL, Empty);
   TREE_THIS_VOLATILE (result) = 1;
   TREE_SIDE_EFFECTS (result) = 1;
   TREE_TYPE (result)