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]

3.4 PATCH: Provide target hook for ASM_OUTPUT_EXTERNAL_LIBCALL


This patch is part of a larger set to integrate support for the IRIX 6 O32
ABI

	http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01065.html

but submitting independent parts individually for ease of review.

ASM_OUTPUT_EXTERNAL_LIBCALL is now runtime-variable as well, so I've chosen
to use the new targhooks.[ch] mechanism and introduced a new target
function targetm.asm_out.external_libcall which uses the old macro
definition if not defined directly using TARGET_ASM_EXTERNAL_LIBCALL.  This
is all straightforward, apart from three questions:

* ASM_OUTPUT_EXTERNAL_LIBCALL is only called once in varasm.c with
  asm_out_file as first arg.  Since this is fixed, it might be useful to
  remove the FILE * arg from the target function and always provide it in
  targhooks.c (default_external_libcall)?

* Before the introduction of the target function, varasm.c
  (assemble_external_libcall) didn't do anything if
  ASM_OUTPUT_EXTERNAL_LIBCALL was undefined.  It may set SYMBOL_REF_USED
  (fun) now even for a no-op default_external_libcall.  I'm not sure if
  this could cause problems.

* This new target function still needs to be documented.  How should this
  be done while both ASM_OUTPUT_EXTERNAL_LIBCALL and
  TARGET_ASM_EXTERNAL_LIBCALL exist?  At least the former should be marked
  as deprecated.

Bootstrap/regtest for the current version (together with the whole patch set
above) in progress on mips-sgi-irix6.5.

This is the last part touching non-MIPS files.  I'll delay posting the rest
separately until at least the first round of testresults (mips-sgi-irix6.5
before the patch set vs. mips-sgi-irix6.5 after (for N32/N64) and
mips-sgi-irix6.5o32 before (for O32) are available and analysed.

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Fri Sep 12 00:12:52 2003  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* target.h (struct gcc_target): New member external_libcall.
	* target-def.h (TARGET_ASM_EXTERNAL_LIBCALL): Provide default.
	(TARGET_ASM_OUT): Use it.
	* doc/tm.texi (TARGET_ASM_EXTERNAL_LIBCALL): Document.
	* targhooks.c: Convert to ISO C 90.
	(default_external_libcall): New function.
	* targhooks.h (default_external_libcall): Declare.
	* varasm.c (assemble_external_libcall): Use
	targetm.asm_out.external_libcall instead of
	ASM_OUTPUT_EXTERNAL_LIBCALL.
	* config/mips/mips-protos.h [TARGET_IRIX5 || TARGET_IRIX 6]
	(mips_output_external_libcall): Declare.
	* config/mips/mips.c (mips_output_external_libcall): Change
	definition guard.
	Change to match TARGET_ASM_EXTERNAL_LIBCALL.
	Only operate for O32 ABI.
	* config/mips/iris5.h (TARGET_ASM_EXTERNAL_LIBCALL): Define
	instead of ASM_OUTPUT_EXTERNAL_LIBCALL.
	* config/mips/iris6.h (ASM_OUTPUT_EXTERNAL_LIBCALL): Don't undef,
	superceded by TARGET_ASM_EXTERNAL_LIBCALL.

Index: gcc/target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.55
diff -u -p -b -r1.55 target-def.h
--- gcc/target-def.h	4 Sep 2003 03:17:51 -0000	1.55
+++ gcc/target-def.h	16 Sep 2003 14:00:15 -0000
@@ -166,6 +166,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
 #endif
 
+#ifndef TARGET_ASM_EXTERNAL_LIBCALL
+#define TARGET_ASM_EXTERNAL_LIBCALL default_external_libcall
+#endif
+
 #define TARGET_ASM_ALIGNED_INT_OP				\
 		       {TARGET_ASM_ALIGNED_HI_OP,		\
 			TARGET_ASM_ALIGNED_SI_OP,		\
@@ -202,7 +206,8 @@ Foundation, 59 Temple Place - Suite 330,
                         TARGET_ASM_OUTPUT_MI_THUNK,             \
                         TARGET_ASM_CAN_OUTPUT_MI_THUNK,         \
                         TARGET_ASM_FILE_START,                  \
-                        TARGET_ASM_FILE_END}
+                        TARGET_ASM_FILE_END,			\
+			TARGET_ASM_EXTERNAL_LIBCALL}
 
 /* Scheduler hooks.  All of these default to null pointers, which
    haifa-sched.c looks for and handles.  */
