From 7b3ec9fa1d93e60f5083efaebaf1f17abeb978d1 Mon Sep 17 00:00:00 2001 From: Gary Oblock Date: Wed, 24 Jun 2020 12:59:18 -0700 Subject: a bit of cleanup --- gcc/ipa-str-reorg-instance-interleave.c | 201 +++++++++++++++++++++++++++++++- 1 file changed, 200 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index 68962e5b63d..0408c8851c4 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -194,7 +194,7 @@ str_reorg_instance_interleave_trans ( Info *info) break; case ReorgT_ElemAssign: { - //break; + #if 0 gimple_stmt_iterator gsi = gsi_for_stmt( stmt); DEBUG_L("ReorgT_ElemAssign: "); @@ -379,6 +379,7 @@ str_reorg_instance_interleave_trans ( Info *info) // temp = *field_addr + // I tried MEM_REF here and build1 had an internal error tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr); DEBUG_L("rhs_ref: %p\n", rhs_ref); @@ -431,7 +432,204 @@ str_reorg_instance_interleave_trans ( Info *info) //delete stmt gsi_remove ( &gsi, true); + } // end ReorgOpT_Indirect case + break; + case ReorgOpT_AryDir: // "x[i].f" + // Not implemented in single pool + internal_error ( "ReorgOpT_AryDir not possible"); + default: + internal_error ( + "Reached operand default for ReorgOpT_Indirect"); + + } // end recognize_op ( rhs, info) switch + #else + gimple_stmt_iterator gsi = gsi_for_stmt( stmt); + + 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); + + bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info); + + tree ro_side = ro_on_left ? lhs : rhs; + tree nonro_side = ro_on_left ? rhs : lhs; + + switch ( recognize_op ( ro_side, info) ) // "a->f" + { + case ReorgOpT_Indirect: + { + tree orig_field = TREE_OPERAND( ro_side, 1); + tree field_type = TREE_TYPE( orig_field); + tree base = ri->instance_interleave.base; + + tree base_field = + find_coresponding_field ( base, orig_field); + + 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); + + // For either case generate common code: + + // field_array = _base.f + tree field_arry_addr = + make_temp_ssa_name( base_field_type, NULL, "field_arry_addr"); + + tree rhs_faa = build3 ( COMPONENT_REF, + // ??? + //base_field_type, + ptr_type_node, // This seems bogus + base, + //base_field, + // This almost certainly is bogus + // If this "works" the the types + // of fields are messed up. + orig_field, + NULL_TREE); + + // Use this to access the array of element. + gimple *get_field_arry_addr = + gimple_build_assign( field_arry_addr, rhs_faa); + + // 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 0 + // DELETE THIS + // offset = index * size_of_field + tree size_of_field = TYPE_SIZE_UNIT ( base_field_type); + tree offset = make_temp_ssa_name( sizetype, NULL, "offset"); // TBD sizetype ??? + // DELETE THIS + gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field); + + // DELETE THIS + // field_addr = field_array + offset + // bug fix here (TBD) type must be *double not double + tree field_addr = + make_temp_ssa_name( base_field_type, NULL, "field_addr"); + + // DELETE THIS + gimple *get_field_addr = + gimple_build_assign ( field_addr, PLUS_EXPR, field_arry_addr, offset); + #endif + + 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); + + // MOD THIS to ARRAY_REF + #if 0 + // NOTE, THIS (MEM_REF)SHOULD NOT WORK + // not tested yet! + // *field_addr = temp + tree lhs_ref = build1 ( MEM_REF, field_type, field_addr); + #else + // field_arry_addr[index] + tree lhs_ref = + build4 ( ARRAY_REF, field_type, field_arry_addr, index, + NULL_TREE, NULL_TREE); + #endif + + final_set = + gimple_build_assign( lhs_ref, 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); + + + // MOD THIS to ARRAY_REF + // temp = *field_addr + #if 0 + // I tried MEM_REF here and build1 had an internal error + tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr); + #else + tree rhs_ref = + build4 ( ARRAY_REF, field_type, field_arry_addr, index, + NULL_TREE, NULL_TREE); + #endif + + temp_set = + gimple_build_assign( field_val_temp, rhs_ref); + + // lhs = temp + final_set = gimple_build_assign( lhs, field_val_temp); + } + DEBUG_L("get_field_arry_addr: "); + DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0); + DEBUG("\n"); + + DEBUG_L("get_index: "); + DEBUG_F( print_gimple_stmt, stderr, get_index, 0); + DEBUG("\n"); + + #if 0 + // DELETE THIS + DEBUG_L("get_offset: "); + DEBUG_F( print_gimple_stmt, stderr, get_offset, 0); + DEBUG("\n"); + + // DELETE THIS + DEBUG_L("get_field_addr: "); + DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0); + DEBUG("\n"); + #endif + + DEBUG_L("temp_set: "); + DEBUG_F( print_gimple_stmt, stderr, temp_set, 0); + DEBUG("\n"); + + DEBUG_L("final_set: "); + DEBUG_F( print_gimple_stmt, stderr, final_set, 0); + DEBUG("\n"); + + gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT); + gsi_insert_before( &gsi, get_index, GSI_SAME_STMT); + #if 0 + // DELETE THIS + gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT); + // DELETE THIS + gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT); + #endif + gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); // << malformed??? + gsi_insert_before( &gsi, final_set, GSI_SAME_STMT); + + + //delete stmt + gsi_remove ( &gsi, true); } // end ReorgOpT_Indirect case break; case ReorgOpT_AryDir: // "x[i].f" @@ -442,6 +640,7 @@ str_reorg_instance_interleave_trans ( Info *info) "Reached operand default for ReorgOpT_Indirect"); } // end recognize_op ( rhs, info) switch + #endif } // end ReorgT_ElemAssign case INDENT(-2); -- cgit v1.2.3