comparison gcc/tree-affine.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Operations with affine combinations of trees. 1 /* Operations with affine combinations of trees.
2 Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it 6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
18 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
19 19
20 /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements 20 /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements
21 to make things simpler; this is sufficient in most cases. */ 21 to make things simpler; this is sufficient in most cases. */
22 22
23 #ifndef GCC_TREE_AFFINE_H
24 #define GCC_TREE_AFFINE_H
25
26
23 #define MAX_AFF_ELTS 8 27 #define MAX_AFF_ELTS 8
24 28
25 /* Element of an affine combination. */ 29 /* Element of an affine combination. */
26 30
27 struct aff_comb_elt 31 struct aff_comb_elt
28 { 32 {
29 /* The value of the element. */ 33 /* The value of the element. */
30 tree val; 34 tree val;
31 35
32 /* Its coefficient in the combination. */ 36 /* Its coefficient in the combination. */
33 double_int coef; 37 widest_int coef;
34 }; 38 };
35 39
36 typedef struct affine_tree_combination 40 struct aff_tree
37 { 41 {
38 /* Type of the result of the combination. */ 42 /* Type of the result of the combination. */
39 tree type; 43 tree type;
40 44
41 /* Constant offset. */ 45 /* Constant offset. */
42 double_int offset; 46 widest_int offset;
43 47
44 /* Number of elements of the combination. */ 48 /* Number of elements of the combination. */
45 unsigned n; 49 unsigned n;
46 50
47 /* Elements and their coefficients. Type of elements may be different from 51 /* Elements and their coefficients. Type of elements may be different from
54 58
55 /* Remainder of the expression. Usually NULL, used only if there are more 59 /* Remainder of the expression. Usually NULL, used only if there are more
56 than MAX_AFF_ELTS elements. Type of REST will be either sizetype for 60 than MAX_AFF_ELTS elements. Type of REST will be either sizetype for
57 TYPE of POINTER_TYPEs or TYPE. */ 61 TYPE of POINTER_TYPEs or TYPE. */
58 tree rest; 62 tree rest;
59 } aff_tree; 63 };
60 64
61 double_int double_int_ext_for_comb (double_int, aff_tree *); 65 struct name_expansion;
62 void aff_combination_const (aff_tree *, tree, double_int); 66
67 widest_int wide_int_ext_for_comb (const widest_int &, aff_tree *);
68 void aff_combination_const (aff_tree *, tree, const widest_int &);
63 void aff_combination_elt (aff_tree *, tree, tree); 69 void aff_combination_elt (aff_tree *, tree, tree);
64 void aff_combination_scale (aff_tree *, double_int); 70 void aff_combination_scale (aff_tree *, const widest_int &);
65 void aff_combination_mult (aff_tree *, aff_tree *, aff_tree *); 71 void aff_combination_mult (aff_tree *, aff_tree *, aff_tree *);
66 void aff_combination_add (aff_tree *, aff_tree *); 72 void aff_combination_add (aff_tree *, aff_tree *);
67 void aff_combination_add_elt (aff_tree *, tree, double_int); 73 void aff_combination_add_elt (aff_tree *, tree, const widest_int &);
68 void aff_combination_remove_elt (aff_tree *, unsigned); 74 void aff_combination_remove_elt (aff_tree *, unsigned);
69 void aff_combination_convert (aff_tree *, tree); 75 void aff_combination_convert (aff_tree *, tree);
70 void tree_to_aff_combination (tree, tree, aff_tree *); 76 void tree_to_aff_combination (tree, tree, aff_tree *);
71 tree aff_combination_to_tree (aff_tree *); 77 tree aff_combination_to_tree (aff_tree *);
72 void unshare_aff_combination (aff_tree *); 78 void unshare_aff_combination (aff_tree *);
73 bool aff_combination_constant_multiple_p (aff_tree *, aff_tree *, double_int *); 79 bool aff_combination_constant_multiple_p (aff_tree *, aff_tree *, widest_int *);
74 void aff_combination_expand (aff_tree *, struct pointer_map_t **); 80 void aff_combination_expand (aff_tree *, hash_map<tree, name_expansion *> **);
75 void tree_to_aff_combination_expand (tree, tree, aff_tree *, 81 void tree_to_aff_combination_expand (tree, tree, aff_tree *,
76 struct pointer_map_t **); 82 hash_map<tree, name_expansion *> **);
77 void get_inner_reference_aff (tree, aff_tree *, double_int *); 83 tree get_inner_reference_aff (tree, aff_tree *, widest_int *);
78 void free_affine_expand_cache (struct pointer_map_t **); 84 void free_affine_expand_cache (hash_map<tree, name_expansion *> **);
85 bool aff_comb_cannot_overlap_p (aff_tree *, const widest_int &,
86 const widest_int &);
79 87
80 /* Debugging functions. */ 88 /* Debugging functions. */
81 void print_aff (FILE *, aff_tree *);
82 void debug_aff (aff_tree *); 89 void debug_aff (aff_tree *);
90
91 /* Return AFF's type. */
92 inline tree
93 aff_combination_type (aff_tree *aff)
94 {
95 return aff->type;
96 }
97
98 /* Return true if AFF is actually ZERO. */
99 inline bool
100 aff_combination_zero_p (aff_tree *aff)
101 {
102 if (!aff)
103 return true;
104
105 if (aff->n == 0 && aff->offset == 0)
106 return true;
107
108 return false;
109 }
110
111 /* Return true if AFF is actually const. */
112 inline bool
113 aff_combination_const_p (aff_tree *aff)
114 {
115 return (aff == NULL || aff->n == 0);
116 }
117
118 /* Return true iff AFF contains one (negated) singleton variable. Users need
119 to make sure AFF points to a valid combination. */
120 inline bool
121 aff_combination_singleton_var_p (aff_tree *aff)
122 {
123 return (aff->n == 1
124 && aff->offset == 0
125 && (aff->elts[0].coef == 1 || aff->elts[0].coef == -1));
126 }
127 #endif /* GCC_TREE_AFFINE_H */