[PATCH] D151423: [MachineInstr] Implement new operand accessors all_defs and all_uses
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 04:28:44 PDT 2023
foad created this revision.
Herald added a subscriber: StephenFan.
Herald added a project: All.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151423
Files:
llvm/include/llvm/CodeGen/MachineInstr.h
Index: llvm/include/llvm/CodeGen/MachineInstr.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineInstr.h
+++ llvm/include/llvm/CodeGen/MachineInstr.h
@@ -702,6 +702,31 @@
operands_begin() + getNumExplicitOperands());
}
+ /// Returns an iterator range over all operands that are (explicit or
+ /// implicit) register defs.
+ auto all_defs() {
+ return make_filter_range(operands(), [](MachineOperand &Op) {
+ return Op.isReg() && Op.isDef();
+ });
+ }
+ auto all_defs() const {
+ return make_filter_range(operands(), [](const MachineOperand &Op) {
+ return Op.isReg() && Op.isDef();
+ });
+ }
+
+ /// Returns an iterator range over all operands that are (explicit or
+ /// implicit) register uses.
+ auto all_uses() {
+ return make_filter_range(
+ uses(), [](MachineOperand &Op) { return Op.isReg() && Op.isUse(); });
+ }
+ auto all_uses() const {
+ return make_filter_range(uses(), [](const MachineOperand &Op) {
+ return Op.isReg() && Op.isUse();
+ });
+ }
+
/// Returns the number of the operand iterator \p I points to.
unsigned getOperandNo(const_mop_iterator I) const {
return I - operands_begin();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151423.525542.patch
Type: text/x-patch
Size: 1254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/80d9760d/attachment.bin>
More information about the llvm-commits
mailing list