diff options
author | Richard Biener <rguenth@gcc.gnu.org> | 2008-07-28 14:33:56 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-07-28 14:33:56 +0000 |
commit | 726a989a8b74bf238a96029860bcf7ba14eff317 (patch) | |
tree | 2926705dd533a8904679724ab1cec40dfee45094 /gcc/ipa-pure-const.c | |
parent | 0d48657d7378a4b1cb25ed181bca8020eae520f1 (diff) | |
download | gcc-726a989a8b74bf238a96029860bcf7ba14eff317.zip gcc-726a989a8b74bf238a96029860bcf7ba14eff317.tar.gz gcc-726a989a8b74bf238a96029860bcf7ba14eff317.tar.bz2 |
backport: ChangeLog.tuples: ChangeLog from gimple-tuples-branch.
2008-07-28 Richard Guenther <rguenther@suse.de>
Merge from gimple-tuples-branch.
* ChangeLog.tuples: ChangeLog from gimple-tuples-branch.
* gimple.def: New file.
* gsstruct.def: Likewise.
* gimple-iterator.c: Likewise.
* gimple-pretty-print.c: Likewise.
* tree-gimple.c: Removed. Merged into ...
* gimple.c: ... here. New file.
* tree-gimple.h: Removed. Merged into ...
* gimple.h: ... here. New file.
* Makefile.in: Add dependencies on GIMPLE_H and tree-iterator.h.
* configure.ac: Added support for ENABLE_GIMPLE_CHECKING and the
--enable-checking=gimple flag.
* config.in: Likewise.
* configure: Regenerated.
* tree-ssa-operands.h: Tuplified.
* tree-vrp.c: Likewise.
* tree-loop-linear.c: Likewise.
* tree-into-ssa.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-dump.c: Likewise.
* tree-complex.c: Likewise.
* cgraphbuild.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-pretty-print.c: Likewise.
* tracer.c: Likewise.
* gengtype.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-ssa-loop-unswitch.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* value-prof.c: Likewise.
* tree-ssa-loop-ch.c: Likewise.
* tree-tailcall.c: Likewise.
* value-prof.h: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* tree-pass.h: Likewise.
* ipa-cp.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-scalar-evolution.h: Likewise.
* target.h: Likewise.
* lambda-mat.c: Likewise.
* tree-phinodes.c: Likewise.
* diagnostic.h: Likewise.
* builtins.c: Likewise.
* tree-ssa-alias-warnings.c: Likewise.
* cfghooks.c: Likewise.
* fold-const.c: Likewise.
* cfghooks.h: Likewise.
* omp-low.c: Likewise.
* tree-ssa-dse.c: Likewise.
* ipa-reference.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* toplev.c: Likewise.
* tree-gimple.c: Likewise.
* tree-gimple.h: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* cgraphunit.c: Likewise.
* tree-ssa-copyrename.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-nomudflap.c: Likewise.
* tree-call-cdce.c: Likewise.
* ipa-pure-const.c: Likewise.
* c-format.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-nrv.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* ipa-utils.c: Likewise.
* tree-ssa-propagate.h: Likewise.
* tree-ssa-alias.c: Likewise.
* gimple-low.c: Likewise.
* tree-ssa-sink.c: Likewise.
* ipa-inline.c: Likewise.
* c-semantics.c: Likewise.
* dwarf2out.c: Likewise.
* expr.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* predict.c: Likewise.
* tree-ssa-loop.c: Likewise.
* tree-parloops.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-ifcombine.c: Likewise.
* matrix-reorg.c: Likewise.
* c-decl.c: Likewise.
* tree-eh.c: Likewise.
* c-pretty-print.c: Likewise.
* lambda-trans.c: Likewise.
* function.c: Likewise.
* langhooks.c: Likewise.
* ebitmap.h: Likewise.
* tree-vectorizer.c: Likewise.
* function.h: Likewise.
* langhooks.h: Likewise.
* tree-vectorizer.h: Likewise.
* ipa-type-escape.c: Likewise.
* ipa-type-escape.h: Likewise.
* domwalk.c: Likewise.
* tree-if-conv.c: Likewise.
* profile.c: Likewise.
* domwalk.h: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-flow-inline.h: Likewise.
* tree-affine.c: Likewise.
* tree-vect-analyze.c: Likewise.
* c-typeck.c: Likewise.
* gimplify.c: Likewise.
* coretypes.h: Likewise.
* tree-ssa-phiopt.c: Likewise.
* calls.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree.def: Likewise.
* tree-dfa.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* cfgexpand.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-predcom.c: Likewise.
* lambda.h: Likewise.
* tree-mudflap.c: Likewise.
* ipa-prop.c: Likewise.
* print-tree.c: Likewise.
* tree-ssa-copy.c: Likewise.
* ipa-prop.h: Likewise.
* tree-ssa-forwprop.c: Likewise.
* ggc-page.c: Likewise.
* c-omp.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-ssa-ter.c: Likewise.
* tree-nested.c: Likewise.
* tree-ssa.c: Likewise.
* lambda-code.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-iterator.c: Likewise.
* tree-optimize.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-vect-transform.c: Likewise.
* tree-object-size.c: Likewise.
* tree-outof-ssa.c: Likewise.
* cfgloop.c: Likewise.
* system.h: Likewise.
* tree-profile.c: Likewise.
* cfgloop.h: Likewise.
* c-gimplify.c: Likewise.
* c-common.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-flow.h: Likewise.
* c-common.h: Likewise.
* basic-block.h: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-ssa-structalias.h: Likewise.
* tree-cfg.c: Likewise.
* passes.c: Likewise.
* ipa-struct-reorg.c: Likewise.
* ipa-struct-reorg.h: Likewise.
* tree-ssa-reassoc.c: Likewise.
* cfgrtl.c: Likewise.
* varpool.c: Likewise.
* stmt.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* langhooks-def.h: Likewise.
* tree-ssa-operands.c: Likewise.
* config/alpha/alpha.c: Likewise.
* config/frv/frv.c: Likewise.
* config/s390/s390.c: Likewise.
* config/m32c/m32c.c: Likewise.
* config/m32c/m32c-protos.h: Likewise.
* config/spu/spu.c: Likewise.
* config/sparc/sparc.c: Likewise.
* config/i386/i386.c: Likewise.
* config/sh/sh.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* config/stormy16/stormy16.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/pa/pa.c: Likewise.
* config/mips/mips.c: Likewise.
From-SVN: r138207
Diffstat (limited to 'gcc/ipa-pure-const.c')
-rw-r--r-- | gcc/ipa-pure-const.c | 165 |
1 files changed, 93 insertions, 72 deletions
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 578c48d..7720d304 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -44,7 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "ggc.h" #include "ipa-utils.h" #include "c-common.h" -#include "tree-gimple.h" +#include "gimple.h" #include "cgraph.h" #include "output.h" #include "flags.h" @@ -276,42 +276,47 @@ check_lhs_var (funct_state local, tree t) actual asm statement. */ static void -get_asm_expr_operands (funct_state local, tree stmt) +get_asm_expr_operands (funct_state local, gimple stmt) { - int noutputs = list_length (ASM_OUTPUTS (stmt)); + size_t noutputs = gimple_asm_noutputs (stmt); const char **oconstraints = (const char **) alloca ((noutputs) * sizeof (const char *)); - int i; - tree link; + size_t i; + tree op; const char *constraint; bool allows_mem, allows_reg, is_inout; - for (i=0, link = ASM_OUTPUTS (stmt); link; ++i, link = TREE_CHAIN (link)) + for (i = 0; i < noutputs; i++) { + op = gimple_asm_output_op (stmt, i); oconstraints[i] = constraint - = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); + = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg, &is_inout); - check_lhs_var (local, TREE_VALUE (link)); + check_lhs_var (local, TREE_VALUE (op)); } - for (link = ASM_INPUTS (stmt); link; link = TREE_CHAIN (link)) + for (i = 0; i < gimple_asm_ninputs (stmt); i++) { + op = gimple_asm_input_op (stmt, i); constraint - = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); + = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); parse_input_constraint (&constraint, 0, 0, noutputs, 0, oconstraints, &allows_mem, &allows_reg); - check_rhs_var (local, TREE_VALUE (link)); + check_rhs_var (local, TREE_VALUE (op)); } - for (link = ASM_CLOBBERS (stmt); link; link = TREE_CHAIN (link)) - if (simple_cst_equal(TREE_VALUE (link), memory_identifier_string) == 1) - /* Abandon all hope, ye who enter here. */ - local->pure_const_state = IPA_NEITHER; + for (i = 0; i < gimple_asm_nclobbers (stmt); i++) + { + op = gimple_asm_clobber_op (stmt, i); + if (simple_cst_equal(TREE_VALUE (op), memory_identifier_string) == 1) + /* Abandon all hope, ye who enter here. */ + local->pure_const_state = IPA_NEITHER; + } - if (ASM_VOLATILE_P (stmt)) + if (gimple_asm_volatile_p (stmt)) local->pure_const_state = IPA_NEITHER; } @@ -323,17 +328,20 @@ get_asm_expr_operands (funct_state local, tree stmt) the entire call expression. */ static void -check_call (funct_state local, tree call_expr) +check_call (funct_state local, gimple call) { - int flags = call_expr_flags (call_expr); - tree operand; - call_expr_arg_iterator iter; - tree callee_t = get_callee_fndecl (call_expr); + int flags = gimple_call_flags (call); + tree lhs, callee_t = gimple_call_fndecl (call); struct cgraph_node* callee; enum availability avail = AVAIL_NOT_AVAILABLE; + size_t i; + + lhs = gimple_call_lhs (call); + if (lhs) + check_lhs_var (local, lhs); - FOR_EACH_CALL_EXPR_ARG (operand, iter, call_expr) - check_rhs_var (local, operand); + for (i = 0; i < gimple_call_num_args (call); i++) + check_rhs_var (local, gimple_call_arg (call, i)); /* The const and pure flags are set by a variety of places in the compiler (including here). If someone has already set the flags @@ -405,11 +413,10 @@ check_call (funct_state local, tree call_expr) should be converted to use the operand scanner. */ static tree -scan_function (tree *tp, - int *walk_subtrees, - void *data) +scan_function_op (tree *tp, int *walk_subtrees, void *data) { - struct cgraph_node *fn = (struct cgraph_node *) data; + struct walk_stmt_info *wi = (struct walk_stmt_info *) data; + struct cgraph_node *fn = (struct cgraph_node *) wi->info; tree t = *tp; funct_state local = get_function_state (fn); @@ -417,58 +424,72 @@ scan_function (tree *tp, { case VAR_DECL: if (DECL_INITIAL (t)) - walk_tree (&DECL_INITIAL (t), scan_function, fn, visited_nodes); + walk_tree (&DECL_INITIAL (t), scan_function_op, data, visited_nodes); *walk_subtrees = 0; break; - case GIMPLE_MODIFY_STMT: + case ADDR_EXPR: + /* This case is here to find addresses on rhs of constructors in + decl_initial of static variables. */ + check_rhs_var (local, t); + *walk_subtrees = 0; + break; + + default: + break; + } + return NULL; +} + +static tree +scan_function_stmt (gimple_stmt_iterator *gsi_p, + bool *handled_ops_p, + struct walk_stmt_info *wi) +{ + struct cgraph_node *fn = (struct cgraph_node *) wi->info; + gimple stmt = gsi_stmt (*gsi_p); + funct_state local = get_function_state (fn); + + switch (gimple_code (stmt)) + { + case GIMPLE_ASSIGN: { /* First look on the lhs and see what variable is stored to */ - tree lhs = GIMPLE_STMT_OPERAND (t, 0); - tree rhs = GIMPLE_STMT_OPERAND (t, 1); + tree lhs = gimple_assign_lhs (stmt); + tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs2 = gimple_assign_rhs2 (stmt); + enum tree_code code = gimple_assign_rhs_code (stmt); + check_lhs_var (local, lhs); /* For the purposes of figuring out what the cast affects */ /* Next check the operands on the rhs to see if they are ok. */ - switch (TREE_CODE_CLASS (TREE_CODE (rhs))) + switch (TREE_CODE_CLASS (code)) { case tcc_binary: { - tree op0 = TREE_OPERAND (rhs, 0); - tree op1 = TREE_OPERAND (rhs, 1); - check_rhs_var (local, op0); - check_rhs_var (local, op1); + check_rhs_var (local, rhs1); + check_rhs_var (local, rhs2); } break; case tcc_unary: { - tree op0 = TREE_OPERAND (rhs, 0); - check_rhs_var (local, op0); + check_rhs_var (local, rhs1); } break; case tcc_reference: - check_rhs_var (local, rhs); + check_rhs_var (local, rhs1); break; case tcc_declaration: - check_rhs_var (local, rhs); + check_rhs_var (local, rhs1); break; case tcc_expression: - switch (TREE_CODE (rhs)) + switch (code) { case ADDR_EXPR: - check_rhs_var (local, rhs); - break; - default: - break; - } - break; - case tcc_vl_exp: - switch (TREE_CODE (rhs)) - { - case CALL_EXPR: - check_call (local, rhs); + check_rhs_var (local, rhs1); break; default: break; @@ -477,19 +498,12 @@ scan_function (tree *tp, default: break; } - *walk_subtrees = 0; + *handled_ops_p = true; } break; - case ADDR_EXPR: - /* This case is here to find addresses on rhs of constructors in - decl_initial of static variables. */ - check_rhs_var (local, t); - *walk_subtrees = 0; - break; - - case LABEL_EXPR: - if (DECL_NONLOCAL (TREE_OPERAND (t, 0))) + case GIMPLE_LABEL: + if (DECL_NONLOCAL (gimple_label_label (stmt))) /* Target of long jump. */ { local->pure_const_state = IPA_NEITHER; @@ -497,14 +511,14 @@ scan_function (tree *tp, } break; - case CALL_EXPR: - check_call (local, t); - *walk_subtrees = 0; + case GIMPLE_CALL: + check_call (local, stmt); + *handled_ops_p = true; break; - case ASM_EXPR: - get_asm_expr_operands (local, t); - *walk_subtrees = 0; + case GIMPLE_ASM: + get_asm_expr_operands (local, stmt); + *handled_ops_p = true; break; default: @@ -567,11 +581,18 @@ analyze_function (struct cgraph_node *fn) FOR_EACH_BB_FN (this_block, this_cfun) { - block_stmt_iterator bsi; - for (bsi = bsi_start (this_block); !bsi_end_p (bsi); bsi_next (&bsi)) + gimple_stmt_iterator gsi; + struct walk_stmt_info wi; + + memset (&wi, 0, sizeof(wi)); + for (gsi = gsi_start_bb (this_block); + !gsi_end_p (gsi); + gsi_next (&gsi)) { - walk_tree (bsi_stmt_ptr (bsi), scan_function, - fn, visited_nodes); + wi.info = fn; + wi.pset = visited_nodes; + walk_gimple_stmt (&gsi, scan_function_stmt, scan_function_op, + &wi); if (l->pure_const_state == IPA_NEITHER) goto end; } |