[clang] [CIR] Add structured control flow for coroutine suspend points (PR #213191)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 21 06:13:24 PDT 2026


================
@@ -4710,6 +4676,85 @@ def CIR_TryCallOp : CIR_CallOpBase<"try_call",[
   ];
 }
 
+//===----------------------------------------------------------------------===//
+// CoroutineOp
+//===----------------------------------------------------------------------===//
+
+def CIR_CoroutineOp : CIR_Op<"coroutine", [
+  DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorInputs"]>,
+  NoRegionArguments, RecursivelySpeculatable, AutomaticAllocationScope
+]> {
+
+  let summary = "Groups a coroutine's structured suspend/resume/destroy control flow";
+  let description = [{
+    `cir.coroutine` is an op consisting of seven regions: `initial_suspend`,
+    `body`, `final_suspend`, grp (TODO),`unwind` (TODO), `destroy`, and`exit`.
+
+    - `initial_suspend`: the coroutine ramp/setup region. Its `cir.await` marked
+      `init` is the ramp boundary: the coroutine frame and its associated state
+      are established before this point, and crossing the await transfers
+      execution to `body`.
+
----------------
erichkeane wrote:

Can we do newlines between each section?

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


More information about the cfe-commits mailing list