On 28 Mar 2012, at 11:48, Niels Grewe wrote:
> Hello David,
>
> Am 28.03.2012 11:27, schrieb David Chisnall:
>> Now for the helpful bit...
>>
>> Looking at what clang generates for things taking NSRect as the argument,
>> the only thing I can think of is to wonder if you forgot to add the byval
>> attribute on the arguments? And did you set the alignment to 8 on the
>> attribute? If the stack slot used for the argument has the incorrect
>> alignment then this would give similar results to what you see...
>
> This is indeed extremely helpful! I did of course forget about the
> attributes. Think I'll add a function to the ABI info provider that
> generates an AttrListPtr for a Function.
Ideally, I'd like to see the ABI class responsible for generating calls /
invokes and function definitions. Rather than passing all of the metadata up
and down, just pass an ArrayRef of Values that represent the arguments, a Value
representing the callee, and a type encoding, and get back a Value representing
the returned object and have the ABI class handle the rest.
In the other direction, I'd like to pass a type encoding and get back a new
Function and an map of parameter names to Allocas storing the formal
parameters. For example, something like this:
object_map<NSString*, llvm::Value*> parameters;
NSString *parameterNames[] = { @"self", @"_cmd", @"someArg" };
Function *method = abi->CreateFunction(@"@@:@", parameterNames, ¶meters);
This would then return a Function with three allocas and three stores at the
start.
> Maybe I can get this done tonight.
Yay!
> But I'm a bit confused about why the alignment is supposed to be 8.
The alignment of the NSRect argument is 8.
> I
> always thought the amd64 ABI mandated the stack to be 16 byte aligned on
> function calls (though it would of course be aligned that way for NSRect
> by accident…)
The alignment of the stack pointer is not necessarily the same as the alignment
of the parameter, especially in cases where there is more than one parameter.
There may be padding after (or before) it to fix the stack alignment.
That said, I think that the problem is the lack of the byval, not the lack of
the alignment.
David
-- Sent from my IBM 1620
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev