Need help about LLVM build coroutine
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sat Mar 2 13:18:47 UTC 2024
On 03/03/2024 2:14 AM, Dakota wrote:
> On Saturday, 2 March 2024 at 13:08:48 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> Even if I was to help you get that IR working, it won't do anything
>> useful for you.
>>
>> A coroutine in LLVM IR is the top of the call stack.
>>
>> It must be able to see all functions it calls.
>>
>> You can't pass a function in by pointer, it has to be hard coded.
>>
>> This needs compiler support, you can't write code outside of the
>> compiler for this.
>
> I see tinygo get this support by mix cpp
> https://github.com/tinygo-org/llvm-project/blob/master/libcxx/include/experimental/coroutine
>
>
> Is the same thing can be done for D ?
That c++ file belongs to LLVM, it is an older intrinsics file that I
believe from my quick searches has been replaced.
We can define it ourselves as part of ldc, that isn't the issue.
The compiler itself needs to be modified to output the appropriate IR
for the coroutine function.
There are no free lunches here unfortunately.
Unless you want to learn LLVM IR and to modify ldc to support it, there
is nothing you can do here beyond talk about how you want it in
D.General sorry.
More information about the digitalmars-d-ldc
mailing list