Hello there.
I'm a complete noob, hope you don't mind.
I want to learn IR by programming in it directly. Is this possible?
For example, how would reproduce this exact c programm in IR?
int main() { return 1; }
and how would one compile it?
Maybe:
function %main() -> i32 {
block0:
v0 = iconst.i32 1
return v0
}
If you stick that in a test run
filetest you should be able to run that with clif-util
: https://github.com/bytecodealliance/wasmtime/blob/master/cranelift/docs/testing.md#test-run
The easiest way to run that is likely: cargo run -p cranelift-tools -- run [options, see --help] scratch.clif
Oh, and you asked how to compile it: cargo run -p cranelift-tools -- compile [options, see --help] scratch.clif
@Andrew Brown your reply came insanely fast and it's perfect. Thanks a dozen!
Do you happen to know in which directory of the wasmtime repo I have to be in, to issue this command?
Just the main directory
I see. While I've tried to get this to work, I ran into the error message
error: failed to read `/Users/nilsmartel/Development/Repositories/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.toml`
Caused by:
No such file or directory (os error 2)
Which seems to be strange, since I have the current master pulled. Do you happen to know a way to circumvent this?
(command issued was just cargo run -p cranelift-tools
)
git submodule update --init
that was awesome, thank you Joey!
Last updated: Dec 23 2024 at 12:05 UTC