[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 05:51:32 PDT 2023


foad updated this revision to Diff 525565.
foad added a comment.

\copydoc


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151423/new/

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,33 @@
                       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();
+    });
+  }
+  /// \copydoc all_defs()
+  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(); });
+  }
+  /// \copydoc all_uses()
+  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.525565.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/9228a17d/attachment.bin>


More information about the llvm-commits mailing list