From: Kai Tietz Date: Thu, 8 May 2008 07:10:49 +0000 (+0200) Subject: 2008-05-07 Kai Tietz X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81464b2cd8f8153d1314a628fdc3dbdbb27a9c02;p=gcc.git 2008-05-07 Kai Tietz * calls.c (compute_argument_block_size): Add argument tree fndecl. (OUTGOING_REG_PARM_STACK_SPACE): Add function type argument. (emit_library_call_value_1): Add new variable fndecl initialized by NULL_TREE. It should be the decl type of orgfun, but this information seems not to be available here, so it uses the default calling abi. * config/arm/arm.c (arm_return_in_memory): Add fntype argumen. * config/arm/arm.h (RETURN_IN_MEMORY): Replace RETURN_IN_MEMORY by TARGET_RETURN_IN_MEMORY. * config/i386/i386-interix.h: Likewise. * config/i386/i386.h: Likewise. * config/i386/i386elf.h: Likewise. * config/i386/ptx4-i.h: Likewise. * config/i386/sol2-10.h: Likewise. * config/i386/sysv4.h: Likewise. * config/i386/vx-common.h: Likewise. * config/cris/cris.h: Removed #if 0 clause. * config/arm/arm-protos.h (arm_return_in_memory): Add fntype argument. * config/i386/i386-protos.h (ix86_return_in_memory): Add fntype argument. (ix86_sol10_return_in_memory): Likewise. (ix86_i386elf_return_in_memory): New. (ix86_i386interix_return_in_memory): New. * config/mt/mt-protos.h (mt_return_in_memory): New. * config/mt/mt.c: Likewise. * config/mt/mt.h (OUTGOING_REG_PARM_STACK_SPACE): Add FNTYPE argument. (RETURN_IN_MEMORY): Replace by TARGET_RETURN_IN_MEMORY. * config/bfin/bfin.h: Likewise. * config/bfin/bfin-protos.h (bfin_return_in_memory): Add fntype argument. * config/bfin/bfin.c: Likewise. * config/pa/pa.h (OUTGOING_REG_PARM_STACK_SPACE): Add FNTYPE argument. * config/alpha/unicosmk.h: Likewise. * config/i386/cygming.h: Likewise. * config/iq2000/iq2000.h: Likewise. * config/mips/mips.h: Likewise. * config/mn10300/mn10300.h: Likewise. * config/rs6000/rs6000.h: Likewise. * config/score/score.h: Likewise. * config/spu/spu.h: Likewise. * config/v850/v850.h: Likewise. * defaults.h: Likewise. * doc/tm.texi (OUTGOING_REG_PARM_STACK_SPACE): Adjust documentation. * expr.c (emit_block_move): Adjust use of OUTGOING_REG_PARM_STACK_SPACE. * function.c (STACK_DYNAMIC_OFFSET): Adjust use of OUTGOING_REG_PARM_STACK_SPACE. * targhooks.c (default_return_in_memory): Remove RETURN_IN_MEMORY. From-SVN: r135069 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1498db30288..681dbb48b63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,53 @@ +2008-05-08 Kai Tietz + + * calls.c (compute_argument_block_size): Add argument tree fndecl. + (OUTGOING_REG_PARM_STACK_SPACE): Add function type argument. + (emit_library_call_value_1): Add new variable fndecl initialized by + NULL_TREE. It should be the decl type of orgfun, but this information + seems not to be available here, so it uses the default calling abi. + * config/arm/arm.c (arm_return_in_memory): Add fntype argumen. + * config/arm/arm.h (RETURN_IN_MEMORY): Replace RETURN_IN_MEMORY + by TARGET_RETURN_IN_MEMORY. + * config/i386/i386-interix.h: Likewise. + * config/i386/i386.h: Likewise. + * config/i386/i386elf.h: Likewise. + * config/i386/ptx4-i.h: Likewise. + * config/i386/sol2-10.h: Likewise. + * config/i386/sysv4.h: Likewise. + * config/i386/vx-common.h: Likewise. + * config/cris/cris.h: Removed #if 0 clause. + * config/arm/arm-protos.h (arm_return_in_memory): Add fntype + argument. + * config/i386/i386-protos.h (ix86_return_in_memory): Add fntype + argument. + (ix86_sol10_return_in_memory): Likewise. + (ix86_i386elf_return_in_memory): New. + (ix86_i386interix_return_in_memory): New. + * config/mt/mt-protos.h (mt_return_in_memory): New. + * config/mt/mt.c: Likewise. + * config/mt/mt.h (OUTGOING_REG_PARM_STACK_SPACE): Add FNTYPE argument. + (RETURN_IN_MEMORY): Replace by TARGET_RETURN_IN_MEMORY. + * config/bfin/bfin.h: Likewise. + * config/bfin/bfin-protos.h (bfin_return_in_memory): Add fntype + argument. + * config/bfin/bfin.c: Likewise. + * config/pa/pa.h (OUTGOING_REG_PARM_STACK_SPACE): Add FNTYPE argument. + * config/alpha/unicosmk.h: Likewise. + * config/i386/cygming.h: Likewise. + * config/iq2000/iq2000.h: Likewise. + * config/mips/mips.h: Likewise. + * config/mn10300/mn10300.h: Likewise. + * config/rs6000/rs6000.h: Likewise. + * config/score/score.h: Likewise. + * config/spu/spu.h: Likewise. + * config/v850/v850.h: Likewise. + * defaults.h: Likewise. + * doc/tm.texi (OUTGOING_REG_PARM_STACK_SPACE): Adjust documentation. + * expr.c (emit_block_move): Adjust use of OUTGOING_REG_PARM_STACK_SPACE. + * function.c (STACK_DYNAMIC_OFFSET): Adjust use of + OUTGOING_REG_PARM_STACK_SPACE. + * targhooks.c (default_return_in_memory): Remove RETURN_IN_MEMORY. + 2008-05-08 Jakub Jelinek * tree-parloops.c (create_parallel_loop): Set OMP_RETURN_NOWAIT diff --git a/gcc/calls.c b/gcc/calls.c index 429ccb4ed23..b382a726c03 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -130,7 +130,7 @@ static void store_unaligned_arguments_into_pseudos (struct arg_data *, int); static int finalize_must_preallocate (int, int, struct arg_data *, struct args_size *); static void precompute_arguments (int, int, struct arg_data *); -static int compute_argument_block_size (int, struct args_size *, int); +static int compute_argument_block_size (int, struct args_size *, tree, int); static void initialize_argument_information (int, struct arg_data *, struct args_size *, int, tree, tree, @@ -1189,6 +1189,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, static int compute_argument_block_size (int reg_parm_stack_space, struct args_size *args_size, + tree fndecl, int preferred_stack_boundary ATTRIBUTE_UNUSED) { int unadjusted_args_size = args_size->constant; @@ -1226,7 +1227,7 @@ compute_argument_block_size (int reg_parm_stack_space, /* The area corresponding to register parameters is not to count in the size of the block we need. So make the adjustment. */ - if (!OUTGOING_REG_PARM_STACK_SPACE) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl)))) args_size->var = size_binop (MINUS_EXPR, args_size->var, ssize_int (reg_parm_stack_space)); @@ -1247,7 +1248,7 @@ compute_argument_block_size (int reg_parm_stack_space, args_size->constant = MAX (args_size->constant, reg_parm_stack_space); - if (!OUTGOING_REG_PARM_STACK_SPACE) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl)))) args_size->constant -= reg_parm_stack_space; } return unadjusted_args_size; @@ -2065,7 +2066,8 @@ expand_call (tree exp, rtx target, int ignore) reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl); #endif - if (!OUTGOING_REG_PARM_STACK_SPACE && reg_parm_stack_space > 0 && PUSH_ARGS) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl))) + && reg_parm_stack_space > 0 && PUSH_ARGS) must_preallocate = 1; /* Set up a place to return a structure. */ @@ -2394,6 +2396,7 @@ expand_call (tree exp, rtx target, int ignore) unadjusted_args_size = compute_argument_block_size (reg_parm_stack_space, &adjusted_args_size, + fndecl, (pass == 0 ? 0 : preferred_stack_boundary)); @@ -2469,7 +2472,7 @@ expand_call (tree exp, rtx target, int ignore) /* Since we will be writing into the entire argument area, the map must be allocated for its entire size, not just the part that is the responsibility of the caller. */ - if (!OUTGOING_REG_PARM_STACK_SPACE) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl)))) needed += reg_parm_stack_space; #ifdef ARGS_GROW_DOWNWARD @@ -2568,7 +2571,8 @@ expand_call (tree exp, rtx target, int ignore) { rtx push_size = GEN_INT (adjusted_args_size.constant - + (OUTGOING_REG_PARM_STACK_SPACE ? 0 + + (OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL + : TREE_TYPE (fndecl))) ? 0 : reg_parm_stack_space)); if (old_stack_level == 0) { @@ -2739,7 +2743,8 @@ expand_call (tree exp, rtx target, int ignore) /* If register arguments require space on the stack and stack space was not preallocated, allocate stack space here for arguments passed in registers. */ - if (OUTGOING_REG_PARM_STACK_SPACE && !ACCUMULATE_OUTGOING_ARGS + if (OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl))) + && !ACCUMULATE_OUTGOING_ARGS && must_preallocate == 0 && reg_parm_stack_space > 0) anti_adjust_stack (GEN_INT (reg_parm_stack_space)); @@ -3274,6 +3279,9 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, struct args_size original_args_size; int argnum; rtx fun; + /* Todo, choose the correct decl type of orgfun. Sadly this information + isn't present here, so we default to native calling abi here. */ + tree fndecl = NULL_TREE; /* library calls default to host calling abi ? */ int inc; int count; rtx argblock = 0; @@ -3552,7 +3560,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, args_size.constant = MAX (args_size.constant, reg_parm_stack_space); - if (!OUTGOING_REG_PARM_STACK_SPACE) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl)))) args_size.constant -= reg_parm_stack_space; if (args_size.constant > crtl->outgoing_args_size) @@ -3577,7 +3585,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, /* Since we will be writing into the entire argument area, the map must be allocated for its entire size, not just the part that is the responsibility of the caller. */ - if (!OUTGOING_REG_PARM_STACK_SPACE) + if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? NULL_TREE : TREE_TYPE (fndecl)))) needed += reg_parm_stack_space; #ifdef ARGS_GROW_DOWNWARD diff --git a/gcc/config/alpha/unicosmk.h b/gcc/config/alpha/unicosmk.h index d08fa73bc28..4a24bd59321 100644 --- a/gcc/config/alpha/unicosmk.h +++ b/gcc/config/alpha/unicosmk.h @@ -115,7 +115,7 @@ along with GCC; see the file COPYING3. If not see in registers) are allocated. */ #define REG_PARM_STACK_SPACE(DECL) 48 -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* If an argument can't be passed in registers even though not all argument registers have been used yet, it is passed on the stack in the space diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 3a71744ea9e..e4540ec125d 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -43,7 +43,7 @@ extern void arm_output_fn_unwind (FILE *, bool); #ifdef TREE_CODE -extern int arm_return_in_memory (const_tree); +extern int arm_return_in_memory (const_tree, const_tree); #endif #ifdef RTX_CODE extern bool arm_vector_mode_supported_p (enum machine_mode); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 64f12a16001..3a8117288a6 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2736,9 +2736,9 @@ arm_apply_result_size (void) /* Decide whether a type should be returned in memory (true) or in a register (false). This is called by the macro - RETURN_IN_MEMORY. */ + TARGET_RETURN_IN_MEMORY. */ int -arm_return_in_memory (const_tree type) +arm_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { HOST_WIDE_INT size; @@ -2801,7 +2801,7 @@ arm_return_in_memory (const_tree type) /* ... Aggregates that are not themselves valid for returning in a register are not allowed. */ - if (RETURN_IN_MEMORY (TREE_TYPE (field))) + if (arm_return_in_memory (TREE_TYPE (field), NULL_TREE)) return 1; /* Now check the remaining fields, if any. Only bitfields are allowed, @@ -2836,7 +2836,7 @@ arm_return_in_memory (const_tree type) if (FLOAT_TYPE_P (TREE_TYPE (field))) return 1; - if (RETURN_IN_MEMORY (TREE_TYPE (field))) + if (arm_return_in_memory (TREE_TYPE (field), NULL_TREE)) return 1; } diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index b6e182c0d22..7f10a5797d8 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1481,7 +1481,7 @@ do { \ /* How large values are returned */ /* A C expression which can inhibit the returning of certain function values in registers, based on the type of value. */ -#define RETURN_IN_MEMORY(TYPE) arm_return_in_memory (TYPE) +#define TARGET_RETURN_IN_MEMORY arm_return_in_memory /* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return values must be in memory. On the ARM, they need only do so if larger diff --git a/gcc/config/arm/netbsd.h b/gcc/config/arm/netbsd.h index 33833cc71fc..d9d39bd1466 100644 --- a/gcc/config/arm/netbsd.h +++ b/gcc/config/arm/netbsd.h @@ -101,7 +101,7 @@ /* Although not normally relevant (since by default, all aggregates are returned in memory) compiling some parts of libc requires non-APCS style struct returns. */ -#undef RETURN_IN_MEMORY +#undef TARGET_RETURN_IN_MEMORY /* VERY BIG NOTE : Change of structure alignment for RiscBSD. There are consequences you should be aware of... diff --git a/gcc/config/bfin/bfin-protos.h b/gcc/config/bfin/bfin-protos.h index 1786f5c36e4..1dc46f7657e 100644 --- a/gcc/config/bfin/bfin-protos.h +++ b/gcc/config/bfin/bfin-protos.h @@ -120,7 +120,7 @@ extern void asm_conditional_branch (rtx, rtx *, int, int); extern rtx bfin_gen_compare (rtx, Mmode); extern int bfin_local_alignment (tree, int); -extern int bfin_return_in_memory (const_tree); +extern int bfin_return_in_memory (const_tree, const_tree); extern void initialize_trampoline (rtx, rtx, rtx); extern bool bfin_legitimate_address_p (Mmode, rtx, int); extern rtx bfin_va_arg (tree, tree); diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 87a1d9360b4..e4c3f0c7832 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -1840,10 +1840,10 @@ bfin_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED, /* Decide whether a type should be returned in memory (true) or in a register (false). This is called by the macro - RETURN_IN_MEMORY. */ + TARGET_RETURN_IN_MEMORY. */ int -bfin_return_in_memory (const_tree type) +bfin_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { int size = int_size_in_bytes (type); return size > 2 * UNITS_PER_WORD || size == -1; diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h index 3850c62ee38..55a6b7d2de3 100644 --- a/gcc/config/bfin/bfin.h +++ b/gcc/config/bfin/bfin.h @@ -283,7 +283,7 @@ extern const char *bfin_library_id_string; /* Define this if the above stack space is to be considered part of the * space allocated by the caller. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* Define this if the maximum size of all the outgoing args is to be accumulated and pushed during the prologue. The amount can be @@ -841,7 +841,7 @@ typedef struct { #define FUNCTION_VALUE_REGNO_P(N) ((N) == REG_R0) #define DEFAULT_PCC_STRUCT_RETURN 0 -#define RETURN_IN_MEMORY(TYPE) bfin_return_in_memory(TYPE) +#define TARGET_RETURN_IN_MEMORY bfin_return_in_memory /* Before the prologue, the return address is in the RETS register. */ #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, REG_RETS) diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index b8f4ae56713..915c3143ceb 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -923,14 +923,6 @@ struct cum_args {int regs;}; /* Node: Aggregate Return */ -#if 0 -/* FIXME: Let's try this some time, so we return structures in registers. - We would cast the result of int_size_in_bytes to unsigned, so we will - get a huge number for "structures" of variable size (-1). */ -#define RETURN_IN_MEMORY(TYPE) \ - ((unsigned) int_size_in_bytes (TYPE) > CRIS_MAX_ARGS_IN_REGS * UNITS_PER_WORD) -#endif - #define CRIS_STRUCT_VALUE_REGNUM ((CRIS_FIRST_ARG_REG) - 1) diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h index 0f7592d490a..95bdcc33d46 100644 --- a/gcc/config/fr30/fr30.h +++ b/gcc/config/fr30/fr30.h @@ -726,7 +726,7 @@ enum reg_class in memory. Since this results in slower code, this should be defined only if needed for compatibility with other compilers or with an ABI. If you define this macro to be 0, then the conventions used for structure and union - return values are decided by the `RETURN_IN_MEMORY' macro. + return values are decided by the `TARGET_RETURN_IN_MEMORY' macro. If not defined, this defaults to the value 1. */ #define DEFAULT_PCC_STRUCT_RETURN 1 diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index 65311da0601..a6537bc60d3 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -127,7 +127,7 @@ along with GCC; see the file COPYING3. If not see #define REG_PARM_STACK_SPACE(FNDECL) (TARGET_64BIT_MS_ABI ? 32 : 0) #undef OUTGOING_REG_PARM_STACK_SPACE -#define OUTGOING_REG_PARM_STACK_SPACE (TARGET_64BIT_MS_ABI ? 1 : 0) +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) (TARGET_64BIT_MS_ABI ? 1 : 0) #undef REGPARM_MAX #define REGPARM_MAX (TARGET_64BIT_MS_ABI ? 4 : 3) diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h index 701536049e3..74e2892b545 100644 --- a/gcc/config/i386/i386-interix.h +++ b/gcc/config/i386/i386-interix.h @@ -357,7 +357,5 @@ extern void i386_pe_unique_section (tree, int); #define DEFAULT_PCC_STRUCT_RETURN 0 -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY(TYPE) \ - (TYPE_MODE (TYPE) == BLKmode || \ - (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 )) +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_i386interix_return_in_memory diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 369953f7c96..fd2e3c7c59c 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -134,9 +134,10 @@ extern rtx ix86_libcall_value (enum machine_mode); extern bool ix86_function_value_regno_p (int); extern bool ix86_function_arg_regno_p (int); extern int ix86_function_arg_boundary (enum machine_mode, tree); -extern int ix86_return_in_memory (const_tree); -extern int ix86_sol10_return_in_memory (const_tree); - +extern int ix86_return_in_memory (const_tree, const_tree); +extern int ix86_sol10_return_in_memory (const_tree,const_tree); +extern int ix86_i386elf_return_in_memory (const_tree,const_tree); +extern int ix86_i386interix_return_in_memory (const_tree,const_tree); extern rtx ix86_force_to_memory (enum machine_mode, rtx); extern void ix86_free_from_memory (enum machine_mode); extern void ix86_split_fp_branch (enum rtx_code code, rtx, rtx, diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7d254fec8cb..0cb337fd4a4 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4902,7 +4902,7 @@ return_in_memory_ms_64 (const_tree type, enum machine_mode mode) } int -ix86_return_in_memory (const_tree type) +ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { const enum machine_mode mode = type_natural_mode (type); @@ -4920,7 +4920,7 @@ ix86_return_in_memory (const_tree type) are returned in memory, rather than in MMX registers. */ int -ix86_sol10_return_in_memory (const_tree type) +ix86_sol10_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { int size; enum machine_mode mode = type_natural_mode (type); @@ -4951,6 +4951,20 @@ ix86_sol10_return_in_memory (const_tree type) return size > 12; } +int +ix86_i386elf_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) +{ + return (TYPE_MODE (type) == BLKmode + || (VECTOR_MODE_P (TYPE_MODE (type)) && int_size_in_bytes (type) == 8)); +} + +int +ix86_i386interix_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) +{ + return (TYPE_MODE (type) == BLKmode + || (AGGREGATE_TYPE_P (type) && int_size_in_bytes(type) > 8 )); +} + /* When returning SSE vector types, we have a choice of either (1) being abi incompatible with a -march switch, or (2) generating an error. @@ -4959,7 +4973,7 @@ ix86_sol10_return_in_memory (const_tree type) Choose the STRUCT_VALUE_RTX hook because that's (at present) only called in response to actually generating a caller or callee that - uses such a type. As opposed to RETURN_IN_MEMORY, which is called + uses such a type. As opposed to TARGET_RETURN_IN_MEMORY, which is called via aggregate_value_p for general type probing from tree-ssa. */ static rtx diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index bb6fa18d99d..87815edaf72 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1278,8 +1278,7 @@ do { \ should always be returned in memory. You should instead use `DEFAULT_PCC_STRUCT_RETURN' to indicate this. */ -#define RETURN_IN_MEMORY(TYPE) \ - ix86_return_in_memory (TYPE) +#define TARGET_RETURN_IN_MEMORY ix86_return_in_memory /* This is overridden by . */ #define MS_AGGREGATE_RETURN 0 diff --git a/gcc/config/i386/i386elf.h b/gcc/config/i386/i386elf.h index cd42f88c52e..6659669ba8a 100644 --- a/gcc/config/i386/i386elf.h +++ b/gcc/config/i386/i386elf.h @@ -29,10 +29,8 @@ along with GCC; see the file COPYING3. If not see /* The ELF ABI for the i386 says that records and unions are returned in memory. */ -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY(TYPE) \ - (TYPE_MODE (TYPE) == BLKmode \ - || (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8)) +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_i386elf_return_in_memory #undef CPP_SPEC #define CPP_SPEC "" diff --git a/gcc/config/i386/ptx4-i.h b/gcc/config/i386/ptx4-i.h index 3c46e6ad098..08473f0c109 100644 --- a/gcc/config/i386/ptx4-i.h +++ b/gcc/config/i386/ptx4-i.h @@ -27,10 +27,8 @@ along with GCC; see the file COPYING3. If not see /* The svr4 ABI for the i386 says that records and unions are returned in memory. */ -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY(TYPE) \ - (TYPE_MODE (TYPE) == BLKmode \ - || (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8)) +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_i386elf_return_in_memory #define TARGET_OS_CPP_BUILTINS() \ do \ diff --git a/gcc/config/i386/sol2-10.h b/gcc/config/i386/sol2-10.h index 92e2c6c230f..88b92f6afb6 100644 --- a/gcc/config/i386/sol2-10.h +++ b/gcc/config/i386/sol2-10.h @@ -110,5 +110,5 @@ along with GCC; see the file COPYING3. If not see #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION i386_solaris_elf_named_section -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY ix86_sol10_return_in_memory +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_sol10_return_in_memory diff --git a/gcc/config/i386/sysv4.h b/gcc/config/i386/sysv4.h index e1052724937..e57fd0c5b0a 100644 --- a/gcc/config/i386/sysv4.h +++ b/gcc/config/i386/sysv4.h @@ -25,10 +25,8 @@ along with GCC; see the file COPYING3. If not see /* The svr4 ABI for the i386 says that records and unions are returned in memory. */ -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY(TYPE) \ - (TYPE_MODE (TYPE) == BLKmode \ - || (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8)) +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_i386elf_return_in_memory /* Output at beginning of assembler file. */ /* The .file command should always begin the output. */ diff --git a/gcc/config/i386/vx-common.h b/gcc/config/i386/vx-common.h index 2544189611c..81530bc90f6 100644 --- a/gcc/config/i386/vx-common.h +++ b/gcc/config/i386/vx-common.h @@ -22,5 +22,5 @@ along with GCC; see the file COPYING3. If not see /* VxWorks uses the same ABI as Solaris 10. */ -#undef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY ix86_sol10_return_in_memory +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY ix86_sol10_return_in_memory diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h index cdbf5a2b3f2..f5574e4d757 100644 --- a/gcc/config/iq2000/iq2000.h +++ b/gcc/config/iq2000/iq2000.h @@ -374,7 +374,7 @@ enum reg_class #define REG_PARM_STACK_SPACE(FNDECL) 0 -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0 diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index cda433aa4f0..1391c99dde4 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -1936,7 +1936,7 @@ enum reg_class If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect of this macro is to determine whether the space is included in `crtl->outgoing_args_size'. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 #define STACK_BOUNDARY (TARGET_NEWABI ? 128 : 64) diff --git a/gcc/config/mn10300/mn10300.h b/gcc/config/mn10300/mn10300.h index 824227546f0..1d2339b6b15 100644 --- a/gcc/config/mn10300/mn10300.h +++ b/gcc/config/mn10300/mn10300.h @@ -486,7 +486,7 @@ enum reg_class { /* We use d0/d1 for passing parameters, so allocate 8 bytes of space for a register flushback area. */ #define REG_PARM_STACK_SPACE(DECL) 8 -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 #define ACCUMULATE_OUTGOING_ARGS 1 /* So we can allocate space for return pointers once for the function diff --git a/gcc/config/mt/mt-protos.h b/gcc/config/mt/mt-protos.h index 99717dc5eff..2dcb9454ecf 100644 --- a/gcc/config/mt/mt-protos.h +++ b/gcc/config/mt/mt-protos.h @@ -31,6 +31,7 @@ extern void mt_add_loop (void); extern const char * mt_cannot_inline_p (tree); extern int mt_function_arg_boundary (enum machine_mode, tree); extern void mt_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int); +extern int mt_return_in_memory (const_tree,const_tree); #endif #ifdef RTX_CODE diff --git a/gcc/config/mt/mt.c b/gcc/config/mt/mt.c index 272e028b902..c7fc0d129f3 100644 --- a/gcc/config/mt/mt.c +++ b/gcc/config/mt/mt.c @@ -2460,6 +2460,13 @@ mt_machine_reorg (void) mt_reorg_hazard (); } } + +int +mt_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) +{ + return (int_size_in_bytes (type) > UNITS_PER_WORD); +} + /* Initialize the GCC target structure. */ const struct attribute_spec mt_attribute_table[]; diff --git a/gcc/config/mt/mt.h b/gcc/config/mt/mt.h index de20d40eb5a..b587326e281 100644 --- a/gcc/config/mt/mt.h +++ b/gcc/config/mt/mt.h @@ -532,7 +532,7 @@ extern struct mt_frame_info current_frame_info; /* Define this if it is the responsibility of the caller to allocate the area reserved for arguments passed in registers. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* The number of register assigned to holding function arguments. */ #define MT_NUM_ARG_REGS 4 @@ -580,7 +580,7 @@ extern struct mt_frame_info current_frame_info; /* A C expression which can inhibit the returning of certain function values in registers, based on the type of value. */ -#define RETURN_IN_MEMORY(TYPE) (int_size_in_bytes (TYPE) > UNITS_PER_WORD) +#define TARGET_RETURN_IN_MEMORY mt_return_in_memory /* Define this macro to be 1 if all structure and union return values must be in memory. */ diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 541f2e3069f..22cd9f33f32 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -549,7 +549,7 @@ extern struct rtx_def *hppa_pic_save_rtx (void); /* Define this if the above stack space is to be considered part of the space allocated by the caller. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* Keep the stack pointer constant throughout the function. This is both an optimization and a necessity: longjmp diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 1bde282172b..7ec3d9447cc 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1327,7 +1327,7 @@ extern enum rs6000_abi rs6000_current_abi; /* available for use by subtarget */ /* Define this if the above stack space is to be considered part of the space allocated by the caller. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* This is the difference between the logical top of stack and the actual sp. diff --git a/gcc/config/score/score.h b/gcc/config/score/score.h index fe6e6f9b770..78d2c574e1a 100644 --- a/gcc/config/score/score.h +++ b/gcc/config/score/score.h @@ -579,7 +579,7 @@ extern enum reg_class score_char_to_class[256]; If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect of this macro is to determine whether the space is included in `crtl->outgoing_args_size'. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0 diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h index 3d038cab46e..729e0d707a8 100644 --- a/gcc/config/spu/spu.h +++ b/gcc/config/spu/spu.h @@ -353,7 +353,7 @@ targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin; \ #define REG_PARM_STACK_SPACE(FNDECL) 0 -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) (0) diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index 50119c2a197..b951b2cce41 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -625,7 +625,7 @@ struct cum_arg { int nbytes; int anonymous_args; }; /* Define this if the above stack space is to be considered part of the space allocated by the caller. */ -#define OUTGOING_REG_PARM_STACK_SPACE 1 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 /* 1 if N is a possible register number for function argument passing. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index ef2dcb76981..cc41b6e6612 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -937,7 +937,7 @@ along with GCC; see the file COPYING3. If not see #endif #ifndef OUTGOING_REG_PARM_STACK_SPACE -#define OUTGOING_REG_PARM_STACK_SPACE 0 +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 0 #endif #endif /* ! GCC_DEFAULTS_H */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 3c015602298..91448a71a42 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -3819,9 +3819,11 @@ which. @c above is overfull. not sure what to do. --mew 5feb93 did @c something, not sure if it looks good. --mew 10feb93 -@defmac OUTGOING_REG_PARM_STACK_SPACE -Define this to a nonzero value if it is the responsibility of the caller -to allocate the area reserved for arguments passed in registers. +@defmac OUTGOING_REG_PARM_STACK_SPACE (@var{fntype}) +Define this to a nonzero value if it is the responsibility of the +caller to allocate the area reserved for arguments passed in registers +when calling a function of @var{fntype}. @var{fntype} may be NULL +if the function called is a library function. If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls whether the space for these arguments counts in the value of diff --git a/gcc/expr.c b/gcc/expr.c index 141904f1231..ae25d40a681 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -1259,6 +1259,10 @@ emit_block_move (rtx x, rtx y, rtx size, enum block_op_methods method) static bool block_move_libcall_safe_for_call_parm (void) { +#if defined (REG_PARM_STACK_SPACE) + tree fn; +#endif + /* If arguments are pushed on the stack, then they're safe. */ if (PUSH_ARGS) return true; @@ -1266,13 +1270,10 @@ block_move_libcall_safe_for_call_parm (void) /* If registers go on the stack anyway, any argument is sure to clobber an outgoing argument. */ #if defined (REG_PARM_STACK_SPACE) - if (OUTGOING_REG_PARM_STACK_SPACE) - { - tree fn; - fn = emit_block_move_libcall_fn (false); - if (REG_PARM_STACK_SPACE (fn) != 0) - return false; - } + fn = emit_block_move_libcall_fn (false); + if (OUTGOING_REG_PARM_STACK_SPACE ((!fn ? NULL_TREE : TREE_TYPE (fn))) + && REG_PARM_STACK_SPACE (fn) != 0) + return false; #endif /* If any argument goes in memory, then it might clobber an outgoing diff --git a/gcc/function.c b/gcc/function.c index 5d70ddd3f9f..29d4c1eda6e 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -1147,7 +1147,8 @@ static int cfa_offset; #define STACK_DYNAMIC_OFFSET(FNDECL) \ ((ACCUMULATE_OUTGOING_ARGS \ ? (crtl->outgoing_args_size \ - + (OUTGOING_REG_PARM_STACK_SPACE ? 0 : REG_PARM_STACK_SPACE (FNDECL))) \ + + (OUTGOING_REG_PARM_STACK_SPACE ((!(FNDECL) ? NULL_TREE : TREE_TYPE (FNDECL))) ? 0 \ + : REG_PARM_STACK_SPACE (FNDECL))) \ : 0) + (STACK_POINTER_OFFSET)) #else #define STACK_DYNAMIC_OFFSET(FNDECL) \ @@ -3850,7 +3851,7 @@ allocate_struct_function (tree fndecl, bool abstract_p) if (init_machine_status) cfun->machine = (*init_machine_status) (); - if (fndecl != NULL) + if (fndecl != NULL_TREE) { DECL_STRUCT_FUNCTION (fndecl) = cfun; cfun->decl = fndecl; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index bfd1905e1d3..d719f5f2195 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -107,11 +107,7 @@ bool default_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { -#ifndef RETURN_IN_MEMORY return (TYPE_MODE (type) == BLKmode); -#else - return RETURN_IN_MEMORY (type); -#endif } rtx