[LLVMdev] TableGen: Requesting feedback for "TGContext"

Sean Silva silvas at purdue.edu
Thu Oct 4 21:55:52 PDT 2012


>> Ok, here's the first batch. It converts the RecTy hierarchy over to
>> use LLVM-style RTTI. Along the way, I also wrote up a new doc "How to
>> set up LLVM-style RTTI for your class hierarchy", which covers the
>> previously undocumented (albeit not that complicated) process for
>> hooking into Support/Casting.h.
>
> Cool.  Please pull this content into the ProgrammersManual as a new section.

I've added a link to the new page where it used to say "it's out of
the scope of this document [ProgrammersManual.html] to describe how to
do this". Is that close enough? When I get around to Sphinxifying
ProgrammersManual.html, I think the general approach is going to be to
break the current top-level divisions into their own pages anyway, so
this will be able to fit right in. The top level divisions of
ProgrammersManual, like "Picking the Right Data Structure for a Task",
are natural topics for their own page I think.

> These all look great, please apply.

Landed in r165290, r165291, r165292, r165293.

>> One question regarding `classof()`s of the form:
>>    static bool classof(const Foo *) { return true; }
>> Is the only purpose of this to optimize away "trivial" upcasts/isa<>
>> checks which are known statically?
>
> Yes.
>
>> If so, could we factor out this
>> case into Casting.h (using a trait like std::is_base_of<>)?
>
> That's a great idea, please do! :)

Ok. We already have an is_base_of<> in Support/type_traits.h, so
hopefully it's mostly a matter of wiring it up. Thankfully we already
have some unittests for Casting.h so no new ground needs to be broken
there. I'll try to get to this tomorrow and post some patches on
llvm-commits.

-- Sean Silva

On Thu, Oct 4, 2012 at 11:05 PM, Chris Lattner <sabre at nondot.org> wrote:
>
> On Oct 4, 2012, at 5:15 PM, Sean Silva <silvas at purdue.edu> wrote:
>
>>> It won't cause a negative effect, go for it!  Dynamic_cast is realllly slow compared to dyn_cast, it is worth the memory.
>>
>> Ok, here's the first batch. It converts the RecTy hierarchy over to
>> use LLVM-style RTTI. Along the way, I also wrote up a new doc "How to
>> set up LLVM-style RTTI for your class hierarchy", which covers the
>> previously undocumented (albeit not that complicated) process for
>> hooking into Support/Casting.h.
>
> Cool.  Please pull this content into the ProgrammersManual as a new section.
>
>> Attached are 4 patches. I've also attached a convenient rendered PDF
>> of the new documentation (credit to Nick Kledzik for the idea of doing
>> this). Generated TableGen files are identical at all steps.
>>
>> 0001-tblgen-Put-dyn_cast-infrastructure-in-place-for-RecT.patch:
>> Sets up Casting.h infrastructure.
>>
>> 0002-tblgen-Replace-uses-of-dynamic_cast-XXXRecTy-with-dy.patch:
>> A mechanical transformation of dynamic_cast<> to dyn_cast<>. This
>> leaves a number of "semantically inappropriate" dyn_cast<>'s (e.g. `if
>> (dyn_cast<>) { /* ... */ }`).
>>
>> 0003-tblgen-Use-appropriate-LLVM-style-RTTI-functions.patch:
>> Fix up "semantically inappropriate" dyn_cast<>'s to isa<> or cast<> as
>> appropriate. If you want I can squash this with 0002.
>>
>> 0004-docs-Add-HowToSetUpLLVMStyleRTTI.rst.patch:
>> Add docs for setting up LLVM-style RTTI for a class hierarchy. The
>> attached PDF is the rendered version of this document. Please give
>> feedback on inaccuracies or suggested improvements for this document.
>
> These all look great, please apply.
>
>> One question regarding `classof()`s of the form:
>>    static bool classof(const Foo *) { return true; }
>> Is the only purpose of this to optimize away "trivial" upcasts/isa<>
>> checks which are known statically?
>
> Yes.
>
>> If so, could we factor out this
>> case into Casting.h (using a trait like std::is_base_of<>)?
>
> That's a great idea, please do! :)
>
> -Chris



More information about the llvm-dev mailing list