From 31fdb4d52b0ed2ebdb4f3d94cfd1243ffa8b6888 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Sat, 13 Apr 1996 19:05:54 +0000 Subject: [PATCH] arm.c (use_return_insn): Don't use return for naked functions. * arm/arm.c (use_return_insn): Don't use return for naked functions. (arm_valid_machine_decl_attribute): New function. (arm_naked_function_p): New function. (output_func_prologue): Naked functions don't have prologues. (arm_expand_prologue): Likewise. (output_func_epilogue): Likewise with epilogues. From-SVN: r11755 --- gcc/config/arm/arm.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 3b4a06a..8d32108 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -307,6 +307,10 @@ use_return_insn () if (regs_ever_live[regno]) return 0; + /* If a function is naked, don't use the "return" insn. */ + if (arm_naked_function_p (current_function_decl)) + return 0; + return 1; } @@ -2335,6 +2339,45 @@ const_pool_offset (symbol) { return get_pool_offset (symbol) - get_pool_size () - get_prologue_size (); } + +/* Return nonzero if ATTR is a valid attribute for DECL. + ATTRIBUTES are any existing attributes and ARGS are the arguments + supplied with ATTR. + + Supported attributes: + + naked: don't output any prologue or epilogue code, the user is assumed + to do the right thing. */ + +int +arm_valid_machine_decl_attribute (decl, attributes, attr, args) + tree decl; + tree attributes; + tree attr; + tree args; +{ + if (args != NULL_TREE) + return 0; + + if (is_attribute_p ("naked", attr)) + return TREE_CODE (decl) == FUNCTION_DECL; + return 0; +} + +/* Return non-zero if FUNC is a naked function. */ + +static int +arm_naked_function_p (func) + tree func; +{ + tree a; + + if (TREE_CODE (func) != FUNCTION_DECL) + abort (); + + a = lookup_attribute ("naked", DECL_MACHINE_ATTRIBUTES (func)); + return a != NULL_TREE; +} /* Routines for use in generating RTL */ @@ -4283,7 +4326,10 @@ output_func_prologue (f, frame_size) if (arm_ccfsm_state || arm_target_insn) abort (); /* Sanity check */ - + + if (arm_naked_function_p (current_function_decl)) + return; + return_used_this_function = 0; lr_save_eliminated = 0; @@ -4354,6 +4400,10 @@ output_func_epilogue (f, frame_size) goto epilogue_done; } + /* Naked functions don't have epilogues. */ + if (arm_naked_function_p (current_function_decl)) + goto epilogue_done; + /* A volatile function should never return. Call abort. */ if (volatile_func) { @@ -4500,6 +4550,10 @@ arm_expand_prologue () int volatile_func = (optimize > 0 && TREE_THIS_VOLATILE (current_function_decl)); + /* Naked functions don't have prologues. */ + if (arm_naked_function_p (current_function_decl)) + return; + if (current_function_anonymous_args && current_function_pretend_args_size) store_arg_regs = 1; -- 2.7.4