12 Commits

Author SHA1 Message Date
Andres-Salamanca
626e3423f8
[CIR] Upstream coroutine builtin coro_end (#176598)
This PR adds support for emitting the `__builtin_coro_end` builtin in
CIR.
2026-01-22 19:02:01 -05:00
Andres-Salamanca
387e6e2b70
[CIR] Upstream support co_return of values from co_await (#173174)
This PR adds support for returning the result of a `co_await` via
`co_return`. A new variable, `__coawait_resume_rval`, is introduced to
store the returned value.
2026-01-16 21:38:45 -05:00
Andres-Salamanca
ba2eaa9f61
[CIR] Upstream support for coroutine co_yield expression (#173162)
This PR upstreams support for the co_yield expression by emitting a
cir.await op with the yield kind.
2026-01-14 22:04:07 -05:00
Andres-Salamanca
4ba8352693
[CIR] Partially upstream coroutine co_return support (#171755)
This PR partially upstreams support for the `co_return` keyword. It
still needs to address the case where a `co_return` returns a value from
a `co_await`.
Additionally, this change focuses on `emitBodyAndFallthrough`, where
depending on whether the function falls through or not it will emit the
user written `co_await`. Another thing to note is the difference from
classic CodeGen, previously it checked whether it could fall through by
using `GetInsertBlock()` to verify that the block existed. In our case,
when a `co_return` is emitted, we mark `setCoreturn()` to indicate that
the coroutine contains a `co_return`.
2025-12-18 08:30:52 -05:00
Andres-Salamanca
64a7628048
[CIR] Upstream Emit the resume branch for cir.await op (#169864)
This PR upstreams the emission of the `cir.await` resume branch.
Handling the case where the return value of `co_await` is not ignored is
deferred to a future PR, which will be added once `co_return` is
upstreamed. Additionally, the `forLValue` variable is always `false` in
the current implementation. When support for emitting `coro_yield` is
added, this variable will be set to `true`, so that work is also
deferred to a future PR.
2025-12-01 18:48:26 -05:00
Andres-Salamanca
97023fba55
[CIR] Emit ready and suspend branches for cir.await (#168814)
This PR adds codegen for `cir.await` ready and suspend. One notable
difference from the classic codegen is that, in the suspend branch, it
emits an `AwaitSuspendWrapper`(`.__await_suspend_wrapper__init`)
function that is always inlined. This function wraps the suspend logic
inside an internal wrapper that gets inlined. Example here:
https://godbolt.org/z/rWYGcaaG4
2025-11-25 17:16:21 -05:00
Andy Kaylor
ef0cd1dae3
[CIR][NFC] Fix warnings in release builds (#168791)
This fixes several warnings that occur in CIR release builds.
2025-11-19 16:12:17 -08:00
Andres-Salamanca
5c43385319
[CIR] Upstream CIR await op (#168133)
This PR upstreams `cir.await` and adds initial codegen for emitting a
skeleton of the ready, suspend, and resume branches. Codegen for these
branches is left for a future PR. It also adds a test for the invalid
case where a `cir.func` is marked as a coroutine but does not contain a
`cir.await` op in its body.
2025-11-19 17:08:23 -05:00
Andres-Salamanca
cf9cb542f2
[CIR] Emit promise declaration in coroutine (#166683)
This PR adds support for emitting the promise declaration in coroutines
and obtaining the `get_return_object()`.
2025-11-12 16:29:11 -05:00
Andres-Salamanca
217f0e54c9
[CIR][NFC] Update TypeCache file to use MLIR-style camel case (#165060)
This PR updates the file `CIRGenTypeCache` to use MLIR-style camel case
naming.The change was inspired by the discussion here:
https://github.com/llvm/llvm-project/pull/164180#discussion_r2461444730
2025-10-28 19:26:33 -05:00
Andres-Salamanca
4448ff453d
[CIR] Emit CIR builtins: coroAlloc, coroBegin, and coroSize (#164180)
This PR adds support for emitting the builtins coroAlloc, coroBegin, and
coroSize.
2025-10-24 17:55:29 -05:00
Andres-Salamanca
16f5a85fb6
[CIR] Initial support for emitting coroutine body (#161616)
This PR adds new `FuncOp` attributes (`coroutine` and `builtin`) and
begins the implementation of the `emitCoroutineBody` function. Feature
markers were also added for guidance in future PRs.
2025-10-03 13:56:53 -05:00