problem with function arguments in ARM EABI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with function arguments in ARM EABI

Lauro Ramos Venancio
I'm facing a problem with functions arguments. ARM EABI defines that
8-bytes arguments must be 8-bytes aligned. For example:

void @f(i32 %a, i64 %b)

ARM EABI:
r0 <- %a
r2,r3 <- %b

Darwin:
r0 <- %a
r1,r2 <- %b

void @g(i32 %a, i32 %b, i32 %c)

ARM EABI or Darwin:
r0 <- %a
r1 <- %b
r2 <- %c

The problem is: I can't differ a i64 argument of two i32 arguments in
ISD::CALL (ARM doesn't have i64 registers). The function
TargetLowering::LowerCallTo transforms all i64 arguments in two i32
arguments.

A possible solution is override TargetLowering::LowerCallTo and do not
expand i64 arguments. I don't know if it's a good solution. None
backend overrides this function.

Any ideas?

Lauro
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with function arguments in ARM EABI

Evan Cheng-2

On Feb 8, 2007, at 10:46 AM, Lauro Ramos Venancio wrote:

> I'm facing a problem with functions arguments. ARM EABI defines that
> 8-bytes arguments must be 8-bytes aligned. For example:
>
> void @f(i32 %a, i64 %b)
>
> ARM EABI:
> r0 <- %a
> r2,r3 <- %b

Ok. I suppose this makes it easier to use 64 bit store instructions.

>
> Darwin:
> r0 <- %a
> r1,r2 <- %b
>
> void @g(i32 %a, i32 %b, i32 %c)
>
> ARM EABI or Darwin:
> r0 <- %a
> r1 <- %b
> r2 <- %c
>
> The problem is: I can't differ a i64 argument of two i32 arguments in
> ISD::CALL (ARM doesn't have i64 registers). The function
> TargetLowering::LowerCallTo transforms all i64 arguments in two i32
> arguments.
>
> A possible solution is override TargetLowering::LowerCallTo and do not
> expand i64 arguments. I don't know if it's a good solution. None
> backend overrides this function.

Yes, you need to override both LowerArguments and LowerCallTo. All of  
the current targets / abi's use the default implementation in  
SelectionDAGISel.cpp But I guess ARM EABI will be the first. :-) As  
far as I can see, this is the only clean way to do it.  I expect the  
ARM EABI specific implementation will be quite a bit simpler than the  
default implementation though.

Evan


>
> Any ideas?
>
> Lauro
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with function arguments in ARM EABI

Lauro Ramos Venancio
>
> Yes, you need to override both LowerArguments and LowerCallTo. All of
> the current targets / abi's use the default implementation in
> SelectionDAGISel.cpp But I guess ARM EABI will be the first. :-) As
> far as I can see, this is the only clean way to do it.  I expect the
> ARM EABI specific implementation will be quite a bit simpler than the
> default implementation though.
>

If I override these functions, I would copy a lot of code and change
only few lines. I found another solution: adding two items to
arguments Flags. Flags[27:24] = number of pieces that an argument was
expanded. Flags[31:28] = sequential piece ID.

What do you think? May I add these items?

Lauro
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with function arguments in ARM EABI

Evan Cheng-2
I am ok with adding an attribute but don't like to add two of them as  
you've described. I don't think you need the "sequential piece ID" to  
deal with this issue, no? You just need a little extra bookkeeping in  
the target lowering code.

Alternatively, you can use a "original alignment" attribute (i.e.  
alignment of unexpanded argument). That would be a 5-bit attribute.

Chris, got a better idea?

Evan

On Feb 9, 2007, at 1:57 PM, Lauro Ramos Venancio wrote:

>>
>> Yes, you need to override both LowerArguments and LowerCallTo. All of
>> the current targets / abi's use the default implementation in
>> SelectionDAGISel.cpp But I guess ARM EABI will be the first. :-) As
>> far as I can see, this is the only clean way to do it.  I expect the
>> ARM EABI specific implementation will be quite a bit simpler than the
>> default implementation though.
>>
>
> If I override these functions, I would copy a lot of code and change
> only few lines. I found another solution: adding two items to
> arguments Flags. Flags[27:24] = number of pieces that an argument was
> expanded. Flags[31:28] = sequential piece ID.
>
> What do you think? May I add these items?
>
> Lauro
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with function arguments in ARM EABI

Evan Cheng-2

On Feb 9, 2007, at 2:50 PM, Evan Cheng wrote:

> I am ok with adding an attribute but don't like to add two of them as
> you've described. I don't think you need the "sequential piece ID" to
> deal with this issue, no? You just need a little extra bookkeeping in
> the target lowering code.
>
> Alternatively, you can use a "original alignment" attribute (i.e.
> alignment of unexpanded argument). That would be a 5-bit attribute.

I think this will work quite well. Add the alignment info to the  
first expanded node and the target lowering code should be able to  
handle the rest. Seems nice and clean.

Evan

>
> Chris, got a better idea?
>
> Evan
>
> On Feb 9, 2007, at 1:57 PM, Lauro Ramos Venancio wrote:
>
>>>
>>> Yes, you need to override both LowerArguments and LowerCallTo.  
>>> All of
>>> the current targets / abi's use the default implementation in
>>> SelectionDAGISel.cpp But I guess ARM EABI will be the first. :-) As
>>> far as I can see, this is the only clean way to do it.  I expect the
>>> ARM EABI specific implementation will be quite a bit simpler than  
>>> the
>>> default implementation though.
>>>
>>
>> If I override these functions, I would copy a lot of code and change
>> only few lines. I found another solution: adding two items to
>> arguments Flags. Flags[27:24] = number of pieces that an argument was
>> expanded. Flags[31:28] = sequential piece ID.
>>
>> What do you think? May I add these items?
>>
>> Lauro
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev