Commit 9b678d96 by Anatoly Sokolov Committed by Anatoly Sokolov

avr.h (machine_function): Add 'is_OS_main' field.

	* config/avr/avr.h (machine_function): Add 'is_OS_main' field.
	* config/avr/avr.c (avr_OS_main_function_p): Add new function.
	(avr_attribute_table): Add 'OS_main' function attribute.
	(avr_regs_to_save, expand_prologue, expand_epilogue): Handle
	functions with 'OS_main' attribute.

From-SVN: r135681
parent ede2e423
2008-05-20 Anatoly Sokolov <aesok@post.ru>
* config/avr/avr.h (machine_function): Add 'is_OS_main' field.
* config/avr/avr.c (avr_OS_main_function_p): Add new function.
(avr_attribute_table): Add 'OS_main' function attribute.
(avr_regs_to_save, expand_prologue, expand_epilogue): Handle
functions with 'OS_main' attribute.
2008-05-20 Richard Guenther <rguenther@suse.de> 2008-05-20 Richard Guenther <rguenther@suse.de>
PR tree-optimization/35204 PR tree-optimization/35204
......
...@@ -52,6 +52,7 @@ static int avr_naked_function_p (tree); ...@@ -52,6 +52,7 @@ static int avr_naked_function_p (tree);
static int interrupt_function_p (tree); static int interrupt_function_p (tree);
static int signal_function_p (tree); static int signal_function_p (tree);
static int avr_OS_task_function_p (tree); static int avr_OS_task_function_p (tree);
static int avr_OS_main_function_p (tree);
static int avr_regs_to_save (HARD_REG_SET *); static int avr_regs_to_save (HARD_REG_SET *);
static int sequent_regs_live (void); static int sequent_regs_live (void);
static const char *ptrreg_to_str (int); static const char *ptrreg_to_str (int);
...@@ -446,6 +447,19 @@ avr_OS_task_function_p (tree func) ...@@ -446,6 +447,19 @@ avr_OS_task_function_p (tree func)
return a != NULL_TREE; return a != NULL_TREE;
} }
/* Return nonzero if FUNC is a OS_main function. */
static int
avr_OS_main_function_p (tree func)
{
tree a;
gcc_assert (TREE_CODE (func) == FUNCTION_DECL);
a = lookup_attribute ("OS_main", TYPE_ATTRIBUTES (TREE_TYPE (func)));
return a != NULL_TREE;
}
/* Return the number of hard registers to push/pop in the prologue/epilogue /* Return the number of hard registers to push/pop in the prologue/epilogue
of the current function, and optionally store these registers in SET. */ of the current function, and optionally store these registers in SET. */
...@@ -464,9 +478,10 @@ avr_regs_to_save (HARD_REG_SET *set) ...@@ -464,9 +478,10 @@ avr_regs_to_save (HARD_REG_SET *set)
count = 0; count = 0;
/* No need to save any registers if the function never returns or /* No need to save any registers if the function never returns or
is have "OS_task" attribute. */ is have "OS_task" or "OS_main" attribute. */
if (TREE_THIS_VOLATILE (current_function_decl) if (TREE_THIS_VOLATILE (current_function_decl)
|| cfun->machine->is_OS_task) || cfun->machine->is_OS_task
|| cfun->machine->is_OS_main)
return 0; return 0;
for (reg = 0; reg < 32; reg++) for (reg = 0; reg < 32; reg++)
...@@ -593,6 +608,7 @@ expand_prologue (void) ...@@ -593,6 +608,7 @@ expand_prologue (void)
cfun->machine->is_interrupt = interrupt_function_p (current_function_decl); cfun->machine->is_interrupt = interrupt_function_p (current_function_decl);
cfun->machine->is_signal = signal_function_p (current_function_decl); cfun->machine->is_signal = signal_function_p (current_function_decl);
cfun->machine->is_OS_task = avr_OS_task_function_p (current_function_decl); cfun->machine->is_OS_task = avr_OS_task_function_p (current_function_decl);
cfun->machine->is_OS_main = avr_OS_main_function_p (current_function_decl);
/* Prologue: naked. */ /* Prologue: naked. */
if (cfun->machine->is_naked) if (cfun->machine->is_naked)
...@@ -606,6 +622,7 @@ expand_prologue (void) ...@@ -606,6 +622,7 @@ expand_prologue (void)
&& !cfun->machine->is_interrupt && !cfun->machine->is_interrupt
&& !cfun->machine->is_signal && !cfun->machine->is_signal
&& !cfun->machine->is_OS_task && !cfun->machine->is_OS_task
&& !cfun->machine->is_OS_main
&& live_seq); && live_seq);
if (cfun->machine->is_interrupt || cfun->machine->is_signal) if (cfun->machine->is_interrupt || cfun->machine->is_signal)
...@@ -675,7 +692,7 @@ expand_prologue (void) ...@@ -675,7 +692,7 @@ expand_prologue (void)
} }
if (frame_pointer_needed) if (frame_pointer_needed)
{ {
if(!cfun->machine->is_OS_task) if (!(cfun->machine->is_OS_task || cfun->machine->is_OS_main))
{ {
/* Push frame pointer. */ /* Push frame pointer. */
insn = emit_move_insn (pushword, frame_pointer_rtx); insn = emit_move_insn (pushword, frame_pointer_rtx);
...@@ -829,6 +846,7 @@ expand_epilogue (void) ...@@ -829,6 +846,7 @@ expand_epilogue (void)
&& !cfun->machine->is_interrupt && !cfun->machine->is_interrupt
&& !cfun->machine->is_signal && !cfun->machine->is_signal
&& !cfun->machine->is_OS_task && !cfun->machine->is_OS_task
&& !cfun->machine->is_OS_main
&& live_seq); && live_seq);
if (minimize && (frame_pointer_needed || live_seq > 4)) if (minimize && (frame_pointer_needed || live_seq > 4))
...@@ -891,7 +909,7 @@ expand_epilogue (void) ...@@ -891,7 +909,7 @@ expand_epilogue (void)
emit_move_insn (stack_pointer_rtx, frame_pointer_rtx); emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
} }
} }
if(!cfun->machine->is_OS_task) if (!(cfun->machine->is_OS_task || cfun->machine->is_OS_main))
{ {
/* Restore previous frame_pointer. */ /* Restore previous frame_pointer. */
emit_insn (gen_pophi (frame_pointer_rtx)); emit_insn (gen_pophi (frame_pointer_rtx));
...@@ -4593,6 +4611,7 @@ const struct attribute_spec avr_attribute_table[] = ...@@ -4593,6 +4611,7 @@ const struct attribute_spec avr_attribute_table[] =
{ "interrupt", 0, 0, true, false, false, avr_handle_fndecl_attribute }, { "interrupt", 0, 0, true, false, false, avr_handle_fndecl_attribute },
{ "naked", 0, 0, false, true, true, avr_handle_fntype_attribute }, { "naked", 0, 0, false, true, true, avr_handle_fntype_attribute },
{ "OS_task", 0, 0, false, true, true, avr_handle_fntype_attribute }, { "OS_task", 0, 0, false, true, true, avr_handle_fntype_attribute },
{ "OS_main", 0, 0, false, true, true, avr_handle_fntype_attribute },
{ NULL, 0, 0, false, false, false, NULL } { NULL, 0, 0, false, false, false, NULL }
}; };
......
...@@ -1042,7 +1042,11 @@ struct machine_function GTY(()) ...@@ -1042,7 +1042,11 @@ struct machine_function GTY(())
as specified by the "signal" attribute. */ as specified by the "signal" attribute. */
int is_signal; int is_signal;
/* 'true' - if current function is a signal function /* 'true' - if current function is a 'task' function
as specified by the "OS_task" attribute. */ as specified by the "OS_task" attribute. */
int is_OS_task; int is_OS_task;
/* 'true' - if current function is a 'main' function
as specified by the "OS_main" attribute. */
int is_OS_main;
}; };
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