diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-06-04 10:02:24 -0700 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-06-04 10:07:20 -0700 |
commit | c7947a5375748e2e2a1b9d6f9f0ba1a37be56dbb (patch) | |
tree | 2064d67f145d88ea1563ced9ea6d6d9b5613eaf1 | |
parent | 1c721a6592240ec17c190daf0f5897ce6f3046c8 (diff) |
Some more cleanup and fixing... not done yet!
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 36 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.c | 135 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.h | 7 |
3 files changed, 133 insertions, 45 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index b0337a00cdb..fd87336152d 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -110,7 +110,7 @@ str_reorg_instance_interleave_trans ( Info *info) switch( trans) { case ReorgT_StrAssign: - DEBUG("ReorgT_StrAssign\n"); + DEBUG_L("ReorgT_StrAssign\n"); // TBD /* tree lhs = gimple_assign_lhs( stmt); @@ -170,7 +170,7 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_ElemAssign: - DEBUG("ReorgT_ElemAssign\n"); + DEBUG_L("ReorgT_ElemAssign\n"); /* tree lhs = gimple_assign_lhs( stmt); tree rhs = gimple_assign_rhs( stmt); @@ -200,7 +200,7 @@ str_reorg_instance_interleave_trans ( Info *info) break; case ReorgT_If_Null: case ReorgT_If_NotNull: - DEBUG("ReorgT_If_(Not)Null\n"); + DEBUG_L("ReorgT_If_(Not)Null\n"); /* gimple_cond_set_rhs( stmt, TYPE_MIN_VALUE( pointer_sized_int_node)); @@ -212,11 +212,11 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_IfPtrGT: case ReorgT_IfPtrLE: case ReorgT_IfPtrGE: - DEBUG("ReorgT_IfPtr*\n"); + DEBUG_L("ReorgT_IfPtr*\n"); // Not needed for single pool. break; case ReorgT_PtrPlusInt: // "a = b + i" - DEBUG("ReorgT_PtrPlusInt\n"); + DEBUG_L("ReorgT_PtrPlusInt\n"); /* // Does the type of stmt need to be adjusted? I assume so. // The ReorgType contains the type of the pointer @@ -243,7 +243,7 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_Ptr2Zero: // "a = 0" - DEBUG("ReorgT_Ptr2Zero\n"); + DEBUG_L("ReorgT_Ptr2Zero\n"); /* // Note, this is way too simple... just saying. gimple_set_op( stmt, 1, @@ -251,11 +251,11 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_PtrDiff: // "i = a - b" - DEBUG("ReorgT_PtrDiff\n"); + DEBUG_L("ReorgT_PtrDiff\n"); // Do nothing in the single pool case. break; case ReorgT_Adr2Ptr: // "a = &x[i]" - DEBUG("ReorgT_Adr2Ptr\n"); + DEBUG_L("ReorgT_Adr2Ptr\n"); /* tree *add_stmt = gimple_build_assign( @@ -272,7 +272,7 @@ str_reorg_instance_interleave_trans ( Info *info) break; case ReorgT_PtrNull: // "x = a == 0" case ReorgT_PtrNotNull: // "x = a != 0" - DEBUG("ReorgT_Ptr(Not)Null\n"); + DEBUG_L("ReorgT_Ptr(Not)Null\n"); /* gimple_set_op( stmt, 2, TYPE_MIN_VALUE( pointer_sized_int_node)); @@ -284,11 +284,11 @@ str_reorg_instance_interleave_trans ( Info *info) case ReorgT_PtrLE: // "i = a <= b" case ReorgT_PtrGT: // "i = a > b" case ReorgT_PtrGE: // "i = a >= b" - DEBUG("ReorgT_Ptr*\n"); + DEBUG_L("ReorgT_Ptr*\n"); // Not needed for single pool. break; case ReorgT_Malloc: - DEBUG("ReorgT_Malloc\n"); + DEBUG_L("ReorgT_Malloc\n"); /* // Note, unlike other simpler transformations, // this must build new basic blocks to add new @@ -505,7 +505,7 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_Calloc: - DEBUG("ReorgT_Calloc\n"); + DEBUG_L("ReorgT_Calloc\n"); /* // This used to be almost a clone of the old version of // the malloc code above and needs to transformed just like @@ -590,7 +590,7 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_Realloc: - DEBUG("ReorgT_Realloc\n"); + DEBUG_L("ReorgT_Realloc\n"); /* // This used to be closely related to the old version of // the malloc code above and needs to transformed just like @@ -667,7 +667,7 @@ str_reorg_instance_interleave_trans ( Info *info) */ break; case ReorgT_Free: - DEBUG("ReorgT_Free\n"); + DEBUG_L("ReorgT_Free\n"); // We won't free the base because it a global. /* for each element of base { @@ -678,6 +678,14 @@ str_reorg_instance_interleave_trans ( Info *info) delete stmt */ break; + case ReorgT_UserFunc: + // TBD The type must be adjusted (maybe.) + DEBUG_L("ReorgT_UserFunc\n"); + break; + case ReorgT_Return: + // TBD The type must be adjusted (maybe.) + DEBUG_L("ReorgT_Return\n"); + break; default: internal_error( "Invalid transformation"); } diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 4efb109a018..f2c25b588cf 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -73,6 +73,7 @@ static void reorg_forbidden ( gimple *, Info_t *); //static ReorgTransformation reorg_recognize ( gimple *, Info_t *); //static bool is_reorg_type ( tree, Info_t *); //static tree base_type_of ( tree); +static bool is_user_function ( gimple *, Info *); static bool is_reorg_alloc_trigger ( gimple *); static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info_t *); //static ReorgType_t *get_reorgtype_info ( tree, Info_t *); @@ -93,8 +94,8 @@ static bool uses_field_of_reorgtypes( gimple *, Info_t *); #if DEBUGGING static const char *code_str( enum tree_code); static const char *type_name_to_str( tree); -static void handle_debug_indenting( int); -static int debug_indenting = 0; +//static void handle_debug_indenting( int); +int debug_indenting = 0; #endif //---------------- Code Follows ---------------- @@ -788,6 +789,7 @@ disq_str_in_str_or_union_helper ( tree type, { //DEBUG_A( ": ", DECL_NAME( fld)); //DEBUG_F( print_generic_decl, stderr, fld, (dump_flags_t)-1); + //DEBUG_F( print_generic_decl, stderr, fld, (dump_flags_t)-1); //DEBUG( " -- "); //INDENT(2); @@ -985,7 +987,8 @@ undelete_reorgtype ( ReorgType_t *rt, Info_t *info ) ReorgTransformation reorg_recognize ( gimple *stmt, Info_t *info ) { - DEBUG_L("ReorgTransformation reorg_recognize(...):\n"); + DEBUG_L ( "ReorgTransformation reorg_recognize for: "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); INDENT(2); switch ( gimple_code( stmt) ) { @@ -1000,7 +1003,8 @@ reorg_recognize ( gimple *stmt, Info_t *info ) DEBUG_L("gimple_assign_single_p() = true\n"); INDENT(2); tree rhs = gimple_assign_rhs1 ( stmt); - switch ( recognize_op ( lhs, info) ) + enum ReorgOpTrans lhs_op = recognize_op ( lhs, info); + switch ( lhs_op ) { case ReorgOpT_Pointer: // "a" DEBUG_L("case ReorgOpT_Pointer\n"); @@ -1056,11 +1060,13 @@ reorg_recognize ( gimple *stmt, Info_t *info ) default: return Not_Supported; } + case ReorgOpT_Temp: // t case ReorgOpT_Scalar: // "z" - DEBUG_L("case ReorgOpT_Scalar\n"); + DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Temp ? "Temp" : "Scalar"); INDENT(-4); switch ( recognize_op( rhs, info) ) { + case ReorgOpT_Temp: // "t" case ReorgOpT_Indirect: // "a->f" case ReorgOpT_AryDir: // "x[i].f" return ReorgT_ElemAssign; @@ -1069,10 +1075,11 @@ reorg_recognize ( gimple *stmt, Info_t *info ) } case ReorgOpT_Indirect: // "a->f" case ReorgOpT_AryDir: // "x[i].f" - DEBUG_L("case ReorgOpT_Indirect\n"); + DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Indirect ? "Indirect" : "AryDir"); INDENT(-4); switch ( recognize_op ( rhs, info) ) { + case ReorgOpT_Temp: // t case ReorgOpT_Scalar: // "z" case ReorgOpT_Indirect: // "a->f" case ReorgOpT_AryDir: // "x[i].f" @@ -1161,18 +1168,73 @@ reorg_recognize ( gimple *stmt, Info_t *info ) } } case GIMPLE_CALL: - DEBUG_L("GIMPLE_COND:\n"); + { + DEBUG_L("GIMPLE_CALL:\n"); + 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; + if ( gimple_call_builtin_p( stmt, BUILT_IN_FREE ) ) return ReorgT_Free; + + // Instead of just returning Not_Supported we need to + // determine if it's a user defined function in which case the + // transformation is meaningless but the type still needs to be + // adjusted (does transform really do this?) + + if ( is_user_function ( stmt, info) ) + { + return ReorgT_UserFunc; + } + + return Not_Supported; + } + break; + case GIMPLE_RETURN: + DEBUG_L("GIMPLE_RETURN:\n"); 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; - if ( gimple_call_builtin_p( stmt, BUILT_IN_FREE ) ) return ReorgT_Free; - return Not_Supported; + return ReorgT_Return; + break; default: + DEBUG_L ( "didn't support: "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + DEBUG( "\n"); + INDENT(-2); return Not_Supported; } } +static bool +is_user_function ( gimple *call_stmt, Info *info) +{ + tree fndecl = gimple_call_fndecl ( call_stmt); + + DEBUG_L("is_user_function: decl in: %p,", fndecl); + DEBUG_F( print_generic_decl, stderr, fndecl, (dump_flags_t)-1); + DEBUG("\n"); + INDENT(2); + + gcc_assert ( fndecl); + + cgraph_node* node; + bool ret_val = false; + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) + { + DEBUG_L("decl %p,", node->decl); + DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)-1); + DEBUG("\n"); + + if ( node->decl == fndecl ) + { + ret_val = true; + break; + } + } + + INDENT(-2); + return true; // <==== Evil work around!!!!!! + return ret_val; +} + void clear_deleted_types( Info *info) { @@ -1300,15 +1362,17 @@ recognize_op ( tree op, Info *info) DEBUG_L(" returns: ReorgOpT_Struct\n"); return ReorgOpT_Struct; } - tree inter_op = TREE_OPERAND( op, 0); - DEBUG_L("inter_op = "); - DEBUG_F( print_generic_expr, stderr, inter_op, TDF_DETAILS); - DEBUG("\n"); + 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))); if ( op_code == ADDR_EXPR ) { DEBUG_L("op_code == ADDR_EXPR\n"); - if ( TREE_CODE ( inter_op) == ARRAY_REF - && is_reorg_type ( inter_op, info) ) + if ( inner_op_code == ARRAY_REF + && is_reorg_type ( inner_op, info) ) { DEBUG_L(" returns: ReorgOpT_Address\n"); return ReorgOpT_Address; @@ -1317,10 +1381,10 @@ recognize_op ( tree op, Info *info) if ( op_code == COMPONENT_REF ) { DEBUG_L("op_code == COMPONENT_REF\n"); - if ( TREE_CODE( inter_op) == INDIRECT_REF ) + if ( inner_op_code == INDIRECT_REF ) { - DEBUG_L("TREE_CODE( inter_op) == INDIRECT_REF\n"); - if ( is_reorg_type ( base_type_of ( type), info) ) + DEBUG_L("TREE_CODE( inner_op) == INDIRECT_REF\n"); + if ( is_reorg_type ( base_type_of ( type), info) ) // inner_type??? { DEBUG_L(" returns: ReorgOpT_Indirect\n"); return ReorgOpT_Indirect; @@ -1328,20 +1392,30 @@ recognize_op ( tree op, Info *info) // Just normal field reference otherwise... DEBUG_L(" returns: ReorgOpT_Scalar\n"); return ReorgOpT_Scalar; - } else { - DEBUG_L("TREE_CODE( inter_op) != INDIRECT_REF\n"); - // Note, doesn't this ignore ARRAY_REF of this? - // I think it's OK at least until we start supporting - // multi-pools. - if ( is_reorg_type ( base_type_of ( type), info) ) + } + if ( inner_op_code == MEM_REF ) { + DEBUG_L("TREE_CODE( inner_op) == MEM_REF\n"); + if ( is_reorg_type ( base_type_of ( inner_type), info) ) { - DEBUG_L(" returns: ReorgOpT_AryDir\n"); - return ReorgOpT_AryDir; + DEBUG_L(" returns: ReorgOpT_Indirect\n"); + return ReorgOpT_Indirect; // TBD } // Just normal field reference otherwise... DEBUG_L(" returns: ReorgOpT_Scalar\n"); return ReorgOpT_Scalar; } + DEBUG_L("TREE_CODE( inner_op) not INDIRECT_REF or MEM_REF\n"); + // Note, doesn't this ignore ARRAY_REF of this? + // I think it's OK at least until we start supporting + // multi-pools. + if ( is_reorg_type ( base_type_of ( inner_type), info) ) + { + DEBUG_L(" returns: ReorgOpT_AryDir\n"); + return ReorgOpT_AryDir; + } + // Just normal field reference otherwise... + DEBUG_L(" returns: ReorgOpT_Scalar\n"); + return ReorgOpT_Scalar; } if ( op_code == ARRAY_REF ) { @@ -1745,6 +1819,7 @@ code_str( enum tree_code tc) case RESULT_DECL: return "RESULT_DECL"; default: + return get_tree_code_name ( tc); switch( TREE_CODE_CLASS( tc) ) { case tcc_type: @@ -1768,7 +1843,7 @@ type_name_to_str ( tree tn) } #if DEBUGGING -static void +void handle_debug_indenting ( int amount ) { debug_indenting += amount; diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index 34cd271c4c8..a379943c05f 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -110,6 +110,8 @@ enum ReorgTransformation { ReorgT_Calloc, // ReorgT_Realloc, // ReorgT_Free, // + ReorgT_UserFunc, // + ReorgT_Return, // return t Not_Supported }; @@ -179,8 +181,11 @@ extern void print_type ( FILE *, tree); // defined marcos in the code. However, some of uses // should obviously be converted to dump file information. -#define DEBUGGING 0 +#define DEBUGGING 1 #if DEBUGGING +extern int debug_indenting; +extern void handle_debug_indenting( int); + // Line numbered #define DEBUG_L(...) { fprintf( stderr, "L# %4d: %*s", __LINE__, debug_indenting, ""); fprintf( stderr, __VA_ARGS__); } // Alinged with line numbered |