[PATCH] D99735: [MIPatternMatch]: Add mi_match for MachineInstr
Petar Avramovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 1 08:04:18 PDT 2021
Petar.Avramovic created this revision.
Petar.Avramovic added reviewers: foad, arsenm.
Petar.Avramovic requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
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, ...).
https://reviews.llvm.org/D99735
Files:
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
Index: llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -24,6 +24,11 @@
return P.match(MRI, R);
}
+template <typename Pattern>
+bool mi_match(MachineInstr &MI, const MachineRegisterInfo &MRI, Pattern &&P) {
+ return P.match(MRI, &MI);
+}
+
// TODO: Extend for N use.
template <typename SubPatternT> struct OneUse_match {
SubPatternT SubPat;
@@ -181,6 +186,13 @@
return true;
return false;
}
+ static bool bind(const MachineRegisterInfo &MRI, MachineInstr *&MI,
+ MachineInstr *Inst) {
+ MI = Inst;
+ if (MI)
+ return true;
+ return false;
+ }
};
template <> struct bind_helper<LLT> {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99735.334702.patch
Type: text/x-patch
Size: 841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210401/4ac468f8/attachment.bin>
More information about the llvm-commits
mailing list