Next: Regs and Memory, Previous: Machine Modes, Up: RTL
12.7 Constant Expression Types
The simplest RTL expressions are those that represent constant values.
(const_int
i)
- This type of expression represents the integer value i. i
is customarily accessed with the macro
INTVAL
as inINTVAL (
exp)
, which is equivalent toXWINT (
exp, 0)
.Constants generated for modes with fewer bits than
HOST_WIDE_INT
must be sign extended to full width (e.g., withgen_int_mode
).There is only one expression object for the integer value zero; it is the value of the variable
const0_rtx
. Likewise, the only expression for integer value one is found inconst1_rtx
, the only expression for integer value two is found inconst2_rtx
, and the only expression for integer value negative one is found inconstm1_rtx
. Any attempt to create an expression of codeconst_int
and value zero, one, two or negative one will returnconst0_rtx
,const1_rtx
,const2_rtx
orconstm1_rtx
as appropriate.Similarly, there is only one object for the integer whose value is
STORE_FLAG_VALUE
. It is found inconst_true_rtx
. IfSTORE_FLAG_VALUE
is one,const_true_rtx
andconst1_rtx
will point to the same object. IfSTORE_FLAG_VALUE
is −1,const_true_rtx
andconstm1_rtx
will point to the same object. (const_double:
m addr i0 i1...)
- Represents either a floating-point constant of mode m or an
integer constant too large to fit into
HOST_BITS_PER_WIDE_INT
bits but small enough to fit within twice that number of bits (GCC does not provide a mechanism to represent even larger constants). In the latter case, m will beVOIDmode
. (const_vector:
m[
x0 x1...])
- Represents a vector constant. The square brackets stand for the vector
containing the constant elements. x0, x1 and so on are
the
const_int
orconst_double
elements.The number of units in a
const_vector
is obtained with the macroCONST_VECTOR_NUNITS
as inCONST_VECTOR_NUNITS (
v)
.Individual elements in a vector constant are accessed with the macro
CONST_VECTOR_ELT
as inCONST_VECTOR_ELT (
v,
n)
where v is the vector constant and n is the element desired.addr is used to contain the
mem
expression that corresponds to the location in memory that at which the constant can be found. If it has not been allocated a memory location, but is on the chain of allconst_double
expressions in this compilation (maintained using an undisplayed field), addr containsconst0_rtx
. If it is not on the chain, addr containscc0_rtx
. addr is customarily accessed with the macroCONST_DOUBLE_MEM
and the chain field viaCONST_DOUBLE_CHAIN
.If m is
VOIDmode
, the bits of the value are stored in i0 and i1. i0 is customarily accessed with the macroCONST_DOUBLE_LOW
and i1 withCONST_DOUBLE_HIGH
.If the constant is floating point (regardless of its precision), then the number of integers used to store the value depends on the size of
REAL_VALUE_TYPE
(see Floating Point). The integers represent a floating point number, but not precisely in the target machine's or host machine's floating point format. To convert them to the precise bit pattern used by the target machine, use the macroREAL_VALUE_TO_TARGET_DOUBLE
and friends (see Data Output).The macro
CONST0_RTX (
mode)
refers to an expression with value 0 in mode mode. If mode mode is of mode classMODE_INT
, it returnsconst0_rtx
. If mode mode is of mode classMODE_FLOAT
, it returns aCONST_DOUBLE
expression in mode mode. Otherwise, it returns aCONST_VECTOR
expression in mode mode. Similarly, the macroCONST1_RTX (
mode)
refers to an expression with value 1 in mode mode and similarly forCONST2_RTX
. TheCONST1_RTX
andCONST2_RTX
macros are undefined for vector modes. (const_string
str)
- Represents a constant string with value str. Currently this is used only for insn attributes (see Insn Attributes) since constant strings in C are placed in memory.
(symbol_ref:
mode symbol)
- Represents the value of an assembler label for data. symbol is
a string that describes the name of the assembler label. If it starts
with a `*', the label is the rest of symbol not including
the `*'. Otherwise, the label is symbol, usually prefixed
with `_'.
The
symbol_ref
contains a mode, which is usuallyPmode
. Usually that is the only mode for which a symbol is directly valid. (label_ref:
mode label)
- Represents the value of an assembler label for code. It contains one
operand, an expression, which must be a
code_label
or anote
of typeNOTE_INSN_DELETED_LABEL
that appears in the instruction sequence to identify the place where the label should go.The reason for using a distinct expression type for code label references is so that jump optimization can distinguish them.
The
label_ref
contains a mode, which is usuallyPmode
. Usually that is the only mode for which a label is directly valid. (const:
m exp)
- Represents a constant that is the result of an assembly-time
arithmetic computation. The operand, exp, is an expression that
contains only constants (
const_int
,symbol_ref
andlabel_ref
expressions) combined withplus
andminus
. However, not all combinations are valid, since the assembler cannot do arbitrary arithmetic on relocatable symbols.m should be
Pmode
. (high:
m exp)
- Represents the high-order bits of exp, usually a
symbol_ref
. The number of bits is machine-dependent and is normally the number of bits specified in an instruction that initializes the high order bits of a register. It is used withlo_sum
to represent the typical two-instruction sequence used in RISC machines to reference a global memory location.m should be
Pmode
.