Index: gcc/target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.62
diff -u -p -b -r1.62 target.h
--- gcc/target.h	4 Sep 2003 03:17:51 -0000	1.62
+++ gcc/target.h	16 Sep 2003 14:00:15 -0000
@@ -148,6 +148,8 @@ struct gcc_target
     /* Output any boilerplate text needed at the end of a
        translation unit.  */
     void (*file_end) (void);
+
+    void (*external_libcall) (FILE *, rtx);
   } asm_out;
 
   /* Functions relating to instruction scheduling.  */
Index: gcc/targhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/targhooks.c,v
retrieving revision 2.5
diff -u -p -b -r2.5 targhooks.c
--- gcc/targhooks.c	5 Sep 2003 02:12:29 -0000	2.5
+++ gcc/targhooks.c	16 Sep 2003 14:00:15 -0000
@@ -61,9 +61,17 @@ Software Foundation, 59 Temple Place - S
 #include "tm_p.h"
 #include "target-def.h"
 
+void
+default_external_libcall (FILE *file ATTRIBUTE_UNUSED,
+			  rtx fun ATTRIBUTE_UNUSED)
+{
+#ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
+  ASM_OUTPUT_EXTERNAL_LIBCALL(file, fun);
+#endif
+}
+
 bool
-default_promote_function_args (fntype)
-     tree fntype ATTRIBUTE_UNUSED;
+default_promote_function_args (tree fntype ATTRIBUTE_UNUSED)
 {
 #ifdef PROMOTE_FUNCTION_ARGS
   return true;
@@ -73,8 +81,7 @@ default_promote_function_args (fntype)
 }
 
 bool
-default_promote_function_return (fntype)
-     tree fntype ATTRIBUTE_UNUSED;
+default_promote_function_return (tree fntype ATTRIBUTE_UNUSED)
 {
 #ifdef PROMOTE_FUNCTION_RETURN
   return true;
@@ -84,8 +91,7 @@ default_promote_function_return (fntype)
 }
 
 bool
