diff options
Diffstat (limited to 'gcc/expr-rewriter.c')
-rw-r--r-- | gcc/expr-rewriter.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/gcc/expr-rewriter.c b/gcc/expr-rewriter.c index 746c23b6c0b..892b7e6a415 100644 --- a/gcc/expr-rewriter.c +++ b/gcc/expr-rewriter.c @@ -99,6 +99,11 @@ ExprTypeRewriter::_walk_MEM_REF_post(const_tree e) void ExprTypeRewriter::_walk_SSA_NAME_post(const_tree t) { + // Here, we need to find out + log("we are in expr-rewriter SSA_NAME_post\n"); + TypeStringifier stringifier; + std::string name = stringifier.stringify(TREE_TYPE(t)); + log("%s\n", name.c_str()); } //TODO: @@ -198,6 +203,8 @@ ExprTypeRewriter::handle_pointer_arithmetic_nonconstant(gimple *s, tree op_0, tr // _3 = &array + _2; < -- this is where we are //enum tree_code code = TREE_CODE(op_1); //assert_is_type(op_1, SSA_NAME); + tree new_type = TREE_TYPE(gimple_assign_lhs(s)); + gimple *def_for_variable = SSA_NAME_DEF_STMT(op_1); // It is possible that we are in a negation statement... @@ -229,7 +236,8 @@ ExprTypeRewriter::handle_pointer_arithmetic_nonconstant(gimple *s, tree op_0, tr // op_0 is the variable // That means that the reorg_type is - tree reorg_type_tree = TREE_TYPE(op_0); + // The truth is that op_0 might not have the correct type + tree reorg_type_tree = new_type; tree reorg_inner_type = TREE_TYPE(reorg_type_tree); tree reorg_type_size_tree = TYPE_SIZE_UNIT(reorg_inner_type); int reorg_type_size_int = tree_to_shwi(reorg_type_size_tree); @@ -345,12 +353,34 @@ ExprTypeRewriter::_walk_post(const_tree e) const enum tree_code code = TREE_CODE(e); tree r_t = _map[t]; TREE_TYPE((tree)e) = r_t; - tree type_main_variant = TYPE_MAIN_VARIANT(TREE_TYPE(e)); - const bool do_we_have_mv_in_map = _map.find(type_main_variant) != _map.end(); + + return; + if (code != MEM_REF) return; + + TypeStringifier stringifier; + std::string name = stringifier.stringify(r_t); + tree m = TYPE_MAIN_VARIANT(r_t); + std::string name_m = stringifier.stringify(m); + const bool main_variant = TYPE_MAIN_VARIANT(r_t) == r_t; + log("main: %s\n", name_m.c_str()); + log("we are in memref: %s is_main_variant %s\n", name.c_str(), main_variant ? "t" : "f"); + tree type_size = TYPE_SIZE(r_t); + log("type size 1 %s?", type_size ? "t" : "f"); + if (!type_size) TYPE_SIZE(r_t) = TYPE_SIZE(m); + log("type size 2 %s?", TYPE_SIZE(r_t) ? "t" : "f"); + if (!TYPE_SIZE(r_t)) layout_type(r_t); + log("type size 3 %s?", TYPE_SIZE(r_t) ? "t" : "f"); + // still no type_size + gcc_assert(TYPE_SIZE(r_t)); + const enum tree_code cc = TREE_CODE(TYPE_SIZE(r_t)); + log("%s\n", get_tree_code_name(cc)); + + //tree type_main_variant = TYPE_MAIN_VARIANT(TREE_TYPE(e)); + //const bool do_we_have_mv_in_map = _map.find(type_main_variant) != _map.end(); // TODO: Fix this hack // We need to make sure that the type main variant is already good here... - TYPE_MAIN_VARIANT(TREE_TYPE(e)) = do_we_have_mv_in_map ? _map[type_main_variant] : TYPE_MAIN_VARIANT(TREE_TYPE(e)); + //TYPE_MAIN_VARIANT(TREE_TYPE(e)) = do_we_have_mv_in_map ? _map[type_main_variant] : TYPE_MAIN_VARIANT(TREE_TYPE(e)); } |