Movatterモバイル変換


[0]ホーム

URL:


Previous:, Up:Operands   [Contents][Index]


11.6.4 Logical Operators

Except when they appear in the condition operand of aGIMPLE_COND, logical ‘and’ and ‘or’ operators are simplifiedas follows:a = b && c becomes

T1 = (bool)b;if (T1 == true)  T1 = (bool)c;a = T1;

Note thatT1 in this example cannot be an expression temporary,because it has two different assignments.

11.6.5 Manipulating operands

All gimple operands are of typetree. But only certaintypes of trees are allowed to be used as operand tuples. Basicvalidation is controlled by the functionget_gimple_rhs_class, which given a tree code, returns anenum with the following values of typeenumgimple_rhs_class

For tree nodes in the categoriesGIMPLE_TERNARY_RHS,GIMPLE_BINARY_RHS andGIMPLE_UNARY_RHS, they cannot bestored inside tuples directly. They first need to be flattened andseparated into individual components. For instance, given the GENERICexpression

a = b + c

its tree representation is:

MODIFY_EXPR <VAR_DECL  <a>, PLUS_EXPR <VAR_DECL <b>, VAR_DECL <c>>>

In this case, the GIMPLE form for this statement is logicallyidentical to its GENERIC form but in GIMPLE, thePLUS_EXPRon the RHS of the assignment is not represented as a tree,instead the two operands are taken out of thePLUS_EXPR sub-treeand flattened into the GIMPLE tuple as follows:

GIMPLE_ASSIGN <PLUS_EXPR, VAR_DECL <a>, VAR_DECL <b>, VAR_DECL <c>>

11.6.6 Operand vector allocation

The operand vector is stored at the bottom of the three tuplestructures that accept operands. This means, that depending onthe code of a given statement, its operand vector will be atdifferent offsets from the base of the structure. To accesstuple operands use the following accessors

GIMPLE function:unsignedgimple_num_ops(gimple g)

Returns the number of operands in statement G.

GIMPLE function:treegimple_op(gimple g, unsigned i)

Returns operandI from statementG.

GIMPLE function:tree *gimple_ops(gimple g)

Returns a pointer into the operand vector for statementG. Thisis computed using an internal table calledgimple_ops_offset_[].This table is indexed by the gimple code ofG.

When the compiler is built, this table is filled-in using thesizes of the structures used by each statement code defined ingimple.def. Since the operand vector is at the bottom of thestructure, for a gimple codeC the offset is computed as sizeof(struct-ofC) - sizeof (tree).

This mechanism adds one memory indirection to every access whenusinggimple_op(), if this becomes a bottleneck, a pass canchoose to memoize the result fromgimple_ops() and use that toaccess the operands.

11.6.7 Operand validation

When adding a new operand to a gimple statement, the operand willbe validated according to what each tuple accepts in its operandvector. These predicates are called by thegimple_name_set_...(). Each tuple will use one of thefollowing predicates (Note, this list is not exhaustive):

GIMPLE function:boolis_gimple_val(tree t)

Returns true if t is a "GIMPLE value", which are all thenon-addressable stack variables (variables for whichis_gimple_reg returns true) and constants (expressions for whichis_gimple_min_invariant returns true).

GIMPLE function:boolis_gimple_addressable(tree t)

Returns true if t is a symbol or memory reference whose addresscan be taken.

GIMPLE function:boolis_gimple_asm_val(tree t)

Similar tois_gimple_val but it also accepts hard registers.

GIMPLE function:boolis_gimple_call_addr(tree t)

Return true if t is a valid expression to use as the functioncalled by aGIMPLE_CALL.

GIMPLE function:boolis_gimple_mem_ref_addr(tree t)

Return true if t is a valid expression to use as first operandof aMEM_REF expression.

GIMPLE function:boolis_gimple_constant(tree t)

Return true if t is a valid gimple constant.

GIMPLE function:boolis_gimple_min_invariant(tree t)

Return true if t is a valid minimal invariant. This is differentfrom constants, in that the specific value of t may not be knownat compile time, but it is known that it doesn’t change (e.g.,the address of a function local variable).

GIMPLE function:boolis_gimple_ip_invariant(tree t)

Return true if t is an interprocedural invariant. This means that tis a valid invariant in all functions (e.g. it can be an address of aglobal variable but not of a local one).

GIMPLE function:boolis_gimple_ip_invariant_address(tree t)

Return true if t is anADDR_EXPR that does not change once theprogram is running (and which is valid in all functions).

11.6.8 Statement validation

GIMPLE function:boolis_gimple_assign(gimple g)

Return true if the code of g isGIMPLE_ASSIGN.

GIMPLE function:boolis_gimple_call(gimple g)

Return true if the code of g isGIMPLE_CALL.

GIMPLE function:boolis_gimple_debug(gimple g)

Return true if the code of g isGIMPLE_DEBUG.

GIMPLE function:boolgimple_assign_cast_p(const_gimple g)

Return true if g is aGIMPLE_ASSIGN that performs a type castoperation.

GIMPLE function:boolgimple_debug_bind_p(gimple g)

Return true if g is aGIMPLE_DEBUG that binds the value of anexpression to a variable.

GIMPLE function:boolis_gimple_omp(gimple g)

Return true if g is any of the OpenMP codes.

GIMPLE function:boolgimple_debug_begin_stmt_p(gimple g)

Return true if g is aGIMPLE_DEBUG that marks the beginning ofa source statement.

GIMPLE function:boolgimple_debug_inline_entry_p(gimple g)

Return true if g is aGIMPLE_DEBUG that marks the entrypoint of an inlined function.

GIMPLE function:boolgimple_debug_nonbind_marker_p(gimple g)

Return true if g is aGIMPLE_DEBUG that marks a program location,without any variable binding.


Previous:Conditional Expressions, Up:Operands   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp