Branch data Line data Source code
1 : : /* vim: set filetype=cpp: */
2 : :
3 : : #ifndef M_OPCODE
4 : : #error "define M_OPCODE(Opcode, Delta, __VA_ARGS__) before including this file"
5 : : #endif
6 : :
7 : :
8 : : /*======================================================================================================================
9 : : * Control flow operations
10 : : *====================================================================================================================*/
11 : :
12 : : /** Stop the machine. */
13 : 10864 : M_OPCODE(Stop, 0)
14 : :
15 : : /* Stop on condition. */
16 : 2 : M_OPCODE(Stop_Z, 0)
17 : 2 : M_OPCODE(Stop_NZ, 0)
18 : 2 : M_OPCODE(Stop_False, 0)
19 : 2 : M_OPCODE(Stop_True, 0)
20 : :
21 : :
22 : : /*======================================================================================================================
23 : : * Stack manipulation operations
24 : : *====================================================================================================================*/
25 : :
26 : : /** Remove the top entry from the stack. */
27 : 12499 : M_OPCODE(Pop, -1)
28 : :
29 : : /** Push NULL to top of the stack. */
30 : 449 : M_OPCODE(Push_Null, +1)
31 : :
32 : : /** Duplicate the top entry of the stack. */
33 : 1760 : M_OPCODE(Dup, +1)
34 : :
35 : :
36 : : /*======================================================================================================================
37 : : * Context Access Operations
38 : : *====================================================================================================================*/
39 : :
40 : : /** Load a value from the context to the top of the stack. */
41 : 74162 : M_OPCODE(Ld_Ctx, +1, index)
42 : :
43 : : /** Update a value in the context with the value on top of the stack. */
44 : 19851 : M_OPCODE(Upd_Ctx, 0, index)
45 : :
46 : :
47 : : /*======================================================================================================================
48 : : * Tuple Access Operations
49 : : *====================================================================================================================*/
50 : :
51 : : /** Load a value from a tuple to the top of the stack. */
52 : 6690 : M_OPCODE(Ld_Tup, +1, tuple_id, index)
53 : :
54 : : /** Store NULL into a tuple. */
55 : 182 : M_OPCODE(St_Tup_Null, 0, tuple_id, index)
56 : : /** Store the current top-of-stack into a tuple. */
57 : 81 : M_OPCODE(St_Tup_i, 0, tuple_id, index)
58 : : /** Store the current top-of-stack into a tuple. */
59 : 13 : M_OPCODE(St_Tup_f, 0, tuple_id, index)
60 : : /** Store the current top-of-stack into a tuple. */
61 : 12 : M_OPCODE(St_Tup_d, 0, tuple_id, index)
62 : : /** Store the current top-of-stack into a tuple. */
63 : 97 : M_OPCODE(St_Tup_s, -1, tuple_id, index)
64 : : /** Store the current top-of-stack into a tuple. */
65 : 81 : M_OPCODE(St_Tup_b, 0, tuple_id, index)
66 : :
67 : :
68 : : /*======================================================================================================================
69 : : * I/O Operations
70 : : *====================================================================================================================*/
71 : :
72 : : /* Writes the character `chr` to the `std::ostream` instance referenced by the `index`-th slot in the context. */
73 : 2 : M_OPCODE(Putc, 0, index, chr)
74 : :
75 : : /* Print a value to the `std::ostream` instance referenced by the `index`-th slot in the context. */
76 : 3 : M_OPCODE(Print_i, 0, index)
77 : 2 : M_OPCODE(Print_f, 0, index)
78 : 1 : M_OPCODE(Print_d, 0, index)
79 : 10 : M_OPCODE(Print_s, 0, index)
80 : 3 : M_OPCODE(Print_b, 0, index)
81 : 3 : M_OPCODE(Print_date, 0, index)
82 : 3 : M_OPCODE(Print_datetime, 0, index)
83 : :
84 : :
85 : : /*======================================================================================================================
86 : : * Storage Access Operations
87 : : *====================================================================================================================*/
88 : :
89 : : /*----- Load from memory ---------------------------------------------------------------------------------------------*/
90 : :
91 : 6417 : M_OPCODE(Ld_i8, 0)
92 : 28 : M_OPCODE(Ld_i16, 0)
93 : 244 : M_OPCODE(Ld_i32, 0)
94 : 13 : M_OPCODE(Ld_i64, 0)
95 : 43 : M_OPCODE(Ld_f, 0)
96 : 23 : M_OPCODE(Ld_d, 0)
97 : 40 : M_OPCODE(Ld_s, -1)
98 : 151 : M_OPCODE(Ld_b, 0, mask)
99 : :
100 : : /*----- Store to memory ----------------------------------------------------------------------------------------------*/
101 : :
102 : 3045 : M_OPCODE(St_i8, -2)
103 : 24 : M_OPCODE(St_i16, -2)
104 : 2899 : M_OPCODE(St_i32, -2)
105 : 19 : M_OPCODE(St_i64, -2)
106 : 43 : M_OPCODE(St_f, -2)
107 : 23 : M_OPCODE(St_d, -2)
108 : 40 : M_OPCODE(St_s, -3)
109 : 156 : M_OPCODE(St_b, -2, bit_offset)
110 : :
111 : :
112 : : /*======================================================================================================================
113 : : * Arithmetical operations
114 : : *====================================================================================================================*/
115 : :
116 : : /* Integral increment. */
117 : 1724 : M_OPCODE(Inc, 0)
118 : : /* Integral decrement. */
119 : 2 : M_OPCODE(Dec, 0)
120 : :
121 : : /* Arithmetic negation */
122 : 26 : M_OPCODE(Minus_i, 0)
123 : 3 : M_OPCODE(Minus_f, 0)
124 : 31 : M_OPCODE(Minus_d, 0)
125 : :
126 : : /* Add two values. */
127 : 7427 : M_OPCODE(Add_i, -1)
128 : 1 : M_OPCODE(Add_f, -1)
129 : 1 : M_OPCODE(Add_d, -1)
130 : 11927 : M_OPCODE(Add_p, -1)
131 : :
132 : : /* Subtract two values. */
133 : 1 : M_OPCODE(Sub_i, -1)
134 : 1 : M_OPCODE(Sub_f, -1)
135 : 1 : M_OPCODE(Sub_d, -1)
136 : :
137 : : /* Multiply two values. */
138 : 7510 : M_OPCODE(Mul_i, -1)
139 : 10 : M_OPCODE(Mul_f, -1)
140 : 8 : M_OPCODE(Mul_d, -1)
141 : :
142 : : /* Divide two values. */
143 : 8 : M_OPCODE(Div_i, -1)
144 : 2 : M_OPCODE(Div_f, -1)
145 : 2 : M_OPCODE(Div_d, -1)
146 : :
147 : : /* Modulo divide two values. */
148 : 3 : M_OPCODE(Mod_i, -1)
149 : :
150 : :
151 : : /*======================================================================================================================
152 : : * Bitwise operations
153 : : *====================================================================================================================*/
154 : :
155 : : /* Bitwise negation */
156 : 3045 : M_OPCODE(Neg_i, 0)
157 : :
158 : : /* Bitwise And */
159 : 6669 : M_OPCODE(And_i, -1)
160 : :
161 : : /* Bitwise Or */
162 : 3046 : M_OPCODE(Or_i, -1)
163 : :
164 : : /* Bitwise Xor */
165 : 4 : M_OPCODE(Xor_i, -1)
166 : :
167 : : /* Shift left - with operand on stack. */
168 : 3294 : M_OPCODE(ShL_i, -1)
169 : :
170 : : /* Shift left immediate - with operand as argument. */
171 : 80 : M_OPCODE(ShLi_i, 0, count)
172 : :
173 : : /* Shift arithmetical right - with operand as argument. */
174 : 4135 : M_OPCODE(SARi_i, 0, count)
175 : :
176 : :
177 : : /*======================================================================================================================
178 : : * Logical operations
179 : : *====================================================================================================================*/
180 : :
181 : : /* Logical not */
182 : 843 : M_OPCODE(Not_b, 0)
183 : :
184 : : /* Logical and. */
185 : 4 : M_OPCODE(And_b, -1)
186 : :
187 : : /* Logical or. */
188 : 4 : M_OPCODE(Or_b, -1)
189 : :
190 : :
191 : : /*======================================================================================================================
192 : : * String manipulation operations
193 : : *====================================================================================================================*/
194 : :
195 : : /* Concatenate two strings. */
196 : 5 : M_OPCODE(Cat_s, -1)
197 : :
198 : :
199 : : /*======================================================================================================================
200 : : * Comparison operations
201 : : *====================================================================================================================*/
202 : :
203 : : /* Test for NULL. */
204 : 3123 : M_OPCODE(Is_Null, 0)
205 : : /* Test equal to zero. */
206 : 2 : M_OPCODE(EqZ_i, 0)
207 : : /* Test not equal to zero. */
208 : 332 : M_OPCODE(NEZ_i, 0)
209 : :
210 : 4238 : M_OPCODE(Eq_i, -1)
211 : 2 : M_OPCODE(Eq_f, -1)
212 : 2 : M_OPCODE(Eq_d, -1)
213 : 2 : M_OPCODE(Eq_b, -1)
214 : 2 : M_OPCODE(Eq_s, -1)
215 : :
216 : 1682 : M_OPCODE(NE_i, -1)
217 : 2 : M_OPCODE(NE_f, -1)
218 : 2 : M_OPCODE(NE_d, -1)
219 : 2 : M_OPCODE(NE_b, -1)
220 : 2 : M_OPCODE(NE_s, -1)
221 : :
222 : 2 : M_OPCODE(LT_i, -1)
223 : 2 : M_OPCODE(LT_f, -1)
224 : 2 : M_OPCODE(LT_d, -1)
225 : 2 : M_OPCODE(LT_s, -1)
226 : :
227 : 2 : M_OPCODE(GT_i, -1)
228 : 2 : M_OPCODE(GT_f, -1)
229 : 2 : M_OPCODE(GT_d, -1)
230 : 2 : M_OPCODE(GT_s, -1)
231 : :
232 : 2 : M_OPCODE(LE_i, -1)
233 : 2 : M_OPCODE(LE_f, -1)
234 : 2 : M_OPCODE(LE_d, -1)
235 : 2 : M_OPCODE(LE_s, -1)
236 : :
237 : 2 : M_OPCODE(GE_i, -1)
238 : 2 : M_OPCODE(GE_f, -1)
239 : 2 : M_OPCODE(GE_d, -1)
240 : 2 : M_OPCODE(GE_s, -1)
241 : :
242 : 2 : M_OPCODE(Cmp_i, -1)
243 : 2 : M_OPCODE(Cmp_f, -1)
244 : 2 : M_OPCODE(Cmp_d, -1)
245 : 2 : M_OPCODE(Cmp_b, -1)
246 : 3 : M_OPCODE(Cmp_s, -1)
247 : :
248 : : /* `LIKE` operator. */
249 : 3 : M_OPCODE(Like_const, -1)
250 : 6 : M_OPCODE(Like_expr, -1)
251 : :
252 : :
253 : : /*======================================================================================================================
254 : : * Selection operation
255 : : *====================================================================================================================*/
256 : :
257 : : /* Select one of two values based on a boolean. */
258 : 3580 : M_OPCODE(Sel, -2)
259 : :
260 : :
261 : : /*======================================================================================================================
262 : : * Type conversion
263 : : *====================================================================================================================*/
264 : :
265 : : /* Cast to int. */
266 : 3 : M_OPCODE(Cast_i_f, 0)
267 : 3 : M_OPCODE(Cast_i_d, 0)
268 : 7575 : M_OPCODE(Cast_i_b, 0)
269 : :
270 : : /* Cast to float. */
271 : 16 : M_OPCODE(Cast_f_i, 0)
272 : 34 : M_OPCODE(Cast_f_d, 0)
273 : :
274 : : /* Cast to double. */
275 : 6 : M_OPCODE(Cast_d_i, 0)
276 : 2 : M_OPCODE(Cast_d_f, 0)
|