Patchwork RFA: Fix microblaze ada --enable-werror-always build

login
register
mail settings
Submitter Joern Rennecke
Date Dec. 2, 2010, 12:49 a.m.
Message ID <20101201194952.bsvkqv26m8k44osg-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/73922/
State New
Headers show

Comments

Joern Rennecke - Dec. 2, 2010, 12:49 a.m.
By hookizing the consumer side of ASM_OUTPUT_IDENT, we no longer need to
worry about how different target definition of this macro might affect
our assorted frontends in various ways.

bootstrapped & regression tested on x86_64-pc-linux-gnu
cross-tested on x86_64-pc-linux-gnu for targets:
alpha-linux-gnu arc-elf arm-eabi avr-elf cris-elf crx-elf fr30-elf  
h8300-elf hppa-linux-gnu ia64-elf iq2000-elf lm32-elf m32c-elf  
m32r-elf m68hc11-elf m68k-elf mcore-elf mep-elf microblaze-elf  
mips-elf mn10300-elf moxie-elf pdp11-aout picochip-elf ppc-elf rx-elf  
s390-linux-gnu score-elf sh-elf sparc-elf spu-elf v850-elf  
xstormy16-elf xtensa-elf

bootstrapped & regression tested on i686-pc-linux-gnu
cross-tested on i686-pc-linux-gnu for targets:
bfin-elf frv-elf microblaze-elf mmix-knuth-mmixware vax-linux-gnu
2010-12-01  Joern Rennecke  <amylaar@spamcop.net>

	PR46738
gcc:
	* targhooks.c (legacy_asm_output_ident): New function.
	* targhooks.h (legacy_asm_output_ident): Declare.
	* target.def (asm_out): New hook output_ident.
gcc/c-family:
	* c-lex.c (cb_ident): Use targetm.asm_out.output_ident.
gcc/ada:
	* gcc-interface/Make-lang.in (ada/trans.o): Depend on $(TARGET_H).
	* gcc-interface/trans.c: Include target.h .
	(gigi): Use targetm.asm_out.output_ident .
Joseph S. Myers - Dec. 2, 2010, 2:44 a.m.
On Wed, 1 Dec 2010, Joern Rennecke wrote:

> +/* Wrapper for ASM_OUTPUT_IDENT.  When this is upgraded to a documented hook
> +   and the macro is eventually compiletely eliminated, the default should be
> +   changed to hook_void_FILEptr_constcharptr.  */

"completely".

There are two uses of this macro and you changed both of them - that is, 
technically, after this patch people can start converting targets to 
define the hook.  Would it really have been any harder to make it a 
documented hook (with documentation of the hook in tm.texi.in duplicating 
that of the macro)?  A proper fix is always better than a quick hack and 
by not documenting the hook this patch seems to be in the quick hack 
category when a proper fix would be no harder.
Joern Rennecke - Dec. 2, 2010, 3:03 a.m.
Quoting "Joseph S. Myers" <joseph@codesourcery.com>:

> There are two uses of this macro and you changed both of them - that is,
> technically, after this patch people can start converting targets to
> define the hook.  Would it really have been any harder to make it a
> documented hook (with documentation of the hook in tm.texi.in duplicating
> that of the macro)?

It would be easy if we could get the FSF's permission to re-license
stuff from tm.texi under the GPL.

At the moment, we either have to leave stuff undocumented in target.def,
and create more non-transferrable documentation in tm.texi.in, or
throw away our existing documentation to start from scratch with GPL/GFDL
dual-licensed documentation for the hook.

Do we have any progress on the licensing issue?
Joern Rennecke - Dec. 2, 2010, 3:48 a.m.
P.S.: Or would it be OK if the documentation would just be:
"Hook to replace ASM_OUTPUT_IDENT." ?
As long as the macro stays, people can look it up there.
And if the FSF still can't get its act together by the time
all targets are converted, we could move the macro into a
new section of former target macros, documentation being kept
separate because of licensing issues...
Joern Rennecke - Dec. 2, 2010, 3:54 a.m.
P.P.S.:
Make that:
"Hook to replace @code{ASM_OUTPUT_IDENT}."
Joseph S. Myers - Dec. 2, 2010, 4:04 a.m.
On Wed, 1 Dec 2010, Joern Rennecke wrote:

> P.S.: Or would it be OK if the documentation would just be:
> "Hook to replace ASM_OUTPUT_IDENT." ?

The natural thing to do is to put the documentation in tm.texi.in, 
alongside that for ASM_OUTPUT_IDENT and based on it.

> As long as the macro stays, people can look it up there.
> And if the FSF still can't get its act together by the time
> all targets are converted, we could move the macro into a
> new section of former target macros, documentation being kept
> separate because of licensing issues...

No, the macros in target.def and their documentation in tm.texi should be 
grouped logically by subject not history.

Patch

