diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-07-14 23:53:07 -0700 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-09-08 09:05:45 +0200 |
commit | 3edbe468efe76c082d2789cf322c3d2e0f05f8e0 (patch) | |
tree | 128f4dbcb92eec522a6ebb86f0792b70edab47f5 | |
parent | ec460300e657ad36ec498f520670c6b7259b1e19 (diff) |
Added decl printing tp print_program.
Fixed bug in modify_decl_core (now actually modifies decls.)
Also added relayout_decl call and modified decl_initial valure
when it exists.
-rw-r--r-- | gcc/ipa-structure-reorg.c | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 3376f00590a..80b0acb4c83 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-collector.hpp" #include "gimple-escaper.hpp" #include "collect-types.h" +#include "stor-layout.h" static void setup_debug_flags ( Info *); @@ -986,11 +987,16 @@ modify_declarations ( Info *info) //modify_decl_core ( &( pv->gcc_decl->decl), info); modify_decl_core ( &( pv->gcc_decl), info); } + + // Note, do not relayout functions decls.... } static void modify_decl_core ( tree *location, Info *info) { + DEBUG_L("before modify_decl_core"); + DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0); + DEBUG("\n"); tree type = *location; tree base = base_type_of ( type); ReorgType_t *ri = get_reorgtype_info ( base, info); @@ -998,19 +1004,46 @@ modify_decl_core ( tree *location, Info *info) { return; } + // array case -- not doing non-dynamically // allocated arrays yet so this case won't // currently occur - - // pointer case - tree *prev = location; - for ( int level = 0; - POINTER_TYPE_P( type); - type = TREE_TYPE( type), level++ ) + + // borrowed from wrangle_ssa_type + tree prev_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); + } + // 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( "LEVEL ZERO\n"); + //modify_ssa_name_type ( side, ri->pointer_rep); + TREE_TYPE ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep); + } + else + { + DEBUG_L( "LEVEL > ZERO\n"); + gcc_assert(0); + } + + if ( DECL_INITIAL ( *location) != NULL ) { - prev = &type; + // Note this assumes the levels code above is not general + DECL_INITIAL ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep); } - *prev = ri->pointer_rep; + + relayout_decl ( *location); + + DEBUG_L(" after modify_decl_core"); + DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0); + DEBUG("\n"); } void @@ -1907,6 +1940,7 @@ print_function ( FILE *file, int leading_space, struct function *func) basic_block bb; fprintf ( file, "%*sFunc: ", leading_space + 2, ""); + // Print Func Type print_generic_expr ( file, TREE_TYPE(TREE_TYPE( func->decl)), (dump_flags_t)0); // Print Func Name @@ -1919,17 +1953,28 @@ print_function ( FILE *file, int leading_space, struct function *func) parm = DECL_CHAIN ( parm) ) { print_generic_expr ( file, TREE_TYPE( parm), (dump_flags_t)0); + fprintf ( file, " "); print_generic_expr ( file, parm, (dump_flags_t)0); + fprintf ( file, "; "); } fprintf ( file, ")\n"); - // TBD Print Local Decls + tree decl; + unsigned i; + FOR_EACH_LOCAL_DECL ( func, i, decl) + { + fprintf ( file, "%*s", leading_space + 6, ""); + print_generic_expr ( file, TREE_TYPE( decl), (dump_flags_t)0); + fprintf ( file, " "); + print_generic_expr ( file, decl, (dump_flags_t)0); + fprintf ( file, ";\n"); + } FOR_EACH_BB_FN ( bb, func) { // print bb num - fprintf ( file, "%*sBB %d:", leading_space, "", bb->index ); + fprintf ( file, "%*sBB %d:", leading_space + 4, "", bb->index ); // Tried to use function gimple_dump_bb is here instead of // the following loop but it's worthless. @@ -1940,7 +1985,7 @@ print_function ( FILE *file, int leading_space, struct function *func) FOR_EACH_EDGE ( e, ei, bb->succs ) { basic_block succ_bb = e->dest; - fprintf ( file, " BB%d", succ_bb->index); + fprintf ( file, ", BB%d", succ_bb->index); if ( e->flags & EDGE_TRUE_VALUE ) fprintf ( file, " true"); if ( e->flags & EDGE_FALSE_VALUE ) fprintf ( file, " false"); if ( e->flags & EDGE_FALLTHRU ) fprintf ( file, " fallthru"); @@ -1953,7 +1998,7 @@ print_function ( FILE *file, int leading_space, struct function *func) gimple_stmt_iterator phii; for ( phii = gsi_start (seq); !gsi_end_p (phii); gsi_next (&phii)) { - fprintf ( file, "%*s", leading_space + 2, "" ); + fprintf ( file, "%*s", leading_space + 6, "" ); print_gimple_stmt ( file, gsi_stmt ( phii), 0, TDF_DETAILS); } } @@ -1964,7 +2009,7 @@ print_function ( FILE *file, int leading_space, struct function *func) gsi_next ( &gsi) ) { gimple *stmt = gsi_stmt ( gsi); - fprintf ( file, "%*s", leading_space + 2, "" ); + fprintf ( file, "%*s", leading_space + 6, "" ); // Issue: for "if" this does not print the gotos. print_gimple_stmt ( file, stmt, 0, TDF_DETAILS); } |