diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2021-11-08 19:10:58 -0800 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2021-11-09 18:00:54 -0800 |
commit | d581cf9c2f6932651dd5d48f60cb4250cfaf6ddd (patch) | |
tree | 7b46dea76463876f6bc50c5442d7a6454383c20e /gcc/config/nios2 | |
parent | c9b1334eecc51bc0562581f2c6e86d3fc474c23c (diff) | |
download | gcc-d581cf9c2f6932651dd5d48f60cb4250cfaf6ddd.zip gcc-d581cf9c2f6932651dd5d48f60cb4250cfaf6ddd.tar.gz gcc-d581cf9c2f6932651dd5d48f60cb4250cfaf6ddd.tar.bz2 |
Nios2: Add TARGET_CAN_INLINE_P hook.
2021-11-09 Sandra Loosemore <sandra@codesourcery.com>
gcc/
* config/nios2/nios2.c (nios2_can_inline_p): New.
(TARGET_CAN_INLINE_P): Define.
gcc/testsuite/
* gcc.target/nios2/custom-fp-inline-1.c: New.
* gcc.target/nios2/custom-fp-inline-2.c: New.
* gcc.target/nios2/custom-fp-inline-3.c: New.
* gcc.target/nios2/custom-fp-inline-4.c: New.
Diffstat (limited to 'gcc/config/nios2')
-rw-r--r-- | gcc/config/nios2/nios2.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c index 7a613e4..f77f7e6 100644 --- a/gcc/config/nios2/nios2.c +++ b/gcc/config/nios2/nios2.c @@ -4162,6 +4162,40 @@ nios2_option_restore (struct gcc_options *opts ATTRIBUTE_UNUSED, sizeof (custom_code_index)); } +static bool +nios2_can_inline_p (tree caller, tree callee) +{ + tree callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee); + tree caller_opts = DECL_FUNCTION_SPECIFIC_TARGET (caller); + struct cl_target_option *callee_ptr, *caller_ptr; + unsigned int i; + + if (! callee_opts) + callee_opts = target_option_default_node; + if (! caller_opts) + caller_opts = target_option_default_node; + + /* If both caller and callee have attributes, assume that if the + pointer is different, the two functions have different target + options since build_target_option_node uses a hash table for the + options. */ + if (callee_opts == caller_opts) + return true; + + /* The only target options we recognize via function attributes are + those related to custom instructions. If we failed the above test, + check that any custom instructions enabled in the callee are also + enabled with the same value in the caller. */ + callee_ptr = TREE_TARGET_OPTION (callee_opts); + caller_ptr = TREE_TARGET_OPTION (caller_opts); + for (i = 0; i < ARRAY_SIZE (nios2_fpu_insn); i++) + if (callee_ptr->saved_fpu_custom_code[i] != -1 + && (callee_ptr->saved_fpu_custom_code[i] + != caller_ptr->saved_fpu_custom_code[i])) + return false; + return true; +} + /* Inner function to process the attribute((target(...))), take an argument and set the current options from the argument. If we have a list, recursively go over the list. */ @@ -5554,6 +5588,9 @@ nios2_adjust_reg_alloc_order (void) #undef TARGET_OPTION_RESTORE #define TARGET_OPTION_RESTORE nios2_option_restore +#undef TARGET_CAN_INLINE_P +#define TARGET_CAN_INLINE_P nios2_can_inline_p + #undef TARGET_SET_CURRENT_FUNCTION #define TARGET_SET_CURRENT_FUNCTION nios2_set_current_function |