1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#[macro_use]
mod cdsl;
mod srcgen;
pub mod error;
pub mod isa;
mod gen_inst;
mod gen_settings;
mod gen_types;
mod constant_hash;
mod shared;
mod unique_table;
pub fn isa_from_arch(arch: &str) -> Result<isa::Isa, String> {
isa::Isa::from_arch(arch).ok_or_else(|| format!("no supported isa found for arch `{}`", arch))
}
pub fn generate(isas: &[isa::Isa], out_dir: &str, isle_dir: &str) -> Result<(), error::Error> {
let mut shared_defs = shared::define();
gen_settings::generate(
&shared_defs.settings,
gen_settings::ParentGroup::None,
"settings.rs",
&out_dir,
)?;
gen_types::generate("types.rs", &out_dir)?;
let target_isas = isa::define(isas, &mut shared_defs);
let all_formats = shared_defs.verify_instruction_formats();
gen_inst::generate(
all_formats,
&shared_defs.all_instructions,
"opcodes.rs",
"inst_builder.rs",
"clif.isle",
&out_dir,
isle_dir,
)?;
for isa in target_isas {
gen_settings::generate(
&isa.settings,
gen_settings::ParentGroup::Shared,
&format!("settings-{}.rs", isa.name),
&out_dir,
)?;
}
Ok(())
}