summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-06-24 21:40:56 -0700
committerGary Oblock <gary@amperecomputing.com>2020-06-24 21:40:56 -0700
commitcb7743d77a90b9f5c696741e22daece19bb70764 (patch)
tree856c54f8b2ceb87c58ea21e30e8b226b856373f2
parent7b3ec9fa1d93e60f5083efaebaf1f17abeb978d1 (diff)
Added transform for pointer plus int. Added mini-pass for dangling SSA temps.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c111
-rw-r--r--gcc/ipa-structure-reorg.c12
2 files changed, 84 insertions, 39 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 0408c8851c4..70b27e170fe 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -114,8 +114,7 @@ str_reorg_instance_interleave_trans ( Info *info)
if ( ri == NULL )
{
DEBUG_L("No Transfrom on: ");
- DEBUG_F( print_gimple_expr, stderr, stmt, 4, TDF_SLIM);
- DEBUG("\n");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
}
else
{
@@ -127,7 +126,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// print out trans and stmt if dumping
if ( info->show_transforms )
{
- print_gimple_expr( info->reorg_dump_file, stmt, 4, TDF_SLIM);
+ print_gimple_stmt( info->reorg_dump_file, stmt, 0);
}
switch ( trans)
@@ -194,6 +193,7 @@ str_reorg_instance_interleave_trans ( Info *info)
break;
case ReorgT_ElemAssign:
{
+ break;
#if 0
gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
@@ -663,39 +663,45 @@ str_reorg_instance_interleave_trans ( Info *info)
// Not needed for single pool.
break;
case ReorgT_PtrPlusInt: // "a = b + i"
- DEBUG_L("ReorgT_PtrPlusInt\n");
- // Needed for hellowotrld
- /*
- // Does the type of stmt need to be adjusted? I assume so.
- // The ReorgType contains the type of the pointer
- // if so that should probably be used. Note, the variables
- // should all be of the correct type (but maybe that's
- // not reflected here. Punting and assigning the types to
- // the type of pointer_sized_int_node is probably not correct
- // even though that's the representation.
- tree type = TREE_TYPE( gimple_assign_lhs( stmt));
- tree tmp =
- make_temp_ssa_name( type, NULL, "PtrPlusInt")
- gimple *adjust_stmt =
- gimple_build_assign(
- tmp,
- TRUNC_DIV_EXPR,
- gimple_assign_rhs2( stmt),
- build_int_cst( type, TYPE_SIZE_UNIT( ri->gcc_type)),
- NULL_TREE, NULL_TREE);
- // 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);
- gsi = gsi_for_stmt( stmt);
- gsi_insert_before( gsi, adjust_stmt, GSI_SAME_STMT);
- */
+ {
+ DEBUG_L("ReorgT_PtrPlusInt: ");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+ // Needed for hellowotrld
+
+ // Does the type of stmt need to be adjusted? I assume so.
+ // The ReorgType contains the type of the pointer
+ // if so that should probably be used. Note, the variables
+ // should all be of the correct type (but maybe that's
+ // not reflected here. Punting and assigning the types to
+ // the type of pointer_sized_int_node is probably not correct
+ // even though that's the representation.
+
+ tree type = ri->pointer_rep;
+ tree tmp = make_temp_ssa_name( type, NULL, "PtrPlusInt");
+ tree str_siz =
+ build_int_cst ( type, int_cst_value ( TYPE_SIZE_UNIT (ri->gcc_type)));
+ tree rhs2 = gimple_assign_rhs2( stmt);
+ gimple *adjust_stmt =
+ gimple_build_assign ( tmp, TRUNC_DIV_EXPR, rhs2, str_siz);
+ // 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);
+ gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
+ gsi_insert_before( &gsi, adjust_stmt, GSI_SAME_STMT);
+
+ DEBUG_L("");
+ DEBUG_F( print_gimple_stmt, stderr, adjust_stmt, 0);
+ DEBUG_L("");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+
+ }
break;
case ReorgT_Ptr2Zero: // "a = 0"
DEBUG_L("ReorgT_Ptr2Zero\n");
/*
- // Note, this is way too simple... just saying.
- gimple_set_op( stmt, 1,
- TYPE_MIN_VALUE( pointer_sized_int_node));
+ // Note, this is way too simple... just saying.
+ gimple_set_op( stmt, 1,
+ TYPE_MIN_VALUE( pointer_sized_int_node));
*/
break;
case ReorgT_PtrDiff: // "i = a - b"
@@ -712,7 +718,7 @@ str_reorg_instance_interleave_trans ( Info *info)
gimple_assign_rhs1( stmt),
gimple_assign_rhs2( stmt),
NULL_TREE, NULL_TREE);
- gimple_stmt_iterator *gsi = gsi_for_stmt( stmt);
+ gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
gsi_insert_before( gsi, add_stmt, GSI_SAME_STMT);
// delete stmt
gsi_remove( gsi, true);
@@ -1235,6 +1241,15 @@ str_reorg_instance_interleave_trans ( Info *info)
case ReorgT_UserFunc:
// Needed for helloworld.
// TBD The type must be adjusted (maybe.)
+
+ // Note, what proably needed is an extra
+ // mini-pass to adjust all "dangling" SSA temps.
+ // I mean dangling in the sense that they are
+ // pointers to a reorg type on the left hand side
+ // of an assign and they haven't been modified to
+ // use the correct reorg pointer represenatation,
+ // even though the right hand side has been.
+
DEBUG_L("ReorgT_UserFunc\n");
break;
case ReorgT_Return:
@@ -1249,6 +1264,36 @@ str_reorg_instance_interleave_trans ( Info *info)
}
pop_cfun ();
}
+
+ // TBD A mini-pass to fixup dangling SSA temps
+ // is run here.
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) {
+ struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
+ // Ulgy GCC idiom with global pointer to current function.
+ 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 ( gimple_code ( stmt) == GIMPLE_ASSIGN )
+ {
+ ReorgType_t *ri = contains_a_reorgtype( stmt, info);
+ if ( ri != NULL )
+ {
+ tree lhs = gimple_assign_lhs( stmt);
+ tree rhs = gimple_assign_rhs1( stmt);
+ gcc_assert ( !tree_contains_a_reorgtype_p ( rhs, info));
+ // etc.
+
+ }
+ }
+ }
+ }
+ pop_cfun ();
+ }
}
static void
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index 6d474b2dfd4..e22770641e8 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -1498,9 +1498,9 @@ is_reorg_type( tree rt, Info *info )
tree
base_type_of ( tree type)
{
- DEBUG_L("base_type_of: ");
- DEBUG_F( print_generic_expr, stderr, type, TDF_DETAILS);
- DEBUG("\n");
+ //DEBUG_L("base_type_of: ");
+ //DEBUG_F( print_generic_expr, stderr, type, TDF_DETAILS);
+ //DEBUG("\n");
for ( ; POINTER_TYPE_P ( type) ||
TREE_CODE ( type) == ARRAY_TYPE ||
TREE_CODE ( type) == VAR_DECL ||
@@ -1628,9 +1628,9 @@ detect_reorg ( tree *tp, int *dummy, void *data)
struct walk_stmt_info *walk_data = ( struct walk_stmt_info *)data;
hidden_info_t *hi = ( hidden_info_t *)walk_data->info;
//ReorgType_t *ri = get_reorgtype_info ( *tp, hi->info); // TBD I suspect this needs base_type_of( TREE_TYPE(*tp))
- DEBUG_L( "*tp = ");
- DEBUG_F( print_generic_expr, stderr, *tp, (dump_flags_t)-1);
- DEBUG("\n");
+ //DEBUG_L( "*tp = ");
+ //DEBUG_F( print_generic_expr, stderr, *tp, (dump_flags_t)-1);
+ //DEBUG("\n");
tree operand = base_type_of ( TREE_TYPE ( *tp));
ReorgType_t *ri = get_reorgtype_info ( operand, hi->info);
if ( ri != NULL )