diff --git a/src/lib.rs b/src/lib.rs index f76f697..0985b9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,7 @@ pub mod errors; pub mod file_span; pub mod file_spanned; pub mod internal_iterator_mut; +pub mod mir; pub mod src_file; pub mod str_id; diff --git a/src/mir/mod.rs b/src/mir/mod.rs new file mode 100644 index 0000000..ea5aebb --- /dev/null +++ b/src/mir/mod.rs @@ -0,0 +1,90 @@ +use super::*; + +#[derive(Debug, Clone)] +pub enum Mir { + /// standard looping over a body of "inner" steps + Loop(MirLoop), + + /// both break and continue are just "jump" + /// + /// * if necessary, you can tell if it was break or continue by the tail of + /// the label it targets. + Jump(MirJump), + + /// call to another function + /// + /// * No actual abi system currently, so basically all calls are total + /// optimization black holes. + Call(MirCall), + + /// go back to the caller + Return(MirReturn), + + /// when a condition holds, do this + If(MirIf), + + /// `inc reg16` + /// + /// * **Flags:** none + Inc16(Reg16), + + /// `dec reg16` + /// + /// * **Flags:** none + Dec16(Reg16), + + /// `inc reg8` + /// + /// * **Flags:** `z` + Inc8(Reg8), + + /// `dec reg8` + /// + /// * **Flags:** `z` + Dec8(Reg8), + + /// `a = [reg16]` + AssignAReg16t(Reg16), + + /// `[reg16] = a` + AssignReg16tA(Reg16), +} + +#[derive(Debug, Clone)] +pub struct MirLoop { + pub steps: Vec, + pub canonical_name: StrID, + pub canonical_start: StrID, + pub canonical_end: StrID, +} + +#[derive(Debug, Clone)] +pub struct MirJump { + pub condition: Condition, + pub target: StrID, +} + +#[derive(Debug, Clone)] +pub struct MirCall { + pub condition: Condition, + pub target: StrID, + pub abi: Abi, +} + +#[derive(Debug, Clone)] +pub struct Abi { + // todo: an ABI system +} + +#[derive(Debug, Clone)] +pub struct MirReturn { + pub condition: Condition, +} + +#[derive(Debug, Clone)] +pub struct MirIf { + pub condition: Condition, + pub steps: Vec, + pub canonical_name: StrID, + pub canonical_end: StrID, +}