This is an archive of the discontinued LLVM Phabricator instance.

[MIPatternMatch]: Add mi_match for MachineInstr
ClosedPublic

Authored by Petar.Avramovic on Apr 1 2021, 8:04 AM.

Details

Summary

This utility allows more efficient start of pattern match.
Often MachineInstr(MI) is available and instead of using
mi_match(MI.getOperand(0).getReg(), MRI, ...) followed by
MRI.getVRegDef(Reg) that gives back MI we now use
mi_match(MI, MRI, ...).

Diff Detail

Event Timeline

Petar.Avramovic requested review of this revision.Apr 1 2021, 8:04 AM
Petar.Avramovic created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2021, 8:04 AM

Probably should have some unit tests for this

paquette added inline comments.Apr 1 2021, 3:35 PM
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
192

Maybe simpler?

Can we have testcases which check what happens with

  • An instruction with 0 defs
  • An instruction with > 1 def

?

Added tests for instructions with 0 and 2 defs.

foad accepted this revision.Apr 26 2021, 3:58 AM

I don't fully understand the C++ but this looks like a useful enhancement to me.

This revision is now accepted and ready to land.Apr 26 2021, 3:58 AM
This revision was landed with ongoing or failed builds.Apr 27 2021, 2:28 AM
This revision was automatically updated to reflect the committed changes.