diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2004-06-26 21:11:23 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2004-06-26 17:11:23 -0400 |
commit | 350fae6628af14c2e760694d39baec5f7858057c (patch) | |
tree | ec365de72a39a5ef2d0a252b8496e9199f69fb3d /gcc/gimplify.c | |
parent | 6573a10434b3aa2784f052d6ffc3905d8490464e (diff) | |
download | gcc-350fae6628af14c2e760694d39baec5f7858057c.zip gcc-350fae6628af14c2e760694d39baec5f7858057c.tar.gz gcc-350fae6628af14c2e760694d39baec5f7858057c.tar.bz2 |
c-common.c (c_safe_from_p, [...]): Deleted.
2004-06-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* c-common.c (c_safe_from_p, c_walk_subtrees): Deleted.
* c-common.def (DECL_STMT): Remove.
* c-common.h (DECL_STMT_DECL): Deleted.
(COMPOUNT_LITERAL_EXPR_DECL): Use DECL_EXPR_DECL.
(c_safe_from_p, c_walk_subtrees): Deleted.
* c-decl.c, c-parse.in, c-pretty-print.c: DECL_STMT now DECL_EXPR.
* c-dump.c (c_dump_tree, case DECL_STMT): Deleted.
* c-gimplify.c (gimplify_decl_stmt): Deleted.
(gimplify_compound_literal_expr): Use DECL_EXPR_DECL
and gimplify_and_add.
(c_gimplify_expr, case DECL_EXPR): New case.
(c_gimplify_expr, case DECL_STMT): Deleted.
* c-lang.c (LANG_HOOKS_SAFE_FROM_P): Likewise.
(LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Likewise.
* expr.c (safe_from_p, case 's'): New case.
* gimplify.c (gimplify_decl_expr): New function.
(gimplify_expr, case DECL_EXPR): New case.
* tree-inline.c (walk_tree): Walk into all fields of a type and
decl only if they are in a DECL_EXPR.
(mark_local_for_remap_r): Minor code cleanup.
* tree-outof-ssa.c (discover_nonconstant_array_refs_r): Add else.
* tree.c (has_cleanups, case DECL_EXPR): New case.
* tree.def (DECL_EXPR): New code.
* tree.h (DECL_EXPR_DECL): New macro.
* objc/objc-lang.c (LANG_HOOKS_SAFE_FROM_P): Deleted.
From-SVN: r83721
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 347e946..7ef88b5 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -660,7 +660,7 @@ copy_if_shared_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, /* Special-case BIND_EXPR. We should never be copying these, therefore we can omit examining BIND_EXPR_VARS. Which also avoids problems with double processing of the DECL_INITIAL, which could be seen via both - the BIND_EXPR_VARS and a DECL_STMT. */ + the BIND_EXPR_VARS and a DECL_EXPR. */ else if (code == BIND_EXPR) { if (TREE_VISITED (t)) @@ -1004,6 +1004,72 @@ gimplify_return_expr (tree stmt, tree *pre_p) return GS_ALL_DONE; } +/* Gimplifies a DECL_EXPR node *STMT_P by making any necessary allocation + and initialization explicit. */ + +static enum gimplify_status +gimplify_decl_expr (tree *stmt_p) +{ + tree stmt = *stmt_p; + tree decl = DECL_EXPR_DECL (stmt); + + *stmt_p = NULL_TREE; + + if (TREE_TYPE (decl) == error_mark_node) + return GS_ERROR; + + else if (TREE_CODE (decl) == TYPE_DECL) + gimplify_type_sizes (TREE_TYPE (decl), stmt_p); + + else if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) + { + tree init = DECL_INITIAL (decl); + + if (!TREE_CONSTANT (DECL_SIZE (decl))) + { + /* This is a variable-sized decl. Simplify its size and mark it + for deferred expansion. Note that mudflap depends on the format + of the emitted code: see mx_register_decls(). */ + tree t, args; + + gimplify_type_sizes (TREE_TYPE (decl), stmt_p); + gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p); + gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p); + + args = tree_cons (NULL, DECL_SIZE_UNIT (decl), NULL); + t = build_fold_addr_expr (decl); + args = tree_cons (NULL, t, args); + t = implicit_built_in_decls[BUILT_IN_STACK_ALLOC]; + t = build_function_call_expr (t, args); + + gimplify_and_add (t, stmt_p); + DECL_DEFER_OUTPUT (decl) = 1; + } + + if (init && init != error_mark_node) + { + if (!TREE_STATIC (decl)) + { + DECL_INITIAL (decl) = NULL_TREE; + init = build (MODIFY_EXPR, void_type_node, decl, init); + gimplify_and_add (init, stmt_p); + } + else + /* We must still examine initializers for static variables + as they may contain a label address. */ + walk_tree (&init, force_labels_r, NULL, NULL); + } + + /* This decl isn't mentioned in the enclosing block, so add it to the + list of temps. FIXME it seems a bit of a kludge to say that + anonymous artificial vars aren't pushed, but everything else is. */ + if (DECL_ARTIFICIAL (decl) && DECL_NAME (decl) == NULL_TREE) + gimple_add_tmp_var (decl); + } + + return GS_ALL_DONE; +} + /* Gimplify a LOOP_EXPR. Normally this just involves gimplifying the body and replacing the LOOP_EXPR with goto, but if the loop contains an EXIT_EXPR, we need to append a label for it to jump to. */ @@ -3521,6 +3587,10 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p, *expr_p = DECL_INITIAL (*expr_p); break; + case DECL_EXPR: + ret = gimplify_decl_expr (expr_p); + break; + case EXC_PTR_EXPR: /* FIXME make this a decl. */ ret = GS_ALL_DONE; |