* gimple.h: Remove all includes. (recalculate_side_effects): Move prototype to gimplify.h. * Makefile.in (PLUGIN_HEADERS): Add flattened gimple.h includes. * gengtype.c (open_base_files): Add gimple.h include list. * gimplify.h (recalculate_side_effects): Relocate prototype here. * gimple.c: Adjust include list. (recalculate_side_effects): Move to gimplify.c. * gimplify.c: Adjust include list. (recalculate_side_effects): Relocate from gimple.c. * alias.c: Add required include files removed from gimple.h. * asan.c: Likewise. * builtins.c: Likewise. * calls.c: Likewise. * cfgexpand.c: Likewise. * cfgloop.c: Likewise. * cfgloopmanip.c: Likewise. * cgraphbuild.c: Likewise. * cgraph.c: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * cilk-common.c: Likewise. * data-streamer.c: Likewise. * data-streamer-in.c: Likewise. * data-streamer-out.c: Likewise. * dse.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * gimple-builder.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple-ssa-isolate-paths.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimple-streamer-in.c: Likewise. * gimple-streamer-out.c: Likewise. * gimple-walk.c: Likewise. * gimplify-me.c: Likewise. * graphite-blocking.c: Likewise. * graphite.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-optimize-isl.c: Likewise. * graphite-poly.c: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * internal-fn.c: Likewise. * ipa.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline.c: Likewise. * ipa-profile.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-utils.c: Likewise. * langhooks.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * omp-low.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * predict.c: Likewise. * profile.c: Likewise. * sese.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * symtab.c: Likewise. * targhooks.c: Likewise. * toplev.c: Likewise. * tracer.c: Likewise. * trans-mem.c: Likewise. * tree-affine.c: Likewise. * tree.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-dfa.c: Likewise. * tree-eh.c: Likewise. * tree-emutls.c: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-nested.c: Likewise. * tree-nrv.c: Likewise. * tree-object-size.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-copy.c: Likewise. * tree-ssa-copyrename.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssanames.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-strlen.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-tail-merge.c: Likewise. * tree-ssa-ter.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-stdarg.c: Likewise. * tree-streamer.c: Likewise. * tree-streamer-in.c: Likewise. * tree-streamer-out.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-tailcall.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * tsan.c: Likewise. * ubsan.c: Likewise. * value-prof.c: Likewise. * varpool.c: Likewise. * var-tracking.c: Likewise. * vtable-verify.c: Likewise. * ada/gcc-interface/trans.c: Add required include files from gimple.h. * c/c-typeck.c: Add required include files from gimple.h. * c-family/c-common.c: Add required include files from gimple.h. * c-family/c-gimplify.c: Likewise * c-family/cilk.c: Likewise * cp/class.c: Add required include files from gimple.h. * cp/cp-gimplify.c: Likewise * cp/decl2.c: Likewise * cp/init.c: Likewise * cp/optimize.c: Likewise * cp/pt.c: Likewise * cp/semantics.c: Likewise * cp/tree.c: Likewise * cp/typeck.c: Likewise * cp/vtable-class-hierarchy.c: Likewise * fortran/trans.c: Add required include files from gimple.h. * fortran/trans-expr.c: Likewise * fortran/trans-openmp.c: Likewise * go/gofrontend/expressions.cc: Add required include files from gimple.h. * go/gofrontend/gogo-tree.cc: Likewise * go/gofrontend/types.cc: Likewise * go/go-gcc.cc: Likewise * go/go-lang.c: Likewise * java/java-gimplify.c: Add required include files from gimple.h. * lto/lto.c: Add required include files from gimple.h. * lto/lto-lang.c: Likewise * lto/lto-object.c: Likewise * lto/lto-partition.c: Likewise * lto/lto-symtab.c: Likewise * objc/objc-act.c: Add required include files from gimple.h. * config/darwin.c: Add required include files removed from gimple.h. * config/aarch64/aarch64-builtins.c: Likewise. * config/aarch64/aarch64.c: Likewise. * config/alpha/alpha.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64.c: Likewise. * config/m32c/m32c.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/tilegx/tilegx.c: Likewise. * config/tilepro/tilepro.c: Likewise. * config/xtensa/xtensa.c: Likewise. * testsuite/gcc.dg/plugin/finish_unit_plugin.c: Add required include files removed from gimple.h. * testsuite/gcc.dg/plugin/ggcplug.c: Likewise. * testsuite/gcc.dg/plugin/one_time_plugin.c: Likewise. * testsuite/gcc.dg/plugin/selfassign.c: Likewise. * testsuite/gcc.dg/plugin/start_unit_plugin.c: Likewise. * testsuite/g++.dg/plugin/selfassign.c: Likewise. From-SVN: r205272
176 lines
4.7 KiB
C
176 lines
4.7 KiB
C
/* Java(TM) language-specific gimplification routines.
|
|
Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>.
|
|
|
|
Java and all Java-based marks are trademarks or registered trademarks
|
|
of Sun Microsystems, Inc. in the United States and other countries.
|
|
The Free Software Foundation is independent of Sun Microsystems, Inc. */
|
|
|
|
#include "config.h"
|
|
#include "system.h"
|
|
#include "coretypes.h"
|
|
#include "tree.h"
|
|
#include "java-tree.h"
|
|
#include "dumpfile.h"
|
|
#include "basic-block.h"
|
|
#include "tree-ssa-alias.h"
|
|
#include "internal-fn.h"
|
|
#include "gimple-expr.h"
|
|
#include "is-a.h"
|
|
#include "gimple.h"
|
|
#include "gimplify.h"
|
|
|
|
static tree java_gimplify_block (tree);
|
|
static enum gimplify_status java_gimplify_modify_expr (tree *);
|
|
static enum gimplify_status java_gimplify_self_mod_expr (tree *, gimple_seq *,
|
|
gimple_seq *);
|
|
|
|
static void dump_java_tree (enum tree_dump_index, tree);
|
|
|
|
/* Convert a Java tree to GENERIC. */
|
|
|
|
void
|
|
java_genericize (tree fndecl)
|
|
{
|
|
walk_tree (&DECL_SAVED_TREE (fndecl), java_replace_references, NULL, NULL);
|
|
dump_java_tree (TDI_original, fndecl);
|
|
}
|
|
|
|
/* Gimplify a Java tree. */
|
|
|
|
int
|
|
java_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
|
|
{
|
|
enum tree_code code = TREE_CODE (*expr_p);
|
|
|
|
switch (code)
|
|
{
|
|
case BLOCK:
|
|
*expr_p = java_gimplify_block (*expr_p);
|
|
break;
|
|
|
|
case MODIFY_EXPR:
|
|
return java_gimplify_modify_expr (expr_p);
|
|
|
|
case POSTINCREMENT_EXPR:
|
|
case POSTDECREMENT_EXPR:
|
|
case PREINCREMENT_EXPR:
|
|
case PREDECREMENT_EXPR:
|
|
return java_gimplify_self_mod_expr (expr_p, pre_p, post_p);
|
|
|
|
/* These should already be lowered before we get here. */
|
|
case URSHIFT_EXPR:
|
|
case COMPARE_EXPR:
|
|
case COMPARE_L_EXPR:
|
|
case COMPARE_G_EXPR:
|
|
gcc_unreachable ();
|
|
|
|
default:
|
|
return GS_UNHANDLED;
|
|
}
|
|
|
|
return GS_OK;
|
|
}
|
|
|
|
static enum gimplify_status
|
|
java_gimplify_modify_expr (tree *modify_expr_p)
|
|
{
|
|
tree modify_expr = *modify_expr_p;
|
|
tree lhs = TREE_OPERAND (modify_expr, 0);
|
|
tree rhs = TREE_OPERAND (modify_expr, 1);
|
|
tree lhs_type = TREE_TYPE (lhs);
|
|
|
|
if (lhs_type != TREE_TYPE (rhs))
|
|
/* Fix up type mismatches to make legal GIMPLE. These are
|
|
generated in several places, in particular null pointer
|
|
assignment and subclass assignment. */
|
|
TREE_OPERAND (modify_expr, 1) = convert (lhs_type, rhs);
|
|
|
|
return GS_UNHANDLED;
|
|
}
|
|
|
|
/* Special case handling for volatiles: we need to generate a barrier
|
|
between the reading and the writing. */
|
|
|
|
static enum gimplify_status
|
|
java_gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
|
|
gimple_seq *post_p ATTRIBUTE_UNUSED)
|
|
{
|
|
tree lhs = TREE_OPERAND (*expr_p, 0);
|
|
|
|
if (TREE_CODE (lhs) == COMPONENT_REF
|
|
&& TREE_THIS_VOLATILE (TREE_OPERAND (lhs, 1)))
|
|
TREE_THIS_VOLATILE (lhs) = 1;
|
|
|
|
return GS_UNHANDLED;
|
|
}
|
|
|
|
|
|
/* Gimplify BLOCK into a BIND_EXPR. */
|
|
|
|
static tree
|
|
java_gimplify_block (tree java_block)
|
|
{
|
|
tree decls = BLOCK_VARS (java_block);
|
|
tree body = BLOCK_EXPR_BODY (java_block);
|
|
gimple outer = gimple_current_bind_expr ();
|
|
tree block;
|
|
|
|
/* Don't bother with empty blocks. */
|
|
if (! body)
|
|
return build_empty_stmt (input_location);
|
|
|
|
if (IS_EMPTY_STMT (body))
|
|
return body;
|
|
|
|
/* Make a proper block. Java blocks are unsuitable for BIND_EXPR
|
|
because they use BLOCK_SUBBLOCKS for another purpose. */
|
|
block = make_node (BLOCK);
|
|
BLOCK_VARS (block) = decls;
|
|
|
|
/* The TREE_USED flag on a block determines whether the debug output
|
|
routines generate info for the variables in that block. */
|
|
TREE_USED (block) = 1;
|
|
|
|
if (outer != NULL)
|
|
{
|
|
tree b = gimple_bind_block (outer);
|
|
BLOCK_SUBBLOCKS (b) = chainon (BLOCK_SUBBLOCKS (b), block);
|
|
}
|
|
BLOCK_EXPR_BODY (java_block) = NULL_TREE;
|
|
|
|
return build3 (BIND_EXPR, TREE_TYPE (java_block), decls, body, block);
|
|
}
|
|
|
|
/* Dump a tree of some kind. This is a convenience wrapper for the
|
|
dump_* functions in tree-dump.c. */
|
|
static void
|
|
dump_java_tree (enum tree_dump_index phase, tree t)
|
|
{
|
|
FILE *stream;
|
|
int flags;
|
|
|
|
stream = dump_begin (phase, &flags);
|
|
flags |= TDF_SLIM;
|
|
if (stream)
|
|
{
|
|
dump_node (t, flags, stream);
|
|
dump_end (phase, stream);
|
|
}
|
|
}
|