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