from Hacker News

Cranelift, a low-level retargetable code generator written in Rust

by exrook on 8/10/18, 4:29 PM with 32 comments

  • by smaddox on 8/11/18, 4:14 PM

    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.

    [1] https://cranelift.readthedocs.io/en/latest/ir.html#boolean-t...

  • by seeekr on 8/11/18, 1:43 PM

    The README says:

    "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."

  • by xvilka on 8/11/18, 3:26 PM

    Hopefully will replace LLVM one day.
  • by steveklabnik on 8/11/18, 3:30 PM

    Previously called “cretone”, by the way.
  • by kodablah on 8/11/18, 3:38 PM

    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.
  • by ndh2 on 8/11/18, 12:08 PM

    Any example or tutorial?
  • by jeandejean on 8/11/18, 4:39 PM

    I understand the enthusiasm for Rust, but I'm growing tired of these project advertised as "written in Rust" like it proves a point in itself.