From c4d7535acf9b506c322c19ded14efd7f8ce228ea Mon Sep 17 00:00:00 2001 From: Gary Oblock Date: Mon, 29 Jun 2020 23:42:02 -0700 Subject: bug fixes for ssa temps (in progress) --- gcc/ipa-str-reorg-instance-interleave.c | 488 +++++++++++--------------------- gcc/ipa-structure-reorg.c | 26 ++ gcc/ipa-structure-reorg.h | 1 + 3 files changed, 195 insertions(+), 320 deletions(-) diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index 527b3ddb3e3..d1d40ce9f3a 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -45,6 +45,8 @@ along with GCC; see the file COPYING3. If not see #include "cfghooks.h" #include "function.h" +static void wrangle_ssa_type( tree, Info_t*); +static bool print_internals (gimple *, void *); static void str_reorg_instance_interleave_qual_part ( Info *); static void str_reorg_instance_interleave_type_part ( Info *); static void create_new_types ( Info_t *); @@ -197,256 +199,6 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_ElemAssign: { //break; - #define USE_MEM_REF 1 - #if 0 - gimple_stmt_iterator gsi = gsi_for_stmt( stmt); - - DEBUG_L("ReorgT_ElemAssign: "); - DEBUG_F( print_gimple_stmt, stderr, stmt, 0); - DEBUG("\n"); - INDENT(2); - // Needed for helloworld - tree lhs = gimple_assign_lhs( stmt); - tree rhs = gimple_assign_rhs1( stmt); - - bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info); - - DEBUG_L( "Reorg on %s\n", ro_on_left ? "left" : "right"); - - tree ro_side = ro_on_left ? lhs : rhs; - tree nonro_side = ro_on_left ? rhs : lhs; - - switch ( recognize_op ( ro_side, info) ) // "a->f" - { - case ReorgOpT_Indirect: - { - DEBUG_L("%s: ", ro_on_left ? "lhs" : "rhs"); - DEBUG_F(print_generic_expr,stderr,ro_side,(dump_flags_t)0); - DEBUG("\n"); - DEBUG_L("ReorgOpT_Indirect\n"); - - tree orig_field = TREE_OPERAND( ro_side, 1); - tree field_type = TREE_TYPE( orig_field); - tree base = ri->instance_interleave.base; - - DEBUG_L("base: %p\n", base); - DEBUG_A(" base: "); - DEBUG_F(print_generic_expr, stderr, base, (dump_flags_t)0); - DEBUG("\n"); - - tree base_field = - find_coresponding_field ( base, orig_field); - - DEBUG_L("base_field: %p\n", base_field); - DEBUG_A(" base_field: "); - DEBUG_F(print_generic_expr, stderr, base_field, (dump_flags_t)0); - DEBUG("\n"); - - tree base_field_type = TREE_TYPE( base_field); - - DEBUG_L("base_field_type: %p\n", base_field_type); - DEBUG_A(" base_field_type: "); - DEBUG_F(print_generic_expr, stderr, base_field_type, (dump_flags_t)0); - DEBUG("\n"); - - tree field_val_temp = - make_temp_ssa_name( field_type, NULL, "field_val_temp"); - - DEBUG_L("field_val_temp: %p\n", field_val_temp); - DEBUG_A(" field_val_temp: "); - DEBUG_F(print_generic_expr, stderr, field_val_temp, (dump_flags_t)0); - DEBUG("\n"); - - tree field_val_temp_type = TREE_TYPE(field_val_temp); // debug only - DEBUG_L("field_val_temp_type: %p\n", field_val_temp_type); - DEBUG_A(" field_val_temp_type: "); - DEBUG_F(print_generic_expr, stderr, field_val_temp_type, (dump_flags_t)0); - DEBUG("\n"); - - tree inner_op = TREE_OPERAND( ro_side, 0); - - DEBUG_L("inner_op: "); - DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)0); - DEBUG("\n"); - - // For either case generate common code: - - // field_array = _base.f - tree field_arry_addr = - make_temp_ssa_name( base_field_type, NULL, "field_arry_addr"); - - DEBUG_L("field_arry_addr: %p\n", field_arry_addr); - DEBUG_A(" field_arry_addr: "); - DEBUG_F(print_generic_expr, stderr, field_arry_addr, (dump_flags_t)0); - DEBUG("\n"); - - tree field_arry_addr_type = TREE_TYPE(field_arry_addr); - DEBUG_L("field_arry_addr_type: %p\n", field_arry_addr_type); - DEBUG_A(" field_arry_addr_type: "); - DEBUG_F(print_generic_expr, stderr, field_arry_addr_type, (dump_flags_t)0); - DEBUG("\n") - - tree rhs_faa = build3 ( COMPONENT_REF, - // ??? - //base_field_type, - ptr_type_node, // This seems bogus - base, - //base_field, - // This almost certainly is bogus - // If this "works" the the types - // of fields are messed up. - orig_field, - NULL_TREE); - - DEBUG_L("rhs_faa: %p\n", rhs_faa); - DEBUG_A(" rhs_faa: "); - DEBUG_F(print_generic_expr, stderr, rhs_faa, (dump_flags_t)0); - DEBUG("\n"); - - tree rhs_faa_type = TREE_TYPE( rhs_faa); - DEBUG_L("rhs_faa_type: %p\n", rhs_faa_type); - DEBUG_A(" rhs_faa_type: "); - DEBUG_F(print_generic_expr, stderr, rhs_faa_type, (dump_flags_t)0); - DEBUG("\n"); - - gimple *get_field_arry_addr = - gimple_build_assign( field_arry_addr, rhs_faa); - - DEBUG_L("get_field_arry_addr: "); - DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0); - DEBUG("\n"); - - // index = a - tree index = - make_temp_ssa_name( ri->pointer_rep, NULL, "index"); - gimple *get_index = - gimple_build_assign( index, inner_op); - - gimple *temp_set; - gimple *final_set; - - // offset = index * size_of_field - tree size_of_field = TYPE_SIZE_UNIT ( base_field_type); - tree offset = make_temp_ssa_name( sizetype, NULL, "offset"); // TBD sizetype ??? - gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field); - - // field_addr = field_array + offset - // bug fix here (TBD) type must be *double not double - tree field_addr = - make_temp_ssa_name( base_field_type, NULL, "field_addr"); - - DEBUG_L("field_addr: %p\n", field_addr); - DEBUG_A(" field_addr: "); - DEBUG_F(print_generic_expr, stderr, field_addr, (dump_flags_t)0); - DEBUG("\n"); - - tree field_addr_type = TREE_TYPE(field_addr); // debug only - DEBUG_L("field_addr_type: %p\n", field_addr_type); - DEBUG_A(" field_addr_type: "); - DEBUG_F(print_generic_expr, stderr, field_addr_type, (dump_flags_t)0); - DEBUG("\n"); - - gimple *get_field_addr = - gimple_build_assign ( field_addr, PLUS_EXPR, field_arry_addr, offset); - - if ( ro_on_left ) - { - // With: a->f = rhs - // Generate: - - // temp = rhs - temp_set = gimple_build_assign( field_val_temp, rhs); - - //// field_array[index] = temp - //tree elem_to_set = - // build4 ( ARRAY_REF, field_type, field_arry_addr, index, - // NULL_TREE, NULL_TREE); - //final_set = - // gimple_build_assign( elem_to_set, field_val_temp); - - // *field_addr = temp - tree lhs_ref = build1 ( MEM_REF, field_type, field_addr); - final_set = - gimple_build_assign( lhs_ref, field_val_temp); - } - else - { - // With: lhs = a->f - // Generate: - - //// temp = field_array[index] - //tree elem_to_get = - // build4 ( ARRAY_REF, field_type, field_arry_addr, index, - // NULL_TREE, NULL_TREE); - //temp_set = - // gimple_build_assign( field_val_temp, elem_to_get); - - - // temp = *field_addr - // I tried MEM_REF here and build1 had an internal error - tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr); - - DEBUG_L("rhs_ref: %p\n", rhs_ref); - DEBUG_A(" rhs_ref: "); - DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0); - DEBUG("\n"); - - tree rhs_ref_type = TREE_TYPE( rhs_ref); // bebug only - DEBUG_L("rhs_ref_type: %p\n", rhs_ref_type); - DEBUG_A(" rhs_ref_type: "); - DEBUG_F(print_generic_expr, stderr, rhs_ref_type, (dump_flags_t)0); - DEBUG("\n"); - - temp_set = - gimple_build_assign( field_val_temp, rhs_ref); - - // lhs = temp - final_set = gimple_build_assign( lhs, field_val_temp); - } - - DEBUG_L("get_field_arry_addr: "); - DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0); - DEBUG("\n"); - DEBUG_L("get_index: "); - DEBUG_F( print_gimple_stmt, stderr, get_index, 0); - DEBUG("\n"); - - DEBUG_L("get_offset: "); - DEBUG_F( print_gimple_stmt, stderr, get_offset, 0); - DEBUG("\n"); - - DEBUG_L("get_field_addr: "); - DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0); - DEBUG("\n"); - - DEBUG_L("temp_set: "); - DEBUG_F( print_gimple_stmt, stderr, temp_set, 0); - DEBUG("\n"); - DEBUG_L("final_set: "); - DEBUG_F( print_gimple_stmt, stderr, final_set, 0); - DEBUG("\n"); - - gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT); - gsi_insert_before( &gsi, get_index, GSI_SAME_STMT); - gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT); - gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT); - gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); // << malformed??? - gsi_insert_before( &gsi, final_set, GSI_SAME_STMT); - - - //delete stmt - gsi_remove ( &gsi, true); - } // end ReorgOpT_Indirect case - break; - case ReorgOpT_AryDir: // "x[i].f" - // Not implemented in single pool - internal_error ( "ReorgOpT_AryDir not possible"); - default: - internal_error ( - "Reached operand default for ReorgOpT_Indirect"); - - } // end recognize_op ( rhs, info) switch - #else gimple_stmt_iterator gsi = gsi_for_stmt( stmt); DEBUG_L("ReorgT_ElemAssign: "); @@ -505,35 +257,33 @@ str_reorg_instance_interleave_trans ( Info *info) // Use this to access the array of element. gimple *get_field_arry_addr = gimple_build_assign( field_arry_addr, rhs_faa); + SSA_NAME_DEF_STMT ( field_arry_addr) = get_field_arry_addr; // index = a tree index = make_temp_ssa_name( ri->pointer_rep, NULL, "index"); gimple *get_index = gimple_build_assign( index, inner_op); + SSA_NAME_DEF_STMT ( index) = get_index; gimple *temp_set; gimple *final_set; - #if USE_MEM_REF // offset = index * size_of_field tree size_of_field = TYPE_SIZE_UNIT ( base_field_type); tree offset = make_temp_ssa_name( sizetype, NULL, "offset"); // TBD sizetype ??? gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field); + SSA_NAME_DEF_STMT ( offset) = get_offset; - #if 1 - // DELETE THIS (WAIT!) // field_addr = field_array + offset // bug fix here (TBD) type must be *double not double tree field_addr = make_temp_ssa_name( base_field_type, NULL, "field_addr"); - // DELETE THIS gimple *get_field_addr = gimple_build_assign ( field_addr, PLUS_EXPR, field_arry_addr, offset); - #endif - #endif + SSA_NAME_DEF_STMT ( field_addr) = get_field_addr; if ( ro_on_left ) { @@ -542,7 +292,8 @@ str_reorg_instance_interleave_trans ( Info *info) // temp = rhs temp_set = gimple_build_assign( field_val_temp, rhs); - + SSA_NAME_DEF_STMT ( field_val_temp) = temp_set; + //// field_array[index] = temp //tree elem_to_set = // build4 ( ARRAY_REF, field_type, field_arry_addr, index, @@ -550,34 +301,10 @@ str_reorg_instance_interleave_trans ( Info *info) //final_set = // gimple_build_assign( elem_to_set, field_val_temp); - // MOD THIS to ARRAY_REF - #if USE_MEM_REF - // NOTE, THIS (MEM_REF)SHOULD NOT WORK - // not tested yet! // *field_addr = temp - // TODO - //tree lhs_ref = build1 ( MEM_REF, field_type, field_addr); - - // NOPE! - //tree lhs_ref = build2 ( MEM_REF, base_field_type, - // base_field, offset); - tree lhs_ref = build2 ( MEM_REF, field_type, field_addr, build_int_cst (ptr_type_node, 0)); - #else - // field_arry_addr[index] - tree lhs_arry = build2 ( MEM_REF, - base_field_type, base_field, - build_int_cst (ptr_type_node, 0)); - //tree lhs_ref = - // build4 ( ARRAY_REF, field_type, field_arry_addr, index, - // NULL_TREE, NULL_TREE); - tree lhs_ref = - build4 ( ARRAY_REF, field_type, lhs_arry, index, - NULL_TREE, NULL_TREE); - #endif - final_set = gimple_build_assign( lhs_ref, field_val_temp); } @@ -587,7 +314,6 @@ str_reorg_instance_interleave_trans ( Info *info) // Generate: // temp = *field_addr - #if USE_MEM_REF // INDIRECT_REF is not supported fot GIMPLE... sigh... // tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr); @@ -626,25 +352,14 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG_L("op1type_type: "); DEBUG_F(print_generic_expr, stderr, op1type_type, (dump_flags_t)0); DEBUG("\n") - - - #else - //tree rhs_ref = - // build4 ( ARRAY_REF, field_type, field_arry_addr, index, - // NULL_TREE, NULL_TREE); - tree rhs_arry = build2 ( MEM_REF, - base_field_type, base_field, - build_int_cst (ptr_type_node, 0)); - tree rhs_ref = - build4 ( ARRAY_REF, field_type, rhs_arry, index, - NULL_TREE, NULL_TREE); - #endif temp_set = gimple_build_assign( field_val_temp, rhs_ref); + SSA_NAME_DEF_STMT ( field_val_temp) = temp_set; // lhs = temp final_set = gimple_build_assign( lhs, field_val_temp); + SSA_NAME_DEF_STMT ( lhs) = final_set; } DEBUG_L("get_field_arry_addr: "); @@ -655,18 +370,13 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG_F( print_gimple_stmt, stderr, get_index, 0); DEBUG("\n"); - #if USE_MEM_REF DEBUG_L("get_offset: "); DEBUG_F( print_gimple_stmt, stderr, get_offset, 0); DEBUG("\n"); - #if 1 - // DELETE THIS (WAIT!) DEBUG_L("get_field_addr: "); DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0); DEBUG("\n"); - #endif - #endif DEBUG_L("temp_set: "); DEBUG_F( print_gimple_stmt, stderr, temp_set, 0); @@ -678,13 +388,8 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT); gsi_insert_before( &gsi, get_index, GSI_SAME_STMT); - #if USE_MEM_REF gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT); - #if 1 - // DELETE THIS (WAIT!) gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT); - #endif - #endif gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); // << malformed??? gsi_insert_before( &gsi, final_set, GSI_SAME_STMT); @@ -701,10 +406,9 @@ str_reorg_instance_interleave_trans ( Info *info) "Reached operand default for ReorgOpT_Indirect"); } // end recognize_op ( rhs, info) switch - #endif + INDENT(-2); } // end ReorgT_ElemAssign case - INDENT(-2); break; case ReorgT_If_Null: case ReorgT_If_NotNull: @@ -744,6 +448,7 @@ str_reorg_instance_interleave_trans ( Info *info) tree rhs2 = gimple_assign_rhs2( stmt); gimple *adjust_stmt = gimple_build_assign ( tmp, TRUNC_DIV_EXPR, rhs2, str_siz); + SSA_NAME_DEF_STMT ( tmp) = adjust_stmt; // Note, gimple_set_op is used in limited places so using it // to modify existed code might be problematic. gimple_set_op( stmt, 2, tmp); @@ -833,7 +538,9 @@ str_reorg_instance_interleave_trans ( Info *info) //gimple *glen = // gimple_build_assign ( len, TRUNC_DIV_EXPR, val, size); gimple *glen = - gimple_build_assign ( len, TRUNC_DIV_EXPR, arg, size); + gimple_build_assign ( len, TRUNC_DIV_EXPR, arg, size); + SSA_NAME_DEF_STMT ( len) = glen; + gsi_insert_before( &gsi, glen, GSI_SAME_STMT); // Note in other places in this doc this would // be "insert glen before stmt" instead of this but @@ -908,17 +615,10 @@ str_reorg_instance_interleave_trans ( Info *info) gimple_stmt_iterator gsi = gsi_start_bb ( new_bb); // Note, switching the order of edge creation and // setting dominator seems to make no difference - #if 0 - // FROM set imm dom new_bb as prev_bb - set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb); - // FROM make_edge( prev_bb, new_bb, EDGE_TRUE_VALUE); - make_edge ( prev_bb, new_bb, EDGE_TRUE_VALUE); - #else // TBD set edge probability and flags make_edge ( prev_bb, new_bb, EDGE_TRUE_VALUE); // TBD what happens if I punt on this???? //set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb); - #endif // FROM make_edge( new_bb, failure_bb, EDGE_FALSE_VALUE); // TBD set edge probability and flags @@ -965,6 +665,7 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG("\n"); gimple *gset_field = gimple_build_assign( lhs_ass, res); + gsi_insert_after( &gsi, gset_field, GSI_SAME_STMT); // FROM gsi_insert_after( &gsi, "res = malloc( mem_size)") @@ -984,6 +685,8 @@ str_reorg_instance_interleave_trans ( Info *info) MULT_EXPR, TYPE_SIZE ( TREE_TYPE ( field)), len); + SSA_NAME_DEF_STMT ( mem_size) = gsize; + gsi_insert_after( &gsi, gsize, GSI_SAME_STMT); // Moved label to top //// FROM gsi_insert_after( &gsi, prev_ok_field) @@ -1030,6 +733,8 @@ str_reorg_instance_interleave_trans ( Info *info) gimple *set_succ = gimple_build_assign ( success_val, build_int_cst ( reorg_pointer_type, 0)); + SSA_NAME_DEF_STMT ( success_val) = set_succ; + gsi_insert_after( &gsi, set_succ, GSI_SAME_STMT); // FROM gsi_insert_after( &gsi, new_ok_field ) //gimple *gnew_ok_field = gimple_build_label ( new_ok_field_L); @@ -1091,6 +796,7 @@ str_reorg_instance_interleave_trans ( Info *info) tree lhs_ass = build3( COMPONENT_REF, ptr_type_node, base, field, NULL_TREE); gimple *gzero = gimple_build_assign( lhs_ass, null_pointer_node); + gsi_insert_after( &gsi, gzero, GSI_SAME_STMT); // FROM gsi_insert_after( &gsi, "free(field)") @@ -1102,6 +808,8 @@ str_reorg_instance_interleave_trans ( Info *info) tree rhs_ass = build3( COMPONENT_REF, ptr_type_node, base, field, NULL_TREE); gimple *gaddr2free = gimple_build_assign( to_free, rhs_ass); + SSA_NAME_DEF_STMT ( to_free) = gaddr2free; + gsi_insert_after( &gsi, gaddr2free, GSI_SAME_STMT); } // FROM gsi_insert_after( &gsi, "fail_val = minint") @@ -1109,6 +817,8 @@ str_reorg_instance_interleave_trans ( Info *info) gimple_build_assign ( fail_val, //build_int_cst ( size_type_node, TYPE_MIN_VALUE ( TREE_TYPE ( fail_val))); // ); + SSA_NAME_DEF_STMT ( fail_val) = gretnull; + gsi_insert_after( &gsi, gretnull, GSI_SAME_STMT); //// FROM gsi_insert_after( &gsi, bad_field ) @@ -1424,17 +1134,51 @@ str_reorg_instance_interleave_trans ( Info *info) tree prev_type = lhs_type; tree type = TREE_TYPE ( prev_type); DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type); - for (; TREE_CODE ( type) == POINTER_TYPE; ) + int levels; + for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ ) { prev_type = type; type = TREE_TYPE ( prev_type); DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type); } + + #if 0 // Modify type of ssa temp (dicey!) // This changes every instance of * reorg_type to the // new pointre rep in one fell swoop. // I sweat just thinking how crazy this is.... TREE_TYPE ( prev_type) = ri->pointer_rep; + #endif + // TBD might use build_pointer_type to build new type for *(N)reorg_type + // to *(N-1)ri->pointer_rep + // Fakes this for levels == 1 + if ( levels == 0) + { + DEBUG_L( "LEVELS ZERO\n"); + } + else + { + if ( levels == 1 ) + { + TREE_TYPE ( lhs) = ri->pointer_rep; + } + else + { + gcc_assert(0); + } + } + } + if ( rhs1_ssa ) + { + wrangle_ssa_type( rhs1, info); + } + if ( rhs2_ssa ) + { + wrangle_ssa_type( rhs2, info); + } + if ( rhs3_ssa ) + { + wrangle_ssa_type( rhs3, info); } } } @@ -1445,13 +1189,117 @@ str_reorg_instance_interleave_trans ( Info *info) } } + fprintf ( stderr, "INTERNALS PRINT\n"); + apply_to_all_gimple ( print_internals, (void *)info); + if ( info->show_all_reorg_cands ) - { - fprintf ( info->reorg_dump_file, "End of str_reorg_instance_interleave_trans:\n"); - print_program ( info->reorg_dump_file, 4); - } + { + fprintf ( info->reorg_dump_file, "End of str_reorg_instance_interleave_trans:\n"); + print_program ( info->reorg_dump_file, 4); + } +} + +static void +wrangle_ssa_type( tree side, Info_t *info ) +{ + tree side_type = TREE_TYPE ( side); + tree bottom_type = base_type_of ( side_type); + DEBUG_L("side: "); + DEBUG_F(print_generic_expr, stderr, side, (dump_flags_t)0); + DEBUG("\n"); + DEBUG_L("bottom_type: "); + DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0); + DEBUG("\n"); + + ReorgType_t *ri = get_reorgtype_info ( bottom_type, info); + tree prev_type = side_type; + tree type = TREE_TYPE ( prev_type); + DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type); + int levels; + for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ ) + { + prev_type = type; + type = TREE_TYPE ( prev_type); + DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type); + } + +#if 0 + // Modify type of ssa temp (dicey!) + // This changes every instance of * reorg_type to the + // new pointre rep in one fell swoop. + // I sweat just thinking how crazy this is.... + TREE_TYPE ( prev_type) = ri->pointer_rep; +#endif + // TBD might use build_pointer_type to build new type for *(N)reorg_type + // to *(N-1)ri->pointer_rep + // Fakes this for levels == 1 + if ( levels == 0) + { + DEBUG_L( "LEVELS ZERO\n"); + } + else + { + if ( levels == 1 ) + { + TREE_TYPE ( side) = ri->pointer_rep; + } + else + { + gcc_assert(0); + } + } +} + + +static bool +print_internals (gimple *stmt, void *data) +{ + Info_t *info = (Info_t*)data; + + print_gimple_stmt ( stderr, stmt, TDF_SLIM); + + if ( gimple_code ( stmt) == GIMPLE_ASSIGN ) + { + tree lhs = gimple_assign_lhs( stmt); + tree rhs1 = gimple_assign_rhs1( stmt); + tree rhs2 = gimple_assign_rhs2( stmt); + tree rhs3 = gimple_assign_rhs3( stmt); + gcc_assert ( lhs); + gcc_assert ( rhs1); + + bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info); + bool rhs1_reorg = tree_contains_a_reorgtype_p ( rhs1, info); + bool rhs2_reorg = tree_contains_a_reorgtype_p ( rhs2, info); + bool rhs3_reorg = tree_contains_a_reorgtype_p ( rhs3, info); + + bool lhs_ssa = lhs_reorg && TREE_CODE(lhs) == SSA_NAME; + bool rhs1_ssa = rhs1_reorg && TREE_CODE(rhs1) == SSA_NAME; + bool rhs2_ssa = rhs2_reorg && TREE_CODE(rhs2) == SSA_NAME; + bool rhs3_ssa = rhs3_reorg && TREE_CODE(rhs3) == SSA_NAME; + + fprintf( stderr, " LHS%s: ", lhs_ssa ? "*" : ""); + print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0); + + fprintf( stderr, ", RHS1%s: ", rhs1_ssa ? "*" : ""); + print_generic_expr ( stderr, TREE_TYPE ( rhs1), (dump_flags_t)0); + + if ( rhs2 ) + { + fprintf( stderr, ", RHS2%s: ", rhs2_ssa ? "*" : ""); + print_generic_expr ( stderr, TREE_TYPE ( rhs2), (dump_flags_t)0); + } + + if ( rhs3 ) + { + fprintf( stderr, ", RHS3%s: ", rhs3_ssa ? "*" : ""); + print_generic_expr ( stderr, TREE_TYPE ( rhs3), (dump_flags_t)0); + } + fprintf ( stderr, "\n"); + } + return false; } + static void str_reorg_instance_interleave_qual_part ( Info *info) { diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index c8a6d742c3a..b58264c6d09 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -1542,6 +1542,32 @@ find_struct_type_ptr_to_struct ( tree type, Info *info) return NULL; } +// 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 ) +{ + struct cgraph_node *node; + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) + { + struct function *func = DECL_STRUCT_FUNCTION ( node->decl); + push_cfun ( func); + basic_block bb; + FOR_EACH_BB_FN ( bb, func) + { + gimple_stmt_iterator gsi; + for ( gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) ) + { + gimple *stmt = gsi_stmt ( gsi); + // If we are searching for something then return here because + // it's found. + if ( (*function) ( stmt, data )) return; + } + } + pop_cfun (); + } +} + // TBD Garbage just so it will compile // What's dicey about this is it may sort of work but then I // can see places where it wouldn't... The language has a say diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index 149863fea9b..f9a687c1e44 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -222,6 +222,7 @@ extern enum ReorgOpTrans recognize_op ( tree, Info_t *); extern ReorgTransformation reorg_recognize ( gimple *, cgraph_node *, Info_t *); +extern void apply_to_all_gimple ( bool (*)(gimple *, void *), void *); extern ReorgType_t *get_reorgtype_info ( tree, Info_t *); extern void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *); extern ReorgType_t *contains_a_reorgtype ( gimple *, Info *); -- cgit v1.2.3