gccint: Constant expressions

1 
1 11.6.1 Constant expressions
1 ---------------------------
1 
1 The table below begins with constants, moves on to unary expressions,
1 then proceeds to binary expressions, and concludes with various other
1 kinds of expressions:
1 
1 'INTEGER_CST'
1      These nodes represent integer constants.  Note that the type of
1      these constants is obtained with 'TREE_TYPE'; they are not always
1      of type 'int'.  In particular, 'char' constants are represented
1      with 'INTEGER_CST' nodes.  The value of the integer constant 'e' is
1      represented in an array of HOST_WIDE_INT. There are enough elements
1      in the array to represent the value without taking extra elements
1      for redundant 0s or -1.  The number of elements used to represent
1      'e' is available via 'TREE_INT_CST_NUNITS'.  Element 'i' can be
1      extracted by using 'TREE_INT_CST_ELT (e, i)'.  'TREE_INT_CST_LOW'
1      is a shorthand for 'TREE_INT_CST_ELT (e, 0)'.
1 
1      The functions 'tree_fits_shwi_p' and 'tree_fits_uhwi_p' can be used
1      to tell if the value is small enough to fit in a signed
1      HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively.  The value
1      can then be extracted using 'tree_to_shwi' and 'tree_to_uhwi'.
1 
1 'REAL_CST'
1 
1      FIXME: Talk about how to obtain representations of this constant,
1      do comparisons, and so forth.
1 
1 'FIXED_CST'
1 
1      These nodes represent fixed-point constants.  The type of these
1      constants is obtained with 'TREE_TYPE'.  'TREE_FIXED_CST_PTR'
1      points to a 'struct fixed_value'; 'TREE_FIXED_CST' returns the
1      structure itself.  'struct fixed_value' contains 'data' with the
1      size of two 'HOST_BITS_PER_WIDE_INT' and 'mode' as the associated
1      fixed-point machine mode for 'data'.
1 
1 'COMPLEX_CST'
1      These nodes are used to represent complex number constants, that is
1      a '__complex__' whose parts are constant nodes.  The
1      'TREE_REALPART' and 'TREE_IMAGPART' return the real and the
1      imaginary parts respectively.
1 
1 'VECTOR_CST'
1      These nodes are used to represent vector constants.  Each vector
1      constant V is treated as a specific instance of an arbitrary-length
1      sequence that itself contains 'VECTOR_CST_NPATTERNS (V)'
1      interleaved patterns.  Each pattern 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 encoded elements per pattern is
1      given by 'VECTOR_CST_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           VECTOR_CST_NPATTERNS (V) == 2
1           VECTOR_CST_NELTS_PER_PATTERN (V) == 3
1 
1      The vector is therefore encoded using the first 6 elements ('{ 0,
1      1, 2, 6, 3, 8 }'), with the remaining 10 elements being implicit
1      extensions of them.
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      'vector_cst_encoding_nelts (V)' gives the total number of encoded
1      elements in V, which is 6 in the example above.
1      'VECTOR_CST_ENCODED_ELTS (V)' gives a pointer to the elements
1      encoded in V and 'VECTOR_CST_ENCODED_ELT (V, I)' accesses the value
1      of encoded element I.
1 
1      'VECTOR_CST_DUPLICATE_P (V)' is true if V simply contains repeated
1      instances of 'VECTOR_CST_NPATTERNS (V)' values.  This is a
1      shorthand for testing 'VECTOR_CST_NELTS_PER_PATTERN (V) == 1'.
1 
1      'VECTOR_CST_STEPPED_P (V)' is true if at least one pattern in V has
1      a nonzero step.  This is a shorthand for testing
1      'VECTOR_CST_NELTS_PER_PATTERN (V) == 3'.
1 
1      The utility function 'vector_cst_elt' gives the value of an
1      arbitrary index as a 'tree'.  'vector_cst_int_elt' gives the same
1      value as a 'wide_int'.
1 
1 'STRING_CST'
1      These nodes represent string-constants.  The 'TREE_STRING_LENGTH'
1      returns the length of the string, as an 'int'.  The
1      'TREE_STRING_POINTER' is a 'char*' containing the string itself.
1      The string may not be 'NUL'-terminated, and it may contain embedded
1      'NUL' characters.  Therefore, the 'TREE_STRING_LENGTH' includes the
1      trailing 'NUL' if it is present.
1 
1      For wide string constants, the 'TREE_STRING_LENGTH' is the number
1      of bytes in the string, and the 'TREE_STRING_POINTER' points to an
1      array of the bytes of the string, as represented on the target
1      system (that is, as integers in the target endianness).  Wide and
1      non-wide string constants are distinguished only by the 'TREE_TYPE'
1      of the 'STRING_CST'.
1 
1      FIXME: The formats of string constants are not well-defined when
1      the target system bytes are not the same width as host system
1      bytes.
1 
1 'POLY_INT_CST'
1      These nodes represent invariants that depend on some
1      target-specific runtime parameters.  They consist of
1      'NUM_POLY_INT_COEFFS' coefficients, with the first coefficient
1      being the constant term and the others being multipliers that are
1      applied to the runtime parameters.
1 
1      'POLY_INT_CST_ELT (X, I)' references coefficient number I of
1      'POLY_INT_CST' node X.  Each coefficient is an 'INTEGER_CST'.
1