gccint: Constants
1
1 14.7 Constant Expression Types
1 ==============================
1
1 The simplest RTL expressions are those that represent constant values.
1
1 '(const_int I)'
1 This type of expression represents the integer value I. I is
1 customarily accessed with the macro 'INTVAL' as in 'INTVAL (EXP)',
1 which is equivalent to 'XWINT (EXP, 0)'.
1
1 Constants generated for modes with fewer bits than in
1 'HOST_WIDE_INT' must be sign extended to full width (e.g., with
1 'gen_int_mode'). For constants for modes with more bits than in
1 'HOST_WIDE_INT' the implied high order bits of that constant are
1 copies of the top bit. Note however that values are neither
1 inherently signed nor inherently unsigned; where necessary,
1 signedness is determined by the rtl operation instead.
1
1 There is only one expression object for the integer value zero; it
1 is the value of the variable 'const0_rtx'. Likewise, the only
1 expression for integer value one is found in 'const1_rtx', the only
1 expression for integer value two is found in 'const2_rtx', and the
1 only expression for integer value negative one is found in
1 'constm1_rtx'. Any attempt to create an expression of code
1 'const_int' and value zero, one, two or negative one will return
1 'const0_rtx', 'const1_rtx', 'const2_rtx' or 'constm1_rtx' as
1 appropriate.
1
1 Similarly, there is only one object for the integer whose value is
1 'STORE_FLAG_VALUE'. It is found in 'const_true_rtx'. If
1 'STORE_FLAG_VALUE' is one, 'const_true_rtx' and 'const1_rtx' will
1 point to the same object. If 'STORE_FLAG_VALUE' is -1,
1 'const_true_rtx' and 'constm1_rtx' will point to the same object.
1
1 '(const_double:M I0 I1 ...)'
1 This represents either a floating-point constant of mode M or (on
1 older ports that do not define 'TARGET_SUPPORTS_WIDE_INT') an
1 integer constant too large to fit into 'HOST_BITS_PER_WIDE_INT'
1 bits but small enough to fit within twice that number of bits. In
1 the latter case, M will be 'VOIDmode'. For integral values
1 constants for modes with more bits than twice the number in
1 'HOST_WIDE_INT' the implied high order bits of that constant are
1 copies of the top bit of 'CONST_DOUBLE_HIGH'. Note however that
1 integral values are neither inherently signed nor inherently
1 unsigned; where necessary, signedness is determined by the rtl
1 operation instead.
1
1 On more modern ports, 'CONST_DOUBLE' only represents floating point
1 values. New ports define 'TARGET_SUPPORTS_WIDE_INT' to make this
1 designation.
1
1 If M is 'VOIDmode', the bits of the value are stored in I0 and I1.
1 I0 is customarily accessed with the macro 'CONST_DOUBLE_LOW' and I1
1 with 'CONST_DOUBLE_HIGH'.
1
1 If the constant is floating point (regardless of its precision),
1 then the number of integers used to store the value depends on the
1 size of 'REAL_VALUE_TYPE' (⇒Floating Point). The integers
1 represent a floating point number, but not precisely in the target
1 machine's or host machine's floating point format. To convert them
1 to the precise bit pattern used by the target machine, use the
11 macro 'REAL_VALUE_TO_TARGET_DOUBLE' and friends (⇒Data
Output).
1
1 '(const_wide_int:M NUNITS ELT0 ...)'
1 This contains an array of 'HOST_WIDE_INT's that is large enough to
1 hold any constant that can be represented on the target. This form
1 of rtl is only used on targets that define
1 'TARGET_SUPPORTS_WIDE_INT' to be nonzero and then 'CONST_DOUBLE's
1 are only used to hold floating-point values. If the target leaves
1 'TARGET_SUPPORTS_WIDE_INT' defined as 0, 'CONST_WIDE_INT's are not
1 used and 'CONST_DOUBLE's are as they were before.
1
1 The values are stored in a compressed format. The higher-order 0s
1 or -1s are not represented if they are just the logical sign
1 extension of the number that is represented.
1
1 'CONST_WIDE_INT_VEC (CODE)'
1 Returns the entire array of 'HOST_WIDE_INT's that are used to store
1 the value. This macro should be rarely used.
1
1 'CONST_WIDE_INT_NUNITS (CODE)'
1 The number of 'HOST_WIDE_INT's used to represent the number. Note
1 that this generally is smaller than the number of 'HOST_WIDE_INT's
1 implied by the mode size.
1
1 'CONST_WIDE_INT_NUNITS (CODE,I)'
1 Returns the 'i'th element of the array. Element 0 is contains the
1 low order bits of the constant.
1
1 '(const_fixed:M ...)'
1 Represents a fixed-point constant of mode M. The operand is a data
1 structure of type 'struct fixed_value' and is accessed with the
1 macro 'CONST_FIXED_VALUE'. The high part of data is accessed with
1 'CONST_FIXED_VALUE_HIGH'; the low part is accessed with
1 'CONST_FIXED_VALUE_LOW'.
1
1 '(const_poly_int:M [C0 C1 ...])'
1 Represents a 'poly_int'-style polynomial integer with coefficients
1 C0, C1, .... The coefficients are 'wide_int'-based integers rather
1 than rtxes. 'CONST_POLY_INT_COEFFS' gives the values of individual
1 coefficients (which is mostly only useful in low-level routines)
1 and 'const_poly_int_value' gives the full 'poly_int' value.
1
1 '(const_vector:M [X0 X1 ...])'
1 Represents a vector constant. The values in square brackets are
1 elements of the vector, which are always 'const_int',
1 'const_wide_int', 'const_double' or 'const_fixed' expressions.
1
1 Each vector constant V is treated as a specific instance of an
1 arbitrary-length sequence that itself contains
1 'CONST_VECTOR_NPATTERNS (V)' interleaved patterns. Each pattern
1 has the form:
1
1 { BASE0, BASE1, BASE1 + STEP, BASE1 + STEP * 2, ... }
1
1 The first three elements in each pattern are enough to determine
1 the values of the other elements. However, if all STEPs are zero,
1 only the first two elements are needed. If in addition each BASE1
1 is equal to the corresponding BASE0, only the first element in each
1 pattern is needed. The number of determining elements per pattern
1 is given by 'CONST_VECTOR_NELTS_PER_PATTERN (V)'.
1
1 For example, the constant:
1
1 { 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 }
1
1 is interpreted as an interleaving of the sequences:
1
1 { 0, 2, 3, 4, 5, 6, 7, 8 }
1 { 1, 6, 8, 10, 12, 14, 16, 18 }
1
1 where the sequences are represented by the following patterns:
1
1 BASE0 == 0, BASE1 == 2, STEP == 1
1 BASE0 == 1, BASE1 == 6, STEP == 2
1
1 In this case:
1
1 CONST_VECTOR_NPATTERNS (V) == 2
1 CONST_VECTOR_NELTS_PER_PATTERN (V) == 3
1
1 Thus the first 6 elements ('{ 0, 1, 2, 6, 3, 8 }') are enough to
1 determine the whole sequence; we refer to them as the "encoded"
1 elements. They are the only elements present in the square
1 brackets for variable-length 'const_vector's (i.e. for
1 'const_vector's whose mode M has a variable number of elements).
1 However, as a convenience to code that needs to handle both
1 'const_vector's and 'parallel's, all elements are present in the
1 square brackets for fixed-length 'const_vector's; the encoding
1 scheme simply reduces the amount of work involved in processing
1 constants that follow a regular pattern.
1
1 Sometimes this scheme can create two possible encodings of the same
1 vector. For example { 0, 1 } could be seen as two patterns with
1 one element each or one pattern with two elements (BASE0 and
1 BASE1). The canonical encoding is always the one with the fewest
1 patterns or (if both encodings have the same number of petterns)
1 the one with the fewest encoded elements.
1
1 'const_vector_encoding_nelts (V)' gives the total number of encoded
1 elements in V, which is 6 in the example above.
1 'CONST_VECTOR_ENCODED_ELT (V, I)' accesses the value of encoded
1 element I.
1
1 'CONST_VECTOR_DUPLICATE_P (V)' is true if V simply contains
1 repeated instances of 'CONST_VECTOR_NPATTERNS (V)' values. This is
1 a shorthand for testing 'CONST_VECTOR_NELTS_PER_PATTERN (V) == 1'.
1
1 'CONST_VECTOR_STEPPED_P (V)' is true if at least one pattern in V
1 has a nonzero step. This is a shorthand for testing
1 'CONST_VECTOR_NELTS_PER_PATTERN (V) == 3'.
1
1 'CONST_VECTOR_NUNITS (V)' gives the total number of elements in V;
1 it is a shorthand for getting the number of units in 'GET_MODE
1 (V)'.
1
1 The utility function 'const_vector_elt' gives the value of an
1 arbitrary element as an 'rtx'. 'const_vector_int_elt' gives the
1 same value as a 'wide_int'.
1
1 '(const_string STR)'
1 Represents a constant string with value STR. Currently this is
1 used only for insn attributes (⇒Insn Attributes) since
1 constant strings in C are placed in memory.
1
1 '(symbol_ref:MODE SYMBOL)'
1 Represents the value of an assembler label for data. SYMBOL is a
1 string that describes the name of the assembler label. If it
1 starts with a '*', the label is the rest of SYMBOL not including
1 the '*'. Otherwise, the label is SYMBOL, usually prefixed with
1 '_'.
1
1 The 'symbol_ref' contains a mode, which is usually 'Pmode'.
1 Usually that is the only mode for which a symbol is directly valid.
1
1 '(label_ref:MODE LABEL)'
1 Represents the value of an assembler label for code. It contains
1 one operand, an expression, which must be a 'code_label' or a
1 'note' of type 'NOTE_INSN_DELETED_LABEL' that appears in the
1 instruction sequence to identify the place where the label should
1 go.
1
1 The reason for using a distinct expression type for code label
1 references is so that jump optimization can distinguish them.
1
1 The 'label_ref' contains a mode, which is usually 'Pmode'. Usually
1 that is the only mode for which a label is directly valid.
1
1 '(const:M EXP)'
1 Represents a constant that is the result of an assembly-time
1 arithmetic computation. The operand, EXP, contains only
1 'const_int', 'symbol_ref', 'label_ref' or 'unspec' expressions,
1 combined with 'plus' and 'minus'. Any such 'unspec's are
1 target-specific and typically represent some form of relocation
1 operator. M should be a valid address mode.
1
1 '(high:M EXP)'
1 Represents the high-order bits of EXP, usually a 'symbol_ref'. The
1 number of bits is machine-dependent and is normally the number of
1 bits specified in an instruction that initializes the high order
1 bits of a register. It is used with 'lo_sum' to represent the
1 typical two-instruction sequence used in RISC machines to reference
1 a global memory location.
1
1 M should be 'Pmode'.
1
1 The macro 'CONST0_RTX (MODE)' refers to an expression with value 0 in
1 mode MODE. If mode MODE is of mode class 'MODE_INT', it returns
1 'const0_rtx'. If mode MODE is of mode class 'MODE_FLOAT', it returns a
1 'CONST_DOUBLE' expression in mode MODE. Otherwise, it returns a
1 'CONST_VECTOR' expression in mode MODE. Similarly, the macro
1 'CONST1_RTX (MODE)' refers to an expression with value 1 in mode MODE
1 and similarly for 'CONST2_RTX'. The 'CONST1_RTX' and 'CONST2_RTX'
1 macros are undefined for vector modes.
1