================
@@ -784,8 +890,28 @@ emitSuspendExpression(CIRGenFunction &cgf, CGCoroData
&coro,
cir::CoroSuspendPoint::create(builder, loc);
break;
case CoroutineSuspendExpr::SuspendReturnType::SuspendHandle:
- cgf.cgm.errorNYI(s.getSourceRange(),
- "await_suspend returning handle");
+ cir::FuncOp coroutineFunction = mlir::cast<cir::FuncOp>(cgf.curFn);
+
+ CIRGenFunction wrapperCGF(cgf.cgm, builder);
+
+ cir::FuncOp suspendWrapper = wrapperCGF.generateAwaitSuspendWrapper(
+ coroutineFunction.getSymName(), suspendPointName, s);
+
+ mlir::Value awaiterPointer =
+ cgf.getOrCreateOpaqueLValueMapping(s.getOpaqueValue())
+ .getPointer();
+
+ assert(coro.coroBegin && "expected coroutine frame");
+
+ cir::PointerType wrapperPointerType =
+ cir::PointerType::get(suspendWrapper.getFunctionType());
+
+ mlir::Value wrapperPointer = cir::GetGlobalOp::create(
+ builder, loc, wrapperPointerType, suspendWrapper.getSymName());
+
+ // TODO(cir): Handle exceptions when resuming the returned coroutine.
+ cir::CoroAwaitSuspendHandleOp::create(builder, loc, awaiterPointer,
----------------
Andres-Salamanca wrote:
OG generates the wrapper above the switch and uses it for all three cases
(void/bool/handle), only the intrinsic changes. Could we structure this so the
wrapper generation is reusable for bool/void too? `suspendPointName` is already
computed above the switch. Fine with doing the bool/void move in a follow-up,
but it’d be nice to set it up that way here.
https://github.com/llvm/llvm-project/pull/240737
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits