dynasm\arch\aarch64/
mod.rs

1use syn::parse;
2use proc_macro_error2::emit_error;
3
4mod ast;
5mod parser;
6mod matching;
7mod compiler;
8mod aarch64data;
9mod encoding_helpers;
10mod debug;
11
12use crate::State;
13use crate::arch::Arch;
14
15#[cfg(feature = "dynasm_opmap")]
16pub use debug::create_opmap;
17#[cfg(feature = "dynasm_extract")]
18pub use debug::extract_opmap;
19
20struct Context<'a, 'b: 'a> {
21    pub state: &'a mut State<'b>
22}
23
24#[derive(Clone, Debug, Default)]
25pub struct ArchAarch64 {
26
27}
28
29impl Arch for ArchAarch64 {
30    fn set_features(&mut self, features: &[syn::Ident]) {
31        if let Some(feature) = features.first() {
32            emit_error!(feature, "Arch aarch64 has no known features");
33        }
34    }
35
36    fn default_align(&self) -> u8 {
37        0
38    }
39
40    fn compile_instruction(&self, state: &mut State, input: parse::ParseStream) -> parse::Result<()> {
41        let mut ctx = Context {
42            state
43        };
44
45        let (instruction, args) = parser::parse_instruction(&mut ctx, input)?;
46        let span = instruction.span;
47
48        let match_data = match matching::match_instruction(&mut ctx, &instruction, args) {
49            Err(None) => return Ok(()),
50            Err(Some(e)) => {
51                emit_error!(span, e);
52                return Ok(())
53            }
54            Ok(m) => m
55        };
56
57        match compiler::compile_instruction(&mut ctx, match_data) {
58            Err(None) => return Ok(()),
59            Err(Some(e)) => {
60                emit_error!(span, e);
61                return Ok(())
62            }
63            Ok(()) => ()
64        }
65
66        Ok(())
67    }
68}