Commit 96ac4c9b by Anatoly Sokolov Committed by Anatoly Sokolov

avr.c (avr_OS_task_function_p): Add new function.

	* config/avr/avr.c (avr_OS_task_function_p): Add new function.
	(avr_regs_to_save): Handle functions with 'OS_task' attribute.
	(avr_simple_epilogue, expand_prologue, avr_asm_function_end_prologue,
	expand_epilogue, output_movhi): Don't handle 'main' function.
	(avr_attribute_table): Add 'OS_task' function attribute.
	* config/avr/avr.h (machine_function): Remove 'is_main' field, add
	'is_OS_task' field.
	* config/avr/avr.md (return_from_main_epilogue): Remove insn.
	(return_from_epilogue, return_from_interrupt_epilogue): Don't handle
	'main' function.
	* config/avr/avr.opt (minit-stack): Remove.

From-SVN: r129662
parent bc4c8d89
2007-10-26 Anatoly Sokolov <aesok@post.ru>
* config/avr/avr.c (avr_OS_task_function_p): Add new function.
(avr_regs_to_save): Handle functions with 'OS_task' attribute.
(avr_simple_epilogue, expand_prologue, avr_asm_function_end_prologue,
expand_epilogue, output_movhi): Don't handle 'main' function.
(avr_attribute_table): Add 'OS_task' function attribute.
* config/avr/avr.h (machine_function): Remove 'is_main' field, add
'is_OS_task' field.
* config/avr/avr.md (return_from_main_epilogue): Remove insn.
(return_from_epilogue, return_from_interrupt_epilogue): Don't handle
'main' function.
* config/avr/avr.opt (minit-stack): Remove.
2007-10-26 Eric Botcazou <ebotcazou@adacore.com> 2007-10-26 Eric Botcazou <ebotcazou@adacore.com>
* tree-nested.c (get_trampoline_type): Fix thinko. * tree-nested.c (get_trampoline_type): Fix thinko.
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
static int avr_naked_function_p (tree); 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_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);
...@@ -434,6 +435,19 @@ signal_function_p (tree func) ...@@ -434,6 +435,19 @@ signal_function_p (tree func)
return a != NULL_TREE; return a != NULL_TREE;
} }
/* Return nonzero if FUNC is a OS_task function. */
static int
avr_OS_task_function_p (tree func)
{
tree a;
gcc_assert (TREE_CODE (func) == FUNCTION_DECL);
a = lookup_attribute ("OS_task", 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. */
...@@ -449,8 +463,10 @@ avr_regs_to_save (HARD_REG_SET *set) ...@@ -449,8 +463,10 @@ avr_regs_to_save (HARD_REG_SET *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. */ /* No need to save any registers if the function never returns or
if (TREE_THIS_VOLATILE (current_function_decl)) is have "OS_task" attribute. */
if (TREE_THIS_VOLATILE (current_function_decl)
|| cfun->machine->is_OS_task)
return 0; return 0;
for (reg = 0; reg < 32; reg++) for (reg = 0; reg < 32; reg++)
...@@ -501,7 +517,6 @@ avr_simple_epilogue (void) ...@@ -501,7 +517,6 @@ avr_simple_epilogue (void)
&& ! interrupt_function_p (current_function_decl) && ! interrupt_function_p (current_function_decl)
&& ! signal_function_p (current_function_decl) && ! signal_function_p (current_function_decl)
&& ! avr_naked_function_p (current_function_decl) && ! avr_naked_function_p (current_function_decl)
&& ! MAIN_NAME_P (DECL_NAME (current_function_decl))
&& ! TREE_THIS_VOLATILE (current_function_decl)); && ! TREE_THIS_VOLATILE (current_function_decl));
} }
...@@ -572,10 +587,10 @@ expand_prologue (void) ...@@ -572,10 +587,10 @@ expand_prologue (void)
last_insn_address = 0; last_insn_address = 0;
/* Init cfun->machine. */ /* Init cfun->machine. */
cfun->machine->is_main = MAIN_NAME_P (DECL_NAME (current_function_decl));
cfun->machine->is_naked = avr_naked_function_p (current_function_decl); cfun->machine->is_naked = avr_naked_function_p (current_function_decl);
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);
/* Prologue: naked. */ /* Prologue: naked. */
if (cfun->machine->is_naked) if (cfun->machine->is_naked)
...@@ -619,18 +634,7 @@ expand_prologue (void) ...@@ -619,18 +634,7 @@ expand_prologue (void)
/* Prevent any attempt to delete the setting of ZERO_REG! */ /* Prevent any attempt to delete the setting of ZERO_REG! */
emit_insn (gen_rtx_USE (VOIDmode, zero_reg_rtx)); emit_insn (gen_rtx_USE (VOIDmode, zero_reg_rtx));
} }
if (cfun->machine->is_main) if (minimize && (frame_pointer_needed || live_seq > 6))
{
char buffer[40];
sprintf (buffer, "%s - %d", avr_init_stack, (int) size);
rtx sym = gen_rtx_SYMBOL_REF (HImode, ggc_strdup (buffer));
/* Initialize stack pointer using frame pointer. */
insn = emit_move_insn (frame_pointer_rtx, sym);
RTX_FRAME_RELATED_P (insn) = 1;
insn = emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
RTX_FRAME_RELATED_P (insn) = 1;
}
else if (minimize && (frame_pointer_needed || live_seq > 6))
{ {
insn = emit_move_insn (gen_rtx_REG (HImode, REG_X), insn = emit_move_insn (gen_rtx_REG (HImode, REG_X),
gen_int_mode (size, HImode)); gen_int_mode (size, HImode));
...@@ -763,10 +767,6 @@ avr_asm_function_end_prologue (FILE *file) ...@@ -763,10 +767,6 @@ avr_asm_function_end_prologue (FILE *file)
{ {
fputs ("/* prologue: Signal */\n", file); fputs ("/* prologue: Signal */\n", file);
} }
else if (cfun->machine->is_main)
{
fputs ("/* prologue: main */\n", file);
}
else else
fputs ("/* prologue: function */\n", file); fputs ("/* prologue: function */\n", file);
} }
...@@ -809,13 +809,7 @@ expand_epilogue (void) ...@@ -809,13 +809,7 @@ expand_epilogue (void)
&& !(cfun->machine->is_interrupt || cfun->machine->is_signal) && !(cfun->machine->is_interrupt || cfun->machine->is_signal)
&& live_seq); && live_seq);
if (cfun->machine->is_main) if (minimize && (frame_pointer_needed || live_seq > 4))
{
/* Return value from main() is already in the correct registers
(r25:r24) as the exit() argument. */
emit_jump_insn (gen_return ());
}
else if (minimize && (frame_pointer_needed || live_seq > 4))
{ {
if (frame_pointer_needed) if (frame_pointer_needed)
{ {
...@@ -1637,9 +1631,6 @@ output_movhi (rtx insn, rtx operands[], int *l) ...@@ -1637,9 +1631,6 @@ output_movhi (rtx insn, rtx operands[], int *l)
or inside main or signal function prologue where they disabled. */ or inside main or signal function prologue where they disabled. */
else if (TARGET_NO_INTERRUPTS else if (TARGET_NO_INTERRUPTS
|| (reload_completed || (reload_completed
&& cfun->machine->is_main
&& prologue_epilogue_contains (insn))
|| (reload_completed
&& cfun->machine->is_signal && cfun->machine->is_signal
&& prologue_epilogue_contains (insn))) && prologue_epilogue_contains (insn)))
{ {
...@@ -4566,6 +4557,7 @@ const struct attribute_spec avr_attribute_table[] = ...@@ -4566,6 +4557,7 @@ const struct attribute_spec avr_attribute_table[] =
{ "signal", 0, 0, true, false, false, avr_handle_fndecl_attribute }, { "signal", 0, 0, true, false, false, avr_handle_fndecl_attribute },
{ "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 },
{ NULL, 0, 0, false, false, false, NULL } { NULL, 0, 0, false, false, false, NULL }
}; };
......
...@@ -956,9 +956,6 @@ mmcu=*:-mmcu=%*}" ...@@ -956,9 +956,6 @@ mmcu=*:-mmcu=%*}"
This is added to the cfun structure. */ This is added to the cfun structure. */
struct machine_function GTY(()) struct machine_function GTY(())
{ {
/* 'true' - if current function is a 'main' function. */
int is_main;
/* 'true' - if current function is a naked function. */ /* 'true' - if current function is a naked function. */
int is_naked; int is_naked;
...@@ -969,4 +966,8 @@ struct machine_function GTY(()) ...@@ -969,4 +966,8 @@ struct machine_function GTY(())
/* 'true' - if current function is a signal function /* 'true' - if current function is a signal function
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
as specified by the "OS_task" attribute. */
int is_OS_task;
}; };
...@@ -2809,32 +2809,16 @@ ...@@ -2809,32 +2809,16 @@
[(return)] [(return)]
"(reload_completed "(reload_completed
&& cfun->machine && cfun->machine
&& !cfun->machine->is_main
&& !(cfun->machine->is_interrupt || cfun->machine->is_signal) && !(cfun->machine->is_interrupt || cfun->machine->is_signal)
&& !cfun->machine->is_naked)" && !cfun->machine->is_naked)"
"ret" "ret"
[(set_attr "cc" "none") [(set_attr "cc" "none")
(set_attr "length" "1")]) (set_attr "length" "1")])
(define_insn "return_from_main_epilogue"
[(return)]
"(reload_completed
&& cfun->machine
&& cfun->machine->is_main
&& !cfun->machine->is_naked)"
"%~jmp exit"
[(set_attr_alternative "length"
[(if_then_else (eq_attr "mcu_mega" "yes")
(const_int 2)
(const_int 1))])
(set_attr "cc" "none")
])
(define_insn "return_from_interrupt_epilogue" (define_insn "return_from_interrupt_epilogue"
[(return)] [(return)]
"(reload_completed "(reload_completed
&& cfun->machine && cfun->machine
&& !cfun->machine->is_main
&& (cfun->machine->is_interrupt || cfun->machine->is_signal) && (cfun->machine->is_interrupt || cfun->machine->is_signal)
&& !cfun->machine->is_naked)" && !cfun->machine->is_naked)"
"reti" "reti"
......
...@@ -29,10 +29,6 @@ Target RejectNegative Joined Var(avr_mcu_name) Init("avr2") ...@@ -29,10 +29,6 @@ Target RejectNegative Joined Var(avr_mcu_name) Init("avr2")
mdeb mdeb
Target Report Undocumented Mask(ALL_DEBUG) Target Report Undocumented Mask(ALL_DEBUG)
minit-stack=
Target RejectNegative Joined Var(avr_init_stack) Init("__stack")
-minit-stack=STACK Use STACK as the initial value of the stack pointer
mint8 mint8
Target Report Mask(INT8) Target Report Mask(INT8)
Use an 8-bit 'int' type Use an 8-bit 'int' type
......
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