PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "ri-util.h"
#include "properties.h"
#include "misc.h"
Go to the source code of this file.
Data Structures | |
struct | cusq_context |
Clean up sequences context. More... | |
Functions | |
void | initialize_clean_up_sequences_statistics (void) |
void | display_clean_up_sequences_statistics (void) |
static bool | store_reference (reference ref, cusq_context *p_ctxt) |
static bool | store_loops (loop l, cusq_context *p_ctxt) |
static bool | store_declarations_references (statement st, cusq_context *p_ctxt) |
static void | cusq_ctxt_init (statement s, cusq_context *p_ctxt) |
static void | cusq_ctxt_reset (cusq_context *p_ctxt) |
static void | replace_entities_in_cusq_context (cusq_context *p_ctxt, hash_table ht) |
replace entities in the module references and loop indices and loop locals stored in the input cusq_context using the input old/new entities mapping More... | |
bool | statement_to_goto_table_flt (instruction i) |
End: clean up sequences context. More... | |
void | compute_statement_to_goto_table (statement s) |
Since clean_up_sequences() is called before the controlizer, there may be some GOTO. More... | |
void | discard_statement_to_goto_table (void) |
Discard the statement_to_goto_table map: More... | |
void | adjust_goto_from_to (statement s1, statement s2) |
Adjust all the GOTOs pointing s1 to s2: More... | |
static void | deal_with_pending_comment (statement s, string *the_comments) |
static bool | sequence_proper_declarations_rename_in_place (sequence seq, hash_table renamings) |
change the declarations of declaration statements directly contained in input sequence according to the input old/new entity mapping More... | |
static void | clean_up_sequences_rewrite (statement s, cusq_context *p_ctxt) |
bool | clean_up_sequences_internal (statement s) |
An entry point for internal usage, such as from take_out_the_exit_node_if_not_a_continue(): More... | |
bool | clean_up_sequences (statement s) |
Recursively clean up the statement sequences by fusing them if possible and by removing useless one. More... | |
Variables | |
static int | clean_up_empty_block_removed |
Clean up the sequences and their contents by fusing them or removing useless continues or empty instructions. More... | |
static int | clean_up_fused_sequences |
static int | clean_up_1_statement_sequence |
hash_table | statement_to_goto_table = NULL |
clean_up_sequences.c More... | |
Adjust all the GOTOs pointing s1 to s2:
s1 | 1 |
s2 | 2 |
Definition at line 282 of file clean_up_sequences.c.
References FOREACH, hash_defined_p(), hash_get(), instruction_goto, pips_assert, pips_debug, s1, and statement_to_goto_table.
Referenced by clean_up_sequences_rewrite().
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
Remove also empty blocs and useless continues.
Definition at line 704 of file clean_up_sequences.c.
References clean_up_sequences_internal(), debug_off, debug_on, display_clean_up_sequences_statistics(), and initialize_clean_up_sequences_statistics().
Referenced by clear_labels(), control_graph(), delay_communications(), delay_communications_interprocedurally(), delay_load_communications(), delay_store_communications(), do_it(), do_symbolic_tiling(), flatten_code(), freia_compiler(), full_loop_unroll(), if_conv_init_statement(), invariant_code_motion(), new_atomizer(), normalize_microcode(), optimize_expressions(), simd_remove_reductions(), simdizer(), simdizer_init(), statement_split_initializations(), symbolic_tiling(), transform_a_for_loop_into_a_while_loop(), transform_a_for_loop_statement_into_a_while_loop(), and unspaghettify_or_restructure_statement().
An entry point for internal usage, such as from take_out_the_exit_node_if_not_a_continue():
Definition at line 676 of file clean_up_sequences.c.
References cusq_context::changed, clean_up_sequences_rewrite(), compute_statement_to_goto_table(), cusq_ctxt_init(), cusq_ctxt_reset(), debug_off, debug_on, discard_statement_to_goto_table(), gen_context_recurse, gen_true2(), ifdebug, statement_consistent_p(), and statement_domain.
Referenced by clean_up_sequences(), and take_out_the_exit_node_if_not_a_continue().
|
static |
Delete empty instruction and fuse blocks of instructions :
Remove the list of unused statements with the statements themselves:
|| !ENDP(statement_declarations(s))
We have a pending comment we were not able to attach. Create a continue statement to attach it:
Keep track of declarations within an empty sequence: see C_syntax/block01.c
A sequence of only 1 instruction can be replaced by this instruction, if it has not declarations
Do not forget to adjust the GOTOs pointing on st:
Discard the old statement:
Definition at line 354 of file clean_up_sequences.c.
References AddLocalEntityToDeclarationsOnly(), adjust_goto_from_to(), BLOCK_SEP_CHAR, CAR, cusq_context::changed, clean_up_1_statement_sequence, clean_up_empty_block_removed, clean_up_fused_sequences, concatenate(), CONS, deal_with_pending_comment(), empty_comments_p(), empty_statement_or_labelless_continue_p(), empty_statement_p(), ENDP, ENTITY, entity_declarations, entity_initial, entity_name, entity_undefined, entity_undefined_p, entity_user_name(), extensions_extension, extensions_undefined, FindEntity(), FOREACH, fprintf(), free(), free_instruction(), gen_free_list(), gen_full_free_list(), gen_length(), gen_nconc(), gen_remove(), get_current_module_entity(), HASH_DEFAULT_SIZE, hash_pointer, hash_put(), hash_table_free(), hash_table_make(), ifdebug, instruction_sequence, instruction_sequence_p, instruction_undefined, cusq_context::l_decl, label_local_name(), make_entity_copy_with_new_name(), make_entity_copy_with_new_name_and_suffix(), make_plain_continue_statement(), make_value_unknown(), cusq_context::merge_sequences_with_declarations, module, MODULE_SEP_STRING, NIL, pips_debug, pips_internal_error, print_entities(), replace_entities_in_cusq_context(), sequence_proper_declarations_rename_in_place(), sequence_statements, STATEMENT, statement_comments, statement_declarations, statement_extensions, statement_identification(), statement_instruction, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_sequence(), statement_sequence_p(), statement_to_direct_declarations(), statement_with_empty_comment_p(), strdup(), string_undefined, strndup(), TOP_LEVEL_MODULE_NAME, unlabelled_statement_p(), user_log(), and value_undefined_p.
Referenced by clean_up_sequences_internal().
void compute_statement_to_goto_table | ( | statement | s | ) |
Since clean_up_sequences() is called before the controlizer, there may be some GOTO.
GOTOs are in fact pointer to the target statement, hence when target statements are moved around, some GOTOs need to be updated. For this purpose, we build a list of GOTOs per target statement.
Definition at line 257 of file clean_up_sequences.c.
References gen_null(), gen_recurse, hash_pointer, hash_table_make(), instruction_domain, pips_assert, statement_to_goto_table, and statement_to_goto_table_flt().
Referenced by clean_up_sequences_internal().
|
static |
Definition at line 133 of file clean_up_sequences.c.
References cusq_context::changed, fprintf(), gen_context_multi_recurse(), gen_null(), get_bool_property(), ifdebug, cusq_context::l_decl, cusq_context::l_loops, cusq_context::l_ref, loop_domain, cusq_context::merge_sequences_with_declarations, NIL, pips_debug, print_entities(), reference_domain, statement_domain, statement_to_declarations(), store_declarations_references(), store_loops(), and store_reference().
Referenced by clean_up_sequences_internal().
|
static |
Definition at line 165 of file clean_up_sequences.c.
References gen_free_list(), cusq_context::l_decl, cusq_context::l_loops, cusq_context::l_ref, and NIL.
Referenced by clean_up_sequences_internal().
There is a pending comment to be added on this statement:
Definition at line 305 of file clean_up_sequences.c.
References free(), and insert_comments_to_statement().
Referenced by clean_up_sequences_rewrite().
void discard_statement_to_goto_table | ( | void | ) |
Discard the statement_to_goto_table map:
Definition at line 269 of file clean_up_sequences.c.
References gen_free_list(), HASH_MAP, hash_table_free(), and statement_to_goto_table.
Referenced by clean_up_sequences_internal().
void display_clean_up_sequences_statistics | ( | void | ) |
Definition at line 62 of file clean_up_sequences.c.
References clean_up_1_statement_sequence, clean_up_empty_block_removed, clean_up_fused_sequences, get_bool_property(), and user_log().
Referenced by clean_up_sequences().
void initialize_clean_up_sequences_statistics | ( | void | ) |
Definition at line 54 of file clean_up_sequences.c.
References clean_up_1_statement_sequence, clean_up_empty_block_removed, and clean_up_fused_sequences.
Referenced by clean_up_sequences().
|
static |
replace entities in the module references and loop indices and loop locals stored in the input cusq_context using the input old/new entities mapping
Definition at line 182 of file clean_up_sequences.c.
References CAR, cusq_context::changed, ENDP, ENTITY, entity_name, entity_undefined, FOREACH, hash_get(), HASH_UNDEFINED_VALUE, cusq_context::l_loops, cusq_context::l_ref, LOOP, loop_index, loop_locals, pips_debug, POP, ref, REFERENCE, and reference_variable.
Referenced by clean_up_sequences_rewrite().
|
static |
change the declarations of declaration statements directly contained in input sequence according to the input old/new entity mapping
seq | is the input sequence |
renamings | is an old/new entity mapping |
Definition at line 323 of file clean_up_sequences.c.
References CAR, declaration_statement_p(), ENDP, ENTITY, entity_name, FOREACH, hash_del(), hash_get(), HASH_UNDEFINED_VALUE, pips_debug, POP, sequence_statements, STATEMENT, and statement_declarations.
Referenced by clean_up_sequences_rewrite().
bool statement_to_goto_table_flt | ( | instruction | i | ) |
End: clean up sequences context.
Add a couple (statement -> GOTO) to the map statement_to_goto_table:
Definition at line 221 of file clean_up_sequences.c.
References CONS, hash_defined_p(), hash_get(), hash_put(), hash_update(), INSTRUCTION, instruction_goto, instruction_goto_p, NIL, pips_debug, and statement_to_goto_table.
Referenced by compute_statement_to_goto_table().
|
static |
Definition at line 114 of file clean_up_sequences.c.
References declaration_statement_p(), ENTITY, entity_initial, FOREACH, gen_context_recurse, gen_null2(), reference_domain, statement_declarations, store_reference(), and value_undefined_p.
Referenced by cusq_ctxt_init().
|
static |
Definition at line 107 of file clean_up_sequences.c.
References CONS, cusq_context::l_loops, and LOOP.
Referenced by cusq_ctxt_init().
|
static |
Definition at line 100 of file clean_up_sequences.c.
References CONS, cusq_context::l_ref, ref, and REFERENCE.
Referenced by cusq_ctxt_init(), and store_declarations_references().
|
static |
Definition at line 49 of file clean_up_sequences.c.
Referenced by clean_up_sequences_rewrite(), display_clean_up_sequences_statistics(), and initialize_clean_up_sequences_statistics().
|
static |
Clean up the sequences and their contents by fusing them or removing useless continues or empty instructions.
Ronan Keryell To store the statistics:
Definition at line 47 of file clean_up_sequences.c.
Referenced by clean_up_sequences_rewrite(), display_clean_up_sequences_statistics(), and initialize_clean_up_sequences_statistics().
|
static |
Definition at line 48 of file clean_up_sequences.c.
Referenced by clean_up_sequences_rewrite(), display_clean_up_sequences_statistics(), and initialize_clean_up_sequences_statistics().
hash_table statement_to_goto_table = NULL |
Definition at line 51 of file clean_up_sequences.c.
Referenced by adjust_goto_from_to(), compute_statement_to_goto_table(), discard_statement_to_goto_table(), and statement_to_goto_table_flt().