Reduct  v4.1.3-1-gd06c383
A functional and immutable language.
Loading...
Searching...
No Matches
opcode.h
Go to the documentation of this file.
1#ifndef REDUCT_OPCODE_H
2#define REDUCT_OPCODE_H 1
3
4#include <reduct/defs.h>
5#include <stdint.h>
6
7/**
8 * @file opcode.h
9 * @brief Bytecode opcodes and properties.
10 * @defgroup opcode Opcodes
11 * @{
12 */
13
14/**
15 * @brief Opcode mode enumeration.
16 * @enum reduct_opcode_mode_t
17 */
18typedef enum
19{
20 REDUCT_OPCODE_MODE_REG = 0, ///< Register operand mode.
21 REDUCT_OPCODE_MODE_CONST = 1 << 7, ///< Constant operand mode.
23
24/**
25 * @brief Opcode operand layouts.
26 * @enum reduct_opcode_layout_t
27 */
28typedef enum
29{
30 REDUCT_OPCODE_LAYOUT_ABC, ///< R(A) R(B) R/K(C)
31 REDUCT_OPCODE_LAYOUT_AC, ///< R(A) R/K(C)
35 REDUCT_OPCODE_LAYOUT_SAX, ///< sAx, no operands
37 REDUCT_OPCODE_LAYOUT_NONE ///< No operands
39
40/**
41 * @brief Opcode enumeration.
42 * @enum reduct_opcode_t
43 *
44 * @warning Instructins that start a new frame such as `REDUCT_OPCODE_CALL` or `REDUCT_OPCODE_RECUR` will utilize the
45 * target register (R(A)) as the base of the new frame. As such, this register must be greater than any live register to
46 * avoid clobbering.
47 */
48typedef enum
49{
50 REDUCT_OPCODE_NOP = 0x10, ///< No operation.
51 REDUCT_OPCODE_MOV, ///< (A, C) Move value in R/K(C) to R(A).
52 REDUCT_OPCODE_LIST, ///< (A, B) R(A) = (R(A) R(A + 1) ... R(A + B - 1))
53 REDUCT_OPCODE_CLOSURE, ///< (A, C) Wrap the function prototype in K(C) in a closure and store in R(A).
54 REDUCT_OPCODE_CAPTURE, ///< (A, B, C) Capture R/K(C) into constant slot B in closure R(A).
55 REDUCT_OPCODE_JMP, ///< (sAx) Unconditional jump by relative offset sAx.
56 REDUCT_OPCODE_JMPF, ///< (sAx, C) Jump by sAx if R(C) is falsy.
57 REDUCT_OPCODE_JMPT, ///< (sAx, C) Jump by sAx if R(C) is truthy.
58 REDUCT_OPCODE_CALL, ///< (A, B, C) Call callable in R/K(C) with B args starting from R(A). Result in R(A).
59 REDUCT_OPCODE_RET, ///< (C) Return value in R/K(C).
60 REDUCT_OPCODE_TAILCALL, ///< (A, B, C) Tail call callable in R/K(C) with B args starting from R(A).
61 REDUCT_OPCODE_RECUR, ///< (A, B) Recursively call the current function with B args starting from R(A).
62 REDUCT_OPCODE_TAILRECUR, ///< (A, B) Recursively tail call the current function with B args starting from R(A).
63 REDUCT_OPCODE_EQ, ///< (A, B, C) If R(B) == R/K(C) store true in R(A), else false.
64 REDUCT_OPCODE_NEQ, ///< (A, B, C) If R(B) != R/K(C) store true in R(A), else false.
65 REDUCT_OPCODE_LT, ///< (A, B, C) If R(B) < R/K(C) store true in R(A), else false.
66 REDUCT_OPCODE_LE, ///< (A, B, C) If R(B) <= R/K(C) store true in R(A), else false.
67 REDUCT_OPCODE_GT, ///< (A, B, C) If R(B) > R/K(C) store true in R(A), else false.
68 REDUCT_OPCODE_GE, ///< (A, B, C) If R(B) >= R/K(C) store true in R(A), else false.
69 REDUCT_OPCODE_ADD, ///< (A, B, C) R(A) = R(B) + R/K(C)
70 REDUCT_OPCODE_SUB, ///< (A, B, C) R(A) = R(B) - R/K(C)
71 REDUCT_OPCODE_MUL, ///< (A, B, C) R(A) = R(B) * R/K(C)
72 REDUCT_OPCODE_DIV, ///< (A, B, C) R(A) = R(B) / R/K(C)
73 REDUCT_OPCODE_MOD, ///< (A, B, C) R(A) = R(B) % R/K(C)
74 REDUCT_OPCODE_BAND, ///< (A, B, C) R(A) = R(B) & R/K(C)
75 REDUCT_OPCODE_BOR, ///< (A, B, C) R(A) = R(B) | R/K(C)
76 REDUCT_OPCODE_BXOR, ///< (A, B, C) R(A) = R(B) ^ R/K(C)
77 REDUCT_OPCODE_BNOT, ///< (A, C) R(A) = ~R/K(C)
78 REDUCT_OPCODE_SHL, ///< (A, B, C) R(A) = R(B) << R/K(C)
79 REDUCT_OPCODE_SHR, ///< (A, B, C) R(A) = R(B) >> R/K(C)
80 REDUCT_OPCODE_JEQ, ///< (B, C) Skip the next instruction if R(B) == R/K(C), else continue.
81 REDUCT_OPCODE_JNEQ, ///< (B, C) Skip the next instruction if R(B) != R/K(C), else continue.
82 REDUCT_OPCODE_JLT, ///< (B, C) Skip the next instruction if R(B) < R/K(C), else continue.
83 REDUCT_OPCODE_JLE, ///< (B, C) Skip the next instruction if R(B) <= R/K(C), else continue.
84 REDUCT_OPCODE_JGT, ///< (B, C) Skip the next instruction if R(B) > R/K(C), else continue.
85 REDUCT_OPCODE_JGE, ///< (B, C) Skip the next instruction if R(B) >= R/K(C), else continue.
86 REDUCT_OPCODE_FORK, ///< (A, B, C) Spawn a thread for R/K(C) with B args starting at R(A). Task handle stored in
87 ///< R(A).
88 REDUCT_OPCODE_JOIN, ///< (A, C) Wait for task handle in R(C) to complete, result stored in R(A).
121
122/**
123 * @brief Opcode flags.
124 * @enum reduct_opcode_flags_t
125 */
126typedef enum
127{
128 REDUCT_OPCODE_FLAG_HAS_TARGET = (1 << 0), ///< Opcode modifies target register A.
129 REDUCT_OPCODE_FLAG_IS_JUMP = (1 << 1), ///< Opcode is a jump.
130 REDUCT_OPCODE_FLAG_HAS_CONST = (1 << 2), ///< Opcode uses C operand and has a const version.
131 REDUCT_OPCODE_FLAG_READ_A = (1 << 3), ///< Opcode reads from register A (or range starting at A).
132 REDUCT_OPCODE_FLAG_READ_B = (1 << 4), ///< Opcode reads from register B.
133 REDUCT_OPCODE_FLAG_READ_C = (1 << 5), ///< Opcode reads from register/constant C.
134 REDUCT_OPCODE_FLAG_READ_RANGE = (1 << 6), ///< Opcode reads a range of registers starting at A.
135 REDUCT_OPCODE_FLAG_IS_COMMUTATIVE = (1 << 7), ///< Opcode is commutative.
136 REDUCT_OPCODE_FLAG_IS_SKIP = (1 << 8), ///< Opcode is a skip instruction.
137 REDUCT_OPCODE_FLAG_IS_CALL = (1 << 9), ///< Opcode is a function call.
138 REDUCT_OPCODE_FLAG_IS_TERMINATOR = (1 << 10), ///< Opcode ends basic block reachability.
139 REDUCT_OPCODE_FLAG_IS_RECUR = (1 << 11), ///< Opcode is a recursive call.
140 REDUCT_OPCODE_FLAG_IS_FORK = (1 << 12), ///< Opcode returns a task handle.
142
143/**
144 * @brief Opcode information structure.
145 */
146typedef struct reduct_opcode_info
147{
148 const char* name;
152
153/**
154 * @brief Opcode information and flags table.
155 */
157
158/**
159 * @brief Get the base form of the opcode without the constant bit set.
160 *
161 * @param _op The opcode.
162 */
163#define REDUCT_OPCODE_BASE(_op) ((_op) & ~REDUCT_OPCODE_MODE_CONST)
164
165/**
166 * @brief Get the name of an opcode.
167 *
168 * @param _op The opcode.
169 */
170#define REDUCT_OPCODE_GET_NAME(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].name)
171
172/**
173 * @brief Get the layout of an opcode.
174 *
175 * @param _op The opcode.
176 */
177#define REDUCT_OPCODE_GET_LAYOUT(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].layout)
178
179/**
180 * @brief Check if an opcode is a comparison instruction.
181 *
182 * @param _op The opcode.
183 */
184#define REDUCT_OPCODE_IS_COMPARE(_op) \
185 (REDUCT_OPCODE_BASE(_op) >= REDUCT_OPCODE_EQ && REDUCT_OPCODE_BASE(_op) <= REDUCT_OPCODE_GE)
186
187/**
188 * @brief Get the skip version of a comparison opcode.
189 *
190 * @param _op The comparison opcode.
191 */
192#define REDUCT_OPCODE_TO_SKIP(_op) \
193 (REDUCT_OPCODE_IS_COMPARE(_op) ? (reduct_opcode_t)((_op) + (REDUCT_OPCODE_JEQ - REDUCT_OPCODE_EQ)) \
194 : REDUCT_OPCODE_NOP)
195
196/**
197 * @brief Invert a skip comparison opcode (e.g. JEQ <-> JNEQ).
198 *
199 * @param _op The skip opcode.
200 */
201#define REDUCT_OPCODE_INVERT_SKIP(_op) \
202 ((reduct_opcode_t)((REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JEQ ? REDUCT_OPCODE_JNEQ \
203 : REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JNEQ ? REDUCT_OPCODE_JEQ \
204 : REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JLT ? REDUCT_OPCODE_JGE \
205 : REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JGE ? REDUCT_OPCODE_JLT \
206 : REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JLE ? REDUCT_OPCODE_JGT \
207 : REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_JGT ? REDUCT_OPCODE_JLE \
208 : (_op)) | \
209 ((_op) & REDUCT_OPCODE_MODE_CONST)))
210
211/**
212 * @brief Get the recursive version of a call opcode.
213 *
214 * @param _op The call opcode.
215 */
216#define REDUCT_OPCODE_TO_RECUR(_op) \
217 (REDUCT_OPCODE_IS_CALL(_op) \
218 ? (reduct_opcode_t)((REDUCT_OPCODE_BASE(_op) == REDUCT_OPCODE_TAILCALL) ? REDUCT_OPCODE_TAILRECUR \
219 : REDUCT_OPCODE_RECUR) \
220 : REDUCT_OPCODE_NOP)
221
222/**
223 * @brief Get the tail version of a call or return opcode.
224 *
225 * @param _op The opcode.
226 */
227#define REDUCT_OPCODE_TO_TAIL(_op) \
228 ((_op) == REDUCT_OPCODE_CALL ? REDUCT_OPCODE_TAILCALL \
229 : (_op) == REDUCT_OPCODE_CALL_CONST ? REDUCT_OPCODE_TAILCALL_CONST \
230 : (_op) == REDUCT_OPCODE_RECUR ? REDUCT_OPCODE_TAILRECUR \
231 : (_op))
232
233/**
234 * @brief Check if an opcode modifies its target register (A).
235 *
236 * @param _op The opcode.
237 */
238#define REDUCT_OPCODE_HAS_TARGET(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_HAS_TARGET)
239
240/**
241 * @brief Check if an opcode is a recursive call.
242 *
243 * @param _op The opcode.
244 */
245#define REDUCT_OPCODE_IS_RECUR(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_RECUR)
246
247/**
248 * @brief Check if an opcode is a jump instruction.
249 *
250 * @param _op The opcode.
251 */
252#define REDUCT_OPCODE_IS_JUMP(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_JUMP)
253
254/**
255 * @brief Check if an opcode uses the C operand and has both a constant and register version.
256 *
257 * @param _op The opcode.
258 */
259#define REDUCT_OPCODE_HAS_CONST(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_HAS_CONST)
260
261/**
262 * @brief Check if an opcode reads from register A.
263 *
264 * @param _op The opcode.
265 */
266#define REDUCT_OPCODE_READS_A(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_READ_A)
267
268/**
269 * @brief Check if an opcode reads from register B.
270 *
271 * @param _op The opcode.
272 */
273#define REDUCT_OPCODE_READS_B(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_READ_B)
274
275/**
276 * @brief Check if an opcode reads from register/constant C.
277 *
278 * @param _op The opcode.
279 */
280#define REDUCT_OPCODE_READS_C(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_READ_C)
281
282/**
283 * @brief Check if an opcode reads a range of registers starting at A.
284 *
285 * @param _op The opcode.
286 */
287#define REDUCT_OPCODE_READS_RANGE(_op) \
288 (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_READ_RANGE)
289
290/**
291 * @brief Check if an opcode is commutative.
292 *
293 * @param _op The opcode.
294 */
295#define REDUCT_OPCODE_IS_COMMUTATIVE(_op) \
296 (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_COMMUTATIVE)
297
298/**
299 * @brief Check if an opcode is a skip instruction.
300 *
301 * @param _op The opcode.
302 */
303#define REDUCT_OPCODE_IS_SKIP(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_SKIP)
304
305/**
306 * @brief Check if an opcode is a skip or jump instruction.
307 *
308 * @param _op The opcode.
309 */
310#define REDUCT_OPCODE_IS_BRANCH(_op) \
311 (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & (REDUCT_OPCODE_FLAG_IS_SKIP | REDUCT_OPCODE_FLAG_IS_JUMP))
312
313/**
314 * @brief Check if an opcode is a function call.
315 *
316 * @param _op The opcode.
317 */
318#define REDUCT_OPCODE_IS_CALL(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_CALL)
319
320/**
321 * @brief Check if an opcode is a terminator.
322 *
323 * @param _op The opcode.
324 */
325#define REDUCT_OPCODE_IS_TERMINATOR(_op) \
326 (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_TERMINATOR)
327
328/**
329 * @brief Check if an opcode is a binary operation (reads B and C).
330 *
331 * @param _op The opcode.
332 */
333#define REDUCT_OPCODE_IS_BINARY(_op) \
334 ((reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & (REDUCT_OPCODE_FLAG_READ_B | REDUCT_OPCODE_FLAG_READ_C)) == \
335 (REDUCT_OPCODE_FLAG_READ_B | REDUCT_OPCODE_FLAG_READ_C))
336
337/**
338 * @brief Check if an opcode is a ternary operation (reads A, B and C).
339 *
340 * @param _op The opcode.
341 */
342#define REDUCT_OPCODE_IS_TERNARY(_op) \
343 ((reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & \
344 (REDUCT_OPCODE_FLAG_READ_A | REDUCT_OPCODE_FLAG_READ_B | REDUCT_OPCODE_FLAG_READ_C)) == \
345 (REDUCT_OPCODE_FLAG_READ_A | REDUCT_OPCODE_FLAG_READ_B | REDUCT_OPCODE_FLAG_READ_C))
346
347/**
348 * @brief Check if an opcode is a unary operation (reads C only).
349 *
350 * @param _op The opcode.
351 */
352#define REDUCT_OPCODE_IS_UNARY(_op) \
353 ((reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & \
354 (REDUCT_OPCODE_FLAG_READ_A | REDUCT_OPCODE_FLAG_READ_B | REDUCT_OPCODE_FLAG_READ_C)) == \
355 REDUCT_OPCODE_FLAG_READ_C)
356
357/**
358 * @brief Check if an opcode is a fork instruction.
359 *
360 * @param _op The opcode.
361 */
362#define REDUCT_OPCODE_IS_FORK(_op) (reductOpcodeTable[REDUCT_OPCODE_BASE(_op)].flags & REDUCT_OPCODE_FLAG_IS_FORK)
363
364/** @} */
365
366#endif
#define REDUCT_API
Definition defs.h:24
reduct_opcode_layout_t
Opcode operand layouts.
Definition opcode.h:29
reduct_opcode_flags_t
Opcode flags.
Definition opcode.h:127
reduct_opcode_t
Opcode enumeration.
Definition opcode.h:49
REDUCT_API const reduct_opcode_info_t reductOpcodeTable[128]
Opcode information and flags table.
reduct_opcode_mode_t
Opcode mode enumeration.
Definition opcode.h:19
@ REDUCT_OPCODE_LAYOUT_AB_RANGE
R(A) B.
Definition opcode.h:33
@ REDUCT_OPCODE_LAYOUT_C
R/K(C)
Definition opcode.h:34
@ REDUCT_OPCODE_LAYOUT_AC
R(A) R/K(C)
Definition opcode.h:31
@ REDUCT_OPCODE_LAYOUT_NONE
No operands.
Definition opcode.h:37
@ REDUCT_OPCODE_LAYOUT_SAX
sAx, no operands
Definition opcode.h:35
@ REDUCT_OPCODE_LAYOUT_ABC_RANGE
R(A) B R/K(C)
Definition opcode.h:32
@ REDUCT_OPCODE_LAYOUT_SAXC
sAx R/K(C)
Definition opcode.h:36
@ REDUCT_OPCODE_LAYOUT_ABC
R(A) R(B) R/K(C)
Definition opcode.h:30
@ REDUCT_OPCODE_FLAG_IS_SKIP
Opcode is a skip instruction.
Definition opcode.h:136
@ REDUCT_OPCODE_FLAG_IS_COMMUTATIVE
Opcode is commutative.
Definition opcode.h:135
@ REDUCT_OPCODE_FLAG_READ_RANGE
Opcode reads a range of registers starting at A.
Definition opcode.h:134
@ REDUCT_OPCODE_FLAG_HAS_TARGET
Opcode modifies target register A.
Definition opcode.h:128
@ REDUCT_OPCODE_FLAG_IS_FORK
Opcode returns a task handle.
Definition opcode.h:140
@ REDUCT_OPCODE_FLAG_READ_C
Opcode reads from register/constant C.
Definition opcode.h:133
@ REDUCT_OPCODE_FLAG_IS_CALL
Opcode is a function call.
Definition opcode.h:137
@ REDUCT_OPCODE_FLAG_IS_JUMP
Opcode is a jump.
Definition opcode.h:129
@ REDUCT_OPCODE_FLAG_IS_TERMINATOR
Opcode ends basic block reachability.
Definition opcode.h:138
@ REDUCT_OPCODE_FLAG_HAS_CONST
Opcode uses C operand and has a const version.
Definition opcode.h:130
@ REDUCT_OPCODE_FLAG_READ_B
Opcode reads from register B.
Definition opcode.h:132
@ REDUCT_OPCODE_FLAG_IS_RECUR
Opcode is a recursive call.
Definition opcode.h:139
@ REDUCT_OPCODE_FLAG_READ_A
Opcode reads from register A (or range starting at A).
Definition opcode.h:131
@ REDUCT_OPCODE_JGE_CONST
Definition opcode.h:117
@ REDUCT_OPCODE_SUB_CONST
Definition opcode.h:102
@ REDUCT_OPCODE_DIV
(A, B, C) R(A) = R(B) / R/K(C)
Definition opcode.h:72
@ REDUCT_OPCODE_JLT_CONST
Definition opcode.h:114
@ REDUCT_OPCODE_JMPF
(sAx, C) Jump by sAx if R(C) is falsy.
Definition opcode.h:56
@ REDUCT_OPCODE_JMPT
(sAx, C) Jump by sAx if R(C) is truthy.
Definition opcode.h:57
@ REDUCT_OPCODE_RECUR
(A, B) Recursively call the current function with B args starting from R(A).
Definition opcode.h:61
@ REDUCT_OPCODE_DIV_CONST
Definition opcode.h:104
@ REDUCT_OPCODE_MOD_CONST
Definition opcode.h:105
@ REDUCT_OPCODE_CLOSURE_CONST
Definition opcode.h:92
@ REDUCT_OPCODE_SHR
(A, B, C) R(A) = R(B) >> R/K(C)
Definition opcode.h:79
@ REDUCT_OPCODE_BXOR_CONST
Definition opcode.h:108
@ REDUCT_OPCODE_BNOT_CONST
Definition opcode.h:109
@ REDUCT_OPCODE_JEQ_CONST
Definition opcode.h:112
@ REDUCT_OPCODE_SHL_CONST
Definition opcode.h:110
@ REDUCT_OPCODE_SHL
(A, B, C) R(A) = R(B) << R/K(C)
Definition opcode.h:78
@ REDUCT_OPCODE_SUB
(A, B, C) R(A) = R(B) - R/K(C)
Definition opcode.h:70
@ REDUCT_OPCODE_NEQ
(A, B, C) If R(B) != R/K(C) store true in R(A), else false.
Definition opcode.h:64
@ REDUCT_OPCODE_JNEQ_CONST
Definition opcode.h:113
@ REDUCT_OPCODE_BOR_CONST
Definition opcode.h:107
@ REDUCT_OPCODE_MOV
(A, C) Move value in R/K(C) to R(A).
Definition opcode.h:51
@ REDUCT_OPCODE_GT_CONST
Definition opcode.h:99
@ REDUCT_OPCODE_JLE_CONST
Definition opcode.h:115
@ REDUCT_OPCODE_JGT
(B, C) Skip the next instruction if R(B) > R/K(C), else continue.
Definition opcode.h:84
@ REDUCT_OPCODE_MUL
(A, B, C) R(A) = R(B) * R/K(C)
Definition opcode.h:71
@ REDUCT_OPCODE_JNEQ
(B, C) Skip the next instruction if R(B) != R/K(C), else continue.
Definition opcode.h:81
@ REDUCT_OPCODE_ADD
(A, B, C) R(A) = R(B) + R/K(C)
Definition opcode.h:69
@ REDUCT_OPCODE_JLE
(B, C) Skip the next instruction if R(B) <= R/K(C), else continue.
Definition opcode.h:83
@ REDUCT_OPCODE_BAND
(A, B, C) R(A) = R(B) & R/K(C)
Definition opcode.h:74
@ REDUCT_OPCODE_ADD_CONST
Definition opcode.h:101
@ REDUCT_OPCODE_RET
(C) Return value in R/K(C).
Definition opcode.h:59
@ REDUCT_OPCODE_CAPTURE_CONST
Definition opcode.h:93
@ REDUCT_OPCODE_BNOT
(A, C) R(A) = ~R/K(C)
Definition opcode.h:77
@ REDUCT_OPCODE_BAND_CONST
Definition opcode.h:106
@ REDUCT_OPCODE_EQ
(A, B, C) If R(B) == R/K(C) store true in R(A), else false.
Definition opcode.h:63
@ REDUCT_OPCODE_SHR_CONST
Definition opcode.h:111
@ REDUCT_OPCODE_JOIN
(A, C) Wait for task handle in R(C) to complete, result stored in R(A).
Definition opcode.h:88
@ REDUCT_OPCODE_CALL
(A, B, C) Call callable in R/K(C) with B args starting from R(A). Result in R(A).
Definition opcode.h:58
@ REDUCT_OPCODE_GT
(A, B, C) If R(B) > R/K(C) store true in R(A), else false.
Definition opcode.h:67
@ REDUCT_OPCODE_JMP
(sAx) Unconditional jump by relative offset sAx.
Definition opcode.h:55
@ REDUCT_OPCODE_FORK_CONST
Definition opcode.h:118
@ REDUCT_OPCODE_NOP
No operation.
Definition opcode.h:50
@ REDUCT_OPCODE_MOV_CONST
Definition opcode.h:89
@ REDUCT_OPCODE_GE
(A, B, C) If R(B) >= R/K(C) store true in R(A), else false.
Definition opcode.h:68
@ REDUCT_OPCODE_JGE
(B, C) Skip the next instruction if R(B) >= R/K(C), else continue.
Definition opcode.h:85
@ REDUCT_OPCODE_BOR
(A, B, C) R(A) = R(B) | R/K(C)
Definition opcode.h:75
@ REDUCT_OPCODE_CLOSURE
(A, C) Wrap the function prototype in K(C) in a closure and store in R(A).
Definition opcode.h:53
@ REDUCT_OPCODE_JEQ
(B, C) Skip the next instruction if R(B) == R/K(C), else continue.
Definition opcode.h:80
@ REDUCT_OPCODE_CALL_CONST
Definition opcode.h:90
@ REDUCT_OPCODE_LT_CONST
Definition opcode.h:97
@ REDUCT_OPCODE_LE
(A, B, C) If R(B) <= R/K(C) store true in R(A), else false.
Definition opcode.h:66
@ REDUCT_OPCODE_TAILCALL_CONST
Definition opcode.h:94
@ REDUCT_OPCODE_LIST
(A, B) R(A) = (R(A) R(A + 1) ... R(A + B - 1))
Definition opcode.h:52
@ REDUCT_OPCODE_EQ_CONST
Definition opcode.h:95
@ REDUCT_OPCODE_GE_CONST
Definition opcode.h:100
@ REDUCT_OPCODE_LE_CONST
Definition opcode.h:98
@ REDUCT_OPCODE_JOIN_CONST
Definition opcode.h:119
@ REDUCT_OPCODE_TAILCALL
(A, B, C) Tail call callable in R/K(C) with B args starting from R(A).
Definition opcode.h:60
@ REDUCT_OPCODE_TAILRECUR
(A, B) Recursively tail call the current function with B args starting from R(A).
Definition opcode.h:62
@ REDUCT_OPCODE_BXOR
(A, B, C) R(A) = R(B) ^ R/K(C)
Definition opcode.h:76
@ REDUCT_OPCODE_CAPTURE
(A, B, C) Capture R/K(C) into constant slot B in closure R(A).
Definition opcode.h:54
@ REDUCT_OPCODE_JLT
(B, C) Skip the next instruction if R(B) < R/K(C), else continue.
Definition opcode.h:82
@ REDUCT_OPCODE_MOD
(A, B, C) R(A) = R(B) % R/K(C)
Definition opcode.h:73
@ REDUCT_OPCODE_JGT_CONST
Definition opcode.h:116
@ REDUCT_OPCODE_LT
(A, B, C) If R(B) < R/K(C) store true in R(A), else false.
Definition opcode.h:65
@ REDUCT_OPCODE_FORK
Definition opcode.h:86
@ REDUCT_OPCODE_MUL_CONST
Definition opcode.h:103
@ REDUCT_OPCODE_RET_CONST
Definition opcode.h:91
@ REDUCT_OPCODE_NEQ_CONST
Definition opcode.h:96
@ REDUCT_OPCODE_MODE_REG
Register operand mode.
Definition opcode.h:20
@ REDUCT_OPCODE_MODE_CONST
Constant operand mode.
Definition opcode.h:21
Opcode information structure.
Definition opcode.h:147
reduct_opcode_flags_t flags
Definition opcode.h:150
reduct_opcode_layout_t layout
Definition opcode.h:149
const char * name
Definition opcode.h:148