### 12.7 Manipulating GIMPLE statements

This section documents all the functions available to handle each of the GIMPLE instructions.

#### 12.7.1 Common accessors

The following are common accessors for gimple statements.

GIMPLE function: enum gimple_code gimple_code (gimple g)

  Return the code for statement `G`.

GIMPLE function: basic_block gimple_bb (gimple g)

  Return the basic block to which statement `G` belongs to.

GIMPLE function: tree gimple_block (gimple g)

  Return the lexical scope block holding statement `G`.

GIMPLE function: tree gimple_expr_type (gimple stmt)

  Return the type of the main expression computed by `STMT`. Return `void_type_node` if `STMT` computes nothing. This will only return something meaningful for `GIMPLE_ASSIGN`, `GIMPLE_COND` and `GIMPLE_CALL`. For all other tuple codes, it will return `void_type_node`.

GIMPLE function: enum tree_code gimple_expr_code (gimple stmt)

  Return the tree code for the expression computed by `STMT`. This is only meaningful for `GIMPLE_CALL`, `GIMPLE_ASSIGN` and `GIMPLE_COND`. If `STMT` is `GIMPLE_CALL`, it will return `CALL_EXPR`. For `GIMPLE_COND`, it returns the code of the comparison predicate. For `GIMPLE_ASSIGN` it returns the code of the operation performed by the `RHS` of the assignment.

GIMPLE function: void gimple_set_block (gimple g, tree block)

  Set the lexical scope block of `G` to `BLOCK`.

GIMPLE function: location_t gimple_locus (gimple g)

  Return locus information for statement `G`.

GIMPLE function: void gimple_set_locus (gimple g, location_t locus)

  Set locus information for statement `G`.

GIMPLE function: bool gimple_locus_empty_p (gimple g)

  Return true if `G` does not have locus information.

GIMPLE function: bool gimple_no_warning_p (gimple stmt)

  Return true if no warnings should be emitted for statement `STMT`.

GIMPLE function: void gimple_set_visited (gimple stmt, bool visited_p)

  Set the visited status on statement `STMT` to `VISITED_P`.

GIMPLE function: bool gimple_visited_p (gimple stmt)

  Return the visited status on statement `STMT`.

GIMPLE function: void gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)

  Set pass local flag `PLF` on statement `STMT` to `VAL_P`.

GIMPLE function: unsigned int gimple_plf (gimple stmt, enum plf_mask plf)

  Return the value of pass local flag `PLF` on statement `STMT`.

GIMPLE function: bool gimple_has_ops (gimple g)

  Return true if statement `G` has register or memory operands.

GIMPLE function: bool gimple_has_mem_ops (gimple g)

  Return true if statement `G` has memory operands.

GIMPLE function: unsigned gimple_num_ops (gimple g)

  Return the number of operands for statement `G`.

GIMPLE function: tree * gimple_ops (gimple g)

  Return the array of operands for statement `G`.

GIMPLE function: tree gimple_op (gimple g, unsigned i)

  Return operand `I` for statement `G`.

GIMPLE function: tree * gimple_op_ptr (gimple g, unsigned i)

  Return a pointer to operand `I` for statement `G`.

GIMPLE function: void gimple_set_op (gimple g, unsigned i, tree op)

  Set operand `I` of statement `G` to `OP`.

GIMPLE function: bitmap gimple_addresses_taken (gimple stmt)

  Return the set of symbols that have had their address taken by `STMT`.

GIMPLE function: struct def_optype_d * gimple_def_ops (gimple g)

  Return the set of `DEF` operands for statement `G`.

GIMPLE function: void gimple_set_def_ops (gimple g, struct def_optype_d *def)

  Set `DEF` to be the set of `DEF` operands for statement `G`.

GIMPLE function: struct use_optype_d * gimple_use_ops (gimple g)

  Return the set of `USE` operands for statement `G`.

GIMPLE function: void gimple_set_use_ops (gimple g, struct use_optype_d *use)

  Set `USE` to be the set of `USE` operands for statement `G`.

GIMPLE function: struct voptype_d * gimple_vuse_ops (gimple g)

  Return the set of `VUSE` operands for statement `G`.

GIMPLE function: void gimple_set_vuse_ops (gimple g, struct voptype_d *ops)

  Set `OPS` to be the set of `VUSE` operands for statement `G`.

GIMPLE function: struct voptype_d * gimple_vdef_ops (gimple g)

  Return the set of `VDEF` operands for statement `G`.

GIMPLE function: void gimple_set_vdef_ops (gimple g, struct voptype_d *ops)

  Set `OPS` to be the set of `VDEF` operands for statement `G`.

GIMPLE function: bitmap gimple_loaded_syms (gimple g)

  Return the set of symbols loaded by statement `G`. Each element of the set is the `DECL_UID` of the corresponding symbol.

GIMPLE function: bitmap gimple_stored_syms (gimple g)

  Return the set of symbols stored by statement `G`. Each element of the set is the `DECL_UID` of the corresponding symbol.

GIMPLE function: bool gimple_modified_p (gimple g)

  Return true if statement `G` has operands and the modified field has been set.

GIMPLE function: bool gimple_has_volatile_ops (gimple stmt)

  Return true if statement `STMT` contains volatile operands.

GIMPLE function: void gimple_set_has_volatile_ops (gimple stmt, bool volatilep)

  Return true if statement `STMT` contains volatile operands.

GIMPLE function: void update_stmt (gimple s)

  Mark statement `S` as modified, and update it.

GIMPLE function: void update_stmt_if_modified (gimple s)

  Update statement `S` if it has been marked modified.

GIMPLE function: gimple gimple_copy (gimple stmt)

  Return a deep copy of statement `STMT`.