vermilion_codegen/
instruction.rs

1//! A module for Vermilion IR instructions.
2
3use crate::entities::Value;
4
5/// An instruction opcode, used when emitting binary.
6#[derive(Clone)]
7pub enum Opcode {
8    Pop,
9    Clone,
10    Clear,
11    Trap,
12    BooleanAdd,
13    BooleanSubtract,
14    ByteAdd,
15    ByteSubtract,
16    ByteMultiply,
17    ByteDivide,
18    ByteRemainder,
19    IntegerAdd,
20    IntegerSubtract,
21    IntegerMultiply,
22    IntegerDivide,
23    IntegerRemainder,
24    FloatAdd,
25    FloatSubtract,
26    FloatMultiply,
27    FloatDivide,
28    FloatRemainder,
29    CastBoolean,
30    CastByte,
31    CastInteger,
32    CastFloat,
33    NegateBoolean,
34    NegateByte,
35    NegateInteger,
36    NegateFloat,
37    Load,
38    Store,
39    Realloc,
40    HeapSize,
41    Alloc,
42    ReallocSection,
43    SectionAddr,
44    SectionShiftLeft,
45    SectionShiftRight,
46    Free,
47    FreeAndShift,
48    Branch,
49    BranchIfZero,
50    BranchIfNotZero,
51    Equal,
52    GreaterThan,
53    LessThan,
54    GreaterThanOrEqual,
55    LessThanOrEqual,
56    Call,
57    Return,
58}
59
60/// A struct that stores information about an instruction.
61#[derive(Clone)]
62pub struct InstructionData {
63
64    /// The opcode of the instruction, which is translated
65    /// directly to bytecode.
66    pub opcode: Opcode,
67
68    /// A list of instruction arguments.
69    pub args: Vec<Value>,
70
71}