<div dir="ltr">Hi Koffie,<div><br></div><div>Casting is out, as you noted, since the struct is user defined. I think using a pointer to the struct is your only option.</div><div><br></div><div>- Lang.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 30, 2015 at 12:36 AM, koffie drinker via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi all,<br><br></div>I'm working on a run time that allows you to run code on the fly. My language allows users to define custom structs.<br><br></div>Once
 I have generated a func that returns a struct, I would like to map the 
function result back to a std::vector<GenericValue> to be used in 
the c++ part. For normal return types (char, ints, double) its easy to 
cast to their function pointer and execute and wrap the results.<br><br></div><div>// for double f();<br>auto func = (double (*f)()) engine->getFunctionAddress("f");<br></div><div>double result = func(); <br><br></div><div>// how to do this for exampleStruct {double, double}, where example struct is defined by the user<br></div><div>// exampleStruct f();<br></div><div>// we can't do auto func = (exampleStruct (*f)()) engine->getFunctionAddress("f");<br></div><div>// since example struct is defined by the user inside the runtime/interpreter<br></div><div>??<br><br></div><div>How
 can I cast a function that returns a user defined struct ? I know the 
layout of the struct, but the struct layout might be different in the IR
 vs C++? I know I could alloc memory in the func and return a ptr to a 
struct (returned as void* ), and use that as an offset to read the 
struct values, but I would like to avoid using a ptr in this case. What 
would be the right approach in ths case?<br></div><div><br></div>I tried to look into t he executionengine::runFunction but, they are incomplete.<br></div>I'm using llvm 3.7 btw.</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>