re PR target/20446 (invalid assembly with -gstabs+)

PR target/20446
	* config/sparc/sparc.h (NEED_INDICATE_EXEC_STACK): Define to 0.
	* config/sparc/linux.h (TARGET_ASM_FILE_END): Delete.
	(NEED_INDICATE_EXEC_STACK): Define to 1.
	* config/sparc/linux64.h (TARGET_ASM_FILE_END): Delete.
	(NEED_INDICATE_EXEC_STACK): Define to 1.
	* config/sparc/sparc.c (TARGET_ASM_FILE_END): Set to sparc_file_end.
	(add_pc_to_pic_symbol): Rename into pic_helper_symbol.
	(add_pc_to_pic_symbol_name): Rename into pic_helper_symbol_name.
	(pic_helper_emitted_p): New global.
	(emit_pic_helper): New function extracted from...
	(load_pic_register): ...here.  Add 'delay_pic_helper' parameter.
	Do not call emit_pic_helper if delay_pic_helper is true.
	(sparc_expand_prologue): Pass 'false' to load_pic_register.
	(sparc_output_mi_thunk): Pass 'true' to load_pic_register.
	(sparc_file_end): New function.

From-SVN: r97550
This commit is contained in:
Eric Botcazou 2005-04-04 17:29:10 +02:00 committed by Eric Botcazou
parent 105d7df650
commit 5e77eb534b
5 changed files with 89 additions and 38 deletions

View File

@ -1,3 +1,22 @@
2005-04-04 Eric Botcazou <ebotcazou@libertysurf.fr>
PR target/20446
* config/sparc/sparc.h (NEED_INDICATE_EXEC_STACK): Define to 0.
* config/sparc/linux.h (TARGET_ASM_FILE_END): Delete.
(NEED_INDICATE_EXEC_STACK): Define to 1.
* config/sparc/linux64.h (TARGET_ASM_FILE_END): Delete.
(NEED_INDICATE_EXEC_STACK): Define to 1.
* config/sparc/sparc.c (TARGET_ASM_FILE_END): Set to sparc_file_end.
(add_pc_to_pic_symbol): Rename into pic_helper_symbol.
(add_pc_to_pic_symbol_name): Rename into pic_helper_symbol_name.
(pic_helper_emitted_p): New global.
(emit_pic_helper): New function extracted from...
(load_pic_register): ...here. Add 'delay_pic_helper' parameter.
Do not call emit_pic_helper if delay_pic_helper is true.
(sparc_expand_prologue): Pass 'false' to load_pic_register.
(sparc_output_mi_thunk): Pass 'true' to load_pic_register.
(sparc_file_end): New function.
2005-04-04 Kazu Hirata <kazu@cs.umass.edu>
* config/mcore/mcore-protos.h: Remove the prototypes for

View File

