/* Gimple IR definitions.
- Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com>
This file is part of GCC.
#include "vecprim.h"
#include "vecir.h"
#include "ggc.h"
-#include "tm.h"
-#include "hard-reg-set.h"
#include "basic-block.h"
#include "tree-ssa-operands.h"
#include "tree-ssa-alias.h"
+#include "internal-fn.h"
struct gimple_seq_node_d;
typedef struct gimple_seq_node_d *gimple_seq_node;
enum gimple_rhs_class
{
GIMPLE_INVALID_RHS, /* The expression cannot be used on the RHS. */
+ GIMPLE_TERNARY_RHS, /* The expression is a ternary operation. */
GIMPLE_BINARY_RHS, /* The expression is a binary operation. */
GIMPLE_UNARY_RHS, /* The expression is a unary operation. */
GIMPLE_SINGLE_RHS /* The expression is a single object (an SSA
GF_CALL_TAILCALL = 1 << 3,
GF_CALL_VA_ARG_PACK = 1 << 4,
GF_CALL_NOTHROW = 1 << 5,
+ GF_CALL_ALLOCA_FOR_VAR = 1 << 6,
+ GF_CALL_INTERNAL = 1 << 7,
GF_OMP_PARALLEL_COMBINED = 1 << 0,
/* True on an GIMPLE_OMP_RETURN statement if the return does not require
GF_OMP_RETURN_NOWAIT = 1 << 0,
GF_OMP_SECTION_LAST = 1 << 0,
+ GF_OMP_ATOMIC_NEED_VALUE = 1 << 0,
GF_PREDICT_TAKEN = 1 << 15
};
-/* Currently, there's only one type of gimple debug stmt. Others are
+/* Currently, there are only two types of gimple debug stmt. Others are
envisioned, for example, to enable the generation of is_stmt notes
in line number information, to mark sequence points, etc. This
subcode is to be used to tell them apart. */
enum gimple_debug_subcode {
- GIMPLE_DEBUG_BIND = 0
+ GIMPLE_DEBUG_BIND = 0,
+ GIMPLE_DEBUG_SOURCE_BIND = 1
};
/* Masks for selecting a pass local flag (PLF) to work on. These
struct pt_solution call_used;
struct pt_solution call_clobbered;
- /* [ WORD 13 ]
+ /* [ WORD 13 ] */
+ union GTY ((desc ("%1.membase.opbase.gsbase.subcode & GF_CALL_INTERNAL"))) {
+ tree GTY ((tag ("0"))) fntype;
+ enum internal_fn GTY ((tag ("GF_CALL_INTERNAL"))) internal_fn;
+ } u;
+
+ /* [ WORD 14 ]
Operand vector. NOTE! This must always be the last field
of this structure. In particular, this means that this
structure cannot be embedded inside another one. */
gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
#define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
-void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *);
+void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *, tree *);
gimple gimple_build_assign_with_ops_stat (enum tree_code, tree, tree,
- tree MEM_STAT_DECL);
-#define gimple_build_assign_with_ops(c,o1,o2,o3) \
- gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
+ tree, tree MEM_STAT_DECL);
+#define gimple_build_assign_with_ops(c,o1,o2,o3) \
+ gimple_build_assign_with_ops_stat (c, o1, o2, o3, NULL_TREE MEM_STAT_INFO)
+#define gimple_build_assign_with_ops3(c,o1,o2,o3,o4) \
+ gimple_build_assign_with_ops_stat (c, o1, o2, o3, o4 MEM_STAT_INFO)
gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
#define gimple_build_debug_bind(var,val,stmt) \
gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
+gimple gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
+#define gimple_build_debug_source_bind(var,val,stmt) \
+ gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
gimple gimple_build_call (tree, unsigned, ...);
+gimple gimple_build_call_valist (tree, unsigned, va_list);
+gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
+gimple gimple_build_call_internal_vec (enum internal_fn, VEC(tree, heap) *);
gimple gimple_build_call_from_tree (tree);
gimple gimplify_assign (tree, tree, gimple_seq *);
gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
void gimple_seq_free (gimple_seq);
void gimple_seq_add_seq (gimple_seq *, gimple_seq);
gimple_seq gimple_seq_copy (gimple_seq);
+bool gimple_call_same_target_p (const_gimple, const_gimple);
int gimple_call_flags (const_gimple);
int gimple_call_return_flags (const_gimple);
int gimple_call_arg_flags (const_gimple, unsigned);
void gimple_call_reset_alias_info (gimple);
bool gimple_assign_copy_p (gimple);
bool gimple_assign_ssa_name_copy_p (gimple);
-bool gimple_assign_single_p (gimple);
bool gimple_assign_unary_nop_p (gimple);
void gimple_set_bb (gimple, struct basic_block_def *);
void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
-void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
- tree, tree);
+void gimple_assign_set_rhs_with_ops_1 (gimple_stmt_iterator *, enum tree_code,
+ tree, tree, tree);
tree gimple_get_lhs (const_gimple);
void gimple_set_lhs (gimple, tree);
void gimple_replace_lhs (gimple, tree);
gimple gimple_copy (gimple);
-bool is_gimple_operand (const_tree);
void gimple_set_modified (gimple, bool);
void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *);
gimple gimple_build_cond_from_tree (tree, tree, tree);
bool gimple_has_side_effects (const_gimple);
bool gimple_rhs_has_side_effects (const_gimple);
bool gimple_could_trap_p (gimple);
+bool gimple_could_trap_p_1 (gimple, bool, bool);
bool gimple_assign_rhs_could_trap_p (gimple);
void gimple_regimplify_operands (gimple, gimple_stmt_iterator *);
bool empty_body_p (gimple_seq);
#define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
const char *gimple_decl_printable_name (tree, int);
-tree gimple_fold_obj_type_ref (tree, tree);
-tree gimple_get_relevant_ref_binfo (tree ref, tree known_binfo);
-tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT, tree);
-
+bool gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace);
+tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree);
+void gimple_adjust_this_by_delta (gimple_stmt_iterator *, tree);
+tree gimple_extract_devirt_binfo_from_cst (tree);
/* Returns true iff T is a valid GIMPLE statement. */
extern bool is_gimple_stmt (tree);
extern bool is_gimple_val (tree);
/* Returns true iff T is a GIMPLE asm statement input. */
extern bool is_gimple_asm_val (tree);
+/* Returns true iff T is a valid address operand of a MEM_REF. */
+bool is_gimple_mem_ref_addr (tree);
/* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
GIMPLE temporary, a renamed user variable, or something else,
respectively. */
/* Returns true iff T is a valid if-statement condition. */
extern bool is_gimple_condexpr (tree);
-/* Returns true iff T is a type conversion. */
-extern bool is_gimple_cast (tree);
/* Returns true iff T is a variable that does not need to live in memory. */
extern bool is_gimple_non_addressable (tree t);
extern void recalculate_side_effects (tree);
extern bool gimple_compare_field_offset (tree, tree);
extern tree gimple_register_type (tree);
+extern tree gimple_register_canonical_type (tree);
extern void print_gimple_types_stats (void);
extern void free_gimple_type_tables (void);
extern tree gimple_unsigned_type (tree);
bool (*)(gimple, tree, void *));
extern bool gimple_ior_addresses_taken (bitmap, gimple);
extern bool gimple_call_builtin_p (gimple, enum built_in_function);
+extern bool gimple_asm_clobbers_memory_p (const_gimple);
/* In gimplify.c */
extern tree create_tmp_var_raw (tree, const char *);
}
+/* Return true if OMP atomic load/store statement G has the
+ GF_OMP_ATOMIC_NEED_VALUE flag set. */
+
+static inline bool
+gimple_omp_atomic_need_value_p (const_gimple g)
+{
+ if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
+ GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
+ return (gimple_omp_subcode (g) & GF_OMP_ATOMIC_NEED_VALUE) != 0;
+}
+
+
+/* Set the GF_OMP_ATOMIC_NEED_VALUE flag on G. */
+
+static inline void
+gimple_omp_atomic_set_need_value (gimple g)
+{
+ if (gimple_code (g) != GIMPLE_OMP_ATOMIC_LOAD)
+ GIMPLE_CHECK (g, GIMPLE_OMP_ATOMIC_STORE);
+ g->gsbase.subcode |= GF_OMP_ATOMIC_NEED_VALUE;
+}
+
+
/* Return the number of operands for statement GS. */
static inline unsigned
gimple_set_op (gs, 2, rhs);
}
+/* Return the third operand on the RHS of assignment statement GS.
+ If GS does not have two operands, NULL is returned instead. */
+
+static inline tree
+gimple_assign_rhs3 (const_gimple gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
+
+ if (gimple_num_ops (gs) >= 4)
+ return gimple_op (gs, 3);
+ else
+ return NULL_TREE;
+}
+
+/* Return a pointer to the third operand on the RHS of assignment
+ statement GS. */
+
+static inline tree *
+gimple_assign_rhs3_ptr (const_gimple gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
+ return gimple_op_ptr (gs, 3);
+}
+
+
+/* Set RHS to be the third operand on the RHS of assignment statement GS. */
+
+static inline void
+gimple_assign_set_rhs3 (gimple gs, tree rhs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
+
+ gimple_set_op (gs, 3, rhs);
+}
+
+/* A wrapper around gimple_assign_set_rhs_with_ops_1, for callers which expect
+ to see only a maximum of two operands. */
+
+static inline void
+gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
+ tree op1, tree op2)
+{
+ gimple_assign_set_rhs_with_ops_1 (gsi, code, op1, op2, NULL);
+}
+
+/* A wrapper around extract_ops_from_tree_1, for callers which expect
+ to see only a maximum of two operands. */
+
+static inline void
+extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
+ tree *op1)
+{
+ tree op2;
+ extract_ops_from_tree_1 (expr, code, op0, op1, &op2);
+ gcc_assert (op2 == NULL_TREE);
+}
+
/* Returns true if GS is a nontemporal move. */
static inline bool
enum tree_code code;
GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
- code = gimple_expr_code (gs);
+ code = (enum tree_code) gs->gsbase.subcode;
+ /* While we initially set subcode to the TREE_CODE of the rhs for
+ GIMPLE_SINGLE_RHS assigns we do not update that subcode to stay
+ in sync when we rewrite stmts into SSA form or do SSA propagations. */
if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
code = TREE_CODE (gimple_assign_rhs1 (gs));
return get_gimple_rhs_class (gimple_assign_rhs_code (gs));
}
+/* Return true if GS is an assignment with a singleton RHS, i.e.,
+ there is no operator associated with the assignment itself.
+ Unlike gimple_assign_copy_p, this predicate returns true for
+ any RHS operand, including those that perform an operation
+ and do not have the semantics of a copy, such as COND_EXPR. */
+
+static inline bool
+gimple_assign_single_p (gimple gs)
+{
+ return (is_gimple_assign (gs)
+ && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
+}
+
/* Return true if S is a type-cast assignment. */
}
+/* Return true if call GS calls an internal-only function, as enumerated
+ by internal_fn. */
+
+static inline bool
+gimple_call_internal_p (const_gimple gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_CALL);
+ return (gs->gsbase.subcode & GF_CALL_INTERNAL) != 0;
+}
+
+
+/* Return the target of internal call GS. */
+
+static inline enum internal_fn
+gimple_call_internal_fn (const_gimple gs)
+{
+ gcc_gimple_checking_assert (gimple_call_internal_p (gs));
+ return gs->gimple_call.u.internal_fn;
+}
+
+
+/* Return the function type of the function called by GS. */
+
+static inline tree
+gimple_call_fntype (const_gimple gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_CALL);
+ if (gimple_call_internal_p (gs))
+ return NULL_TREE;
+ return gs->gimple_call.u.fntype;
+}
+
+/* Set the type of the function called by GS to FNTYPE. */
+
+static inline void
+gimple_call_set_fntype (gimple gs, tree fntype)
+{
+ GIMPLE_CHECK (gs, GIMPLE_CALL);
+ gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
+ gs->gimple_call.u.fntype = fntype;
+}
+
+
/* Return the tree node representing the function called by call
statement GS. */
return gimple_op (gs, 1);
}
-
/* Return a pointer to the tree node representing the function called by call
statement GS. */
gimple_call_set_fn (gimple gs, tree fn)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
+ gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
gimple_set_op (gs, 1, fn);
}
gimple_call_set_fndecl (gimple gs, tree decl)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
+ gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
}
+/* Set internal function FN to be the function called by call statement GS. */
+
+static inline void
+gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
+{
+ GIMPLE_CHECK (gs, GIMPLE_CALL);
+ gcc_gimple_checking_assert (gimple_call_internal_p (gs));
+ gs->gimple_call.u.internal_fn = fn;
+}
+
+
+/* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
+ associated with the callee if known. Otherwise return NULL_TREE. */
+
+static inline tree
+gimple_call_addr_fndecl (const_tree fn)
+{
+ if (fn && TREE_CODE (fn) == ADDR_EXPR)
+ {
+ tree fndecl = TREE_OPERAND (fn, 0);
+ if (TREE_CODE (fndecl) == MEM_REF
+ && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
+ && integer_zerop (TREE_OPERAND (fndecl, 1)))
+ fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
+ if (TREE_CODE (fndecl) == FUNCTION_DECL)
+ return fndecl;
+ }
+ return NULL_TREE;
+}
+
/* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
Otherwise return NULL. This function is analogous to
get_callee_fndecl in tree land. */
static inline tree
gimple_call_fndecl (const_gimple gs)
{
- tree addr = gimple_call_fn (gs);
- if (TREE_CODE (addr) == ADDR_EXPR)
- return TREE_OPERAND (addr, 0);
- return NULL_TREE;
+ return gimple_call_addr_fndecl (gimple_call_fn (gs));
}
static inline tree
gimple_call_return_type (const_gimple gs)
{
- tree fn = gimple_call_fn (gs);
- tree type = TREE_TYPE (fn);
+ tree type = gimple_call_fntype (gs);
- /* See through the pointer. */
- type = TREE_TYPE (type);
+ if (type == NULL_TREE)
+ return TREE_TYPE (gimple_call_lhs (gs));
- /* The type returned by a FUNCTION_DECL is the type of its
+ /* The type returned by a function is the type of its
function type. */
return TREE_TYPE (type);
}
return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
}
+/* If FOR_VAR is true, GIMPLE_CALL S is a call to builtin_alloca that
+ is known to be emitted for VLA objects. Those are wrapped by
+ stack_save/stack_restore calls and hence can't lead to unbounded
+ stack growth even when they occur in loops. */
+
+static inline void
+gimple_call_set_alloca_for_var (gimple s, bool for_var)
+{
+ GIMPLE_CHECK (s, GIMPLE_CALL);
+ if (for_var)
+ s->gsbase.subcode |= GF_CALL_ALLOCA_FOR_VAR;
+ else
+ s->gsbase.subcode &= ~GF_CALL_ALLOCA_FOR_VAR;
+}
+
+/* Return true of S is a call to builtin_alloca emitted for VLA objects. */
+
+static inline bool
+gimple_call_alloca_for_var_p (gimple s)
+{
+ GIMPLE_CHECK (s, GIMPLE_CALL);
+ return (s->gsbase.subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
+}
/* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL. */
#undef GIMPLE_DEBUG_BIND_NOVALUE
+/* Return true if S is a GIMPLE_DEBUG SOURCE BIND statement. */
+
+static inline bool
+gimple_debug_source_bind_p (const_gimple s)
+{
+ if (is_gimple_debug (s))
+ return s->gsbase.subcode == GIMPLE_DEBUG_SOURCE_BIND;
+
+ return false;
+}
+
+/* Return the variable bound in a GIMPLE_DEBUG source bind statement. */
+
+static inline tree
+gimple_debug_source_bind_get_var (gimple dbg)
+{
+ GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+ gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
+ return gimple_op (dbg, 0);
+}
+
+/* Return the value bound to the variable in a GIMPLE_DEBUG source bind
+ statement. */
+
+static inline tree
+gimple_debug_source_bind_get_value (gimple dbg)
+{
+ GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+ gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
+ return gimple_op (dbg, 1);
+}
+
+/* Return a pointer to the value bound to the variable in a
+ GIMPLE_DEBUG source bind statement. */
+
+static inline tree *
+gimple_debug_source_bind_get_value_ptr (gimple dbg)
+{
+ GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+ gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
+ return gimple_op_ptr (dbg, 1);
+}
+
+/* Set the variable bound in a GIMPLE_DEBUG source bind statement. */
+
+static inline void
+gimple_debug_source_bind_set_var (gimple dbg, tree var)
+{
+ GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+ gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
+ gimple_set_op (dbg, 0, var);
+}
+
+/* Set the value bound to the variable in a GIMPLE_DEBUG source bind
+ statement. */
+
+static inline void
+gimple_debug_source_bind_set_value (gimple dbg, tree value)
+{
+ GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+ gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
+ gimple_set_op (dbg, 1, value);
+}
+
/* Return the body for the OMP statement GS. */
static inline gimple_seq
void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
tree gimple_fold_builtin (gimple);
bool fold_stmt (gimple_stmt_iterator *);
-bool fold_stmt_inplace (gimple);
-tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
-tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
-tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
+bool fold_stmt_inplace (gimple_stmt_iterator *);
tree get_symbol_constant_value (tree);
-bool may_propagate_address_into_dereference (tree, tree);
+tree canonicalize_constructor_val (tree);
extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree,
enum tree_code, tree, tree);
extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
enum tree_code, tree, tree);
+bool gimple_val_nonnegative_real_p (tree);
#endif /* GCC_GIMPLE_H */