<div dir="auto"><div dir="ltr"><div dir="ltr">Hi Yafei,<div><br></div><div>you're looking for the [FunctionType](<a href="http://llvm.org/doxygen/classllvm_1_1FunctionType.html" target="_blank" rel="noreferrer">http://llvm.org/doxygen/classllvm_1_1FunctionType.html</a>).</div><div><br></div><div>Cheers,</div><div>Philip</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 26, 2019 at 11:15 AM Yafei Liu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi, I'm learning to use llvm api to generate IR code, I got two good tutorials, <a href="https://llvm.org/docs/tutorial/" target="_blank" rel="noreferrer">https://llvm.org/docs/tutorial/</a> and <a href="https://www.ibm.com/developerworks/library/os-createcompilerllvm1/index.html" target="_blank" rel="noreferrer">https://www.ibm.com/developerworks/library/os-createcompilerllvm1/index.html</a>, but non of those showed how to implement a function pointer(or at least there is but I didn't find out). </div><div dir="ltr"><br></div><div>For example I got a c style code like this: </div><div><br></div><div><div>int foo(int i) {</div><div>  return ++i;</div><div>}</div><div><br></div><div>int (*p)(int);</div><div><br></div><div>int main() {</div><div>  p = foo;</div><div>  p(3);</div><div>}</div></div><div><br></div><div>I turn it into IR code and found the sytex of a function pointer is:</div><div>@p = global i32 (i32)* null, align 8</div><div>I tried play with llvm::PointerType but I cannot get the sytex, so could anyone teach me how to do this?</div></div></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>