diff options
author | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-02 16:41:48 +0000 |
---|---|---|
committer | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-02 16:41:48 +0000 |
commit | e3a19533c3ba16854e1dc1bb2ac7ce197883e38f (patch) | |
tree | a909112c3b26051d56924ebe9435b84f207b2091 /gcc/gimple.h | |
parent | 93106215b9a003a0f5aa582d4c2b9078cb386d47 (diff) | |
download | gcc-e3a19533c3ba16854e1dc1bb2ac7ce197883e38f.tar.gz |
* coretypes.h (gimple_seq, const_gimple_seq): Typedef as gimple.
* gimple.h (struct gimple_seq_node_d, struct gimple_seq_d): Remove.
(const_gimple_seq_node): Remove.
(gimple_seq_node): Typedef as gimple.
(struct gimple_statement_base): Add next and prev members,
adjust all WORD markers in using structs.
(union gimple_statement_d): Link via gsbase.next field for GC and PCH.
(gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last,
gimple_seq_last_stmt): Adjust as gimple_seq, gimple_seq_node and
gimple are the same.
(gimple_seq_set_last, gimple_seq_set_first): Don't allocate
gimple_seq, adjust.
(gimple_init_singleton): New function.
(gsi_start_1, gsi_last_1, gsi_end_p, gsi_one_before_end_p): Adjust.
(gsi_next, gsi_prev): Adjust, handle prev cyclic list correctly.
(gsi_stmt): Adjust.
(gsi_stmt_ptr): Remove.
(enum gimple_alloc_kind): Remove gimple_alloc_kind_seq member.
* gimple-iterator.c (update_bb_for_stmts): Take last parameter
again, adjust for above changes.
(update_call_edge_frequencies): Adjust for above changes.
(gsi_insert_seq_nodes_before): Rewrite for new data structure.
(gsi_insert_seq_nodes_after): Ditto.
(gsi_split_seq_after): Ditto.
(gsi_set_stmt): Ditto.
(gsi_split_seq_before): Ditto.
(gsi_remove): Ditto.
(gsi_insert_seq_before_without_update): Don't free sequence.
(gsi_insert_seq_after_without_update): Ditto.
(gsi_replace): Assert some more invariants.
(gsi_insert_before_without_update, gsi_insert_after_without_update):
Tidy.
(gsi_for_stmt): Don't search for stmt.
(gsi_insert_on_edge_immediate): Tidy.
* gimple.c (gimple_alloc_k): Remove "sequences".
(gimple_seq_cache): Remove.
(gimple_alloc_stat): Make stmt a singleton sequence.
(gimple_seq_alloc, gimple_seq_free): Remove.
(gimple_assign_set_rhs_with_ops_1): Ensure new stmt is a singleton.
(gimple_copy): Ditto.
* gimplify.c (gimplify_cleanup_point_expr): Use gsi_set_stmt,
create iterator from correct sequence.
* tree-phinodes.c (make_phi_node): Make stmt a singleton.
* gimple.h (gimple_stmt_iterator <seq>): Make it be pointer to
gimple_seq.
(gimple_seq_set_last, gimple_seq_set_first): Take pointer to
sequence, lazily allocate it.
(bb_seq_addr): New function.
(gsi_start_1): Rename from gsi_start, but take pointer to sequence.
(gsi_start): Macro to wrap gsi_start_1 taking pointer of argument.
(gsi_none): New function.
(gsi_start_bb): Adjust.
(gsi_last_1): Rename from gsi_last, but take pointer to sequence.
(gsi_last): Macro to wrap gsi_last_1 taking pointer of argument.
(gsi_last_bb): Adjust.
(gsi_seq): Adjust.
* tree-flow-inline.h (phi_nodes_ptr): New function.
* gimple-iterator.c (gsi_insert_seq_nodes_before): Adjust to
datastructure and interface change.
(gsi_insert_seq_before_without_update): Ditto.
(gsi_insert_seq_nodes_after): Ditto.
(gsi_insert_seq_after_without_update): Ditto.
(gsi_split_seq_after): Ditto, don't use gimple_seq_alloc.
(gsi_split_seq_before): Ditto.
(gsi_start_phis): Adjust.
* tree-vect-loop.c (vect_determine_vectorization_factor): Use
gsi_none.
(vect_transform_loop): Ditto.
* gimple.c (gimple_seq_add_stmt, gimple_seq_add_seq,
gimple_seq_copy): Don't use gimple_seq_alloc.
* gimplify.c (gimple_seq_add_stmt_without_update): Ditto.
(gimplify_seq_add_seq): Ditto.
* lto-streamer-in.c (make_new_block): Ditto.
* tree-cfg.c (create_bb): Ditto.
* tree-sra.c (initialize_parameter_reductions): Ditto.
* gimple.h (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last,
gimple_seq_last_stmt, gimple_seq_set_last, gimple_seq_set_first,
gimple_seq_empty_p, gimple_seq_alloc_with_stmt, bb_seq,
set_bb_seq): Move down to after gimple_statement_d definition.
* gimple-fold.c (gimplify_and_update_call_from_tree): Use
gsi_replace_with_seq, instead of inserting itself.
* gimple-iterator.c (gsi_replace_with_seq): New function.
* tree-ssa-forwprop.c (forward_propagate_comparison): Take
iterator instead of statement, advance it.
(ssa_forward_propagate_and_combine): Adjust call to above.
* tree-phinodes.c (add_phi_node_to_bb): Tidy, don't use
gimple_seq_alloc.
* omp-low.c (finalize_task_copyfn): Don't use gimple_seq_alloc.
* tree-nested.c (walk_gimple_omp_for): Ditto.
* trans-mem.c (lower_transaction): Ditto.
* tree-eh.c (do_return_redirection): Ditto.
(do_goto_redirection): Ditto.
(lower_try_finally_switch): Ditto.
* gimplify.c (gimplify_stmt): Ditto.
(gimplify_scan_omp_clauses): Ditto.
(gimplify_omp_for): Ditto.
(gimplify_function_tree): Ditto.
* gimple-fold.c (gimplify_and_update_call_from_tree): Ditto.
* tree-mudflap.c (mf_decl_cache_locals): Ditto.
(mf_build_check_statement_for): Ditto.
(mx_register_decls): Ditto.
* graphite-sese-to-poly.c (remove_invariant_phi): Ditto,
and don't use itertors to append.
(insert_stmts): Ditto.
(insert_out_of_ssa_copy): Ditto.
(insert_out_of_ssa_copy_on_edge): Ditto.
* gimple.h (gimple_bind_body_ptr): New function.
(gimple_bind_body): Use it.
(gimple_catch_handler): Use gimple_catch_handler_ptr.
(gimple_eh_filter_failure_ptr): New function.
(gimple_eh_filter_failure): Use it.
(gimple_eh_else_n_body_ptr): New function.
(gimple_eh_else_n_body): Use it.
(gimple_eh_else_e_body_ptr): New function.
(gimple_eh_else_e_body): Use it.
(gimple_try_eval_ptr): New function.
(gimple_try_eval): Use it.
(gimple_try_cleanup_ptr): New function.
(gimple_try_cleanup): Use it.
(gimple_wce_cleanup_ptr): New function.
(gimple_wce_cleanup): Use it.
(gimple_omp_body_ptr): New function.
(gimple_omp_body): Use it.
(gimple_omp_for_pre_body_ptr): New function.
(gimple_omp_for_pre_body): Use it.
(gimple_transaction_body_ptr): New function.
(gimple_transaction_body): Use it.
(gsi_split_seq_before): Adjust to return nothing and take pointer
to sequence.
(gsi_set_stmt): Declare.
(gsi_replace_with_seq): Declare.
(walk_gimple_seq_mod): Declare.
* function.h (struct function <gimple_body>): Use typedef gimple_seq.
* gimple-iterator.c (gsi_set_stmt): New function.
(gsi_split_seq_before): Return new sequence via pointer argument.
(gsi_replace): Use gsi_set_stmt.
* tree-ssa-loop-im.c (move_computations_stmt): First remove
then insert stmt.
* tree-complex.c (update_complex_components_on_edge): Don't
copy gsi.
* tree-phinodes.c (resize_phi_node): Don't resize stmt in-place,
return new stmt.
(reserve_phi_args_for_new_edge): Change call to above,
use gsi_set_stmt.
* omp-low.c (lower_omp): Change prototype to take pointer to
sequence.
(lower_rec_input_clauses): Use gimple_seq_add_seq instead of
iterators. Adjust call to lower_omp.
(lower_lastprivate_clauses): Adjust call to lower_omp.
(lower_reduction_clauses): Ditto.
(expand_omp_taskreg): Nullify non-cfg body of child_fn.
(lower_omp_sections): Don't explicitely count sequence length,
nullify lowered bodies earlier, ensure stmts are part of only
one sequence, adjust call to lower_omp.
(lower_omp_single): Ensure stmts are part of only one sequence,
adjust call to lower_omp.
(lower_omp_master): Ditto.
(lower_omp_ordered): Ditto.
(lower_omp_critical): Ditto.
(lower_omp_for): Ditto.
(lower_omp_taskreg): Ditto, tidy.
(lower_omp_1): Adjust calls to lower_omp.
(execute_lower_omp): Ditto.
(lower_omp): Adjust to take pointer to sequence.
(diagnose_sb_2): Use walk_gimple_seq_mod.
(diagnose_omp_structured_block_errors): Ditto and set possibly
changed function body.
* gimple-low.c (lower_function_body): Set function body after
it stabilizes.
(lower_sequence): Adjust to take pointer to sequence.
(lower_omp_directive): Ensure stmt isn't put twice into the
sequence, adjust call to lower_sequence.
(lower_stmt): Adjust calls to lower_sequence.
(lower_gimple_bind): Ditto.
(gimple_try_catch_may_fallthru): Call gsi_start with lvalue.
* tree-nested.c (walk_body): Take pointer to sequence, use
walk_gimple_seq_mod.
(walk_function): Adjust call to walk_body, set possibly changed
body.
(walk_gimple_omp_for): Adjust calls to walk_body.
(convert_nonlocal_omp_clauses): Ditto.
(convert_nonlocal_reference_stmt): Ditto.
(convert_local_omp_clauses): Ditto.
(convert_local_reference_stmt): Ditto.
(convert_tramp_reference_stmt): Ditto.
(convert_gimple_call): Ditto.
(convert_nl_goto_reference): Use local iterator copy.
* gimple.c (walk_gimple_seq_mod): Renamed from walk_gimple_seq,
but taking pointer to sequence, ensure gsi_start is called with
callers lvalue.
(walk_gimple_seq): New wrapper around walk_gimple_seq_mod,
asserting that the sequence head didn't change.
(walk_gimple_stmt): Replace all calls to walk_gimple_seq with
walk_gimple_seq_mod.
* trans-mem.c (lower_transaction): Use walk_gimple_seq_mod.
(execute_lower_tm): Ditto, and set possibly changed body.
* tree-eh.c (lower_eh_constructs_1): Take pointer to sequence,
call gsi_start with that lvalue.
(replace_goto_queue_stmt_list): Ditto.
(replace_goto_queue_1): Adjust calls to replace_goto_queue_stmt_list.
(replace_goto_queue): Ditto.
(lower_try_finally_nofallthru): Adjust calls to lower_eh_constructs_1.
(lower_try_finally_onedest): Ditto.
(lower_try_finally_copy): Ditto.
(lower_try_finally_switch): Ditto.
(lower_try_finally): Ditto.
(lower_eh_filter): Ditto.
(lower_eh_must_not_throw): Ditto.
(lower_cleanup): Ditto.
(lower_eh_constructs_2): Ditto.
(lower_catch): Ditto, and ensure gsi_start is called with lvalue.
(lower_eh_constructs): Adjust calls to lower_eh_constructs_1, and
set possibly changed body.
(optimize_double_finally): Call gsi_start with lvalue.
* tree-cfg.c (make_blocks): Adjust call to gsi_split_seq_before.
(gimple_split_block): Ditto.
(gimple_merge_blocks): Use gsi_start_phis.
(move_stmt_r): Use walk_gimple_seq_mod.
* tree-ssa-dse.c (dse_enter_block): Use gsi_last_bb.
* cgraphbuild.c (build_cgraph_edges): Use gsi_start_phis.
(rebuild_cgraph_edges): Ditto.
(cgraph_rebuild_references): Ditto.
* ipa-prop.c (ipa_analyze_params_uses): Ditto.
* tree-inline.c (copy_phis_for_bb): Ditto.
* tree-ssa-dce.c: Ditto.
* cgraphunit.c (cgraph_analyze_function): Use gimple_has_body_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187053 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r-- | gcc/gimple.h | 638 |
1 files changed, 376 insertions, 262 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h index e0f8660fba3..c40d7c3cc4e 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -32,9 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-alias.h" #include "internal-fn.h" -struct gimple_seq_node_d; -typedef struct gimple_seq_node_d *gimple_seq_node; -typedef const struct gimple_seq_node_d *const_gimple_seq_node; +typedef gimple gimple_seq_node; /* For each block, the PHI nodes that need to be rewritten are stored into these vectors. */ @@ -133,130 +131,6 @@ enum plf_mask { GF_PLF_2 = 1 << 1 }; -/* A node in a gimple_seq_d. */ -struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) gimple_seq_node_d { - gimple stmt; - struct gimple_seq_node_d *prev; - struct gimple_seq_node_d *next; -}; - -/* A double-linked sequence of gimple statements. */ -struct GTY ((chain_next ("%h.next_free"))) gimple_seq_d { - /* First and last statements in the sequence. */ - gimple_seq_node first; - gimple_seq_node last; - - /* Sequences are created/destroyed frequently. To minimize - allocation activity, deallocated sequences are kept in a pool of - available sequences. This is the pointer to the next free - sequence in the pool. */ - gimple_seq next_free; -}; - - -/* Return the first node in GIMPLE sequence S. */ - -static inline gimple_seq_node -gimple_seq_first (const_gimple_seq s) -{ - return s ? s->first : NULL; -} - - -/* Return the first statement in GIMPLE sequence S. */ - -static inline gimple -gimple_seq_first_stmt (const_gimple_seq s) -{ - gimple_seq_node n = gimple_seq_first (s); - return (n) ? n->stmt : NULL; -} - - -/* Return the last node in GIMPLE sequence S. */ - -static inline gimple_seq_node -gimple_seq_last (const_gimple_seq s) -{ - return s ? s->last : NULL; -} - - -/* Return the last statement in GIMPLE sequence S. */ - -static inline gimple -gimple_seq_last_stmt (const_gimple_seq s) -{ - gimple_seq_node n = gimple_seq_last (s); - return (n) ? n->stmt : NULL; -} - - -/* Set the last node in GIMPLE sequence S to LAST. */ - -static inline void -gimple_seq_set_last (gimple_seq s, gimple_seq_node last) -{ - s->last = last; -} - - -/* Set the first node in GIMPLE sequence S to FIRST. */ - -static inline void -gimple_seq_set_first (gimple_seq s, gimple_seq_node first) -{ - s->first = first; -} - - -/* Return true if GIMPLE sequence S is empty. */ - -static inline bool -gimple_seq_empty_p (const_gimple_seq s) -{ - return s == NULL || s->first == NULL; -} - - -void gimple_seq_add_stmt (gimple_seq *, gimple); - -/* Link gimple statement GS to the end of the sequence *SEQ_P. If - *SEQ_P is NULL, a new sequence is allocated. This function is - similar to gimple_seq_add_stmt, but does not scan the operands. - During gimplification, we need to manipulate statement sequences - before the def/use vectors have been constructed. */ -void gimple_seq_add_stmt_without_update (gimple_seq *, gimple); - -/* Allocate a new sequence and initialize its first element with STMT. */ - -static inline gimple_seq -gimple_seq_alloc_with_stmt (gimple stmt) -{ - gimple_seq seq = NULL; - gimple_seq_add_stmt (&seq, stmt); - return seq; -} - - -/* Returns the sequence of statements in BB. */ - -static inline gimple_seq -bb_seq (const_basic_block bb) -{ - return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL; -} - - -/* Sets the sequence of statements in BB to SEQ. */ - -static inline void -set_bb_seq (basic_block bb, gimple_seq seq) -{ - gcc_checking_assert (!(bb->flags & BB_RTL)); - bb->il.gimple->seq = seq; -} - /* Iterator object for GIMPLE statement sequences. */ typedef struct @@ -268,7 +142,7 @@ typedef struct are necessary to handle edge cases such as when statement is added to an empty basic block or when the last statement of a block/sequence is removed. */ - gimple_seq seq; + gimple_seq *seq; basic_block bb; } gimple_stmt_iterator; @@ -332,7 +206,16 @@ struct GTY(()) gimple_statement_base { Basic block holding this statement. */ struct basic_block_def *bb; - /* [ WORD 4 ] + /* [ WORD 4-5 ] + Linked lists of gimple statements. The next pointers form + a NULL terminated list, the prev pointers are a cyclic list. + A gimple statement is hence also a double-ended list of + statements, with the pointer itself being the first element, + and the prev pointer being the last. */ + gimple next; + gimple GTY((skip)) prev; + + /* [ WORD 6 ] Lexical block holding this statement. */ tree block; }; @@ -342,10 +225,10 @@ struct GTY(()) gimple_statement_base { struct GTY(()) gimple_statement_with_ops_base { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5-6 ] + /* [ WORD 7-8 ] SSA operand vectors. NOTE: It should be possible to amalgamate these vectors with the operand vector OP. However, the SSA operand vectors are organized differently and contain @@ -359,10 +242,10 @@ struct GTY(()) gimple_statement_with_ops_base struct GTY(()) gimple_statement_with_ops { - /* [ WORD 1-6 ] */ + /* [ WORD 1-8 ] */ struct gimple_statement_with_ops_base opbase; - /* [ WORD 7 ] + /* [ WORD 9 ] Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one. */ @@ -374,10 +257,10 @@ struct GTY(()) gimple_statement_with_ops struct GTY(()) gimple_statement_with_memory_ops_base { - /* [ WORD 1-6 ] */ + /* [ WORD 1-8 ] */ struct gimple_statement_with_ops_base opbase; - /* [ WORD 7-8 ] + /* [ WORD 9-10 ] Virtual operands for this statement. The GC will pick them up via the ssa_names array. */ tree GTY((skip (""))) vdef; @@ -389,10 +272,10 @@ struct GTY(()) gimple_statement_with_memory_ops_base struct GTY(()) gimple_statement_with_memory_ops { - /* [ WORD 1-8 ] */ + /* [ WORD 1-10 ] */ struct gimple_statement_with_memory_ops_base membase; - /* [ WORD 9 ] + /* [ WORD 11 ] Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one. */ @@ -404,20 +287,20 @@ struct GTY(()) gimple_statement_with_memory_ops struct GTY(()) gimple_statement_call { - /* [ WORD 1-8 ] */ + /* [ WORD 1-10 ] */ struct gimple_statement_with_memory_ops_base membase; - /* [ WORD 9-12 ] */ + /* [ WORD 11-14 ] */ struct pt_solution call_used; struct pt_solution call_clobbered; - /* [ WORD 13 ] */ + /* [ WORD 15 ] */ union GTY ((desc ("%1.membase.opbase.gsbase.subcode & GF_CALL_INTERNAL"))) { tree GTY ((tag ("0"))) fntype; enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn; } u; - /* [ WORD 14 ] + /* [ WORD 16 ] Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one. */ @@ -428,10 +311,10 @@ struct GTY(()) gimple_statement_call /* OpenMP statements (#pragma omp). */ struct GTY(()) gimple_statement_omp { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] */ + /* [ WORD 7 ] */ gimple_seq body; }; @@ -439,14 +322,14 @@ struct GTY(()) gimple_statement_omp { /* GIMPLE_BIND */ struct GTY(()) gimple_statement_bind { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] + /* [ WORD 7 ] Variables declared in this scope. */ tree vars; - /* [ WORD 6 ] + /* [ WORD 8 ] This is different than the BLOCK field in gimple_statement_base, which is analogous to TREE_BLOCK (i.e., the lexical block holding this statement). This field is the equivalent of BIND_EXPR_BLOCK @@ -454,7 +337,7 @@ struct GTY(()) gimple_statement_bind { gimple-low.c. */ tree block; - /* [ WORD 7 ] */ + /* [ WORD 9 ] */ gimple_seq body; }; @@ -462,13 +345,13 @@ struct GTY(()) gimple_statement_bind { /* GIMPLE_CATCH */ struct GTY(()) gimple_statement_catch { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] */ + /* [ WORD 7 ] */ tree types; - /* [ WORD 6 ] */ + /* [ WORD 8 ] */ gimple_seq handler; }; @@ -476,14 +359,14 @@ struct GTY(()) gimple_statement_catch { /* GIMPLE_EH_FILTER */ struct GTY(()) gimple_statement_eh_filter { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] + /* [ WORD 7 ] Filter types. */ tree types; - /* [ WORD 6 ] + /* [ WORD 8 ] Failure actions. */ gimple_seq failure; }; @@ -491,37 +374,37 @@ struct GTY(()) gimple_statement_eh_filter { /* GIMPLE_EH_ELSE */ struct GTY(()) gimple_statement_eh_else { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5,6 ] */ + /* [ WORD 7,8 ] */ gimple_seq n_body, e_body; }; /* GIMPLE_EH_MUST_NOT_THROW */ struct GTY(()) gimple_statement_eh_mnt { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] Abort function decl. */ + /* [ WORD 7 ] Abort function decl. */ tree fndecl; }; /* GIMPLE_PHI */ struct GTY(()) gimple_statement_phi { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] */ + /* [ WORD 7 ] */ unsigned capacity; unsigned nargs; - /* [ WORD 6 ] */ + /* [ WORD 8 ] */ tree result; - /* [ WORD 7 ] */ + /* [ WORD 9 ] */ struct phi_arg_d GTY ((length ("%h.nargs"))) args[1]; }; @@ -530,10 +413,10 @@ struct GTY(()) gimple_statement_phi { struct GTY(()) gimple_statement_eh_ctrl { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] + /* [ WORD 7 ] Exception region number. */ int region; }; @@ -542,14 +425,14 @@ struct GTY(()) gimple_statement_eh_ctrl /* GIMPLE_TRY */ struct GTY(()) gimple_statement_try { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] + /* [ WORD 7 ] Expression to evaluate. */ gimple_seq eval; - /* [ WORD 6 ] + /* [ WORD 8 ] Cleanup expression. */ gimple_seq cleanup; }; @@ -571,7 +454,7 @@ enum gimple_try_flags /* GIMPLE_WITH_CLEANUP_EXPR */ struct GTY(()) gimple_statement_wce { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; /* Subcode: CLEANUP_EH_ONLY. True if the cleanup should only be @@ -579,7 +462,7 @@ struct GTY(()) gimple_statement_wce { scope. This flag is analogous to the CLEANUP_EH_ONLY flag in TARGET_EXPRs. */ - /* [ WORD 5 ] + /* [ WORD 7 ] Cleanup expression. */ gimple_seq cleanup; }; @@ -589,21 +472,21 @@ struct GTY(()) gimple_statement_wce { struct GTY(()) gimple_statement_asm { - /* [ WORD 1-8 ] */ + /* [ WORD 1-10 ] */ struct gimple_statement_with_memory_ops_base membase; - /* [ WORD 9 ] + /* [ WORD 11 ] __asm__ statement. */ const char *string; - /* [ WORD 10 ] + /* [ WORD 12 ] Number of inputs, outputs, clobbers, labels. */ unsigned char ni; unsigned char no; unsigned char nc; unsigned char nl; - /* [ WORD 11 ] + /* [ WORD 13 ] Operand vector. NOTE! This must always be the last field of this structure. In particular, this means that this structure cannot be embedded inside another one. */ @@ -613,10 +496,10 @@ struct GTY(()) gimple_statement_asm /* GIMPLE_OMP_CRITICAL */ struct GTY(()) gimple_statement_omp_critical { - /* [ WORD 1-5 ] */ + /* [ WORD 1-7 ] */ struct gimple_statement_omp omp; - /* [ WORD 6 ] + /* [ WORD 8 ] Critical section name. */ tree name; }; @@ -642,20 +525,20 @@ struct GTY(()) gimple_omp_for_iter { /* GIMPLE_OMP_FOR */ struct GTY(()) gimple_statement_omp_for { - /* [ WORD 1-5 ] */ + /* [ WORD 1-7 ] */ struct gimple_statement_omp omp; - /* [ WORD 6 ] */ + /* [ WORD 8 ] */ tree clauses; - /* [ WORD 7 ] + /* [ WORD 9 ] Number of elements in iter array. */ size_t collapse; - /* [ WORD 8 ] */ + /* [ WORD 10 ] */ struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter; - /* [ WORD 9 ] + /* [ WORD 11 ] Pre-body evaluated before the loop body begins. */ gimple_seq pre_body; }; @@ -664,18 +547,18 @@ struct GTY(()) gimple_statement_omp_for { /* GIMPLE_OMP_PARALLEL */ struct GTY(()) gimple_statement_omp_parallel { - /* [ WORD 1-5 ] */ + /* [ WORD 1-7 ] */ struct gimple_statement_omp omp; - /* [ WORD 6 ] + /* [ WORD 8 ] Clauses. */ tree clauses; - /* [ WORD 7 ] + /* [ WORD 9 ] Child function holding the body of the parallel region. */ tree child_fn; - /* [ WORD 8 ] + /* [ WORD 10 ] Shared data argument. */ tree data_arg; }; @@ -684,14 +567,14 @@ struct GTY(()) gimple_statement_omp_parallel { /* GIMPLE_OMP_TASK */ struct GTY(()) gimple_statement_omp_task { - /* [ WORD 1-8 ] */ + /* [ WORD 1-10 ] */ struct gimple_statement_omp_parallel par; - /* [ WORD 9 ] + /* [ WORD 11 ] Child function holding firstprivate initialization if needed. */ tree copy_fn; - /* [ WORD 10-11 ] + /* [ WORD 12-13 ] Size and alignment in bytes of the argument data block. */ tree arg_size; tree arg_align; @@ -705,13 +588,13 @@ struct GTY(()) gimple_statement_omp_task { /* GIMPLE_OMP_SECTIONS */ struct GTY(()) gimple_statement_omp_sections { - /* [ WORD 1-5 ] */ + /* [ WORD 1-7 ] */ struct gimple_statement_omp omp; - /* [ WORD 6 ] */ + /* [ WORD 8 ] */ tree clauses; - /* [ WORD 7 ] + /* [ WORD 9 ] The control variable used for deciding which of the sections to execute. */ tree control; @@ -723,23 +606,23 @@ struct GTY(()) gimple_statement_omp_sections { do not need the body field. */ struct GTY(()) gimple_statement_omp_continue { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] */ + /* [ WORD 7 ] */ tree control_def; - /* [ WORD 6 ] */ + /* [ WORD 8 ] */ tree control_use; }; /* GIMPLE_OMP_SINGLE */ struct GTY(()) gimple_statement_omp_single { - /* [ WORD 1-5 ] */ + /* [ WORD 1-7 ] */ struct gimple_statement_omp omp; - /* [ WORD 6 ] */ + /* [ WORD 7 ] */ tree clauses; }; @@ -749,10 +632,10 @@ struct GTY(()) gimple_statement_omp_single { contains a sequence, which we don't need here. */ struct GTY(()) gimple_statement_omp_atomic_load { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5-6 ] */ + /* [ WORD 7-8 ] */ tree rhs, lhs; }; @@ -760,10 +643,10 @@ struct GTY(()) gimple_statement_omp_atomic_load { See note on GIMPLE_OMP_ATOMIC_LOAD. */ struct GTY(()) gimple_statement_omp_atomic_store { - /* [ WORD 1-4 ] */ + /* [ WORD 1-6 ] */ struct gimple_statement_base gsbase; - /* [ WORD 5 ] */ + /* [ WORD 7 ] */ tree val; }; @@ -815,7 +698,8 @@ enum gimple_statement_structure_enum { /* Define the overall contents of a gimple tuple. It may be any of the structures declared above for various types of tuples. */ -union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d { +union GTY ((desc ("gimple_statement_structure (&%h)"), + chain_next ("%h.gsbase.next"), variable_size)) gimple_statement_d { struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase; struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops; struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase; @@ -1136,6 +1020,115 @@ extern tree tree_ssa_strip_useless_type_conversions (tree); extern bool useless_type_conversion_p (tree, tree); extern bool types_compatible_p (tree, tree); +/* Return the first node in GIMPLE sequence S. */ + +static inline gimple_seq_node +gimple_seq_first (const_gimple_seq s) +{ + return s; +} + + +/* Return the first statement in GIMPLE sequence S. */ + +static inline gimple +gimple_seq_first_stmt (const_gimple_seq s) +{ + gimple_seq_node n = gimple_seq_first (s); + return n; +} + + +/* Return the last node in GIMPLE sequence S. */ + +static inline gimple_seq_node +gimple_seq_last (const_gimple_seq s) +{ + return s ? s->gsbase.prev : NULL; +} + + +/* Return the last statement in GIMPLE sequence S. */ + +static inline gimple +gimple_seq_last_stmt (const_gimple_seq s) +{ + gimple_seq_node n = gimple_seq_last (s); + return n; +} + + +/* Set the last node in GIMPLE sequence *PS to LAST. */ + +static inline void +gimple_seq_set_last (gimple_seq *ps, gimple_seq_node last) +{ + (*ps)->gsbase.prev = last; +} + + +/* Set the first node in GIMPLE sequence *PS to FIRST. */ + +static inline void +gimple_seq_set_first (gimple_seq *ps, gimple_seq_node first) +{ + *ps = first; +} + + +/* Return true if GIMPLE sequence S is empty. */ + +static inline bool +gimple_seq_empty_p (const_gimple_seq s) +{ + return s == NULL; +} + + +void gimple_seq_add_stmt (gimple_seq *, gimple); + +/* Link gimple statement GS to the end of the sequence *SEQ_P. If + *SEQ_P is NULL, a new sequence is allocated. This function is + similar to gimple_seq_add_stmt, but does not scan the operands. + During gimplification, we need to manipulate statement sequences + before the def/use vectors have been constructed. */ +void gimple_seq_add_stmt_without_update (gimple_seq *, gimple); + +/* Allocate a new sequence and initialize its first element with STMT. */ + +static inline gimple_seq +gimple_seq_alloc_with_stmt (gimple stmt) +{ + gimple_seq seq = NULL; + gimple_seq_add_stmt (&seq, stmt); + return seq; +} + + +/* Returns the sequence of statements in BB. */ + +static inline gimple_seq +bb_seq (const_basic_block bb) +{ + return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL; +} + +static inline gimple_seq * +bb_seq_addr (const_basic_block bb) +{ + return (!(bb->flags & BB_RTL) && bb->il.gimple) ? &bb->il.gimple->seq : NULL; +} + +/* Sets the sequence of statements in BB to SEQ. */ + +static inline void +set_bb_seq (basic_block bb, gimple_seq seq) +{ + gcc_checking_assert (!(bb->flags & BB_RTL)); + bb->il.gimple->seq = seq; +} + + /* Return the code for GIMPLE statement G. */ static inline enum gimple_code @@ -1358,6 +1351,16 @@ gimple_uid (const_gimple g) } +/* Make statement G a singleton sequence. */ + +static inline void +gimple_init_singleton (gimple g) +{ + g->gsbase.next = NULL; + g->gsbase.prev = g; +} + + /* Return true if GIMPLE statement G has register or memory operands. */ static inline bool @@ -2819,13 +2822,19 @@ gimple_bind_append_vars (gimple gs, tree vars) } +static inline gimple_seq * +gimple_bind_body_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_BIND); + return &gs->gimple_bind.body; +} + /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS. */ static inline gimple_seq gimple_bind_body (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_BIND); - return gs->gimple_bind.body; + return *gimple_bind_body_ptr (gs); } @@ -3108,17 +3117,6 @@ gimple_catch_types_ptr (gimple gs) } -/* Return the GIMPLE sequence representing the body of the handler of - GIMPLE_CATCH statement GS. */ - -static inline gimple_seq -gimple_catch_handler (gimple gs) -{ - GIMPLE_CHECK (gs, GIMPLE_CATCH); - return gs->gimple_catch.handler; -} - - /* Return a pointer to the GIMPLE sequence representing the body of the handler of GIMPLE_CATCH statement GS. */ @@ -3130,6 +3128,16 @@ gimple_catch_handler_ptr (gimple gs) } +/* Return the GIMPLE sequence representing the body of the handler of + GIMPLE_CATCH statement GS. */ + +static inline gimple_seq +gimple_catch_handler (gimple gs) +{ + return *gimple_catch_handler_ptr (gs); +} + + /* Set T to be the set of types handled by GIMPLE_CATCH GS. */ static inline void @@ -3171,14 +3179,24 @@ gimple_eh_filter_types_ptr (gimple gs) } +/* Return a pointer to the sequence of statement to execute when + GIMPLE_EH_FILTER statement fails. */ + +static inline gimple_seq * +gimple_eh_filter_failure_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); + return &gs->gimple_eh_filter.failure; +} + + /* Return the sequence of statement to execute when GIMPLE_EH_FILTER statement fails. */ static inline gimple_seq gimple_eh_filter_failure (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_EH_FILTER); - return gs->gimple_eh_filter.failure; + return *gimple_eh_filter_failure_ptr (gs); } @@ -3222,18 +3240,30 @@ gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl) /* GIMPLE_EH_ELSE accessors. */ +static inline gimple_seq * +gimple_eh_else_n_body_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_EH_ELSE); + return &gs->gimple_eh_else.n_body; +} + static inline gimple_seq gimple_eh_else_n_body (gimple gs) { + return *gimple_eh_else_n_body_ptr (gs); +} + +static inline gimple_seq * +gimple_eh_else_e_body_ptr (gimple gs) +{ GIMPLE_CHECK (gs, GIMPLE_EH_ELSE); - return gs->gimple_eh_else.n_body; + return &gs->gimple_eh_else.e_body; } static inline gimple_seq gimple_eh_else_e_body (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_EH_ELSE); - return gs->gimple_eh_else.e_body; + return *gimple_eh_else_e_body_ptr (gs); } static inline void @@ -3286,13 +3316,34 @@ gimple_try_catch_is_cleanup (const_gimple gs) } +/* Return a pointer to the sequence of statements used as the + body for GIMPLE_TRY GS. */ + +static inline gimple_seq * +gimple_try_eval_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_TRY); + return &gs->gimple_try.eval; +} + + /* Return the sequence of statements used as the body for GIMPLE_TRY GS. */ static inline gimple_seq gimple_try_eval (gimple gs) { + return *gimple_try_eval_ptr (gs); +} + + +/* Return a pointer to the sequence of statements used as the cleanup body for + GIMPLE_TRY GS. */ + +static inline gimple_seq * +gimple_try_cleanup_ptr (gimple gs) +{ GIMPLE_CHECK (gs, GIMPLE_TRY); - return gs->gimple_try.eval; + return &gs->gimple_try.cleanup; } @@ -3302,8 +3353,7 @@ gimple_try_eval (gimple gs) static inline gimple_seq gimple_try_cleanup (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_TRY); - return gs->gimple_try.cleanup; + return *gimple_try_cleanup_ptr (gs); } @@ -3342,13 +3392,22 @@ gimple_try_set_cleanup (gimple gs, gimple_seq cleanup) } +/* Return a pointer to the cleanup sequence for cleanup statement GS. */ + +static inline gimple_seq * +gimple_wce_cleanup_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); + return &gs->gimple_wce.cleanup; +} + + /* Return the cleanup sequence for cleanup statement GS. */ static inline gimple_seq gimple_wce_cleanup (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR); - return gs->gimple_wce.cleanup; + return *gimple_wce_cleanup_ptr (gs); } @@ -3747,12 +3806,20 @@ gimple_debug_source_bind_set_value (gimple dbg, tree value) gimple_set_op (dbg, 1, value); } +/* Return a pointer to the body for the OMP statement GS. */ + +static inline gimple_seq * +gimple_omp_body_ptr (gimple gs) +{ + return &gs->omp.body; +} + /* Return the body for the OMP statement GS. */ static inline gimple_seq gimple_omp_body (gimple gs) { - return gs->omp.body; + return *gimple_omp_body_ptr (gs); } /* Set BODY to be the body for the OMP statement GS. */ @@ -3966,14 +4033,24 @@ gimple_omp_for_set_incr (gimple gs, size_t i, tree incr) } +/* Return a pointer to the sequence of statements to execute before the OMP_FOR + statement GS starts. */ + +static inline gimple_seq * +gimple_omp_for_pre_body_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); + return &gs->gimple_omp_for.pre_body; +} + + /* Return the sequence of statements to execute before the OMP_FOR statement GS starts. */ static inline gimple_seq gimple_omp_for_pre_body (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_OMP_FOR); - return gs->gimple_omp_for.pre_body; + return *gimple_omp_for_pre_body_ptr (gs); } @@ -4627,13 +4704,21 @@ gimple_omp_continue_set_control_use (gimple g, tree use) g->gimple_omp_continue.control_use = use; } +/* Return a pointer to the body for the GIMPLE_TRANSACTION statement GS. */ + +static inline gimple_seq * +gimple_transaction_body_ptr (gimple gs) +{ + GIMPLE_CHECK (gs, GIMPLE_TRANSACTION); + return &gs->gimple_transaction.body; +} + /* Return the body for the GIMPLE_TRANSACTION statement GS. */ static inline gimple_seq gimple_transaction_body (gimple gs) { - GIMPLE_CHECK (gs, GIMPLE_TRANSACTION); - return gs->gimple_transaction.body; + return *gimple_transaction_body_ptr (gs); } /* Return the label associated with a GIMPLE_TRANSACTION. */ @@ -4858,17 +4943,28 @@ is_gimple_reg_type (tree type) /* Return a new iterator pointing to GIMPLE_SEQ's first statement. */ static inline gimple_stmt_iterator -gsi_start (gimple_seq seq) +gsi_start_1 (gimple_seq *seq) { gimple_stmt_iterator i; - i.ptr = gimple_seq_first (seq); + i.ptr = gimple_seq_first (*seq); i.seq = seq; - i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL; + i.bb = i.ptr ? gimple_bb (i.ptr) : NULL; return i; } +#define gsi_start(x) gsi_start_1(&(x)) + +static inline gimple_stmt_iterator +gsi_none (void) +{ + gimple_stmt_iterator i; + i.ptr = NULL; + i.seq = NULL; + i.bb = NULL; + return i; +} /* Return a new iterator pointing to the first statement in basic block BB. */ @@ -4876,12 +4972,23 @@ static inline gimple_stmt_iterator gsi_start_bb (basic_block bb) { gimple_stmt_iterator i; - gimple_seq seq; + gimple_seq *seq; - seq = bb_seq (bb); - i.ptr = gimple_seq_first (seq); - i.seq = seq; - i.bb = bb; + seq = bb_seq_addr (bb); + if (!seq) + /* XXX Only necessary because of ENTRY/EXIT block which don't have + il.gimple */ + { + i.ptr = NULL; + i.seq = NULL; + i.bb = NULL; + } + else + { + i.ptr = gimple_seq_first (*seq); + i.seq = seq; + i.bb = bb; + } return i; } @@ -4890,17 +4997,18 @@ gsi_start_bb (basic_block bb) /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */ static inline gimple_stmt_iterator -gsi_last (gimple_seq seq) +gsi_last_1 (gimple_seq *seq) { gimple_stmt_iterator i; - i.ptr = gimple_seq_last (seq); + i.ptr = gimple_seq_last (*seq); i.seq = seq; - i.bb = (i.ptr && i.ptr->stmt) ? gimple_bb (i.ptr->stmt) : NULL; + i.bb = i.ptr ? gimple_bb (i.ptr) : NULL; return i; } +#define gsi_last(x) gsi_last_1(&(x)) /* Return a new iterator pointing to the last statement in basic block BB. */ @@ -4908,12 +5016,23 @@ static inline gimple_stmt_iterator gsi_last_bb (basic_block bb) { gimple_stmt_iterator i; - gimple_seq seq; + gimple_seq *seq; - seq = bb_seq (bb); - i.ptr = gimple_seq_last (seq); - i.seq = seq; - i.bb = bb; + seq = bb_seq_addr (bb); + if (!seq) + /* XXX Only necessary because of ENTRY/EXIT block which don't have + il.gimple */ + { + i.ptr = NULL; + i.seq = NULL; + i.bb = NULL; + } + else + { + i.ptr = gimple_seq_last (*seq); + i.seq = seq; + i.bb = bb; + } return i; } @@ -4933,7 +5052,7 @@ gsi_end_p (gimple_stmt_iterator i) static inline bool gsi_one_before_end_p (gimple_stmt_iterator i) { - return i.ptr != NULL && i.ptr->next == NULL; + return i.ptr != NULL && i.ptr->gsbase.next == NULL; } @@ -4942,7 +5061,7 @@ gsi_one_before_end_p (gimple_stmt_iterator i) static inline void gsi_next (gimple_stmt_iterator *i) { - i->ptr = i->ptr->next; + i->ptr = i->ptr->gsbase.next; } /* Advance the iterator to the previous gimple statement. */ @@ -4950,7 +5069,11 @@ gsi_next (gimple_stmt_iterator *i) static inline void gsi_prev (gimple_stmt_iterator *i) { - i->ptr = i->ptr->prev; + gimple prev = i->ptr->gsbase.prev; + if (prev->gsbase.next) + i->ptr = prev; + else + i->ptr = NULL; } /* Return the current stmt. */ @@ -4958,7 +5081,7 @@ gsi_prev (gimple_stmt_iterator *i) static inline gimple gsi_stmt (gimple_stmt_iterator i) { - return i.ptr->stmt; + return i.ptr; } /* Return a block statement iterator that points to the first non-label @@ -5027,18 +5150,6 @@ gsi_last_nondebug_bb (basic_block bb) return i; } -/* Return a pointer to the current stmt. - - NOTE: You may want to use gsi_replace on the iterator itself, - as this performs additional bookkeeping that will not be done - if you simply assign through a pointer returned by gsi_stmt_ptr. */ - -static inline gimple * -gsi_stmt_ptr (gimple_stmt_iterator *i) -{ - return &i->ptr->stmt; -} - /* Return the basic block associated with this iterator. */ @@ -5054,7 +5165,7 @@ gsi_bb (gimple_stmt_iterator i) static inline gimple_seq gsi_seq (gimple_stmt_iterator i) { - return i.seq; + return *i.seq; } @@ -5071,8 +5182,10 @@ enum gsi_iterator_update /* In gimple-iterator.c */ gimple_stmt_iterator gsi_start_phis (basic_block); gimple_seq gsi_split_seq_after (gimple_stmt_iterator); -gimple_seq gsi_split_seq_before (gimple_stmt_iterator *); +void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *); +void gsi_set_stmt (gimple_stmt_iterator *, gimple); void gsi_replace (gimple_stmt_iterator *, gimple, bool); +void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool); void gsi_insert_before (gimple_stmt_iterator *, gimple, enum gsi_iterator_update); void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple, @@ -5167,6 +5280,8 @@ typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *, gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn, struct walk_stmt_info *); +gimple walk_gimple_seq_mod (gimple_seq *, walk_stmt_fn, walk_tree_fn, + struct walk_stmt_info *); tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn, struct walk_stmt_info *); tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *); @@ -5179,7 +5294,6 @@ enum gimple_alloc_kind gimple_alloc_kind_assign, /* Assignments. */ gimple_alloc_kind_phi, /* PHI nodes. */ gimple_alloc_kind_cond, /* Conditionals. */ - gimple_alloc_kind_seq, /* Sequences. */ gimple_alloc_kind_rest, /* Everything else. */ gimple_alloc_kind_all }; |