[Mlir-commits] [mlir] [mlir][emitc] Add a structured for operation (PR #68206)

Marius Brehler llvmlistbot at llvm.org
Wed Oct 25 07:30:09 PDT 2023


================
@@ -246,6 +246,67 @@ def EmitC_DivOp : EmitC_BinaryOp<"div", []> {
   let results = (outs FloatIntegerIndexOrOpaqueType);
 }
 
+def EmitC_ForOp : EmitC_Op<"for",
+      [AllTypesMatch<["lowerBound", "upperBound", "step"]>,
+       SingleBlockImplicitTerminator<"emitc::YieldOp">,
+       RecursiveMemoryEffects]> {
+  let summary = "for operation";
+  let description = [{
+    The `emitc.for` operation represents a C loop of the following form:
+
+    ```c++
+    for (size_t i = lb; i < ub; i += step) { /* ... */ }
----------------
marbre wrote:

> Not necessarily if you change to `IntegerIndexOrOpaqueType` as you suggested (?).

Forget about my previous comment... I actually intended to underline that it must not be an `size_t`.

https://github.com/llvm/llvm-project/pull/68206


More information about the Mlir-commits mailing list