<div>Thanks, Eli.  I finally got back to addressing this.  How's the enclosed?</div>
<div> </div>
<div>-John<br><br></div>
<div class="gmail_quote">On Tue, Aug 10, 2010 at 8:28 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On Tue, Aug 10, 2010 at 1:08 PM, John Thompson<br>
<div class="im"><<a href="mailto:john.thompson.jtsoftware@gmail.com">john.thompson.jtsoftware@gmail.com</a>> wrote:<br></div>
<div>
<div></div>
<div class="h5">> Since this is what I believe is a custom attribute, to make sure we are on<br>> the same page, the vecreturn attribute is described as follows in our gcc<br>> doc:<br>><br>> ***<br>> Returning a Vector Class in Registers<br>
><br>> According to the PPU ABI specifications, a class with a single member of<br>> vector type is returned in<br>> memory when used as the return value of a function. This results in<br>> inefficient code when implementing<br>
> vector classes. To return the value in a single vector register, add the<br>> vecreturn attribute to the class<br>> definition. This attribute is also applicable to struct types.<br>><br>> Example:<br>><br>
> struct Vector<br>> {<br>>   __vector float xyzw;<br>> } __attribute__((vecreturn));<br>><br>> Vector Add(Vector lhs, Vector rhs)<br>> {<br>>   Vector result;<br>>   result.xyzw = vec_add(lhs.xyzw, rhs.xyzw);<br>
>   return result; // This will be returned in a register<br>> }<br>> ***<br>><br>> I believe I should be doing a little more checking to make sure the<br>> structure/class to which the vecreturn attribute is attached is of the<br>
> proper kind, i.e. only has one data member, and the member is a vector.<br>><br>> Is the enclosed patch the right way to do this checking, using the field<br>> iterator?<br>><br>> If so, may I check it in?  Otherwise, please let me know the right way to do<br>
> it.<br><br></div></div>It's the right approach.<br><br>+  CXXRecordDecl *record = static_cast<CXXRecordDecl*>(d);<br><br>The following is preferred:<br>CXXRecordDecl *record = cast<CXXRecordDecl>(d);<br>
<br>You probably want to check isPOD().<br><br>Would some check that the vector is small enough to be returned in a<br>single register be appropriate?<br><br>Is there some reason why vecreturn is only valid for C++?  If not, you<br>
should check for a RecordDecl instead of a CXXRecordDecl.<br><font color="#888888"><br>-Eli<br></font></blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br>
<br>