================
@@ -4702,6 +4619,131 @@ def CIR_CoReturnOp : CIR_Op<"co_return", [
let hasLLVMLowering = false;
}
+//===----------------------------------------------------------------------===//
+// Coroutine intrinsics
+//===----------------------------------------------------------------------===//
+
+class CIR_CoroIntrinsicOp<string mnem, dag ins, dag outs,
+ list<Trait> traits = []>
+ : CIR_Op<"coro.intrinsic." # mnem, traits> {
+ let hasLLVMLowering = 1;
+ let arguments = ins;
+ let results = outs;
+
+ let assemblyFormat = [{
+ `(` operands `)` `:` functional-type(operands, results) attr-dict
+ }];
+}
+//===----------------------------------------------------------------------===//
+// Coroutine intrinsic IdOp
+//===----------------------------------------------------------------------===//
+
+// TODO: This operation should return an MLIR `token` once the type becomes
+// available. `CIR_UInt32` is used as a temporary placeholder.
+def CIR_CoroIntrinsicIdOp : CIR_CoroIntrinsicOp<"id",
+ (ins CIR_AnyIntType:$align, CIR_VoidPtrType:$promise,
+ CIR_VoidPtrType:$coroaddr, CIR_VoidPtrType:$fnaddrs),
+ (outs CIR_UInt32:$result)> {
+ let summary = "Represents llvm.coro.id";
+ let description = [{
+ Marks the beginning of a coroutine's lifetime and identifies it to the
+ rest of the coroutine intrinsics. Takes the required alignment of the
+ coroutine frame, a pointer to the coroutine promise (or null if none),
+ the address of the coroutine function itself, and an opaque pointer used
+ by the frontend to convey additional information to the coroutine
+ lowering passes (or null).
+
+ The result is a token that must be passed to every other
+ `coro.intrinsic.*` operation associated with this coroutine
+ (`coro.alloc`, `coro.begin`, `coro.free`, etc.), tying them all to the
+ same coroutine instance.
+ }];
+}
+
+//===----------------------------------------------------------------------===//
+// Coroutine intrinsic AllocOp
+//===----------------------------------------------------------------------===//
+
+def CIR_CoroIntrinsicAllocOp : CIR_CoroIntrinsicOp<"alloc",
+ (ins CIR_AnyIntType:$id),
+ (outs CIR_AnyBoolType:$result)> {
+ let summary = "Represents llvm.coro.alloc";
+ let description = [{
+ Queries whether the coroutine identified by `id` needs a dynamically
+ allocated frame. Returns `true` if the coroutine frame must be allocated,
+ or `false` otherwise.
----------------
Andres-Salamanca wrote:
Yeah, agreed the name is misleading that's actually why I've been calling it
`ShouldAlloc` in my tests. It's also relevant down the line since the coroutine
lowering pass may be able to elide the heap allocation entirely, so it really
is "should we alloc" rather than "do the alloc".
https://github.com/llvm/llvm-project/pull/211699
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits