|
|
|
use crate::asm::data::{Rd, Wr, RdObj};
|
|
|
|
use crate::asm::data::literal::{DebugMsg, Label, RoutineName};
|
|
|
|
use crate::asm::instr::{Cond, Op};
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum BuiltinOp {
|
|
|
|
/// Do nothing
|
|
|
|
Nop,
|
|
|
|
/// Stop execution
|
|
|
|
Halt,
|
|
|
|
/// Mark a jump target.
|
|
|
|
Label(Label),
|
|
|
|
/// Jump to a label
|
|
|
|
Jump(Label),
|
|
|
|
/// Jump to a label if a flag is set
|
|
|
|
JumpIf(Cond, Label),
|
|
|
|
/// Far jump to a label if a flag is set
|
|
|
|
FarJumpIf(Cond, 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).
|
|
|
|
/// Kept in the low level instruction file for position-independent code
|
|
|
|
Routine(RoutineName),
|
|
|
|
/// Skip backward or forward
|
|
|
|
Skip(Rd),
|
|
|
|
/// Skip if a flag is set
|
|
|
|
SkipIf(Cond, Rd),
|
|
|
|
/// Deny jumps, skips and run across this address, producing a run-time fault with a message.
|
|
|
|
Barrier(Option<DebugMsg>),
|
|
|
|
/// Generate a run-time fault with a debugger message
|
|
|
|
Fault(Option<DebugMsg>),
|
|
|
|
/// Deallocate an 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::BuiltIn(bo)
|
|
|
|
}
|
|
|
|
}
|