As I understand it, first-class structs will allow structs to be passed as function arguments and returned as results (i.e. multiple return values) instead of passing pointers to structs. However, the GEP instruction only handles pointer types. So I do not understand how you will be able to extract the fields of a struct when it is received as a value type. Will the GEP instruction be altered so that it can be applied to structs directly? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e
On Sun, Feb 1, 2009 at 7:38 AM, Jon Harrop <jon at ffconsultancy.com> wrote:> > As I understand it, first-class structs will allow structs to be passed as > function arguments and returned as results (i.e. multiple return values) > instead of passing pointers to structs. However, the GEP instruction only > handles pointer types. So I do not understand how you will be able to extract > the fields of a struct when it is received as a value type. > > Will the GEP instruction be altered so that it can be applied to structs > directly?No, see: http://llvm.org/docs/LangRef.html#i_extractvalue Andrew
On Feb 1, 2009, at 5:38 AM, Jon Harrop wrote:> > As I understand it, first-class structs will allow structs to be > passed as > function arguments and returned as results (i.e. multiple return > values) > instead of passing pointers to structs. However, the GEP instruction > only > handles pointer types. So I do not understand how you will be able > to extract > the fields of a struct when it is received as a value type.Use the extractvalue instruction. Dan
On Feb 1, 2009, at 5:38 AM, Jon Harrop wrote:> > As I understand it, first-class structs will allow structs to be > passed asfirst-class structs already exist. :)> > function arguments and returned as results (i.e. multiple return > values) > instead of passing pointers to structs. However, the GEP instruction > only > handles pointer types. So I do not understand how you will be able > to extract > the fields of a struct when it is received as a value type.Use the extractvalue instruction.> Will the GEP instruction be altered so that it can be applied to > structs > directly?No. -Chris
On Feb 1, 2009, at 08:38, Jon Harrop wrote:> As I understand it, first-class structs will allow structs to be > passed as function arguments and returned as results (i.e. multiple > return values) instead of passing pointers to structs. However, the > GEP instruction only handles pointer types. So I do not understand > how you will be able to extract the fields of a struct when it is > received as a value type. > > Will the GEP instruction be altered so that it can be applied to > structs directly?You can't take the address of a register, much less an element thereof. extractvalue and insertvalue are the instructions to manipulate aggregate registers. http://llvm.org/docs/LangRef.html#aggregateops — Gordon
Hi Jon, check out http://llvm.org/docs/LangRef.html#aggregateops Ciao, Duncan.
On Monday 02 February 2009 19:52:12 Duncan Sands wrote:> Hi Jon, check out > > http://llvm.org/docs/LangRef.html#aggregateopsWonderful, thank you. I missed this because it wasn't in the C and OCaml bindings in LLVM 2.4... -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e
On Monday 02 February 2009 19:25:46 Chris Lattner wrote:> On Feb 1, 2009, at 5:38 AM, Jon Harrop wrote: > > As I understand it, first-class structs will allow structs to be > > passed as > > first-class structs already exist. :)Hmm, I cannot get them to work. I suspect the problem is somewhere between OCaml and their implementation within LLVM because I am not even seeing the instructions when I visualize my function. I have augmented "bindings/ocaml/llvm/llvm.ml*", "include/llvm-c/Core.h" and "lib/VMCore/Core.cpp" with functions to handle InsertValue and ExtractValue. Any ideas? Maybe I should leave this until 2.5... -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e