I'm working on implementing a simple functional language in LLVM. It's statically typed, but I'd like to a have some simple multimethods involved. Does LLVM have some intrinsics for handling something like C++ vtables? Or do I need to implement my own way of handling single-dispatch functions? Thanks, Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110511/0c5b7126/attachment.html>
On Wed, May 11, 2011 at 8:54 PM, Timothy Baldridge <tbaldridge at gmail.com>wrote:> I'm working on implementing a simple functional language in LLVM. It's > statically typed, but I'd like to a have some simple multimethods involved. > Does LLVM have some intrinsics for handling something like C++ vtables? Or > do I need to implement my own way of handling single-dispatch functions? >You'll need to do that yourself. A vtable is just an array of function pointers.> Thanks, > > Timothy > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110511/9ffe820b/attachment.html>
On 12 May 2011 06:05, Talin <viridia at gmail.com> wrote:> You'll need to do that yourself. A vtable is just an array of function > pointers.You can map the concept in C++ and run Clang on it to output IR, so you know more or less it should be done in your language. cheers, --renato
Hello Timothy, If you are basing your language on the Clang source base then it will be able to do VTables. If you're basing it on LLVM by itself, there are no intrinsics for doing VTables. You just have to do a Load on the VPtr in your class, GetElementPtr on the array pointed to by the VPtr, and then execute the method pointer you just retrieved. I hope this helps you, --Sam Crow>________________________________ >From: Timothy Baldridge <tbaldridge at gmail.com> >To: llvmdev at cs.uiuc.edu >Sent: Wednesday, May 11, 2011 10:54 PM >Subject: [LLVMdev] Vtables for non c++ languages > > >I'm working on implementing a simple functional language in LLVM. It's statically typed, but I'd like to a have some simple multimethods involved. Does LLVM have some intrinsics for handling something like C++ vtables? Or do I need to implement my own way of handling single-dispatch functions? > >Thanks, > >Timothy >