This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Introduce an abstract variable resolver interface
ClosedPublic

Authored by nhaehnle on Feb 21 2018, 2:46 AM.

Details

Summary

The intention is to allow us to more easily restructure how resolving is
done, e.g. resolving multiple variables simultaneously, or using the
resolving mechanism to implement !foreach.

Change-Id: I4b976b54a32e240ad4f562f7eb86a4d663a20ea8

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle created this revision.Feb 21 2018, 2:46 AM
tra added inline comments.Feb 22 2018, 2:24 PM
include/llvm/TableGen/Record.h
1631 ↗(On Diff #135225)

Please describe the purpose of this function. It's not clear what are those unset bits and why would we want (or not) to keep them.

1642 ↗(On Diff #135225)

This needs documentation, too. Does it accept nullptr? What does it return? Can it return nullptr? If so, what does it mean?

lib/TableGen/Record.cpp
1837–1858 ↗(On Diff #135225)

Do we ever cache objects that get deallocated?
If so, using pointers for cache is problematic VarName may have been deallocated and re-allocated to represent something else since it was cached. Perhaps you want to use fully qualified var name as the key instead.

nhaehnle updated this revision to Diff 135556.Feb 22 2018, 4:36 PM
nhaehnle marked 3 inline comments as done.

Update comments.

Thanks for taking a look at all the patches!

include/llvm/TableGen/Record.h
1631 ↗(On Diff #135225)

It's to do with keeping cross-references alive to represent instruction encodings. I'm adding a comment, see also http://nhaehnle.blogspot.de/2018/02/tablegen-3-bits.html

1642 ↗(On Diff #135225)

This is an override and we don't usually duplicate documentation for those in LLVM. The base class has documentation.

lib/TableGen/Record.cpp
1837–1858 ↗(On Diff #135225)

Inits are never deallocated (except on program shutdown). They are owned by the static pools from which they are allocated, see the various ::get function implementations.

tra accepted this revision.Feb 23 2018, 2:37 PM
tra added inline comments.
include/llvm/TableGen/Record.h
1631 ↗(On Diff #135225)

Interesting. This feature does not seem to be mentioned anywhere in the docs. It probably should be, though I'm not sure where. We have bare-bones syntax doc, very simple language introduction, and the list of back-ends. We currently don't have any good place for describing how tablegen does things.

After these patches you're officially going to be the only person who can claim to understand it. :-) Any chance you could write few pages (separately from this patch) that would give people an idea of what to expect from tablegen? I.e. how name resolution works, special cases like references to bits, etc. That would be extremely valuable, IMO.

lib/TableGen/Record.cpp
1837–1858 ↗(On Diff #135225)

OK.

This revision is now accepted and ready to land.Feb 23 2018, 2:37 PM
nhaehnle added inline comments.Feb 25 2018, 7:54 AM
include/llvm/TableGen/Record.h
1631 ↗(On Diff #135225)

Agreed. I'm already writing up some parts for the blog I've been linking to, but it makes sense to put some of this stuff into docs/TableGen/ as well. I'll try to make some time for that.

This revision was automatically updated to reflect the committed changes.