Commit e52b6b63 by Marek Michalkiewicz Committed by Marek Michalkiewicz

avr.c (avr_regs_to_save): No need to save any registers in a noreturn function.


	* config/avr/avr.c (avr_regs_to_save): No need to save any registers
	in a noreturn function.
	(avr_output_function_prologue, avr_output_function_epilogue):
	Correct function size calculation.  Do not crash on empty function.
	(avr_output_function_epilogue): No need for epilogue after a BARRIER.

From-SVN: r54386
parent 1569d670
2002-06-08 Marek Michalkiewicz <marekm@amelek.gda.pl>
* config/avr/avr.c (avr_regs_to_save): No need to save any registers
in a noreturn function.
(avr_output_function_prologue, avr_output_function_epilogue):
Correct function size calculation. Do not crash on empty function.
(avr_output_function_epilogue): No need for epilogue after a BARRIER.
2002-06-08 Jason Thorpe <thorpej@wasabisystems.com> 2002-06-08 Jason Thorpe <thorpej@wasabisystems.com>
* config/mips/netbsd.h (SUBTARGET_EXTRA_SPECS): Add * config/mips/netbsd.h (SUBTARGET_EXTRA_SPECS): Add
......
...@@ -395,6 +395,11 @@ avr_regs_to_save (set) ...@@ -395,6 +395,11 @@ avr_regs_to_save (set)
if (set) if (set)
CLEAR_HARD_REG_SET (*set); CLEAR_HARD_REG_SET (*set);
count = 0; count = 0;
/* No need to save any registers if the function never returns. */
if (TREE_THIS_VOLATILE (current_function_decl))
return 0;
for (reg = 0; reg < 32; reg++) for (reg = 0; reg < 32; reg++)
{ {
/* Do not push/pop __tmp_reg__, __zero_reg__, as well as /* Do not push/pop __tmp_reg__, __zero_reg__, as well as
...@@ -609,11 +614,16 @@ avr_output_function_prologue (file, size) ...@@ -609,11 +614,16 @@ avr_output_function_prologue (file, size)
int main_p; int main_p;
int live_seq; int live_seq;
int minimize; int minimize;
last_insn_address = 0;
jump_tables_size = 0;
prologue_size = 0;
fprintf (file, "/* prologue: frame size=%d */\n", size);
if (avr_naked_function_p (current_function_decl)) if (avr_naked_function_p (current_function_decl))
{ {
fprintf (file, "/* prologue: naked */\n"); fputs ("/* prologue: naked */\n", file);
return; goto out;
} }
interrupt_func_p = interrupt_function_p (current_function_decl); interrupt_func_p = interrupt_function_p (current_function_decl);
...@@ -623,11 +633,6 @@ avr_output_function_prologue (file, size) ...@@ -623,11 +633,6 @@ avr_output_function_prologue (file, size)
minimize = (TARGET_CALL_PROLOGUES minimize = (TARGET_CALL_PROLOGUES
&& !interrupt_func_p && !signal_func_p && live_seq); && !interrupt_func_p && !signal_func_p && live_seq);
last_insn_address = 0;
jump_tables_size = 0;
prologue_size = 0;
fprintf (file, "/* prologue: frame size=%d */\n", size);
if (interrupt_func_p) if (interrupt_func_p)
{ {
fprintf (file,"\tsei\n"); fprintf (file,"\tsei\n");
...@@ -722,6 +727,8 @@ avr_output_function_prologue (file, size) ...@@ -722,6 +727,8 @@ avr_output_function_prologue (file, size)
} }
} }
} }
out:
fprintf (file, "/* prologue end (size=%d) */\n", prologue_size); fprintf (file, "/* prologue end (size=%d) */\n", prologue_size);
} }
...@@ -739,25 +746,39 @@ avr_output_function_epilogue (file, size) ...@@ -739,25 +746,39 @@ avr_output_function_epilogue (file, size)
int function_size; int function_size;
int live_seq; int live_seq;
int minimize; int minimize;
rtx last = get_last_nonnote_insn ();
function_size = jump_tables_size;
if (last)
{
rtx first = get_first_nonnote_insn ();
function_size += (INSN_ADDRESSES (INSN_UID (last)) -
INSN_ADDRESSES (INSN_UID (first)));
function_size += get_attr_length (last);
}
fprintf (file, "/* epilogue: frame size=%d */\n", size);
epilogue_size = 0;
if (avr_naked_function_p (current_function_decl)) if (avr_naked_function_p (current_function_decl))
{ {
fprintf (file, "/* epilogue: naked */\n"); fputs ("/* epilogue: naked */\n", file);
return; goto out;
}
if (last && GET_CODE (last) == BARRIER)
{
fputs ("/* epilogue: noreturn */\n", file);
goto out;
} }
interrupt_func_p = interrupt_function_p (current_function_decl); interrupt_func_p = interrupt_function_p (current_function_decl);
signal_func_p = signal_function_p (current_function_decl); signal_func_p = signal_function_p (current_function_decl);
main_p = MAIN_NAME_P (DECL_NAME (current_function_decl)); main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
function_size = (INSN_ADDRESSES (INSN_UID (get_last_nonnote_insn ()))
- INSN_ADDRESSES (INSN_UID (get_first_nonnote_insn ())));
function_size += jump_tables_size;
live_seq = sequent_regs_live (); live_seq = sequent_regs_live ();
minimize = (TARGET_CALL_PROLOGUES minimize = (TARGET_CALL_PROLOGUES
&& !interrupt_func_p && !signal_func_p && live_seq); && !interrupt_func_p && !signal_func_p && live_seq);
epilogue_size = 0;
fprintf (file, "/* epilogue: frame size=%d */\n", size);
if (main_p) if (main_p)
{ {
/* Return value from main() is already in the correct registers /* Return value from main() is already in the correct registers
...@@ -850,7 +871,8 @@ avr_output_function_epilogue (file, size) ...@@ -850,7 +871,8 @@ avr_output_function_epilogue (file, size)
fprintf (file, "\tret\n"); fprintf (file, "\tret\n");
++epilogue_size; ++epilogue_size;
} }
out:
fprintf (file, "/* epilogue end (size=%d) */\n", epilogue_size); fprintf (file, "/* epilogue end (size=%d) */\n", epilogue_size);
fprintf (file, "/* function %s size %d (%d) */\n", current_function_name, fprintf (file, "/* function %s size %d (%d) */\n", current_function_name,
prologue_size + function_size + epilogue_size, function_size); prologue_size + function_size + epilogue_size, function_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment