cranelift_assembler_x64_meta/
lib.rs

1//! This crate generates Cranelift-specific assembly code for x64 instructions; see the `README.md`
2//! for more information.
3
4pub mod dsl;
5mod generate;
6pub mod instructions;
7
8use cranelift_srcgen::{Formatter, Language};
9use std::path::{Path, PathBuf};
10
11/// Generate the assembler `file` containing the core assembler logic; each of
12/// the DSL-defined instructions is emitted into a Rust `enum Inst`.
13///
14/// # Panics
15///
16/// This function panics if we cannot update the file.
17pub fn generate_rust_assembler<P: AsRef<Path>>(dir: P, file: &str) -> PathBuf {
18    let out = dir.as_ref().join(file);
19    eprintln!("Generating {}", out.display());
20    let mut fmt = Formatter::new(Language::Rust);
21    generate::rust_assembler(&mut fmt, &instructions::list());
22    fmt.write(file, dir.as_ref()).unwrap();
23    out
24}