gaia_assembler/instruction/
mod.rs1use crate::types::GaiaType;
2use gaia_types::neural::NeuralNode;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub enum GaiaInstruction {
8 Core(CoreInstruction),
10 Managed(ManagedInstruction),
12 Domain(DomainInstruction),
14}
15
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub enum CoreInstruction {
19 Alloca(GaiaType, usize),
22 Load(GaiaType),
24 Store(GaiaType),
26 Gep {
28 base_type: GaiaType,
29 indices: Vec<usize>,
30 },
31
32 Add(GaiaType),
34 Sub(GaiaType),
35 Mul(GaiaType),
36 Div(GaiaType),
37 Rem(GaiaType),
38 And(GaiaType),
39 Or(GaiaType),
40 Xor(GaiaType),
41 Shl(GaiaType),
42 Shr(GaiaType),
43 Neg(GaiaType),
44 Not(GaiaType),
45
46 Cmp(CmpCondition, GaiaType),
48
49 Cast {
51 from: GaiaType,
52 to: GaiaType,
53 kind: CastKind,
54 },
55
56 PushConstant(crate::program::GaiaConstant),
58 Pop,
59 Dup,
60
61 LoadLocal(u32, GaiaType),
64 StoreLocal(u32, GaiaType),
66 LoadArg(u32, GaiaType),
68 StoreArg(u32, GaiaType),
70
71 Ret,
74 Br(String),
76 BrTrue(String),
78 BrFalse(String),
80 Label(String),
82 Call(String, usize),
84
85 New(String),
88 NewArray(GaiaType, bool),
90 LoadField(String, String),
92 StoreField(String, String),
94 LoadElement(GaiaType),
96 StoreElement(GaiaType),
98 ArrayLength,
100
101 StructNew(String),
104 StructGet {
106 struct_name: String,
107 field_index: u32,
108 is_signed: bool,
109 },
110 StructSet {
112 struct_name: String,
113 field_index: u32,
114 },
115 ArrayNew(String),
117 ArrayGet {
119 array_name: String,
120 is_signed: bool,
121 },
122 ArraySet(String),
124}
125
126#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
128pub enum CmpCondition {
129 Eq,
130 Ne,
131 Lt,
132 Le,
133 Gt,
134 Ge,
135}
136
137#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
139pub enum CastKind {
140 Bitcast,
141 Trunc,
142 Zext,
143 Sext,
144 FpToUi,
145 FpToSi,
146 UiToFp,
147 SiToFp,
148}
149
150#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
152pub enum ManagedInstruction {
153 CallMethod { target: String, method: String, signature: crate::types::GaiaSignature, is_virtual: bool },
155 CallStatic { target: String, method: String, signature: crate::types::GaiaSignature },
157 Box(GaiaType),
159 Unbox(GaiaType),
161 InstanceOf(GaiaType),
163 CheckCast(GaiaType),
165 Initiate(usize),
167 Finalize,
169}
170
171#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
173pub enum DomainInstruction {
174 Neural(NeuralNode),
176
177 MatMul { a_shape: Vec<usize>, b_shape: Vec<usize>, transpose_a: bool, transpose_b: bool },
180 Conv2D { stride: [usize; 2], padding: [usize; 2], dilation: [usize; 2], groups: usize },
182 ElementWise(GaiaType, String),
184
185 GetThreadId(usize),
188 GetGroupSize(usize),
190 Barrier,
192}