summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-06-19 10:59:12 -0700
committerGary Oblock <gary@amperecomputing.com>2020-06-19 10:59:12 -0700
commit35e226d2866a18045a97942b03ca593901f7a79b (patch)
treefdcd2777b9fada849f5a24c088947cf8d2b94462
parent8f31158edf7ba386f144faa525d3babe0ff54349 (diff)
element access code in place but not functional
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c119
-rw-r--r--gcc/ipa-structure-reorg.c4
-rw-r--r--gcc/ipa-structure-reorg.h1
3 files changed, 87 insertions, 37 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 71f42a10c30..be7596bbed4 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -110,6 +110,9 @@ str_reorg_instance_interleave_trans ( Info *info)
ReorgType_t *ri = contains_a_reorgtype( stmt, info);
if ( ri != NULL )
{
+ DEBUG_F( print_reorg_with_msg, stderr, ri, 0,
+ "reorg from str_reorg_instance_interleave_trans");
+
enum ReorgTransformation trans =
reorg_recognize ( stmt, node, info);
// print out trans and stmt if dumping
@@ -187,6 +190,7 @@ str_reorg_instance_interleave_trans ( Info *info)
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);
@@ -200,52 +204,96 @@ str_reorg_instance_interleave_trans ( Info *info)
case ReorgOpT_Indirect:
{
DEBUG_L("%s: ", ro_on_left ? "lhs" : "rhs");
- DEBUG_F( print_generic_expr, stderr, ro_side, (dump_flags_t)-1);
- DEBUG("\n");
- DEBUG_L("ReorgT_Indirect\n");
- // Note, there are lot's of missing low level details here
- // A,B are new SSA
- tree temp_A =
- make_temp_ssa_name( sizetype, NULL, "temp_A");
- tree temp_B =
- make_temp_ssa_name( sizetype, NULL, "temp_B");
- // type_name( rhs) is a little sloppy because it's the type
- // name if the "a" that matters and not the type name of
- // "a->f."
-
- // generate A <- concat( REORG_SP_PREFIX, type_name( rhs)) BOGUS
- // and insert before stmt BOGUS
- // NOTE, we have the base so what we are really generating is
- // A <- base.f since "a" is an index and not a pointer.
- // TBD we need field and should use the type of it from base
- //
-
- // This is experimental
- tree inner_op = TREE_OPERAND( ro_side, 0);
- DEBUG_L("EXPT: ");
- DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)-1);
+ DEBUG_F(print_generic_expr,stderr,ro_side,(dump_flags_t)-1);
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("\n");
- //tree orig_field = TBD;
- tree orig_field; // = TBD
tree base_field =
find_coresponding_field ( base, orig_field);
+ DEBUG_L("base_field:\n");
+ DEBUG_F(print_generic_expr, stderr, base_field, (dump_flags_t)-1);
+ tree base_field_type = TREE_TYPE( base_field);
+
+ tree field_val_temp =
+ make_temp_ssa_name( field_type, NULL, "field_val_temp");
+
+ tree inner_op = TREE_OPERAND( ro_side, 0);
+ //DEBUG_L("EXPT: ");
+ //DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)-1);
+ //DEBUG("\n");
+
+ // ?? why is this here
tree rhs_ass = build3 ( COMPONENT_REF,
ptr_type_node,
base,
base_field,
NULL_TREE);
+
+ // For either case generate common code:
- // generate B <- A->"f"
- // and insert before stmt
- // NOTE, we really generate B <- A[a]
+ // field_array = _base.f
+ tree field_arry_addr =
+ make_temp_ssa_name( field_type, NULL, "field_arry_addr");
+ tree rhs_faa = build3 ( COMPONENT_REF,
+ base_field_type,
+ base,
+ base_field,
+ NULL_TREE);
+ gimple *get_field_arry_addr =
+ gimple_build_assign( field_arry_addr, rhs_faa);
- // generate lhs <- B
- // and insert before stmt
+ // 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;
+ 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);
+ }
+ 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);
+
+ // lhs = temp
+ final_set = gimple_build_assign( lhs, field_val_temp);
+ }
+ // Note, since we are adding gimple in reverse
+ // execution order, do it here.
+ gsi_insert_before( &gsi, final_set, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, get_index, GSI_SAME_STMT);
+ gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT);
+
//delete stmt
gsi_remove ( &gsi, true);
@@ -253,14 +301,15 @@ str_reorg_instance_interleave_trans ( Info *info)
break;
case ReorgOpT_AryDir: // "x[i].f"
// Not implemented in single pool
- internal_error ( "ReorgT_AryDir not possible");
+ internal_error ( "ReorgOpT_AryDir not possible");
default:
internal_error (
- "Reached operand default for ReorgT_Indirect");
+ "Reached operand default for ReorgOpT_Indirect");
} // end recognize_op ( rhs, info) switch
} // end ReorgT_ElemAssign case
+ INDENT(-2);
break;
case ReorgT_If_Null:
case ReorgT_If_NotNull:
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index b186b2aa8f3..6d474b2dfd4 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -82,7 +82,7 @@ static bool is_user_function ( gimple *, cgraph_node *, Info *);
static bool is_reorg_alloc_trigger ( gimple *);
static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info *);
//static ReorgType_t *get_reorgtype_info ( tree, Info *);
-static void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *);
+//static void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *);
static void dump_reorg ( ReorgType_t *reorg);
static void print_reorgs ( FILE *, int, Info *);
//static void print_reorg ( FILE *, int, ReorgType_t *);
@@ -1692,7 +1692,7 @@ tree_contains_a_reorgtype_p ( tree expr, Info *info)
return tre_hi.found_reorg != NULL;
}
-static void
+void
print_reorg_with_msg ( FILE *file,
ReorgType_t *reorg,
int leading_space,
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index 82ee1ebca16..149863fea9b 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -223,6 +223,7 @@ extern ReorgTransformation reorg_recognize ( gimple *,
cgraph_node *,
Info_t *);
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 *);
extern bool tree_contains_a_reorgtype_p ( tree, Info *);
extern bool is_reorg_type ( tree, Info_t *);