-
Reactor (LLVM): Add support for Coroutines. · 1c82c7b8Ben Clayton authored
rr::Coroutines are similar to rr::Functions in that it builds a new executable function, but Coroutines have the following differences: (1) Coroutines do not support Return() statements. (2) Coroutines support Yield() statements to suspend execution of the coroutine and pass a value up to the caller. Yield can be called multiple times in a single execution of a coroutine. (3) The template argument T to Coroutine<T> is a C-style function signature. (4) Coroutine::operator() returns a rr::Stream<T> instead of an rr::Routine. (5) operator() starts execution of the coroutine immediately. (6) operator() uses the Coroutine's template function signature to ensure the argument types match the generated function signature. It is my personal opinion that (3), (5) and (6) provide a more convenient and safer interface and this could be adopted by rr::Function (post immediate milestone). Coroutines expose 3 externally callable functions: (1) 'coroutine_begin' - the main entry point of the coroutine. Allocates a coroutine stack frame, and executes up to the first call to Yield(). (2) 'coroutine_await' - the function to collect a yielded value and resume execution of the suspended coroutine. (3) 'coroutine_destroy' - the function to destruct and release the coroutine stack frame. As there are now three exposed functions for coroutines, rr::Routine::getEntry() now takes a function index. Standard rr::Functions always pass 0. rr::Nucleus::CoroutineEntries is an enumerator of these coroutine functions that correspond to the function index passed to rr::Routine::getEntry(). This change also adds third_party/llvm-7.0/stubs/Stubs.cpp. This file holds stub functions that are never called by LLVM, but are referenced by the linker. Actually linking in the file that declares these functions will drag in more referenced files, significantly slowing the build and potentially bloating the final executable size. Coroutines are not currently supported by Subzero. Bug: b/131672705 Change-Id: I0b13fe38b84c8dc85f4678019bf8d8afa7d9c37a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30212Tested-by:Ben Clayton <bclayton@google.com> Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by:
Nicolas Capens <nicolascapens@google.com>
1c82c7b8
×