Introduce TF WhileOp and lower it to MLIR CFG
authorSmit Hinsu <hinsu@google.com>
Wed, 21 Nov 2018 02:43:22 +0000 (18:43 -0800)
committerjpienaar <jpienaar@google.com>
Fri, 29 Mar 2019 21:06:04 +0000 (14:06 -0700)
Also, added iterators for VariadicResults class.

TESTED with unit tests

TODOs:
- Handle non-bool condition results (similar to the IfOp)
- Use PatternRewriter
PiperOrigin-RevId: 222340376

mlir/include/mlir/IR/OpDefinition.h

index 7afbb2c98760c88357c21e05d3c7e66105d67357..2fa2c7e945fc440007827cc7025c521d957f6069 100644 (file)
@@ -597,6 +597,28 @@ public:
   void setResult(unsigned i, SSAValue *value) {
     this->getOperation()->setResult(i, value);
   }
+
+  // Support non-const result iteration.
+  using result_iterator = Operation::result_iterator;
+  result_iterator result_begin() {
+    return this->getOperation()->result_begin();
+  }
+  result_iterator result_end() { return this->getOperation()->result_end(); }
+  llvm::iterator_range<result_iterator> getResults() {
+    return this->getOperation()->getResults();
+  }
+
+  // Support const result iteration.
+  using const_result_iterator = Operation::const_result_iterator;
+  const_result_iterator result_begin() const {
+    return this->getOperation()->result_begin();
+  }
+  const_result_iterator result_end() const {
+    return this->getOperation()->result_end();
+  }
+  llvm::iterator_range<const_result_iterator> getResults() const {
+    return this->getOperation()->getResults();
+  }
 };
 
 /// This class provides verification for ops that are known to have the same