Message ID | 1395257479.17148.11.camel@gnopaine |
---|---|
State | New |
Headers | show |
On Wed, 19 Mar 2014, Bill Schmidt wrote: > Hi, > > This patch (diff-abi-calls) backports fixes to common code to support > the new ELFv2 ABI. Copying Richard and Jakub for these bits. Ok. Thanks, Richard. > Thanks, > Bill > > > 2014-03-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com> > > Backport from mainline r204798: > > 2013-11-14 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> > Alan Modra <amodra@gmail.com> > > * function.c (assign_parms): Use all.reg_parm_stack_space instead > of re-evaluating REG_PARM_STACK_SPACE target macro. > (locate_and_pad_parm): New parameter REG_PARM_STACK_SPACE. Use it > instead of evaluating target macro REG_PARM_STACK_SPACE every time. > (assign_parm_find_entry_rtl): Update call. > * calls.c (initialize_argument_information): Update call. > (emit_library_call_value_1): Likewise. > * expr.h (locate_and_pad_parm): Update prototype. > > Backport from mainline r204797: > > 2013-11-14 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> > > * calls.c (store_unaligned_arguments_into_pseudos): Skip PARALLEL > arguments. > > Backport from mainline r197003: > > 2013-03-23 Eric Botcazou <ebotcazou@adacore.com> > > * calls.c (expand_call): Add missing guard to code handling return > of non-BLKmode structures in MSB. > * function.c (expand_function_end): Likewise. > > > Index: gcc-4_8-branch/gcc/calls.c > =================================================================== > --- gcc-4_8-branch.orig/gcc/calls.c 2013-12-28 17:41:32.056627059 +0100 > +++ gcc-4_8-branch/gcc/calls.c 2013-12-28 17:50:43.356356135 +0100 > @@ -983,6 +983,7 @@ store_unaligned_arguments_into_pseudos ( > > for (i = 0; i < num_actuals; i++) > if (args[i].reg != 0 && ! args[i].pass_on_stack > + && GET_CODE (args[i].reg) != PARALLEL > && args[i].mode == BLKmode > && MEM_P (args[i].value) > && (MEM_ALIGN (args[i].value) > @@ -1327,6 +1328,7 @@ initialize_argument_information (int num > #else > args[i].reg != 0, > #endif > + reg_parm_stack_space, > args[i].pass_on_stack ? 0 : args[i].partial, > fndecl, args_size, &args[i].locate); > #ifdef BLOCK_REG_PADDING > @@ -3171,7 +3173,9 @@ expand_call (tree exp, rtx target, int i > group load/store machinery below. */ > if (!structure_value_addr > && !pcc_struct_value > + && TYPE_MODE (rettype) != VOIDmode > && TYPE_MODE (rettype) != BLKmode > + && REG_P (valreg) > && targetm.calls.return_in_msb (rettype)) > { > if (shift_return_value (TYPE_MODE (rettype), false, valreg)) > @@ -3734,7 +3738,8 @@ emit_library_call_value_1 (int retval, r > #else > argvec[count].reg != 0, > #endif > - 0, NULL_TREE, &args_size, &argvec[count].locate); > + reg_parm_stack_space, 0, > + NULL_TREE, &args_size, &argvec[count].locate); > > if (argvec[count].reg == 0 || argvec[count].partial != 0 > || reg_parm_stack_space > 0) > @@ -3821,7 +3826,7 @@ emit_library_call_value_1 (int retval, r > #else > argvec[count].reg != 0, > #endif > - argvec[count].partial, > + reg_parm_stack_space, argvec[count].partial, > NULL_TREE, &args_size, &argvec[count].locate); > args_size.constant += argvec[count].locate.size.constant; > gcc_assert (!argvec[count].locate.size.var); > Index: gcc-4_8-branch/gcc/function.c > =================================================================== > --- gcc-4_8-branch.orig/gcc/function.c 2013-12-28 17:41:32.056627059 +0100 > +++ gcc-4_8-branch/gcc/function.c 2013-12-28 17:50:43.362356165 +0100 > @@ -2507,6 +2507,7 @@ assign_parm_find_entry_rtl (struct assig > } > > locate_and_pad_parm (data->promoted_mode, data->passed_type, in_regs, > + all->reg_parm_stack_space, > entry_parm ? data->partial : 0, current_function_decl, > &all->stack_args_size, &data->locate); > > @@ -3485,11 +3486,7 @@ assign_parms (tree fndecl) > /* Adjust function incoming argument size for alignment and > minimum length. */ > > -#ifdef REG_PARM_STACK_SPACE > - crtl->args.size = MAX (crtl->args.size, > - REG_PARM_STACK_SPACE (fndecl)); > -#endif > - > + crtl->args.size = MAX (crtl->args.size, all.reg_parm_stack_space); > crtl->args.size = CEIL_ROUND (crtl->args.size, > PARM_BOUNDARY / BITS_PER_UNIT); > > @@ -3693,6 +3690,9 @@ gimplify_parameters (void) > IN_REGS is nonzero if the argument will be passed in registers. It will > never be set if REG_PARM_STACK_SPACE is not defined. > > + REG_PARM_STACK_SPACE is the number of bytes of stack space reserved > + for arguments which are passed in registers. > + > FNDECL is the function in which the argument was defined. > > There are two types of rounding that are done. The first, controlled by > @@ -3713,19 +3713,16 @@ gimplify_parameters (void) > > void > locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, > - int partial, tree fndecl ATTRIBUTE_UNUSED, > + int reg_parm_stack_space, int partial, > + tree fndecl ATTRIBUTE_UNUSED, > struct args_size *initial_offset_ptr, > struct locate_and_pad_arg_data *locate) > { > tree sizetree; > enum direction where_pad; > unsigned int boundary, round_boundary; > - int reg_parm_stack_space = 0; > int part_size_in_regs; > > -#ifdef REG_PARM_STACK_SPACE > - reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl); > - > /* If we have found a stack parm before we reach the end of the > area reserved for registers, skip that area. */ > if (! in_regs) > @@ -3743,7 +3740,6 @@ locate_and_pad_parm (enum machine_mode p > initial_offset_ptr->constant = reg_parm_stack_space; > } > } > -#endif /* REG_PARM_STACK_SPACE */ > > part_size_in_regs = (reg_parm_stack_space == 0 ? partial : 0); > > @@ -3806,11 +3802,7 @@ locate_and_pad_parm (enum machine_mode p > > locate->slot_offset.constant += part_size_in_regs; > > - if (!in_regs > -#ifdef REG_PARM_STACK_SPACE > - || REG_PARM_STACK_SPACE (fndecl) > 0 > -#endif > - ) > + if (!in_regs || reg_parm_stack_space > 0) > pad_to_arg_alignment (&locate->slot_offset, boundary, > &locate->alignment_pad); > > @@ -3830,11 +3822,7 @@ locate_and_pad_parm (enum machine_mode p > pad_below (&locate->offset, passed_mode, sizetree); > > #else /* !ARGS_GROW_DOWNWARD */ > - if (!in_regs > -#ifdef REG_PARM_STACK_SPACE > - || REG_PARM_STACK_SPACE (fndecl) > 0 > -#endif > - ) > + if (!in_regs || reg_parm_stack_space > 0) > pad_to_arg_alignment (initial_offset_ptr, boundary, > &locate->alignment_pad); > locate->slot_offset = *initial_offset_ptr; > @@ -5093,6 +5081,7 @@ expand_function_end (void) > amount. BLKmode results are handled using the group load/store > machinery. */ > if (TYPE_MODE (TREE_TYPE (decl_result)) != BLKmode > + && REG_P (real_decl_rtl) > && targetm.calls.return_in_msb (TREE_TYPE (decl_result))) > { > emit_move_insn (gen_rtx_REG (GET_MODE (decl_rtl), > Index: gcc-4_8-branch/gcc/expr.h > =================================================================== > --- gcc-4_8-branch.orig/gcc/expr.h 2013-12-28 17:41:32.056627059 +0100 > +++ gcc-4_8-branch/gcc/expr.h 2013-12-28 17:50:43.366356185 +0100 > @@ -521,8 +521,8 @@ extern rtx expand_divmod (int, enum tree > rtx, int); > #endif > > -extern void locate_and_pad_parm (enum machine_mode, tree, int, int, tree, > - struct args_size *, > +extern void locate_and_pad_parm (enum machine_mode, tree, int, int, int, > + tree, struct args_size *, > struct locate_and_pad_arg_data *); > > /* Return the CODE_LABEL rtx for a LABEL_DECL, creating it if necessary. */ > > > >
Index: gcc-4_8-branch/gcc/calls.c =================================================================== --- gcc-4_8-branch.orig/gcc/calls.c 2013-12-28 17:41:32.056627059 +0100 +++ gcc-4_8-branch/gcc/calls.c 2013-12-28 17:50:43.356356135 +0100 @@ -983,6 +983,7 @@ store_unaligned_arguments_into_pseudos ( for (i = 0; i < num_actuals; i++) if (args[i].reg != 0 && ! args[i].pass_on_stack + && GET_CODE (args[i].reg) != PARALLEL && args[i].mode == BLKmode && MEM_P (args[i].value) && (MEM_ALIGN (args[i].value) @@ -1327,6 +1328,7 @@ initialize_argument_information (int num #else args[i].reg != 0, #endif + reg_parm_stack_space, args[i].pass_on_stack ? 0 : args[i].partial, fndecl, args_size, &args[i].locate); #ifdef BLOCK_REG_PADDING @@ -3171,7 +3173,9 @@ expand_call (tree exp, rtx target, int i group load/store machinery below. */ if (!structure_value_addr && !pcc_struct_value + && TYPE_MODE (rettype) != VOIDmode && TYPE_MODE (rettype) != BLKmode + && REG_P (valreg) && targetm.calls.return_in_msb (rettype)) { if (shift_return_value (TYPE_MODE (rettype), false, valreg)) @@ -3734,7 +3738,8 @@ emit_library_call_value_1 (int retval, r #else argvec[count].reg != 0, #endif - 0, NULL_TREE, &args_size, &argvec[count].locate); + reg_parm_stack_space, 0, + NULL_TREE, &args_size, &argvec[count].locate); if (argvec[count].reg == 0 || argvec[count].partial != 0 || reg_parm_stack_space > 0) @@ -3821,7 +3826,7 @@ emit_library_call_value_1 (int retval, r #else argvec[count].reg != 0, #endif - argvec[count].partial, + reg_parm_stack_space, argvec[count].partial, NULL_TREE, &args_size, &argvec[count].locate); args_size.constant += argvec[count].locate.size.constant; gcc_assert (!argvec[count].locate.size.var); Index: gcc-4_8-branch/gcc/function.c =================================================================== --- gcc-4_8-branch.orig/gcc/function.c 2013-12-28 17:41:32.056627059 +0100 +++ gcc-4_8-branch/gcc/function.c 2013-12-28 17:50:43.362356165 +0100 @@ -2507,6 +2507,7 @@ assign_parm_find_entry_rtl (struct assig } locate_and_pad_parm (data->promoted_mode, data->passed_type, in_regs, + all->reg_parm_stack_space, entry_parm ? data->partial : 0, current_function_decl, &all->stack_args_size, &data->locate); @@ -3485,11 +3486,7 @@ assign_parms (tree fndecl) /* Adjust function incoming argument size for alignment and minimum length. */ -#ifdef REG_PARM_STACK_SPACE - crtl->args.size = MAX (crtl->args.size, - REG_PARM_STACK_SPACE (fndecl)); -#endif - + crtl->args.size = MAX (crtl->args.size, all.reg_parm_stack_space); crtl->args.size = CEIL_ROUND (crtl->args.size, PARM_BOUNDARY / BITS_PER_UNIT); @@ -3693,6 +3690,9 @@ gimplify_parameters (void) IN_REGS is nonzero if the argument will be passed in registers. It will never be set if REG_PARM_STACK_SPACE is not defined. + REG_PARM_STACK_SPACE is the number of bytes of stack space reserved + for arguments which are passed in registers. + FNDECL is the function in which the argument was defined. There are two types of rounding that are done. The first, controlled by @@ -3713,19 +3713,16 @@ gimplify_parameters (void) void locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, - int partial, tree fndecl ATTRIBUTE_UNUSED, + int reg_parm_stack_space, int partial, + tree fndecl ATTRIBUTE_UNUSED, struct args_size *initial_offset_ptr, struct locate_and_pad_arg_data *locate) { tree sizetree; enum direction where_pad; unsigned int boundary, round_boundary; - int reg_parm_stack_space = 0; int part_size_in_regs; -#ifdef REG_PARM_STACK_SPACE - reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl); - /* If we have found a stack parm before we reach the end of the area reserved for registers, skip that area. */ if (! in_regs) @@ -3743,7 +3740,6 @@ locate_and_pad_parm (enum machine_mode p initial_offset_ptr->constant = reg_parm_stack_space; } } -#endif /* REG_PARM_STACK_SPACE */ part_size_in_regs = (reg_parm_stack_space == 0 ? partial : 0); @@ -3806,11 +3802,7 @@ locate_and_pad_parm (enum machine_mode p locate->slot_offset.constant += part_size_in_regs; - if (!in_regs -#ifdef REG_PARM_STACK_SPACE - || REG_PARM_STACK_SPACE (fndecl) > 0 -#endif - ) + if (!in_regs || reg_parm_stack_space > 0) pad_to_arg_alignment (&locate->slot_offset, boundary, &locate->alignment_pad); @@ -3830,11 +3822,7 @@ locate_and_pad_parm (enum machine_mode p pad_below (&locate->offset, passed_mode, sizetree); #else /* !ARGS_GROW_DOWNWARD */ - if (!in_regs -#ifdef REG_PARM_STACK_SPACE - || REG_PARM_STACK_SPACE (fndecl) > 0 -#endif - ) + if (!in_regs || reg_parm_stack_space > 0) pad_to_arg_alignment (initial_offset_ptr, boundary, &locate->alignment_pad); locate->slot_offset = *initial_offset_ptr; @@ -5093,6 +5081,7 @@ expand_function_end (void) amount. BLKmode results are handled using the group load/store machinery. */ if (TYPE_MODE (TREE_TYPE (decl_result)) != BLKmode + && REG_P (real_decl_rtl) && targetm.calls.return_in_msb (TREE_TYPE (decl_result))) { emit_move_insn (gen_rtx_REG (GET_MODE (decl_rtl), Index: gcc-4_8-branch/gcc/expr.h =================================================================== --- gcc-4_8-branch.orig/gcc/expr.h 2013-12-28 17:41:32.056627059 +0100 +++ gcc-4_8-branch/gcc/expr.h 2013-12-28 17:50:43.366356185 +0100 @@ -521,8 +521,8 @@ extern rtx expand_divmod (int, enum tree rtx, int); #endif -extern void locate_and_pad_parm (enum machine_mode, tree, int, int, tree, - struct args_size *, +extern void locate_and_pad_parm (enum machine_mode, tree, int, int, int, + tree, struct args_size *, struct locate_and_pad_arg_data *); /* Return the CODE_LABEL rtx for a LABEL_DECL, creating it if necessary. */