Cranelift

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Cranelift
DeveloperBytecode Alliance
Initial release2016; 10 years ago (2016)
Stable release
0.105.2 / February 28, 2024; 2 years ago (2024-02-28)
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inRust
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemCross-platform
    TypeCompiler
    LicenseApache License with LLVM exceptions[1]
    Websitecranelift.dev

    Cranelift (formerly known as Cretonne) is an optimizing compiler backend that converts a target-independent intermediate representation into executable machine code. It is written in Rust. The project started in 2016 and is currently developed by Bytecode Alliance.[2][3] Unlike compiler backends such as LLVM that focus more on ahead-of-time compilation, Cranelift instead focuses on just-in-time compilation with short compile time being an explicit goal of the project.[4]

    As of 2023, Cranelift supports instruction set architectures such as x86-64, AArch64, RISC-V, and IBM z/Architecture.

    History

    [edit | edit source]

    Prior to the backend framework rewrite in 2020, the project made use of only one intermediate representation (IR) across all compilation stages prior to machine code emission, namely CLIF (Cranelift IR Format). The old design made use of instruction legalizations, which involved transforming the high-level IR continuously until each CLIF instruction corresponded to an instruction of the target machine, at which point the executable code could be emitted.

    In 2020, the backend was rewritten to use a separate, machine-specific IR called VCode for later compilation stages instead. After this rewrite, a high-level input CLIF would be optimized by a middle layer before being lowered into VCode, which would be further transformed by remaining passes in the backend.[4] Peepmatic, a tool used to generate a peephole optimizer from a domain-specific language (DSL), was also added,[5] though it was later removed.[6]

    In 2022, a new register allocator, which was adapted from the register allocator from IonMonkey, was added. In addition, the backend framework was reworked to utilize ISLE (Instruction Selection/Lowering Expressions DSL), another DSL in the project that was made to ease the development of the instruction selection stage in backends.[7]

    The mid-end saw addition of optimization passes that make use of e-graphs in 2022.[8] The optimization passes are enabled by default starting in 2023.

    Applications

    [edit | edit source]

    Cranelift is used by multiple WebAssembly runtimes, such as [[Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value).]]  and [[Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value).]] , with performance comparable to LLVM-based runtimes.[9]

    An alternative code generator for the Rust compiler that is powered by Cranelift also exists.[10]

    See also

    [edit | edit source]

    Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).