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 u8:dst i16:low-bits

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

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

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

Instruction: make-long-long-immediate u24: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 u24: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 u24:dst s32: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! u24: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 u12:dst u12:src

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

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

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

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

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

Instruction: load-typed-array u8:dst u8:type u8: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]