@ -209,8 +209,6 @@ do { \
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
/* Determine whether the the entire c99 runtime is present in the
runtime library. */
#define TARGET_C99_FUNCTIONS 1
@ -233,3 +231,6 @@ do { \
change their minds. */
#undef SPARC_RELAXED_ORDERING
#define SPARC_RELAXED_ORDERING true
#undef NEED_INDICATE_EXEC_STACK
#define NEED_INDICATE_EXEC_STACK 1

View File

@ -343,8 +343,6 @@ do { \
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
/* Determine whether the the entire c99 runtime is present in the
runtime library. */
#define TARGET_C99_FUNCTIONS 1
@ -367,3 +365,6 @@ do { \
change their minds. */
#undef SPARC_RELAXED_ORDERING
#define SPARC_RELAXED_ORDERING true
#undef NEED_INDICATE_EXEC_STACK
#define NEED_INDICATE_EXEC_STACK 1

View File

@ -314,7 +314,8 @@ static rtx sparc_builtin_saveregs (void);
static int epilogue_renumber (rtx *, int);
static bool sparc_assemble_integer (rtx, unsigned int, int);
static int set_extends (rtx);
static void load_pic_register (void);
static void emit_pic_helper (void);
static void load_pic_register (bool);
static int save_or_restore_regs (int, int, rtx, int, int);
static void emit_save_regs (void);
static void emit_restore_regs (void);
@ -362,6 +363,7 @@ static bool sparc_pass_by_reference (CUMULATIVE_ARGS *,
static int sparc_arg_partial_bytes (CUMULATIVE_ARGS *,
enum machine_mode, tree, bool);
static void sparc_dwarf_handle_frame_unspec (const char *, rtx, int);
static void sparc_file_end (void);
#ifdef SUBTARGET_ATTRIBUTE_TABLE
const struct attribute_spec sparc_attribute_table[];
#endif
@ -504,6 +506,8 @@ enum processor_type sparc_cpu;
#undef TARGET_RELAXED_ORDERING
#define TARGET_RELAXED_ORDERING SPARC_RELAXED_ORDERING
#define TARGET_ASM_FILE_END sparc_file_end
struct gcc_target targetm = TARGET_INITIALIZER;
/* Validate and override various options, and do some machine dependent
@ -3355,13 +3359,12 @@ sparc_cannot_force_const_mem (rtx x)
}
}
/* The table we use to reference PIC data. */
/* PIC support. */
static GTY(()) char pic_helper_symbol_name[256];
static GTY(()) rtx pic_helper_symbol;
static GTY(()) bool pic_helper_emitted_p = false;
static GTY(()) rtx global_offset_table;
/* The function we use to get at it. */
static GTY(()) rtx add_pc_to_pic_symbol;
static GTY(()) char add_pc_to_pic_symbol_name[256];
/* Ensure that we are not using patterns that are not OK with PIC. */
int
@ -3951,46 +3954,57 @@ legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, enum machine_mode mode)
return x;
}
/* Emit the special PIC prologue. */
/* Emit the special PIC helper function. */
static void
load_pic_register (void)
emit_pic_helper (void)
{
const char *pic_name = reg_names[REGNO (pic_offset_table_rtx)];
int align;
text_section ();
align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
if (align > 0)
ASM_OUTPUT_ALIGN (asm_out_file, align);
ASM_OUTPUT_LABEL (asm_out_file, pic_helper_symbol_name);
if (flag_delayed_branch)
fprintf (asm_out_file, "\tjmp\t%%o7+8\n\t add\t%%o7, %s, %s\n",
pic_name, pic_name);
else
fprintf (asm_out_file, "\tadd\t%%o7, %s, %s\n\tjmp\t%%o7+8\n\t nop\n",
pic_name, pic_name);
pic_helper_emitted_p = true;
}
/* Emit code to load the PIC register. */
static void
load_pic_register (bool delay_pic_helper)
{
int orig_flag_pic = flag_pic;
/* If we haven't emitted the special helper function, do so now. */
if (add_pc_to_pic_symbol_name[0] == 0)
/* If we haven't initialized the special PIC symbols, do so now. */
if (!pic_helper_symbol_name[0])
{
const char *pic_name = reg_names[REGNO (pic_offset_table_rtx)];
int align;
ASM_GENERATE_INTERNAL_LABEL (add_pc_to_pic_symbol_name, "LADDPC", 0);
text_section ();
align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
if (align > 0)
ASM_OUTPUT_ALIGN (asm_out_file, align);
ASM_OUTPUT_LABEL (asm_out_file, add_pc_to_pic_symbol_name);
if (flag_delayed_branch)
fprintf (asm_out_file, "\tjmp %%o7+8\n\t add\t%%o7, %s, %s\n",
pic_name, pic_name);
else
fprintf (asm_out_file, "\tadd\t%%o7, %s, %s\n\tjmp %%o7+8\n\t nop\n",
pic_name, pic_name);
ASM_GENERATE_INTERNAL_LABEL (pic_helper_symbol_name, "LADDPC", 0);
pic_helper_symbol = gen_rtx_SYMBOL_REF (Pmode, pic_helper_symbol_name);
global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
}
/* Initialize every time through, since we can't easily
know this to be permanent. */
global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
add_pc_to_pic_symbol = gen_rtx_SYMBOL_REF (Pmode, add_pc_to_pic_symbol_name);
/* If we haven't emitted the special PIC helper function, do so now unless
we are requested to delay it. */
if (!delay_pic_helper && !pic_helper_emitted_p)
emit_pic_helper ();
flag_pic = 0;
if (TARGET_ARCH64)
emit_insn (gen_load_pcrel_symdi (pic_offset_table_rtx, global_offset_table,
add_pc_to_pic_symbol));
pic_helper_symbol));
else
emit_insn (gen_load_pcrel_symsi (pic_offset_table_rtx, global_offset_table,
add_pc_to_pic_symbol));
pic_helper_symbol));
flag_pic = orig_flag_pic;
/* Need to emit this whether or not we obey regdecls,
@ -4639,7 +4653,7 @@ sparc_expand_prologue (void)
/* Load the PIC register if needed. */
if (flag_pic && current_function_uses_pic_offset_table)
load_pic_register ();
load_pic_register (false);
}
/* This function generates the assembly code for function entry, which boils
@ -9060,7 +9074,9 @@ sparc_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
{
spill_reg = gen_rtx_REG (word_mode, 15); /* %o7 */
start_sequence ();
load_pic_register (); /* clobbers %o7 */
/* Delay emitting the PIC helper function because it needs to
change the section and we are emitting assembly code. */
load_pic_register (true); /* clobbers %o7 */
scratch = legitimize_pic_address (funexp, Pmode, scratch);
seq = get_insns ();
end_sequence ();
@ -9211,4 +9227,15 @@ sparc_output_dwarf_dtprel (FILE *file, int size, rtx x)
fputs (")", file);
}
static
void sparc_file_end (void)
{
/* If we haven't emitted the special PIC helper function, do so now. */
if (pic_helper_symbol_name[0] && !pic_helper_emitted_p)
emit_pic_helper ();
if (NEED_INDICATE_EXEC_STACK)
file_end_indicate_exec_stack ();
}
#include "gt-sparc.h"

View File

@ -214,6 +214,9 @@ extern enum cmodel sparc_cmodel;
total memory ordering (TMO). */
#define SPARC_RELAXED_ORDERING false
/* Do not use the .note.GNU-stack convention by default. */
#define NEED_INDICATE_EXEC_STACK 0
/* This is call-clobbered in the normal ABI, but is reserved in the
home grown (aka upward compatible) embedded ABI. */
#define EMBMEDANY_BASE_REG "%g4"