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

Jacques Pienaar llvmlistbot at llvm.org
Wed Oct 4 14:48:51 PDT 2023


================
@@ -246,6 +247,81 @@ def EmitC_DivOp : EmitC_BinaryOp<"div", []> {
   let results = (outs FloatIntegerIndexOrOpaqueType);
 }
 
+def EmitC_ForOp : EmitC_Op<"for",
+      [AutomaticAllocationScope, DeclareOpInterfaceMethods<LoopLikeOpInterface,
+       ["getInits", "getSingleInductionVar", "getSingleLowerBound",
+        "getSingleStep", "getSingleUpperBound"]>,
+       AllTypesMatch<["lowerBound", "upperBound", "step"]>,
+       DeclareOpInterfaceMethods<RegionBranchOpInterface,
+        ["getEntrySuccessorOperands"]>,
+       SingleBlockImplicitTerminator<"emitc::YieldOp">,
+       RecursiveMemoryEffects]> {
+  let summary = "for operation";
+  let description = [{
+    The `emitc.for` operation represents a loop taking 3 SSA values as operands
+    that represent the lower bound, upper bound and step respectively. The
+    operation defines an SSA value for its induction variable. It has one
----------------
jpienaar wrote:

This is a bit more restrictive than C isn't it? E.g., you can define a variables inside the clause statement and initialize them. So this would be closer to 3 basic blocks

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


More information about the Mlir-commits mailing list