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
66
67
68
69
70
71
72
73
74
75
76
77
//! `offlineasm`: a portable assembler for x86-64, AArch64, and RISC-V 64.
//!
//! The [`offlineasm!`] macro parses offlineasm assembly at compile time.
//! With `backend = native` it emits `global_asm!()` for the target, and with
//! `backend = rloop` it emits a dispatch loop in Rust.
//!
//! [`offlineasm_include!`] includes a file and compiles it the same way.
//!
//! ```no_run
//! use offlineasm::offlineasm;
//!
//! offlineasm! {
//! settings {
//! backend = native,
//! }
//!
//! global _answer
//! _answer:
//! move t0, 42
//! ret
//! }
//!
//! fn main() {}
//! ```
//!
//! Each `settings { ... }` entry maps an offlineasm setting to a Rust `cfg`
//! predicate, and a generated `macro_rules!` chain resolves it at compile
//! time, because a proc macro cannot evaluate `cfg(...)` itself. Without a
//! `settings` block the macro emits every valid combination behind its own
//! `#[cfg(...)]` guard.
//!
//! ## The rloop backend
//!
//! `backend = rloop` emits one `Opcode` enum per program and a trait the host
//! implements. [`crate::rt`] supplies the owned machine state: `Machine` with
//! its `Registers`. `push`/`pop` (and `peek`/`poke`) address memory at
//! `regs.sp` directly, just like `loadp`/`storep`, so the host must point
//! `sp` at a real stack buffer before running generated code.
//!
//! ```ignore
//! use offlineasm::rt::*;
//!
//! offlineasm! {
//! settings {
//! backend = rloop,
//! }
//!
//! global _answer
//! _answer:
//! move t0, 42
//! ret
//! }
//! ```
//!
//! The generated labels call each other with `extern "rust-preserve-none"`,
//! so a crate that expands the macro with `backend = rloop` needs nightly
//! Rust and `#![feature(rust_preserve_none_cc)]`. The rest of this crate stays
//! on stable Rust.
//!
//! ## Instruction reference
//!
//! See [mod@reference].
pub use ;
pub use offlineasm_inner as __offlineasm_inner;