diff options
author | Jason Merrill <jason@redhat.com> | 2004-06-09 11:32:44 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2004-06-09 11:32:44 -0400 |
commit | cd3ce9b44c1c3b4f4567de0d2767df058b89ce58 (patch) | |
tree | a63536f7f79b61493abe2609fb704c1c740bcd7d /gcc/gimplify.c | |
parent | e072ae27e0898a7244b08d003a43b4cecf146df0 (diff) | |
download | gcc-cd3ce9b44c1c3b4f4567de0d2767df058b89ce58.zip gcc-cd3ce9b44c1c3b4f4567de0d2767df058b89ce58.tar.gz gcc-cd3ce9b44c1c3b4f4567de0d2767df058b89ce58.tar.bz2 |
Gimplify VA_ARG_EXPR into simpler forms.
* target.h: Add gimplify_va_arg_expr hook.
* target-def.h: Add TARGET_GIMPLIFY_VA_ARG_EXPR.
* fold-const.c (build_fold_addr_expr)
(build_fold_addr_expr_with_type): Move from gimplify.c.
* tree.h: Declare them.
* gimplify.c (gimplify_and_add): New fn.
(build_addr_expr, build_addr_expr_with_type): Move to fold-const.c.
(gimplify_array_ref_to_plus, gimplify_modify_expr)
(gimplify_expr): Use build_fold_*.
(copy_if_shared_r): Only mark VA_ARG_EXPR volatile if we
don't know how to gimplify it.
* builtins.c (std_gimplify_va_arg_expr): New fn.
(dummy_object): New static fn.
(gimplify_va_arg_expr): New fn.
(stabilize_va_list): Use build_fold_*.
* tree-gimple.h: Declare new fns.
* config/i386/i386.c (TARGET_GIMPLIFY_VA_ARG_EXPR): Define.
(ix86_gimplify_va_arg): New fn.
* config/i386/ia64.c (TARGET_GIMPLIFY_VA_ARG_EXPR): Define.
(ia64_gimplify_va_arg): New fn.
* config/i386/rs6000.c (rs6000_gimplify_va_arg): New fn.
(TARGET_GIMPLIFY_VA_ARG_EXPR): Define.
* config/i386/sparc.c (sparc_gimplify_va_arg): New fn.
* alias.c (get_varargs_alias_set): Just return 0 for now.
* c-objc-common.c (c_tree_printer): Improve handling of %T.
From-SVN: r82838
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 66 |
1 files changed, 20 insertions, 46 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index c6378aa..c25a891 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -45,6 +45,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "output.h" #include "expr.h" #include "ggc.h" +#include "target.h" static struct gimplify_ctx { @@ -237,6 +238,15 @@ append_to_statement_list_force (tree t, tree *list_p) append_to_statement_list_1 (t, list_p, t != NULL); } +/* Both gimplify the statement T and append it to LIST_P. */ + +void +gimplify_and_add (tree t, tree *list_p) +{ + gimplify_stmt (&t); + append_to_statement_list (t, list_p); +} + /* Add T to the end of a COMPOUND_EXPR pointed by LIST_P. The type of the result is the type of T. */ @@ -668,13 +678,17 @@ copy_if_shared_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, else { TREE_VISITED (t) = 1; - if (TREE_CODE (*tp) == VA_ARG_EXPR) + if (TREE_CODE (*tp) == VA_ARG_EXPR + && targetm.calls.gimplify_va_arg_expr == NULL) { /* Mark any _DECL inside the operand as volatile to avoid the optimizers messing around with it. We have to do this early, otherwise we might mark a variable as volatile after we gimplify other statements that use the variable assuming it's not volatile. */ + + /* FIXME once most targets define the above hook, this should + go away (perhaps along with the #include "target.h"). */ walk_tree (&TREE_OPERAND (*tp, 0), mark_decls_volatile_r, NULL, NULL); } @@ -1633,39 +1647,6 @@ gimplify_minimax_expr (tree *expr_p, tree *pre_p, tree *post_p) return GS_OK; } -/* Build an expression for the address of T. Folds away INDIRECT_REF to - avoid confusing the gimplify process. */ - -static tree -build_addr_expr_with_type (tree t, tree ptrtype) -{ - if (TREE_CODE (t) == INDIRECT_REF) - { - t = TREE_OPERAND (t, 0); - if (TREE_TYPE (t) != ptrtype) - t = build1 (NOP_EXPR, ptrtype, t); - } - else - { - tree base = t; - while (TREE_CODE (base) == COMPONENT_REF - || TREE_CODE (base) == ARRAY_REF) - base = TREE_OPERAND (base, 0); - if (DECL_P (base)) - TREE_ADDRESSABLE (base) = 1; - - t = build1 (ADDR_EXPR, ptrtype, t); - } - - return t; -} - -static tree -build_addr_expr (tree t) -{ - return build_addr_expr_with_type (t, build_pointer_type (TREE_TYPE (t))); -} - /* Subroutine of gimplify_compound_lval and gimplify_array_ref. Converts an ARRAY_REF to the equivalent *(&array + offset) form. */ @@ -1716,7 +1697,7 @@ gimplify_array_ref_to_plus (tree *expr_p, tree *pre_p, tree *post_p) if (ret == GS_ERROR) return ret; - addr = build_addr_expr_with_type (array, ptrtype); + addr = build_fold_addr_expr_with_type (array, ptrtype); result = fold (build (add_code, ptrtype, addr, offset)); *expr_p = build1 (INDIRECT_REF, elttype, result); @@ -2533,9 +2514,9 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value) t = TYPE_SIZE_UNIT (TREE_TYPE (*to_p)); t = unshare_expr (t); args = tree_cons (NULL, t, NULL); - t = build_addr_expr (*from_p); + t = build_fold_addr_expr (*from_p); args = tree_cons (NULL, t, args); - dest = build_addr_expr (*to_p); + dest = build_fold_addr_expr (*to_p); args = tree_cons (NULL, dest, args); t = implicit_built_in_decls[BUILT_IN_MEMCPY]; t = build_function_call_expr (t, args); @@ -3239,14 +3220,7 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p, break; case VA_ARG_EXPR: - /* Mark any _DECL inside the operand as volatile to avoid the - optimizers messing around with it. FIXME: Remove this once - VA_ARG_EXPRs are properly lowered. */ - walk_tree (&TREE_OPERAND (*expr_p, 0), mark_decls_volatile_r, - NULL, NULL); - - /* va_arg expressions are in GIMPLE form already. */ - ret = GS_ALL_DONE; + ret = gimplify_va_arg_expr (expr_p, pre_p, post_p); break; case CONVERT_EXPR: @@ -3586,7 +3560,7 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p, /* An lvalue will do. Take the address of the expression, store it in a temporary, and replace the expression with an INDIRECT_REF of that temporary. */ - tmp = build_addr_expr (*expr_p); + tmp = build_fold_addr_expr (*expr_p); gimplify_expr (&tmp, pre_p, post_p, is_gimple_reg, fb_rvalue); *expr_p = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (tmp)), tmp); } |