mirror of
https://github.com/Noratrieb/crapderive.git
synced 2026-01-14 16:45:08 +01:00
ir
This commit is contained in:
parent
23c8e14984
commit
e01c429076
1 changed files with 33 additions and 0 deletions
33
src/ir.rs
Normal file
33
src/ir.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Register(u8);
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Place {
|
||||
Register(Register),
|
||||
/// `[r5]`
|
||||
AddrRegister(Register),
|
||||
/// `[353]`
|
||||
AddrLiteral(u64),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Value {
|
||||
Literal(u64),
|
||||
Place(Place),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Location {
|
||||
index: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Stmt {
|
||||
Mov { to: Place, from: Value },
|
||||
Add { to: Place, value: Value },
|
||||
Sub { to: Place, value: Value },
|
||||
Mul { to: Place, value: Value },
|
||||
Div { to: Place, value: Value },
|
||||
Jmp { to: Location },
|
||||
Cmp { lhs: Value, rhs: Value },
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue