It's interesting that booleans are stored as 0 or -1 [1]. I wonder what drove that decision. I just checked, and Rust's LLVM stores booleans as 0 or 1.
That would only be true if `a` is guaranteed to be a non-zero value though, right? e.g. `x = some_bool ? 0 : 1` would not be able to be represented that way.
"Cranelift is designed to be a code generator for WebAssembly, but it is general enough to be useful elsewhere too. The initial planned uses that affected its design are:
WebAssembly compiler for the SpiderMonkey engine in Firefox.
Backend for the IonMonkey JavaScript JIT compiler in Firefox.
Debug build backend for the Rust compiler."
Faster would be the most desirable attribute in my opinion. Rust should be much faster at least for development builds and LLVM is one of the parts which slows it down.
Does it, or are there plans to, translate the IR to WASM (i.e. a WASM backend instead of just frontend)? This seems to have a more expressive set of instructions than WASM and could be a good target for compilers.
It is something we're thinking about. You might have to limit yourself to a subset of the full Cranelift IR for this, but I think we could make that subset big enough to be interesting.
There's a tutorial in development, but it's not finished yet. So right now isn't the optimal time for an HN post, but HN doesn't always ask people before linking to their projects ¯\_(ツ)_/¯.
Sure, it doesn't prove a point, but the headline does show the level of growth Rust is enjoying... It's not that different than "game X on Linux" in the early days, or "ML in Python".
[1] https://cranelift.readthedocs.io/en/latest/ir.html#boolean-t...