diff options
Diffstat (limited to 'gcc/config/avr/avr.c')
-rw-r--r-- | gcc/config/avr/avr.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 9a860533e9a..1293a4b3463 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -52,6 +52,7 @@ static int avr_naked_function_p (tree); static int interrupt_function_p (tree); static int signal_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 sequent_regs_live (void); static const char *ptrreg_to_str (int); @@ -446,6 +447,19 @@ avr_OS_task_function_p (tree func) 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 of the current function, and optionally store these registers in SET. */ @@ -464,9 +478,10 @@ avr_regs_to_save (HARD_REG_SET *set) count = 0; /* 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) - || cfun->machine->is_OS_task) + || cfun->machine->is_OS_task + || cfun->machine->is_OS_main) return 0; for (reg = 0; reg < 32; reg++) @@ -593,6 +608,7 @@ expand_prologue (void) cfun->machine->is_interrupt = interrupt_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_main = avr_OS_main_function_p (current_function_decl); /* Prologue: naked. */ if (cfun->machine->is_naked) @@ -606,6 +622,7 @@ expand_prologue (void) && !cfun->machine->is_interrupt && !cfun->machine->is_signal && !cfun->machine->is_OS_task + && !cfun->machine->is_OS_main && live_seq); if (cfun->machine->is_interrupt || cfun->machine->is_signal) @@ -675,7 +692,7 @@ expand_prologue (void) } if (frame_pointer_needed) { - if(!cfun->machine->is_OS_task) + if (!(cfun->machine->is_OS_task || cfun->machine->is_OS_main)) { /* Push frame pointer. */ insn = emit_move_insn (pushword, frame_pointer_rtx); @@ -829,6 +846,7 @@ expand_epilogue (void) && !cfun->machine->is_interrupt && !cfun->machine->is_signal && !cfun->machine->is_OS_task + && !cfun->machine->is_OS_main && live_seq); if (minimize && (frame_pointer_needed || live_seq > 4)) @@ -891,7 +909,7 @@ expand_epilogue (void) 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. */ emit_insn (gen_pophi (frame_pointer_rtx)); @@ -4593,6 +4611,7 @@ const struct attribute_spec avr_attribute_table[] = { "interrupt", 0, 0, true, false, false, avr_handle_fndecl_attribute }, { "naked", 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 } }; |