1#[derive(Clone, Copy, Debug, PartialEq)]
2pub enum Endianness {
3 Little,
4 Big,
5}
6
7#[derive(Clone, Copy, Debug, PartialEq)]
8pub struct ArchConfig {
9 pub name: &'static str,
10 pub pointer_size: usize,
11 pub cache_line_size: usize,
12 pub max_align: usize,
13 pub endianness: Endianness,
14}
15
16pub const X86_64_SYSV: ArchConfig = ArchConfig {
17 name: "x86_64",
18 pointer_size: 8,
19 cache_line_size: 64,
20 max_align: 16,
21 endianness: Endianness::Little,
22};
23
24pub const AARCH64: ArchConfig = ArchConfig {
25 name: "aarch64",
26 pointer_size: 8,
27 cache_line_size: 64,
28 max_align: 16,
29 endianness: Endianness::Little,
30};
31
32pub const AARCH64_APPLE: ArchConfig = ArchConfig {
33 name: "aarch64-apple",
34 pointer_size: 8,
35 cache_line_size: 128,
36 max_align: 16,
37 endianness: Endianness::Little,
38};
39
40pub const WASM32: ArchConfig = ArchConfig {
41 name: "wasm32",
42 pointer_size: 4,
43 cache_line_size: 64,
44 max_align: 8,
45 endianness: Endianness::Little,
46};
47
48pub const RISCV64: ArchConfig = ArchConfig {
49 name: "riscv64",
50 pointer_size: 8,
51 cache_line_size: 64,
52 max_align: 16,
53 endianness: Endianness::Little,
54};
55
56pub fn arch_by_name(name: &str) -> Option<&'static ArchConfig> {
60 match name {
61 "x86_64" => Some(&X86_64_SYSV),
62 "aarch64" => Some(&AARCH64),
63 "aarch64_apple" => Some(&AARCH64_APPLE),
64 "wasm32" => Some(&WASM32),
65 "riscv64" => Some(&RISCV64),
66 _ => None,
67 }
68}