I had a similar issue on my port. I fixed it by adding a check_move
before the generation of the move to look at the potential offset
used.

That allowed the compiler to not generate those wrong offsets
depending on the mode on my port. It looks something like this :

/* Check the operands of the move to make sure we can perform the move */
bool check_move (rtx op0, rtx op1)
{
    /* First check offsets */
    if (MEM_P (op0))
    {
        int offset;
        int res = rtx_get_offset (XEXP (op0, 0), &offset);

        if (res < 0)
            return false;

        if (! cyclops_check_offset (offset, GET_MODE (op0)))
        {
            return false;
        }
    }

    /* Check second operand */
    if (MEM_P (op1))
    {
        int offset;
        int res = rtx_get_offset (XEXP (op1, 0), &offset);

        if (res < 0)
            return false;

        if (! cyclops_check_offset (offset, GET_MODE (op1)))
        {
            return false;
        }
    }

    return true;
}

Jc

On Tue, Aug 4, 2009 at 1:39 AM, Mohamed Shafi<shafi...@gmail.com> wrote:
> 2009/8/3 Jim Wilson <wil...@codesourcery.com>:
>> On 08/03/2009 02:14 AM, Mohamed Shafi wrote:
>>>
>>> short - 2 bytes
>>> 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
>>
>> You haven't explained what the actual problem is.  Is there a problem with
>> global variables?  Is the variable initialized or uninitialized? If it is
>> uninitialized, is it common?  If this a local variable?  Is this a function
>> argument or parameter?  Is this a named or unnamed (stdarg) argument or
>> parameter?  Etc.  It always helps to include a testcase.
>>
>> You should also mention what gcc is currently emitting, why it is wrong, and
>> what the output should be instead.
>>
>> All this talk about stack and parm boundary suggests that it might be an
>> issue with function arguments, in which case you will probably have to
>> describe the calling conventions a bit so we can understand what you want.
>>
>  This is the test case that i tried
>
> short funs (int a, int b, char w,short e,short r)
> {
>  return e+r;
> }
>
> 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)
>
> funs:
>        add      16,sp
>        mov  d0,(sp-16)
>        mov  d1,(sp-12)
>        movh  (sp-19),d0
>        movh  d0,(sp-8)
>        movh  (sp-21),d0
>        movh  d0,(sp-6)
>        movh  (sp-8),d1
>        movh  (sp-6),d0
>        add     d1,d0,d0
>        sub    16,sp
>        ret
>
>
> From the above code you can see that some of the half word access is
> not aligned on a 2byte boundary.
>
> So where am i going wrong.
> Hope this info is enough
>
> Regards,
> Shafi
>

Reply via email to