Next: Customizations, Previous: GNU lightning examples, Up: Top
GNU lightning uses the special _jit
identifier. To be able
to be able to use multiple jit generation states at the same
time, it is required to used code similar to:
struct jit_state lightning; #define lightning _jit
This will cause the symbol defined to _jit
to be passed as
the first argument to the underlying GNU lightning implementation,
that is usually a function with an _
(underscode) prefix
and with an argument named _jit
, in the pattern:
static void _jit_mnemonic(jit_state_t *, jit_gpr_t, jit_gpr_t); #define jit_mnemonic(u, v) _jit_mnemonic(_jit, u, v);
The reason for this is to use the same syntax as the initial lightning implementation and to avoid needing the user to keep adding an extra argument to every call, as multiple jit states generating code in paralell should be very uncommon.
As mentioned earlier in this chapter, all GNU lightning back-ends are guaranteed to have at least six general-purpose integer registers and six floating-point registers, but many back-ends will have more.
To access the entire register files, you can use the
JIT_R
, JIT_V
and JIT_F
macros. They
accept a parameter that identifies the register number, which
must be strictly less than JIT_R_NUM
, JIT_V_NUM
and JIT_F_NUM
respectively; the number need not be
constant. Of course, expressions like JIT_R0
and
JIT_R(0)
denote the same register, and likewise for
integer callee-saved, or floating-point, registers.