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


9.3.7.8 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 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.

Sometimes you need to load up a code pointer into a register; for this, use load-label.

Instruction: load-label s24:dst l32:offset

Load a label offset words away from the current ip and write it to dst. offset is a signed 32-bit integer.

Finally, Guile supports a number of unboxed data types, with their associate constant loaders.

Instruction: load-f64 s24:dst au32:high-bits au32:low-bits

Load a double-precision floating-point value formed by joining high-bits and low-bits, and write it to dst.

Instruction: load-u64 s24:dst au32:high-bits au32:low-bits

Load an unsigned 64-bit integer formed by joining high-bits and low-bits, and write it to dst.

Instruction: load-s64 s24:dst au32:high-bits au32:low-bits

Load a signed 64-bit integer formed by joining high-bits and low-bits, and write it to dst.

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-set! 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.


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