Index: targhooks.c
===================================================================
--- targhooks.c	(revision 167318)
+++ targhooks.c	(working copy)
@@ -371,6 +371,16 @@ 
   return false;
 }
 
+/* Implementation of TARGET_ASM_OUTPUT_IDENT using the old macro.  */
+void
+legacy_asm_output_ident (FILE *stream ATTRIBUTE_UNUSED,
+			 const char *string ATTRIBUTE_UNUSED)
+{
+#ifdef ASM_OUTPUT_IDENT
+  ASM_OUTPUT_IDENT (stream, string);
+#endif
+}
+
 /* True if MODE is valid for the target.  By "valid", we mean able to
    be manipulated in non-trivial ways.  In particular, this means all
    the arithmetic is supported.
Index: targhooks.h
===================================================================
--- targhooks.h	(revision 167318)
+++ targhooks.h	(working copy)
@@ -66,6 +66,7 @@ 
 extern void default_print_operand_address (FILE *, rtx);
 extern bool default_print_operand_punct_valid_p (unsigned char);
 extern bool default_asm_output_addr_const_extra (FILE *, rtx);
+extern void legacy_asm_output_ident (FILE *stream, const char *);
 
 extern bool default_scalar_mode_supported_p (enum machine_mode);
 extern bool targhook_words_big_endian (void);
Index: c-family/c-lex.c
===================================================================
--- c-family/c-lex.c	(revision 167318)
+++ c-family/c-lex.c	(working copy)
@@ -165,18 +165,16 @@ 
 	  unsigned int ARG_UNUSED (line),
 	  const cpp_string * ARG_UNUSED (str))
 {
-#ifdef ASM_OUTPUT_IDENT
   if (!flag_no_ident)
     {
       /* Convert escapes in the string.  */
       cpp_string cstr = { 0, 0 };
       if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
 	{
-	  ASM_OUTPUT_IDENT (asm_out_file, (const char *) cstr.text);
+	  targetm.asm_out.output_ident (asm_out_file, (const char *) cstr.text);
 	  free (CONST_CAST (unsigned char *, cstr.text));
 	}
     }
-#endif
 }
 
 /* Called at the start of every non-empty line.  TOKEN is the first
Index: target.def
===================================================================
--- target.def	(revision 167318)
+++ target.def	(working copy)
@@ -524,6 +524,15 @@ 
  bool ,(unsigned char code),
  default_print_operand_punct_valid_p)
 
+/* Wrapper for ASM_OUTPUT_IDENT.  When this is upgraded to a documented hook
+   and the macro is eventually compiletely eliminated, the default should be
+   changed to hook_void_FILEptr_constcharptr.  */
+DEFHOOK_UNDOC
+(output_ident,
+ "",
+ void, (FILE *stream, const char *string),
+ legacy_asm_output_ident)
+
 HOOK_VECTOR_END (asm_out)
 
 /* Functions relating to instruction scheduling.  All of these
Index: ada/gcc-interface/Make-lang.in
===================================================================
--- ada/gcc-interface/Make-lang.in	(revision 167318)
+++ ada/gcc-interface/Make-lang.in	(working copy)
@@ -1246,7 +1246,7 @@ 
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) -I.. $(ALL_CPPFLAGS) $< -o $@
 
 ada/trans.o : ada/gcc-interface/trans.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-   $(TM_H) $(TREE_H) $(FLAGS_H) output.h tree-iterator.h  \
+   $(TM_H) $(TREE_H) $(FLAGS_H) output.h tree-iterator.h  $(TARGET_H) \
    $(GIMPLE_H) ada/gcc-interface/ada.h ada/adadecode.h ada/types.h \
    ada/atree.h ada/elists.h ada/namet.h ada/nlists.h ada/snames.h \
    ada/stringt.h ada/uintp.h ada/urealp.h ada/fe.h ada/sinfo.h ada/einfo.h \
Index: ada/gcc-interface/trans.c
===================================================================
--- ada/gcc-interface/trans.c	(revision 167318)
+++ ada/gcc-interface/trans.c	(working copy)
@@ -34,6 +34,7 @@ 
 #include "libfuncs.h"	/* For set_stack_check_libfunc.  */
 #include "tree-iterator.h"
 #include "gimple.h"
+#include "target.h"
 
 #include "ada.h"
 #include "adadecode.h"
@@ -591,12 +592,10 @@ 
   VEC_safe_push (tree, gc, gnu_program_error_label_stack, NULL_TREE);
 
   /* Process any Pragma Ident for the main unit.  */
-#ifdef ASM_OUTPUT_IDENT
   if (Present (Ident_String (Main_Unit)))
-    ASM_OUTPUT_IDENT
+    targetm.asm_out.output_ident
       (asm_out_file,
        TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit))));
-#endif
 
   /* If we are using the GCC exception mechanism, let GCC know.  */
   if (Exception_Mechanism == Back_End_Exceptions)