gccint: Unary and Binary Expressions
1
1 11.6.3 Unary and Binary Expressions
1 -----------------------------------
1
1 'NEGATE_EXPR'
1 These nodes represent unary negation of the single operand, for
1 both integer and floating-point types. The type of negation can be
1 determined by looking at the type of the expression.
1
1 The behavior of this operation on signed arithmetic overflow is
1 controlled by the 'flag_wrapv' and 'flag_trapv' variables.
1
1 'ABS_EXPR'
1 These nodes represent the absolute value of the single operand, for
1 both integer and floating-point types. This is typically used to
1 implement the 'abs', 'labs' and 'llabs' builtins for integer types,
1 and the 'fabs', 'fabsf' and 'fabsl' builtins for floating point
1 types. The type of abs operation can be determined by looking at
1 the type of the expression.
1
1 This node is not used for complex types. To represent the modulus
1 or complex abs of a complex value, use the 'BUILT_IN_CABS',
1 'BUILT_IN_CABSF' or 'BUILT_IN_CABSL' builtins, as used to implement
1 the C99 'cabs', 'cabsf' and 'cabsl' built-in functions.
1
1 'BIT_NOT_EXPR'
1 These nodes represent bitwise complement, and will always have
1 integral type. The only operand is the value to be complemented.
1
1 'TRUTH_NOT_EXPR'
1 These nodes represent logical negation, and will always have
1 integral (or boolean) type. The operand is the value being
1 negated. The type of the operand and that of the result are always
1 of 'BOOLEAN_TYPE' or 'INTEGER_TYPE'.
1
1 'PREDECREMENT_EXPR'
1 'PREINCREMENT_EXPR'
1 'POSTDECREMENT_EXPR'
1 'POSTINCREMENT_EXPR'
1 These nodes represent increment and decrement expressions. The
1 value of the single operand is computed, and the operand
1 incremented or decremented. In the case of 'PREDECREMENT_EXPR' and
1 'PREINCREMENT_EXPR', the value of the expression is the value
1 resulting after the increment or decrement; in the case of
1 'POSTDECREMENT_EXPR' and 'POSTINCREMENT_EXPR' is the value before
1 the increment or decrement occurs. The type of the operand, like
1 that of the result, will be either integral, boolean, or
1 floating-point.
1
1 'FIX_TRUNC_EXPR'
1 These nodes represent conversion of a floating-point value to an
1 integer. The single operand will have a floating-point type, while
1 the complete expression will have an integral (or boolean) type.
1 The operand is rounded towards zero.
1
1 'FLOAT_EXPR'
1 These nodes represent conversion of an integral (or boolean) value
1 to a floating-point value. The single operand will have integral
1 type, while the complete expression will have a floating-point
1 type.
1
1 FIXME: How is the operand supposed to be rounded? Is this
1 dependent on '-mieee'?
1
1 'COMPLEX_EXPR'
1 These nodes are used to represent complex numbers constructed from
1 two expressions of the same (integer or real) type. The first
1 operand is the real part and the second operand is the imaginary
1 part.
1
1 'CONJ_EXPR'
1 These nodes represent the conjugate of their operand.
1
1 'REALPART_EXPR'
1 'IMAGPART_EXPR'
1 These nodes represent respectively the real and the imaginary parts
1 of complex numbers (their sole argument).
1
1 'NON_LVALUE_EXPR'
1 These nodes indicate that their one and only operand is not an
1 lvalue. A back end can treat these identically to the single
1 operand.
1
1 'NOP_EXPR'
1 These nodes are used to represent conversions that do not require
1 any code-generation. For example, conversion of a 'char*' to an
1 'int*' does not require any code be generated; such a conversion is
1 represented by a 'NOP_EXPR'. The single operand is the expression
1 to be converted. The conversion from a pointer to a reference is
1 also represented with a 'NOP_EXPR'.
1
1 'CONVERT_EXPR'
1 These nodes are similar to 'NOP_EXPR's, but are used in those
1 situations where code may need to be generated. For example, if an
1 'int*' is converted to an 'int' code may need to be generated on
1 some platforms. These nodes are never used for C++-specific
1 conversions, like conversions between pointers to different classes
1 in an inheritance hierarchy. Any adjustments that need to be made
1 in such cases are always indicated explicitly. Similarly, a
1 user-defined conversion is never represented by a 'CONVERT_EXPR';
1 instead, the function calls are made explicit.
1
1 'FIXED_CONVERT_EXPR'
1 These nodes are used to represent conversions that involve
1 fixed-point values. For example, from a fixed-point value to
1 another fixed-point value, from an integer to a fixed-point value,
1 from a fixed-point value to an integer, from a floating-point value
1 to a fixed-point value, or from a fixed-point value to a
1 floating-point value.
1
1 'LSHIFT_EXPR'
1 'RSHIFT_EXPR'
1 These nodes represent left and right shifts, respectively. The
1 first operand is the value to shift; it will always be of integral
1 type. The second operand is an expression for the number of bits
1 by which to shift. Right shift should be treated as arithmetic,
1 i.e., the high-order bits should be zero-filled when the expression
1 has unsigned type and filled with the sign bit when the expression
1 has signed type. Note that the result is undefined if the second
1 operand is larger than or equal to the first operand's type size.
1 Unlike most nodes, these can have a vector as first operand and a
1 scalar as second operand.
1
1 'BIT_IOR_EXPR'
1 'BIT_XOR_EXPR'
1 'BIT_AND_EXPR'
1 These nodes represent bitwise inclusive or, bitwise exclusive or,
1 and bitwise and, respectively. Both operands will always have
1 integral type.
1
1 'TRUTH_ANDIF_EXPR'
1 'TRUTH_ORIF_EXPR'
1 These nodes represent logical "and" and logical "or", respectively.
1 These operators are not strict; i.e., the second operand is
1 evaluated only if the value of the expression is not determined by
1 evaluation of the first operand. The type of the operands and that
1 of the result are always of 'BOOLEAN_TYPE' or 'INTEGER_TYPE'.
1
1 'TRUTH_AND_EXPR'
1 'TRUTH_OR_EXPR'
1 'TRUTH_XOR_EXPR'
1 These nodes represent logical and, logical or, and logical
1 exclusive or. They are strict; both arguments are always
1 evaluated. There are no corresponding operators in C or C++, but
1 the front end will sometimes generate these expressions anyhow, if
1 it can tell that strictness does not matter. The type of the
1 operands and that of the result are always of 'BOOLEAN_TYPE' or
1 'INTEGER_TYPE'.
1
1 'POINTER_PLUS_EXPR'
1 This node represents pointer arithmetic. The first operand is
1 always a pointer/reference type. The second operand is always an
1 unsigned integer type compatible with sizetype. This and
1 POINTER_DIFF_EXPR are the only binary arithmetic operators that can
1 operate on pointer types.
1
1 'POINTER_DIFF_EXPR'
1 This node represents pointer subtraction. The two operands always
1 have pointer/reference type. It returns a signed integer of the
1 same precision as the pointers. The behavior is undefined if the
1 difference of the two pointers, seen as infinite precision
1 non-negative integers, does not fit in the result type. The result
1 does not depend on the pointer type, it is not divided by the size
1 of the pointed-to type.
1
1 'PLUS_EXPR'
1 'MINUS_EXPR'
1 'MULT_EXPR'
1 These nodes represent various binary arithmetic operations.
1 Respectively, these operations are addition, subtraction (of the
1 second operand from the first) and multiplication. Their operands
1 may have either integral or floating type, but there will never be
1 case in which one operand is of floating type and the other is of
1 integral type.
1
1 The behavior of these operations on signed arithmetic overflow is
1 controlled by the 'flag_wrapv' and 'flag_trapv' variables.
1
1 'MULT_HIGHPART_EXPR'
1 This node represents the "high-part" of a widening multiplication.
1 For an integral type with B bits of precision, the result is the
1 most significant B bits of the full 2B product.
1
1 'RDIV_EXPR'
1 This node represents a floating point division operation.
1
1 'TRUNC_DIV_EXPR'
1 'FLOOR_DIV_EXPR'
1 'CEIL_DIV_EXPR'
1 'ROUND_DIV_EXPR'
1 These nodes represent integer division operations that return an
1 integer result. 'TRUNC_DIV_EXPR' rounds towards zero,
1 'FLOOR_DIV_EXPR' rounds towards negative infinity, 'CEIL_DIV_EXPR'
1 rounds towards positive infinity and 'ROUND_DIV_EXPR' rounds to the
1 closest integer. Integer division in C and C++ is truncating, i.e.
1 'TRUNC_DIV_EXPR'.
1
1 The behavior of these operations on signed arithmetic overflow,
1 when dividing the minimum signed integer by minus one, is
1 controlled by the 'flag_wrapv' and 'flag_trapv' variables.
1
1 'TRUNC_MOD_EXPR'
1 'FLOOR_MOD_EXPR'
1 'CEIL_MOD_EXPR'
1 'ROUND_MOD_EXPR'
1 These nodes represent the integer remainder or modulus operation.
1 The integer modulus of two operands 'a' and 'b' is defined as 'a -
1 (a/b)*b' where the division calculated using the corresponding
1 division operator. Hence for 'TRUNC_MOD_EXPR' this definition
1 assumes division using truncation towards zero, i.e.
1 'TRUNC_DIV_EXPR'. Integer remainder in C and C++ uses truncating
1 division, i.e. 'TRUNC_MOD_EXPR'.
1
1 'EXACT_DIV_EXPR'
1 The 'EXACT_DIV_EXPR' code is used to represent integer divisions
1 where the numerator is known to be an exact multiple of the
1 denominator. This allows the backend to choose between the faster
1 of 'TRUNC_DIV_EXPR', 'CEIL_DIV_EXPR' and 'FLOOR_DIV_EXPR' for the
1 current target.
1
1 'LT_EXPR'
1 'LE_EXPR'
1 'GT_EXPR'
1 'GE_EXPR'
1 'EQ_EXPR'
1 'NE_EXPR'
1 These nodes represent the less than, less than or equal to, greater
1 than, greater than or equal to, equal, and not equal comparison
1 operators. The first and second operands will either be both of
1 integral type, both of floating type or both of vector type. The
1 result type of these expressions will always be of integral,
1 boolean or signed integral vector type. These operations return
1 the result type's zero value for false, the result type's one value
1 for true, and a vector whose elements are zero (false) or minus one
1 (true) for vectors.
1
1 For floating point comparisons, if we honor IEEE NaNs and either
1 operand is NaN, then 'NE_EXPR' always returns true and the
1 remaining operators always return false. On some targets,
1 comparisons against an IEEE NaN, other than equality and
1 inequality, may generate a floating point exception.
1
1 'ORDERED_EXPR'
1 'UNORDERED_EXPR'
1 These nodes represent non-trapping ordered and unordered comparison
1 operators. These operations take two floating point operands and
1 determine whether they are ordered or unordered relative to each
1 other. If either operand is an IEEE NaN, their comparison is
1 defined to be unordered, otherwise the comparison is defined to be
1 ordered. The result type of these expressions will always be of
1 integral or boolean type. These operations return the result
1 type's zero value for false, and the result type's one value for
1 true.
1
1 'UNLT_EXPR'
1 'UNLE_EXPR'
1 'UNGT_EXPR'
1 'UNGE_EXPR'
1 'UNEQ_EXPR'
1 'LTGT_EXPR'
1 These nodes represent the unordered comparison operators. These
1 operations take two floating point operands and determine whether
1 the operands are unordered or are less than, less than or equal to,
1 greater than, greater than or equal to, or equal respectively. For
1 example, 'UNLT_EXPR' returns true if either operand is an IEEE NaN
1 or the first operand is less than the second. With the possible
1 exception of 'LTGT_EXPR', all of these operations are guaranteed
1 not to generate a floating point exception. The result type of
1 these expressions will always be of integral or boolean type.
1 These operations return the result type's zero value for false, and
1 the result type's one value for true.
1
1 'MODIFY_EXPR'
1 These nodes represent assignment. The left-hand side is the first
1 operand; the right-hand side is the second operand. The left-hand
1 side will be a 'VAR_DECL', 'INDIRECT_REF', 'COMPONENT_REF', or
1 other lvalue.
1
1 These nodes are used to represent not only assignment with '=' but
1 also compound assignments (like '+='), by reduction to '='
1 assignment. In other words, the representation for 'i += 3' looks
1 just like that for 'i = i + 3'.
1
1 'INIT_EXPR'
1 These nodes are just like 'MODIFY_EXPR', but are used only when a
1 variable is initialized, rather than assigned to subsequently.
1 This means that we can assume that the target of the initialization
1 is not used in computing its own value; any reference to the lhs in
1 computing the rhs is undefined.
1
1 'COMPOUND_EXPR'
1 These nodes represent comma-expressions. The first operand is an
1 expression whose value is computed and thrown away prior to the
1 evaluation of the second operand. The value of the entire
1 expression is the value of the second operand.
1
1 'COND_EXPR'
1 These nodes represent '?:' expressions. The first operand is of
1 boolean or integral type. If it evaluates to a nonzero value, the
1 second operand should be evaluated, and returned as the value of
1 the expression. Otherwise, the third operand is evaluated, and
1 returned as the value of the expression.
1
1 The second operand must have the same type as the entire
1 expression, unless it unconditionally throws an exception or calls
1 a noreturn function, in which case it should have void type. The
1 same constraints apply to the third operand. This allows array
1 bounds checks to be represented conveniently as '(i >= 0 && i < 10)
1 ? i : abort()'.
1
1 As a GNU extension, the C language front-ends allow the second
1 operand of the '?:' operator may be omitted in the source. For
1 example, 'x ? : 3' is equivalent to 'x ? x : 3', assuming that 'x'
1 is an expression without side effects. In the tree representation,
1 however, the second operand is always present, possibly protected
1 by 'SAVE_EXPR' if the first argument does cause side effects.
1
1 'CALL_EXPR'
1 These nodes are used to represent calls to functions, including
1 non-static member functions. 'CALL_EXPR's are implemented as
1 expression nodes with a variable number of operands. Rather than
1 using 'TREE_OPERAND' to extract them, it is preferable to use the
1 specialized accessor macros and functions that operate specifically
1 on 'CALL_EXPR' nodes.
1
1 'CALL_EXPR_FN' returns a pointer to the function to call; it is
1 always an expression whose type is a 'POINTER_TYPE'.
1
1 The number of arguments to the call is returned by
1 'call_expr_nargs', while the arguments themselves can be accessed
1 with the 'CALL_EXPR_ARG' macro. The arguments are zero-indexed and
1 numbered left-to-right. You can iterate over the arguments using
1 'FOR_EACH_CALL_EXPR_ARG', as in:
1
1 tree call, arg;
1 call_expr_arg_iterator iter;
1 FOR_EACH_CALL_EXPR_ARG (arg, iter, call)
1 /* arg is bound to successive arguments of call. */
1 ...;
1
1 For non-static member functions, there will be an operand
1 corresponding to the 'this' pointer. There will always be
1 expressions corresponding to all of the arguments, even if the
1 function is declared with default arguments and some arguments are
1 not explicitly provided at the call sites.
1
1 'CALL_EXPR's also have a 'CALL_EXPR_STATIC_CHAIN' operand that is
1 used to implement nested functions. This operand is otherwise
1 null.
1
1 'CLEANUP_POINT_EXPR'
1 These nodes represent full-expressions. The single operand is an
1 expression to evaluate. Any destructor calls engendered by the
1 creation of temporaries during the evaluation of that expression
1 should be performed immediately after the expression is evaluated.
1
1 'CONSTRUCTOR'
1 These nodes represent the brace-enclosed initializers for a
1 structure or an array. They contain a sequence of component values
1 made out of a vector of constructor_elt, which is a ('INDEX',
1 'VALUE') pair.
1
1 If the 'TREE_TYPE' of the 'CONSTRUCTOR' is a 'RECORD_TYPE',
1 'UNION_TYPE' or 'QUAL_UNION_TYPE' then the 'INDEX' of each node in
1 the sequence will be a 'FIELD_DECL' and the 'VALUE' will be the
1 expression used to initialize that field.
1
1 If the 'TREE_TYPE' of the 'CONSTRUCTOR' is an 'ARRAY_TYPE', then
1 the 'INDEX' of each node in the sequence will be an 'INTEGER_CST'
1 or a 'RANGE_EXPR' of two 'INTEGER_CST's. A single 'INTEGER_CST'
1 indicates which element of the array is being assigned to. A
1 'RANGE_EXPR' indicates an inclusive range of elements to
1 initialize. In both cases the 'VALUE' is the corresponding
1 initializer. It is re-evaluated for each element of a
1 'RANGE_EXPR'. If the 'INDEX' is 'NULL_TREE', then the initializer
1 is for the next available array element.
1
1 In the front end, you should not depend on the fields appearing in
1 any particular order. However, in the middle end, fields must
1 appear in declaration order. You should not assume that all fields
1 will be represented. Unrepresented fields will be cleared
1 (zeroed), unless the CONSTRUCTOR_NO_CLEARING flag is set, in which
1 case their value becomes undefined.
1
1 'COMPOUND_LITERAL_EXPR'
1 These nodes represent ISO C99 compound literals. The
1 'COMPOUND_LITERAL_EXPR_DECL_EXPR' is a 'DECL_EXPR' containing an
1 anonymous 'VAR_DECL' for the unnamed object represented by the
1 compound literal; the 'DECL_INITIAL' of that 'VAR_DECL' is a
1 'CONSTRUCTOR' representing the brace-enclosed list of initializers
1 in the compound literal. That anonymous 'VAR_DECL' can also be
1 accessed directly by the 'COMPOUND_LITERAL_EXPR_DECL' macro.
1
1 'SAVE_EXPR'
1
1 A 'SAVE_EXPR' represents an expression (possibly involving side
1 effects) that is used more than once. The side effects should
1 occur only the first time the expression is evaluated. Subsequent
1 uses should just reuse the computed value. The first operand to
1 the 'SAVE_EXPR' is the expression to evaluate. The side effects
1 should be executed where the 'SAVE_EXPR' is first encountered in a
1 depth-first preorder traversal of the expression tree.
1
1 'TARGET_EXPR'
1 A 'TARGET_EXPR' represents a temporary object. The first operand
1 is a 'VAR_DECL' for the temporary variable. The second operand is
1 the initializer for the temporary. The initializer is evaluated
1 and, if non-void, copied (bitwise) into the temporary. If the
1 initializer is void, that means that it will perform the
1 initialization itself.
1
1 Often, a 'TARGET_EXPR' occurs on the right-hand side of an
1 assignment, or as the second operand to a comma-expression which is
1 itself the right-hand side of an assignment, etc. In this case, we
1 say that the 'TARGET_EXPR' is "normal"; otherwise, we say it is
1 "orphaned". For a normal 'TARGET_EXPR' the temporary variable
1 should be treated as an alias for the left-hand side of the
1 assignment, rather than as a new temporary variable.
1
1 The third operand to the 'TARGET_EXPR', if present, is a
1 cleanup-expression (i.e., destructor call) for the temporary. If
1 this expression is orphaned, then this expression must be executed
1 when the statement containing this expression is complete. These
1 cleanups must always be executed in the order opposite to that in
1 which they were encountered. Note that if a temporary is created
1 on one branch of a conditional operator (i.e., in the second or
1 third operand to a 'COND_EXPR'), the cleanup must be run only if
1 that branch is actually executed.
1
1 'VA_ARG_EXPR'
1 This node is used to implement support for the C/C++ variable
1 argument-list mechanism. It represents expressions like 'va_arg
1 (ap, type)'. Its 'TREE_TYPE' yields the tree representation for
1 'type' and its sole argument yields the representation for 'ap'.
1
1 'ANNOTATE_EXPR'
1 This node is used to attach markers to an expression. The first
1 operand is the annotated expression, the second is an 'INTEGER_CST'
1 with a value from 'enum annot_expr_kind', the third is an
1 'INTEGER_CST'.
1