Константы
CONST := ['-'] NUMBER # Decimal integer | 's_' FP # Single-precision float | 'd_' FP # Double-precision float | $IDENT # Global symbol
Throughout the IL, constants are specified with a unified syntax and semantics. Constants are immediates, meaning that they can be used directly in instructions; there is no need for a "load constant" instruction.
The representation of integers is two's complement. Floating-point numbers are represented using the single-precision and double-precision formats of the IEEE 754 standard.
Constants specify a sequence of bits and are untyped. They are always parsed as 64-bit blobs. Depending on the context surrounding a constant, only some of its bits are used. For example, in the program below, the two variables defined have the same value since the first operand of the subtraction is a word (32-bit) context.
%x =w sub -1, 0 %y =w sub 4294967295, 0
Because specifying floating-point constants by their bits makes the code less readable, syntactic sugar is provided to express them. Standard scientific notation is prefixed with s_ and d_ for single and double precision numbers respectively. Once again, the following example defines twice the same double-precision constant.
%x =d add d_0, d_-1 %y =d add d_0, -4616189618054758400
Global symbols can also be used directly as constants; they will be resolved and turned into actual numeric constants by the linker.