diff --git a/gcc/gcc/calls.c b/gcc/gcc/calls.c index 9b387e75ab..8363adf35a 100644 --- a/gcc/gcc/calls.c +++ b/gcc/gcc/calls.c @@ -231,9 +231,9 @@ prepare_call_address (tree fndecl_or_type, rtx funexp, rtx static_chain_value, #ifndef NO_FUNCTION_CSE int is_magic = 0; - if (fndecl) + if (fndecl_or_type) { - tree fntype = TREE_TYPE(fndecl); + tree fntype = TREE_TYPE(fndecl_or_type); if(fntype && lookup_attribute ("raw_inline", TYPE_ATTRIBUTES (fntype))) is_magic = 1; } @@ -1199,7 +1199,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, /* Count arg position in order args appear. */ int argpos; - int i; + int i, inc; args_size->constant = 0; args_size->var = 0; @@ -1209,7 +1209,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, /* In this loop, we consider args in the order they are written. We fill up ARGS from the back. */ - if (PUSH_ARGS_REVERSED != reverse_args) + if (!reverse_args) { i = num_actuals - 1, inc = -1; /* In this case, must reverse order of args @@ -1231,7 +1231,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, if (struct_value_addr_value) { args[j].tree_value = struct_value_addr_value; - j--; + j += inc; /* If we pass structure address then we need to create bounds for it. Since created bounds is @@ -1244,8 +1244,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, = chkp_make_bounds_for_struct_addr (struct_value_addr_value); expand_expr_real (args[j].tree_value, args[j].value, VOIDmode, EXPAND_NORMAL, 0, false); - args[j].pointer_arg = j + 1; - j--; + args[j].pointer_arg = j + 1; // ### ??? + j += inc; } } FOR_EACH_CALL_EXPR_ARG (arg, iter, exp) @@ -1303,12 +1303,12 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, { tree subtype = TREE_TYPE (argtype); args[j].tree_value = build1 (REALPART_EXPR, subtype, arg); - j--; + j += inc; args[j].tree_value = build1 (IMAGPART_EXPR, subtype, arg); } else args[j].tree_value = arg; - j--; + j += inc; } if (slots) @@ -1318,7 +1318,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, bitmap_obstack_release (NULL); /* I counts args in order (to be) pushed; ARGPOS counts in order written. */ - for (argpos = 0; argpos < num_actuals; i--, argpos++) + for (argpos = 0; argpos < num_actuals; i += inc, argpos++) { tree type = TREE_TYPE (args[i].tree_value); int unsignedp; diff --git a/gcc/gcc/config/m68k/m68k-mac-pragmas.c b/gcc/gcc/config/m68k/m68k-mac-pragmas.c index 371afd0cd7..5a543ba156 100644 --- a/gcc/gcc/config/m68k/m68k-mac-pragmas.c +++ b/gcc/gcc/config/m68k/m68k-mac-pragmas.c @@ -6,6 +6,13 @@ #include "system.h" #include "coretypes.h" #include "tm.h" +#include "hash-set.h" +#include "vec.h" +#include "double-int.h" +#include "input.h" +#include "alias.h" +#include "symtab.h" +#include "inchash.h" #include "tree.h" #include "c-family/c-pragma.h" diff --git a/gcc/gcc/config/m68k/m68k-protos.h b/gcc/gcc/config/m68k/m68k-protos.h index 47dea2dc93..ace3a100f1 100644 --- a/gcc/gcc/config/m68k/m68k-protos.h +++ b/gcc/gcc/config/m68k/m68k-protos.h @@ -63,7 +63,7 @@ extern rtx m68k_legitimize_tls_address (rtx); extern bool m68k_tls_reference_p (rtx, bool); extern int valid_dbcc_comparison_p_2 (rtx, machine_mode); extern rtx m68k_libcall_value (machine_mode); -extern rtx m68k_function_value (const_tree, const_tree); +extern rtx m68k_function_value (const_tree, const_tree, bool); extern int emit_move_sequence (rtx *, machine_mode, rtx); extern bool m68k_movem_pattern_p (rtx, rtx, HOST_WIDE_INT, bool); extern const char *m68k_output_movem (rtx *, rtx, HOST_WIDE_INT, bool); diff --git a/gcc/gcc/config/m68k/m68k.c b/gcc/gcc/config/m68k/m68k.c index 3e182098af..6f356ded03 100644 --- a/gcc/gcc/config/m68k/m68k.c +++ b/gcc/gcc/config/m68k/m68k.c @@ -205,7 +205,6 @@ static rtx m68k_function_arg (cumulative_args_t, machine_mode, static bool m68k_cannot_force_const_mem (machine_mode mode, rtx x); static bool m68k_output_addr_const_extra (FILE *, rtx); static void m68k_init_sync_libfuncs (void) ATTRIBUTE_UNUSED; -static rtx m68k_function_value (const_tree, const_tree, bool); /* Initialize the GCC target structure. */ @@ -1585,114 +1584,6 @@ m68k_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, } -/* Return libcall result in A0 instead of usual D0. */ -static bool m68k_libcall_value_in_a0_p = false; - -/* Return floating point values in a 68881 register. This makes 68881 code - a little bit faster. It also makes -msoft-float code incompatible with - hard-float code, so people have to be careful not to mix the two. - For ColdFire it was decided the ABI incompatibility is undesirable. - If there is need for a hard-float ABI it is probably worth doing it - properly and also passing function arguments in FP registers. */ -rtx -m68k_libcall_value (enum machine_mode mode) -{ - switch (mode) { - case SFmode: - case DFmode: - case XFmode: - if (TARGET_68881) - return gen_rtx_REG (mode, FP0_REG); - break; - default: - break; - } - - return gen_rtx_REG (mode, m68k_libcall_value_in_a0_p ? A0_REG : D0_REG); -} - -/* Location in which function value is returned. */ -rtx -m68k_function_value (const_tree valtype, const_tree func_decl_or_type, bool outgoing) -{ - enum machine_mode mode; - - mode = TYPE_MODE (valtype); - - if(func_decl_or_type) - { - CUMULATIVE_ARGS cum; - const_tree decl = func_decl_or_type; - const_tree type = func_decl_or_type; - if(TREE_CODE(type) == FUNCTION_DECL) - type = TREE_TYPE(type); - else - decl = NULL; - m68k_init_cumulative_args(&cum, type, NULL, decl, -1); - if(cum.regparam) - return gen_rtx_REG (mode, cum.arg_regs[0]); - } - return gen_rtx_REG (mode, D0_REG); - - #if 0 - switch (mode) { - case SFmode: - case DFmode: - case XFmode: - if (TARGET_68881) - return gen_rtx_REG (mode, FP0_REG); - break; - default: - break; - } - - /* If the function returns a pointer, push that into %a0. */ - if (func && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (func)))) - /* For compatibility with the large body of existing code which - does not always properly declare external functions returning - pointer types, the m68k/SVR4 convention is to copy the value - returned for pointer functions from a0 to d0 in the function - epilogue, so that callers that have neglected to properly - declare the callee can still find the correct return value in - d0. */ - return gen_rtx_PARALLEL - (mode, - gen_rtvec (2, - gen_rtx_EXPR_LIST (VOIDmode, - gen_rtx_REG (mode, A0_REG), - const0_rtx), - gen_rtx_EXPR_LIST (VOIDmode, - gen_rtx_REG (mode, D0_REG), - const0_rtx))); - else if (POINTER_TYPE_P (valtype)) - return gen_rtx_REG (mode, A0_REG); - else - return gen_rtx_REG (mode, D0_REG); - #endif -} - -/* Worker function for TARGET_RETURN_IN_MEMORY. */ -#if M68K_HONOR_TARGET_STRICT_ALIGNMENT -static bool -m68k_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) -{ - enum machine_mode mode = TYPE_MODE (type); - - if (mode == BLKmode) - return true; - - /* If TYPE's known alignment is less than the alignment of MODE that - would contain the structure, then return in memory. We need to - do so to maintain the compatibility between code compiled with - -mstrict-align and that compiled with -mno-strict-align. */ - if (AGGREGATE_TYPE_P (type) - && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (mode)) - return true; - - return false; -} -#endif - /* Convert X to a legitimate function call memory reference and return the result. */ @@ -2738,6 +2629,9 @@ m68k_get_tls_get_addr (void) return m68k_tls_get_addr; } +/* Return libcall result in A0 instead of usual D0. */ +static bool m68k_libcall_value_in_a0_p = false; + /* Emit instruction sequence that calls __tls_get_addr. X is the TLS symbol we are referencing and RELOC is the symbol type to use (either TLSGD or TLSLDM). EQV is the REG_EQUAL note for the sequence @@ -5561,11 +5455,27 @@ m68k_libcall_value (enum machine_mode mode) NOTE: Due to differences in ABIs, don't call this function directly, use FUNCTION_VALUE instead. */ rtx -m68k_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED) +m68k_function_value (const_tree valtype, const_tree func_decl_or_type, bool outgoing) { enum machine_mode mode; mode = TYPE_MODE (valtype); + + const_tree decl = NULL, type = NULL; + if(func_decl_or_type) + { + CUMULATIVE_ARGS cum; + decl = func_decl_or_type; + type = func_decl_or_type; + if(TREE_CODE(type) == FUNCTION_DECL) + type = TREE_TYPE(type); + else + decl = NULL; + m68k_init_cumulative_args(&cum, type, NULL, decl, -1); + if(cum.regparam) + return gen_rtx_REG (mode, cum.arg_regs[0]); + } + switch (mode) { case SFmode: case DFmode: @@ -5578,7 +5488,7 @@ m68k_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED) } /* If the function returns a pointer, push that into %a0. */ - if (func && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (func)))) + if (type && POINTER_TYPE_P (TREE_TYPE (type)) && !outgoing) /* For compatibility with the large body of existing code which does not always properly declare external functions returning pointer types, the m68k/SVR4 convention is to copy the value