<div dir="ltr">Hi Yafei,<div><br></div><div>a Value whose type is a FunctionType _is_ a function pointer. You use FunctionType::get to create such a type given the return type and the argument types. Or you call foo->getType() if foo is a Function* :)</div><div><br></div><div>Cheers,</div><div>Philip</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 26, 2019 at 12:41 PM Yafei Liu <<a href="mailto:yfliu@mobvoi.com">yfliu@mobvoi.com</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">Hi Philip,<div>Isn't function pointer a pointer first? I checked  FunctionType and still have no idea about how to do this, can you show me which api in FunctionType should I use?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 26, 2019 at 7:18 PM Philip Pfaffe <<a href="mailto:philip.pfaffe@gmail.com" target="_blank">philip.pfaffe@gmail.com</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="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" rel="noreferrer" target="_blank">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" rel="noreferrer" target="_blank">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/" rel="noreferrer" target="_blank">https://llvm.org/docs/tutorial/</a> and <a href="https://www.ibm.com/developerworks/library/os-createcompilerllvm1/index.html" rel="noreferrer" target="_blank">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" rel="noreferrer" target="_blank">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>
</blockquote></div>
</blockquote></div>