This is an archive of the discontinued LLVM Phabricator instance.

[tblgen] Add getOperatorAsDef() to Record
ClosedPublic

Authored by dsanders on Oct 3 2019, 2:19 PM.

Details

Summary

While working with DagInit's, it's often the case that you expect the
operator to be a reference to a def. This patch adds a wrapper for this
common case to reduce the amount of boilerplate callers need to duplicate
repeatedly.

getOperatorAsDef() returns the record if the DagInit has an operator that is
a DefInit. Otherwise, it prints a fatal error.

There's only a few pre-existing examples in LLVM at the moment and I've
left a few instances of the code this simplifies as they had more specific
error messages than the generic one this produces. I'm going to be using
this a fair bit in my subsequent patches.

Diff Detail

Event Timeline

dsanders created this revision.Oct 3 2019, 2:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 3 2019, 2:19 PM
nhaehnle accepted this revision.Oct 8 2019, 6:11 AM
nhaehnle added a subscriber: nhaehnle.

Thanks, this makes a lot of sense. LGTM.

This revision is now accepted and ready to land.Oct 8 2019, 6:11 AM
This revision was automatically updated to reflect the committed changes.