Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:GIMPLE   [Contents][Index]


11.10 Sequence iterators

Sequence iterators are convenience constructs for iteratingthrough statements in a sequence. Given a sequenceSEQ, here isa typical use of gimple sequence iterators:

gimple_stmt_iterator gsi;for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))  {    gimple g = gsi_stmt (gsi);    /* Do something with gimple statementG.  */  }

Backward iterations are possible:

        for (gsi = gsi_last (seq); !gsi_end_p (gsi); gsi_prev (&gsi))

Forward and backward iterations on basic blocks are possible withgsi_start_bb andgsi_last_bb.

In the documentation below we sometimes refer to enumgsi_iterator_update. The valid options for this enumeration are:

Below is a list of the functions used to manipulate and usestatement iterators.

GIMPLE function:gimple_stmt_iteratorgsi_start(gimple_seq seq)

Return a new iterator pointing to the sequenceSEQ’s firststatement. IfSEQ is empty, the iterator’s basic block isNULL.Usegsi_start_bb instead when the iterator needs to always havethe correct basic block set.

GIMPLE function:gimple_stmt_iteratorgsi_start_bb(basic_block bb)

Return a new iterator pointing to the first statement in basicblockBB.

GIMPLE function:gimple_stmt_iteratorgsi_last(gimple_seq seq)

Return a new iterator initially pointing to the last statement ofsequenceSEQ. IfSEQ is empty, the iterator’s basic block isNULL. Usegsi_last_bb instead when the iterator needs to alwayshave the correct basic block set.

GIMPLE function:gimple_stmt_iteratorgsi_last_bb(basic_block bb)

Return a new iterator pointing to the last statement in basicblockBB.

GIMPLE function:boolgsi_end_p(gimple_stmt_iterator i)

ReturnTRUE if at the end ofI.

GIMPLE function:boolgsi_one_before_end_p(gimple_stmt_iterator i)

ReturnTRUE if we’re one statement before the end ofI.

GIMPLE function:voidgsi_next(gimple_stmt_iterator *i)

Advance the iterator to the next gimple statement.

GIMPLE function:voidgsi_prev(gimple_stmt_iterator *i)

Advance the iterator to the previous gimple statement.

GIMPLE function:gimplegsi_stmt(gimple_stmt_iterator i)

Return the current stmt.

GIMPLE function:gimple_stmt_iteratorgsi_after_labels(basic_block bb)

Return a block statement iterator that points to the firstnon-label statement in blockBB.

GIMPLE function:gimple *gsi_stmt_ptr(gimple_stmt_iterator *i)

Return a pointer to the current stmt.

GIMPLE function:basic_blockgsi_bb(gimple_stmt_iterator i)

Return the basic block associated with this iterator.

GIMPLE function:gimple_seqgsi_seq(gimple_stmt_iterator i)

Return the sequence associated with this iterator.

GIMPLE function:voidgsi_remove(gimple_stmt_iterator *i, bool remove_eh_info)

Remove the current stmt from the sequence. The iterator isupdated to point to the next statement. WhenREMOVE_EH_INFO istrue we remove the statement pointed to by iteratorI from theEHtables. Otherwise we do not modify theEH tables. Generally,REMOVE_EH_INFO should be true when the statement is going to beremoved from theIL and not reinserted elsewhere.

GIMPLE function:voidgsi_link_seq_before(gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)

Links the sequence of statementsSEQ before the statement pointedby iteratorI.MODE indicates what to do with the iteratorafter insertion (seeenum gsi_iterator_update above).

GIMPLE function:voidgsi_link_before(gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode)

Links statementG before the statement pointed-to by iteratorI.Updates iteratorI according toMODE.

GIMPLE function:voidgsi_link_seq_after(gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)

Links sequenceSEQ after the statement pointed-to by iteratorI.MODE is as ingsi_insert_after.

GIMPLE function:voidgsi_link_after(gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode)

Links statementG after the statement pointed-to by iteratorI.MODE is as ingsi_insert_after.

GIMPLE function:gimple_seqgsi_split_seq_after(gimple_stmt_iterator i)

Move all statements in the sequence afterI to a new sequence.Return this new sequence.

GIMPLE function:gimple_seqgsi_split_seq_before(gimple_stmt_iterator *i)

Move all statements in the sequence beforeI to a new sequence.Return this new sequence.

GIMPLE function:voidgsi_replace(gimple_stmt_iterator *i, gimple stmt, bool update_eh_info)

Replace the statement pointed-to byI toSTMT. IfUPDATE_EH_INFOis true, the exception handling information of the originalstatement is moved to the new statement.

GIMPLE function:voidgsi_insert_before(gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update mode)

Insert statementSTMT before the statement pointed-to by iteratorI, updateSTMT’s basic block and scan it for new operands.MODEspecifies how to update iteratorI after insertion (see enumgsi_iterator_update).

GIMPLE function:voidgsi_insert_seq_before(gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)

Likegsi_insert_before, but for all the statements inSEQ.

GIMPLE function:voidgsi_insert_after(gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update mode)

Insert statementSTMT after the statement pointed-to by iteratorI, updateSTMT’s basic block and scan it for new operands.MODEspecifies how to update iteratorI after insertion (see enumgsi_iterator_update).

GIMPLE function:voidgsi_insert_seq_after(gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)

Likegsi_insert_after, but for all the statements inSEQ.

GIMPLE function:gimple_stmt_iteratorgsi_for_stmt(gimple stmt)

Finds iterator forSTMT.

GIMPLE function:voidgsi_move_after(gimple_stmt_iterator *from, gimple_stmt_iterator *to)

Move the statement atFROM so it comes right after the statementatTO.

GIMPLE function:voidgsi_move_before(gimple_stmt_iterator *from, gimple_stmt_iterator *to)

Move the statement atFROM so it comes right before the statementatTO.

GIMPLE function:voidgsi_move_to_bb_end(gimple_stmt_iterator *from, basic_block bb)

Move the statement atFROM to the end of basic blockBB.

GIMPLE function:voidgsi_insert_on_edge(edge e, gimple stmt)

AddSTMT to the pending list of edgeE. No actual insertion ismade until a call togsi_commit_edge_inserts() is made.

GIMPLE function:voidgsi_insert_seq_on_edge(edge e, gimple_seq seq)

Add the sequence of statements inSEQ to the pending list of edgeE. No actual insertion is made until a call togsi_commit_edge_inserts() is made.

GIMPLE function:basic_blockgsi_insert_on_edge_immediate(edge e, gimple stmt)

Similar togsi_insert_on_edge+gsi_commit_edge_inserts. If a newblock has to be created, it is returned.

GIMPLE function:voidgsi_commit_one_edge_insert(edge e, basic_block *new_bb)

Commit insertions pending at edgeE. If a new block is created,setNEW_BB to this block, otherwise set it toNULL.

GIMPLE function:voidgsi_commit_edge_inserts(void)

This routine will commit all pending edge insertions, creatingany new basic blocks which are necessary.


Next:Adding a new GIMPLE statement code, Previous:GIMPLE sequences, Up:GIMPLE   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp