#register #assembly #offset #regs

bin+lib cranelift-assembler-x64

A Cranelift-specific x64 assembler

4 releases

0.118.0 Mar 20, 2025
0.117.2 Feb 25, 2025
0.117.1 Feb 21, 2025
0.117.0 Feb 20, 2025

#374 in Programming languages

Download history 919/week @ 2025-02-14 10123/week @ 2025-02-21 16937/week @ 2025-02-28 16667/week @ 2025-03-07 20564/week @ 2025-03-14 16467/week @ 2025-03-21 26135/week @ 2025-03-28

82,229 downloads per month
Used in 52 crates (2 directly)

Apache-2.0 WITH LLVM-exception

57KB
1K SLoC

cranelift-assembler-x64

A Cranelift-specific x64 assembler. Unlike the existing cranelift-codegen assembler, this assembler uses instructions, not instruction classes, as the core abstraction.

Use

Like cranelift-codegen, using this assembler starts with enum Inst. For convenience, a main.rs script prints the path to this generated code:

$ cat $(cargo run) | head
...
pub enum Inst<R:Registers> {
    andb_i(andb_i),
    andw_i(andw_i),
    andl_i(andl_i),
    ...

Test

In order to check that this assembler emits correct machine code, we fuzz it against a known-good disassembler. We can run a quick, one-second check:

$ cargo test -- --nocapture

Or we can run the fuzzer indefinitely:

$ cargo +nightly fuzz run -s none roundtrip -j16

Dependencies

~0–5MB
~157K SLoC