Stream: cranelift

Topic: Does Cranelift IR support any kind of I/O operations?


view this post on Zulip Mohannad Al-Awad (Dec 16 2022 at 17:22):

I was reading through the list of IR instructions while I was wondering if I/O (i.e. other than CPU and RAM data crunching) can be achieved? If not, then the only way is through calling OS API's, am I correct? Is this also true for LLVM?

view this post on Zulip Chris Fallin (Dec 16 2022 at 18:04):

@Mohannad Al-Awad nope, the only means of interacting with the outside world is by calling other functions (or by accessing memory with atomics and communicating with an outside thread/process using s ahared-memory protocol of some sort). This is pretty typical for a compiler: the core code generation functionality is generic across OSes and the surrounding environment, and it's up to the embedder (the application that invokes Cranelift) to provide hooks/imports

view this post on Zulip Mohannad Al-Awad (Dec 16 2022 at 18:08):

Hi @Chris Fallin. Thank you for the clarification. Do you know if this is also true for out-of-the-box LLVM?

view this post on Zulip Chris Fallin (Dec 16 2022 at 18:09):

I think so, yeah; LLVM has builtin intrinsics that sometimes become calls to the runtime (e.g., memcpy), but nothing for e.g. a syscall or anything like that

view this post on Zulip Chris Fallin (Dec 16 2022 at 18:09):

err, I guess an exception could be its inline assembly support, in a trivial sort of way: one could use inline assembly to embed a syscall instruction, or (in kernel code) x86 IO instructions or whatnot

view this post on Zulip Chris Fallin (Dec 16 2022 at 18:10):

but the compiler passes that through, it doesn't reason about it or see it as "IO"


Last updated: Dec 23 2024 at 13:07 UTC