1 //! This crate generates Cranelift-specific assembly code for x64 instructions; see the `README.md`
2 //! for more information.
3 
4 pub mod dsl;
5 mod generate;
6 pub mod instructions;
7 
8 use cranelift_srcgen::{Formatter, Language};
9 use 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.
generate_rust_assembler<P: AsRef<Path>>(dir: P, file: &str) -> PathBuf17 pub 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 }
25