cardinal_backend/opcode.rs
1//! Exposes an enum of instruction Opcodes.
2//!
3//! Used for generating Function instructions.
4
5use crate::Value;
6
7/// An enumeration of instruction Opcodes
8/// for Cardinal's IR.
9///
10/// Hex names are provided in documentation.
11pub enum Opcode {
12 /// Adds two numbers together, overwriting the
13 /// provided output variable reference.
14 ///
15 /// - `x`: Output variable reference
16 /// - `y`: Integer value
17 /// - `z`: Integer value
18 ///
19 /// ```
20 /// x = y + z
21 /// ```
22 IntegerAdd(Value, Value, Value),
23
24 /// Negates a number, overwriting the provided
25 /// output variable reference with the result.
26 ///
27 /// - `x`: Output variable reference.
28 /// - `y`: Signed integer value.
29 ///
30 /// ```
31 /// x = -y
32 /// ```
33 IntegerNegate(Value, Value),
34}