On Tue, 2009-08-04 at 11:09 +0530, Mohamed Shafi wrote:
> >> i am not able to implement the alignment for short.
> >> The following is are the macros that i used for this
> >> #define PARM_BOUNDARY 8
> >> #define STACK_BOUNDARY 64
> The target is 32bit . The first two parameters are passed in registers
> and the rest in stack. For the parameters that are passed in stack the
> alignment is that of the data type. The stack pointer is 8 byte
> aligned. char is 1 byte, int is 4 byte and short is 2 byte. The code
> that is getting generated is give below (-O0 -fomit-frame-pointer)

Er, wait.  You set PARM_BOUNDARY to 8.  This means all arguments will be
padded to at most an 8-bit boundary, which means that yes, a short after
a char will have only 1 byte alignment.  If you want all arguments to
have 2-byte alignment, then you need to set PARM_BOUNDARY to 16.  But
you probably want a value of 32 here so that 4-byte ints get 4-byte
alignment.  This will allocate a minimum 4-byte stack slot for every
argument.  I don't know the calling convention, so I don't know exactly
how you want arguments arranged on the stack.

If you are pushing arguments, then you can lie in the PUSH_ROUNDING
macro.  You could say for instance that one byte pushes always push 2
bytes.  This ensures that the stack always has 2-byte alignment while
pushing arguments.  If your push instruction doesn't actually do this,
then you need to modify the pushqi pattern to emit two pushes or use a
HImode push to get the right behaviour.

Try looking at the code in store_one_arg in calls.c, and emit_push_insn
in expr.c.

Jim


Reply via email to