X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ftree-ssa-sccvn.h;h=b37b084413d91867dbf36d7923aa97fd6460d80b;hb=fe10f73e500e04b2006cdcfd1349e93dfdcebd0e;hp=0f8189cf2a5ba363e2faae0afc8bc8d570fe469e;hpb=f6c33c78e5e0d4c5582c1936c3346b9916b6490a;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index 0f8189cf2a5..b37b084413d 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -1,5 +1,5 @@ /* Tree SCC value numbering - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by Daniel Berlin This file is part of GCC. @@ -21,6 +21,10 @@ #ifndef TREE_SSA_SCCVN_H #define TREE_SSA_SCCVN_H +/* In tree-ssa-sccvn.c */ +bool expressions_equal_p (tree, tree); + + /* TOP of the VN lattice. */ extern tree VN_TOP; @@ -38,10 +42,18 @@ typedef struct vn_nary_op_s hashval_t hashcode; tree result; tree type; - tree op[4]; + tree op[1]; } *vn_nary_op_t; typedef const struct vn_nary_op_s *const_vn_nary_op_t; +/* Return the size of a vn_nary_op_t with LENGTH operands. */ + +static inline size_t +sizeof_vn_nary_op (unsigned int length) +{ + return sizeof (struct vn_nary_op_s) + sizeof (tree) * (length - 1); +} + /* Phi nodes in the hashtable consist of their non-VN_TOP phi arguments, and the basic block the phi is in. Result is the value number of the operation, and hashcode is stored to avoid having to @@ -68,6 +80,8 @@ typedef const struct vn_phi_s *const_vn_phi_t; typedef struct vn_reference_op_struct { enum tree_code opcode; + /* Constant offset this op adds or -1 if it is variable. */ + HOST_WIDE_INT off; tree type; tree op0; tree op1; @@ -79,20 +93,21 @@ typedef const vn_reference_op_s *const_vn_reference_op_t; DEF_VEC_O(vn_reference_op_s); DEF_VEC_ALLOC_O(vn_reference_op_s, heap); -/* A reference operation in the hashtable is representation as a - collection of vuses, representing the memory state at the time of +/* A reference operation in the hashtable is representation as + the vuse, representing the memory state at the time of the operation, and a collection of operands that make up the addressing calculation. If two vn_reference_t's have the same set of operands, they access the same memory location. We also store - the resulting value number, and the hashcode. The vuses are - always stored in order sorted by ssa name version. */ + the resulting value number, and the hashcode. */ typedef struct vn_reference_s { /* Unique identifier that all expressions with the same value have. */ unsigned int value_id; hashval_t hashcode; - VEC (tree, gc) *vuses; + tree vuse; + alias_set_type set; + tree type; VEC (vn_reference_op_s, heap) *operands; tree result; } *vn_reference_t; @@ -104,7 +119,30 @@ typedef struct vn_constant_s hashval_t hashcode; tree constant; } *vn_constant_t; - + +/* Hash the constant CONSTANT with distinguishing type incompatible + constants in the types_compatible_p sense. */ + +static inline hashval_t +vn_hash_constant_with_type (tree constant) +{ + tree type = TREE_TYPE (constant); + return (iterative_hash_expr (constant, 0) + + INTEGRAL_TYPE_P (type) + + (INTEGRAL_TYPE_P (type) + ? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0)); +} + +/* Compare the constants C1 and C2 with distinguishing type incompatible + constants in the types_compatible_p sense. */ + +static inline bool +vn_constant_eq_with_type (tree c1, tree c2) +{ + return (expressions_equal_p (c1, c2) + && types_compatible_p (TREE_TYPE (c1), TREE_TYPE (c2))); +} + typedef struct vn_ssa_aux { /* Value number. This may be an SSA name or a constant. */ @@ -135,37 +173,60 @@ typedef struct vn_ssa_aux unsigned needs_insertion : 1; } *vn_ssa_aux_t; +typedef enum { VN_NOWALK, VN_WALK, VN_WALKREWRITE } vn_lookup_kind; + /* Return the value numbering info for an SSA_NAME. */ extern vn_ssa_aux_t VN_INFO (tree); extern vn_ssa_aux_t VN_INFO_GET (tree); -bool run_scc_vn (bool); +tree vn_get_expr_for (tree); +bool run_scc_vn (vn_lookup_kind); void free_scc_vn (void); -void switch_to_PRE_table (void); tree vn_nary_op_lookup (tree, vn_nary_op_t *); +tree vn_nary_op_lookup_stmt (gimple, vn_nary_op_t *); tree vn_nary_op_lookup_pieces (unsigned int, enum tree_code, - tree, tree, tree, tree, tree, - vn_nary_op_t *); + tree, tree *, vn_nary_op_t *); vn_nary_op_t vn_nary_op_insert (tree, tree); +vn_nary_op_t vn_nary_op_insert_stmt (gimple, tree); vn_nary_op_t vn_nary_op_insert_pieces (unsigned int, enum tree_code, - tree, tree, tree, tree, - tree, tree, unsigned int); -tree vn_reference_lookup_pieces (VEC (tree, gc) *, + tree, tree *, tree, unsigned int); +void vn_reference_fold_indirect (VEC (vn_reference_op_s, heap) **, + unsigned int *); +void copy_reference_ops_from_ref (tree, VEC(vn_reference_op_s, heap) **); +void copy_reference_ops_from_call (gimple, VEC(vn_reference_op_s, heap) **); +bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, tree, + VEC (vn_reference_op_s, heap) *); +tree vn_reference_lookup_pieces (tree, alias_set_type, tree, VEC (vn_reference_op_s, heap) *, - vn_reference_t *); -tree vn_reference_lookup (tree, VEC (tree, gc) *, bool, vn_reference_t *); -vn_reference_t vn_reference_insert (tree, tree, VEC (tree, gc) *); -vn_reference_t vn_reference_insert_pieces (VEC (tree, gc) *, + vn_reference_t *, vn_lookup_kind); +tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *); +vn_reference_t vn_reference_insert (tree, tree, tree); +vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, tree, VEC (vn_reference_op_s, heap) *, tree, unsigned int); hashval_t vn_nary_op_compute_hash (const vn_nary_op_t); int vn_nary_op_eq (const void *, const void *); +bool vn_nary_may_trap (vn_nary_op_t); hashval_t vn_reference_compute_hash (const vn_reference_t); int vn_reference_eq (const void *, const void *); unsigned int get_max_value_id (void); unsigned int get_next_value_id (void); +unsigned int get_constant_value_id (tree); unsigned int get_or_alloc_constant_value_id (tree); bool value_id_constant_p (unsigned int); -VEC (tree, gc) *shared_vuses_from_stmt (tree); -VEC (tree, gc) *copy_vuses_from_stmt (tree); +tree fully_constant_vn_reference_p (vn_reference_t); + +/* Valueize NAME if it is an SSA name, otherwise just return it. */ + +static inline tree +vn_valueize (tree name) +{ + if (TREE_CODE (name) == SSA_NAME) + { + tree tem = VN_INFO (name)->valnum; + return tem == VN_TOP ? name : tem; + } + return name; +} + #endif /* TREE_SSA_SCCVN_H */