You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.1 KiB
76 lines
2.1 KiB
use crate::asm::data::{Rd, RdObj, Wr};
|
|
use crate::asm::data::literal::{DebugMsg, Label, RoutineName};
|
|
use crate::asm::instr::Op;
|
|
use crate::asm::instr::op::OpKind;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Barrier {
|
|
/// Barrier that logically opens a section that cannot be jumped into, typically a routine
|
|
Open(Label),
|
|
/// Closing counterpart to the Open barrier
|
|
Close(Label),
|
|
/// Stand-alone barrier
|
|
Standalone,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum BuiltinOp {
|
|
/// Do nothing (costs one cycle)
|
|
Nop,
|
|
/// Stop execution
|
|
Halt,
|
|
/// Sleep
|
|
Sleep {
|
|
micros: Rd,
|
|
},
|
|
/// Mark a jump target.
|
|
Label(Label),
|
|
/// Jump to a label
|
|
Jump(Label),
|
|
/// Mark a far jump target (can be jumped to from another routine).
|
|
/// This label is preserved in optimized code.
|
|
FarLabel(Label),
|
|
/// Jump to a label that can be in another function
|
|
FarJump(Label),
|
|
/// Call a routine with arguments.
|
|
/// The arguments are passed as argX. Return values are stored in resX registers.
|
|
Call(RoutineName, Vec<Rd>),
|
|
/// Exit the current routine with return values
|
|
Ret(Vec<Rd>),
|
|
/// Mark a routine entry point (call target).
|
|
/// The RoutineName struct includes its arity
|
|
Routine(RoutineName),
|
|
/// Skip backward or forward. The skip count can be defined by an argument.
|
|
Skip(Rd),
|
|
/// Deny jumps, skips and run across this address, producing a run-time fault.
|
|
Barrier {
|
|
kind: Barrier,
|
|
msg: Option<DebugMsg>,
|
|
},
|
|
/// Generate a run-time fault with a debugger message
|
|
Fault(Option<DebugMsg>),
|
|
/// Deallocate an extension object.
|
|
/// The object is released and the handle becomes invalid.
|
|
Drop(RdObj),
|
|
/// Copy value
|
|
Move { dst: Wr, src: Rd },
|
|
/// Store runtime status to a register
|
|
StoreStatus { dst: Wr },
|
|
/// Load runtime status from a register
|
|
LoadStatus { src: Rd },
|
|
}
|
|
|
|
impl From<BuiltinOp> for Op {
|
|
fn from(bo: BuiltinOp) -> Self {
|
|
Op {
|
|
kind: bo.into(),
|
|
cond: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<BuiltinOp> for OpKind {
|
|
fn from(bo: BuiltinOp) -> Self {
|
|
OpKind::BuiltIn(bo)
|
|
}
|
|
}
|
|
|