diff options
Diffstat (limited to 'gcc/ipa-structure-reorg.c')
-rw-r--r-- | gcc/ipa-structure-reorg.c | 391 |
1 files changed, 298 insertions, 93 deletions
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 4d9bf695b59..96f07c11aeb 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -140,7 +140,7 @@ ipa_structure_reorg ( void) cgraph_node* node; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) node->get_untransformed_body (); - DEBUG_F( ssa_check, stderr, Show_everything, Do_not_fail, false, true); + //DEBUG_F( ssa_check, stderr, Show_everything, Do_not_fail, false, true); setup_debug_flags ( &info); initial_debug_info ( &info); @@ -153,10 +153,10 @@ ipa_structure_reorg ( void) return true; } - DEBUG_L("after reorg_analysis\n"); + //DEBUG_L("after reorg_analysis\n"); bool qualified = reorg_qualification(&info); - DEBUG_L("after reorg_qualification\n"); + //DEBUG_L("after reorg_qualification\n"); //DEBUG_L(""); //DEBUG_F(wolf_fence, &info); @@ -186,6 +186,8 @@ ipa_structure_reorg ( void) } + fprintf (stderr, "info.show_all_reorg_cands_in_detail %s\n", + info.show_all_reorg_cands_in_detail ? "true" : "false"); if ( info.show_all_reorg_cands_in_detail ) { fprintf ( info.reorg_dump_file, "Qualified the following types:\n"); @@ -193,7 +195,7 @@ ipa_structure_reorg ( void) } reorg_common_middle_code( &info); // ??? might not amount to anything - DEBUG_L("after reorg_common_middle_code\n"); + //DEBUG_L("after reorg_common_middle_code\n"); //DEBUG_L(""); //DEBUG_F(wolf_fence, &info); @@ -324,7 +326,7 @@ reorg_analysis ( Info *info) gimple *stmt = gsi_stmt ( gsi); //DEBUG_L ( ""); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - INDENT(2); + //INDENT(2); if ( is_gimple_call ( stmt) ) { // next line has issues but the mechanism is sound @@ -345,34 +347,78 @@ reorg_analysis ( Info *info) //DEBUG_A( "TREE_CODE( bt) == %s\n", code_str( TREE_CODE ( bt))); //DEBUG_A(""); //DEBUG_F(flexible_print, stderr, bt, 1, (dump_flags_t)0); - INDENT(-2); + //INDENT(-2); continue; } if ( TREE_CODE( bt) == VOID_TYPE ) { - // find the use of lhs. If is an assign + // Find the use of lhs. If is an assign // get use the base type of it's lhs. - // Otherwise never mind. + // Otherwise never mind. Note, there + // can be multiple uses but find the "one" + // that's a simple assignment to a typed + // variable. + + #if 0 gimple *use_stmt; use_operand_p immuse; bool yup_a_use = single_imm_use ( t, &immuse, &use_stmt); - //DEBUG_A("VOID case: %sa single imm use, ", yup_a_use ? "" : "not "); - //DEBUG("%san assign\n", - // yup_a_use && is_gimple_assign ( use_stmt) ? "" : "not "); + DEBUG_A("VOID case: %sa single imm use, ", yup_a_use ? "" : "not "); + DEBUG("%san assign\n", + yup_a_use && is_gimple_assign ( use_stmt) ? "" : "not "); if ( TREE_CODE ( t) == SSA_NAME && yup_a_use && is_gimple_assign ( use_stmt) ) { tree use_lhs = gimple_assign_lhs ( use_stmt); bt = base_type_of ( TREE_TYPE ( use_lhs)); + //DEBUG_A("found bt: "); + //DEBUG_F(flexible_print, stderr, bt, 1, (dump_flags_t)0); } else - continue; + { + //DEBUG_A("bailed on base type of complicated case\n"); + //INDENT(-2); + continue; + } + #endif + + tree ssa_name = gimple_call_lhs( stmt); + gimple *use_stmt; + imm_use_iterator iter; + int num_bt = 0; + FOR_EACH_IMM_USE_STMT ( use_stmt, iter, ssa_name) + { + //DEBUG_A("use_stmt: "); + //DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0); + if ( is_assign_from_ssa ( use_stmt ) ) + { + //DEBUG_A("is assign from ssa\n"); + tree lhs_assign = gimple_assign_lhs( use_stmt); + tree lhs_type = TREE_TYPE ( lhs_assign); + tree lhs_base_type = base_type_of ( lhs_type); + if ( TREE_CODE( lhs_base_type) != VOID_TYPE ) + { + //DEBUG_A("not void\n"); + num_bt++; + bt = lhs_base_type; + } + } + } + if ( num_bt != 1 ) + { + //DEBUG_L("bailed on base type of complicated case\n"); + //INDENT(-2); + continue; + } } + + + bool alloc_trigger = is_reorg_alloc_trigger ( stmt); // find if in reorgtypes and get the info (in one call) ReorgType_t *ri = get_reorgtype_info ( bt, info); - if ( ri != NULL && is_reorg_alloc_trigger ( stmt) ) + if ( ri != NULL && alloc_trigger ) { //DEBUG_L( "Found allocaion: \n"); //DEBUG_A( " Reorg: "); @@ -385,13 +431,13 @@ reorg_analysis ( Info *info) } } } - INDENT(-2); + //INDENT(-2); } } } -//DEBUG_L( "possible deletes:\n"); - INDENT(2); + //DEBUG_L( "possible deletes:\n"); + //INDENT(2); // It's LOT more clear to use an iterator here TBD for ( int i = 0; i < info->reorg_type->size (); i++ ) { @@ -407,10 +453,18 @@ reorg_analysis ( Info *info) //DEBUG_A("%d pools\n",n) if ( n != 1 ) { + if ( info->show_all_reorg_cands_in_detail ) + { + fprintf ( info->reorg_dump_file, "Delete ReorgType: "); + flexible_print ( info->reorg_dump_file, + (*(info->reorg_type))[i].gcc_type, + 0, (dump_flags_t)0); + fprintf ( info->reorg_dump_file, ", it has %d pools\n", n); + } delete_reorgtype ( &(*(info->reorg_type))[i], info); } } - INDENT(-2); + //INDENT(-2); //DEBUG_L("after reorg_analysis\n"); remove_deleted_types ( info, &reorg_analysis_debug); @@ -469,7 +523,9 @@ find_decls_and_types ( Info *info) if ( TREE_CODE ( base) == RECORD_TYPE ) { // skip if found before - if ( typeset.find ( base) != typeset.end () ) + tree tmv_type = TYPE_MAIN_VARIANT ( base); + tree tmv_base = tmv_type ? tmv_type : base; + if ( typeset.find ( tmv_base) != typeset.end () ) { //DEBUG_L( " not found\n"); continue; @@ -479,9 +535,9 @@ find_decls_and_types ( Info *info) } #if USE_REORG_TYPES - add_reorg_type ( base, info); + add_reorg_type ( tmv_base, info); #endif - typeset.insert ( base); // ??? + typeset.insert ( tmv_base); // ??? } } @@ -516,16 +572,18 @@ find_decls_and_types ( Info *info) if ( TREE_CODE ( base) == RECORD_TYPE) { - if ( typeset.find ( base) != typeset.end () ) + tree tmv_type = TYPE_MAIN_VARIANT ( base); + tree tmv_base = tmv_type ? tmv_type : base; + if ( typeset.find ( tmv_base) != typeset.end () ) { //INDENT(-2) continue; } #if USE_REORG_TYPES - add_reorg_type ( base, info); + add_reorg_type ( tmv_base, info); #endif - typeset.insert ( base); // ??? + typeset.insert ( tmv_base); // ??? } } //INDENT(-2); @@ -721,6 +779,8 @@ find_decls_and_types ( Info *info) static void add_reorg_type ( tree base, Info *info) { + tree tmv_type = TYPE_MAIN_VARIANT ( base); + tree type2add = tmv_type ? tmv_type : base; ReorgType_t rt = { 0, true, base, NULL, NULL, false, false, false, { 0}, { 0}, { 0, 0, 0, NULL, 0.0, 0.0, false}}; @@ -851,6 +911,14 @@ disq_str_in_str_or_union_helper ( tree type, ReorgType_t *rinfo = get_reorgtype_info ( field_type, info); // base to field type if ( rinfo != NULL ) { + if ( info->show_all_reorg_cands_in_detail ) + { + fprintf ( info->reorg_dump_file, "Delete ReorgType: "); + flexible_print ( info->reorg_dump_file, + rinfo->gcc_type, + 0, (dump_flags_t)0); + fprintf ( info->reorg_dump_file, ", Structure in structure.\n"); + } delete_reorgtype ( rinfo, info); } else { disq_str_in_str_or_union_helper ( field_type, typeset, info ); // base to field type @@ -923,7 +991,11 @@ transformation_legality ( Info *info) // GIMPLE_IL sizeof tree expr // memmove(&astruct_1, &astruct_2, sizeof(struct astruct_s)); // memmove(&astruct_1.b, &astruct_2.b, 2*sizeof(_Bool)); - const bool run_escape_analysis = flag_ipa_dead_field_eliminate && !flag_ipa_instance_interleave && !flag_ipa_field_reorder; + const bool run_escape_analysis = + flag_ipa_dead_field_eliminate && + !flag_ipa_instance_interleave && + !flag_ipa_field_reorder; + if (run_escape_analysis) { bool retval = !info->is_non_escaping_set_empty(); @@ -954,7 +1026,8 @@ transformation_legality ( Info *info) case Not_Supported: //DEBUG_L("deleting %d reorgs for unsuported stmt: ", num); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - disqualify_all_reorgtypes_of ( stmt, num, info); + // TBD This is not working + //disqualify_all_reorgtypes_of ( stmt, num, info); case ReorgT_UserFunc: // TBD ReorgT_Ptr2Zero does not catch all cases of // setting a reorg pointer to zero. One that I @@ -1006,6 +1079,7 @@ transformation_legality_debug ( Info *info, ReorgType *reorg ) static void reorg_common_middle_code ( Info *info) { + if ( BYPASS_TRANSFORM ) return; modify_declarations( info); } @@ -1101,11 +1175,24 @@ disqualify_all_reorgtypes_of ( gimple *stmt, int num, Info *info) { //DEBUG_L("disqualify %d reorgtypes of: ", num); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + if ( info->show_all_reorg_cands_in_detail ) + { + print_gimple_stmt( info->reorg_dump_file, stmt, 0); + } int i; for ( i = 0; i < num; i++ ) { ReorgType_t *reorg_type = get_reorgtype ( stmt, info, i); + //DEBUG_A( "reorg_type = %p\n", reorg_type); + if ( info->show_all_reorg_cands_in_detail ) + { + fprintf ( info->reorg_dump_file, " Delete ReorgType: "); + flexible_print ( info->reorg_dump_file, + (*(info->reorg_type))[i].gcc_type, + 0, (dump_flags_t)0); + fprintf ( info->reorg_dump_file, ", because of gimple above.\n"); + } delete_reorgtype ( reorg_type, info); } } @@ -1131,7 +1218,7 @@ modify_func_type ( struct function *func, Info *info ) tree func_type = TREE_TYPE ( func->decl); //DEBUG_L("old func_type = "); //DEBUG_F( flexible_print, stderr, func_type, 1, (dump_flags_t)0); - INDENT(4); + //INDENT(4); tree new_type; tree func_ret_type = TREE_TYPE ( func_type); tree base = base_type_of ( func_ret_type); @@ -1171,13 +1258,14 @@ modify_func_type ( struct function *func, Info *info ) ri = get_reorgtype_info ( base, info); if ( ri != NULL ) { + int levels = number_of_levels ( type_of_arg ); if ( number_of_levels ( type_of_arg ) == 1 ) { new_arg_type = TYPE_MAIN_VARIANT ( ri->pointer_rep); } else { - gcc_assert(0); + new_arg_type = make_multilevel ( ri->pointer_rep, levels); } } else @@ -1196,7 +1284,7 @@ modify_func_type ( struct function *func, Info *info ) //DEBUG_A("new args = "); //DEBUG_F( flexible_print, stderr, new_args, 1, (dump_flags_t)0); - INDENT(-4); + //INDENT(-4); new_type = build_function_type ( func_ret_type, new_args); //DEBUG_L("new_type (func) = "); @@ -1238,6 +1326,18 @@ tree prev_type; return levels; } +tree +make_multilevel( tree base_type, int levels_indirection) +{ + if ( levels_indirection == 0 ) + return base_type; + else + { + tree lower = make_multilevel ( base_type, levels_indirection - 1); + return build_pointer_type ( lower); + } +} + static bool modify_func_decl_core ( struct function *func, Info *info) { @@ -1460,7 +1560,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) { //DEBUG_L ( "ReorgTransformation reorg_recognize for: "); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - INDENT(2); + //INDENT(2); switch ( gimple_code( stmt) ) { case GIMPLE_ASSIGN: @@ -1472,24 +1572,26 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) if ( gimple_assign_single_p ( stmt) ) { //DEBUG_L("gimple_assign_single_p() = true\n"); - INDENT(2); + //INDENT(2); tree rhs = gimple_assign_rhs1 ( stmt); enum ReorgOpTrans lhs_op = recognize_op ( lhs, true, info); switch ( lhs_op ) { case ReorgOpT_Pointer: // "a" //DEBUG_L("case ReorgOpT_Pointer\n"); - INDENT(-4); + //INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Scalar: - if ( integer_zerop ( rhs) ) { - return ReorgT_Ptr2Zero; + if ( integer_zerop ( rhs) ) + { + return ReorgT_Ptr2Zero; + } + // If we get here this is clearly really odd code + // so we need to bail out. + return Not_Supported; } - // If we get here this is clearly really odd code - // so we need to bail out. - return Not_Supported; case ReorgOpT_Temp: // t return ReorgT_ElemAssign; case ReorgOpT_Address: // "&x[i]" @@ -1499,7 +1601,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) } case ReorgOpT_Struct: // "s" //DEBUG_L("case ReorgOpT_Struct\n"); - INDENT(-4); + //INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Deref: // "*a" @@ -1516,7 +1618,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) } case ReorgOpT_Deref: // "*a" //DEBUG_L("case ReorgOpT_Deref\n"); - INDENT(-4); + //INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Deref: // "*a" @@ -1528,7 +1630,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) } case ReorgOpT_Array: // "x[i]" //DEBUG_L("case ReorgOpT_Array\n"); - INDENT(-4); + //INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Struct: // "s" @@ -1541,7 +1643,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) case ReorgOpT_Temp: // t case ReorgOpT_Scalar: // "z" //DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Temp ? "Temp" : "Scalar"); - INDENT(-4); + //INDENT(-4); switch ( recognize_op( rhs, true, info) ) { case ReorgOpT_Scalar: // "z" @@ -1555,42 +1657,43 @@ 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); + //INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { + case ReorgOpT_Cst: // k case ReorgOpT_Temp: // t case ReorgOpT_Scalar: // "z" case ReorgOpT_Indirect: // "a->f" case ReorgOpT_AryDir: // "x[i].f" return ReorgT_ElemAssign; + case ReorgOpT_Cst0: + return ReorgT_Ptr2Zero; default: return Not_Supported; } default: - INDENT(-4); + //INDENT(-4); return Not_Supported; } // switch ( recognize_op ( lhs, true, info) ) } else { //DEBUG_L("gimple_assign_single_p() = false\n"); - INDENT(2); + //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"); - + //DEBUG_F( flexible_print, stderr, op1, 1, TDF_DETAILS); if ( CONVERT_EXPR_CODE_P ( gimple_assign_rhs_code ( stmt))) { //DEBUG_L("CONVERT_EXPR_CODE_P (...)\n"); - INDENT(-4); + //INDENT(-4); return ReorgT_Convert; } if ( gimple_assign_rhs3 ( stmt) != NULL ) { //DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n"); - INDENT(-4); + //INDENT(-4); return Not_Supported; } @@ -1601,7 +1704,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) || (POINTER_TYPE_P ( TREE_TYPE( op2)) && integer_zerop ( op1))) && ( integer_zerop ( op1) || integer_zerop ( op2) ); //DEBUG_L("zero_case = %s\n", zero_case ? "true" : "false" ); - INDENT(-4); + //INDENT(-4); switch ( rhs_code ) { case POINTER_PLUS_EXPR: @@ -1664,7 +1767,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) gcc_assert( edge); //DEBUG_L("called function %s gimple_body\n", // edge->callee->has_gimple_body_p() ? "has a" : "has no"); - INDENT(-2); + //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; if ( gimple_call_builtin_p( stmt, BUILT_IN_REALLOC) ) return ReorgT_Realloc; @@ -1685,14 +1788,14 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) break; case GIMPLE_RETURN: //DEBUG_L("GIMPLE_RETURN:\n"); - INDENT(-2); + //INDENT(-2); return ReorgT_Return; break; default: //DEBUG_L ( "didn't support: "); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); //DEBUG( "\n"); - INDENT(-2); + //INDENT(-2); return Not_Supported; } } @@ -1812,17 +1915,28 @@ recognize_op ( tree op, bool lie, Info *info) // case with a bogus RHS. //DEBUG_L(" returns: ReorgOpT_Temp\n"); return ReorgOpT_Temp; + case INTEGER_CST: + if ( integer_zerop ( op) ) + { + //DEBUG_A(" returns: ReorgOpT_Cst0\n"); + return ReorgOpT_Cst0; + } case REAL_CST: case FIXED_CST: case STRING_CST: case COMPLEX_CST: case CONSTRUCTOR: - case INTEGER_CST: case VECTOR_CST: - return ReorgOpT_Cst; + { + //DEBUG_A(" returns: ReorgOpT_Cst\n"); + return ReorgOpT_Cst; + } } tree type = TREE_TYPE ( op); + // This type bases approach seems like crap. + // I'm turning it off to see what breaks. + #if 0 if ( type != NULL && POINTER_TYPE_P (type) ) { //DEBUG_L("POINTER_TYPE_P (type) = true\n"); @@ -1840,41 +1954,74 @@ recognize_op ( tree op, bool lie, Info *info) return ReorgOpT_Scalar; } } + #endif // This might not occur in practice if ( op_code == RECORD_TYPE ) { // The assumption here is that this // is a reorg type. - //DEBUG_L(" returns: ReorgOpT_Struct\n"); + //DEBUG_A(" returns: ReorgOpT_Struct\n"); return ReorgOpT_Struct; } if ( op_code == VAR_DECL ) { tree type = TREE_TYPE ( op); - //DEBUG_L(" recursing on type :"); - //DEBUG_F( flexible_print, stderr, type, 1, TDF_DETAILS); - return recognize_op ( type, true, info); + gcc_assert ( type != NULL ); + if ( POINTER_TYPE_P (type) ) + { + bool a_reorg = is_reorg_type ( type, info); + if ( a_reorg || !lie ) + { + //DEBUG_A(" returns: ReorgOpT_Pointer\n"); + return ReorgOpT_Pointer; + } + else + { + // This would be for when the field of a struct + // element is a pointer that's not a reorg + // pointer. I.e. ReorgT_ElemAssign. That is + // this is while lie for a good purpose. + //DEBUG_L(" returns: ReorgOpT_Scalar\n"); + return ReorgOpT_Scalar; + } + } + //DEBUG_L(" returns: ReorgOpT_Scalar\n"); + return ReorgOpT_Scalar; } tree inner_op = TREE_OPERAND( op, 0); tree inner_type = TREE_TYPE ( inner_op); enum tree_code inner_op_code = TREE_CODE ( inner_op); //DEBUG_L("inner_op = "); - //DEBUG_F( print_generic_expr, stderr, inner_op, TDF_DETAILS); - //DEBUG(", TREE_CODE = %s\n", code_str( TREE_CODE(inner_op))); + //DEBUG_F(flexible_print, stderr, inner_op, 0, (dump_flags_t)0); + //DEBUG(", TREE_CODE = %s\n", code_str( inner_op_code)); if ( op_code == ADDR_EXPR ) { //DEBUG_L("op_code == ADDR_EXPR\n"); - bool a_reorg = is_reorg_type ( inner_op, info); - if ( inner_op_code == ARRAY_REF - && (a_reorg || !lie) ) + if ( inner_op_code == ARRAY_REF ) + { + bool a_reorg = is_reorg_type ( inner_op, info); + if ( a_reorg || !lie ) + { + //DEBUG_L(" returns: ReorgOpT_Address\n"); + return ReorgOpT_Address; + } + } + // TBD shouldn't we be testing for a reorg??? + if ( inner_op_code == VAR_DECL ) { - //DEBUG_L(" returns: ReorgOpT_Address\n"); - return ReorgOpT_Address; + tree var_type = TREE_TYPE ( inner_op ); + bool a_reorg = is_reorg_type ( var_type, info); + if ( a_reorg || !lie ) + { + //DEBUG_L(" returns: ReorgOpT_Address\n"); + return ReorgOpT_Address; + } } } if ( op_code == COMPONENT_REF ) { //DEBUG_L("op_code == COMPONENT_REF\n"); + if ( inner_op_code == INDIRECT_REF ) { //DEBUG_L("TREE_CODE( inner_op) == INDIRECT_REF\n"); @@ -1907,7 +2054,7 @@ recognize_op ( tree op, bool lie, Info *info) bool a_reorg = is_reorg_type ( base_type_of ( inner_type), info); if ( a_reorg || !lie ) { - //DEBUG_L(" returns: ReorgOpT_AryDir\n"); + //DEBUG_A(" returns: ReorgOpT_AryDir\n"); return ReorgOpT_AryDir; } // Just normal field reference otherwise... @@ -1920,7 +2067,7 @@ recognize_op ( tree op, bool lie, Info *info) bool a_reorg = is_reorg_type( base_type_of ( type), info); if ( a_reorg || !lie ) { - //DEBUG_L(" returns: ReorgOpT_Array\n"); + //DEBUG_A(" returns: ReorgOpT_Array\n"); return ReorgOpT_Array; } //DEBUG_L(" returns: ReorgOpT_Scalar\n"); @@ -1935,7 +2082,7 @@ recognize_op ( tree op, bool lie, Info *info) bool a_reorg = is_reorg_type ( type, info); if( a_reorg || !lie ) { - //DEBUG_L(" returns: ReorgOpT_Deref\n"); + //DEBUG_A(" returns: ReorgOpT_Deref\n"); return ReorgOpT_Deref; } //DEBUG_L(" returns: ReorgOpT_Scalar\n"); @@ -1948,6 +2095,8 @@ recognize_op ( tree op, bool lie, Info *info) bool is_reorg_type( tree rt, Info *info ) { + tree tmv_type = TYPE_MAIN_VARIANT ( rt); + tree type2check = tmv_type ? tmv_type : rt; return get_reorgtype_info ( rt, info) != NULL; } @@ -2100,12 +2249,16 @@ bool same_type_p( tree a, tree b ) ReorgType_t * get_reorgtype_info ( tree type, Info* info) { - //DEBUG_L( "get_reorgtype_info\n"); + //DEBUG_L( "get_reorgtype_info: type = "); + //DEBUG_F( flexible_print, stderr, type, 1, (dump_flags_t)0); // Note, I'm going to use the most stupid and slowest possible way // to do this. The advanage is it will be super easy and almost // certainly correct. It will also almost certainly need to be // improved but I get something out there now. + + tree tmv_type = TYPE_MAIN_VARIANT ( type); + tree type2check = tmv_type ? tmv_type : type; for ( std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin (); ri != info->reorg_type->end (); ri++ ) @@ -2118,7 +2271,7 @@ get_reorgtype_info ( tree type, Info* info) //DEBUG_L(""); //DEBUG_F( print_generic_expr, stderr, type, TDF_DETAILS); //DEBUG("\n"); - if ( same_type_p ( ri->gcc_type, type) ) + if ( same_type_p ( ri->gcc_type, type2check) ) { //DEBUG_A( " returns %p\n", &(*ri)); @@ -2160,11 +2313,11 @@ contains_a_reorgtype ( gimple *stmt, Info *info) { //DEBUG_L ( "contains_a_reorgtype: "); //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - INDENT(2); + //INDENT(2); if ( gimple_code ( stmt) == GIMPLE_PHI ) { - INDENT(-2); + //INDENT(-2); tree base = base_type_of ( TREE_TYPE ( PHI_RESULT ( stmt))); return get_reorgtype_info ( base, info); } @@ -2179,7 +2332,7 @@ contains_a_reorgtype ( gimple *stmt, Info *info) walk_gimple_op ( stmt, detect_reorg, &walk_info); - INDENT(-2); + //INDENT(-2); return hi.found_reorg; } } @@ -2263,26 +2416,34 @@ print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detai = identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( reorg->gcc_type))); fprintf ( file, "%*s{ type:%s, #%d, ", leading_space, "",text, reorg->id); - if( reorg->do_dead_field_elim ) { - fprintf ( file, "elim:{ "); - // TBD - fprintf ( file, "}, "); - } + if ( reorg->do_dead_field_elim ) + { + fprintf ( file, "elim:{ "); + // TBD + fprintf ( file, "}, "); + } - if( reorg->do_field_reorder ) { - fprintf ( file, "reorder:{ "); - // TBD - fprintf ( file, "}, "); - } + if ( reorg->do_field_reorder ) + { + fprintf ( file, "reorder:{ "); + // TBD + fprintf ( file, "}, "); + } + + if ( reorg->do_instance_interleave ) + { + fprintf ( file, "inter:{ "); + // TBD + fprintf ( file, "%s, ", + reorg->instance_interleave.multi_pool ? "multi" : "single" ); + // TBD When multi-pool implemented (and found) emit pointer_rep. + fprintf ( file, "}, "); + } + else + { + fprintf ( file, "no interleave, "); + } - if( reorg->do_instance_interleave ) { - fprintf ( file, "inter:{ "); - // TBD - fprintf ( file, "%s, ", - reorg->instance_interleave.multi_pool ? "multi" : "single" ); - // TBD When multi-pool implemented (and found) emit pointer_rep. - fprintf ( file, "}, "); - } if ( reorg->reorg_ver_type != NULL ) { // TBD does this belong here? How will the clone be done with elim and @@ -2487,6 +2648,8 @@ print_function ( FILE *file, int leading_space, struct function *func) ReorgType_t * get_reorgtype( gimple *stmt, Info *info, int i) { + //DEBUG_A("get_reorgtype: i = %d, stmt = ", i); + //DEBUG_F(print_gimple_stmt, stderr, stmt, 0); // Looking at operands of statement, when we get to // the ith one, return it. int num_reorgs = 0; @@ -2496,11 +2659,37 @@ get_reorgtype( gimple *stmt, Info *info, int i) { tree op = gimple_op ( stmt, j); if ( tree_contains_a_reorgtype_p ( op, info) ) { - num_reorgs++; if ( num_reorgs == i ) { - return get_reorgtype_info ( op, info); + //DEBUG_A("op = "); + //DEBUG_F( flexible_print, stderr, op, 1, (dump_flags_t)0); + + if ( TREE_CODE ( op) == COMPONENT_REF ) + { + tree field_op = TREE_OPERAND ( op, 1); + tree field_type = TREE_TYPE ( field_op); + tree base_field_type = base_type_of ( field_type); + //DEBUG_A("field_op = "); + //DEBUG_F( flexible_print, stderr, field_op, 1, (dump_flags_t)0); + //DEBUG_A("field_type = "); + //DEBUG_F( flexible_print, stderr, field_type, 1, (dump_flags_t)0); + //DEBUG_A("base_field_type = "); + //DEBUG_F( flexible_print, stderr, base_field_type, 1, (dump_flags_t)0); + return get_reorgtype_info ( base_field_type, info); + } + else + { + tree op_type = TREE_TYPE ( op); + tree op_base_type = base_type_of ( op_type); + //DEBUG_A("op_type = "); + //DEBUG_F( flexible_print, stderr, op_type, 1, (dump_flags_t)0); + //DEBUG_A("op_base_type = "); + //DEBUG_F( flexible_print, stderr, op_base_type, 1, (dump_flags_t)0); + + return get_reorgtype_info ( op_base_type, info); + } } + num_reorgs++; } } gcc_assert ( 0); @@ -2600,6 +2789,22 @@ modify_ssa_name_type ( tree ssa_name, tree type) } } +bool +is_assign_from_ssa ( gimple *stmt ) +{ + if ( is_gimple_assign ( stmt) ) + { + //DEBUG_A("is gimple assign\n"); + if ( gimple_assign_rhs_class ( stmt) == GIMPLE_SINGLE_RHS ) + { + //DEBUG_A("has single rhs\n"); + if ( TREE_CODE ( gimple_assign_rhs1 ( stmt)) == SSA_NAME ) + return true; + } + } + return false; +} + //-- debugging only -- //static const char * #if DEBUGGING |