-default_promote_prototypes (fntype)
-     tree fntype ATTRIBUTE_UNUSED;
+default_promote_prototypes (tree fntype ATTRIBUTE_UNUSED)
 {
   if (PROMOTE_PROTOTYPES)
     return true;
Index: gcc/targhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/targhooks.h,v
retrieving revision 2.1
diff -u -p -b -r2.1 targhooks.h
--- gcc/targhooks.h	4 Sep 2003 03:17:51 -0000	2.1
+++ gcc/targhooks.h	16 Sep 2003 14:00:15 -0000
@@ -18,6 +18,8 @@ along with GCC; see the file COPYING.  I
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+extern void default_external_libcall (FILE *, rtx);
+
 extern bool default_promote_function_args (tree);
 extern bool default_promote_function_return (tree);
 extern bool default_promote_prototypes (tree);
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.383
diff -u -p -b -r1.383 varasm.c
--- gcc/varasm.c	9 Sep 2003 13:37:17 -0000	1.383
+++ gcc/varasm.c	16 Sep 2003 14:00:21 -0000
@@ -1629,16 +1629,14 @@ assemble_external (tree decl ATTRIBUTE_U
 /* Similar, for calling a library function FUN.  */
 
 void
-assemble_external_libcall (rtx fun ATTRIBUTE_UNUSED)
+assemble_external_libcall (rtx fun)
 {
-#ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
   /* Declare library function name external when first used, if nec.  */
   if (! SYMBOL_REF_USED (fun))
     {
       SYMBOL_REF_USED (fun) = 1;
-      ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
+      (*targetm.asm_out.external_libcall) (asm_out_file, fun);
     }
-#endif
 }
 
 /* Assemble a label named NAME.  */
Index: gcc/config/mips/iris5.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5.h,v
retrieving revision 1.21
diff -u -p -r1.21 iris5.h
--- gcc/config/mips/iris5.h	17 Sep 2003 17:40:05 -0000	1.21
+++ gcc/config/mips/iris5.h	17 Sep 2003 19:05:19 -0000
@@ -215,8 +215,8 @@ do {						\
 } while (0)
 
 /* Also do this for libcalls.  */
-#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)	\
-  mips_output_external_libcall (FILE, XSTR (FUN, 0))
+#undef TARGET_ASM_EXTERNAL_LIBCALL
+#define TARGET_ASM_EXTERNAL_LIBCALL mips_output_external_libcall
 
 /* This does for functions what ASM_DECLARE_OBJECT_NAME does for variables.
    This is used indirectly by ASM_OUTPUT_EXTERNAL.  */
Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.67
diff -u -p -r1.67 iris6.h
--- gcc/config/mips/iris6.h	12 Aug 2003 20:50:29 -0000	1.67
+++ gcc/config/mips/iris6.h	17 Sep 2003 19:08:19 -0000
@@ -178,7 +178,6 @@ Boston, MA 02111-1307, USA.  */
 /* IRIX 5 stuff that we don't need for IRIX 6.  */
 /* ??? We do need this for the -mabi=32 switch though.  */
 #undef ASM_OUTPUT_UNDEF_FUNCTION
-#undef ASM_OUTPUT_EXTERNAL_LIBCALL
 #undef ASM_DECLARE_FUNCTION_SIZE
 
 /* Stuff we need for IRIX 6 that isn't in IRIX 5.  */
Index: gcc/config/mips/mips-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips-protos.h,v
retrieving revision 1.49
diff -u -p -r1.49 mips-protos.h
--- gcc/config/mips/mips-protos.h	27 Aug 2003 07:05:17 -0000	1.49
+++ gcc/config/mips/mips-protos.h	17 Sep 2003 19:11:32 -0000
@@ -98,8 +98,8 @@ extern HOST_WIDE_INT mips_debugger_offse
 extern void print_operand (FILE *, rtx, int);
 extern void print_operand_address (FILE *, rtx);
 extern int mips_output_external (FILE *, tree, const char *);
-#ifdef ASM_OUTPUT_UNDEF_FUNCTION
-extern int mips_output_external_libcall (FILE *, const char *);
+#if TARGET_IRIX5 || TARGET_IRIX6
+extern void mips_output_external_libcall (FILE *, rtx);
 #endif
 extern void mips_output_filename (FILE *, const char *);
 extern void mips_output_lineno (FILE *, int);
Index: gcc/config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.309
diff -u -p -r1.309 mips.c
--- gcc/config/mips/mips.c	4 Sep 2003 09:55:30 -0000	1.309
+++ gcc/config/mips/mips.c	17 Sep 2003 19:17:14 -0000
@@ -5517,19 +5517,20 @@ mips_output_external (FILE *file ATTRIBU
   return 0;
 }
 
-#ifdef ASM_OUTPUT_UNDEF_FUNCTION
-int
-mips_output_external_libcall (FILE *file ATTRIBUTE_UNUSED, const char *name)
+#if TARGET_IRIX5 || TARGET_IRIX6
+void
+mips_output_external_libcall (FILE *file ATTRIBUTE_UNUSED, rtx fun)
 {
   register struct extern_list *p;
 
-  p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list));
-  p->next = extern_head;
-  p->name = name;
-  p->size = -1;
-  extern_head = p;
-
-  return 0;
+  if (mips_abi == ABI_32)
+    {
+      p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list));
+      p->next = extern_head;
+      p->name = XSTR (fun, 0);
+      p->size = -1;
+      extern_head = p;
+    }
 }
 #endif
 


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