This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran,Ada,LTO] FE support for leaf builtins


Hi,
this patch adds neccesary frontend bits so bulitins can be declared with the newly introduced
leaf attribute.

Bootstrapped/regtested x86_64-linux, OK?

	* gcc-interface/utils.c (handle_leaf_attribute): New function.
	(gnat_internal_attribute_tables): Add leaf.

	* lto-lang.c (handle_leaf_attribute): New function.
	(lto_attribute_tables): Add leaf.

	* f95-lang.c (gfc_define_builtin): Make leaf.
	(gfc_init_builtin_functions): Handle only ATTR_CONST_NOTHROW_LEAF_LIST
	and ATTR_NOTHROW_LEAF_LIST.
	(DEF_SYNC_BUILTIN): Check ATTR_CONST_NOTHROW_LEAF_LIST.
	(DEF_GOMP_BUILTIN): Likewise.
Index: ada/gcc-interface/utils.c
===================================================================
*** ada/gcc-interface/utils.c	(revision 164606)
--- ada/gcc-interface/utils.c	(working copy)
*************** static tree handle_novops_attribute (tre
*** 87,92 ****
--- 87,93 ----
  static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
  static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
  static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
+ static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
  static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
  static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
  static tree handle_vector_size_attribute (tree *, tree, tree, int, bool *);
*************** const struct attribute_spec gnat_interna
*** 108,113 ****
--- 109,115 ----
    { "nonnull",      0, -1, false, true,  true,  handle_nonnull_attribute },
    { "sentinel",     0, 1,  false, true,  true,  handle_sentinel_attribute },
    { "noreturn",     0, 0,  true,  false, false, handle_noreturn_attribute },
+   { "leaf",         0, 0,  true,  false, false, handle_leaf_attribute },
    { "malloc",       0, 0,  true,  false, false, handle_malloc_attribute },
    { "type generic", 0, 0,  false, true, true, handle_type_generic_attribute },
  
*************** handle_noreturn_attribute (tree *node, t
*** 5181,5186 ****
--- 5183,5210 ----
        *no_add_attrs = true;
      }
  
+   return NULL_TREE;
+ }
+ 
+ /* Handle a "leaf" attribute; arguments as in
+    struct attribute_spec.handler.  */
+ 
+ static tree
+ handle_leaf_attribute (tree *node, tree name,
+ 		       tree ARG_UNUSED (args),
+ 		       int ARG_UNUSED (flags), bool *no_add_attrs)
+ {
+   if (TREE_CODE (*node) != FUNCTION_DECL)
+     {
+       warning (OPT_Wattributes, "%qE attribute ignored", name);
+       *no_add_attrs = true;
+     }
+   if (!TREE_PUBLIC (*node))
+     {
+       warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
+       *no_add_attrs = true;
+     }
+ 
    return NULL_TREE;
  }
  
Index: fortran/f95-lang.c
===================================================================
*** fortran/f95-lang.c	(revision 164606)
--- fortran/f95-lang.c	(working copy)
*************** gfc_define_builtin (const char *name,
*** 638,643 ****
--- 638,645 ----
    if (const_p)
      TREE_READONLY (decl) = 1;
    TREE_NOTHROW (decl) = 1;
+   DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
+ 				      NULL, DECL_ATTRIBUTES (decl));
  
    built_in_decls[code] = decl;
    implicit_built_in_decls[code] = decl;
*************** gfc_init_builtin_functions (void)
*** 728,735 ****
    enum
    {
      /* So far we need just these 2 attribute types.  */
!     ATTR_NOTHROW_LIST,
!     ATTR_CONST_NOTHROW_LIST
    };
  
    tree mfunc_float[6];
--- 730,737 ----
    enum
    {
      /* So far we need just these 2 attribute types.  */
!     ATTR_NOTHROW_LEAF_LIST,
!     ATTR_CONST_NOTHROW_LEAF_LIST
    };
  
    tree mfunc_float[6];
*************** gfc_init_builtin_functions (void)
*** 1083,1089 ****
  #undef DEF_SYNC_BUILTIN
  #define DEF_SYNC_BUILTIN(code, name, type, attr) \
      gfc_define_builtin (name, builtin_types[type], code, name, \
! 			attr == ATTR_CONST_NOTHROW_LIST);
  #include "../sync-builtins.def"
  #undef DEF_SYNC_BUILTIN
  
--- 1085,1091 ----
  #undef DEF_SYNC_BUILTIN
  #define DEF_SYNC_BUILTIN(code, name, type, attr) \
      gfc_define_builtin (name, builtin_types[type], code, name, \
! 			attr == ATTR_CONST_NOTHROW_LEAF_LIST);
  #include "../sync-builtins.def"
  #undef DEF_SYNC_BUILTIN
  
*************** gfc_init_builtin_functions (void)
*** 1092,1098 ****
  #undef DEF_GOMP_BUILTIN
  #define DEF_GOMP_BUILTIN(code, name, type, attr) \
        gfc_define_builtin ("__builtin_" name, builtin_types[type], \
! 			  code, name, attr == ATTR_CONST_NOTHROW_LIST);
  #include "../omp-builtins.def"
  #undef DEF_GOMP_BUILTIN
      }
--- 1094,1100 ----
  #undef DEF_GOMP_BUILTIN
  #define DEF_GOMP_BUILTIN(code, name, type, attr) \
        gfc_define_builtin ("__builtin_" name, builtin_types[type], \
! 			  code, name, attr == ATTR_CONST_NOTHROW_LEAF_LIST);
  #include "../omp-builtins.def"
  #undef DEF_GOMP_BUILTIN
      }
Index: lto/lto-lang.c
===================================================================
*** lto/lto-lang.c	(revision 164606)
--- lto/lto-lang.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 36,41 ****
--- 36,42 ----
  #include "toplev.h"
  
  static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
+ static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
  static tree handle_const_attribute (tree *, tree, tree, int, bool *);
  static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
  static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
*************** const struct attribute_spec lto_attribut
*** 53,58 ****
--- 54,61 ----
    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
    { "noreturn",               0, 0, true,  false, false,
  			      handle_noreturn_attribute },
+   { "leaf",		      0, 0, true,  false, false,
+ 			      handle_leaf_attribute },
    /* The same comments as for noreturn attributes apply to const ones.  */
    { "const",                  0, 0, true,  false, false,
  			      handle_const_attribute },
*************** handle_noreturn_attribute (tree *node, t
*** 184,189 ****
--- 187,213 ----
    return NULL_TREE;
  }
  
+ /* Handle a "leaf" attribute; arguments as in
+    struct attribute_spec.handler.  */
+ 
+ static tree
+ handle_leaf_attribute (tree *node, tree name,
+ 		       tree ARG_UNUSED (args),
+ 		       int ARG_UNUSED (flags), bool *no_add_attrs)
+ {
+   if (TREE_CODE (*node) != FUNCTION_DECL)
+     {
+       warning (OPT_Wattributes, "%qE attribute ignored", name);
+       *no_add_attrs = true;
+     }
+   if (!TREE_PUBLIC (*node))
+     {
+       warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
+       *no_add_attrs = true;
+     }
+ 
+   return NULL_TREE;
+ }
  
  /* Handle a "const" attribute; arguments as in
     struct attribute_spec.handler.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]