[PATCH] D99734: [MIPatternMatch]: Add ICstRegMatch
Petar Avramovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 1 08:03:36 PDT 2021
Petar.Avramovic created this revision.
Petar.Avramovic added reviewers: arsenm, foad.
Petar.Avramovic requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Matches G_CONSTANT and returns its def register.
https://reviews.llvm.org/D99734
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
@@ -90,6 +90,22 @@
}
///}
+struct ICstRegMatch {
+ Register &CR;
+ ICstRegMatch(Register &C) : CR(C) {}
+ bool match(const MachineRegisterInfo &MRI, Register Reg) {
+ if (auto MaybeCst = getConstantVRegValWithLookThrough(
+ Reg, MRI, /*LookThroughInstrs*/ true,
+ /*HandleFConstants*/ false)) {
+ CR = MaybeCst->VReg;
+ return true;
+ }
+ return false;
+ }
+};
+
+inline ICstRegMatch m_ICst(Register &Reg) { return ICstRegMatch(Reg); }
+
// TODO: Rework this for different kinds of MachineOperand.
// Currently assumes the Src for a match is a register.
// We might want to support taking in some MachineOperands and call getReg on
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99734.334701.patch
Type: text/x-patch
Size: 929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210401/4bf04902/attachment.bin>
More information about the llvm-commits
mailing list