Guile Lowlevel Intermediate Language (GLIL) is a structured intermediate
language whose expressions more closely approximate Guile’s VM
instruction set. Its expression types are defined in
A unit of code that at run-time will correspond to a compiled
procedure. meta should be an alist of properties, as in
<lambda>. body is an ordered list of GLIL
A prologue for a function with no optional, keyword, or rest arguments. nreq is the number of required arguments. nlocs the total number of local variables, including the arguments. If the procedure was not given exactly nreq arguments, control will jump to else-label, if given, or otherwise signal an error.
A prologue for a function with optional or rest arguments. Like
<glil-std-prelude>, with the addition that nopt is the
number of optional arguments (possibly zero) and rest is an
index of a local variable at which to bind a rest argument, or
#f if there is no rest argument.
A prologue for a function with keyword arguments. Like
<glil-opt-prelude>, with the addition that kw is a list
of keyword arguments, and allow-other-keys? is a flag indicating
whether to allow unknown keys. See
bind-kwargs, for details on the format of kw.
An advisory expression that notes a liveness extent for a set of
variables. vars is a list of
index), where type should be either
<glil-bind> expressions end up being serialized as part of a
program’s metadata and do not form part of a program’s code path.
A multiple-value binding of the values on the stack to vars. If rest is true, the last element of vars will be treated as a rest argument.
In addition to pushing a binding annotation on the stack, like
<glil-bind>, an expression is emitted at compilation time to
make sure that there are enough values available to bind. See the
truncate-values in Procedure Call and Return Instructions, for more information.
Closes the liveness extent of the most recently encountered
<glil-mv-bind> expression. As GLIL
expressions are compiled, a parallel stack of live bindings is
maintained; this expression pops off the top element from that stack.
Bindings are written into the program’s metadata so that debuggers and other tools can determine the set of live local variables at a given offset within a VM program.
Records source information for the preceding expression. loc
should be an association list of containing
filename keys, e.g. as returned by
Pushes “the unspecified value” on the stack.
Pushes a constant value onto the stack. obj must be a number, string, symbol, keyword, boolean, character, uniform array, the empty list, or a pair or vector of constants.
Accesses a lexically bound variable. If the variable is not
local? it is free. All variables may have
bound? as their op. Boxed variables may
also have the ops
which correspond in semantics to the VM instructions
fix-closure. See Stack Layout, for
Accesses a toplevel variable. op may be
Accesses a variable within a specific module. See Tree-IL’s
<module-ref>, for more information.
Creates a new label. label can be any Scheme value, and should be unique.
Branch to a label. label should be a
inst is a branching instruction:
This expression is probably misnamed, as it does not correspond to
<glil-call> invokes the VM instruction named
inst, noting that it is called with nargs stack arguments.
The arguments should be pushed on the stack already. What happens to
the stack afterwards depends on the instruction.
Performs a multiple-value call. ra is a
corresponding to the multiple-value return address for the call. See
the notes on
mv-call in Procedure Call and Return Instructions, for more information.
Push a dynamic prompt into the stack, with a handler at label. escape-only? is a flag that is propagated to the prompt, allowing an abort to avoid capturing a continuation in some cases. See Prompts, for more information.
Users may enter in GLIL at the REPL as well, though there is a bit more bookkeeping to do:
scheme@(guile-user)> ,language glil Happy hacking with Guile Lowlevel Intermediate Language (GLIL)! To switch back, type `,L scheme'. glil@(guile-user)> (program () (std-prelude 0 0 #f) (const 3) (call return 1)) ⇒ 3
Just as in all of Guile’s compilers, an environment is passed to the GLIL-to-object code compiler, and one is returned as well, along with the object code.