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: Target hook for ASM_FILE_END


Zack Weinberg <zack@codesourcery.com> writes:
> Index: config/mips/iris6.h
> --- config/mips/iris6.h	12 May 2003 09:51:31 -0000	1.60
> +++ config/mips/iris6.h	6 Jun 2003 01:30:26 -0000
> @@ -358,8 +358,8 @@ current_section_flags ()						\
>  #define ASM_OUTPUT_ALIGN iris6_asm_output_align
>  #undef ASM_FILE_START
>  #define ASM_FILE_START  iris6_asm_file_start
> -#undef ASM_FILE_END
> -#define ASM_FILE_END	iris6_asm_file_end
> +#undef TARGET_ASM_FILE_END
> +#define TARGET_ASM_FILE_END iris6_file_end
>  
>  #undef MAX_OFILE_ALIGNMENT
>  #define MAX_OFILE_ALIGNMENT (32768*8)
> ===================================================================
> Index: config/mips/mips.h
> --- config/mips/mips.h	4 Jun 2003 17:50:42 -0000	1.256
> +++ config/mips/mips.h	6 Jun 2003 01:30:32 -0000
> @@ -3931,9 +3931,7 @@ while (0)
>    mips_output_external(STREAM,DECL,NAME)
>  
>  /* This says what to print at the end of the assembly file */
> -#undef ASM_FILE_END
> -#define ASM_FILE_END(STREAM) mips_asm_file_end(STREAM)
> -
> +#define TARGET_ASM_FILE_END mips_file_end
>  
>  /* Play switch file games if we're optimizing the global pointer.  */
>  
> ===================================================================
> Index: config/mips/mips.c
> --- config/mips/mips.c	3 Jun 2003 08:57:54 -0000	1.272
> +++ config/mips/mips.c	6 Jun 2003 01:30:29 -0000
> @@ -287,7 +287,9 @@ static int mips_use_dfa_pipeline_interfa
>  static bool mips_rtx_costs			PARAMS ((rtx, int, int, int *));
>  static int mips_address_cost                    PARAMS ((rtx));
>  static void mips_encode_section_info            PARAMS ((tree, rtx, int));
> -
> +static void mips_file_end PARAMS ((void));
> +static void iris6_file_end PARAMS ((void))
> +     ATTRIBUTE_UNUSED;
>  

Minor niggle, but how about guarding iris6_file_end with TARGET_IRIX6,
just like the definition is?  Seems more self-documenting than an
ATTRIBUTE_UNUSED directive.

Also, something like:

    #undef TARGET_ASM_FILE_END
    #ifdef TARGET_IRIX6
    static void iris6_file_end PARAMS ((void));
    #define TARGET_ASM_FILE_END iris6_file_end
    #else
    #define TARGET_ASM_FILE_END mips_file_end
    #endif

(or whatever) would keep everything inside mips.c rather than
polluting the header files with the names of static functions.

Not really sure if that's better, just thought I'd ask.

> @@ -10717,19 +10718,19 @@ iris6_section_align_1 (slot, data)
>    return 1;
>  }
>  
> -void
> -iris6_asm_file_end (stream)
> -     FILE *stream;
> +static void
> +iris6_file_end ()
>  {
>    /* Emit section directives with the proper alignment at the top of the
>       real output file.  */
> +  FILE *temp = asm_out_file;
>    asm_out_file = iris_orig_asm_out_file;
>    htab_traverse (iris_section_align_htab, iris6_section_align_1, NULL);
>  
>    /* Copy the data emitted to the temp file to the real output file.  */
> -  copy_file_data (asm_out_file, stream);
> +  copy_file_data (asm_out_file, temp);
>  
> -  mips_asm_file_end (stream);
> +  mips_file_end ();
>  }
>  #endif /* TARGET_IRIX6 */

I think this counts as a bug fix ;).  Shouldn't the old code have
been passing asm_out_file rather than "stream" to mips_asm_file_end()?
"Stream" is the temporary file, and is closed by copy_file_data.

Running:

    $ cat foo.c
    extern int x;
    int f () { return x; }
    $ gcc foo.c -O2 -mno-abicalls -G8 -S

on irix before your patch, I get:

    foo.c:3: fatal error: can't write to output file: Bad file number
    compilation terminated.

Richard


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