* gimplify-be.h: New file. Add prototypes.
* gimplify.h: Don't include gimple.h.
(struct gimplify_hasher, struct gimplify_ctx, is_gimple_sizepos,
gimplify_hasher::hash, gimplify_hasher::equal): Relocate from gimple.h.
* gimple.h (struct gimplify_hasher, gimplify_hasher::hash,
gimplify_hasher::equal, struct gimplify_ctx, is_gimple_sizepos): Move
to gimplify.h.
(enum gsi_iterator_update): Move to gimple-iterator.h.
* gimple-iterator.h (enum gsi_iterator_update): Relocate from gimple.h.
* gimplify-be.c: New File.
(force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Relocate from
gimplify.c.
* gimplify.c (force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Move to
gimplify-be.c.
* Makefile.in (OBJS): Add gimplify-be.o
===================================================================
***************
+ /* Header file for back end gimplification.
+ Copyright (C) 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/>. */
+
+ #ifndef GCC_GIMPLIFY_BE_H
+ #define GCC_GIMPLIFY_BE_H
+
+ /* Validation of GIMPLE expressions. Note that these predicates only check
+ * the basic form of the expression, they don't recurse to make sure that
+ * underlying nodes are also of the right form. */
+ typedef bool (*gimple_predicate)(tree);
+
+ extern tree force_gimple_operand_1 (tree, gimple_seq *, gimple_predicate, tree);
+ extern tree force_gimple_operand (tree, gimple_seq *, bool, tree);
+ extern tree force_gimple_operand_gsi_1 (gimple_stmt_iterator *, tree,
+ gimple_predicate, tree,
+ bool, enum gsi_iterator_update);
+ extern tree force_gimple_operand_gsi (gimple_stmt_iterator *, tree, bool, tree,
+ bool, enum gsi_iterator_update);
+
+ #endif /* GCC_GIMPLIFY_BE_H */
===================================================================
*************** along with GCC; see the file COPYING3.
#ifndef GCC_GIMPLIFY_H
#define GCC_GIMPLIFY_H
- #include "gimple.h"
-
/* Validation of GIMPLE expressions. Note that these predicates only check
the basic form of the expression, they don't recurse to make sure that
underlying nodes are also of the right form. */
*************** enum gimplify_status {
GS_OK = 0, /* We did something, maybe more to do. */
GS_ALL_DONE = 1 /* The expression is fully gimplified. */
};
+ /* Gimplify hashtable helper. */
+
+ struct gimplify_hasher : typed_free_remove <elt_t>
+ {
+ typedef elt_t value_type;
+ typedef elt_t compare_type;
+ static inline hashval_t hash (const value_type *);
+ static inline bool equal (const value_type *, const compare_type *);
+ };
+
+ struct gimplify_ctx
+ {
+ struct gimplify_ctx *prev_context;
+
+ vec<gimple> bind_expr_stack;
+ tree temps;
+ gimple_seq conditional_cleanups;
+ tree exit_label;
+ tree return_temp;
+
+ vec<tree> case_labels;
+ /* The formal temporary table. Should this be persistent? */
+ hash_table <gimplify_hasher> temp_htab;
+
+ int conditions;
+ bool save_stack;
+ bool into_ssa;
+ bool allow_rhs_cond_expr;
+ bool in_cleanup_point_expr;
+ };
+
+ extern struct gimplify_ctx *gimplify_ctxp;
extern void push_gimplify_context (struct gimplify_ctx *);
extern void pop_gimplify_context (gimple);
extern gimple gimple_current_bind_expr (void);
*************** extern void gimplify_one_sizepos (tree *
extern gimple gimplify_body (tree, bool);
extern void gimplify_function_tree (tree);
extern void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
- extern tree force_gimple_operand_1 (tree, gimple_seq *, gimple_predicate, tree);
- extern tree force_gimple_operand (tree, gimple_seq *, bool, tree);
- extern tree force_gimple_operand_gsi_1 (gimple_stmt_iterator *, tree,
- gimple_predicate, tree,
- bool, enum gsi_iterator_update);
- extern tree force_gimple_operand_gsi (gimple_stmt_iterator *, tree, bool, tree,
- bool, enum gsi_iterator_update);
-
extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
gimple_seq *);
gimple gimplify_assign (tree, tree, gimple_seq *);
#endif /* GCC_GIMPLIFY_H */
extern gimple gimplify_body (tree, bool);
extern void gimplify_function_tree (tree);
extern void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
gimple_seq *);
gimple gimplify_assign (tree, tree, gimple_seq *);
+ /* Return true if gimplify_one_sizepos doesn't need to gimplify
+ expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
+ fields). */
+ static inline bool
+ is_gimple_sizepos (tree expr)
+ {
+ /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
+ is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
+ anything if it's already a VAR_DECL. If it's a VAR_DECL from another
+ function, the gimplifier will want to replace it with a new variable,
+ but that will cause problems if this type is from outside the function.
+ It's OK to have that here. */
+ return (expr == NULL_TREE
+ || TREE_CONSTANT (expr)
+ || TREE_CODE (expr) == VAR_DECL
+ || CONTAINS_PLACEHOLDER_P (expr));
+ }
+
+ inline hashval_t
+ gimplify_hasher::hash (const value_type *p)
+ {
+ tree t = p->val;
+ return iterative_hash_expr (t, 0);
+ }
+
+ inline bool
+ gimplify_hasher::equal (const value_type *p1, const compare_type *p2)
+ {
+ tree t1 = p1->val;
+ tree t2 = p2->val;
+ enum tree_code code = TREE_CODE (t1);
+
+ if (TREE_CODE (t2) != code
+ || TREE_TYPE (t1) != TREE_TYPE (t2))
+ return false;
+
+ if (!operand_equal_p (t1, t2, 0))
+ return false;
+
+ #ifdef ENABLE_CHECKING
+ /* Only allow them to compare equal if they also hash equal; otherwise
+ results are nondeterminate, and we fail bootstrap comparison. */
+ gcc_assert (hash (p1) == hash (p2));
+ #endif
+
+ return true;
+ }
+
+
#endif /* GCC_GIMPLIFY_H */
===================================================================
*************** typedef struct gimple_temp_hash_elt
tree temp; /* Value */
} elt_t;
- /* Gimplify hashtable helper. */
-
- struct gimplify_hasher : typed_free_remove <elt_t>
- {
- typedef elt_t value_type;
- typedef elt_t compare_type;
- static inline hashval_t hash (const value_type *);
- static inline bool equal (const value_type *, const compare_type *);
- };
-
- inline hashval_t
- gimplify_hasher::hash (const value_type *p)
- {
- tree t = p->val;
- return iterative_hash_expr (t, 0);
- }
-
- inline bool
- gimplify_hasher::equal (const value_type *p1, const compare_type *p2)
- {
- tree t1 = p1->val;
- tree t2 = p2->val;
- enum tree_code code = TREE_CODE (t1);
-
- if (TREE_CODE (t2) != code
- || TREE_TYPE (t1) != TREE_TYPE (t2))
- return false;
-
- if (!operand_equal_p (t1, t2, 0))
- return false;
-
- #ifdef ENABLE_CHECKING
- /* Only allow them to compare equal if they also hash equal; otherwise
- results are nondeterminate, and we fail bootstrap comparison. */
- gcc_assert (hash (p1) == hash (p2));
- #endif
-
- return true;
- }
-
- struct gimplify_ctx
- {
- struct gimplify_ctx *prev_context;
-
- vec<gimple> bind_expr_stack;
- tree temps;
- gimple_seq conditional_cleanups;
- tree exit_label;
- tree return_temp;
-
- vec<tree> case_labels;
- /* The formal temporary table. Should this be persistent? */
- hash_table <gimplify_hasher> temp_htab;
-
- int conditions;
- bool save_stack;
- bool into_ssa;
- bool allow_rhs_cond_expr;
- bool in_cleanup_point_expr;
- };
-
- /* Return true if gimplify_one_sizepos doesn't need to gimplify
- expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
- fields). */
- static inline bool
- is_gimple_sizepos (tree expr)
- {
- /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
- is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
- anything if it's already a VAR_DECL. If it's a VAR_DECL from another
- function, the gimplifier will want to replace it with a new variable,
- but that will cause problems if this type is from outside the function.
- It's OK to have that here. */
- return (expr == NULL_TREE
- || TREE_CONSTANT (expr)
- || TREE_CODE (expr) == VAR_DECL
- || CONTAINS_PLACEHOLDER_P (expr));
- }
-
/* Get the number of the next statement uid to be allocated. */
static inline unsigned int
gimple_stmt_max_uid (struct function *fn)
*************** inc_gimple_stmt_max_uid (struct function
}
/* Miscellaneous helpers. */
- struct gimplify_omp_ctx;
extern tree canonicalize_cond_expr_cond (tree);
extern void dump_decl_set (FILE *, bitmap);
extern bool nonfreeing_call_p (gimple);
*************** gimple_expr_type (const_gimple stmt)
return void_type_node;
}
- enum gsi_iterator_update
- {
- GSI_NEW_STMT, /* Only valid when single statement is added, move
- iterator to it. */
- GSI_SAME_STMT, /* Leave the iterator at the same statement. */
- GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
- for linking other statements in the same
- direction. */
- };
-
gimple gimple_call_copy_skip_args (gimple, bitmap);
/* Enum and arrays used for allocation stats. Keep in sync with
===================================================================
*************** typedef struct gimple_stmt_iterator_d
basic_block bb;
} gimple_stmt_iterator;
+ enum gsi_iterator_update
+ {
+ GSI_NEW_STMT, /* Only valid when single statement is added, move
+ iterator to it. */
+ GSI_SAME_STMT, /* Leave the iterator at the same statement. */
+ GSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable
+ for linking other statements in the same
+ direction. */
+ };
+
extern void gsi_insert_seq_before_without_update (gimple_stmt_iterator *,
gimple_seq,
enum gsi_iterator_update);
===================================================================
***************
+ /* Tree lowering to gimple for backend use only.
+ This converts the GENERIC functions-as-trees tree representation into
+ the GIMPLE form.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ Major work done by Sebastian Pop <s.pop@laposte.net>,
+ Diego Novillo <dnovillo@redhat.com> and Jason Merrill <jason@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 "tree.h"
+ #include "gimple.h"
+ #include "gimple-iterator.h"
+ #include "gimplify.h"
+ #include "gimplify-be.h"
+ #include "gimple-ssa.h"
+ #include "tree-ssanames.h"
+
+
+ /* Expand EXPR to list of gimple statements STMTS. GIMPLE_TEST_F specifies
+ the predicate that will hold for the result. If VAR is not NULL, make the
+ base variable of the final destination be VAR if suitable. */
+
+ tree
+ force_gimple_operand_1 (tree expr, gimple_seq *stmts,
+ gimple_predicate gimple_test_f, tree var)
+ {
+ enum gimplify_status ret;
+ struct gimplify_ctx gctx;
+ location_t saved_location;
+
+ *stmts = NULL;
+
+ /* gimple_test_f might be more strict than is_gimple_val, make
+ sure we pass both. Just checking gimple_test_f doesn't work
+ because most gimple predicates do not work recursively. */
+ if (is_gimple_val (expr)
+ && (*gimple_test_f) (expr))
+ return expr;
+
+ push_gimplify_context (&gctx);
+ gimplify_ctxp->into_ssa = gimple_in_ssa_p (cfun);
+ gimplify_ctxp->allow_rhs_cond_expr = true;
+ saved_location = input_location;
+ input_location = UNKNOWN_LOCATION;
+
+ if (var)
+ {
+ if (gimplify_ctxp->into_ssa
+ && is_gimple_reg (var))
+ var = make_ssa_name (var, NULL);
+ expr = build2 (MODIFY_EXPR, TREE_TYPE (var), var, expr);
+ }
+
+ if (TREE_CODE (expr) != MODIFY_EXPR
+ && TREE_TYPE (expr) == void_type_node)
+ {
+ gimplify_and_add (expr, stmts);
+ expr = NULL_TREE;
+ }
+ else
+ {
+ ret = gimplify_expr (&expr, stmts, NULL, gimple_test_f, fb_rvalue);
+ gcc_assert (ret != GS_ERROR);
+ }
+
+ input_location = saved_location;
+ pop_gimplify_context (NULL);
+
+ return expr;
+ }
+
+ /* Expand EXPR to list of gimple statements STMTS. If SIMPLE is true,
+ force the result to be either ssa_name or an invariant, otherwise
+ just force it to be a rhs expression. If VAR is not NULL, make the
+ base variable of the final destination be VAR if suitable. */
+
+ tree
+ force_gimple_operand (tree expr, gimple_seq *stmts, bool simple, tree var)
+ {
+ return force_gimple_operand_1 (expr, stmts,
+ simple ? is_gimple_val : is_gimple_reg_rhs,
+ var);
+ }
+
+ /* Invoke force_gimple_operand_1 for EXPR with parameters GIMPLE_TEST_F
+ and VAR. If some statements are produced, emits them at GSI.
+ If BEFORE is true. the statements are appended before GSI, otherwise
+ they are appended after it. M specifies the way GSI moves after
+ insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING are the usual values). */
+
+ tree
+ force_gimple_operand_gsi_1 (gimple_stmt_iterator *gsi, tree expr,
+ gimple_predicate gimple_test_f,
+ tree var, bool before,
+ enum gsi_iterator_update m)
+ {
+ gimple_seq stmts;
+
+ expr = force_gimple_operand_1 (expr, &stmts, gimple_test_f, var);
+
+ if (!gimple_seq_empty_p (stmts))
+ {
+ if (before)
+ gsi_insert_seq_before (gsi, stmts, m);
+ else
+ gsi_insert_seq_after (gsi, stmts, m);
+ }
+
+ return expr;
+ }
+
+ /* Invoke force_gimple_operand_1 for EXPR with parameter VAR.
+ If SIMPLE is true, force the result to be either ssa_name or an invariant,
+ otherwise just force it to be a rhs expression. If some statements are
+ produced, emits them at GSI. If BEFORE is true, the statements are
+ appended before GSI, otherwise they are appended after it. M specifies
+ the way GSI moves after insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING
+ are the usual values). */
+
+ tree
+ force_gimple_operand_gsi (gimple_stmt_iterator *gsi, tree expr,
+ bool simple_p, tree var, bool before,
+ enum gsi_iterator_update m)
+ {
+ return force_gimple_operand_gsi_1 (gsi, expr,
+ simple_p
+ ? is_gimple_val : is_gimple_reg_rhs,
+ var, before, m);
+ }
+
+
===================================================================
*************** along with GCC; see the file COPYING3.
#include "config.h"
#include "system.h"
#include "coretypes.h"
- #include "tm.h"
#include "tree.h"
#include "gimplify.h"
#include "gimple-iterator.h"
#include "tree-iterator.h"
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
+ #include "gimple.h"
#include "gimplify.h"
#include "gimple-iterator.h"
#include "tree-iterator.h"
*************** along with GCC; see the file COPYING3.
#include "tree-cfg.h"
#include "tree-ssanames.h"
#include "tree-ssa.h"
- #include "timevar.h"
- #include "hashtab.h"
- #include "flags.h"
- #include "function.h"
- #include "ggc.h"
#include "diagnostic-core.h"
#include "target.h"
- #include "pointer-set.h"
#include "splay-tree.h"
- #include "vec.h"
#include "omp-low.h"
#include "gimple-low.h"
#include "cilk.h"
#include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */
#include "tree-pass.h" /* FIXME: only for PROP_gimple_any */
- #include "expr.h"
- #include "tm_p.h"
enum gimplify_omp_var_data
{
*************** struct gimplify_omp_ctx
bool combined_loop;
};
! static struct gimplify_ctx *gimplify_ctxp;
static struct gimplify_omp_ctx *gimplify_omp_ctxp;
bool combined_loop;
};
! struct gimplify_ctx *gimplify_ctxp;
static struct gimplify_omp_ctx *gimplify_omp_ctxp;
*************** gimple_regimplify_operands (gimple stmt,
pop_gimplify_context (NULL);
}
- /* Expand EXPR to list of gimple statements STMTS. GIMPLE_TEST_F specifies
- the predicate that will hold for the result. If VAR is not NULL, make the
- base variable of the final destination be VAR if suitable. */
-
- tree
- force_gimple_operand_1 (tree expr, gimple_seq *stmts,
- gimple_predicate gimple_test_f, tree var)
- {
- enum gimplify_status ret;
- struct gimplify_ctx gctx;
- location_t saved_location;
-
- *stmts = NULL;
-
- /* gimple_test_f might be more strict than is_gimple_val, make
- sure we pass both. Just checking gimple_test_f doesn't work
- because most gimple predicates do not work recursively. */
- if (is_gimple_val (expr)
- && (*gimple_test_f) (expr))
- return expr;
-
- push_gimplify_context (&gctx);
- gimplify_ctxp->into_ssa = gimple_in_ssa_p (cfun);
- gimplify_ctxp->allow_rhs_cond_expr = true;
- saved_location = input_location;
- input_location = UNKNOWN_LOCATION;
-
- if (var)
- {
- if (gimplify_ctxp->into_ssa
- && is_gimple_reg (var))
- var = make_ssa_name (var, NULL);
- expr = build2 (MODIFY_EXPR, TREE_TYPE (var), var, expr);
- }
-
- if (TREE_CODE (expr) != MODIFY_EXPR
- && TREE_TYPE (expr) == void_type_node)
- {
- gimplify_and_add (expr, stmts);
- expr = NULL_TREE;
- }
- else
- {
- ret = gimplify_expr (&expr, stmts, NULL, gimple_test_f, fb_rvalue);
- gcc_assert (ret != GS_ERROR);
- }
-
- input_location = saved_location;
- pop_gimplify_context (NULL);
-
- return expr;
- }
-
- /* Expand EXPR to list of gimple statements STMTS. If SIMPLE is true,
- force the result to be either ssa_name or an invariant, otherwise
- just force it to be a rhs expression. If VAR is not NULL, make the
- base variable of the final destination be VAR if suitable. */
-
- tree
- force_gimple_operand (tree expr, gimple_seq *stmts, bool simple, tree var)
- {
- return force_gimple_operand_1 (expr, stmts,
- simple ? is_gimple_val : is_gimple_reg_rhs,
- var);
- }
-
- /* Invoke force_gimple_operand_1 for EXPR with parameters GIMPLE_TEST_F
- and VAR. If some statements are produced, emits them at GSI.
- If BEFORE is true. the statements are appended before GSI, otherwise
- they are appended after it. M specifies the way GSI moves after
- insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING are the usual values). */
-
- tree
- force_gimple_operand_gsi_1 (gimple_stmt_iterator *gsi, tree expr,
- gimple_predicate gimple_test_f,
- tree var, bool before,
- enum gsi_iterator_update m)
- {
- gimple_seq stmts;
-
- expr = force_gimple_operand_1 (expr, &stmts, gimple_test_f, var);
-
- if (!gimple_seq_empty_p (stmts))
- {
- if (before)
- gsi_insert_seq_before (gsi, stmts, m);
- else
- gsi_insert_seq_after (gsi, stmts, m);
- }
-
- return expr;
- }
-
- /* Invoke force_gimple_operand_1 for EXPR with parameter VAR.
- If SIMPLE is true, force the result to be either ssa_name or an invariant,
- otherwise just force it to be a rhs expression. If some statements are
- produced, emits them at GSI. If BEFORE is true, the statements are
- appended before GSI, otherwise they are appended after it. M specifies
- the way GSI moves after insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING
- are the usual values). */
-
- tree
- force_gimple_operand_gsi (gimple_stmt_iterator *gsi, tree expr,
- bool simple_p, tree var, bool before,
- enum gsi_iterator_update m)
- {
- return force_gimple_operand_gsi_1 (gsi, expr,
- simple_p
- ? is_gimple_val : is_gimple_reg_rhs,
- var, before, m);
- }
-
/* Return a dummy expression of type TYPE in order to keep going after an
error. */
===================================================================
*************** OBJS = \
gimple-streamer-out.o \
gimple-walk.o \
gimplify.o \
+ gimplify-be.o \
godump.o \
graph.o \
graphds.o \