Previous: Attributes, Up: Trees
9.8 Expressions
The internal representation for expressions is for the most part quite straightforward. However, there are a few facts that one must bear in mind. In particular, the expression “tree” is actually a directed acyclic graph. (For example there may be many references to the integer constant zero throughout the source program; many of these will be represented by the same expression node.) You should not rely on certain kinds of node being shared, nor should rely on certain kinds of nodes being unshared.
The following macros can be used with all expression nodes:
TREE_TYPE- Returns the type of the expression. This value may not be precisely the same type that would be given the expression in the original program.
In what follows, some nodes that one might expect to always have type
bool are documented to have either integral or boolean type. At
some point in the future, the C front end may also make use of this same
intermediate representation, and at this point these nodes will
certainly have integral type. The previous sentence is not meant to
imply that the C++ front end does not or will not give these nodes
integral type.
Below, we list the various kinds of expression nodes. Except where
noted otherwise, the operands to an expression are accessed using the
TREE_OPERAND macro. For example, to access the first operand to
a binary plus expression expr, use:
TREE_OPERAND (expr, 0)
As this example indicates, the operands are zero-indexed.
All the expressions starting with OMP_ represent directives and
clauses used by the OpenMP API http://www.openmp.org/.
The table below begins with constants, moves on to unary expressions, then proceeds to binary expressions, and concludes with various other kinds of expressions:
INTEGER_CST- These nodes represent integer constants. Note that the type of these
constants is obtained with
TREE_TYPE; they are not always of typeint. In particular,charconstants are represented withINTEGER_CSTnodes. The value of the integer constanteis given by((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT) + TREE_INST_CST_LOW (e))HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms. Both
TREE_INT_CST_HIGHandTREE_INT_CST_LOWreturn aHOST_WIDE_INT. The value of anINTEGER_CSTis interpreted as a signed or unsigned quantity depending on the type of the constant. In general, the expression given above will overflow, so it should not be used to calculate the value of the constant.The variable
integer_zero_nodeis an integer constant with value zero. Similarly,integer_one_nodeis an integer constant with value one. Thesize_zero_nodeandsize_one_nodevariables are analogous, but have typesize_trather thanint.The function
tree_int_cst_ltis a predicate which holds if its first argument is less than its second. Both constants are assumed to have the same signedness (i.e., either both should be signed or both should be unsigned.) The full width of the constant is used when doing the comparison; the usual rules about promotions and conversions are ignored. Similarly,tree_int_cst_equalholds if the two constants are equal. Thetree_int_cst_sgnfunction returns the sign of a constant. The value is1,0, or-1according on whether the constant is greater than, equal to, or less than zero. Again, the signedness of the constant's type is taken into account; an unsigned constant is never less than zero, no matter what its bit-pattern. REAL_CST-
FIXME: Talk about how to obtain representations of this constant, do
comparisons, and so forth.
COMPLEX_CST- These nodes are used to represent complex number constants, that is a
__complex__whose parts are constant nodes. TheTREE_REALPARTandTREE_IMAGPARTreturn the real and the imaginary parts respectively. VECTOR_CST- These nodes are used to represent vector constants, whose parts are
constant nodes. Each individual constant node is either an integer or a
double constant node. The first operand is a
TREE_LISTof the constant nodes and is accessed throughTREE_VECTOR_CST_ELTS. STRING_CST- These nodes represent string-constants. The
TREE_STRING_LENGTHreturns the length of the string, as anint. TheTREE_STRING_POINTERis achar*containing the string itself. The string may not beNUL-terminated, and it may contain embeddedNULcharacters. Therefore, theTREE_STRING_LENGTHincludes the trailingNULif it is present.For wide string constants, the
TREE_STRING_LENGTHis the number of bytes in the string, and theTREE_STRING_POINTERpoints to an array of the bytes of the string, as represented on the target system (that is, as integers in the target endianness). Wide and non-wide string constants are distinguished only by theTREE_TYPEof theSTRING_CST.FIXME: The formats of string constants are not well-defined when the target system bytes are not the same width as host system bytes.
PTRMEM_CST- These nodes are used to represent pointer-to-member constants. The
PTRMEM_CST_CLASSis the class type (either aRECORD_TYPEorUNION_TYPEwithin which the pointer points), and thePTRMEM_CST_MEMBERis the declaration for the pointed to object. Note that theDECL_CONTEXTfor thePTRMEM_CST_MEMBERis in general different from thePTRMEM_CST_CLASS. For example, given:struct B { int i; }; struct D : public B {}; int D::*dp = &D::i;The
PTRMEM_CST_CLASSfor&D::iisD, even though theDECL_CONTEXTfor thePTRMEM_CST_MEMBERisB, sinceB::iis a member ofB, notD. VAR_DECL-
These nodes represent variables, including static data members. For
more information, see Declarations.
NEGATE_EXPR- These nodes represent unary negation of the single operand, for both
integer and floating-point types. The type of negation can be
determined by looking at the type of the expression.
The behavior of this operation on signed arithmetic overflow is controlled by the
flag_wrapvandflag_trapvvariables. ABS_EXPR- These nodes represent the absolute value of the single operand, for
both integer and floating-point types. This is typically used to
implement the
abs,labsandllabsbuiltins for integer types, and thefabs,fabsfandfabslbuiltins for floating point types. The type of abs operation can be determined by looking at the type of the expression.This node is not used for complex types. To represent the modulus or complex abs of a complex value, use the
BUILT_IN_CABS,BUILT_IN_CABSForBUILT_IN_CABSLbuiltins, as used to implement the C99cabs,cabsfandcabslbuilt-in functions. BIT_NOT_EXPR- These nodes represent bitwise complement, and will always have integral
type. The only operand is the value to be complemented.
TRUTH_NOT_EXPR- These nodes represent logical negation, and will always have integral
(or boolean) type. The operand is the value being negated. The type
of the operand and that of the result are always of
BOOLEAN_TYPEorINTEGER_TYPE. PREDECREMENT_EXPRPREINCREMENT_EXPRPOSTDECREMENT_EXPRPOSTINCREMENT_EXPR- These nodes represent increment and decrement expressions. The value of
the single operand is computed, and the operand incremented or
decremented. In the case of
PREDECREMENT_EXPRandPREINCREMENT_EXPR, the value of the expression is the value resulting after the increment or decrement; in the case ofPOSTDECREMENT_EXPRandPOSTINCREMENT_EXPRis the value before the increment or decrement occurs. The type of the operand, like that of the result, will be either integral, boolean, or floating-point. ADDR_EXPR- These nodes are used to represent the address of an object. (These
expressions will always have pointer or reference type.) The operand may
be another expression, or it may be a declaration.
As an extension, GCC allows users to take the address of a label. In this case, the operand of the
ADDR_EXPRwill be aLABEL_DECL. The type of such an expression isvoid*.If the object addressed is not an lvalue, a temporary is created, and the address of the temporary is used.
INDIRECT_REF- These nodes are used to represent the object pointed to by a pointer.
The operand is the pointer being dereferenced; it will always have
pointer or reference type.
FIX_TRUNC_EXPR- These nodes represent conversion of a floating-point value to an
integer. The single operand will have a floating-point type, while
the complete expression will have an integral (or boolean) type. The
operand is rounded towards zero.
FLOAT_EXPR- These nodes represent conversion of an integral (or boolean) value to a
floating-point value. The single operand will have integral type, while
the complete expression will have a floating-point type.
FIXME: How is the operand supposed to be rounded? Is this dependent on -mieee?
COMPLEX_EXPR- These nodes are used to represent complex numbers constructed from two
expressions of the same (integer or real) type. The first operand is the
real part and the second operand is the imaginary part.
CONJ_EXPR- These nodes represent the conjugate of their operand.
REALPART_EXPRIMAGPART_EXPR- These nodes represent respectively the real and the imaginary parts
of complex numbers (their sole argument).
NON_LVALUE_EXPR- These nodes indicate that their one and only operand is not an lvalue.
A back end can treat these identically to the single operand.
NOP_EXPR- These nodes are used to represent conversions that do not require any
code-generation. For example, conversion of a
char*to anint*does not require any code be generated; such a conversion is represented by aNOP_EXPR. The single operand is the expression to be converted. The conversion from a pointer to a reference is also represented with aNOP_EXPR. CONVERT_EXPR- These nodes are similar to
NOP_EXPRs, but are used in those situations where code may need to be generated. For example, if anint*is converted to anintcode may need to be generated on some platforms. These nodes are never used for C++-specific conversions, like conversions between pointers to different classes in an inheritance hierarchy. Any adjustments that need to be made in such cases are always indicated explicitly. Similarly, a user-defined conversion is never represented by aCONVERT_EXPR; instead, the function calls are made explicit. THROW_EXPR- These nodes represent
throwexpressions. The single operand is an expression for the code that should be executed to throw the exception. However, there is one implicit action not represented in that expression; namely the call to__throw. This function takes no arguments. Ifsetjmp/longjmpexceptions are used, the function__sjthrowis called instead. The normal GCC back end uses the functionemit_throwto generate this code; you can examine this function to see what needs to be done. LSHIFT_EXPRRSHIFT_EXPR- These nodes represent left and right shifts, respectively. The first
operand is the value to shift; it will always be of integral type. The
second operand is an expression for the number of bits by which to
shift. Right shift should be treated as arithmetic, i.e., the
high-order bits should be zero-filled when the expression has unsigned
type and filled with the sign bit when the expression has signed type.
Note that the result is undefined if the second operand is larger
than or equal to the first operand's type size.
BIT_IOR_EXPRBIT_XOR_EXPRBIT_AND_EXPR- These nodes represent bitwise inclusive or, bitwise exclusive or, and
bitwise and, respectively. Both operands will always have integral
type.
TRUTH_ANDIF_EXPRTRUTH_ORIF_EXPR- These nodes represent logical and and logical or, respectively. These
operators are not strict; i.e., the second operand is evaluated only if
the value of the expression is not determined by evaluation of the first
operand. The type of the operands and that of the result are always of
BOOLEAN_TYPEorINTEGER_TYPE. TRUTH_AND_EXPRTRUTH_OR_EXPRTRUTH_XOR_EXPR- These nodes represent logical and, logical or, and logical exclusive or.
They are strict; both arguments are always evaluated. There are no
corresponding operators in C or C++, but the front end will sometimes
generate these expressions anyhow, if it can tell that strictness does
not matter. The type of the operands and that of the result are
always of
BOOLEAN_TYPEorINTEGER_TYPE. PLUS_EXPRMINUS_EXPRMULT_EXPR- These nodes represent various binary arithmetic operations.
Respectively, these operations are addition, subtraction (of the second
operand from the first) and multiplication. Their operands may have
either integral or floating type, but there will never be case in which
one operand is of floating type and the other is of integral type.
The behavior of these operations on signed arithmetic overflow is controlled by the
flag_wrapvandflag_trapvvariables. RDIV_EXPR- This node represents a floating point division operation.
TRUNC_DIV_EXPRFLOOR_DIV_EXPRCEIL_DIV_EXPRROUND_DIV_EXPR- These nodes represent integer division operations that return an integer
result.
TRUNC_DIV_EXPRrounds towards zero,FLOOR_DIV_EXPRrounds towards negative infinity,CEIL_DIV_EXPRrounds towards positive infinity andROUND_DIV_EXPRrounds to the closest integer. Integer division in C and C++ is truncating, i.e.TRUNC_DIV_EXPR.The behavior of these operations on signed arithmetic overflow, when dividing the minimum signed integer by minus one, is controlled by the
flag_wrapvandflag_trapvvariables. TRUNC_MOD_EXPRFLOOR_MOD_EXPRCEIL_MOD_EXPRROUND_MOD_EXPR- These nodes represent the integer remainder or modulus operation.
The integer modulus of two operands
aandbis defined asa - (a/b)*bwhere the division calculated using the corresponding division operator. Hence forTRUNC_MOD_EXPRthis definition assumes division using truncation towards zero, i.e.TRUNC_DIV_EXPR. Integer remainder in C and C++ uses truncating division, i.e.TRUNC_MOD_EXPR. EXACT_DIV_EXPR- The
EXACT_DIV_EXPRcode is used to represent integer divisions where the numerator is known to be an exact multiple of the denominator. This allows the backend to choose between the faster ofTRUNC_DIV_EXPR,CEIL_DIV_EXPRandFLOOR_DIV_EXPRfor the current target. ARRAY_REF- These nodes represent array accesses. The first operand is the array;
the second is the index. To calculate the address of the memory
accessed, you must scale the index by the size of the type of the array
elements. The type of these expressions must be the type of a component of
the array. The third and fourth operands are used after gimplification
to represent the lower bound and component size but should not be used
directly; call
array_ref_low_boundandarray_ref_element_sizeinstead. ARRAY_RANGE_REF- These nodes represent access to a range (or “slice”) of an array. The
operands are the same as that for
ARRAY_REFand have the same meanings. The type of these expressions must be an array whose component type is the same as that of the first operand. The range of that array type determines the amount of data these expressions access. TARGET_MEM_REF- These nodes represent memory accesses whose address directly map to
an addressing mode of the target architecture. The first argument
is
TMR_SYMBOLand must be aVAR_DECLof an object with a fixed address. The second argument isTMR_BASEand the third one isTMR_INDEX. The fourth argument isTMR_STEPand must be anINTEGER_CST. The fifth argument isTMR_OFFSETand must be anINTEGER_CST. Any of the arguments may be NULL if the appropriate component does not appear in the address. Address of theTARGET_MEM_REFis determined in the following way.&TMR_SYMBOL + TMR_BASE + TMR_INDEX * TMR_STEP + TMR_OFFSETThe sixth argument is the reference to the original memory access, which is preserved for the purposes of the RTL alias analysis. The seventh argument is a tag representing the results of tree level alias analysis.
LT_EXPRLE_EXPRGT_EXPRGE_EXPREQ_EXPRNE_EXPR- These nodes represent the less than, less than or equal to, greater
than, greater than or equal to, equal, and not equal comparison
operators. The first and second operand with either be both of integral
type or both of floating type. The result type of these expressions
will always be of integral or boolean type. These operations return
the result type's zero value for false, and the result type's one value
for true.
For floating point comparisons, if we honor IEEE NaNs and either operand is NaN, then
NE_EXPRalways returns true and the remaining operators always return false. On some targets, comparisons against an IEEE NaN, other than equality and inequality, may generate a floating point exception. ORDERED_EXPRUNORDERED_EXPR- These nodes represent non-trapping ordered and unordered comparison
operators. These operations take two floating point operands and
determine whether they are ordered or unordered relative to each other.
If either operand is an IEEE NaN, their comparison is defined to be
unordered, otherwise the comparison is defined to be ordered. The
result type of these expressions will always be of integral or boolean
type. These operations return the result type's zero value for false,
and the result type's one value for true.
UNLT_EXPRUNLE_EXPRUNGT_EXPRUNGE_EXPRUNEQ_EXPRLTGT_EXPR- These nodes represent the unordered comparison operators.
These operations take two floating point operands and determine whether
the operands are unordered or are less than, less than or equal to,
greater than, greater than or equal to, or equal respectively. For
example,
UNLT_EXPRreturns true if either operand is an IEEE NaN or the first operand is less than the second. With the possible exception ofLTGT_EXPR, all of these operations are guaranteed not to generate a floating point exception. The result type of these expressions will always be of integral or boolean type. These operations return the result type's zero value for false, and the result type's one value for true. MODIFY_EXPR- These nodes represent assignment. The left-hand side is the first
operand; the right-hand side is the second operand. The left-hand side
will be a
VAR_DECL,INDIRECT_REF,COMPONENT_REF, or other lvalue.These nodes are used to represent not only assignment with `=' but also compound assignments (like `+='), by reduction to `=' assignment. In other words, the representation for `i += 3' looks just like that for `i = i + 3'.
INIT_EXPR- These nodes are just like
MODIFY_EXPR, but are used only when a variable is initialized, rather than assigned to subsequently. This means that we can assume that the target of the initialization is not used in computing its own value; any reference to the lhs in computing the rhs is undefined. COMPONENT_REF- These nodes represent non-static data member accesses. The first
operand is the object (rather than a pointer to it); the second operand
is the
FIELD_DECLfor the data member. The third operand represents the byte offset of the field, but should not be used directly; callcomponent_ref_field_offsetinstead. COMPOUND_EXPR- These nodes represent comma-expressions. The first operand is an
expression whose value is computed and thrown away prior to the
evaluation of the second operand. The value of the entire expression is
the value of the second operand.
COND_EXPR- These nodes represent
?:expressions. The first operand is of boolean or integral type. If it evaluates to a nonzero value, the second operand should be evaluated, and returned as the value of the expression. Otherwise, the third operand is evaluated, and returned as the value of the expression.The second operand must have the same type as the entire expression, unless it unconditionally throws an exception or calls a noreturn function, in which case it should have void type. The same constraints apply to the third operand. This allows array bounds checks to be represented conveniently as
(i >= 0 && i < 10) ? i : abort().As a GNU extension, the C language front-ends allow the second operand of the
?:operator may be omitted in the source. For example,x ? : 3is equivalent tox ? x : 3, assuming thatxis an expression without side-effects. In the tree representation, however, the second operand is always present, possibly protected bySAVE_EXPRif the first argument does cause side-effects. CALL_EXPR- These nodes are used to represent calls to functions, including
non-static member functions. The first operand is a pointer to the
function to call; it is always an expression whose type is a
POINTER_TYPE. The second argument is aTREE_LIST. The arguments to the call appear left-to-right in the list. TheTREE_VALUEof each list node contains the expression corresponding to that argument. (The value ofTREE_PURPOSEfor these nodes is unspecified, and should be ignored.) For non-static member functions, there will be an operand corresponding to thethispointer. There will always be expressions corresponding to all of the arguments, even if the function is declared with default arguments and some arguments are not explicitly provided at the call sites. STMT_EXPR- These nodes are used to represent GCC's statement-expression extension.
The statement-expression extension allows code like this:
int f() { return ({ int j; j = 3; j + 7; }); }In other words, an sequence of statements may occur where a single expression would normally appear. The
STMT_EXPRnode represents such an expression. TheSTMT_EXPR_STMTgives the statement contained in the expression. The value of the expression is the value of the last sub-statement in the body. More precisely, the value is the value computed by the last statement nested insideBIND_EXPR,TRY_FINALLY_EXPR, orTRY_CATCH_EXPR. For example, in:({ 3; })the value is
3while in:({ if (x) { 3; } })there is no value. If the
STMT_EXPRdoes not yield a value, it's type will bevoid. BIND_EXPR- These nodes represent local blocks. The first operand is a list of
variables, connected via their
TREE_CHAINfield. These will never require cleanups. The scope of these variables is just the body of theBIND_EXPR. The body of theBIND_EXPRis the second operand. LOOP_EXPR- These nodes represent “infinite” loops. The
LOOP_EXPR_BODYrepresents the body of the loop. It should be executed forever, unless anEXIT_EXPRis encountered. EXIT_EXPR- These nodes represent conditional exits from the nearest enclosing
LOOP_EXPR. The single operand is the condition; if it is nonzero, then the loop should be exited. AnEXIT_EXPRwill only appear within aLOOP_EXPR. CLEANUP_POINT_EXPR- These nodes represent full-expressions. The single operand is an
expression to evaluate. Any destructor calls engendered by the creation
of temporaries during the evaluation of that expression should be
performed immediately after the expression is evaluated.
CONSTRUCTOR- These nodes represent the brace-enclosed initializers for a structure or
array. The first operand is reserved for use by the back end. The
second operand is a
TREE_LIST. If theTREE_TYPEof theCONSTRUCTORis aRECORD_TYPEorUNION_TYPE, then theTREE_PURPOSEof each node in theTREE_LISTwill be aFIELD_DECLand theTREE_VALUEof each node will be the expression used to initialize that field.If the
TREE_TYPEof theCONSTRUCTORis anARRAY_TYPE, then theTREE_PURPOSEof each element in theTREE_LISTwill be anINTEGER_CSTor aRANGE_EXPRof twoINTEGER_CSTs. A singleINTEGER_CSTindicates which element of the array (indexed from zero) is being assigned to. ARANGE_EXPRindicates an inclusive range of elements to initialize. In both cases theTREE_VALUEis the corresponding initializer. It is re-evaluated for each element of aRANGE_EXPR. If theTREE_PURPOSEisNULL_TREE, then the initializer is for the next available array element.In the front end, you should not depend on the fields appearing in any particular order. However, in the middle end, fields must appear in declaration order. You should not assume that all fields will be represented. Unrepresented fields will be set to zero.
COMPOUND_LITERAL_EXPR- These nodes represent ISO C99 compound literals. The
COMPOUND_LITERAL_EXPR_DECL_STMTis aDECL_STMTcontaining an anonymousVAR_DECLfor the unnamed object represented by the compound literal; theDECL_INITIALof thatVAR_DECLis aCONSTRUCTORrepresenting the brace-enclosed list of initializers in the compound literal. That anonymousVAR_DECLcan also be accessed directly by theCOMPOUND_LITERAL_EXPR_DECLmacro. SAVE_EXPR-
A
SAVE_EXPRrepresents an expression (possibly involving side-effects) that is used more than once. The side-effects should occur only the first time the expression is evaluated. Subsequent uses should just reuse the computed value. The first operand to theSAVE_EXPRis the expression to evaluate. The side-effects should be executed where theSAVE_EXPRis first encountered in a depth-first preorder traversal of the expression tree. TARGET_EXPR- A
TARGET_EXPRrepresents a temporary object. The first operand is aVAR_DECLfor the temporary variable. The second operand is the initializer for the temporary. The initializer is evaluated and, if non-void, copied (bitwise) into the temporary. If the initializer is void, that means that it will perform the initialization itself.Often, a
TARGET_EXPRoccurs on the right-hand side of an assignment, or as the second operand to a comma-expression which is itself the right-hand side of an assignment, etc. In this case, we say that theTARGET_EXPRis “normal”; otherwise, we say it is “orphaned”. For a normalTARGET_EXPRthe temporary variable should be treated as an alias for the left-hand side of the assignment, rather than as a new temporary variable.The third operand to the
TARGET_EXPR, if present, is a cleanup-expression (i.e., destructor call) for the temporary. If this expression is orphaned, then this expression must be executed when the statement containing this expression is complete. These cleanups must always be executed in the order opposite to that in which they were encountered. Note that if a temporary is created on one branch of a conditional operator (i.e., in the second or third operand to aCOND_EXPR), the cleanup must be run only if that branch is actually executed.See
STMT_IS_FULL_EXPR_Pfor more information about running these cleanups. AGGR_INIT_EXPR- An
AGGR_INIT_EXPRrepresents the initialization as the return value of a function call, or as the result of a constructor. AnAGGR_INIT_EXPRwill only appear as a full-expression, or as the second operand of aTARGET_EXPR. The first operand to theAGGR_INIT_EXPRis the address of a function to call, just as in aCALL_EXPR. The second operand are the arguments to pass that function, as aTREE_LIST, again in a manner similar to that of aCALL_EXPR.If
AGGR_INIT_VIA_CTOR_Pholds of theAGGR_INIT_EXPR, then the initialization is via a constructor call. The address of the third operand of theAGGR_INIT_EXPR, which is always aVAR_DECL, is taken, and this value replaces the first argument in the argument list.In either case, the expression is void.
VA_ARG_EXPR- This node is used to implement support for the C/C++ variable argument-list
mechanism. It represents expressions like
va_arg (ap, type). ItsTREE_TYPEyields the tree representation fortypeand its sole argument yields the representation forap. OMP_PARALLEL-
Represents
#pragma omp parallel [clause1 ... clauseN]. It has four operands:Operand
OMP_PARALLEL_BODYis valid while in GENERIC and High GIMPLE forms. It contains the body of code to be executed by all the threads. During GIMPLE lowering, this operand becomesNULLand the body is emitted linearly afterOMP_PARALLEL.Operand
OMP_PARALLEL_CLAUSESis the list of clauses associated with the directive.Operand
OMP_PARALLEL_FNis created bypass_lower_omp, it contains theFUNCTION_DECLfor the function that will contain the body of the parallel region.Operand
OMP_PARALLEL_DATA_ARGis also created bypass_lower_omp. If there are shared variables to be communicated to the children threads, this operand will contain theVAR_DECLthat contains all the shared values and variables. OMP_FOR-
Represents
#pragma omp for [clause1 ... clauseN]. It has 5 operands:Operand
OMP_FOR_BODYcontains the loop body.Operand
OMP_FOR_CLAUSESis the list of clauses associated with the directive.Operand
OMP_FOR_INITis the loop initialization code of the formVAR = N1.Operand
OMP_FOR_CONDis the loop conditional expression of the formVAR {<,>,<=,>=} N2.Operand
OMP_FOR_INCRis the loop index increment of the formVAR {+=,-=} INCR.Operand
OMP_FOR_PRE_BODYcontains side-effect code from operandsOMP_FOR_INIT,OMP_FOR_CONDandOMP_FOR_INC. These side-effects are part of theOMP_FORblock but must be evaluated before the start of loop body.The loop index variable
VARmust be a signed integer variable, which is implicitly private to each thread. BoundsN1andN2and the increment expressionINCRare required to be loop invariant integer expressions that are evaluated without any synchronization. The evaluation order, frequency of evaluation and side-effects are unspecified by the standard. OMP_SECTIONS-
Represents
#pragma omp sections [clause1 ... clauseN].Operand
OMP_SECTIONS_BODYcontains the sections body, which in turn contains a set ofOMP_SECTIONnodes for each of the concurrent sections delimited by#pragma omp section.Operand
OMP_SECTIONS_CLAUSESis the list of clauses associated with the directive. OMP_SECTION-
Section delimiter for
OMP_SECTIONS. OMP_SINGLE-
Represents
#pragma omp single.Operand
OMP_SINGLE_BODYcontains the body of code to be executed by a single thread.Operand
OMP_SINGLE_CLAUSESis the list of clauses associated with the directive. OMP_MASTER-
Represents
#pragma omp master.Operand
OMP_MASTER_BODYcontains the body of code to be executed by the master thread. OMP_ORDERED-
Represents
#pragma omp ordered.Operand
OMP_ORDERED_BODYcontains the body of code to be executed in the sequential order dictated by the loop index variable. OMP_CRITICAL-
Represents
#pragma omp critical [name].Operand
OMP_CRITICAL_BODYis the critical section.Operand
OMP_CRITICAL_NAMEis an optional identifier to label the critical section. OMP_RETURN-
This does not represent any OpenMP directive, it is an artificial
marker to indicate the end of the body of an OpenMP. It is used
by the flow graph (
tree-cfg.c) and OpenMP region building code (omp-low.c). OMP_CONTINUE-
Similarly, this instruction does not represent an OpenMP
directive, it is used by
OMP_FORandOMP_SECTIONSto mark the place where the code needs to loop to the next iteration (in the case ofOMP_FOR) or the next section (in the case ofOMP_SECTIONS).In some cases,
OMP_CONTINUEis placed right beforeOMP_RETURN. But if there are cleanups that need to occur right after the looping body, it will be emitted betweenOMP_CONTINUEandOMP_RETURN. OMP_ATOMIC-
Represents
#pragma omp atomic.Operand 0 is the address at which the atomic operation is to be performed.
Operand 1 is the expression to evaluate. The gimplifier tries three alternative code generation strategies. Whenever possible, an atomic update built-in is used. If that fails, a compare-and-swap loop is attempted. If that also fails, a regular critical section around the expression is used.
OMP_CLAUSE-
Represents clauses associated with one of the
OMP_directives. Clauses are represented by separate sub-codes defined in tree.h. Clauses codes can be one of:OMP_CLAUSE_PRIVATE,OMP_CLAUSE_SHARED,OMP_CLAUSE_FIRSTPRIVATE,OMP_CLAUSE_LASTPRIVATE,OMP_CLAUSE_COPYIN,OMP_CLAUSE_COPYPRIVATE,OMP_CLAUSE_IF,OMP_CLAUSE_NUM_THREADS,OMP_CLAUSE_SCHEDULE,OMP_CLAUSE_NOWAIT,OMP_CLAUSE_ORDERED,OMP_CLAUSE_DEFAULT, andOMP_CLAUSE_REDUCTION. Each code represents the corresponding OpenMP clause.Clauses associated with the same directive are chained together via
OMP_CLAUSE_CHAIN. Those clauses that accept a list of variables are restricted to exactly one, accessed withOMP_CLAUSE_VAR. Therefore, multiple variables under the same clauseCneed to be represented as multipleCclauses chained together. This facilitates adding new clauses during compilation.