/* Convert function calls to rtl insns, for GNU C compiler.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
This file is part of GCC.
rtx offset = ARGS_SIZE_RTX (args[i].locate.offset);
rtx slot_offset = ARGS_SIZE_RTX (args[i].locate.slot_offset);
rtx addr;
+ unsigned int align, boundary;
/* Skip this parm if it will not be passed on the stack. */
if (! args[i].pass_on_stack && args[i].reg != 0)
addr = plus_constant (addr, arg_offset);
args[i].stack = gen_rtx_MEM (args[i].mode, addr);
- set_mem_align (args[i].stack, PARM_BOUNDARY);
set_mem_attributes (args[i].stack,
TREE_TYPE (args[i].tree_value), 1);
+ align = BITS_PER_UNIT;
+ boundary = args[i].locate.boundary;
+ if (args[i].locate.where_pad != downward)
+ align = boundary;
+ else if (GET_CODE (offset) == CONST_INT)
+ {
+ align = INTVAL (offset) * BITS_PER_UNIT | boundary;
+ align = align & -align;
+ }
+ set_mem_align (args[i].stack, align);
if (GET_CODE (slot_offset) == CONST_INT)
addr = plus_constant (arg_reg, INTVAL (slot_offset));
addr = plus_constant (addr, arg_offset);
args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
- set_mem_align (args[i].stack_slot, PARM_BOUNDARY);
set_mem_attributes (args[i].stack_slot,
TREE_TYPE (args[i].tree_value), 1);
+ set_mem_align (args[i].stack_slot, args[i].locate.boundary);
/* Function incoming arguments may overlap with sibling call
outgoing arguments and we cannot allow reordering of reads
NULL_RTX, TYPE_MODE (sizetype), 0);
}
- /* Some types will require stricter alignment, which will be
- provided for elsewhere in argument layout. */
- parm_align = MAX (PARM_BOUNDARY, TYPE_ALIGN (TREE_TYPE (pval)));
+ parm_align = arg->locate.boundary;
/* When an argument is padded down, the block is aligned to
PARM_BOUNDARY, but the actual argument isn't. */
/* Expands front end tree to back end RTL for GCC.
Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
This file is part of GCC.
set_mem_attributes (stack_parm, parm, 1);
- boundary = FUNCTION_ARG_BOUNDARY (data->promoted_mode, data->passed_type);
- align = 0;
+ boundary = data->locate.boundary;
+ align = BITS_PER_UNIT;
/* If we're padding upward, we know that the alignment of the slot
is FUNCTION_ARG_BOUNDARY. If we're using slot_offset, we're
intentionally forcing upward padding. Otherwise we have to come
up with a guess at the alignment based on OFFSET_RTX. */
- if (data->locate.where_pad == upward || data->entry_parm)
+ if (data->locate.where_pad != downward || data->entry_parm)
align = boundary;
else if (GET_CODE (offset_rtx) == CONST_INT)
{
align = INTVAL (offset_rtx) * BITS_PER_UNIT | boundary;
align = align & -align;
}
- if (align > 0)
- set_mem_align (stack_parm, align);
+ set_mem_align (stack_parm, align);
if (data->entry_parm)
set_reg_attrs_for_parm (data->entry_parm, stack_parm);
/* A subroutine of assign_parms. Adjust DATA->STACK_RTL such that it's
always valid and properly aligned. */
-
static void
assign_parm_adjust_stack_rtl (struct assign_parm_data_one *data)
{
/* If we can't trust the parm stack slot to be aligned enough for its
ultimate type, don't use that slot after entry. We'll make another
stack slot, if we need one. */
- if (STRICT_ALIGNMENT && stack_parm
- && GET_MODE_ALIGNMENT (data->nominal_mode) > MEM_ALIGN (stack_parm))
+ if (stack_parm
+ && ((STRICT_ALIGNMENT
+ && GET_MODE_ALIGNMENT (data->nominal_mode) > MEM_ALIGN (stack_parm))
+ || (data->nominal_type
+ && TYPE_ALIGN (data->nominal_type) > MEM_ALIGN (stack_parm)
+ && MEM_ALIGN (stack_parm) < PREFERRED_STACK_BOUNDARY)))
stack_parm = NULL;
/* If parm was passed in memory, and we need to convert it on entry,
{
rtx entry_parm = data->entry_parm;
rtx stack_parm = data->stack_parm;
+ HOST_WIDE_INT size;
+ HOST_WIDE_INT size_stored;
if (GET_CODE (entry_parm) == PARALLEL)
entry_parm = emit_group_move_into_temps (entry_parm);
return;
}
+ size = int_size_in_bytes (data->passed_type);
+ size_stored = CEIL_ROUND (size, UNITS_PER_WORD);
+ if (stack_parm == 0)
+ {
+ stack_parm = assign_stack_local (BLKmode, size_stored,
+ TYPE_ALIGN (data->passed_type));
+ if (GET_MODE_SIZE (GET_MODE (entry_parm)) == size)
+ PUT_MODE (stack_parm, GET_MODE (entry_parm));
+ set_mem_attributes (stack_parm, parm, 1);
+ }
+
/* If a BLKmode arrives in registers, copy it to a stack slot. Handle
calls that pass values in multiple non-contiguous locations. */
if (REG_P (entry_parm) || GET_CODE (entry_parm) == PARALLEL)
{
- HOST_WIDE_INT size = int_size_in_bytes (data->passed_type);
- HOST_WIDE_INT size_stored = CEIL_ROUND (size, UNITS_PER_WORD);
rtx mem;
/* Note that we will be storing an integral number of words.
So we have to be careful to ensure that we allocate an
- integral number of words. We do this below in the
+ integral number of words. We do this above when we call
assign_stack_local if space was not allocated in the argument
list. If it was, this will not work if PARM_BOUNDARY is not
a multiple of BITS_PER_WORD. It isn't clear how to fix this
if it becomes a problem. Exception is when BLKmode arrives
with arguments not conforming to word_mode. */
- if (stack_parm == 0)
- {
- stack_parm = assign_stack_local (BLKmode, size_stored, 0);
- data->stack_parm = stack_parm;
- PUT_MODE (stack_parm, GET_MODE (entry_parm));
- set_mem_attributes (stack_parm, parm, 1);
- }
+ if (data->stack_parm == 0)
+ ;
else if (GET_CODE (entry_parm) == PARALLEL)
;
else
move_block_from_reg (REGNO (entry_parm), mem,
size_stored / UNITS_PER_WORD);
}
+ else if (data->stack_parm == 0)
+ {
+ push_to_sequence (all->conversion_insns);
+ emit_block_move (stack_parm, data->entry_parm, GEN_INT (size),
+ BLOCK_OP_NORMAL);
+ all->conversion_insns = get_insns ();
+ end_sequence ();
+ }
+ data->stack_parm = stack_parm;
SET_DECL_RTL (parm, stack_parm);
}
{
/* Value must be stored in the stack slot STACK_PARM during function
execution. */
+ bool to_conversion = false;
if (data->promoted_mode != data->nominal_mode)
{
emit_move_insn (tempreg, validize_mem (data->entry_parm));
push_to_sequence (all->conversion_insns);
+ to_conversion = true;
+
data->entry_parm = convert_to_mode (data->nominal_mode, tempreg,
TYPE_UNSIGNED (TREE_TYPE (parm)));
/* ??? This may need a big-endian conversion on sparc64. */
data->stack_parm
= adjust_address (data->stack_parm, data->nominal_mode, 0);
-
- all->conversion_insns = get_insns ();
- end_sequence ();
}
if (data->entry_parm != data->stack_parm)
{
+ rtx src, dest;
+
if (data->stack_parm == 0)
{
data->stack_parm
= assign_stack_local (GET_MODE (data->entry_parm),
GET_MODE_SIZE (GET_MODE (data->entry_parm)),
- 0);
+ TYPE_ALIGN (data->passed_type));
set_mem_attributes (data->stack_parm, parm, 1);
}
- if (data->promoted_mode != data->nominal_mode)
+ dest = validize_mem (data->stack_parm);
+ src = validize_mem (data->entry_parm);
+
+ if (MEM_P (src))
{
- push_to_sequence (all->conversion_insns);
- emit_move_insn (validize_mem (data->stack_parm),
- validize_mem (data->entry_parm));
- all->conversion_insns = get_insns ();
- end_sequence ();
+ /* Use a block move to handle potentially misaligned entry_parm. */
+ if (!to_conversion)
+ push_to_sequence (all->conversion_insns);
+ to_conversion = true;
+
+ emit_block_move (dest, src,
+ GEN_INT (int_size_in_bytes (data->passed_type)),
+ BLOCK_OP_NORMAL);
}
else
- emit_move_insn (validize_mem (data->stack_parm),
- validize_mem (data->entry_parm));
+ emit_move_insn (dest, src);
+ }
+
+ if (to_conversion)
+ {
+ all->conversion_insns = get_insns ();
+ end_sequence ();
}
SET_DECL_RTL (parm, data->stack_parm);
/* split_complex_arg put the real and imag parts in
pseudos. Move them to memory. */
- tmp = assign_stack_local (DECL_MODE (parm), size, 0);
+ tmp = assign_stack_local (DECL_MODE (parm), size,
+ TYPE_ALIGN (TREE_TYPE (parm)));
set_mem_attributes (tmp, parm, 1);
rmem = adjust_address_nv (tmp, inner, 0);
imem = adjust_address_nv (tmp, inner, GET_MODE_SIZE (inner));
where_pad = FUNCTION_ARG_PADDING (passed_mode, type);
boundary = FUNCTION_ARG_BOUNDARY (passed_mode, type);
locate->where_pad = where_pad;
+ locate->boundary = boundary;
#ifdef ARGS_GROW_DOWNWARD
locate->slot_offset.constant = -initial_offset_ptr->constant;