5368224f42
gcc: 2012-09-19 Dehao Chen <dehao@google.com> * toplev.c (general_init): Init block_locations. * tree.c (tree_set_block): New. (tree_block): Change to use LOCATION_BLOCK. * tree.h (TREE_SET_BLOCK): New. * final.c (reemit_insn_block_notes): Change to use LOCATION_BLOCK. (final_start_function): Likewise. * input.c (expand_location_1): Likewise. * input.h (LOCATION_LOCUS): New. (LOCATION_BLOCK): New. (IS_UNKNOWN_LOCATION): New. * fold-const.c (expr_location_or): Change to use new location. * reorg.c (emit_delay_sequence): Likewise. (try_merge_delay_insns): Likewise. * modulo-sched.c (dump_insn_location): Likewise. * lto-streamer-out.c (lto_output_location_bitpack): Likewise. * lto-cgraph.c (output_node_opt_summary): Likewise. * jump.c (rtx_renumbered_equal_p): Likewise. * ifcvt.c (noce_try_move): Likewise. (noce_try_store_flag): Likewise. (noce_try_store_flag_constants): Likewise. (noce_try_addcc): Likewise. (noce_try_store_flag_mask): Likewise. (noce_try_cmove): Likewise. (noce_try_cmove_arith): Likewise. (noce_try_minmax): Likewise. (noce_try_abs): Likewise. (noce_try_sign_mask): Likewise. (noce_try_bitop): Likewise. (noce_process_if_block): Likewise. (cond_move_process_if_block): Likewise. (find_cond_trap): Likewise. * ipa-prop.c (ipa_set_jf_constant): Likewise. (ipa_write_jump_function): Likewise. * dwarf2out.c (add_src_coords_attributes): Likewise. * expr.c (expand_expr_real): Likewise. * tree-parloops.c (create_loop_fn): Likewise. * recog.c (peep2_attempt): Likewise. * function.c (free_after_compilation): Likewise. (expand_function_end): Likewise. (set_insn_locations): Likewise. (thread_prologue_and_epilogue_insns): Likewise. * print-rtl.c (print_rtx): Likewise. * profile.c (branch_prob): Likewise. * trans-mem.c (ipa_tm_scan_irr_block): Likewise. * gimplify.c (gimplify_call_expr): Likewise. * except.c (duplicate_eh_regions_1): Likewise. * emit-rtl.c (try_split): Likewise. (make_insn_raw): Likewise. (make_debug_insn_raw): Likewise. (make_jump_insn_raw): Likewise. (make_call_insn_raw): Likewise. (emit_pattern_after_setloc): Likewise. (emit_pattern_after): Likewise. (emit_debug_insn_after): Likewise. (emit_pattern_before): Likewise. (emit_insn_before_setloc): Likewise. (emit_jump_insn_before): Likewise. (emit_call_insn_before_setloc): Likewise. (emit_call_insn_before): Likeise. (emit_debug_insn_before_setloc): Likewise. (emit_copy_of_insn_after): Likewise. (insn_locators_alloc): Remove. (insn_locators_finalize): Remove. (insn_locators_free): Remove. (set_curr_insn_source_location): Remove. (get_curr_insn_source_location): Remove. (set_curr_insn_block): Remove. (get_curr_insn_block): Remove. (locator_scope): Remove. (insn_scope): Change to use new location. (locator_location): Remove. (insn_line): Change to use new location. (locator_file): Remove. (insn_file): Change to use new location. (locator_eq): Remove. (insn_locations_init): New. (insn_locations_finalize): New. (set_curr_insn_location): New. (curr_insn_location): New. * cfgexpand.c (gimple_assign_rhs_to_tree): Change to use new location. (expand_gimple_cond): Likewise. (expand_call_stmt): Likewise. (expand_gimple_stmt_1): Likewise. (expand_gimple_basic_block): Likewise. (construct_exit_block): Likewise. (gimple_expand_cfg): Likewise. * cfgcleanup.c (try_forward_edges): Likewise. * tree-ssa-live.c (remove_unused_scope_block_p): Likewise. (dump_scope_block): Likewise. (remove_unused_locals): Likewise. * rtl.c (rtx_equal_p_cb): Likewise. (rtx_equal_p): Likewise. * rtl.h (XUINT): New. (INSN_LOCATOR): Remove. (CURR_INSN_LOCATION): Remove. (INSN_LOCATION): New. (INSN_HAS_LOCATION): New. * tree-inline.c (remap_gimple_op_r): Change to use new location. (copy_tree_body_r): Likewise. (copy_phis_for_bb): Likewise. (expand_call_inline): Likewise. * tree-streamer-in.c (lto_input_ts_exp_tree_pointers): Likewise. * tree-streamer-out.c (write_ts_decl_minimal_tree_pointers): Likewise. * gimple-streamer-out.c (output_gimple_stmt): Likewise. * combine.c (try_combine): Likewise. * tree-outof-ssa.c (set_location_for_edge): Likewise. (insert_partition_copy_on_edge): Likewise. (insert_value_copy_on_edge): Likewise. (insert_rtx_to_part_on_edge): Likewise. (insert_part_to_rtx_on_edge): Likewise. * basic-block.h (edge_def): Remove field. * gimple.h (gimple_statement_base): Remove field. (gimple_bb): Change to use new location. (gimple_set_block): Likewise. (gimple_has_location): Likewise. * tree-cfg.c (make_cond_expr_edges): Likewise. (make_goto_expr_edges): Likewise. (gimple_can_merge_blocks_p): Likewise. (move_stmt_op): Likewise. (move_block_to_fn): Likewise. * config/alpha/alpha.c (alpha_output_mi_thunk_osf): Likewise. * config/sparc/sparc.c (sparc_output_mi_thunk): Likewise. * config/i386/i386.c (x86_output_mi_thunk): Likewise. * config/tilegx/tilegx.c (tilegx_output_mi_thunk): Likewise. * config/sh/sh.c (sh_output_mi_thunk): Likewise. * config/ia64/ia64.c (ia64_output_mi_thunk): Likewise. * config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise. * config/score/score.c (score_output_mi_thunk): Likewise. * config/tilepro/tilepro.c (tilepro_asm_output_mi_thunk): Likewise. * config/mips/mips.c (mips_output_mi_thunk): Likewise. * cfgrtl.c (unique_locus_on_edge_between_p): Likewise. (unique_locus_on_edge_between_p): Likewise. (emit_nop_for_unique_locus_between): Likewise. (force_nonfallthru_and_redirect): Likewise. (fixup_reorder_chain): Likewise. (cfg_layout_merge_blocks): Likewise. * stmt.c (emit_case_nodes): Likewise. gcc/lto: 2012-09-19 Dehao Chen <dehao@google.com> * lto/lto.c (lto_fixup_prevailing_decls): Remove tree.exp.block field. libcpp: 2012-09-19 Dehao Chen <dehao@google.com> * include/line-map.h (MAX_SOURCE_LOCATION): New value. (location_adhoc_data_fini): New. (get_combined_adhoc_loc): New. (get_data_from_adhoc_loc): New. (get_location_from_adhoc_loc): New. (location_adhoc_data_map): New. (COMBINE_LOCATION_DATA): New. (IS_ADHOC_LOC): New. (expanded_location): New field. (line_maps): New field. * line-map.c (location_adhoc_data): New. (location_adhoc_data_hash): New. (location_adhoc_data_eq): New. (location_adhoc_data_update): New. (get_combined_adhoc_loc): New. (get_data_from_adhoc_loc): New. (get_location_from_adhoc_loc): New. (location_adhoc_data_init): New. (location_adhoc_data_fini): New. (linemap_init): Initialize location_adhoc_data. (linemap_lookup): Change to use new location. (linemap_ordinary_map_lookup): Likewise. (linemap_macro_map_lookup): Likewise. (linemap_macro_map_loc_to_def_point): Likewise. (linemap_macro_map_loc_unwind_toward_spel): Likewise. (linemap_get_expansion_line): Likewise. (linemap_get_expansion_filename): Likewise. (linemap_location_in_system_header_p): Likewise. (linemap_location_from_macro_expansion_p): Likewise. (linemap_macro_loc_to_spelling_point): Likewise. (linemap_macro_loc_to_def_point): Likewise. (linemap_macro_loc_to_exp_point): Likewise. (linemap_resolve_location): Likewise. (linemap_unwind_toward_expansion): Likewise. (linemap_unwind_to_first_non_reserved_loc): Likewise. (linemap_expand_location): Likewise. (linemap_dump_location): Likewise. (linemap_line_start): Likewise. From-SVN: r191494
220 lines
6.3 KiB
C
220 lines
6.3 KiB
C
/* Routines for emitting GIMPLE to a file stream.
|
|
|
|
Copyright 2011 Free Software Foundation, Inc.
|
|
Contributed by Diego Novillo <dnovillo@google.com>
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include "config.h"
|
|
#include "system.h"
|
|
#include "coretypes.h"
|
|
#include "tree.h"
|
|
#include "tree-flow.h"
|
|
#include "data-streamer.h"
|
|
#include "gimple-streamer.h"
|
|
#include "lto-streamer.h"
|
|
#include "tree-streamer.h"
|
|
|
|
/* Output PHI function PHI to the main stream in OB. */
|
|
|
|
static void
|
|
output_phi (struct output_block *ob, gimple phi)
|
|
{
|
|
unsigned i, len = gimple_phi_num_args (phi);
|
|
|
|
streamer_write_record_start (ob, lto_gimple_code_to_tag (GIMPLE_PHI));
|
|
streamer_write_uhwi (ob, SSA_NAME_VERSION (PHI_RESULT (phi)));
|
|
|
|
for (i = 0; i < len; i++)
|
|
{
|
|
stream_write_tree (ob, gimple_phi_arg_def (phi, i), true);
|
|
streamer_write_uhwi (ob, gimple_phi_arg_edge (phi, i)->src->index);
|
|
lto_output_location (ob, gimple_phi_arg_location (phi, i));
|
|
}
|
|
}
|
|
|
|
|
|
/* Emit statement STMT on the main stream of output block OB. */
|
|
|
|
static void
|
|
output_gimple_stmt (struct output_block *ob, gimple stmt)
|
|
{
|
|
unsigned i;
|
|
enum gimple_code code;
|
|
enum LTO_tags tag;
|
|
struct bitpack_d bp;
|
|
|
|
/* Emit identifying tag. */
|
|
code = gimple_code (stmt);
|
|
tag = lto_gimple_code_to_tag (code);
|
|
streamer_write_record_start (ob, tag);
|
|
|
|
/* Emit the tuple header. */
|
|
bp = bitpack_create (ob->main_stream);
|
|
bp_pack_var_len_unsigned (&bp, gimple_num_ops (stmt));
|
|
bp_pack_value (&bp, gimple_no_warning_p (stmt), 1);
|
|
if (is_gimple_assign (stmt))
|
|
bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1);
|
|
bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1);
|
|
bp_pack_var_len_unsigned (&bp, stmt->gsbase.subcode);
|
|
streamer_write_bitpack (&bp);
|
|
|
|
/* Emit location information for the statement. */
|
|
lto_output_location (ob, LOCATION_LOCUS (gimple_location (stmt)));
|
|
|
|
/* Emit the lexical block holding STMT. */
|
|
stream_write_tree (ob, gimple_block (stmt), true);
|
|
|
|
/* Emit the operands. */
|
|
switch (gimple_code (stmt))
|
|
{
|
|
case GIMPLE_RESX:
|
|
streamer_write_hwi (ob, gimple_resx_region (stmt));
|
|
break;
|
|
|
|
case GIMPLE_EH_MUST_NOT_THROW:
|
|
stream_write_tree (ob, gimple_eh_must_not_throw_fndecl (stmt), true);
|
|
break;
|
|
|
|
case GIMPLE_EH_DISPATCH:
|
|
streamer_write_hwi (ob, gimple_eh_dispatch_region (stmt));
|
|
break;
|
|
|
|
case GIMPLE_ASM:
|
|
streamer_write_uhwi (ob, gimple_asm_ninputs (stmt));
|
|
streamer_write_uhwi (ob, gimple_asm_noutputs (stmt));
|
|
streamer_write_uhwi (ob, gimple_asm_nclobbers (stmt));
|
|
streamer_write_uhwi (ob, gimple_asm_nlabels (stmt));
|
|
streamer_write_string (ob, ob->main_stream, gimple_asm_string (stmt),
|
|
true);
|
|
/* Fallthru */
|
|
|
|
case GIMPLE_ASSIGN:
|
|
case GIMPLE_CALL:
|
|
case GIMPLE_RETURN:
|
|
case GIMPLE_SWITCH:
|
|
case GIMPLE_LABEL:
|
|
case GIMPLE_COND:
|
|
case GIMPLE_GOTO:
|
|
case GIMPLE_DEBUG:
|
|
for (i = 0; i < gimple_num_ops (stmt); i++)
|
|
{
|
|
tree op = gimple_op (stmt, i);
|
|
/* Wrap all uses of non-automatic variables inside MEM_REFs
|
|
so that we do not have to deal with type mismatches on
|
|
merged symbols during IL read in. The first operand
|
|
of GIMPLE_DEBUG must be a decl, not MEM_REF, though. */
|
|
if (op && (i || !is_gimple_debug (stmt)))
|
|
{
|
|
tree *basep = &op;
|
|
while (handled_component_p (*basep))
|
|
basep = &TREE_OPERAND (*basep, 0);
|
|
if (TREE_CODE (*basep) == VAR_DECL
|
|
&& !auto_var_in_fn_p (*basep, current_function_decl)
|
|
&& !DECL_REGISTER (*basep))
|
|
{
|
|
bool volatilep = TREE_THIS_VOLATILE (*basep);
|
|
*basep = build2 (MEM_REF, TREE_TYPE (*basep),
|
|
build_fold_addr_expr (*basep),
|
|
build_int_cst (build_pointer_type
|
|
(TREE_TYPE (*basep)), 0));
|
|
TREE_THIS_VOLATILE (*basep) = volatilep;
|
|
}
|
|
}
|
|
stream_write_tree (ob, op, true);
|
|
}
|
|
if (is_gimple_call (stmt))
|
|
{
|
|
if (gimple_call_internal_p (stmt))
|
|
streamer_write_enum (ob->main_stream, internal_fn,
|
|
IFN_LAST, gimple_call_internal_fn (stmt));
|
|
else
|
|
stream_write_tree (ob, gimple_call_fntype (stmt), true);
|
|
}
|
|
break;
|
|
|
|
case GIMPLE_NOP:
|
|
case GIMPLE_PREDICT:
|
|
break;
|
|
|
|
case GIMPLE_TRANSACTION:
|
|
gcc_assert (gimple_transaction_body (stmt) == NULL);
|
|
stream_write_tree (ob, gimple_transaction_label (stmt), true);
|
|
break;
|
|
|
|
default:
|
|
gcc_unreachable ();
|
|
}
|
|
}
|
|
|
|
|
|
/* Output a basic block BB to the main stream in OB for this FN. */
|
|
|
|
void
|
|
output_bb (struct output_block *ob, basic_block bb, struct function *fn)
|
|
{
|
|
gimple_stmt_iterator bsi = gsi_start_bb (bb);
|
|
|
|
streamer_write_record_start (ob,
|
|
(!gsi_end_p (bsi)) || phi_nodes (bb)
|
|
? LTO_bb1
|
|
: LTO_bb0);
|
|
|
|
streamer_write_uhwi (ob, bb->index);
|
|
streamer_write_hwi (ob, bb->count);
|
|
streamer_write_hwi (ob, bb->frequency);
|
|
streamer_write_hwi (ob, bb->flags);
|
|
|
|
if (!gsi_end_p (bsi) || phi_nodes (bb))
|
|
{
|
|
/* Output the statements. The list of statements is terminated
|
|
with a zero. */
|
|
for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
|
|
{
|
|
int region;
|
|
gimple stmt = gsi_stmt (bsi);
|
|
|
|
output_gimple_stmt (ob, stmt);
|
|
|
|
/* Emit the EH region holding STMT. */
|
|
region = lookup_stmt_eh_lp_fn (fn, stmt);
|
|
if (region != 0)
|
|
{
|
|
streamer_write_record_start (ob, LTO_eh_region);
|
|
streamer_write_hwi (ob, region);
|
|
}
|
|
else
|
|
streamer_write_record_start (ob, LTO_null);
|
|
}
|
|
|
|
streamer_write_record_start (ob, LTO_null);
|
|
|
|
for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
|
|
{
|
|
gimple phi = gsi_stmt (bsi);
|
|
|
|
/* Only emit PHIs for gimple registers. PHI nodes for .MEM
|
|
will be filled in on reading when the SSA form is
|
|
updated. */
|
|
if (!virtual_operand_p (gimple_phi_result (phi)))
|
|
output_phi (ob, phi);
|
|
}
|
|
|
|
streamer_write_record_start (ob, LTO_null);
|
|
}
|
|
}
|