This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: PATCH c++/19044


On Dec 18, 2004, at 5:46 PM, Richard Henderson wrote:

On Sat, Dec 18, 2004 at 10:32:17AM -0800, Matt Austern wrote:
! if (TREE_CODE (decl) == FUNCTION_DECL
! && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
! {
! tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
! set_user_assembler_name (builtin, asmspec);
! }
! set_user_assembler_name (decl, asmspec);

Actually, Matt, you've missed a bit from the C front end --


           if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
             init_block_move_fn (asmspec);
           else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
             init_block_clear_fn (asmspec);

You might do well to just move this entire block to a new function
in c-common.c.

Yep, I think that makes sense. Here's version 2 of my patch. Again, bootstrapped and tested on powerpc-apple-darwin. OK to commit to mainline?


--Matt

* c-common.c (set_builtin_user_assembler_name): New.
* c-common.h (set_builtin_user_assembler_name): Declare.
* c-decl.c (finish_decl): Use set_builtin_user_assembler_name

* decl.c (make_rtl_for_nonlocal_decl): Use set_builtin_user_assembler_name

* g++.dg/ext/builtin6.C: New



Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.594
diff -p -r1.594 c-common.c
*** gcc/c-common.c	13 Dec 2004 17:14:56 -0000	1.594
--- gcc/c-common.c	20 Dec 2004 16:35:42 -0000
*************** c_common_nodes_and_builtins (void)
*** 3223,3228 ****
--- 3223,3244 ----
    main_identifier_node = get_identifier ("main");
  }

+ void
+ set_builtin_user_assembler_name (tree decl, const char *asmspec)
+ {
+   tree builtin;
+   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
+ 	      && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+ 	      && asmspec != 0);
+
+   builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
+   set_user_assembler_name (builtin, asmspec);
+   if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
+     init_block_move_fn (asmspec);
+   else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
+     init_block_clear_fn (asmspec);
+ }
+
  tree
  build_va_arg (tree expr, tree type)
  {
Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.272
diff -p -r1.272 c-common.h
*** gcc/c-common.h	25 Nov 2004 17:11:23 -0000	1.272
--- gcc/c-common.h	20 Dec 2004 16:35:43 -0000
*************** extern tree c_build_qualified_type (tree
*** 674,679 ****
--- 674,681 ----
     frontends.  */
  extern void c_common_nodes_and_builtins (void);

+ extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
+
extern void disable_builtin_function (const char *);


  extern tree build_va_arg (tree, tree);
Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.616
diff -p -r1.616 c-decl.c
*** gcc/c-decl.c	19 Dec 2004 04:42:08 -0000	1.616
--- gcc/c-decl.c	20 Dec 2004 16:35:45 -0000
*************** finish_decl (tree decl, tree init, tree
*** 3233,3246 ****
    if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
      {
        if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
! 	{
! 	  tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
! 	  set_user_assembler_name (builtin, asmspec);
! 	   if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
! 	     init_block_move_fn (asmspec);
! 	   else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
! 	     init_block_clear_fn (asmspec);
! 	 }
        set_user_assembler_name (decl, asmspec);
      }

--- 3233,3239 ----
    if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
      {
        if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
! 	set_builtin_user_assembler_name (decl, asmspec);
        set_user_assembler_name (decl, asmspec);
      }

Index: gcc/cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1342
diff -p -r1.1342 decl.c
*** gcc/cp/decl.c	16 Dec 2004 11:03:21 -0000	1.1342
--- gcc/cp/decl.c	20 Dec 2004 16:35:49 -0000
*************** make_rtl_for_nonlocal_decl (tree decl, t
*** 4644,4650 ****
  	  DECL_HARD_REGISTER (decl) = 1;
  	}
        else
! 	set_user_assembler_name (decl, asmspec);
      }

    /* Handle non-variables up front.  */
--- 4644,4655 ----
  	  DECL_HARD_REGISTER (decl) = 1;
  	}
        else
! 	{
! 	  if (TREE_CODE (decl) == FUNCTION_DECL
! 	      && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
! 	    set_builtin_user_assembler_name (decl, asmspec);
! 	  set_user_assembler_name (decl, asmspec);
! 	}
      }

    /* Handle non-variables up front.  */
Index: gcc/testsuite/g++.dg/ext/builtin6.C
===================================================================
RCS file: gcc/testsuite/g++.dg/ext/builtin6.C
diff -N gcc/testsuite/g++.dg/ext/builtin6.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/ext/builtin6.C	20 Dec 2004 16:35:51 -0000
***************
*** 0 ****
--- 1,11 ----
+ // PR c++/19044
+ // Verify that alternate asm name for builtin named "foo" also gets
+ // applied to its sibling "__builtin_foo".
+
+ // { dg-do compile }
+ // { dg-final { scan-assembler "fancy_sin" } }
+
+ extern "C" double sin(double) __asm("_fancy_sin");
+
+ double foo(double x) { return __builtin_sin(x); }
+


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