Module Fang_vm
Abstractions for a virtual machine.
The intermediate representation for programs assumes a generic ("virtual") machine with these features:
- efficient temporary storage locations
- a way to refer to particular memory locations.
Later, when targeting a particular hardware architecture, these are replaced with architecture-specific registers and assembler labels.
Temporary storage locations
type box
A handle to a temporary storage location (a "box").
These storage locations are like registers, except there are no limits on how many may be allocated (unlike actual hardware architectures in which there are a finite number of registers).
val box : unit -> box
Allocate a new temporary storage location.
A newly-allocated box is distinct from all previously-allocated boxes. Allocating a box is cheap.
module Box : sig ... end
Operations on temporary storage locations.
Labels for memory locations
type label
A label for a location in program memory.
There are two types of labels:
- "global" labels denote named parts of the program (such as subroutiones) where the name itself is meaningful.
- "local" labels are anonymous. They have distinct names, but these names are generated in an unspecified way. Local labels are useful for denoting parts of a program for later reference but where the name itself is irrelevant.
val local_label : unit -> label
Generate a new local label that is guaranteed to be distinct from all previously-generated local labels.
val global_label : string -> label
global_label name
is the global label with the namename
.
module Label : sig ... end
Operations on labels.