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 CallIndirect(usize),
86
87 New(String),
90 NewArray(GaiaType, bool),
92 LoadField(String, String),
94 StoreField(String, String),
96 LoadElement(GaiaType),
98 StoreElement(GaiaType),
100 ArrayLength,
102 ArrayPush,
104
105 StructNew(String),
108 StructGet {
110 struct_name: String,
111 field_index: u32,
112 is_signed: bool,
113 },
114 StructSet {
116 struct_name: String,
117 field_index: u32,
118 },
119 ArrayNew(String),
121 ArrayGet {
123 array_name: String,
124 is_signed: bool,
125 },
126 ArraySet(String),
128}
129
130#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
132pub enum CmpCondition {
133 Eq,
134 Ne,
135 Lt,
136 Le,
137 Gt,
138 Ge,
139}
140
141#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
143pub enum CastKind {
144 Bitcast,
145 Trunc,
146 Zext,
147 Sext,
148 FpToUi,
149 FpToSi,
150 UiToFp,
151 SiToFp,
152}
153
154#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
156pub enum ManagedInstruction {
157 CallMethod {
159 target: String,
160 method: String,
161 signature: crate::types::GaiaSignature,
162 is_virtual: bool,
163 call_site_id: Option<u32>,
164 },
165 CallStatic { target: String, method: String, signature: crate::types::GaiaSignature },
167 Box(GaiaType),
169 Unbox(GaiaType),
171 InstanceOf(GaiaType),
173 CheckCast(GaiaType),
175 Initiate(usize),
177 Finalize,
179}
180
181#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
183pub enum DomainInstruction {
184 Neural(NeuralNode),
186
187 MatMul { a_shape: Vec<usize>, b_shape: Vec<usize>, transpose_a: bool, transpose_b: bool },
190 Conv2D { stride: [usize; 2], padding: [usize; 2], dilation: [usize; 2], groups: usize },
192 ElementWise(GaiaType, String),
194
195 GetThreadId(usize),
198 GetGroupSize(usize),
200 Barrier,
202}