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]

[patch] Rename and Document IA64 unwinding hooks


The patch below renames the IA64 target unwinding hooks to a target-neutral 
name, and documents them. I'm planning on using these to generate ARM EABI 
unwinding tables.

Bootstrapped and tested on ia64-hp-hpux11.22 and cross to arm-none-elf.
Ok?

Paul

2004-07-15  Paul Brook  <paul@codesourcery.com>

	* dwarf2out.c (dwarf2out_begin_prologue): Rename IA64_UNWIND_INFO
	to TARGET_UNWIND_INFO.
	* except.c (output_function_exception_table): Ditto.
	* except.h: Ditto.
	* opts.c (decode_options): Ditto.
	* passes.c (rest_of_handle_final): Ditto.
	* final.c (final_start_function): Ditto.
	(final_scan_insn, final_scan_insn): Replace IA64_UNWIND_EMIT with
	target hook.
	* output.h (default_unwind_emit): Declare.
	* varasm.c (default_unwind_emit): New function.
	* target-def.h: Define and use TARGET_UNWIND_EMIT.
	* target.h (struct gcc_target): Add unwind_emit.
	* config/ia64/ia64.c (TARGET_UNWIND_EMIT): Define.
	* config/ia64/ia64.h: Rename IA64_UNWIND_INFO to TARGET_UNWIND_INFO.
	Remove IA64_UNWIND_EMIT.
	* doc/tm.texi: Document TARGET_UNWIND_EMIT and TARGET_UNWIND_INFO.

