summaryrefslogtreecommitdiff
path: root/gcc/ipa-structure-reorg.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ipa-structure-reorg.c')
-rw-r--r--gcc/ipa-structure-reorg.c106
1 files changed, 96 insertions, 10 deletions
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index f20336d4e2e..3376f00590a 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -1133,8 +1133,8 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
}
case ReorgOpT_Indirect: // "a->f"
case ReorgOpT_AryDir: // "x[i].f"
- DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Indirect ? "Indirect" : "AryDir");
- INDENT(-4);
+ //DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Indirect ? "Indirect" : "AryDir");
+ //INDENT(-4);
switch ( recognize_op ( rhs, info) )
{
case ReorgOpT_Temp: // t
@@ -1156,13 +1156,24 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
//INDENT(2);
tree op1 = gimple_assign_rhs1 ( stmt);
tree op2 = gimple_assign_rhs2 ( stmt);
+ //DEBUG_L("op1 = %p, op2 = %p\n", op1, op2);
+ //DEBUG_A("");
+ //DEBUG_F( print_generic_expr, stderr, op1, (dump_flags_t)-1);
+ //DEBUG("\n");
+
+ if ( CONVERT_EXPR_CODE_P ( gimple_assign_rhs_code ( stmt)))
+ {
+ //DEBUG_L("CONVERT_EXPR_CODE_P (...)\n");
+ //INDENT(-4);
+ return ReorgT_Convert;
+ }
if ( gimple_assign_rhs3 ( stmt) != NULL )
- {
- //DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n");
- //INDENT(-4);
- return Not_Supported;
- }
+ {
+ //DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n");
+ //INDENT(-4);
+ return Not_Supported;
+ }
// TBD The parenthesis where a disaster here in the HL Design so
// double check this!
@@ -1233,7 +1244,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
struct cgraph_edge *edge = node->get_edge ( stmt);
gcc_assert( edge);
//DEBUG_L("called function %s gimple_body\n",
- // edge->callee->has_gimple_body_p() ? "has a" : "has no");
+ // edge->callee->has_gimple_body_p() ? "has a" : "has no");
//INDENT(-2);
if ( gimple_call_builtin_p( stmt, BUILT_IN_CALLOC ) ) return ReorgT_Calloc;
if ( gimple_call_builtin_p( stmt, BUILT_IN_MALLOC ) ) return ReorgT_Malloc;
@@ -1369,7 +1380,7 @@ remove_deleted_types ( Info *info, ReorgFn reorg_fn)
enum ReorgOpTrans
recognize_op ( tree op, Info *info)
{
- // DEBUG_L("recognize_op: ");
+ //DEBUG_L("recognize_op: ");
//DEBUG_F( print_generic_expr, stderr, op, TDF_DETAILS);
//DEBUG("\n");
enum tree_code op_code = TREE_CODE ( op);
@@ -1546,7 +1557,7 @@ find_struct_type_ptr_to_struct ( tree type, Info *info)
// The applied function func can be used to search because it forces
// a return if it returns true;
void
-apply_to_all_gimple ( bool (*function)(gimple *, void *), void *data )
+apply_to_all_gimple ( bool (*function)(gimple *, void *), bool phis_too, void *data )
{
struct cgraph_node *node;
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
@@ -1556,6 +1567,19 @@ apply_to_all_gimple ( bool (*function)(gimple *, void *), void *data )
basic_block bb;
FOR_EACH_BB_FN ( bb, func)
{
+ if ( phis_too )
+ {
+ gimple_seq seq = bb->il.gimple.phi_nodes;
+ if ( seq )
+ {
+ gimple_stmt_iterator phii;
+ for ( phii = gsi_start (seq); !gsi_end_p (phii); gsi_next (&phii))
+ {
+ gimple *phi_stmt = gsi_stmt ( phii);
+ if ( (*function) ( phi_stmt, data )) return;
+ }
+ }
+ }
gimple_stmt_iterator gsi;
for ( gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) )
{
@@ -1854,11 +1878,25 @@ print_program ( FILE *file, int leading_space )
{
struct cgraph_node *node;
fprintf ( file, "%*sProgram:\n", leading_space, "");
+
+ // Print Global Decls
+ //
+ varpool_node *var;
+ FOR_EACH_VARIABLE ( var)
+ {
+ tree decl = var->decl;
+ fprintf ( file, "%*s", leading_space, "");
+ print_generic_decl ( file, decl, (dump_flags_t)0);
+ fprintf ( file, "\n");
+ }
+
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
{
struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
+ #if 0
// print func name
fprintf ( file, "%*sFunc: %s\n", leading_space + 2, "", lang_hooks.decl_printable_name ( node->decl, 2));
+ #endif
print_function ( file, leading_space + 4, func);
}
}
@@ -1867,6 +1905,26 @@ static void
print_function ( FILE *file, int leading_space, struct function *func)
{
basic_block bb;
+
+ fprintf ( file, "%*sFunc: ", leading_space + 2, "");
+ print_generic_expr ( file, TREE_TYPE(TREE_TYPE( func->decl)), (dump_flags_t)0);
+
+ // Print Func Name
+ fprintf ( file, " %s ( ", lang_hooks.decl_printable_name ( func->decl, 2));
+
+ // Print Parameter Decls
+ tree parm;
+ for ( parm = DECL_ARGUMENTS ( func->decl);
+ parm;
+ parm = DECL_CHAIN ( parm) )
+ {
+ print_generic_expr ( file, TREE_TYPE( parm), (dump_flags_t)0);
+ print_generic_expr ( file, parm, (dump_flags_t)0);
+ }
+ fprintf ( file, ")\n");
+
+
+ // TBD Print Local Decls
FOR_EACH_BB_FN ( bb, func)
{
@@ -1889,6 +1947,16 @@ print_function ( FILE *file, int leading_space, struct function *func)
}
fprintf ( file, "\n");
+ gimple_seq seq = bb->il.gimple.phi_nodes;
+ if ( seq )
+ {
+ gimple_stmt_iterator phii;
+ for ( phii = gsi_start (seq); !gsi_end_p (phii); gsi_next (&phii))
+ {
+ fprintf ( file, "%*s", leading_space + 2, "" );
+ print_gimple_stmt ( file, gsi_stmt ( phii), 0, TDF_DETAILS);
+ }
+ }
gimple_stmt_iterator gsi;
for ( gsi = gsi_start_bb ( bb);
@@ -1932,6 +2000,24 @@ uses_field_of_reorgtypes( gimple *stmt, Info * info)
return false;
}
+void
+modify_ssa_name_type ( tree ssa_name, tree type)
+{
+ // This rips off the code in make_ssa_name_fn.
+ // Note, this probabily be made into special function
+ // that is part of tree-ssanames.
+ if ( TYPE_P ( type))
+ {
+ TREE_TYPE ( ssa_name) = TYPE_MAIN_VARIANT ( type);
+ SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, NULL_TREE);
+ }
+ else
+ {
+ TREE_TYPE ( ssa_name) = TREE_TYPE ( type);
+ SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, type);
+ }
+}
+
//-- debugging only --
//static const char *
#if DEBUGGING