You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Coroutines] Documentation for custom ABIs (#111781)
Update the llvm/docs/Coroutines.rst docs to include a full description
of Custom ABI objects. This documentation describes the how ABI objects
allow users (plugin libraries) to create custom ABI objects for their
needs.
Copy file name to clipboardExpand all lines: llvm/docs/Coroutines.rst
+90Lines changed: 90 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -312,6 +312,7 @@ lowered to a constant representing the size required for the coroutine frame.
312
312
The `coro.begin`_ intrinsic initializes the coroutine frame and returns the
313
313
coroutine handle. The second parameter of `coro.begin` is given a block of memory
314
314
to be used if the coroutine frame needs to be allocated dynamically.
315
+
315
316
The `coro.id`_ intrinsic serves as coroutine identity useful in cases when the
316
317
`coro.begin`_ intrinsic get duplicated by optimization passes such as
317
318
jump-threading.
@@ -749,6 +750,65 @@ and python iterator `__next__` would look like:
749
750
return *(int*)coro.promise(hdl, 4, false);
750
751
}
751
752
753
+
Custom ABIs and Plugin Libraries
754
+
--------------------------------
755
+
756
+
Plugin libraries can extend coroutine lowering enabling a wide variety of users
757
+
to utilize the coroutine transformation passes. An existing coroutine lowering
758
+
is extended by:
759
+
760
+
#. defining custom ABIs that inherit from the existing ABIs,
761
+
#. give a list of generators for the custom ABIs when constructing the `CoroSplit`_ pass, and
762
+
#. use `coro.begin.custom.abi`_ in place of `coro.begin`_ that has an additional parameter for the index of the generator/ABI to be used for the coroutine.
763
+
764
+
A custom ABI overriding the SwitchABI's materialization looks like:
765
+
766
+
.. code-block:: c++
767
+
768
+
class CustomSwitchABI : public coro::SwitchABI {
769
+
public:
770
+
CustomSwitchABI(Function &F, coro::Shape &S)
771
+
: coro::SwitchABI(F, S, ExtraMaterializable) {}
772
+
};
773
+
774
+
Giving a list of custom ABI generators while constructing the `CoroSplit`
0 commit comments