tnj_arch/
lib.rs

1//! This crate provides information about architectures.
2#![deny(missing_docs)]
3
4use target_lexicon::{Aarch64Architecture, Architecture};
5use types::I64;
6
7mod arch;
8pub mod reg;
9
10use crate::reg::Register;
11pub use arch::Arch;
12
13/// Get the air `Arch` for the given target architecture.
14pub fn get_arch(arch: Architecture) -> Option<Arch> {
15    match arch {
16        Architecture::Aarch64(Aarch64Architecture::Aarch64) => {
17            let mut regs = (0..=30)
18                .map(|n| Register::new(format!("x{}", n), I64))
19                .collect::<Vec<_>>();
20            regs.push(Register::new("sp".to_string(), I64));
21            regs.push(Register::new("pc".to_string(), I64));
22            Some(Arch::new(arch, I64, regs))
23        }
24        _ => None,
25    }
26}