This [1] might worth reading, Malhar. [1] http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html 2017-06-10 4:12 GMT+08:00 Tim Northover via llvm-dev < llvm-dev at lists.llvm.org>:> On 9 June 2017 at 12:03, Jajoo, Malhar via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Is there some way around this ( without suggesting a change to my entire > AST ) ? > > LLVM has its own lightweight dynamic casting infrastructure which the > Type hierarchy already makes use of. > > You have to implement a "classof" function in your DummyType > definition. That means you'll need a new type ID. Appropriating an > unused one is slightly dodgy, but probably OK in practice if you're > careful. > > After that you'd write "dyn_cast" instead of "dynamic_cast", since > that's what the LLVM version is called. > > Cheers. > > Tim. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170610/8f5386ab/attachment.html>
Hi Tim, Thanks for that , I have read the documentation on this , but I would like to know if it would be the right thing to do , ie , changing the enum within llvm::Type and I'm slightly unclear on how I can update the C binding ? Can someone kindly clarify that ? Thanks, Malhar ________________________________ From: 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> Sent: Friday, June 9, 2017 11:29:26 PM To: Tim Northover Cc: Jajoo, Malhar; llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Subclassing LLVM Type This [1] might worth reading, Malhar. [1] http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html How to set up LLVM-style RTTI for your class hierarchy ...<http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html> llvm.org Background ¶ LLVM avoids using C++’s built in RTTI. Instead, it pervasively uses its own hand-rolled form of RTTI which is much more efficient and flexible ... 2017-06-10 4:12 GMT+08:00 Tim Northover via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>: On 9 June 2017 at 12:03, Jajoo, Malhar via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:> Is there some way around this ( without suggesting a change to my entire AST ) ?LLVM has its own lightweight dynamic casting infrastructure which the Type hierarchy already makes use of. You have to implement a "classof" function in your DummyType definition. That means you'll need a new type ID. Appropriating an unused one is slightly dodgy, but probably OK in practice if you're careful. After that you'd write "dyn_cast" instead of "dynamic_cast", since that's what the LLVM version is called. Cheers. Tim. _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170609/e3c7944a/attachment.html>
On 9 June 2017 at 15:29, Jajoo, Malhar via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Thanks for that , I have read the documentation on this , but I would like to know > if it would be the right thing to do , ie , changing the enum within llvm::TypeWell, I find the idea of a non-canonical DummyType slightly disturbing (I don't think it's something we'd ever support officially). But you might be able to make it work and if you need dyn_cast then modifying that enum is about the only way to get it. Do you know that there's such a thing as an "opaque type" in LLVM, by the way? You haven't said what you need this DummyType for but it might serve as a replacement. Basically you start off with an unspecified struct type that you can then fill the details in for later.> and I'm slightly unclear on how I can update the C binding ? > Can someone kindly clarify that ?Can't help you there, I'm afraid. I've never used the C API and barely looked at it. Tim.