diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2010-06-05 20:33:22 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2010-06-05 20:33:22 +0000 |
commit | 39dabefd0e5e21b7829ec4ddf811ab19346983d7 (patch) | |
tree | 68de2ea9a7798604f2afa24cac397e87b3bf94d7 /gcc/c-family/c-gimplify.c | |
parent | ad06ee51fe9e658817b79f5db44a431fc1854288 (diff) | |
download | gcc-39dabefd0e5e21b7829ec4ddf811ab19346983d7.tar.gz |
c-common.c: Move to c-family/.
gcc/ChangeLog:
* c-common.c: Move to c-family/.
* c-common.def: Likewise.
* c-common.h: Likewise.
* c-cppbuiltin.c: Likewise.
* c-dump.c: Likewise.
* c-format.c: Likewise.
* c-format.h : Likewise.
* c-gimplify.c: Likewise.
* c-lex.c: Likewise.
* c-omp.c: Likewise.
* c.opt: Likewise.
* c-opts.c: Likewise.
* c-pch.c: Likewise.
* c-ppoutput.c: Likewise.
* c-pragma.c: Likewise.
* c-pragma.h: Likewise.
* c-pretty-print.c: Likewise.
* c-pretty-print.h: Likewise.
* c-semantics.c: Likewise.
* stub-objc.c: Likewise.
* gengtype.c (get_file_langdir): Special-case files in c-family/.
(get_output_file_with_visibility): Fix name for c-common.h.
* c-config-lang.in: Update paths in gtfiles for files in c-family/.
* c-tree.h: Update include path for moved files.
* c-lang.c: Likewise.
* c-lang.h: Likewise.
* c-parser.c: Likewise.
* c-convert.c: Likewise.
* c-decl.c: Likewise.
* c-objc-common.c: Likewise.
* configure.ac: Make sure c-family/ exists in the build directory.
* configure: Regenerate.
* Makefile.in: Update paths for moved files. Regroup files per
location and update dependencies. Move generated_files down after
ALL_GTFILES_H.
* config/spu/spu-c.c: Update paths for moved files.
* config/mep/mep-pragma.c: Likewise.
* config/darwin-c.c: Likewise.
* config/i386/msformat-c.c: Likewise.
* config/i386/i386-c.c: Likewise.
* config/avr/avr-c.c: Likewise.
* config/sol2-c.c: Likewise.
* config/ia64/ia64-c.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/arm/arm.c: Likewise.
* config/arm/arm-c.c: Likewise.
* config/h8300/h8300.c: Likewise.
* config/v850/v850-c.c: Likewise.
* config/t-darwin: Fix dependencies for moved files.
* config/t-sol2: Fix dependencies for moved files.
* config/mep/t-mep: Fix dependencies for moved files.
* config/ia64/t-ia64: Fix dependencies for moved files.
* config/rs6000/t-rs6000: Fix dependencies for moved files.
* config/v850/t-v850: Fix dependencies for moved files.
* config/v850/t-v850e: Fix dependencies for moved files.
* config/m32c/m32c-pragma.c
* po/exgettext: Look in c-family/ also.
c-family/ChangeLog:
* c-common.c: Include gt-c-family-c-common.h.
* c-pragma.c: Include gt-c-family-c-pragma.h.
objc/ChangeLog:
* objc-act.c: Update include path for moved files.
* objc-lang.c: Likewise.
* config-lang.in: Update paths in gtfiles for files in c-family/.
objcp/ChangeLog:
* objcp-lang.c: Update include path for moved files.
* config-lang.in: Update paths in gtfiles for files in c-family/.
cp/ChangeLog:
* typeck.c: Update include path for moved files.
* decl.c: Likewise.
* rtti.c: Likewise.
* cp-gimplify.c: Likewise.
* cp-lang.c: Likewise.
* pt.c: Likewise.
* semantics.c: Likewise.
* cxx-pretty-print.h: Likewise.
* decl2.c: Likewise.
* parser.c: Likewise.
* cp-objcp-common.c: Likewise.
* cp-tree.h: Likewise.
* name-lookup.c: Likewise.
* lex.c: Likewise.
* name-lookup.h: Likewise.
* config-lang.in: Update paths in gtfiles for files in c-family/.
* Make-lang.in: Likewise.
From-SVN: r160330
Diffstat (limited to 'gcc/c-family/c-gimplify.c')
-rw-r--r-- | gcc/c-family/c-gimplify.c | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c new file mode 100644 index 00000000000..06963a05e71 --- /dev/null +++ b/gcc/c-family/c-gimplify.c @@ -0,0 +1,190 @@ +/* Tree lowering pass. This pass gimplifies the tree representation built + by the C-based front ends. The structure of gimplified, or + language-independent, trees is dictated by the grammar described in this + file. + Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + Lowering of expressions contributed by Sebastian Pop <s.pop@laposte.net> + Re-written to support lowering of whole function trees, documentation + and miscellaneous cleanups by Diego Novillo <dnovillo@redhat.com> + +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/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "c-common.h" +#include "gimple.h" +#include "basic-block.h" +#include "tree-flow.h" +#include "tree-inline.h" +#include "diagnostic-core.h" +#include "langhooks.h" +#include "langhooks-def.h" +#include "flags.h" +#include "toplev.h" +#include "tree-dump.h" +#include "c-pretty-print.h" +#include "cgraph.h" + + +/* The gimplification pass converts the language-dependent trees + (ld-trees) emitted by the parser into language-independent trees + (li-trees) that are the target of SSA analysis and transformations. + + Language-independent trees are based on the SIMPLE intermediate + representation used in the McCAT compiler framework: + + "Designing the McCAT Compiler Based on a Family of Structured + Intermediate Representations," + L. Hendren, C. Donawa, M. Emami, G. Gao, Justiani, and B. Sridharan, + Proceedings of the 5th International Workshop on Languages and + Compilers for Parallel Computing, no. 757 in Lecture Notes in + Computer Science, New Haven, Connecticut, pp. 406-420, + Springer-Verlag, August 3-5, 1992. + + http://www-acaps.cs.mcgill.ca/info/McCAT/McCAT.html + + Basically, we walk down gimplifying the nodes that we encounter. As we + walk back up, we check that they fit our constraints, and copy them + into temporaries if not. */ + +/* Gimplification of statement trees. */ + +/* Convert the tree representation of FNDECL from C frontend trees to + GENERIC. */ + +void +c_genericize (tree fndecl) +{ + FILE *dump_orig; + int local_dump_flags; + struct cgraph_node *cgn; + + /* Dump the C-specific tree IR. */ + dump_orig = dump_begin (TDI_original, &local_dump_flags); + if (dump_orig) + { + fprintf (dump_orig, "\n;; Function %s", + lang_hooks.decl_printable_name (fndecl, 2)); + fprintf (dump_orig, " (%s)\n", + (!DECL_ASSEMBLER_NAME_SET_P (fndecl) ? "null" + : IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)))); + fprintf (dump_orig, ";; enabled by -%s\n", dump_flag_name (TDI_original)); + fprintf (dump_orig, "\n"); + + if (local_dump_flags & TDF_RAW) + dump_node (DECL_SAVED_TREE (fndecl), + TDF_SLIM | local_dump_flags, dump_orig); + else + print_c_tree (dump_orig, DECL_SAVED_TREE (fndecl)); + fprintf (dump_orig, "\n"); + + dump_end (TDI_original, dump_orig); + } + + /* Dump all nested functions now. */ + cgn = cgraph_node (fndecl); + for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) + c_genericize (cgn->decl); +} + +static void +add_block_to_enclosing (tree block) +{ + unsigned i; + tree enclosing; + gimple bind; + VEC(gimple, heap) *stack = gimple_bind_expr_stack (); + + for (i = 0; VEC_iterate (gimple, stack, i, bind); i++) + if (gimple_bind_block (bind)) + break; + + enclosing = gimple_bind_block (bind); + BLOCK_SUBBLOCKS (enclosing) = chainon (BLOCK_SUBBLOCKS (enclosing), block); +} + +/* Genericize a scope by creating a new BIND_EXPR. + BLOCK is either a BLOCK representing the scope or a chain of _DECLs. + In the latter case, we need to create a new BLOCK and add it to the + BLOCK_SUBBLOCKS of the enclosing block. + BODY is a chain of C _STMT nodes for the contents of the scope, to be + genericized. */ + +tree +c_build_bind_expr (location_t loc, tree block, tree body) +{ + tree decls, bind; + + if (block == NULL_TREE) + decls = NULL_TREE; + else if (TREE_CODE (block) == BLOCK) + decls = BLOCK_VARS (block); + else + { + decls = block; + if (DECL_ARTIFICIAL (decls)) + block = NULL_TREE; + else + { + block = make_node (BLOCK); + BLOCK_VARS (block) = decls; + add_block_to_enclosing (block); + } + } + + if (!body) + body = build_empty_stmt (loc); + if (decls || block) + { + bind = build3 (BIND_EXPR, void_type_node, decls, body, block); + TREE_SIDE_EFFECTS (bind) = 1; + SET_EXPR_LOCATION (bind, loc); + } + else + bind = body; + + return bind; +} + +/* Gimplification of expression trees. */ + +/* Do C-specific gimplification on *EXPR_P. PRE_P and POST_P are as in + gimplify_expr. */ + +int +c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, + gimple_seq *post_p ATTRIBUTE_UNUSED) +{ + enum tree_code code = TREE_CODE (*expr_p); + + /* This is handled mostly by gimplify.c, but we have to deal with + not warning about int x = x; as it is a GCC extension to turn off + this warning but only if warn_init_self is zero. */ + if (code == DECL_EXPR + && TREE_CODE (DECL_EXPR_DECL (*expr_p)) == VAR_DECL + && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p)) + && !TREE_STATIC (DECL_EXPR_DECL (*expr_p)) + && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p)) + && !warn_init_self) + TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1; + + return GS_UNHANDLED; +} |