<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 20, 2009, at 12:27 AM, Talin wrote:</div><blockquote type="cite">What's the current status on support for first-class structs? The last I heard was:<div><ul><li>Structs which are smaller or equal to two pointers can be passed / returned / loaded / stored by value.</li><li>There are plans to expand this in the future to support arbitrary-sized structs as first class values. (Probably via some transformation pass the converts the return value into a hidden parameter.)</li>

</ul><div>First question - are those statements still true?</div></div></blockquote><div><br></div>I can't answer this or most of your other questions, but:</div><div><br><blockquote type="cite"><div><div>Another thing I noticed recently was that although we have insert/extract value, there's no 'constructvalue' instruction. I'm thinking of something that would take a structure type + a list of individual field values and returns a first class aggregate. Right now, if you want to construct a new aggregate, it seems that you either have to alloca it, use GEP to fill in the fields, and then load it - or you have to alloca it, load the uninitialized struct, and then use successive insertvalue instructions to initialize it. At least, I can't think of another way to do it. (Of course, you can get SSA struct values from other places, but I'm talking about creating a fresh value.)</div></div></blockquote><div><br></div>The way to do this is to start with undef and repeatedly insert into it.  For example:</div><div>  %0 = insertvalue undef {i1,i8*}, i32 0, i1 0</div><div>  %1 = insertvalue {i1,i8*} %0, i32 1, i8* %pointer</div><div><br></div><div>Arguably there should be a helper method for this on IRBuilder.</div><div><br></div>John.</body></html>