[PATCH] D91263: GlobalISel: Directly expose getDefSrcRegIgnoringCopies utility
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 07:26:48 PST 2020
arsenm created this revision.
arsenm added reviewers: aemerson, paquette, aditya_nandakumar, dsanders.
Herald added subscribers: hiraditya, rovka.
Herald added a project: LLVM.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
It's useful to get both the instruction and register at the same time.
https://reviews.llvm.org/D91263
Files:
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/Utils.cpp
Index: llvm/lib/CodeGen/GlobalISel/Utils.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -351,13 +351,6 @@
return MI->getOperand(1).getFPImm();
}
-namespace {
-struct DefinitionAndSourceRegister {
- MachineInstr *MI;
- Register Reg;
-};
-} // namespace
-
/// Return the source virtual register if this is a bit-preserving no-op cast,
/// otherwise Register().
static Register getCopyLikeSrcReg(const MachineInstr &MI,
@@ -389,9 +382,9 @@
}
}
-static Optional<DefinitionAndSourceRegister>
-getDefSrcRegIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI,
- bool CopyOnly) {
+Optional<DefinitionAndSourceRegister>
+llvm::getDefSrcRegIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI,
+ bool CopyOnly) {
Register DefSrcReg = Reg;
auto *DefMI = MRI.getVRegDef(Reg);
auto DstTy = MRI.getType(DefMI->getOperand(0).getReg());
Index: llvm/include/llvm/CodeGen/GlobalISel/Utils.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/Utils.h
+++ llvm/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -151,6 +151,17 @@
MachineInstr *getOpcodeDef(unsigned Opcode, Register Reg,
const MachineRegisterInfo &MRI);
+struct DefinitionAndSourceRegister {
+ MachineInstr *MI;
+ Register Reg;
+};
+
+/// Find the def instruction for \p Reg, and underlying value Register folding
+/// away any copies.
+Optional<DefinitionAndSourceRegister>
+getDefSrcRegIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI,
+ bool CopyOnly = true);
+
/// Find the def instruction for \p Reg, folding away any trivial copies. May
/// return nullptr if \p Reg is not a generic virtual register.
MachineInstr *getDefIgnoringCopies(Register Reg,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91263.304514.patch
Type: text/x-patch
Size: 1937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201111/d9da5e99/attachment.bin>
More information about the llvm-commits
mailing list