Node:C Code Macros, Next:C Code restrictions, Previous:Simple instructions, Up:Simple instructions
Vmgen recognizes the following strings in the C code part of simple instructions:
SET_IP
SUPER_END
SET_IP
.
INST_TAIL;
INST_TAIL;
with code for ending a VM instruction and
dispatching the next VM instruction. Even without a INST_TAIL;
this
happens automatically when control reaches the end of the C code. If
you want to have this in the middle of the C code, you need to use
INST_TAIL;
. A typical example is a conditional VM branch:
if (branch_condition) { SET_IP(target); INST_TAIL; } /* implicit tail follows here */
In this example, INST_TAIL;
is not strictly necessary, because there
is another one implicitly after the if-statement, but using it improves
branch prediction accuracy slightly and allows other optimizations.
SUPER_CONTINUE
SET_IP
in the VM instruction. This enables an optimization that
is not yet implemented in the vmgen-ex code (but in Gforth). The
typical application is in conditional VM branches:
if (branch_condition) { SET_IP(target); INST_TAIL; /* now this INST_TAIL is necessary */ } SUPER_CONTINUE;
Note that Vmgen is not smart about C-level tokenization, comments,
strings, or conditional compilation, so it will interpret even a
commented-out SUPER_END as ending a basic block (or, e.g.,
RESET_IP;
as SET_IP;
). Conversely, Vmgen requires the literal
presence of these strings; Vmgen will not see them if they are hiding in
a C preprocessor macro.