/* Inline functions for tree-flow.h
- Copyright (C) 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed 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 2, or (at your option)
+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,
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 COPYING. If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
#ifndef _TREE_FLOW_INLINE_H
#define _TREE_FLOW_INLINE_H 1
infrastructure is initialized. Check for presence of the datastructures
at first place. */
static inline bool
-gimple_in_ssa_p (struct function *fun)
+gimple_in_ssa_p (const struct function *fun)
{
return fun && fun->gimple_df && fun->gimple_df->in_ssa_p;
}
/* 'true' after aliases have been computed (see compute_may_aliases). */
static inline bool
-gimple_aliases_computed_p (struct function *fun)
+gimple_aliases_computed_p (const struct function *fun)
{
gcc_assert (fun && fun->gimple_df);
return fun->gimple_df->aliases_computed_p;
call-clobbered variables are addressable (e.g., a local static
variable). */
static inline bitmap
-gimple_addressable_vars (struct function *fun)
+gimple_addressable_vars (const struct function *fun)
{
gcc_assert (fun && fun->gimple_df);
return fun->gimple_df->addressable_vars;
/* Call clobbered variables in the function. If bit I is set, then
REFERENCED_VARS (I) is call-clobbered. */
static inline bitmap
-gimple_call_clobbered_vars (struct function *fun)
+gimple_call_clobbered_vars (const struct function *fun)
{
gcc_assert (fun && fun->gimple_df);
return fun->gimple_df->call_clobbered_vars;
/* Array of all variables referenced in the function. */
static inline htab_t
-gimple_referenced_vars (struct function *fun)
+gimple_referenced_vars (const struct function *fun)
{
if (!fun->gimple_df)
return NULL;
/* Artificial variable used to model the effects of function calls. */
static inline tree
-gimple_global_var (struct function *fun)
+gimple_global_var (const struct function *fun)
{
gcc_assert (fun && fun->gimple_df);
return fun->gimple_df->global_var;
/* Artificial variable used to model the effects of nonlocal
variables. */
static inline tree
-gimple_nonlocal_all (struct function *fun)
+gimple_nonlocal_all (const struct function *fun)
{
gcc_assert (fun && fun->gimple_df);
return fun->gimple_df->nonlocal_all;
/* Hashtable of variables annotations. Used for static variables only;
local variables have direct pointer in the tree node. */
static inline htab_t
-gimple_var_anns (struct function *fun)
+gimple_var_anns (const struct function *fun)
{
return fun->gimple_df->var_anns;
}
or NULL if we have reached the end. */
static inline bool
-end_htab_p (htab_iterator *hti)
+end_htab_p (const htab_iterator *hti)
{
if (hti->slot >= hti->limit)
return true;
iterating through. */
static inline bool
-end_referenced_vars_p (referenced_var_iterator *iter)
+end_referenced_vars_p (const referenced_var_iterator *iter)
{
return end_htab_p (&iter->hti);
}
/* Return the variable annotation for T, which must be a _DECL node.
Return NULL if the variable annotation doesn't already exist. */
static inline var_ann_t
-var_ann (tree t)
+var_ann (const_tree t)
{
gcc_assert (t);
gcc_assert (DECL_P (t));
htab_find_with_hash (gimple_var_anns (cfun), t, DECL_UID (t)));
if (!sann)
return NULL;
- gcc_assert (sann->ann.common.type = VAR_ANN);
+ gcc_assert (sann->ann.common.type == VAR_ANN);
return &sann->ann;
}
gcc_assert (!t->base.ann
/* Return the function annotation for T, which must be a FUNCTION_DECL node.
Return NULL if the function annotation doesn't already exist. */
static inline function_ann_t
-function_ann (tree t)
+function_ann (const_tree t)
{
gcc_assert (t);
gcc_assert (TREE_CODE (t) == FUNCTION_DECL);
return ann ? ann->bb : NULL;
}
-/* Return the may_aliases varray for variable VAR, or NULL if it has
+/* Return the may_aliases bitmap for variable VAR, or NULL if it has
no may aliases. */
-static inline VEC(tree, gc) *
-may_aliases (tree var)
+static inline bitmap
+may_aliases (const_tree var)
{
- var_ann_t ann = var_ann (var);
- return ann ? ann->may_aliases : NULL;
+ return MTAG_ALIASES (var);
}
/* Return the line number for EXPR, or return -1 if we have no line
number information for it. */
static inline int
-get_lineno (tree expr)
+get_lineno (const_tree expr)
{
if (expr == NULL_TREE)
return -1;
return EXPR_LINENO (expr);
}
-/* Return the file name for EXPR, or return "???" if we have no
- filename information. */
-static inline const char *
-get_filename (tree expr)
-{
- const char *filename;
- if (expr == NULL_TREE)
- return "???";
-
- if (TREE_CODE (expr) == COMPOUND_EXPR)
- expr = TREE_OPERAND (expr, 0);
-
- if (EXPR_HAS_LOCATION (expr) && (filename = EXPR_FILENAME (expr)))
- return filename;
- else
- return "???";
-}
-
/* Return true if T is a noreturn call. */
static inline bool
noreturn_call_p (tree t)
/* Return true is IMM has reached the end of the immediate use list. */
static inline bool
-end_readonly_imm_use_p (imm_use_iterator *imm)
+end_readonly_imm_use_p (const imm_use_iterator *imm)
{
return (imm->imm_use == imm->end_p);
}
/* Return true if VAR has no uses. */
static inline bool
-has_zero_uses (tree var)
+has_zero_uses (const_tree var)
{
- ssa_use_operand_t *ptr;
- ptr = &(SSA_NAME_IMM_USE_NODE (var));
+ const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
/* A single use means there is no items in the list. */
return (ptr == ptr->next);
}
/* Return true if VAR has a single use. */
static inline bool
-has_single_use (tree var)
+has_single_use (const_tree var)
{
- ssa_use_operand_t *ptr;
- ptr = &(SSA_NAME_IMM_USE_NODE (var));
+ const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
/* A single use means there is one item in the list. */
return (ptr != ptr->next && ptr == ptr->next->next);
}
-/* If VAR has only a single immediate use, return true. */
-static inline bool
-single_imm_use_p (tree var)
-{
- ssa_use_operand_t *ptr;
-
- ptr = &(SSA_NAME_IMM_USE_NODE (var));
- return (ptr != ptr->next && ptr == ptr->next->next);
-}
-
-
/* If VAR has only a single immediate use, return true, and set USE_P and STMT
to the use pointer and stmt of occurrence. */
static inline bool
-single_imm_use (tree var, use_operand_p *use_p, tree *stmt)
+single_imm_use (const_tree var, use_operand_p *use_p, tree *stmt)
{
- ssa_use_operand_t *ptr;
-
- ptr = &(SSA_NAME_IMM_USE_NODE (var));
+ const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
if (ptr != ptr->next && ptr == ptr->next->next)
{
*use_p = ptr->next;
/* Return the number of immediate uses of VAR. */
static inline unsigned int
-num_imm_uses (tree var)
+num_imm_uses (const_tree var)
{
- ssa_use_operand_t *ptr, *start;
- unsigned int num;
+ const ssa_use_operand_t *const start = &(SSA_NAME_IMM_USE_NODE (var));
+ const ssa_use_operand_t *ptr;
+ unsigned int num = 0;
- start = &(SSA_NAME_IMM_USE_NODE (var));
- num = 0;
for (ptr = start->next; ptr != start; ptr = ptr->next)
num++;
return num;
}
-/* Return true if VAR has no immediate uses. */
-static inline bool
-zero_imm_uses_p (tree var)
-{
- ssa_use_operand_t *ptr = &(SSA_NAME_IMM_USE_NODE (var));
- return (ptr == ptr->next);
-}
-
/* Return the tree pointer to by USE. */
static inline tree
get_use_from_ptr (use_operand_p use)
/* Return the PHI nodes for basic block BB, or NULL if there are no
PHI nodes. */
static inline tree
-phi_nodes (basic_block bb)
+phi_nodes (const_basic_block bb)
{
- return bb->phi_nodes;
+ gcc_assert (!(bb->flags & BB_RTL));
+ if (!bb->il.tree)
+ return NULL;
+ return bb->il.tree->phi_nodes;
+}
+
+/* Return pointer to the list of PHI nodes for basic block BB. */
+
+static inline tree *
+phi_nodes_ptr (basic_block bb)
+{
+ gcc_assert (!(bb->flags & BB_RTL));
+ return &bb->il.tree->phi_nodes;
}
/* Set list of phi nodes of a basic block BB to L. */
{
tree phi;
- bb->phi_nodes = l;
+ gcc_assert (!(bb->flags & BB_RTL));
+ bb->il.tree->phi_nodes = l;
for (phi = l; phi; phi = PHI_CHAIN (phi))
set_bb_for_stmt (phi, bb);
}
ann->used = 1;
}
-/* Return true if T is an executable statement. */
-static inline bool
-is_exec_stmt (tree t)
-{
- return (t && !IS_EMPTY_STMT (t) && t != error_mark_node);
-}
+/* Return true if T (assumed to be a DECL) is a global variable. */
-/* Return true if this stmt can be the target of a control transfer stmt such
- as a goto. */
static inline bool
-is_label_stmt (tree t)
-{
- if (t)
- switch (TREE_CODE (t))
- {
- case LABEL_DECL:
- case LABEL_EXPR:
- case CASE_LABEL_EXPR:
- return true;
- default:
- return false;
- }
- return false;
+is_global_var (const_tree t)
+{
+ if (MTAG_P (t))
+ return (TREE_STATIC (t) || MTAG_GLOBAL (t));
+ else
+ return (TREE_STATIC (t) || DECL_EXTERNAL (t));
}
/* PHI nodes should contain only ssa_names and invariants. A test
slip in in the meantime. */
static inline bool
-phi_ssa_name_p (tree t)
+phi_ssa_name_p (const_tree t)
{
if (TREE_CODE (t) == SSA_NAME)
return true;
/* ----------------------------------------------------------------------- */
+/* Returns the list of statements in BB. */
+
+static inline tree
+bb_stmt_list (const_basic_block bb)
+{
+ gcc_assert (!(bb->flags & BB_RTL));
+ return bb->il.tree->stmt_list;
+}
+
+/* Sets the list of statements in BB to LIST. */
+
+static inline void
+set_bb_stmt_list (basic_block bb, tree list)
+{
+ gcc_assert (!(bb->flags & BB_RTL));
+ bb->il.tree->stmt_list = list;
+}
+
/* Return a block_stmt_iterator that points to beginning of basic
block BB. */
static inline block_stmt_iterator
bsi_start (basic_block bb)
{
block_stmt_iterator bsi;
- if (bb->stmt_list)
- bsi.tsi = tsi_start (bb->stmt_list);
- else
+ if (bb->index < NUM_FIXED_BLOCKS)
{
- gcc_assert (bb->index < NUM_FIXED_BLOCKS);
bsi.tsi.ptr = NULL;
bsi.tsi.container = NULL;
}
+ else
+ bsi.tsi = tsi_start (bb_stmt_list (bb));
bsi.bb = bb;
return bsi;
}
bsi_last (basic_block bb)
{
block_stmt_iterator bsi;
- if (bb->stmt_list)
- bsi.tsi = tsi_last (bb->stmt_list);
- else
+
+ if (bb->index < NUM_FIXED_BLOCKS)
{
- gcc_assert (bb->index < NUM_FIXED_BLOCKS);
bsi.tsi.ptr = NULL;
bsi.tsi.container = NULL;
}
+ else
+ bsi.tsi = tsi_last (bb_stmt_list (bb));
bsi.bb = bb;
return bsi;
}
return tag;
}
-
-/* Set MPT to be the memory partition associated with symbol SYM. */
-
-static inline void
-set_memory_partition (tree sym, tree mpt)
-{
-#if defined ENABLE_CHECKING
- if (mpt)
- gcc_assert (TREE_CODE (mpt) == MEMORY_PARTITION_TAG
- && !is_gimple_reg (sym));
-#endif
- var_ann (sym)->mpt = mpt;
- if (mpt)
- {
- bitmap_set_bit (MPT_SYMBOLS (mpt), DECL_UID (sym));
-
- /* MPT inherits the call-clobbering attributes from SYM. */
- if (is_call_clobbered (sym))
- {
- MTAG_GLOBAL (mpt) = 1;
- mark_call_clobbered (mpt, ESCAPE_IS_GLOBAL);
- }
- }
-}
-
/* Return true if NAME is a memory factoring SSA name (i.e., an SSA
name for a memory partition. */
static inline bool
-factoring_name_p (tree name)
+factoring_name_p (const_tree name)
{
return TREE_CODE (SSA_NAME_VAR (name)) == MEMORY_PARTITION_TAG;
}
/* Return true if VAR is a clobbered by function calls. */
static inline bool
-is_call_clobbered (tree var)
+is_call_clobbered (const_tree var)
{
if (!MTAG_P (var))
- return DECL_CALL_CLOBBERED (var);
+ return var_ann (var)->call_clobbered;
else
return bitmap_bit_p (gimple_call_clobbered_vars (cfun), DECL_UID (var));
}
{
var_ann (var)->escape_mask |= escape_type;
if (!MTAG_P (var))
- DECL_CALL_CLOBBERED (var) = true;
+ var_ann (var)->call_clobbered = true;
bitmap_set_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
}
if (MTAG_P (var) && TREE_CODE (var) != STRUCT_FIELD_TAG)
MTAG_GLOBAL (var) = 0;
if (!MTAG_P (var))
- DECL_CALL_CLOBBERED (var) = false;
+ var_ann (var)->call_clobbered = false;
bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
}
/* Return the common annotation for T. Return NULL if the annotation
doesn't already exist. */
static inline tree_ann_common_t
-tree_common_ann (tree t)
+tree_common_ann (const_tree t)
{
/* Watch out static variables with unshared annotations. */
if (DECL_P (t) && TREE_CODE (t) == VAR_DECL)
/* Return true if PTR is finished iterating. */
static inline bool
-op_iter_done (ssa_op_iter *ptr)
+op_iter_done (const ssa_op_iter *ptr)
{
return ptr->done;
}
/* Return true is IMM has reached the end of the immediate use stmt list. */
static inline bool
-end_imm_use_stmt_p (imm_use_iterator *imm)
+end_imm_use_stmt_p (const imm_use_iterator *imm)
{
return (imm->imm_use == imm->end_p);
}
link_use_stmts_after (imm->imm_use, imm);
return USE_STMT (imm->imm_use);
-
}
/* This routine will return the first use on the stmt IMM currently refers
/* Return TRUE if the last use on the stmt IMM refers to has been visited. */
static inline bool
-end_imm_use_on_stmt_p (imm_use_iterator *imm)
+end_imm_use_on_stmt_p (const imm_use_iterator *imm)
{
return (imm->imm_use == &(imm->iter_node));
}
/* Return true if VAR cannot be modified by the program. */
static inline bool
-unmodifiable_var_p (tree var)
+unmodifiable_var_p (const_tree var)
{
if (TREE_CODE (var) == SSA_NAME)
var = SSA_NAME_VAR (var);
/* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it. */
static inline bool
-array_ref_contains_indirect_ref (tree ref)
+array_ref_contains_indirect_ref (const_tree ref)
{
gcc_assert (TREE_CODE (ref) == ARRAY_REF);
somewhere in it. */
static inline bool
-ref_contains_array_ref (tree ref)
+ref_contains_array_ref (const_tree ref)
{
gcc_assert (handled_component_p (ref));
subvariables for it. */
static inline subvar_t *
-lookup_subvars_for_var (tree var)
+lookup_subvars_for_var (const_tree var)
{
var_ann_t ann = var_ann (var);
gcc_assert (ann);
types which are not gimple registers can have subvars. */
static inline bool
-var_can_have_subvars (tree v)
+var_can_have_subvars (const_tree v)
{
/* Volatile variables should never have subvars. */
if (TREE_THIS_VOLATILE (v))
static inline bool
overlap_subvar (unsigned HOST_WIDE_INT offset, unsigned HOST_WIDE_INT size,
- tree sv, bool *exact)
+ const_tree sv, bool *exact)
{
/* There are three possible cases of overlap.
1. We can have an exact overlap, like so:
/* Accessor to tree-ssa-operands.c caches. */
static inline struct ssa_operands *
-gimple_ssa_operands (struct function *fun)
+gimple_ssa_operands (const struct function *fun)
{
return &fun->gimple_df->ssa_operands;
}
+
+/* Map describing reference statistics for function FN. */
+static inline struct mem_ref_stats_d *
+gimple_mem_ref_stats (const struct function *fn)
+{
+ return &fn->gimple_df->mem_ref_stats;
+}
#endif /* _TREE_FLOW_INLINE_H */