Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Instruction Set   [Contents][Index]


9.3.7.7 Constant Instructions

The following instructions load literal data into a program. There are two kinds.

The first set of instructions loads immediate values. These instructions encode the immediate directly into the instruction stream.

Instruction: make-short-immediate s8:dst i16:low-bits

Make an immediate whose low bits are low-bits, and whose top bits are 0.

Instruction: make-long-immediate s24:dst i32:low-bits

Make an immediate whose low bits are low-bits, and whose top bits are 0.

Instruction: make-long-long-immediate s24:dst a32:high-bits b32:low-bits

Make an immediate with high-bits and low-bits.

Non-immediate constant literals are referenced either directly or indirectly. For example, Guile knows at compile-time what the layout of a string will be like, and arranges to embed that object directly in the compiled image. A reference to a string will use make-non-immediate to treat a pointer into the compilation unit as a SCM value directly.

Instruction: make-non-immediate s24:dst n32:offset

Load a pointer to statically allocated memory into dst. The object’s memory is will be found offset 32-bit words away from the current instruction pointer. Whether the object is mutable or immutable depends on where it was allocated by the compiler, and loaded by the loader.

Some objects must be unique across the whole system. This is the case for symbols and keywords. For these objects, Guile arranges to initialize them when the compilation unit is loaded, storing them into a slot in the image. References go indirectly through that slot. static-ref is used in this case.

Instruction: static-ref s24:dst r32:offset

Load a scm value into dst. The scm value will be fetched from memory, offset 32-bit words away from the current instruction pointer. offset is a signed value.

Fields of non-immediates may need to be fixed up at load time, because we do not know in advance at what address they will be loaded. This is the case, for example, for a pair containing a non-immediate in one of its fields. static-ref and static-patch! are used in these situations.

Instruction: static-set! s24:src lo32:offset

Store a scm value into memory, offset 32-bit words away from the current instruction pointer. offset is a signed value.

Instruction: static-patch! x24:_ lo32:dst-offset l32:src-offset

Patch a pointer at dst-offset to point to src-offset. Both offsets are signed 32-bit values, indicating a memory address as a number of 32-bit words away from the current instruction pointer.

Many kinds of literals can be loaded with the above instructions, once the compiler has prepared the statically allocated data. This is the case for vectors, strings, uniform vectors, pairs, and procedures with no free variables. Other kinds of data might need special initializers; those instructions follow.

Instruction: string->number s12:dst s12:src

Parse a string in src to a number, and store in dst.

Instruction: string->symbol s12:dst s12:src

Parse a string in src to a symbol, and store in dst.

Instruction: symbol->keyword s12:dst s12:src

Make a keyword from the symbol in src, and store it in dst.

Instruction: load-typed-array s24:dst x8:_ s24:type x8:_ s24:shape n32:offset u32:len

Load the contiguous typed array located at offset 32-bit words away from the instruction pointer, and store into dst. len is a byte length. offset is signed.


Next: , Previous: , Up: Instruction Set   [Contents][Index]