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?
@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
Hi @Chris Fallin. Thank you for the clarification. Do you know if this is also true for out-of-the-box LLVM?
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
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
but the compiler passes that through, it doesn't reason about it or see it as "IO"
Last updated: Nov 22 2024 at 17:03 UTC