[cfe-commits] [QUESTION] vecreturn attribute question 1
John Thompson
john.thompson.jtsoftware at gmail.com
Tue Aug 10 13:08:59 PDT 2010
Since this is what I believe is a custom attribute, to make sure we are on
the same page, the vecreturn attribute is described as follows in our gcc
doc:
***
Returning a Vector Class in Registers
According to the PPU ABI specifications, a class with a single member of
vector type is returned in
memory when used as the return value of a function. This results in
inefficient code when implementing
vector classes. To return the value in a single vector register, add the
vecreturn attribute to the class
definition. This attribute is also applicable to struct types.
Example:
struct Vector
{
__vector float xyzw;
} __attribute__((vecreturn));
Vector Add(Vector lhs, Vector rhs)
{
Vector result;
result.xyzw = vec_add(lhs.xyzw, rhs.xyzw);
return result; // This will be returned in a register
}
***
I believe I should be doing a little more checking to make sure the
structure/class to which the vecreturn attribute is attached is of the
proper kind, i.e. only has one data member, and the member is a vector.
Is the enclosed patch the right way to do this checking, using the field
iterator?
If so, may I check it in? Otherwise, please let me know the right way to do
it.
-John
--
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100810/8d62ebcb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vecreturn2.patch
Type: application/octet-stream
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100810/8d62ebcb/attachment.obj>
More information about the cfe-commits
mailing list