This is an archive of the discontinued LLVM Phabricator instance.

[TableGen/GlobalISel] Emit MI_predicate custom code for PatFrags (not only PatFrag)
ClosedPublic

Authored by bjope on Mar 12 2021, 3:29 AM.

Details

Summary

When GlobalISelEmitter::emitCxxPredicateFns emitted code for MI
predicates it used "PatFrag" when searching for definitions. With
this patch it will search for all "PatFrags" instead. Since PatFrag
derives from PatFrags the difference is that we now include all
definitions using PatFrags directly as well. Thus making it possible
to use GISelPredicateCode together with a PatFrags definition.

It might be noted that the matcher code was emitted also for PatFrags
in the past. But then one ended up with errors since the custom code
in testMIPredicate_MI was missing.

Diff Detail

Event Timeline

bjope created this revision.Mar 12 2021, 3:29 AM
bjope requested review of this revision.Mar 12 2021, 3:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2021, 3:29 AM
Herald added a subscriber: wdng. · View Herald Transcript

Looks good, I would like for other reviewers to also take a look.

llvm/test/TableGen/GlobalISelEmitterCustomPredicate.td
183

You said that matcher code was emitted also for PatFrags. GlobalISel emmiter ignores this for me without the patch (does not report skip message either). Am I missing something/is that another test? Was the emitted match code broken?

bjope added inline comments.Mar 12 2021, 6:00 AM
llvm/test/TableGen/GlobalISelEmitterCustomPredicate.td
183

The checks added at the beginning of the test case failed for me. While the matcher table checks below were generated (passing the test) also without the fix.
I haven't seen any problem with the matching. I limited the checks to verify that we get four GIM_Try blocks (the PatFrags has two patterns and both are commutative so 2x2=4 GIM_Try blocks is expected afaict).

llvm/test/TableGen/GlobalISelEmitterCustomPredicate.td
183

Ah, I see it now. Those enums were missing PatFrags, but matchers picked up the PatFrags. Looks good.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 16 2021, 4:44 AM
This revision was automatically updated to reflect the committed changes.