Index: gcc/dwarf2out.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/dwarf2out.c,v
retrieving revision 1.533
diff -u -p -r1.533 dwarf2out.c
--- gcc/dwarf2out.c	9 Jul 2004 03:29:27 -0000	1.533
+++ gcc/dwarf2out.c	14 Jul 2004 16:14:18 -0000
@@ -2360,7 +2360,7 @@ dwarf2out_begin_prologue (unsigned int l
 
   current_function_func_begin_label = 0;
 
-#ifdef IA64_UNWIND_INFO
+#ifdef TARGET_UNWIND_INFO
   /* ??? current_function_func_begin_label is also used by except.c
      for call-site information.  We must emit this label if it might
      be used.  */
@@ -2379,7 +2379,7 @@ dwarf2out_begin_prologue (unsigned int l
 			  current_function_funcdef_no);
   current_function_func_begin_label = get_identifier (label);
 
-#ifdef IA64_UNWIND_INFO
+#ifdef TARGET_UNWIND_INFO
   /* We can elide the fde allocation if we're not emitting debug info.  */
   if (! dwarf2out_do_frame ())
     return;
Index: gcc/except.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/except.c,v
retrieving revision 1.279
diff -u -p -r1.279 except.c
--- gcc/except.c	9 Jul 2004 03:29:31 -0000	1.279
+++ gcc/except.c	14 Jul 2004 16:14:18 -0000
@@ -3598,7 +3598,8 @@ output_function_exception_table (void)
   if (! cfun->uses_eh_lsda)
     return;
 
-#ifdef IA64_UNWIND_INFO
+#ifdef TARGET_UNWIND_INFO
+  /* TODO: Move this into target file.  */
   fputs ("\t.personality\t", asm_out_file);
   output_addr_const (asm_out_file, eh_personality_libfunc);
   fputs ("\n\t.handlerdata\n", asm_out_file);
Index: gcc/except.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/except.h,v
retrieving revision 1.78
diff -u -p -r1.78 except.h
--- gcc/except.h	8 Jul 2004 07:45:35 -0000	1.78
+++ gcc/except.h	14 Jul 2004 16:14:18 -0000
@@ -130,7 +130,7 @@ extern tree (*lang_eh_runtime_type) (tre
 
 #ifndef MUST_USE_SJLJ_EXCEPTIONS
 # if !(defined (EH_RETURN_DATA_REGNO)			\
-       && (defined (IA64_UNWIND_INFO)			\
+       && (defined (TARGET_UNWIND_INFO)			\
 	   || (DWARF2_UNWIND_INFO			\
 	       && (defined (EH_RETURN_HANDLER_RTX)	\
 		   || defined (HAVE_eh_return)))))
@@ -152,8 +152,8 @@ extern tree (*lang_eh_runtime_type) (tre
 #  if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
     #error "EH_RETURN_HANDLER_RTX or eh_return required"
 #  endif
-#  if !defined(DWARF2_UNWIND_INFO) && !defined(IA64_UNWIND_INFO)
-    #error "{DWARF2,IA64}_UNWIND_INFO required"
+#  if !defined(DWARF2_UNWIND_INFO) && !defined(TARGET_UNWIND_INFO)
+    #error "{DWARF2,TARGET}_UNWIND_INFO required"
 #  endif
 # endif
 #else
Index: gcc/final.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/final.c,v
retrieving revision 1.320
diff -u -p -r1.320 final.c
--- gcc/final.c	9 Jul 2004 03:29:31 -0000	1.320
+++ gcc/final.c	14 Jul 2004 16:14:18 -0000
@@ -1347,7 +1347,7 @@ final_start_function (rtx first ATTRIBUT
 
   (*debug_hooks->begin_prologue) (last_linenum, last_filename);
 
-#if defined (DWARF2_UNWIND_INFO) || defined (IA64_UNWIND_INFO)
+#if defined (DWARF2_UNWIND_INFO) || defined (TARGET_UNWIND_INFO)
   if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG)
     dwarf2out_begin_prologue (0, NULL);
 #endif
@@ -1732,9 +1732,10 @@ final_scan_insn (rtx insn, FILE *file, i
 	      && !scan_ahead_for_unlikely_executed_note (insn))
 	    text_section ();
 
-#ifdef IA64_UNWIND_INFO
-	  IA64_UNWIND_EMIT (asm_out_file, insn);
+#ifdef TARGET_UNWIND_INFO
+	  targetm.asm_out.unwind_emit (asm_out_file, insn);
 #endif
+
 	  if (flag_debug_asm)
 	    fprintf (asm_out_file, "\t%s basic block %d\n",
 		     ASM_COMMENT_START, NOTE_BASIC_BLOCK (insn)->index);
@@ -2525,11 +2526,14 @@ final_scan_insn (rtx insn, FILE *file, i
 	if (prescan > 0)
 	  break;
 
-#ifdef IA64_UNWIND_INFO
-	IA64_UNWIND_EMIT (asm_out_file, insn);
+#ifdef TARGET_UNWIND_INFO
+	/* ??? This will put the directives in the wrong place if
+	   get_insn_template outputs assembly directly.  However calling it
+	   before get_insn_template breaks if the insns is split.  */
+	targetm.asm_out.unwind_emit (asm_out_file, insn);
 #endif
-	/* Output assembler code from the template.  */
 
+	/* Output assembler code from the template.  */
 	output_asm_insn (template, recog_data.operand);
 
 	/* If necessary, report the effect that the instruction has on
Index: gcc/opts.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/opts.c,v
retrieving revision 1.73
diff -u -p -r1.73 opts.c
--- gcc/opts.c	8 Jul 2004 19:49:08 -0000	1.73
+++ gcc/opts.c	14 Jul 2004 16:14:18 -0000
@@ -578,10 +578,10 @@ decode_options (unsigned int argc, const
   target_flags = 0;
   set_target_switch ("");
 
-  /* Unwind tables are always present in an ABI-conformant IA-64
-     object file, so the default should be ON.  */
-#ifdef IA64_UNWIND_INFO
-  flag_unwind_tables = IA64_UNWIND_INFO;
+  /* Unwind tables are always present when a target has ABI-specified unwind
+     tables, so the default should be ON.  */
+#ifdef TARGET_UNWIND_INFO
+  flag_unwind_tables = TARGET_UNWIND_INFO;
 #endif
 
 #ifdef OPTIMIZATION_OPTIONS
Index: gcc/output.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/output.h,v
retrieving revision 1.142
diff -u -p -r1.142 output.h
--- gcc/output.h	8 Jul 2004 07:41:59 -0000	1.142
+++ gcc/output.h	14 Jul 2004 16:14:18 -0000
@@ -511,6 +511,7 @@ extern bool default_binds_local_p (tree)
 extern bool default_binds_local_p_1 (tree, int);
 extern void default_globalize_label (FILE *, const char *);
 extern void default_emit_unwind_label (FILE *, tree, int, int);
+extern void default_unwind_emit (FILE *, rtx);
 extern void default_internal_label (FILE *, const char *, unsigned long);
 extern void default_file_start (void);
 extern void file_end_indicate_exec_stack (void);
Index: gcc/passes.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/passes.c,v
retrieving revision 2.29
diff -u -p -r2.29 passes.c
--- gcc/passes.c	8 Jul 2004 07:41:59 -0000	2.29
+++ gcc/passes.c	14 Jul 2004 16:14:18 -0000
@@ -450,7 +450,7 @@ rest_of_handle_final (void)
     final (get_insns (), asm_out_file, optimize, 0);
     final_end_function ();
 
-#ifdef IA64_UNWIND_INFO
+#ifdef TARGET_UNWIND_INFO
     /* ??? The IA-64 ".handlerdata" directive must be issued before
        the ".endp" directive that closes the procedure descriptor.  */
     output_function_exception_table ();
@@ -458,7 +458,7 @@ rest_of_handle_final (void)
 
     assemble_end_function (current_function_decl, fnname);
 
-#ifndef IA64_UNWIND_INFO
+#ifndef TARGET_UNWIND_INFO
     /* Otherwise, it feels unclean to switch sections in the middle.  */
     output_function_exception_table ();
 #endif
Index: gcc/target-def.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target-def.h,v
retrieving revision 1.85
diff -u -p -r1.85 target-def.h
--- gcc/target-def.h	9 Jul 2004 22:42:37 -0000	1.85
+++ gcc/target-def.h	14 Jul 2004 16:14:18 -0000
@@ -62,6 +62,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_ASM_EMIT_UNWIND_LABEL default_emit_unwind_label
 #endif
 
+#ifndef TARGET_UNWIND_EMIT
+#define TARGET_UNWIND_EMIT default_unwind_emit
+#endif
+
 #ifndef TARGET_ASM_INTERNAL_LABEL
 #define TARGET_ASM_INTERNAL_LABEL default_internal_label
 #endif
@@ -195,6 +199,7 @@ Foundation, 59 Temple Place - Suite 330,
 			TARGET_ASM_INTEGER,			\
 			TARGET_ASM_GLOBALIZE_LABEL,		\
                         TARGET_ASM_EMIT_UNWIND_LABEL,           \
+			TARGET_UNWIND_EMIT,			\
 			TARGET_ASM_INTERNAL_LABEL,		\
 			TARGET_ASM_ASSEMBLE_VISIBILITY,		\
 			TARGET_ASM_FUNCTION_PROLOGUE,		\
Index: gcc/target.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target.h,v
retrieving revision 1.98
diff -u -p -r1.98 target.h
--- gcc/target.h	9 Jul 2004 22:42:37 -0000	1.98
+++ gcc/target.h	14 Jul 2004 16:14:18 -0000
@@ -85,6 +85,9 @@ struct gcc_target
        this is only a placeholder for an omitted FDE.  */
     void (* unwind_label) (FILE *, tree, int, int);
 
+    /* Emit any directives required to unwind this instruction.  */
+    void (* unwind_emit) (FILE *, rtx);
+
     /* Output an internal label.  */
     void (* internal_label) (FILE *, const char *, unsigned long);
 
Index: gcc/varasm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/varasm.c,v
retrieving revision 1.433
diff -u -p -r1.433 varasm.c
--- gcc/varasm.c	9 Jul 2004 03:29:35 -0000	1.433
+++ gcc/varasm.c	14 Jul 2004 16:32:18 -0000
@@ -5015,6 +5015,18 @@ default_emit_unwind_label (FILE * stream
 { 
 }
 
+
+/* Emit any directives required to unwind this instruction.  */
+
+void
+default_unwind_emit (FILE * stream ATTRIBUTE_UNUSED,
+		     rtx insn ATTRIBUTE_UNUSED)
+{
+  /* Should never happen.  */
+  abort ();
+}
+
+
 /* This is how to output an internal numbered label where PREFIX is
    the class of label and LABELNO is the number within the class.  */
 
Index: gcc/config/arm/t-arm-elf
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/t-arm-elf,v
retrieving revision 1.22
diff -u -p -r1.22 t-arm-elf
--- gcc/config/arm/t-arm-elf	15 May 2004 17:31:51 -0000	1.22
+++ gcc/config/arm/t-arm-elf	25 Jun 2004 15:16:37 -0000
@@ -11,6 +11,9 @@ MULTILIB_DIRNAMES    = arm thumb
 MULTILIB_EXCEPTIONS  = 
 MULTILIB_MATCHES     =
 
+MULTILIB_OPTIONS    += mabi=aapcs
+MULTILIB_DIRNAMES   += aapcs
+
 # MULTILIB_OPTIONS    += mcpu=ep9312
 # MULTILIB_DIRNAMES   += ep9312
 # MULTILIB_EXCEPTIONS += *mthumb/*mcpu=ep9312*
Index: gcc/config/ia64/ia64.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.300
diff -u -p -r1.300 ia64.c
--- gcc/config/ia64/ia64.c	9 Jul 2004 23:10:11 -0000	1.300
+++ gcc/config/ia64/ia64.c	14 Jul 2004 16:14:18 -0000
@@ -411,6 +411,9 @@ static const struct attribute_spec ia64_
 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
 #define TARGET_GIMPLIFY_VA_ARG_EXPR ia64_gimplify_va_arg
 
+#undef TARGET_UNWIND_EMIT
+#define TARGET_UNWIND_EMIT process_for_unwind_directive
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Return 1 if OP is a valid operand for the MEM of a CALL insn.  */
Index: gcc/config/ia64/ia64.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/ia64/ia64.h,v
retrieving revision 1.178
diff -u -p -r1.178 ia64.h
--- gcc/config/ia64/ia64.h	5 Jul 2004 19:49:15 -0000	1.178
+++ gcc/config/ia64/ia64.h	14 Jul 2004 16:14:18 -0000
@@ -2281,8 +2281,7 @@ do {									\
 
 extern int ia64_final_schedule;
 
-#define IA64_UNWIND_INFO	1
-#define IA64_UNWIND_EMIT(f,i)	process_for_unwind_directive (f,i)
+#define TARGET_UNWIND_INFO	1
 
 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 15 : INVALID_REGNUM)
 
Index: gcc/doc/tm.texi
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/doc/tm.texi,v
retrieving revision 1.338
diff -u -p -r1.338 tm.texi
--- gcc/doc/tm.texi	9 Jul 2004 22:42:43 -0000	1.338
+++ gcc/doc/tm.texi	14 Jul 2004 16:41:34 -0000
@@ -7508,6 +7508,11 @@ true if this is a placeholder label for 
 The default is that FDEs are not given nonlocal labels.
 @end deftypefn
 
+@deftypefn {Taget Hook} void TARGET_UNWIND_EMIT (@var{stream}, @var{insn})
+This target hook emits and assembly directives required to unwind the
+given instruction.  This is only used when TARGET_UNWIND_INFO is set.
+@end deftypefn
+
 @node Exception Region Output
 @subsection Assembler Commands for Exception Regions
 
@@ -7557,6 +7562,11 @@ If this macro is defined to anything, th
 instead of inline unwinders and @code{__unwind_function} in the 
non-@code{setjmp} case.
 @end defmac
 
+@defmac TARGET_UNWIND_INFO
+Define this macro if your target has ABI specified unwind tables.  Usually
+these will be output by @code{TARGET_UNWIND_EMIT}.
+@end defmac
+
 @defmac MUST_USE_SJLJ_EXCEPTIONS
 This macro need only be defined if @code{DWARF2_UNWIND_INFO} is
 runtime-variable.  In that case, @file{except.h} cannot correctly


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