1 /* This code is machine-generated.  See its source for license
2    information. This software is derived from software
3    distributed under the GNU GPL version 3 or later. */
4 
5 /* User-specified code, initial header part: beginning. */
6 #line 118 "../../libpoke/pvm.jitter"
7 #line 118 "../../libpoke/pvm.jitter"
8 
9 #   include <config.h>
10 
11 /* User-specified code, initial header part: end */
12 
13 /* VM library: main header file.
14 
15    Copyright (C) 2016, 2017, 2018, 2019, 2020 Luca Saiu
16    Written by Luca Saiu
17 
18    This file is part of Jitter.
19 
20    Jitter is free software: you can redistribute it and/or modify
21    it under the terms of the GNU General Public License as published by
22    the Free Software Foundation, either version 3 of the License, or
23    (at your option) any later version.
24 
25    Jitter is distributed in the hope that it will be useful,
26    but WITHOUT ANY WARRANTY; without even the implied warranty of
27    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28    GNU General Public License for more details.
29 
30    You should have received a copy of the GNU General Public License
31    along with Jitter.  If not, see <http://www.gnu.org/licenses/>. */
32 
33 
34 /* Generated file warning.
35  * ************************************************************************** */
36 
37 /* Unless this file is named exactly "vm.h" , without any prefix, you are
38    looking at a machine-generated derived file.  The original source is the vm.h
39    template from Jitter, with added code implementing the pvm VM. */
40 
41 
42 
43 
44 /* This multiple-inclusion guard is opened here in the template, and will be
45    closed at the end of the generated code.  It is normal to find no matching
46    #endif in the template file.  */
47 #ifndef PVM_VM_H_
48 #define PVM_VM_H_
49 
50 
51 /* This is the main VM header to use from hand-written code.
52  * ************************************************************************** */
53 
54 #include <stdio.h>
55 #include <stdbool.h>
56 
57 #include <jitter/jitter.h>
58 #include <jitter/jitter-hash.h>
59 #include <jitter/jitter-stack.h>
60 #include <jitter/jitter-instruction.h>
61 #include <jitter/jitter-mutable-routine.h>
62 #include <jitter/jitter-print.h>
63 #include <jitter/jitter-routine.h>
64 //#include <jitter/jitter-specialize.h> // FIXME: what about only declaring jitter_specialize in another header, and not including this?
65 #include <jitter/jitter-disassemble.h>
66 #include <jitter/jitter-vm.h>
67 #include <jitter/jitter-profile.h>
68 #include <jitter/jitter-data-locations.h>
69 #include <jitter/jitter-arithmetic.h>
70 #include <jitter/jitter-bitwise.h>
71 #include <jitter/jitter-signals.h>
72 #include <jitter/jitter-list.h>
73 
74 
75 
76 
77 /* Initialization and finalization.
78  * ************************************************************************** */
79 
80 /* Initialize the runtime state for the pvm VM.  This needs to be called
81    before using VM routines or VM states in any way. */
82 void
83 pvm_initialize (void);
84 
85 /* Finalize the runtime state, freeing some resources.  After calling this no
86    use of VM routines or states is allowed.  It is possible to re-initialize
87    after finalizing; these later re-initializations might be more efficient than
88    the first initialization. */
89 void
90 pvm_finalize (void);
91 
92 
93 
94 
95 /* State data structure initialization and finalization.
96  * ************************************************************************** */
97 
98 /* The machine state is separated into the backing and the more compact runtime
99    data structures, to be allocated in registers as far as possible.  These are
100    just a forward-declarations: the actual definitions are machine-generated. */
101 struct pvm_state_backing;
102 struct pvm_state_runtime;
103 
104 /* A data structure containing both the backing and the runtime state.  This is
105    a forward-declaration: the actual definition will come after both are
106    defined. */
107 struct pvm_state;
108 
109 /* Initialize the pointed VM state data structure, or fail fatally.  The
110    function definition is machine-generated, even if it may include user code.
111    The state backing and runtime are initialized at the same time, and in fact
112    the distinction between them is invisible to the VM user. */
113 void
114 pvm_state_initialize (struct pvm_state *state)
115   __attribute__ ((nonnull (1)));
116 
117 /* Finalize the pointed VM state data structure, or fail fatally.  The function
118    definition is machine-generated, even if it may include user code.  The state
119    backing and runtime are finalized at the same time. */
120 void
121 pvm_state_finalize (struct pvm_state *state)
122   __attribute__ ((nonnull (1)));
123 
124 
125 
126 
127 /* State data structure: iteration.
128  * ************************************************************************** */
129 
130 /* The header of a doubly-linked list linking every state for the pvm VM
131    together.  This global is automatically wrapped, and therefore also
132    accessible from VM instruction code. */
133 extern struct jitter_list_header * const
134 pvm_states;
135 
136 /* A pointer to the current state, only accessible from VM code.  This is usable
137    for pointer comparison when iterating over states. */
138 #define PVM_OWN_STATE                           \
139   ((struct pvm_state *) jitter_original_state)
140 
141 /* Given an l-value of type struct pvm_state * (usually a variable name)
142    expand to a for loop statement iterating over every existing pvm state
143    using the l-value as iteration variable.  The expansion will execute the
144    statement immediately following the macro call with the l-value in scope;
145    in order words the loop body is not a macro argument, but follows the macro
146    use.
147    The l-value may be evaluated an unspecified number of times.
148    This macro is safe to use within VM instruction code.
149    For example:
150      struct pvm_state *s;
151      PVM_FOR_EACH_STATE (s)
152        printf ("This is a state: %p\n", s); // (but printf unsafe in VM code) */
153 #define PVM_FOR_EACH_STATE(jitter_state_iteration_lvalue)     \
154   for ((jitter_state_iteration_lvalue)                             \
155           = pvm_states->first;                                \
156        (jitter_state_iteration_lvalue)                             \
157           != NULL;                                                 \
158        (jitter_state_iteration_lvalue)                             \
159          = (jitter_state_iteration_lvalue)->links.next)            \
160     /* Here comes the body supplied by the user: no semicolon. */
161 
162 
163 
164 
165 /* Mutable routine initialization.
166  * ************************************************************************** */
167 
168 /* Return a freshly-allocated empty mutable routine for the pvm VM. */
169 struct jitter_mutable_routine*
170 pvm_make_mutable_routine (void)
171   __attribute__ ((returns_nonnull));
172 
173 /* Mutable routine finalization is actually VM-independent, but a definition of
174    pvm_destroy_mutable_routine is provided below as a macro, for cosmetic
175    reasons. */
176 
177 
178 /* Mutable routines: code generation C API.
179  * ************************************************************************** */
180 
181 /* This is the preferred way of adding a new VM instruction to a pointed
182    routine, more efficient than pvm_mutable_routine_append_instruction_name
183    even if only usable when the VM instruction opcode is known at compile time.
184    The unspecialized instruction name must be explicitly mangled by the user as
185    per the rules in jitterc_mangle.c .  For example an instruction named foo_bar
186    can be added to the routine pointed by p with any one of
187      pvm_mutable_routine_append_instruction_name (p, "foo_bar");
188    ,
189      PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION (p, foo_ubar);
190    , and
191      PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION_ID
192         (p, pvm_meta_instruction_id_foo_ubar);
193    .
194    The string "foo_bar" is not mangled, but the token foo_ubar is. */
195 #define PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION(                 \
196           routine_p, instruction_mangled_name_root)                  \
197   do                                                                 \
198     {                                                                \
199       jitter_mutable_routine_append_meta_instruction                 \
200          ((routine_p),                                               \
201           pvm_meta_instructions                                 \
202           + JITTER_CONCATENATE_TWO(pvm_meta_instruction_id_,    \
203                                    instruction_mangled_name_root));  \
204     }                                                                \
205   while (false)
206 
207 /* Append the unspecialized instruction whose id is given to the pointed routine.
208    The id must be a case of enum pvm_meta_instruction_id ; such cases have
209    a name starting with pvm_meta_instruction_id_ .
210    This is slightly less convenient to use than PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION
211    but more general, as the instruction id is allowed to be a non-constant C
212    expression. */
213 #define PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION_ID(_jitter_routine_p,       \
214                                                        _jitter_instruction_id)  \
215   do                                                                            \
216     {                                                                           \
217       jitter_mutable_routine_append_instruction_id                              \
218          ((_jitter_routine_p),                                                  \
219           pvm_meta_instructions,                                           \
220           PVM_META_INSTRUCTION_NO,                                         \
221           (_jitter_instruction_id));                                            \
222     }                                                                           \
223   while (false)
224 
225 /* This is the preferred way of appending a register argument to the instruction
226    being added to the pointed routine, more convenient than directly using
227    pvm_mutable_routine_append_register_id_parameter , even if only usable
228    when the register class is known at compile time.  Here the register class is
229    only provided as a letter, but both the routine pointer and the register
230    index are arbitrary C expressions.
231    For example, in
232      PVM_MUTABLE_ROUTINE_APPEND_REGISTER_PARAMETER (p, r,
233                                                          variable_to_index (x));
234    the second macro argument "r" represents the register class named "r", and
235    not the value of a variable named r. */
236 #define PVM_MUTABLE_ROUTINE_APPEND_REGISTER_PARAMETER(routine_p,     \
237                                                            class_letter,  \
238                                                            index)         \
239   do                                                                      \
240     {                                                                     \
241       pvm_mutable_routine_append_register_parameter                  \
242          ((routine_p),                                                    \
243           & JITTER_CONCATENATE_TWO(pvm_register_class_,              \
244                                    class_letter),                         \
245           (index));                                                       \
246     }                                                                     \
247   while (false)
248 
249 
250 
251 
252 /* Routine unified API: initialization.
253  * ************************************************************************** */
254 
255 /* See the comments above in "Mutable routines: initialization", and the
256    implementation of the unified routine API in <jitter/jitter-routine.h> . */
257 
258 #define pvm_make_routine pvm_make_mutable_routine
259 
260 
261 
262 
263 /* Routine unified API: code generation C API.
264  * ************************************************************************** */
265 
266 /* See the comments above in "Mutable routines: code generation C API". */
267 
268 #define PVM_ROUTINE_APPEND_INSTRUCTION  \
269   PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION
270 #define PVM_ROUTINE_APPEND_INSTRUCTION_ID  \
271   PVM_MUTABLE_ROUTINE_APPEND_INSTRUCTION_ID
272 #define PVM_ROUTINE_APPEND_REGISTER_PARAMETER  \
273   PVM_MUTABLE_ROUTINE_APPEND_REGISTER_PARAMETER
274 
275 
276 
277 
278 /* Array: special-purpose data.
279  * ************************************************************************** */
280 
281 /* The Array is a convenient place to store special-purpose data, accessible in
282    an efficient way from a VM routine.
283    Every item in special-purpose data is thread-local. */
284 
285 /* The special-purpose data struct.  Every Array contains one of these at unbiased
286    offset PVM_SPECIAL_PURPOSE_STATE_DATA_UNBIASED_OFFSET from the unbiased
287    beginning of the array.
288    This entire struct is aligned to at least sizeof (jitter_int) bytes.  The
289    entire struct is meant to be always accessed through a pointer-to-volatile,
290    as its content may be altered from signal handlers and from different
291    threads.  In particualar the user should use the macro
292      PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA
293    defined below and the macros defined from it as accessors.
294    VM code accessing special-purpose data for its own state should use
295      PVM_SPECIAL_PURPOSE_STATE_DATA
296    and the macros defined from it. */
297 struct jitter_special_purpose_state_data
298 {
299   /* Notification fields.
300    * ***************************************************************** */
301 
302   /* This is a Boolean flag, held as a word-sized datum so as to ensure
303      atomicity in access.  It is also aligned to at least sizeof (jitter_int)
304      bytes.
305      Non-zero means that there is at least one notification pending, zero means
306      that there are no notifications.  The flag specifies no other details: it
307      is meant to be fast to check, with detailed information about each pending
308      notification available elsewhere.
309      It is the receiver's responsibility to periodically poll for notifications
310      in application-specific "safe-points":
311      A check can be inserted, for example, in all of these program points:
312      a) at every backward branch;
313      b) at every procedure entry;
314      c) right after a call to each blocking primitive (as long as primitives
315        can be interrupted).
316      Safe-point checks are designed to be short and fast in the common case.  In
317      the common case no action is required, and the VM routine should simply
318      fall through.  If an action is required then control should branch off to a
319      handler, where the user may implement the required behavior.
320      It is mandatory that, as long as notifications can arrive, this field
321      is reset to zero (when handling pending notifications) only by a thread
322      running VM code in the state containing this struct.
323      Other threads are allowed to set this to non-zero, in order to send a
324      notification.  */
325   jitter_int pending_notifications;
326 
327   /* Information about pending signal notifications.  If any signal is pending
328      then pending_notifications must also be set, so that a notification check
329      can always just quickly check pending_notifications, and then look at more
330      details (including in pending_signal_notifications) only in the rare case
331      of pending_notifications being true. */
332   struct jitter_signal_notification *pending_signal_notifications;
333 
334 
335   /* Profiling instrumentation fields.
336    * ***************************************************************** */
337   struct jitter_profile_runtime profile_runtime;
338 };
339 
340 
341 
342 
343 /* The Array and volatility.
344  * ************************************************************************** */
345 
346 /* Some fields of The Array, seen from VM code, are meant to be volatile, since
347    they can be set by signal handlers or by other threads.  However it is
348    acceptable to not see such changes immediately after they occur (notifications
349    will get delayed, but not lost) and always accessing such data through a
350    volatile struct is suboptimal.
351 
352    Non-VM code does need a volatile qualifier.
353 
354    Advanced dispatches already need a trick using inline assembly to make the
355    base pointer (a biased pointer to The Array beginning) appear to
356    spontaneously change beween instruction.  That is sufficient to express the
357    degree of volatility required for this purpose.
358    Simple dispatches, on targets where inline assembly may not be available at
359    all, will use an actual volatile qualifier. */
360 #if defined (JITTER_DISPATCH_SWITCH)               \
361     || defined (JITTER_DISPATCH_DIRECT_THREADING)
362 # define PVM_ARRAY_VOLATILE_QUALIFIER volatile
363 #elif defined (JITTER_DISPATCH_MINIMAL_THREADING)  \
364       || defined (JITTER_DISPATCH_NO_THREADING)
365 # define PVM_ARRAY_VOLATILE_QUALIFIER /* nothing */
366 #else
367 # error "unknown dispatch: this should not happen"
368 #endif /* dispatch conditional */
369 
370 
371 
372 
373 /* Array element access: residuals, transfers, slow registers, and more.
374  * ************************************************************************** */
375 
376 /* In order to cover a wider range of addresses with simple base + register
377    addressing the base does not necessarily point to the beginning of the Array;
378    instead the base points to the beginning of the Array plus JITTER_ARRAY_BIAS
379    bytes.
380    FIXME: define the bias as a value appropriate to each architecture.  I think
381    I should just move the definition to jitter-machine.h and provide a default
382    here, in case the definition is missing on some architecture. */
383 
384 /* FIXME: Horrible, horrible, horrible temporary workaround!
385 
386    This is a temporary workaround, very ugly and fragile, to compensate
387    a limitation in jitter-specialize.c , which I will need to rewrite anyway.
388    The problem is that jitter-specialize.c patches snippets to load non-label
389    residuals in a VM-independent way based only on slow-register/memory residual
390    indices, which is incorrect.  By using this particular bias I am cancelling
391    that error.
392    Test case, on a machine having only one register residual and a VM having just
393      one fast register:
394      [luca@moore ~/repos/jitter/_build/native-gcc-9]$ Q=bin/uninspired--no-threading; make $Q && echo 'mov 2, %r1' | libtool --mode=execute valgrind $Q --disassemble - --print-locations
395    If this bias is wrong the slow-register accesses in mov/nR/%rR will use two
396    different offsets, one for reading and another for writing.  With this
397    workaround they will be the same.
398    Good, with workadound (biased offset 0x0 from the base in %rbx):
399     # 0x4a43d38: mov/nR/%rR 0x2, 0x20 (21 bytes):
400         0x0000000004effb30 41 bc 02 00 00 00    	movl   $0x2,%r12d
401         0x0000000004effb36 48 c7 43 00 20 00 00 00 	movq   $0x20,0x0(%rbx)
402         0x0000000004effb3e 48 8b 13             	movq   (%rbx),%rdx
403         0x0000000004effb41 4c 89 24 13          	movq   %r12,(%rbx,%rdx,1)
404    Bad, with JITTER_ARRAY_BIAS defined as zero: first write at 0x0(%rbx)
405                                                 then read at 0x10(%rbx):
406     # 0x4a43d38: mov/nR/%rR 0x2, 0x30 (22 bytes):
407         0x0000000004effb30 41 bc 02 00 00 00    	movl   $0x2,%r12d
408         0x0000000004effb36 48 c7 43 00 30 00 00 00 	movq   $0x30,0x0(%rbx)
409         0x0000000004effb3e 48 8b 53 10          	movq   0x10(%rbx),%rdx
410         0x0000000004effb42 4c 89 24 13          	movq   %r12,(%rbx,%rdx,1) */
411 #define JITTER_ARRAY_BIAS \
412   (sizeof (struct jitter_special_purpose_state_data))
413 //#define JITTER_ARRAY_BIAS //0//(((jitter_int) 1 << 15))//(((jitter_int) 1 << 31))//0//0//16//0
414 
415 /* Array-based globals are not implemented yet.  For the purpose of computing
416    Array offsets I will say they are zero. */
417 #define PVM_GLOBAL_NO 0
418 
419 /* Transfer registers are not implemented yet.  For the purpose of computing
420    Array offsets I will say they are zero. */
421 #define PVM_TRANSFER_REGISTER_NO 0
422 
423 /* Define macros holding offsets in bytes for the first global, memory residual
424    and transfer register, from an initial Array pointer.
425    In general we have to keep into account:
426    - globals (word-sized);
427    - special-purpose state data;
428    - memory residuals (word-sized);
429    - transfer registers (word-sized);
430    - slow registers (pvm_any_register-sized and aligned).
431    Notice that memory
432    residuals (meaning residuals stored in The Array) are zero on dispatching
433    modes different from no-threading.  This relies on
434    PVM_MAX_MEMORY_RESIDUAL_ARITY , defined below, which in its turn depends
435    on PVM_MAX_RESIDUAL_ARITY, which is machine-generated. */
436 #define PVM_FIRST_GLOBAL_UNBIASED_OFFSET  \
437   0
438 #define PVM_SPECIAL_PURPOSE_STATE_DATA_UNBIASED_OFFSET  \
439   (PVM_FIRST_GLOBAL_UNBIASED_OFFSET                     \
440    + sizeof (jitter_int) * PVM_GLOBAL_NO)
441 #define PVM_FIRST_MEMORY_RESIDUAL_UNBIASED_OFFSET   \
442   (PVM_SPECIAL_PURPOSE_STATE_DATA_UNBIASED_OFFSET   \
443    + sizeof (struct jitter_special_purpose_state_data))
444 #define PVM_FIRST_TRANSFER_REGISTER_UNBIASED_OFFSET        \
445   (PVM_FIRST_MEMORY_RESIDUAL_UNBIASED_OFFSET               \
446    + sizeof (jitter_int) * PVM_MAX_MEMORY_RESIDUAL_ARITY)
447 #define PVM_FIRST_SLOW_REGISTER_UNBIASED_OFFSET          \
448   JITTER_NEXT_MULTIPLE_OF_POSITIVE                            \
449      (PVM_FIRST_TRANSFER_REGISTER_UNBIASED_OFFSET        \
450       + sizeof (jitter_int) * PVM_TRANSFER_REGISTER_NO,  \
451       sizeof (union pvm_any_register))
452 
453 /* Expand to the offset of the special-purpose data struct from the Array
454    biased beginning. */
455 #define PVM_SPECIAL_PURPOSE_STATE_DATA_OFFSET       \
456   (PVM_SPECIAL_PURPOSE_STATE_DATA_UNBIASED_OFFSET   \
457    - JITTER_ARRAY_BIAS)
458 
459 /* Given an expression evaluating to the Array unbiased beginning, expand to
460    an expression evaluating to a pointer to its special-purpose data.
461    This is convenient for accessing special-purpose data from outside the
462    state -- for example, to set the pending notification flag for another
463    thread.
464    There are two versions of this feature:
465      PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA
466    is meant to be used to access state data for some other thread, or in
467    general out of VM code.
468      PVM_OWN_SPECIAL_PURPOSE_STATE_DATA
469    is for VM code accessing its own special-purpose data. */
470 #define PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA_PRIVATE(qualifier,      \
471                                                              array_address)  \
472   ((qualifier struct jitter_special_purpose_state_data *)                    \
473    (((char *) (array_address))                                               \
474     + PVM_SPECIAL_PURPOSE_STATE_DATA_UNBIASED_OFFSET))
475 #define PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA(array_address)       \
476   PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA_PRIVATE (volatile,         \
477                                                         (array_address))
478 #define PVM_OWN_SPECIAL_PURPOSE_STATE_DATA          \
479   PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA_PRIVATE   \
480      (PVM_ARRAY_VOLATILE_QUALIFIER,                 \
481       ((char *) jitter_array_base) - JITTER_ARRAY_BIAS)
482 
483 /* Given a state pointer, expand to an expression evaluating to a pointer to
484    the state's special-purpose data.  This is meant for threads accessing
485    other threads' special-purpose data, typically to set notifications. */
486 #define PVM_STATE_TO_SPECIAL_PURPOSE_STATE_DATA(state_p)  \
487   (PVM_ARRAY_TO_SPECIAL_PURPOSE_STATE_DATA                \
488      ((state_p)->pvm_state_backing.jitter_array))
489 
490 /* Given a state pointer, expand to an expression evaluating to the
491    pending_notification field for the state as an l-value.  This is meant for
492    threads sending notifications to other threads. */
493 #define PVM_STATE_TO_PENDING_NOTIFICATIONS(state_p)   \
494   (PVM_STATE_TO_SPECIAL_PURPOSE_STATE_DATA (state_p)  \
495      ->pending_notifications)
496 
497 /* Given a state pointer and a signal, expand to an l-value evaluating to a the
498    pending field of the struct jitter_signal_notification element for the given
499    signal in the pointed state.  This is meant for threads sending signal
500    notifications to other threads and for C handler function. */
501 #define PVM_STATE_AND_SIGNAL_TO_PENDING_SIGNAL_NOTIFICATION(state_p,    \
502                                                                  signal_id)  \
503   (((PVM_STATE_TO_SPECIAL_PURPOSE_STATE_DATA (state_p)                   \
504        ->pending_signal_notifications)                                        \
505     + (signal_id))->pending)
506 
507 
508 /* Expand to the offset of the i-th register of class c in bytes from the Array
509    beginning.
510    The c argument must be a literal C (one-character) identifier.
511    The i argument should always be a compile-time constant for performance, and
512    it is in generated code.
513    The i-th c-class register must be slow, otherwise the offset will be
514    incorrect -- in fact fast registers are, hopefully, not in memory at all.
515 
516    Slow registers come in the Array ordered first by index, then by class.  For
517    example if there are three classes "r" with 4 fast registers, "f" with 7 fast
518    registers and "q" with 2 fast registers, slow registers can be accessed in
519    this order:
520      r4, f7, q2, r5, r8, q3, r6, r9, q4, and so on.
521    Each contiguous group of slow registers spanning every class and starting
522    from the first class (here for example <r5, r6, q3>) is called a "rank".
523    This organization is convenient since changing the number of slow registers
524    doesn't invalidate any offset computed in the past: the Array can simply be
525    resized and its base pointer updated, without changing the code accessing it.
526 
527    This relies on macro such as PVM_REGISTER_CLASS_NO and
528    PVM_REGISTER_?_FAST_REGISTER_NO and , defined below in machine-generated
529    code. */
530 #define PVM_SLOW_REGISTER_UNBIASED_OFFSET(c, i)                     \
531   (PVM_FIRST_SLOW_REGISTER_UNBIASED_OFFSET                          \
532    + (sizeof (union pvm_any_register)                               \
533       * (PVM_REGISTER_CLASS_NO                                      \
534          * ((i) - JITTER_CONCATENATE_THREE(PVM_REGISTER_, c,        \
535                                            _FAST_REGISTER_NO))           \
536          + JITTER_CONCATENATE_THREE(PVM_REGISTER_, c, _CLASS_ID))))
537 
538 /* Expand to the offset of the i-th register of class c in bytes from the base,
539    keeping the bias into account. */
540 #define PVM_SLOW_REGISTER_OFFSET(c, i)                              \
541   (PVM_SLOW_REGISTER_UNBIASED_OFFSET(c, i) - JITTER_ARRAY_BIAS)
542 
543 /* Expand to the Array size in bytes, assuming the given number of slow
544    registers per class.  This is an allocation size, ignoring the bias. */
545 #define PVM_ARRAY_SIZE(slow_register_per_class_no)                  \
546   (PVM_FIRST_SLOW_REGISTER_UNBIASED_OFFSET                          \
547    + (sizeof (union pvm_any_register)                               \
548       * PVM_REGISTER_CLASS_NO                                       \
549       * (slow_register_per_class_no)))
550 
551 
552 
553 
554 /* Residual access.
555  * ************************************************************************** */
556 
557 /* How many residuals we can have at most in memory, which is to say,
558    without counting residuals kept in reserved registers.
559 
560    Implementation note: it would be wrong here to use a CPP conditional based on
561    the value of PVM_MAX_RESIDUAL_ARITY , as I was doing in a preliminary
562    version.  That lead to a tricky bug, since PVM_MAX_RESIDUAL_ARITY ,
563    which is defined below but is not yet available here, simply counted as 0
564    for the purposes of evaluating the CPP condititional. */
565 #ifdef JITTER_DISPATCH_NO_THREADING
566   /* We are using no-threading dispatch.  If there are no more residuals
567      than reserved residual registers then we never need to keep any in
568      memory.  Otherwise we need to keep as many residuals in memory as the
569      total number of residuals minus how many registers are reserved for
570      them. */
571 # define PVM_MAX_MEMORY_RESIDUAL_ARITY                          \
572     ((PVM_MAX_RESIDUAL_ARITY <= JITTER_RESIDUAL_REGISTER_NO)    \
573      ? 0                                                             \
574      : (PVM_MAX_RESIDUAL_ARITY - JITTER_RESIDUAL_REGISTER_NO))
575 #else // Not no-threading.
576   /* No registers are reserved for residuals in this dispatching mode; even if
577      in fact all residuals are memory residuals they don't count here, since
578      residuals are not held in The Array in this dispatching mode. */
579 # define PVM_MAX_MEMORY_RESIDUAL_ARITY  \
580   0
581 #endif // #ifdef JITTER_DISPATCH_NO_THREADING
582 
583 #ifdef JITTER_DISPATCH_NO_THREADING
584 /* Expand to the offset from the base, in bytes, of the i-th residual.  The
585    given index must be greater than or equal to JITTER_RESIDUAL_REGISTER_NO;
586    residuals with indices lower than that number are not stored in The Array
587    at all.
588    This is not useful with any of the other dispatching modes, where residuals
589    directly follow each VM instruction opcode or thread.  For good performance i
590    should always be a compile-time constant, as it is in machine-generated
591    code.
592    Residuals always have the size of a jitter word, even if some register class
593    may be wider. */
594 /* FIXME: if later I use a different policy than simply checking
595    JITTER_RESIDUAL_REGISTER_NO to decide how many residuals to keep in
596    registers, then I have to change this or meet very nasty bugs. */
597 # define PVM_RESIDUAL_UNBIASED_OFFSET(i)                      \
598     (PVM_FIRST_MEMORY_RESIDUAL_UNBIASED_OFFSET                \
599      + (sizeof (jitter_int) * (i - JITTER_RESIDUAL_REGISTER_NO)))
600 # define PVM_RESIDUAL_OFFSET(i)  \
601     (PVM_RESIDUAL_UNBIASED_OFFSET(i) - JITTER_ARRAY_BIAS)
602 #endif // #ifdef JITTER_DISPATCH_NO_THREADING
603 
604 
605 
606 /* Mutable routine text frontend.
607  * ************************************************************************** */
608 
609 /* Parse VM code from the given file or string into the pointed VM routine,
610    which is allowed but not required to be empty.
611    These are simple wrappers around functions implemented in the Bison file. */
612 void
613 pvm_parse_mutable_routine_from_file_star (FILE *input_file,
614                                                struct jitter_mutable_routine *p)
615   __attribute__ ((nonnull (1, 2)));
616 void
617 pvm_parse_mutable_routine_from_file (const char *input_file_name,
618                                           struct jitter_mutable_routine *p)
619   __attribute__ ((nonnull (1, 2)));
620 void
621 pvm_parse_mutable_routine_from_string (const char *string,
622                                             struct jitter_mutable_routine *p)
623   __attribute__ ((nonnull (1, 2)));
624 
625 
626 
627 
628 /* Unified routine text frontend.
629  * ************************************************************************** */
630 
631 /* The C wrappers for the ordinary API can be reused for the unified API, since
632    it internally works with mutable routines. */
633 #define pvm_parse_routine_from_file_star  \
634   pvm_parse_mutable_routine_from_file_star
635 #define pvm_parse_routine_from_file  \
636   pvm_parse_mutable_routine_from_file
637 #define pvm_parse_routine_from_string  \
638   pvm_parse_mutable_routine_from_string
639 
640 
641 
642 
643 /* Machine-generated data structures.
644  * ************************************************************************** */
645 
646 /* Declare a few machine-generated data structures, which together define a VM. */
647 
648 /* Threads or pointers to native code blocks of course don't exist with
649    switch-dispatching. */
650 #ifndef JITTER_DISPATCH_SWITCH
651 /* Every possible thread, indexed by enum jitter_specialized_instruction_opcode .
652    This is used at specialization time, and the user shouldn't need to touch
653    it. */
654 extern const jitter_thread *
655 pvm_threads;
656 
657 /* VM instruction end label.  These are not all reachable at run time, but
658    having them in a global array might prevent older GCCs from being too clever
659    in reordering blocks. */
660 extern const jitter_thread *
661 pvm_thread_ends;
662 
663 /* The size, in chars, of each thread's native code.  The elements are in the
664    same order of pvm_threads.  Sizes could conceptually be of type size_t ,
665    but in order to be defensive I'm storing pointer differences as signed
666    values, so that we may catch compilation problems: if any VM instruction end
667    *precedes* its VM instruction beginning, then the compiler has reordered
668    labels, which would have disastrous effects with replicated code. */
669 extern const long *
670 pvm_thread_sizes;
671 #endif // #ifndef JITTER_DISPATCH_SWITCH
672 
673 /* This is defined in the machine-generated vm/meta-instructions.c . */
674 extern struct jitter_hash_table
675 pvm_meta_instruction_hash;
676 
677 /* An array specifying every existing meta-instruction, defined in the order of
678    enum pvm_meta_instruction_id .  This is defined in vm/meta-instructions.c ,
679    which is machine-generated. */
680 extern const struct jitter_meta_instruction
681 pvm_meta_instructions [];
682 
683 /* An array whose indices are specialised instruction opcodes, and
684    whose elements are the corresponding unspecialised instructions
685    opcodes -- or -1 when there is no mapping mapping having */
686 extern const int
687 pvm_specialized_instruction_to_unspecialized_instruction [];
688 
689 /* How many residual parameters each specialized instruction has.  The
690    actual array definition is machine-generated. */
691 extern const size_t
692 pvm_specialized_instruction_residual_arities [];
693 
694 /* An array of bitmasks, one per specialized instruction.  Each bitmask holds
695    one bit per residual argument, counting from the least significant (the first
696    residual arg maps to element & (1 << 0), the second to element & (1 << 1),
697    and so on).
698    Each bit is 1 if and only if the corresponding residual argument is a label
699    or a fast label.
700    Only residual arguments are counted: for example a specialized instruction
701    foo_n1_lR_r2 would have a mask with the *first* bit set. */
702 extern const unsigned long // FIXME: possibly use a shorter type when possible
703 pvm_specialized_instruction_label_bitmasks [];
704 
705 /* Like pvm_specialized_instruction_label_bitmasks , but for fast labels
706    only.
707    The actual definition is conditionalized so as to appear only when
708    needed according to the dispatching model. */
709 extern const unsigned long // FIXME: possibly use a shorter type when possible
710 pvm_specialized_instruction_fast_label_bitmasks [];
711 
712 /* An array of booleans in which each element is true iff the specialized
713    instruction whose opcode is the index is relocatable. */
714 extern const bool
715 pvm_specialized_instruction_relocatables [];
716 
717 /* An array of booleans in which each element is true iff the specialized
718    instruction whose opcode is the index is a caller. */
719 extern const bool
720 pvm_specialized_instruction_callers [];
721 
722 /* An array of booleans in which each element is true iff the specialized
723    instruction whose opcode is the index is a callee. */
724 extern const bool
725 pvm_specialized_instruction_callees [];
726 
727 /* This big array of strings contains the name of each specialized instruction,
728    in the order of enum pvm_specialized_instruction_opcode . */
729 extern const char* const
730 pvm_specialized_instruction_names [];
731 
732 
733 /* A pointer to a struct containing const pointers to the structures above, plus
734    sizes; there will be only one instance of this per VM, machine-generated.
735    Each program data structure contains a pointer to that instance, so that
736    VM-independent functions, given a program, will have everything needed to
737    work.  The one instance of struct jitter_vm for the pvm VM. */
738 extern struct jitter_vm * const
739 pvm_vm;
740 
741 /* A pointer to a struct containing VM-specific parameters set in part when
742    calling jitterc and in part when compiling the generated C code, such as the
743    dispatching model and the number of fast registers.  The data is fully
744    initialized only after a call to pvm_initialize . */
745 extern const
746 struct jitter_vm_configuration * const
747 pvm_vm_configuration;
748 
749 
750 
751 
752 /* Compatibility macros.
753  * ************************************************************************** */
754 
755 /* It is convenient, for future extensibility, to expose an interface in which
756    some VM-independent functions and data structures actually look as if they
757    were specific to the user VM. */
758 
759 /* What the user refers to as struct pvm_mutable_routine is actually a
760    struct jitter_mutable_routine , whose definition is VM-independent. */
761 #define pvm_mutable_routine jitter_mutable_routine
762 
763 /* Same for executable routines. */
764 #define pvm_executable_routine jitter_executable_routine
765 
766 /* Same for unified routines. */
767 #define pvm_routine jitter_routine
768 
769 /* Destroy a non-executable routine (routine initialization is actually
770    VM-specific). */
771 #define pvm_destroy_mutable_routine jitter_destroy_mutable_routine
772 
773 /* Destroy a unified routine. */
774 #define pvm_destroy_routine jitter_destroy_routine
775 
776 /* Pin a unified routine. */
777 #define pvm_pin_routine jitter_pin_routine
778 
779 /* Unpin a unified routine. */
780 #define pvm_unpin_routine jitter_unpin_routine
781 
782 /* Print VM configuration. */
783 #define pvm_print_vm_configuration jitter_print_vm_configuration
784 
785 /* Generic routine construction API. */
786 #define pvm_label \
787   jitter_label
788 #define pvm_fresh_label \
789   jitter_fresh_label
790 
791 /* Mutable routine option API. */
792 #define pvm_set_mutable_routine_option_slow_literals_only \
793   jitter_set_mutable_routine_option_slow_literals_only
794 #define pvm_set_mutable_routine_option_slow_registers_only \
795   jitter_set_mutable_routine_option_slow_registers_only
796 #define pvm_set_mutable_routine_option_slow_literals_and_registers_only \
797   jitter_set_mutable_routine_option_slow_literals_and_registers_only
798 #define pvm_set_mutable_routine_option_add_final_exitvm \
799   jitter_set_mutable_routine_option_add_final_exitvm
800 #define pvm_set_mutable_routine_option_optimization_rewriting \
801   jitter_set_mutable_routine_option_optimization_rewriting
802 
803 /* Printing and disassembling: ordinary API. */
804 #define pvm_mutable_routine_print \
805   jitter_mutable_routine_print
806 #define pvm_executable_routine_disassemble \
807   jitter_executable_routine_disassemble
808 
809 /* Mutable routine construction API. */
810 #define pvm_mutable_routine_append_instruction_name \
811   jitter_mutable_routine_append_instruction_name
812 #define pvm_mutable_routine_append_meta_instruction \
813   jitter_mutable_routine_append_meta_instruction
814 #define pvm_mutable_routine_append_label \
815   jitter_mutable_routine_append_label
816 #define pvm_mutable_routine_append_symbolic_label \
817   jitter_mutable_routine_append_symbolic_label
818 #define pvm_mutable_routine_append_register_parameter \
819   jitter_mutable_routine_append_register_parameter
820 #define pvm_mutable_routine_append_literal_parameter \
821   jitter_mutable_routine_append_literal_parameter
822 #define pvm_mutable_routine_append_signed_literal_parameter \
823   jitter_mutable_routine_append_signed_literal_parameter
824 #define pvm_mutable_routine_append_unsigned_literal_parameter \
825   jitter_mutable_routine_append_unsigned_literal_parameter
826 #define pvm_mutable_routine_append_pointer_literal_parameter \
827   jitter_mutable_routine_append_pointer_literal_parameter
828 #define pvm_mutable_routine_append_label_parameter \
829   jitter_mutable_routine_append_label_parameter
830 #define pvm_mutable_routine_append_symbolic_label_parameter \
831   jitter_mutable_routine_append_symbolic_label_parameter
832 
833 /* Mutable routine destruction. */
834 #define pvm_destroy_executable_routine \
835   jitter_destroy_executable_routine
836 
837 /* Making executable routines from mutable routines. */
838 #define pvm_make_executable_routine \
839   jitter_make_executable_routine
840 
841 /* Unified routine option API. */
842 #define pvm_set_routine_option_slow_literals_only \
843   jitter_set_mutable_routine_option_slow_literals_only
844 #define pvm_set_routine_option_slow_registers_only \
845   jitter_set_mutable_routine_option_slow_registers_only
846 #define pvm_set_routine_option_slow_literals_and_registers_only \
847   jitter_set_mutable_routine_option_slow_literals_and_registers_only
848 #define pvm_set_routine_option_add_final_exitvm \
849   jitter_set_mutable_routine_option_add_final_exitvm
850 #define pvm_set_routine_option_optimization_rewriting \
851   jitter_set_mutable_routine_option_optimization_rewriting
852 
853 /* Printing and disassembling: unified API.  These do not follow the pattern of
854    the rest: wrapped identifiers here are the names of C functions specific to
855    the unified API */
856 #define pvm_routine_print \
857   jitter_routine_print
858 #define pvm_routine_disassemble \
859   jitter_routine_disassemble
860 
861 /* Unified routine construction API. */
862 #define pvm_routine_append_instruction_name \
863   jitter_mutable_routine_append_instruction_name
864 #define pvm_routine_append_meta_instruction \
865   jitter_mutable_routine_append_meta_instruction
866 #define pvm_routine_append_label \
867   jitter_mutable_routine_append_label
868 #define pvm_routine_append_symbolic_label \
869   jitter_mutable_routine_append_symbolic_label
870 #define pvm_routine_append_register_parameter \
871   jitter_mutable_routine_append_register_parameter
872 #define pvm_routine_append_literal_parameter \
873   jitter_mutable_routine_append_literal_parameter
874 #define pvm_routine_append_signed_literal_parameter \
875   jitter_mutable_routine_append_signed_literal_parameter
876 #define pvm_routine_append_unsigned_literal_parameter \
877   jitter_mutable_routine_append_unsigned_literal_parameter
878 #define pvm_routine_append_pointer_literal_parameter \
879   jitter_mutable_routine_append_pointer_literal_parameter
880 #define pvm_routine_append_label_parameter \
881   jitter_mutable_routine_append_label_parameter
882 #define pvm_routine_append_symbolic_label_parameter \
883   jitter_mutable_routine_append_symbolic_label_parameter
884 
885 /* Mutable routine destruction. */
886 #define pvm_destroy_routine                                           \
887   /* This does not follow the pattern of the rest: the wrapped identifier  \
888      here is the name of a C function specific to the unified API. */      \
889   jitter_destroy_routine
890 
891 /* The unified API has no facility to explicitly make executable routines: their
892    very existence is hidden.  For this reason some of the macros above, such
893    pvm_make_executable_routine, have no unified counterpart here. */
894 
895 /* Profiling.  Apart from pvm_state_profile, which returns a pointer to
896    the profile within a pointed state structure, everything else here has the
897    same API as the functionality in jitter/jitter-profile.h , without the VM
898    pointer.
899    Notice that this API does nothing useful onless one of the CPP macros
900    JITTER_PROFILE_COUNT or JITTER_PROFILE_SAMPLE is defined. */
901 #define pvm_profile_runtime  \
902   jitter_profile_runtime /* the struct name */
903 #define pvm_profile  \
904   jitter_profile /* the struct name */
905 // FIXME: no: distinguish between struct jitter_profile_runtime and its user-friendly variant
906 struct jitter_profile_runtime *
907 pvm_state_profile_runtime (struct pvm_state *s)
908   __attribute__ ((returns_nonnull, nonnull (1)));
909 struct pvm_profile_runtime*
910 pvm_profile_runtime_make (void)
911   __attribute__ ((returns_nonnull));
912 #define pvm_profile_destroy jitter_profile_destroy
913 void
914 pvm_profile_runtime_clear (struct pvm_profile_runtime *p)
915   __attribute__ ((nonnull (1)));
916 void
917 pvm_profile_runtime_merge_from (struct pvm_profile_runtime *to,
918                                      const struct pvm_profile_runtime *from)
919   __attribute__ ((nonnull (1, 2)));
920 void
921 pvm_profile_runtime_merge_from_state (struct pvm_profile_runtime *to,
922                                    const struct pvm_state *from_state)
923   __attribute__ ((nonnull (1, 2)));
924 struct pvm_profile *
925 pvm_profile_unspecialized_from_runtime
926    (const struct pvm_profile_runtime *p)
927   __attribute__ ((returns_nonnull, nonnull (1)));
928 struct pvm_profile *
929 pvm_profile_specialized_from_runtime (const struct pvm_profile_runtime
930                                            *p)
931   __attribute__ ((returns_nonnull, nonnull (1)));
932 void
933 pvm_profile_runtime_print_unspecialized
934    (jitter_print_context ct,
935     const struct pvm_profile_runtime *p)
936   __attribute__ ((nonnull (1, 2)));
937 void
938 pvm_profile_runtime_print_specialized (jitter_print_context ct,
939                                             const struct pvm_profile_runtime
940                                             *p)
941   __attribute__ ((nonnull (1, 2)));
942 
943 
944 
945 
946 /* Register class types.
947  * ************************************************************************** */
948 
949 /* Return a pointer to a statically allocated register class descriptor, given
950    the register class character, or NULL if the character does not represent a
951    valid register class.
952 
953    A constant array indexed by a character would have been more efficient, but
954    relying on character ordering is not portable, at least in theory.  A
955    non-constant array could be initialized in a portable way, but that would
956    probably not be worth the trouble. */
957 const struct jitter_register_class *
958 pvm_register_class_character_to_register_class (char c)
959   __attribute__ ((pure));
960 
961 
962 /* A constant array of constant pointers to every existing register class
963    descriptor, ordered by class id; each pointer within the array refers the
964    only existing class descriptor for its class.  The number of elements is
965    PVM_REGISTER_CLASS_NO , but that is not declared because the definition
966    of PVM_REGISTER_CLASS_NO comes later in generated code.
967 
968    This is useful when the user code enumerates every existing register class,
969    particularly for debugging. */
970 extern const struct jitter_register_class * const
971 pvm_regiter_classes [];
972 
973 
974 
975 
976 /* Array re-allocation.
977  * ************************************************************************** */
978 
979 /* Make the Array in the pointed state large enough to accommodate the given
980    number of slow reigsters per class, adjusting the Array pointer as needed
981    and recording information about the new size in the state; change nothing
982    if the array is already large enough.  Return the new base.
983    For example passing 3 as the value of slow_register_no would make
984    place for three slow registers per register class: if the current VM had two
985    classes 'r' and 'f' than the function would ensure that the Array can hold
986    three 'r' and three 'f' slow registers, independently from the number
987    of fast 'r' or 'f' registers.
988    Any new elements allocated in the Array are left uninitialized, but its old
989    content remains valid. */
990 char *
991 pvm_make_place_for_slow_registers (struct pvm_state *s,
992                                         jitter_int slow_register_no_per_class)
993   __attribute__ ((noinline));
994 
995 
996 
997 
998 /* **************************************************************************
999  * Evrything following this point is for internal use only.
1000  * ************************************************************************** */
1001 
1002 
1003 
1004 
1005 /* Defect tables.
1006  * ************************************************************************** */
1007 
1008 /* It is harmless to declare these unconditionally, even if they only used when
1009    patch-ins are available.  See jitter/jitter-defect.h .*/
1010 
1011 /* The worst-case defect table.  This is a global constant array, having one
1012    element per specialized instruction. */
1013 extern const jitter_uint
1014 pvm_worst_case_defect_table [];
1015 
1016 /* The actual defect table, to be filled at initialization time. */
1017 extern jitter_uint
1018 pvm_defect_table [];
1019 
1020 
1021 
1022 
1023 /* Instruction rewriter.
1024  * ************************************************************************** */
1025 
1026 /* Try to apply each rewrite rule in order and run the first one that matches,
1027    if any, on the pointed program.  When a rule fires the following ones are not
1028    checked but if a rule, after removing the last few instructions, adds another
1029    one, the addition will trigger another rewrite in its turn, and so on until
1030    no more rewriting is possible.  The rewriting process is inherently
1031    recursive.
1032 
1033    The implementation of this function is machine-generated, but the user can
1034    add her own code in the rewriter-c block, which ends up near the beginning of
1035    this function body, right after JITTTER_REWRITE_FUNCTION_PROLOG_ .  The
1036    formal argument seen from the body is named jitter_mutable_routine_p .
1037 
1038    Rationale: the argument is named differently in the body in order to keep
1039    the namespace conventions and, more importantly, to encourage the user to
1040    read this comment.
1041 
1042    The user must *not* append labels to the VM routines during rewriting: that
1043    would break it.  The user is responsible for destroying any instruction she
1044    removes, including their arguments.  The user can assume that
1045    jitter_rewritable_instruction_no is strictly greater than zero. */
1046 void
1047 pvm_rewrite (struct jitter_mutable_routine *jitter_mutable_routine_p);
1048 
1049 
1050 
1051 
1052 /* Program points at run time in executable routines.
1053  * ************************************************************************** */
1054 
1055 /* Provide a nice name for a program point type which looks VM-dependent. */
1056 typedef jitter_program_point
1057 pvm_program_point;
1058 
1059 /* Again, provide a VM-dependent alias for an actually VM-independent macro. */
1060 #define PVM_EXECUTABLE_ROUTINE_BEGINNING(_jitter_executable_routine_ptr)  \
1061   JITTER_EXECUTABLE_ROUTINE_BEGINNING(_jitter_executable_routine_ptr)
1062 
1063 
1064 
1065 
1066 /* Program points at run time in routines: unified routine API.
1067  * ************************************************************************** */
1068 
1069 /* Like PVM_EXECUTABLE_ROUTINE_BEGINNING for the unified routine API. */
1070 #define PVM_ROUTINE_BEGINNING(_jitter_routine)                \
1071   JITTER_EXECUTABLE_ROUTINE_BEGINNING                              \
1072      (jitter_routine_make_executable_if_needed (_jitter_routine))
1073 
1074 
1075 
1076 /* Executing code from an executable routine.
1077  * ************************************************************************** */
1078 
1079 /* Make sure that the pointed state has enough slow registers to run the pointed
1080    executable routine; if that is not the case, allocate more slow registers. */
1081 void
1082 pvm_ensure_enough_slow_registers_for_executable_routine
1083    (const struct jitter_executable_routine *er, struct pvm_state *s)
1084   __attribute__ ((nonnull (1, 2)));
1085 
1086 /* Run VM code starting from the given program point (which must belong to some
1087    executable routine), in the pointed VM state.
1088 
1089    Since no executable routine is given this cannot automatically guarantee that
1090    the slow registers in the pointed state are in sufficient number; it is the
1091    user's responsibility to check, if needed.
1092 
1093    This function is also usable with the unified routine API. */
1094 void
1095 pvm_branch_to_program_point (pvm_program_point p,
1096                                   struct pvm_state *s)
1097   __attribute__ ((nonnull (1, 2)));
1098 
1099 /* Run VM code starting from the beginning of the pointed executable routine,
1100    in the pointed VM state.  This does ensure that the slow registers in
1101    the pointed state are in sufficient number, by calling
1102    pvm_ensure_enough_slow_registers_for .
1103    This function is slightly less efficient than
1104    pvm_branch_to_program_point , and pvm_branch_to_program_point
1105    should be preferred in contexts where C code repeatedly calls VM code. */
1106 void
1107 pvm_execute_executable_routine (const struct jitter_executable_routine *er,
1108                                      struct pvm_state *s)
1109   __attribute__ ((nonnull (1, 2)));
1110 
1111 
1112 
1113 
1114 /* Executing code: unified routine API.
1115  * ************************************************************************** */
1116 
1117 /* Like pvm_ensure_enough_slow_registers_for_executable_routine , with the
1118    unified API. */
1119 void
1120 pvm_ensure_enough_slow_registers_for_routine
1121    (jitter_routine r, struct pvm_state *s)
1122   __attribute__ ((nonnull (1, 2)));
1123 
1124 /* pvm_branch_to_program_point , declared above, is also usable with the
1125    unified routine API. */
1126 
1127 /* Like pvm_execute_executable_routine, for a unified routine. */
1128 void
1129 pvm_execute_routine (jitter_routine r,
1130                           struct pvm_state *s)
1131   __attribute__ ((nonnull (1, 2)));
1132 
1133 
1134 
1135 
1136 /* Low-level debugging features relying on assembly: data locations.
1137  * ************************************************************************** */
1138 
1139 /* Dump human-readable information about data locations to the given print
1140    context.
1141    This is a trivial VM-dependent wrapper around jitter_dump_data_locations,
1142    which does not require a struct jitter_vm pointer as input. */
1143 void
1144 pvm_dump_data_locations (jitter_print_context output)
1145   __attribute__ ((nonnull (1)));
1146 
1147 
1148 
1149 
1150 /* Sample profiling: internal API.
1151  * ************************************************************************** */
1152 
1153 /* The functions in this sections are used internally by vm2.c, only when
1154    sample-profiling is enabled.  In fact these functions are not defined at all
1155    otherwise. */
1156 
1157 /* Initialise global sampling-related structures. */
1158 // FIXME: no: distinguish struct jitter_profile_runtime and struct jitter_profile
1159 void
1160 pvm_profile_sample_initialize (void);
1161 
1162 /* Begin sampling. */
1163 void
1164 pvm_profile_sample_start (struct pvm_state *state)
1165   __attribute__ ((nonnull (1)));
1166 
1167 /* Stop sampling. */
1168 void
1169 pvm_profile_sample_stop (void);
1170 
1171 
1172 
1173 
1174 /* Machine-generated code.
1175  * ************************************************************************** */
1176 
1177 /* What follows could be conceptually split into several generated header files,
1178    but having too many files would be inconvenient for the user to compile and
1179    link.  For this reason we generate a single header. */
1180 
1181 /* User-specified code, early header part: beginning. */
1182 #line 124 "../../libpoke/pvm.jitter"
1183 #line 124 "../../libpoke/pvm.jitter"
1184 
1185 #   include "pvm.h"
1186 #   include "pvm-val.h"
1187 #   include "ios.h"
1188 #   include "pkt.h"
1189 #   include "pk-utils.h"
1190 
1191     /* Exception handlers, that are installed in the "exceptionstack".
1192 
1193        EXCEPTION is the exception type, either one of the E_* values defined
1194        above, or any integer >= 256 for user-defined exceptions.
1195 
1196        MAIN_STACK_HEIGHT and RETURN_STACK_HEIGHT are the heights of
1197        the main and return stacks, to restore before transferring
1198        control to the exception handler.
1199 
1200        CODE is the program point where the exception handler starts.
1201 
1202        ENV is the run-time environment to restore before transferring
1203        control to the exception handler.  */
1204 
1205     struct pvm_exception_handler
1206     {
1207       int exception;
1208       jitter_stack_height main_stack_height;
1209       jitter_stack_height return_stack_height;
1210       pvm_program_point code;
1211       pvm_env env;
1212     };
1213 
1214 /* User-specified code, early header part: end */
1215 
1216 /* Configuration data for struct jitter_vm_configuration. */
1217 #define PVM_VM_NAME JITTER_STRINGIFY(Pvm)
1218 #define PVM_LOWER_CASE_PREFIX "pvm"
1219 #define PVM_UPPER_CASE_PREFIX "PVM"
1220 #define PVM_DISPATCH_HUMAN_READABLE \
1221   JITTER_DISPATCH_NAME_STRING
1222 #define PVM_MAX_FAST_REGISTER_NO_PER_CLASS -1
1223 #define PVM_MAX_NONRESIDUAL_LITERAL_NO -1
1224 
1225 
1226 /* For each register class define the register type, a unique index, and the
1227    number of fast registers.  Indices are useful for computing slow register
1228    offsets.  For each register class declare a global register class
1229    descriptor, convenient to use when generating unspecialized instructions
1230    from the C API.*/
1231 typedef
1232 pvm_val pvm_register_r;
1233 #define PVM_REGISTER_r_CLASS_ID 0
1234 #define PVM_REGISTER_r_FAST_REGISTER_NO 0
1235 extern const struct jitter_register_class
1236 pvm_register_class_r;
1237 
1238 /* How many register classes we have. */
1239 #define PVM_REGISTER_CLASS_NO  1
1240 
1241 /* A union large enough to hold a register of any class, or a machine word. */
1242 union pvm_any_register
1243 {
1244   /* In any case the union must be at least as large as a machine word. */
1245   jitter_int jitter_unused_field;
1246 
1247   pvm_register_r r /* A r-class register */;
1248 };
1249 
1250 /* An enumeration of all pvm register classes. */
1251 enum pvm_register_class_id
1252   {
1253     pvm_register_class_id_r = PVM_REGISTER_r_CLASS_ID,
1254 
1255     /* The number of register class ids, not valid as a class id itself. */
1256     pvm_register_class_id_no = PVM_REGISTER_CLASS_NO
1257   };
1258 
1259 /* A macro expanding to a statement initialising a rank of slow
1260    registers.  The argument has type union pvm_any_register *
1261    and points to the first register in a rank. */
1262 #define PVM_INITIALIZE_SLOW_REGISTER_RANK(rank) \
1263   do \
1264     { \
1265       union pvm_any_register *_jitter_rank __attribute__ ((unused)) \
1266         = (rank); \
1267       /* r-class registers need no initialisation. */ \
1268     } \
1269   while (false)
1270 
1271 
1272 #ifndef PVM_STATE_H_
1273 #define PVM_STATE_H_
1274 
1275 //#include <jitter/jitter.h>
1276 
1277 /* Early C code from the user for the state definition. */
1278 /* End of the early C code from the user for the state definition. */
1279 
1280 /* The VM state backing. */
1281 struct pvm_state_backing
1282 {
1283   /* The Array.  This initial pointer is kept in the backing, since it is
1284      not normally needed at run time.  By subtracting JITTER_ARRAY_BIAS from
1285      it (as a pointer to char) we get the base pointer. */
1286   char *jitter_array;
1287 
1288   /* How many slow registers per class the Array can hold, without being
1289      reallocated.  This number is always the same for evey class. */
1290   jitter_int jitter_slow_register_no_per_class;
1291 
1292   /* Stack backing data structures. */
1293   struct jitter_stack_backing jitter_stack_stack_backing;
1294   struct jitter_stack_backing jitter_stack_returnstack_backing;
1295   struct jitter_stack_backing jitter_stack_exceptionstack_backing;
1296 
1297   /* State backing fields added in C by the user. */
1298 #line 811 "../../libpoke/pvm.jitter"
1299 #line 811 "../../libpoke/pvm.jitter"
1300 
1301       enum pvm_exit_code exit_code;
1302       pvm_val result_value;
1303       jitter_stack_height canary;
1304       pvm vm;
1305 
1306   /* End of the state backing fields added in C by the user. */
1307 };
1308 
1309 /* The VM state runtime data structure, using memory from the VM state backing. */
1310 struct pvm_state_runtime
1311 {
1312 #if    defined(JITTER_DISPATCH_SWITCH)                   \
1313     || defined(JITTER_DISPATCH_DIRECT_THREADING)         \
1314     || defined(JITTER_DISPATCH_MINIMAL_THREADING)        \
1315     || (   defined(JITTER_DISPATCH_NO_THREADING)         \
1316         && ! defined(JITTER_MACHINE_SUPPORTS_PROCEDURE))
1317   /* A link register for branch-and-link operations.  This field must *not*
1318      be accessed from user code, as it may not exist on all dispatching
1319      models.  It is only used internally for JITTER_PROCEDURE_PROLOG. */
1320   const union jitter_word *_jitter_link;
1321 #endif
1322 
1323   /* With recent GCC versions (as of Summer 2017) the *last* declared fields
1324      are the most likely to be allocated in registers; this is why VM registers
1325      are in reverse order here.  The first few fast registers will be the "fastest"
1326      ones, allocated in hardware registers; they may be followed by other fast
1327      fast allocated on the stack at known offsets, with intermediate performance; then
1328      come the slow registers.  In critical code the users should prefer a register with as
1329      small an index as possible for best performance. */
1330 
1331   /* Stack runtime data structures. */
1332   JITTER_STACK_TOS_DECLARATION(pvm_val, stack);
1333   JITTER_STACK_NTOS_DECLARATION(pvm_val, returnstack);
1334   JITTER_STACK_NTOS_DECLARATION(struct pvm_exception_handler, exceptionstack);
1335 
1336   /* State runtime fields added in C by the user. */
1337 #line 820 "../../libpoke/pvm.jitter"
1338 #line 820 "../../libpoke/pvm.jitter"
1339 
1340       pvm_env env;
1341       uint32_t push_hi;
1342       uint32_t endian;
1343       uint32_t nenc;
1344       uint32_t pretty_print;
1345       enum pvm_omode omode;
1346       int obase;
1347       int omaps;
1348       uint32_t odepth;
1349       uint32_t oindent;
1350       uint32_t oacutoff;
1351 
1352   /* End of the state runtime fields added in C by the user. */
1353 };
1354 
1355 /* A struct holding both the backing and the runtime part of the VM state. */
1356 struct pvm_state
1357 {
1358   /* Pointers to the previous and next VM state for this VM. */
1359   struct jitter_list_links links;
1360 
1361   /* Each state data structure contains its backing. */
1362   struct pvm_state_backing pvm_state_backing;
1363 
1364   /* Each state data structure contains its runtime data structures,
1365      to be allocated to registers as long as possible, and using
1366      memory from the backing. */
1367   struct pvm_state_runtime pvm_state_runtime;
1368 };
1369 #endif // #ifndef PVM_STATE_H_
1370 #ifndef PVM_META_INSTRUCTIONS_H_
1371 #define PVM_META_INSTRUCTIONS_H_
1372 
1373 enum pvm_meta_instruction_id
1374   {
1375     pvm_meta_instruction_id_addi = 0,
1376     pvm_meta_instruction_id_addiu = 1,
1377     pvm_meta_instruction_id_addl = 2,
1378     pvm_meta_instruction_id_addlu = 3,
1379     pvm_meta_instruction_id_ains = 4,
1380     pvm_meta_instruction_id_and = 5,
1381     pvm_meta_instruction_id_aref = 6,
1382     pvm_meta_instruction_id_arefo = 7,
1383     pvm_meta_instruction_id_arem = 8,
1384     pvm_meta_instruction_id_aset = 9,
1385     pvm_meta_instruction_id_asettb = 10,
1386     pvm_meta_instruction_id_atr = 11,
1387     pvm_meta_instruction_id_ba = 12,
1388     pvm_meta_instruction_id_bandi = 13,
1389     pvm_meta_instruction_id_bandiu = 14,
1390     pvm_meta_instruction_id_bandl = 15,
1391     pvm_meta_instruction_id_bandlu = 16,
1392     pvm_meta_instruction_id_beghl = 17,
1393     pvm_meta_instruction_id_begsc = 18,
1394     pvm_meta_instruction_id_bn = 19,
1395     pvm_meta_instruction_id_bnn = 20,
1396     pvm_meta_instruction_id_bnoti = 21,
1397     pvm_meta_instruction_id_bnotiu = 22,
1398     pvm_meta_instruction_id_bnotl = 23,
1399     pvm_meta_instruction_id_bnotlu = 24,
1400     pvm_meta_instruction_id_bnzi = 25,
1401     pvm_meta_instruction_id_bnziu = 26,
1402     pvm_meta_instruction_id_bnzl = 27,
1403     pvm_meta_instruction_id_bnzlu = 28,
1404     pvm_meta_instruction_id_bori = 29,
1405     pvm_meta_instruction_id_boriu = 30,
1406     pvm_meta_instruction_id_borl = 31,
1407     pvm_meta_instruction_id_borlu = 32,
1408     pvm_meta_instruction_id_bsli = 33,
1409     pvm_meta_instruction_id_bsliu = 34,
1410     pvm_meta_instruction_id_bsll = 35,
1411     pvm_meta_instruction_id_bsllu = 36,
1412     pvm_meta_instruction_id_bsri = 37,
1413     pvm_meta_instruction_id_bsriu = 38,
1414     pvm_meta_instruction_id_bsrl = 39,
1415     pvm_meta_instruction_id_bsrlu = 40,
1416     pvm_meta_instruction_id_bxori = 41,
1417     pvm_meta_instruction_id_bxoriu = 42,
1418     pvm_meta_instruction_id_bxorl = 43,
1419     pvm_meta_instruction_id_bxorlu = 44,
1420     pvm_meta_instruction_id_bzi = 45,
1421     pvm_meta_instruction_id_bziu = 46,
1422     pvm_meta_instruction_id_bzl = 47,
1423     pvm_meta_instruction_id_bzlu = 48,
1424     pvm_meta_instruction_id_call = 49,
1425     pvm_meta_instruction_id_canary = 50,
1426     pvm_meta_instruction_id_close = 51,
1427     pvm_meta_instruction_id_ctos = 52,
1428     pvm_meta_instruction_id_disas = 53,
1429     pvm_meta_instruction_id_divi = 54,
1430     pvm_meta_instruction_id_diviu = 55,
1431     pvm_meta_instruction_id_divl = 56,
1432     pvm_meta_instruction_id_divlu = 57,
1433     pvm_meta_instruction_id_drop = 58,
1434     pvm_meta_instruction_id_drop2 = 59,
1435     pvm_meta_instruction_id_drop3 = 60,
1436     pvm_meta_instruction_id_drop4 = 61,
1437     pvm_meta_instruction_id_duc = 62,
1438     pvm_meta_instruction_id_dup = 63,
1439     pvm_meta_instruction_id_endhl = 64,
1440     pvm_meta_instruction_id_endsc = 65,
1441     pvm_meta_instruction_id_eqi = 66,
1442     pvm_meta_instruction_id_eqiu = 67,
1443     pvm_meta_instruction_id_eql = 68,
1444     pvm_meta_instruction_id_eqlu = 69,
1445     pvm_meta_instruction_id_eqs = 70,
1446     pvm_meta_instruction_id_exit = 71,
1447     pvm_meta_instruction_id_exitvm = 72,
1448     pvm_meta_instruction_id_flush = 73,
1449     pvm_meta_instruction_id_fromr = 74,
1450     pvm_meta_instruction_id_gei = 75,
1451     pvm_meta_instruction_id_geiu = 76,
1452     pvm_meta_instruction_id_gel = 77,
1453     pvm_meta_instruction_id_gelu = 78,
1454     pvm_meta_instruction_id_ges = 79,
1455     pvm_meta_instruction_id_getenv = 80,
1456     pvm_meta_instruction_id_gti = 81,
1457     pvm_meta_instruction_id_gtiu = 82,
1458     pvm_meta_instruction_id_gtl = 83,
1459     pvm_meta_instruction_id_gtlu = 84,
1460     pvm_meta_instruction_id_gts = 85,
1461     pvm_meta_instruction_id_indent = 86,
1462     pvm_meta_instruction_id_iogetb = 87,
1463     pvm_meta_instruction_id_iosetb = 88,
1464     pvm_meta_instruction_id_iosize = 89,
1465     pvm_meta_instruction_id_isa = 90,
1466     pvm_meta_instruction_id_itoi = 91,
1467     pvm_meta_instruction_id_itoiu = 92,
1468     pvm_meta_instruction_id_itol = 93,
1469     pvm_meta_instruction_id_itolu = 94,
1470     pvm_meta_instruction_id_iutoi = 95,
1471     pvm_meta_instruction_id_iutoiu = 96,
1472     pvm_meta_instruction_id_iutol = 97,
1473     pvm_meta_instruction_id_iutolu = 98,
1474     pvm_meta_instruction_id_lei = 99,
1475     pvm_meta_instruction_id_leiu = 100,
1476     pvm_meta_instruction_id_lel = 101,
1477     pvm_meta_instruction_id_lelu = 102,
1478     pvm_meta_instruction_id_les = 103,
1479     pvm_meta_instruction_id_lti = 104,
1480     pvm_meta_instruction_id_ltiu = 105,
1481     pvm_meta_instruction_id_ltl = 106,
1482     pvm_meta_instruction_id_ltlu = 107,
1483     pvm_meta_instruction_id_ltoi = 108,
1484     pvm_meta_instruction_id_ltoiu = 109,
1485     pvm_meta_instruction_id_ltol = 110,
1486     pvm_meta_instruction_id_ltolu = 111,
1487     pvm_meta_instruction_id_lts = 112,
1488     pvm_meta_instruction_id_lutoi = 113,
1489     pvm_meta_instruction_id_lutoiu = 114,
1490     pvm_meta_instruction_id_lutol = 115,
1491     pvm_meta_instruction_id_lutolu = 116,
1492     pvm_meta_instruction_id_map = 117,
1493     pvm_meta_instruction_id_mgetios = 118,
1494     pvm_meta_instruction_id_mgetm = 119,
1495     pvm_meta_instruction_id_mgeto = 120,
1496     pvm_meta_instruction_id_mgets = 121,
1497     pvm_meta_instruction_id_mgetsel = 122,
1498     pvm_meta_instruction_id_mgetsiz = 123,
1499     pvm_meta_instruction_id_mgetw = 124,
1500     pvm_meta_instruction_id_mka = 125,
1501     pvm_meta_instruction_id_mko = 126,
1502     pvm_meta_instruction_id_mksct = 127,
1503     pvm_meta_instruction_id_mktya = 128,
1504     pvm_meta_instruction_id_mktyany = 129,
1505     pvm_meta_instruction_id_mktyc = 130,
1506     pvm_meta_instruction_id_mktyi = 131,
1507     pvm_meta_instruction_id_mktyo = 132,
1508     pvm_meta_instruction_id_mktys = 133,
1509     pvm_meta_instruction_id_mktysct = 134,
1510     pvm_meta_instruction_id_mktyv = 135,
1511     pvm_meta_instruction_id_mm = 136,
1512     pvm_meta_instruction_id_modi = 137,
1513     pvm_meta_instruction_id_modiu = 138,
1514     pvm_meta_instruction_id_modl = 139,
1515     pvm_meta_instruction_id_modlu = 140,
1516     pvm_meta_instruction_id_msetios = 141,
1517     pvm_meta_instruction_id_msetm = 142,
1518     pvm_meta_instruction_id_mseto = 143,
1519     pvm_meta_instruction_id_msets = 144,
1520     pvm_meta_instruction_id_msetsel = 145,
1521     pvm_meta_instruction_id_msetsiz = 146,
1522     pvm_meta_instruction_id_msetw = 147,
1523     pvm_meta_instruction_id_muli = 148,
1524     pvm_meta_instruction_id_muliu = 149,
1525     pvm_meta_instruction_id_mull = 150,
1526     pvm_meta_instruction_id_mullu = 151,
1527     pvm_meta_instruction_id_muls = 152,
1528     pvm_meta_instruction_id_negi = 153,
1529     pvm_meta_instruction_id_negiu = 154,
1530     pvm_meta_instruction_id_negl = 155,
1531     pvm_meta_instruction_id_neglu = 156,
1532     pvm_meta_instruction_id_nei = 157,
1533     pvm_meta_instruction_id_neiu = 158,
1534     pvm_meta_instruction_id_nel = 159,
1535     pvm_meta_instruction_id_nelu = 160,
1536     pvm_meta_instruction_id_nes = 161,
1537     pvm_meta_instruction_id_nip = 162,
1538     pvm_meta_instruction_id_nip2 = 163,
1539     pvm_meta_instruction_id_nip3 = 164,
1540     pvm_meta_instruction_id_nn = 165,
1541     pvm_meta_instruction_id_nnn = 166,
1542     pvm_meta_instruction_id_nop = 167,
1543     pvm_meta_instruction_id_not = 168,
1544     pvm_meta_instruction_id_note = 169,
1545     pvm_meta_instruction_id_nrot = 170,
1546     pvm_meta_instruction_id_ogetbt = 171,
1547     pvm_meta_instruction_id_ogetm = 172,
1548     pvm_meta_instruction_id_ogetu = 173,
1549     pvm_meta_instruction_id_open = 174,
1550     pvm_meta_instruction_id_or = 175,
1551     pvm_meta_instruction_id_osetm = 176,
1552     pvm_meta_instruction_id_over = 177,
1553     pvm_meta_instruction_id_pec = 178,
1554     pvm_meta_instruction_id_peekdi = 179,
1555     pvm_meta_instruction_id_peekdiu = 180,
1556     pvm_meta_instruction_id_peekdl = 181,
1557     pvm_meta_instruction_id_peekdlu = 182,
1558     pvm_meta_instruction_id_peeki = 183,
1559     pvm_meta_instruction_id_peekiu = 184,
1560     pvm_meta_instruction_id_peekl = 185,
1561     pvm_meta_instruction_id_peeklu = 186,
1562     pvm_meta_instruction_id_peeks = 187,
1563     pvm_meta_instruction_id_pokedi = 188,
1564     pvm_meta_instruction_id_pokediu = 189,
1565     pvm_meta_instruction_id_pokedl = 190,
1566     pvm_meta_instruction_id_pokedlu = 191,
1567     pvm_meta_instruction_id_pokei = 192,
1568     pvm_meta_instruction_id_pokeiu = 193,
1569     pvm_meta_instruction_id_pokel = 194,
1570     pvm_meta_instruction_id_pokelu = 195,
1571     pvm_meta_instruction_id_pokes = 196,
1572     pvm_meta_instruction_id_pope = 197,
1573     pvm_meta_instruction_id_popend = 198,
1574     pvm_meta_instruction_id_popf = 199,
1575     pvm_meta_instruction_id_popios = 200,
1576     pvm_meta_instruction_id_popoac = 201,
1577     pvm_meta_instruction_id_popob = 202,
1578     pvm_meta_instruction_id_popobc = 203,
1579     pvm_meta_instruction_id_popoc = 204,
1580     pvm_meta_instruction_id_popod = 205,
1581     pvm_meta_instruction_id_popoi = 206,
1582     pvm_meta_instruction_id_popom = 207,
1583     pvm_meta_instruction_id_popoo = 208,
1584     pvm_meta_instruction_id_popopp = 209,
1585     pvm_meta_instruction_id_popr = 210,
1586     pvm_meta_instruction_id_popvar = 211,
1587     pvm_meta_instruction_id_powi = 212,
1588     pvm_meta_instruction_id_powiu = 213,
1589     pvm_meta_instruction_id_powl = 214,
1590     pvm_meta_instruction_id_powlu = 215,
1591     pvm_meta_instruction_id_printi = 216,
1592     pvm_meta_instruction_id_printiu = 217,
1593     pvm_meta_instruction_id_printl = 218,
1594     pvm_meta_instruction_id_printlu = 219,
1595     pvm_meta_instruction_id_prints = 220,
1596     pvm_meta_instruction_id_prolog = 221,
1597     pvm_meta_instruction_id_push = 222,
1598     pvm_meta_instruction_id_push32 = 223,
1599     pvm_meta_instruction_id_pushe = 224,
1600     pvm_meta_instruction_id_pushend = 225,
1601     pvm_meta_instruction_id_pushf = 226,
1602     pvm_meta_instruction_id_pushhi = 227,
1603     pvm_meta_instruction_id_pushios = 228,
1604     pvm_meta_instruction_id_pushlo = 229,
1605     pvm_meta_instruction_id_pushoac = 230,
1606     pvm_meta_instruction_id_pushob = 231,
1607     pvm_meta_instruction_id_pushobc = 232,
1608     pvm_meta_instruction_id_pushoc = 233,
1609     pvm_meta_instruction_id_pushod = 234,
1610     pvm_meta_instruction_id_pushoi = 235,
1611     pvm_meta_instruction_id_pushom = 236,
1612     pvm_meta_instruction_id_pushoo = 237,
1613     pvm_meta_instruction_id_pushopp = 238,
1614     pvm_meta_instruction_id_pushr = 239,
1615     pvm_meta_instruction_id_pushtopvar = 240,
1616     pvm_meta_instruction_id_pushvar = 241,
1617     pvm_meta_instruction_id_quake = 242,
1618     pvm_meta_instruction_id_raise = 243,
1619     pvm_meta_instruction_id_rand = 244,
1620     pvm_meta_instruction_id_regvar = 245,
1621     pvm_meta_instruction_id_reloc = 246,
1622     pvm_meta_instruction_id_restorer = 247,
1623     pvm_meta_instruction_id_return = 248,
1624     pvm_meta_instruction_id_revn = 249,
1625     pvm_meta_instruction_id_rot = 250,
1626     pvm_meta_instruction_id_saver = 251,
1627     pvm_meta_instruction_id_sconc = 252,
1628     pvm_meta_instruction_id_sel = 253,
1629     pvm_meta_instruction_id_setr = 254,
1630     pvm_meta_instruction_id_siz = 255,
1631     pvm_meta_instruction_id_smodi = 256,
1632     pvm_meta_instruction_id_sref = 257,
1633     pvm_meta_instruction_id_srefi = 258,
1634     pvm_meta_instruction_id_srefia = 259,
1635     pvm_meta_instruction_id_srefio = 260,
1636     pvm_meta_instruction_id_srefmnt = 261,
1637     pvm_meta_instruction_id_srefnt = 262,
1638     pvm_meta_instruction_id_srefo = 263,
1639     pvm_meta_instruction_id_sset = 264,
1640     pvm_meta_instruction_id_strace = 265,
1641     pvm_meta_instruction_id_strref = 266,
1642     pvm_meta_instruction_id_subi = 267,
1643     pvm_meta_instruction_id_subiu = 268,
1644     pvm_meta_instruction_id_subl = 269,
1645     pvm_meta_instruction_id_sublu = 270,
1646     pvm_meta_instruction_id_substr = 271,
1647     pvm_meta_instruction_id_swap = 272,
1648     pvm_meta_instruction_id_swapgti = 273,
1649     pvm_meta_instruction_id_swapgtiu = 274,
1650     pvm_meta_instruction_id_swapgtl = 275,
1651     pvm_meta_instruction_id_swapgtlu = 276,
1652     pvm_meta_instruction_id_sync = 277,
1653     pvm_meta_instruction_id_time = 278,
1654     pvm_meta_instruction_id_tor = 279,
1655     pvm_meta_instruction_id_tuck = 280,
1656     pvm_meta_instruction_id_tyagetb = 281,
1657     pvm_meta_instruction_id_tyagett = 282,
1658     pvm_meta_instruction_id_tyisc = 283,
1659     pvm_meta_instruction_id_tyissct = 284,
1660     pvm_meta_instruction_id_typof = 285,
1661     pvm_meta_instruction_id_tysctn = 286,
1662     pvm_meta_instruction_id_unmap = 287,
1663     pvm_meta_instruction_id_unreachable = 288,
1664     pvm_meta_instruction_id_ureloc = 289,
1665     pvm_meta_instruction_id_write = 290
1666   };
1667 
1668 #define PVM_META_INSTRUCTION_NO 291
1669 
1670 /* The longest meta-instruction name length, not mangled, without
1671    counting the final '\0' character. */
1672 #define PVM_MAX_META_INSTRUCTION_NAME_LENGTH 11
1673 
1674 #endif // #ifndef PVM_META_INSTRUCTIONS_H_
1675 #ifndef PVM_SPECIALIZED_INSTRUCTIONS_H_
1676 #define PVM_SPECIALIZED_INSTRUCTIONS_H_
1677 
1678 enum pvm_specialized_instruction_opcode
1679   {
1680     pvm_specialized_instruction_opcode__eINVALID = 0,
1681     pvm_specialized_instruction_opcode__eBEGINBASICBLOCK = 1,
1682     pvm_specialized_instruction_opcode__eEXITVM = 2,
1683     pvm_specialized_instruction_opcode__eDATALOCATIONS = 3,
1684     pvm_specialized_instruction_opcode__eNOP = 4,
1685     pvm_specialized_instruction_opcode__eUNREACHABLE0 = 5,
1686     pvm_specialized_instruction_opcode__eUNREACHABLE1 = 6,
1687     pvm_specialized_instruction_opcode__eUNREACHABLE2 = 7,
1688     pvm_specialized_instruction_opcode_addi = 8,
1689     pvm_specialized_instruction_opcode_addiu = 9,
1690     pvm_specialized_instruction_opcode_addl = 10,
1691     pvm_specialized_instruction_opcode_addlu = 11,
1692     pvm_specialized_instruction_opcode_ains = 12,
1693     pvm_specialized_instruction_opcode_and = 13,
1694     pvm_specialized_instruction_opcode_aref = 14,
1695     pvm_specialized_instruction_opcode_arefo = 15,
1696     pvm_specialized_instruction_opcode_arem = 16,
1697     pvm_specialized_instruction_opcode_aset = 17,
1698     pvm_specialized_instruction_opcode_asettb = 18,
1699     pvm_specialized_instruction_opcode_atr = 19,
1700     pvm_specialized_instruction_opcode_ba__fR = 20,
1701     pvm_specialized_instruction_opcode_bandi = 21,
1702     pvm_specialized_instruction_opcode_bandiu = 22,
1703     pvm_specialized_instruction_opcode_bandl = 23,
1704     pvm_specialized_instruction_opcode_bandlu = 24,
1705     pvm_specialized_instruction_opcode_beghl = 25,
1706     pvm_specialized_instruction_opcode_begsc = 26,
1707     pvm_specialized_instruction_opcode_bn__fR = 27,
1708     pvm_specialized_instruction_opcode_bnn__fR = 28,
1709     pvm_specialized_instruction_opcode_bnoti = 29,
1710     pvm_specialized_instruction_opcode_bnotiu = 30,
1711     pvm_specialized_instruction_opcode_bnotl = 31,
1712     pvm_specialized_instruction_opcode_bnotlu = 32,
1713     pvm_specialized_instruction_opcode_bnzi__fR = 33,
1714     pvm_specialized_instruction_opcode_bnziu__fR = 34,
1715     pvm_specialized_instruction_opcode_bnzl__fR = 35,
1716     pvm_specialized_instruction_opcode_bnzlu__fR = 36,
1717     pvm_specialized_instruction_opcode_bori = 37,
1718     pvm_specialized_instruction_opcode_boriu = 38,
1719     pvm_specialized_instruction_opcode_borl = 39,
1720     pvm_specialized_instruction_opcode_borlu = 40,
1721     pvm_specialized_instruction_opcode_bsli = 41,
1722     pvm_specialized_instruction_opcode_bsliu = 42,
1723     pvm_specialized_instruction_opcode_bsll = 43,
1724     pvm_specialized_instruction_opcode_bsllu = 44,
1725     pvm_specialized_instruction_opcode_bsri = 45,
1726     pvm_specialized_instruction_opcode_bsriu = 46,
1727     pvm_specialized_instruction_opcode_bsrl = 47,
1728     pvm_specialized_instruction_opcode_bsrlu = 48,
1729     pvm_specialized_instruction_opcode_bxori = 49,
1730     pvm_specialized_instruction_opcode_bxoriu = 50,
1731     pvm_specialized_instruction_opcode_bxorl = 51,
1732     pvm_specialized_instruction_opcode_bxorlu = 52,
1733     pvm_specialized_instruction_opcode_bzi__fR = 53,
1734     pvm_specialized_instruction_opcode_bziu__fR = 54,
1735     pvm_specialized_instruction_opcode_bzl__fR = 55,
1736     pvm_specialized_instruction_opcode_bzlu__fR = 56,
1737     pvm_specialized_instruction_opcode_call__retR = 57,
1738     pvm_specialized_instruction_opcode_canary = 58,
1739     pvm_specialized_instruction_opcode_close = 59,
1740     pvm_specialized_instruction_opcode_ctos = 60,
1741     pvm_specialized_instruction_opcode_disas = 61,
1742     pvm_specialized_instruction_opcode_divi = 62,
1743     pvm_specialized_instruction_opcode_diviu = 63,
1744     pvm_specialized_instruction_opcode_divl = 64,
1745     pvm_specialized_instruction_opcode_divlu = 65,
1746     pvm_specialized_instruction_opcode_drop = 66,
1747     pvm_specialized_instruction_opcode_drop2 = 67,
1748     pvm_specialized_instruction_opcode_drop3 = 68,
1749     pvm_specialized_instruction_opcode_drop4 = 69,
1750     pvm_specialized_instruction_opcode_duc = 70,
1751     pvm_specialized_instruction_opcode_dup = 71,
1752     pvm_specialized_instruction_opcode_endhl = 72,
1753     pvm_specialized_instruction_opcode_endsc = 73,
1754     pvm_specialized_instruction_opcode_eqi = 74,
1755     pvm_specialized_instruction_opcode_eqiu = 75,
1756     pvm_specialized_instruction_opcode_eql = 76,
1757     pvm_specialized_instruction_opcode_eqlu = 77,
1758     pvm_specialized_instruction_opcode_eqs = 78,
1759     pvm_specialized_instruction_opcode_exit = 79,
1760     pvm_specialized_instruction_opcode_exitvm = 80,
1761     pvm_specialized_instruction_opcode_flush = 81,
1762     pvm_specialized_instruction_opcode_fromr = 82,
1763     pvm_specialized_instruction_opcode_gei = 83,
1764     pvm_specialized_instruction_opcode_geiu = 84,
1765     pvm_specialized_instruction_opcode_gel = 85,
1766     pvm_specialized_instruction_opcode_gelu = 86,
1767     pvm_specialized_instruction_opcode_ges = 87,
1768     pvm_specialized_instruction_opcode_getenv = 88,
1769     pvm_specialized_instruction_opcode_gti = 89,
1770     pvm_specialized_instruction_opcode_gtiu = 90,
1771     pvm_specialized_instruction_opcode_gtl = 91,
1772     pvm_specialized_instruction_opcode_gtlu = 92,
1773     pvm_specialized_instruction_opcode_gts = 93,
1774     pvm_specialized_instruction_opcode_indent = 94,
1775     pvm_specialized_instruction_opcode_iogetb = 95,
1776     pvm_specialized_instruction_opcode_iosetb = 96,
1777     pvm_specialized_instruction_opcode_iosize = 97,
1778     pvm_specialized_instruction_opcode_isa = 98,
1779     pvm_specialized_instruction_opcode_itoi__nR = 99,
1780     pvm_specialized_instruction_opcode_itoiu__nR = 100,
1781     pvm_specialized_instruction_opcode_itol__nR = 101,
1782     pvm_specialized_instruction_opcode_itolu__nR = 102,
1783     pvm_specialized_instruction_opcode_iutoi__nR = 103,
1784     pvm_specialized_instruction_opcode_iutoiu__nR = 104,
1785     pvm_specialized_instruction_opcode_iutol__nR = 105,
1786     pvm_specialized_instruction_opcode_iutolu__nR = 106,
1787     pvm_specialized_instruction_opcode_lei = 107,
1788     pvm_specialized_instruction_opcode_leiu = 108,
1789     pvm_specialized_instruction_opcode_lel = 109,
1790     pvm_specialized_instruction_opcode_lelu = 110,
1791     pvm_specialized_instruction_opcode_les = 111,
1792     pvm_specialized_instruction_opcode_lti = 112,
1793     pvm_specialized_instruction_opcode_ltiu = 113,
1794     pvm_specialized_instruction_opcode_ltl = 114,
1795     pvm_specialized_instruction_opcode_ltlu = 115,
1796     pvm_specialized_instruction_opcode_ltoi__nR = 116,
1797     pvm_specialized_instruction_opcode_ltoiu__nR = 117,
1798     pvm_specialized_instruction_opcode_ltol__nR = 118,
1799     pvm_specialized_instruction_opcode_ltolu__nR = 119,
1800     pvm_specialized_instruction_opcode_lts = 120,
1801     pvm_specialized_instruction_opcode_lutoi__nR = 121,
1802     pvm_specialized_instruction_opcode_lutoiu__nR = 122,
1803     pvm_specialized_instruction_opcode_lutol__nR = 123,
1804     pvm_specialized_instruction_opcode_lutolu__nR = 124,
1805     pvm_specialized_instruction_opcode_map = 125,
1806     pvm_specialized_instruction_opcode_mgetios = 126,
1807     pvm_specialized_instruction_opcode_mgetm = 127,
1808     pvm_specialized_instruction_opcode_mgeto = 128,
1809     pvm_specialized_instruction_opcode_mgets = 129,
1810     pvm_specialized_instruction_opcode_mgetsel = 130,
1811     pvm_specialized_instruction_opcode_mgetsiz = 131,
1812     pvm_specialized_instruction_opcode_mgetw = 132,
1813     pvm_specialized_instruction_opcode_mka = 133,
1814     pvm_specialized_instruction_opcode_mko = 134,
1815     pvm_specialized_instruction_opcode_mksct = 135,
1816     pvm_specialized_instruction_opcode_mktya = 136,
1817     pvm_specialized_instruction_opcode_mktyany = 137,
1818     pvm_specialized_instruction_opcode_mktyc = 138,
1819     pvm_specialized_instruction_opcode_mktyi = 139,
1820     pvm_specialized_instruction_opcode_mktyo = 140,
1821     pvm_specialized_instruction_opcode_mktys = 141,
1822     pvm_specialized_instruction_opcode_mktysct = 142,
1823     pvm_specialized_instruction_opcode_mktyv = 143,
1824     pvm_specialized_instruction_opcode_mm = 144,
1825     pvm_specialized_instruction_opcode_modi = 145,
1826     pvm_specialized_instruction_opcode_modiu = 146,
1827     pvm_specialized_instruction_opcode_modl = 147,
1828     pvm_specialized_instruction_opcode_modlu = 148,
1829     pvm_specialized_instruction_opcode_msetios = 149,
1830     pvm_specialized_instruction_opcode_msetm = 150,
1831     pvm_specialized_instruction_opcode_mseto = 151,
1832     pvm_specialized_instruction_opcode_msets = 152,
1833     pvm_specialized_instruction_opcode_msetsel = 153,
1834     pvm_specialized_instruction_opcode_msetsiz = 154,
1835     pvm_specialized_instruction_opcode_msetw = 155,
1836     pvm_specialized_instruction_opcode_muli = 156,
1837     pvm_specialized_instruction_opcode_muliu = 157,
1838     pvm_specialized_instruction_opcode_mull = 158,
1839     pvm_specialized_instruction_opcode_mullu = 159,
1840     pvm_specialized_instruction_opcode_muls = 160,
1841     pvm_specialized_instruction_opcode_negi = 161,
1842     pvm_specialized_instruction_opcode_negiu = 162,
1843     pvm_specialized_instruction_opcode_negl = 163,
1844     pvm_specialized_instruction_opcode_neglu = 164,
1845     pvm_specialized_instruction_opcode_nei = 165,
1846     pvm_specialized_instruction_opcode_neiu = 166,
1847     pvm_specialized_instruction_opcode_nel = 167,
1848     pvm_specialized_instruction_opcode_nelu = 168,
1849     pvm_specialized_instruction_opcode_nes = 169,
1850     pvm_specialized_instruction_opcode_nip = 170,
1851     pvm_specialized_instruction_opcode_nip2 = 171,
1852     pvm_specialized_instruction_opcode_nip3 = 172,
1853     pvm_specialized_instruction_opcode_nn = 173,
1854     pvm_specialized_instruction_opcode_nnn = 174,
1855     pvm_specialized_instruction_opcode_nop = 175,
1856     pvm_specialized_instruction_opcode_not = 176,
1857     pvm_specialized_instruction_opcode_note__nR = 177,
1858     pvm_specialized_instruction_opcode_nrot = 178,
1859     pvm_specialized_instruction_opcode_ogetbt = 179,
1860     pvm_specialized_instruction_opcode_ogetm = 180,
1861     pvm_specialized_instruction_opcode_ogetu = 181,
1862     pvm_specialized_instruction_opcode_open = 182,
1863     pvm_specialized_instruction_opcode_or = 183,
1864     pvm_specialized_instruction_opcode_osetm = 184,
1865     pvm_specialized_instruction_opcode_over = 185,
1866     pvm_specialized_instruction_opcode_pec = 186,
1867     pvm_specialized_instruction_opcode_peekdi__nR = 187,
1868     pvm_specialized_instruction_opcode_peekdiu__nR = 188,
1869     pvm_specialized_instruction_opcode_peekdl__nR = 189,
1870     pvm_specialized_instruction_opcode_peekdlu__nR = 190,
1871     pvm_specialized_instruction_opcode_peeki__nR__nR__nR = 191,
1872     pvm_specialized_instruction_opcode_peekiu__nR__nR = 192,
1873     pvm_specialized_instruction_opcode_peekl__nR__nR__nR = 193,
1874     pvm_specialized_instruction_opcode_peeklu__nR__nR = 194,
1875     pvm_specialized_instruction_opcode_peeks = 195,
1876     pvm_specialized_instruction_opcode_pokedi__nR = 196,
1877     pvm_specialized_instruction_opcode_pokediu__nR = 197,
1878     pvm_specialized_instruction_opcode_pokedl__nR = 198,
1879     pvm_specialized_instruction_opcode_pokedlu__nR = 199,
1880     pvm_specialized_instruction_opcode_pokei__nR__nR__nR = 200,
1881     pvm_specialized_instruction_opcode_pokeiu__nR__nR = 201,
1882     pvm_specialized_instruction_opcode_pokel__nR__nR__nR = 202,
1883     pvm_specialized_instruction_opcode_pokelu__nR__nR = 203,
1884     pvm_specialized_instruction_opcode_pokes = 204,
1885     pvm_specialized_instruction_opcode_pope = 205,
1886     pvm_specialized_instruction_opcode_popend = 206,
1887     pvm_specialized_instruction_opcode_popf__nR = 207,
1888     pvm_specialized_instruction_opcode_popios = 208,
1889     pvm_specialized_instruction_opcode_popoac = 209,
1890     pvm_specialized_instruction_opcode_popob = 210,
1891     pvm_specialized_instruction_opcode_popobc = 211,
1892     pvm_specialized_instruction_opcode_popoc = 212,
1893     pvm_specialized_instruction_opcode_popod = 213,
1894     pvm_specialized_instruction_opcode_popoi = 214,
1895     pvm_specialized_instruction_opcode_popom = 215,
1896     pvm_specialized_instruction_opcode_popoo = 216,
1897     pvm_specialized_instruction_opcode_popopp = 217,
1898     pvm_specialized_instruction_opcode_popr___rrR = 218,
1899     pvm_specialized_instruction_opcode_popvar__nR__nR = 219,
1900     pvm_specialized_instruction_opcode_powi = 220,
1901     pvm_specialized_instruction_opcode_powiu = 221,
1902     pvm_specialized_instruction_opcode_powl = 222,
1903     pvm_specialized_instruction_opcode_powlu = 223,
1904     pvm_specialized_instruction_opcode_printi__nR = 224,
1905     pvm_specialized_instruction_opcode_printiu__nR = 225,
1906     pvm_specialized_instruction_opcode_printl__nR = 226,
1907     pvm_specialized_instruction_opcode_printlu__nR = 227,
1908     pvm_specialized_instruction_opcode_prints = 228,
1909     pvm_specialized_instruction_opcode_prolog = 229,
1910     pvm_specialized_instruction_opcode_push__nR = 230,
1911     pvm_specialized_instruction_opcode_push__lR = 231,
1912     pvm_specialized_instruction_opcode_push32__nR = 232,
1913     pvm_specialized_instruction_opcode_push32__lR = 233,
1914     pvm_specialized_instruction_opcode_pushe__lR = 234,
1915     pvm_specialized_instruction_opcode_pushend = 235,
1916     pvm_specialized_instruction_opcode_pushf__nR = 236,
1917     pvm_specialized_instruction_opcode_pushhi__nR = 237,
1918     pvm_specialized_instruction_opcode_pushhi__lR = 238,
1919     pvm_specialized_instruction_opcode_pushios = 239,
1920     pvm_specialized_instruction_opcode_pushlo__nR = 240,
1921     pvm_specialized_instruction_opcode_pushlo__lR = 241,
1922     pvm_specialized_instruction_opcode_pushoac = 242,
1923     pvm_specialized_instruction_opcode_pushob = 243,
1924     pvm_specialized_instruction_opcode_pushobc = 244,
1925     pvm_specialized_instruction_opcode_pushoc = 245,
1926     pvm_specialized_instruction_opcode_pushod = 246,
1927     pvm_specialized_instruction_opcode_pushoi = 247,
1928     pvm_specialized_instruction_opcode_pushom = 248,
1929     pvm_specialized_instruction_opcode_pushoo = 249,
1930     pvm_specialized_instruction_opcode_pushopp = 250,
1931     pvm_specialized_instruction_opcode_pushr___rrR = 251,
1932     pvm_specialized_instruction_opcode_pushtopvar__nR = 252,
1933     pvm_specialized_instruction_opcode_pushvar__n0__n0 = 253,
1934     pvm_specialized_instruction_opcode_pushvar__n0__n1 = 254,
1935     pvm_specialized_instruction_opcode_pushvar__n0__n2 = 255,
1936     pvm_specialized_instruction_opcode_pushvar__n0__n3 = 256,
1937     pvm_specialized_instruction_opcode_pushvar__n0__n4 = 257,
1938     pvm_specialized_instruction_opcode_pushvar__n0__n5 = 258,
1939     pvm_specialized_instruction_opcode_pushvar__n0__nR = 259,
1940     pvm_specialized_instruction_opcode_pushvar__nR__n0 = 260,
1941     pvm_specialized_instruction_opcode_pushvar__nR__n1 = 261,
1942     pvm_specialized_instruction_opcode_pushvar__nR__n2 = 262,
1943     pvm_specialized_instruction_opcode_pushvar__nR__n3 = 263,
1944     pvm_specialized_instruction_opcode_pushvar__nR__n4 = 264,
1945     pvm_specialized_instruction_opcode_pushvar__nR__n5 = 265,
1946     pvm_specialized_instruction_opcode_pushvar__nR__nR = 266,
1947     pvm_specialized_instruction_opcode_quake = 267,
1948     pvm_specialized_instruction_opcode_raise = 268,
1949     pvm_specialized_instruction_opcode_rand = 269,
1950     pvm_specialized_instruction_opcode_regvar = 270,
1951     pvm_specialized_instruction_opcode_reloc = 271,
1952     pvm_specialized_instruction_opcode_restorer___rrR = 272,
1953     pvm_specialized_instruction_opcode_return = 273,
1954     pvm_specialized_instruction_opcode_revn__n3 = 274,
1955     pvm_specialized_instruction_opcode_revn__n4 = 275,
1956     pvm_specialized_instruction_opcode_revn__nR = 276,
1957     pvm_specialized_instruction_opcode_rot = 277,
1958     pvm_specialized_instruction_opcode_saver___rrR = 278,
1959     pvm_specialized_instruction_opcode_sconc = 279,
1960     pvm_specialized_instruction_opcode_sel = 280,
1961     pvm_specialized_instruction_opcode_setr___rrR = 281,
1962     pvm_specialized_instruction_opcode_siz = 282,
1963     pvm_specialized_instruction_opcode_smodi = 283,
1964     pvm_specialized_instruction_opcode_sref = 284,
1965     pvm_specialized_instruction_opcode_srefi = 285,
1966     pvm_specialized_instruction_opcode_srefia = 286,
1967     pvm_specialized_instruction_opcode_srefio = 287,
1968     pvm_specialized_instruction_opcode_srefmnt = 288,
1969     pvm_specialized_instruction_opcode_srefnt = 289,
1970     pvm_specialized_instruction_opcode_srefo = 290,
1971     pvm_specialized_instruction_opcode_sset = 291,
1972     pvm_specialized_instruction_opcode_strace__nR = 292,
1973     pvm_specialized_instruction_opcode_strref = 293,
1974     pvm_specialized_instruction_opcode_subi = 294,
1975     pvm_specialized_instruction_opcode_subiu = 295,
1976     pvm_specialized_instruction_opcode_subl = 296,
1977     pvm_specialized_instruction_opcode_sublu = 297,
1978     pvm_specialized_instruction_opcode_substr = 298,
1979     pvm_specialized_instruction_opcode_swap = 299,
1980     pvm_specialized_instruction_opcode_swapgti = 300,
1981     pvm_specialized_instruction_opcode_swapgtiu = 301,
1982     pvm_specialized_instruction_opcode_swapgtl = 302,
1983     pvm_specialized_instruction_opcode_swapgtlu = 303,
1984     pvm_specialized_instruction_opcode_sync = 304,
1985     pvm_specialized_instruction_opcode_time = 305,
1986     pvm_specialized_instruction_opcode_tor = 306,
1987     pvm_specialized_instruction_opcode_tuck = 307,
1988     pvm_specialized_instruction_opcode_tyagetb = 308,
1989     pvm_specialized_instruction_opcode_tyagett = 309,
1990     pvm_specialized_instruction_opcode_tyisc = 310,
1991     pvm_specialized_instruction_opcode_tyissct = 311,
1992     pvm_specialized_instruction_opcode_typof = 312,
1993     pvm_specialized_instruction_opcode_tysctn = 313,
1994     pvm_specialized_instruction_opcode_unmap = 314,
1995     pvm_specialized_instruction_opcode_unreachable = 315,
1996     pvm_specialized_instruction_opcode_ureloc = 316,
1997     pvm_specialized_instruction_opcode_write__retR = 317,
1998     pvm_specialized_instruction_opcode__Aba__fR_A_mno_mfast_mbranches = 318,
1999     pvm_specialized_instruction_opcode__Abn__fR_A_mno_mfast_mbranches = 319,
2000     pvm_specialized_instruction_opcode__Abnn__fR_A_mno_mfast_mbranches = 320,
2001     pvm_specialized_instruction_opcode__Abnzi__fR_A_mno_mfast_mbranches = 321,
2002     pvm_specialized_instruction_opcode__Abnziu__fR_A_mno_mfast_mbranches = 322,
2003     pvm_specialized_instruction_opcode__Abnzl__fR_A_mno_mfast_mbranches = 323,
2004     pvm_specialized_instruction_opcode__Abnzlu__fR_A_mno_mfast_mbranches = 324,
2005     pvm_specialized_instruction_opcode__Abzi__fR_A_mno_mfast_mbranches = 325,
2006     pvm_specialized_instruction_opcode__Abziu__fR_A_mno_mfast_mbranches = 326,
2007     pvm_specialized_instruction_opcode__Abzl__fR_A_mno_mfast_mbranches = 327,
2008     pvm_specialized_instruction_opcode__Abzlu__fR_A_mno_mfast_mbranches = 328
2009   };
2010 
2011 #define PVM_SPECIALIZED_INSTRUCTION_NO 329
2012 
2013 #endif // #ifndef PVM_SPECIALIZED_INSTRUCTIONS_H_
2014 /* How many residuals we can have at most.  This, with some dispatching models,
2015    is needed to compute a slow register offset from the base. */
2016 #define PVM_MAX_RESIDUAL_ARITY  3
2017 
2018 /* User-specified code, late header part: beginning. */
2019 #line 183 "../../libpoke/pvm.jitter"
2020 #line 183 "../../libpoke/pvm.jitter"
2021 
2022     /* Macros to raise an exception from within an instruction.  This
2023        is used in the RAISE instruction itself, and also in instructions
2024        that can fail, such as integer division or IO.
2025 
2026        The code in the macro looks for the first matching exception
2027        handler in the exception handlers stack.  Then it restores the
2028        heights of the main stack and the return stack, restores the
2029        original dynamic environment, and then pushes the exception
2030        type as an integer in the main stack, before branching to the
2031        exception handler.  */
2032 
2033 #define PVM_RAISE_DIRECT(EXCEPTION)                                   \
2034   do                                                                  \
2035   {                                                                   \
2036    int exception_code                                                 \
2037      = PVM_VAL_INT (pvm_ref_struct_cstr ((EXCEPTION), "code"));       \
2038                                                                       \
2039    while (1)                                                          \
2040    {                                                                  \
2041      struct pvm_exception_handler ehandler                            \
2042        = JITTER_TOP_EXCEPTIONSTACK ();                                \
2043      int handler_exception = ehandler.exception;                      \
2044                                                                       \
2045      JITTER_DROP_EXCEPTIONSTACK ();                                   \
2046                                                                       \
2047      if (handler_exception == 0                                       \
2048          || handler_exception == exception_code)                      \
2049      {                                                                \
2050        JITTER_SET_HEIGHT_STACK (ehandler.main_stack_height);          \
2051        JITTER_SET_HEIGHT_RETURNSTACK (ehandler.return_stack_height);  \
2052                                                                       \
2053        JITTER_PUSH_STACK ((EXCEPTION));                               \
2054                                                                       \
2055        jitter_state_runtime.env = ehandler.env;                       \
2056        JITTER_BRANCH (ehandler.code);                                 \
2057        break;                                                         \
2058      }                                                                \
2059    }                                                                  \
2060  } while (0)
2061 
2062 
2063 #define PVM_RAISE(CODE,STR,ESTATUS)                                   \
2064  do                                                                   \
2065  {                                                                    \
2066    pvm_val exception = pvm_make_exception ((CODE),(STR),(ESTATUS));   \
2067    PVM_RAISE_DIRECT (exception);                                      \
2068  } while (0)
2069 
2070 #define PVM_RAISE_DFL(BASE)                                           \
2071  do                                                                   \
2072  {                                                                    \
2073    PVM_RAISE (BASE,BASE##_MSG,BASE##_ESTATUS);                        \
2074  } while (0)
2075 
2076     /* Macros to implement different kind of instructions.  These are to
2077        avoid flagrant code replication below.  */
2078 
2079 /* Binary numeric operations generating a boolean on the stack.
2080    ( TYPE TYPE -- TYPE TYPE INT ) */
2081 # define PVM_BOOL_BINOP(TYPE,OP)                                             \
2082    do                                                                        \
2083     {                                                                        \
2084       pvm_val res = PVM_MAKE_INT (PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ()) \
2085                                   OP PVM_VAL_##TYPE (JITTER_TOP_STACK ()), 32); \
2086       JITTER_PUSH_STACK (res);                                               \
2087     } while (0)
2088 
2089 /* Unary numeric operations.
2090    ( TYPE -- TYPE TYPE) */
2091 # define PVM_UNOP(TYPE,TYPER,TYPERLC,OP)                                     \
2092    do                                                                        \
2093     {                                                                        \
2094       int size = PVM_VAL_##TYPER##_SIZE (JITTER_TOP_STACK ());               \
2095       pvm_val res = pvm_make_##TYPERLC (OP PVM_VAL_##TYPE (JITTER_TOP_STACK ()), size); \
2096       JITTER_PUSH_STACK (res);                                               \
2097     } while (0)
2098 
2099 /* Signed negation.
2100    We check for overflow, raising E_overflow whenever appropriate.  */
2101 
2102 # define PVM_NEG_SIGNED(TYPE,CTYPE)                                          \
2103   do                                                                         \
2104   {                                                                          \
2105     CTYPE a = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2106     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2107     int64_t a64 = ((int64_t) a << (64 - size));                              \
2108                                                                              \
2109     if (INT_NEGATE_OVERFLOW (a64))                                           \
2110       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2111     else                                                                     \
2112       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (-a, size));                        \
2113   } while (0)
2114 
2115 
2116 /* Signed addition.
2117    The two operands and the result are assumed to be PVM integers, having
2118    the same bit size.
2119    We check for overflow, raising E_overflow whenever appropriate.  */
2120 
2121 # define PVM_ADD_SIGNED(TYPE,CTYPE)                                          \
2122   do                                                                         \
2123   {                                                                          \
2124     CTYPE a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                    \
2125     CTYPE b = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2126     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2127     int64_t a64 = ((int64_t) a << (64 - size));                              \
2128     int64_t b64 = ((int64_t) b << (64 - size));                              \
2129                                                                              \
2130     if (INT_ADD_OVERFLOW (a64, b64))                                         \
2131       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2132     else                                                                     \
2133       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (a + b, size));                     \
2134   } while (0)
2135 
2136 /* Signed subtraction.
2137    The two operands and the result are assumed to be PVM integers, having
2138    the same bit size.
2139    We check for overflow, raising E_overflow whenever appropriate.  */
2140 
2141 # define PVM_SUB_SIGNED(TYPE,CTYPE)                                          \
2142   do                                                                         \
2143   {                                                                          \
2144     CTYPE a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                    \
2145     CTYPE b = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2146     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2147     int64_t a64 = ((int64_t) a << (64 - size));                              \
2148     int64_t b64 = ((int64_t) b << (64 - size));                              \
2149                                                                              \
2150     if (INT_SUBTRACT_OVERFLOW (a64, b64))                                    \
2151       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2152     else                                                                     \
2153       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (a - b, size));                     \
2154   } while (0)
2155 
2156 /* Signed multiplication.
2157    The two operands and the result are assumed to be PVM integers, having
2158    the same bit size.
2159    We check for overflow, raising E_overflow whenever appropriate.  */
2160 
2161 # define PVM_MUL_SIGNED(TYPE,CTYPE)                                          \
2162   do                                                                         \
2163   {                                                                          \
2164     CTYPE a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                    \
2165     CTYPE b = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2166     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2167     int64_t a64 = ((int64_t) a << (64 - size));                              \
2168                                                                              \
2169     if (INT_MULTIPLY_OVERFLOW (a64, b))                                      \
2170       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2171     else                                                                     \
2172       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (a * b, size));                     \
2173   } while (0)
2174 
2175 /* Signed division.
2176    We check for overflow, raising E_overflow whenever appropriate.  */
2177 
2178 # define PVM_DIV_SIGNED(TYPE,CTYPE)                                          \
2179    if (PVM_VAL_##TYPE (JITTER_TOP_STACK ()) == 0)                            \
2180    {                                                                         \
2181       PVM_RAISE_DFL (PVM_E_DIV_BY_ZERO);                                     \
2182    }                                                                         \
2183    else                                                                      \
2184    {                                                                         \
2185     CTYPE a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                    \
2186     CTYPE b = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2187     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2188     int64_t a64 = ((int64_t) a << (64 - size));                              \
2189                                                                              \
2190     if (INT_DIVIDE_OVERFLOW (a64, b))                                        \
2191       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2192     else                                                                     \
2193       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (a / b, size));                     \
2194    }
2195 
2196 # define PVM_MOD_SIGNED(TYPE,CTYPE)                                          \
2197    if (PVM_VAL_##TYPE (JITTER_TOP_STACK ()) == 0)                            \
2198    {                                                                         \
2199       PVM_RAISE_DFL (PVM_E_DIV_BY_ZERO);                                     \
2200    }                                                                         \
2201    else                                                                      \
2202    {                                                                         \
2203     CTYPE a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                    \
2204     CTYPE b = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                          \
2205     int size = PVM_VAL_##TYPE##_SIZE (JITTER_TOP_STACK ());                  \
2206     int64_t a64 = ((int64_t) a << (64 - size));                              \
2207                                                                              \
2208     if (INT_DIVIDE_OVERFLOW (a64, b))                                        \
2209       PVM_RAISE_DFL (PVM_E_OVERFLOW);                                        \
2210     else                                                                     \
2211       JITTER_PUSH_STACK (PVM_MAKE_##TYPE (a % b, size));                     \
2212    }
2213 
2214 /* Binary numeric operations.
2215   ( TYPE TYPE -- TYPE TYPE TYPE ) */
2216 # define PVM_BINOP(TYPEA,TYPEB,TYPER,OP)                                     \
2217    do                                                                        \
2218     {                                                                        \
2219       int size = PVM_VAL_##TYPER##_SIZE (JITTER_UNDER_TOP_STACK ());       \
2220       pvm_val res = PVM_MAKE_##TYPER (PVM_VAL_##TYPEA (JITTER_UNDER_TOP_STACK ()) \
2221                                       OP PVM_VAL_##TYPEB (JITTER_TOP_STACK ()), size); \
2222       JITTER_PUSH_STACK (res);                                               \
2223     } while (0)
2224 
2225 /* Same, but with division by zero run-time check.  */
2226 # define PVM_CHECKED_BINOP(TYPEA,TYPEB,TYPER,OP)                             \
2227    if (PVM_VAL_##TYPEB (JITTER_TOP_STACK ()) == 0)                           \
2228    {                                                                         \
2229       PVM_RAISE_DFL (PVM_E_DIV_BY_ZERO);                                     \
2230    }                                                                         \
2231    else                                                                      \
2232    {                                                                         \
2233       PVM_BINOP (TYPEA, TYPEB, TYPER, OP);                                   \
2234    }
2235 
2236 /* Same, but for left-shifts, which includes an overflow check on the
2237    bit count.  */
2238 # define PVM_BINOP_SL(TYPEA, TYPEB,TYPER, OP)                                \
2239    {                                                                         \
2240      pvm_val type = pvm_typeof (JITTER_UNDER_TOP_STACK ());                  \
2241      uint64_t size = PVM_VAL_INTEGRAL (PVM_VAL_TYP_I_SIZE (type));           \
2242                                                                              \
2243      if (PVM_VAL_##TYPEB (JITTER_TOP_STACK ()) >= size)                      \
2244      {                                                                       \
2245         PVM_RAISE_DFL (PVM_E_OUT_OF_BOUNDS);                                 \
2246      }                                                                       \
2247      else                                                                    \
2248      {                                                                       \
2249         PVM_BINOP (TYPEA, TYPEB, TYPER, OP);                                 \
2250      }                                                                       \
2251    }
2252 
2253 /* Unsigned exponentiation.  */
2254 
2255 # define PVM_POWOP(TYPE,TYPEC,TYPELC)                                       \
2256   do                                                                        \
2257   {                                                                         \
2258      uint64_t size = PVM_VAL_##TYPE##_SIZE (JITTER_UNDER_TOP_STACK ());     \
2259      TYPEC res                                                              \
2260       = (TYPEC) pk_upow (PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ()),        \
2261                          PVM_VAL_UINT (JITTER_TOP_STACK ()));               \
2262                                                                             \
2263      JITTER_PUSH_STACK (pvm_make_##TYPELC (res, size));                     \
2264   }                                                                         \
2265   while (0)
2266 
2267 /* Signed exponentiation, with overflow check.  */
2268 
2269 # define PVM_POWOP_SIGNED(TYPE,TYPEC,TYPELC)                                \
2270   do                                                                        \
2271   {                                                                         \
2272      int overflow_p;                                                        \
2273      uint32_t i;                                                            \
2274      TYPEC res;                                                             \
2275      uint64_t size = PVM_VAL_##TYPE##_SIZE (JITTER_UNDER_TOP_STACK ());     \
2276      TYPEC a = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                  \
2277      uint32_t b = PVM_VAL_UINT (JITTER_TOP_STACK ());                       \
2278      int64_t res64 = 1L << (64 - size);                                     \
2279                                                                             \
2280      overflow_p = 0;                                                        \
2281      for (i = 0; i < b; ++i)                                                \
2282        {                                                                    \
2283          if (INT_MULTIPLY_OVERFLOW (res64, a))                              \
2284            {                                                                \
2285              PVM_RAISE_DFL (PVM_E_OVERFLOW);                                \
2286              overflow_p = 1;                                                \
2287              break;                                                         \
2288            }                                                                \
2289                                                                             \
2290          res64 *= a;                                                        \
2291         }                                                                   \
2292                                                                             \
2293      if (!overflow_p)                                                       \
2294        {                                                                    \
2295          res = res64 >> (64 - size);                                        \
2296          JITTER_PUSH_STACK (pvm_make_##TYPELC (res, size));                 \
2297        }                                                                    \
2298   }                                                                         \
2299   while (0)
2300 
2301 
2302 /* Conversion instructions.
2303    ( TYPE -- TYPE RTYPE )  */
2304 #define PVM_CONVOP(TYPE, TYPEC, RTYPELC, RTYPEC)                             \
2305    do                                                                        \
2306     {                                                                        \
2307       jitter_uint tsize = JITTER_ARGN0;                                      \
2308       TYPEC val = PVM_VAL_##TYPE (JITTER_TOP_STACK ());                      \
2309       JITTER_PUSH_STACK (pvm_make_##RTYPELC ((RTYPEC) val, tsize));          \
2310     } while (0)
2311 
2312 /* Auxiliary macros used in PVM_PEEK and PVM_POKE below.  */
2313 #define PVM_IOS_ARGS_INT                                                     \
2314   io, offset, 0, bits, endian, nenc, &value
2315 #define PVM_IOS_ARGS_UINT                                                    \
2316   io, offset, 0, bits, endian, &value
2317 #define PVM_IOS_ARGS_WRITE_INT                                               \
2318   io, offset, 0, bits, endian, nenc, value
2319 #define PVM_IOS_ARGS_WRITE_UINT                                              \
2320   io, offset, 0, bits, endian, value
2321 
2322 /* Integral peek instructions.
2323    ( IOS BOFF -- VAL )  */
2324 #define PVM_PEEK(TYPE,IOTYPE,NENC,ENDIAN,BITS,IOARGS)                        \
2325   do                                                                         \
2326    {                                                                         \
2327      int ret;                                                                \
2328      __attribute__((unused)) enum ios_nenc nenc = (NENC);                    \
2329      enum ios_endian endian = (ENDIAN);                                      \
2330      int bits = (BITS);                                                      \
2331      IOTYPE##64_t value;                                                     \
2332      ios io;                                                                 \
2333      ios_off offset;                                                         \
2334                                                                              \
2335      offset = PVM_VAL_ULONG (JITTER_TOP_STACK ());                           \
2336      if (JITTER_UNDER_TOP_STACK () == PVM_NULL)                              \
2337        io = ios_cur ();                                                      \
2338      else                                                                    \
2339        io = ios_search_by_id (PVM_VAL_INT (JITTER_UNDER_TOP_STACK ()));      \
2340                                                                              \
2341      if (io == NULL)                                                         \
2342        PVM_RAISE_DFL (PVM_E_NO_IOS);                                         \
2343                                                                              \
2344      JITTER_DROP_STACK ();                                                   \
2345      if ((ret = ios_read_##IOTYPE (IOARGS)) != IOS_OK)                       \
2346        {                                                                     \
2347          if (ret == IOS_EIOFF)                                               \
2348             PVM_RAISE_DFL (PVM_E_EOF);                                       \
2349          else if (ret == IOS_ENOMEM)                                         \
2350             PVM_RAISE (PVM_E_IO, "out of memory", PVM_E_IO_ESTATUS);         \
2351          else                                                                \
2352             PVM_RAISE_DFL (PVM_E_IO);                                        \
2353          JITTER_TOP_STACK () = PVM_NULL;                                     \
2354        }                                                                     \
2355      else                                                                    \
2356        JITTER_TOP_STACK () = pvm_make_##TYPE (value, bits);                  \
2357    } while (0)
2358 
2359 /* Integral poke instructions.
2360    ( IOS BOFF VAL -- )  */
2361 #define PVM_POKE(TYPE,IOTYPE,NENC,ENDIAN,BITS,IOARGS)                        \
2362   do                                                                         \
2363    {                                                                         \
2364      int ret;                                                                \
2365      __attribute__((unused)) enum ios_nenc nenc = (NENC);                    \
2366      enum ios_endian endian = (ENDIAN);                                      \
2367      int bits = (BITS);                                                      \
2368      IOTYPE##64_t value = PVM_VAL_##TYPE (JITTER_TOP_STACK ());              \
2369      pvm_val offset_val = JITTER_UNDER_TOP_STACK ();                         \
2370      ios io;                                                                 \
2371      ios_off offset;                                                         \
2372                                                                              \
2373      JITTER_DROP_STACK ();                                                   \
2374      JITTER_DROP_STACK ();                                                   \
2375                                                                              \
2376      if (JITTER_TOP_STACK () == PVM_NULL)                                    \
2377        io = ios_cur ();                                                      \
2378      else                                                                    \
2379        io = ios_search_by_id (PVM_VAL_INT (JITTER_TOP_STACK ()));            \
2380                                                                              \
2381      if (io == NULL)                                                         \
2382        PVM_RAISE_DFL (PVM_E_NO_IOS);                                         \
2383      JITTER_DROP_STACK ();                                                   \
2384                                                                              \
2385      offset = PVM_VAL_ULONG (offset_val);                                    \
2386      if ((ret = ios_write_##IOTYPE (IOARGS)) != IOS_OK)                      \
2387        {                                                                     \
2388          if (ret == IOS_EIOFF)                                               \
2389             PVM_RAISE_DFL (PVM_E_EOF);                                       \
2390          else                                                                \
2391             PVM_RAISE_DFL (PVM_E_IO);                                        \
2392        }                                                                     \
2393    } while (0)
2394 
2395 /* Macro to call to a closure.  This is used in the instruction CALL,
2396    and also other instructions required to... call :D The argument
2397    should be a closure (surprise.)  */
2398 
2399 #define PVM_CALL(CLS)                                                        \
2400    do                                                                        \
2401     {                                                                        \
2402        /* Make place for the return address in the return stack.  */         \
2403        /* actual value will be written by the callee. */                     \
2404        JITTER_PUSH_UNSPECIFIED_RETURNSTACK();                                \
2405                                                                              \
2406        /* Save the current environment and use the callee's environment. */     \
2407        JITTER_PUSH_RETURNSTACK ((jitter_uint) (uintptr_t) jitter_state_runtime.env); \
2408        jitter_state_runtime.env = PVM_VAL_CLS_ENV ((CLS));                   \
2409                                                                              \
2410        /* Branch-and-link to the native code, whose first instruction will */ \
2411        /*  be a prolog. */                                                   \
2412        JITTER_BRANCH_AND_LINK (PVM_VAL_CLS_ENTRY_POINT ((CLS)));           \
2413     } while (0)
2414 
2415 /* Macros to implement printi* and printl* instructions.  */
2416 
2417 #define PVM_PRINTI(TYPE,TYPEC,IFORMAT,BASE)                                 \
2418   do                                                                        \
2419   {                                                                         \
2420     TYPEC val = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                 \
2421     char fmt[6];  /* %0NNd */                                               \
2422     uint32_t mask                                                           \
2423         = JITTER_ARGN0 == 32 ? (uint32_t)-1                                 \
2424                              : (((uint32_t)1 << JITTER_ARGN0) - 1);         \
2425                                                                             \
2426     fmt[0] = '%';                                                           \
2427     fmt[1] = '0';                                                           \
2428     if ((BASE) == 10)                                                       \
2429     {                                                                       \
2430       fmt[2] = IFORMAT;                                                     \
2431       fmt[3] = '\0';                                                        \
2432     }                                                                       \
2433     else                                                                    \
2434     {                                                                       \
2435       int prec = 0;                                                         \
2436                                                                             \
2437       if ((BASE) == 256)                                                    \
2438       {                                                                     \
2439         fmt[4] = 'c';                                                       \
2440         prec = 1;                                                           \
2441       }                                                                     \
2442       else if ((BASE) == 16)                                                \
2443       {                                                                     \
2444         fmt[4] = 'x';                                                       \
2445         prec = (JITTER_ARGN0 / 4) + ((JITTER_ARGN0 % 4) != 0);              \
2446       }                                                                     \
2447       else if ((BASE) == 8)                                                 \
2448       {                                                                     \
2449         fmt[4] = 'o';                                                       \
2450         prec = (JITTER_ARGN0 / 3) + ((JITTER_ARGN0 % 3) != 0);              \
2451       }                                                                     \
2452       else if ((BASE) == 2)                                                 \
2453       {                                                                     \
2454         pk_print_binary (pk_puts, val, JITTER_ARGN0, 1);                    \
2455         JITTER_DROP_STACK ();                                               \
2456         JITTER_DROP_STACK ();                                               \
2457         break;                                                              \
2458       }                                                                     \
2459                                                                             \
2460       assert (prec != 0);                                                   \
2461       fmt[2] = '0' + (prec / 10);                                           \
2462       fmt[3] = '0' + prec - (prec / 10 * 10);                               \
2463       fmt[5] = '\0';                                                        \
2464     }                                                                       \
2465                                                                             \
2466     pk_printf (fmt, (BASE) == 10 ? val : val & mask);                       \
2467     JITTER_DROP_STACK ();                                                   \
2468     JITTER_DROP_STACK ();                                                   \
2469   } while (0)
2470 
2471 #define PVM_PRINTL(TYPE,TYPEC,IFORMAT,BASE)                                 \
2472   do                                                                        \
2473   {                                                                         \
2474     TYPEC val = PVM_VAL_##TYPE (JITTER_UNDER_TOP_STACK ());                 \
2475     char fmt[7];  /* %0NNff */                                              \
2476     uint64_t mask                                                           \
2477         = JITTER_ARGN0 == 64 ? (uint64_t)-1                                 \
2478                              : (((uint64_t)1 << JITTER_ARGN0) - 1);         \
2479                                                                             \
2480     fmt[0] = '%';                                                           \
2481     fmt[1] = '0';                                                           \
2482     fmt[4] = 'l';                                                           \
2483     if ((BASE) == 10)                                                       \
2484     {                                                                       \
2485       fmt[2] = IFORMAT;                                                     \
2486       fmt[3] = '\0';                                                        \
2487     }                                                                       \
2488     else                                                                    \
2489     {                                                                       \
2490       int prec = 0;                                                         \
2491                                                                             \
2492       if ((BASE) == 16)                                                     \
2493       {                                                                     \
2494         fmt[5] = 'x';                                                       \
2495         prec = (JITTER_ARGN0 / 4) + ((JITTER_ARGN0 % 4) != 0);              \
2496       }                                                                     \
2497       else if ((BASE) == 8)                                                 \
2498       {                                                                     \
2499         fmt[5] = 'o';                                                       \
2500         prec = (JITTER_ARGN0 / 3) + ((JITTER_ARGN0 % 3) != 0);              \
2501       }                                                                     \
2502       else if ((BASE) == 2)                                                 \
2503       {                                                                     \
2504         pk_print_binary (pk_puts, val, JITTER_ARGN0, 1);                    \
2505         JITTER_DROP_STACK ();                                               \
2506         JITTER_DROP_STACK ();                                               \
2507         break;                                                              \
2508       }                                                                     \
2509                                                                             \
2510       fmt[2] = '0' + (prec / 10);                                           \
2511       fmt[3] = '0' + prec - (prec / 10 * 10);                               \
2512       fmt[6] = '\0';                                                        \
2513     }                                                                       \
2514                                                                             \
2515     pk_printf (fmt, (BASE) == 10 ? val : val & mask);                       \
2516     JITTER_DROP_STACK ();                                                   \
2517     JITTER_DROP_STACK ();                                                   \
2518   } while (0)
2519 
2520 
2521 /* User-specified code, late header part: end */
2522 
2523 
2524 /* Close the multiple-inclusion guard opened in the template. */
2525 #endif // #ifndef PVM_VM_H_
2526