diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-09 15:57:43 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-09 15:57:43 +0000 |
commit | eacbf1cd3aff3dbf47a71dc7fdb1d01dce8e777e (patch) | |
tree | 1bfb594134ffebca206d3ed2fe55693634759c1d /gcc/final.c | |
parent | 11fd42e7594bdb9c8d9cf10f9924cb8644752b78 (diff) | |
download | gcc-eacbf1cd3aff3dbf47a71dc7fdb1d01dce8e777e.tar.gz |
2013-09-09 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 202389 using svnmerge.py; notice
that gcc/melt/xtramelt-ana-base.melt has been significantly
updated, but some updates are yet missing...
[gcc/]
2013-09-09 Basile Starynkevitch <basile@starynkevitch.net>
{{When merging trunk GCC 4.9 with C++ passes}}
* melt/xtramelt-ana-base.melt: Add GCC 4.9 specific code, still
incomplete, for classy passes.... Only Gimple passes are yet possible...
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@202408 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/final.c')
-rw-r--r-- | gcc/final.c | 291 |
1 files changed, 201 insertions, 90 deletions
diff --git a/gcc/final.c b/gcc/final.c index d9b4408aadf..d1c8d7c77fb 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -795,26 +795,90 @@ compute_alignments (void) return 0; } -struct rtl_opt_pass pass_compute_alignments = +/* Grow the LABEL_ALIGN array after new labels are created. */ + +static void +grow_label_align (void) +{ + int old = max_labelno; + int n_labels; + int n_old_labels; + + max_labelno = max_label_num (); + + n_labels = max_labelno - min_labelno + 1; + n_old_labels = old - min_labelno + 1; + + label_align = XRESIZEVEC (struct label_alignment, label_align, n_labels); + + /* Range of labels grows monotonically in the function. Failing here + means that the initialization of array got lost. */ + gcc_assert (n_old_labels <= n_labels); + + memset (label_align + n_old_labels, 0, + (n_labels - n_old_labels) * sizeof (struct label_alignment)); +} + +/* Update the already computed alignment information. LABEL_PAIRS is a vector + made up of pairs of labels for which the alignment information of the first + element will be copied from that of the second element. */ + +void +update_alignments (vec<rtx> &label_pairs) { - { - RTL_PASS, - "alignments", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - NULL, /* gate */ - compute_alignments, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - TODO_verify_rtl_sharing /* todo_flags_finish */ - } + unsigned int i = 0; + rtx iter, label; + + if (max_labelno != max_label_num ()) + grow_label_align (); + + FOR_EACH_VEC_ELT (label_pairs, i, iter) + if (i & 1) + { + LABEL_TO_ALIGNMENT (label) = LABEL_TO_ALIGNMENT (iter); + LABEL_TO_MAX_SKIP (label) = LABEL_TO_MAX_SKIP (iter); + } + else + label = iter; +} + +namespace { + +const pass_data pass_data_compute_alignments = +{ + RTL_PASS, /* type */ + "alignments", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + false, /* has_gate */ + true, /* has_execute */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_verify_rtl_sharing, /* todo_flags_finish */ }; +class pass_compute_alignments : public rtl_opt_pass +{ +public: + pass_compute_alignments(gcc::context *ctxt) + : rtl_opt_pass(pass_data_compute_alignments, ctxt) + {} + + /* opt_pass methods: */ + unsigned int execute () { return compute_alignments (); } + +}; // class pass_compute_alignments + +} // anon namespace + +rtl_opt_pass * +make_pass_compute_alignments (gcc::context *ctxt) +{ + return new pass_compute_alignments (ctxt); +} + /* Make a pass over all insns and compute their actual lengths by shortening any branches of variable length if possible. */ @@ -852,25 +916,7 @@ shorten_branches (rtx first) uid_shuid = XNEWVEC (int, max_uid); if (max_labelno != max_label_num ()) - { - int old = max_labelno; - int n_labels; - int n_old_labels; - - max_labelno = max_label_num (); - - n_labels = max_labelno - min_labelno + 1; - n_old_labels = old - min_labelno + 1; - - label_align = XRESIZEVEC (struct label_alignment, label_align, n_labels); - - /* Range of labels grows monotonically in the function. Failing here - means that the initialization of array got lost. */ - gcc_assert (n_old_labels <= n_labels); - - memset (label_align + n_old_labels, 0, - (n_labels - n_old_labels) * sizeof (struct label_alignment)); - } + grow_label_align (); /* Initialize label_align and set up uid_shuid to be strictly monotonically rising with insn order. */ @@ -1604,12 +1650,26 @@ reemit_insn_block_notes (void) rtx insn, note; insn = get_insns (); - if (!active_insn_p (insn)) - insn = next_active_insn (insn); - for (; insn; insn = next_active_insn (insn)) + for (; insn; insn = NEXT_INSN (insn)) { tree this_block; + /* Prevent lexical blocks from straddling section boundaries. */ + if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_SWITCH_TEXT_SECTIONS) + { + for (tree s = cur_block; s != DECL_INITIAL (cfun->decl); + s = BLOCK_SUPERCONTEXT (s)) + { + rtx note = emit_note_before (NOTE_INSN_BLOCK_END, insn); + NOTE_BLOCK (note) = s; + note = emit_note_after (NOTE_INSN_BLOCK_BEG, insn); + NOTE_BLOCK (note) = s; + } + } + + if (!active_insn_p (insn)) + continue; + /* Avoid putting scope notes between jump table and its label. */ if (JUMP_TABLE_DATA_P (insn)) continue; @@ -4409,26 +4469,43 @@ rest_of_handle_final (void) return 0; } -struct rtl_opt_pass pass_final = +namespace { + +const pass_data pass_data_final = { - { - RTL_PASS, - "final", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - NULL, /* gate */ - rest_of_handle_final, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_FINAL, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ - } + RTL_PASS, /* type */ + "final", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + false, /* has_gate */ + true, /* has_execute */ + TV_FINAL, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ }; +class pass_final : public rtl_opt_pass +{ +public: + pass_final(gcc::context *ctxt) + : rtl_opt_pass(pass_data_final, ctxt) + {} + + /* opt_pass methods: */ + unsigned int execute () { return rest_of_handle_final (); } + +}; // class pass_final + +} // anon namespace + +rtl_opt_pass * +make_pass_final (gcc::context *ctxt) +{ + return new pass_final (ctxt); +} + static unsigned int rest_of_handle_shorten_branches (void) @@ -4438,26 +4515,43 @@ rest_of_handle_shorten_branches (void) return 0; } -struct rtl_opt_pass pass_shorten_branches = +namespace { + +const pass_data pass_data_shorten_branches = { - { - RTL_PASS, - "shorten", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - NULL, /* gate */ - rest_of_handle_shorten_branches, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_SHORTEN_BRANCH, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ - } + RTL_PASS, /* type */ + "shorten", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + false, /* has_gate */ + true, /* has_execute */ + TV_SHORTEN_BRANCH, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ }; +class pass_shorten_branches : public rtl_opt_pass +{ +public: + pass_shorten_branches(gcc::context *ctxt) + : rtl_opt_pass(pass_data_shorten_branches, ctxt) + {} + + /* opt_pass methods: */ + unsigned int execute () { return rest_of_handle_shorten_branches (); } + +}; // class pass_shorten_branches + +} // anon namespace + +rtl_opt_pass * +make_pass_shorten_branches (gcc::context *ctxt) +{ + return new pass_shorten_branches (ctxt); +} + static unsigned int rest_of_clean_state (void) @@ -4585,22 +4679,39 @@ rest_of_clean_state (void) return 0; } -struct rtl_opt_pass pass_clean_state = +namespace { + +const pass_data pass_data_clean_state = { - { - RTL_PASS, - "*clean_state", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - NULL, /* gate */ - rest_of_clean_state, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_FINAL, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - PROP_rtl, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ - } + RTL_PASS, /* type */ + "*clean_state", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + false, /* has_gate */ + true, /* has_execute */ + TV_FINAL, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + PROP_rtl, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ }; + +class pass_clean_state : public rtl_opt_pass +{ +public: + pass_clean_state(gcc::context *ctxt) + : rtl_opt_pass(pass_data_clean_state, ctxt) + {} + + /* opt_pass methods: */ + unsigned int execute () { return rest_of_clean_state (); } + +}; // class pass_clean_state + +} // anon namespace + +rtl_opt_pass * +make_pass_clean_state (gcc::context *ctxt) +{ + return new pass_clean_state (ctxt); +} |