This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Suppress type validation when parsing pattern fragments
ClosedPublic

Authored by uweigand on Jul 3 2018, 10:57 AM.

Details

Summary

Currently, any attempt to define a PatFrag involving any floating-point only (or vector only) node causes a hard assertion failure in TableGen if the current target does not have any floating-point (or vector) types.

This is annoying if you want to provide convenience fragments in common code (e.g. include/llvm/Target/TargetSelectionDAG.td) that is parsed on all platforms, including those that miss such types.

But really, there's no reason not accept this when parsing the fragment -- of course it would be an error for such a target to actually *use* such a fragment anywhere, but as long as it doesn't, I think TableGen shouldn't error out.

The immediate cause of the assertion failure is the test inside the ValidateOnExit destructor. This patch simply disables that check while infering types during parsing of pattern fragments (only).

If there's a cleaner / simpler way to achieve the same effect, please let me know ...

Diff Detail

Repository
rL LLVM

Event Timeline

uweigand created this revision.Jul 3 2018, 10:57 AM
hfinkel accepted this revision.Jul 13 2018, 9:32 AM
hfinkel added a subscriber: hfinkel.

LGTM

utils/TableGen/CodeGenDAGPatterns.cpp
3026 ↗(On Diff #153943)

I'd name this SV, or something, instead of _1. Seeing a name with an underscore, at least for me, draws attention unnecessarily.

This revision is now accepted and ready to land.Jul 13 2018, 9:32 AM

Sorry for the delay in reviewing. Yes, I think it's ok for now. At some point I will probably revisit this to try to generate better diagnostics, but this change is fine now.

This revision was automatically updated to reflect the committed changes.