00001
00002
00003 #ifndef _ACCESS_UTIL_H
00004 #define _ACCESS_UTIL_H
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "../AbstractAccess.h"
00018 #include "../SimEdgeKernel.h"
00019 #include "../SimBiGraph.h"
00020 #include "../SimGraphIterator.h"
00021 #include "../SimEdge.h"
00022 #include "../Program.h"
00023 #include "../IPAStats.h"
00024
00025 enum AR_MEET {
00026 AR_X,
00027 AR_Y,
00028 AR_OR,
00029 AR_AND,
00030 AR_X_NOTY,
00031 AR_NOTX_Y
00032 };
00033
00034 enum AR_CONSERVATIVE {
00035 UNDERESTIMATE,
00036 OVERESTIMATE
00037 };
00038
00039 enum AR_CERTAINTY {
00040 AR_YES,
00041 AR_NO,
00042 AR_UNSURE
00043 };
00044
00045 struct Dimcount {
00046 int dims;
00047 int count;
00048 Dimcount * next;
00049 };
00050
00051 struct Accreg_set {
00052 AbstractAccess * ar;
00053 int count;
00054 Accreg_set * next;
00055 };
00056
00057 struct AR_Stats {
00058 bool print;
00059 int total;
00060 int exact;
00061 int inexact;
00062 int proc_boundary;
00063 int both_same_dims;
00064 int caller_grtr_dims;
00065 int callee_grtr_dims;
00066 int callee_1;
00067 int caller_1;
00068 int subscr_subscr;
00069 int match_declared_dim;
00070 int less_declared_dim;
00071 int greater_declared_dim;
00072 int nonaffine;
00073 int triangular;
00074 int diagonal;
00075 int total_dims;
00076 int proven_monotonic;
00077 int proven_nonmonotonic;
00078 int monotonic_unknown;
00079 int minnest;
00080 int maxnest;
00081 int totalnest;
00082 Dimcount * base_dc;
00083 Dimcount * last_dc;
00084 int dc_count;
00085 Accreg_set * base_ars_uniq;
00086 Accreg_set * last_ars_uniq;
00087 int ars_uniq_count;
00088 Accreg_set * base_ars_uniq_dims;
00089 Accreg_set * last_ars_uniq_dims;
00090 int ars_uniq_dims_count;
00091 Accreg_set * base_ars_uniq_strd;
00092 Accreg_set * last_ars_uniq_strd;
00093 int ars_uniq_strd_count;
00094 Accreg_set * base_ars_uniq_dims_st;
00095 Accreg_set * last_ars_uniq_dims_st;
00096 int ars_uniq_dims_st_count;
00097 };
00098
00099 void print_access_region_statistics(ostream & o, const RefList<AbstractAccess> & list,
00100 Statement & stmt, Symbol & sym );
00101
00102 void print_access_region_statistics(ostream & o, const List<AbstractAccess> & list,
00103 Statement & stmt, Symbol & sym );
00104
00105 void init_ar_statistics( AR_Stats & stats );
00106
00107 void collect_ar_statistics (AbstractAccess & access_region,
00108 AR_Stats & stats, Symbol & sym );
00109
00110 void print_ar_stats_line( ostream & o, Statement & stmt, AR_Stats & stats );
00111
00112 bool
00113 intersect_ARDs (AbstractAccess & ard1, AbstractAccess & ard2,
00114 RangeAccessor & range_acc, SimEdge & edge,
00115 AR_CONSERVATIVE direction,
00116 List<AbstractAccess> & new_ard1,
00117 List<AbstractAccess> & new_ard2,
00118 List<AbstractAccess> & intersect,
00119 AR_MEET meet_op,
00120 IPAStats & istats);
00121
00122
00123 bool ar_intersect (List<AbstractAccess> & list1, AR_CONSERVATIVE direction,
00124 IPAStats & istats);
00125
00126 bool ar_intersect (List<AbstractAccess> & list1, int ard1, RefList<AbstractAccess> & discard1,
00127 List<AbstractAccess> & list2, int ard2,
00128 SimBiGraph & sbg, SimEdge & edge,
00129 IPAStats & istats);
00130
00131 bool ar_intersect (List<AbstractAccess> & list1, int ard1, RefList<AbstractAccess> & discard1,
00132 List<AbstractAccess> & list2, int ard2, RefList<AbstractAccess> & discard2,
00133 SimBiGraph & sg, SimEdge & edge,
00134 List<AbstractAccess> & intersect, AR_CONSERVATIVE direction,
00135 AR_MEET meet_op, IPAStats & istats);
00136
00137 void ar_intersect(List<AbstractAccess> & list1,
00138 List<AbstractAccess> & list2,
00139 AR_CONSERVATIVE direction,
00140 List<AbstractAccess> & result,
00141 IPAStats & istats);
00142
00143 void ar_subtract(List<AbstractAccess> & list1,
00144 List<AbstractAccess> & list2,
00145 AR_CONSERVATIVE direction,
00146 List<AbstractAccess> & result);
00147
00148 void ar_subtract(List<AbstractAccess> & list1,
00149 List<AbstractAccess> & list2,
00150 AR_CONSERVATIVE direction);
00151
00152 bool ar_plausible_execution(List<AbstractAccess> & list);
00153
00154
00155 bool ar_plausible_execution(AbstractAccess & aa);
00156
00157
00158 bool ar_subregion(AbstractAccess & ar1, AbstractAccess & ar2, SimEdge & edge,
00159 AR_CONSERVATIVE direction, Array<int> *match = 0);
00160
00161
00162 void ar_append(List<AbstractAccess> & list1, List<AbstractAccess> & list2,
00163 IPAStats & istats);
00164 void ar_append_new_pred(List<AbstractAccess> & list1, List<AbstractAccess> & list2,
00165 List<AbstractAccess> & lista, int indexa,
00166 List<AbstractAccess> & listb, int indexb,
00167 AR_MEET meet_op, PredicateRepository & repos, IPAStats & istats);
00168 void ar_append(List<AbstractAccess> & list1, AbstractAccess * ard);
00169
00170 AbstractAccess * compute_abstract_access(const Expression & expr, Statement * stmt,
00171 AR_TYPE artype );
00172
00173 SimilarityType contig_type (SimilarityType oldtype);
00174
00175 void check_access_patterns(Program & prog, ProgramUnit & pgm);
00176
00177 void simplify_descriptors( List<AbstractAccess> &, IPAStats & istats);
00178 void simplify_descriptors_scalar( List<AbstractAccess> &, IPAStats &);
00179
00180 SimTypeOfChange ar_aggregate(SimEdge & edge, SimGraph & sg, List<AbstractAccess> & list );
00181
00182 SimTypeOfChange contiguous_aggregation ( RangeAccessor * range_acc, AbstractAccess * edge1, AbstractAccess * edge2,
00183 int smaller_offset, int dim_less_index, int dim_grt_index );
00184
00185 RefList<AbstractAccess> * ar_interleave(SimGraphIterator & sgit, SimGraph & sg);
00186
00187 void add_to_chain(AbstractAccess *node1, AbstractAccess *node2,
00188 List<RefList<AbstractAccess> > & chain_list);
00189
00190 void
00191 calc_stride_span_match(AbstractAccess & aa1, AbstractAccess & aa2,
00192 RangeAccessor & range_acc,
00193 Array<int> & stride_match1, Array<int> & stride_match2,
00194 Array<bool> & span_match1, Array<bool> & span_match2);
00195
00196 Array<int> *
00197 invert_match(Array<int> * match_index, int new_dims);
00198
00199
00200
00201 bool
00202 ar_implies(AbstractAccess & aa1, AbstractAccess & aa2);
00203
00204 bool
00205 ar_offsets_match(AbstractAccess & descr1, AbstractAccess & descr2);
00206
00207 bool
00208 ar_predicates_equal(AbstractAccess & aa1, AbstractAccess & aa2);
00209
00210 bool
00211 ar_predicates_negation(AbstractAccess & aa1, AbstractAccess & aa2);
00212
00213 Expression *
00214 and_predicate(Expression * ex1, Expression * ex2, Expression * ex3=0);
00215
00216 Expression *
00217 or_predicate(Expression * ex1, Expression * ex2, Expression * ex3=0);
00218
00219 bool
00220 ar_subsume(Expression & implier, Expression & implied);
00221
00222 bool
00223 subsume_relation(const Expression & implier_subtree, const Expression & implied_subtree);
00224
00225 Expression *
00226 transform_not_equal(Expression * expr);
00227
00228 bool
00229 test_linkedness(const Expression & expr1, const Expression & expr2);
00230
00231 void
00232 elim_equivalent_descrs( List<AbstractAccess> & list, IPAStats & istats );
00233
00234 bool
00235 ar_descriptors_equal( AbstractAccess & ard1, AbstractAccess & ard2 );
00236
00237 bool
00238 ar_descriptor_member (List<AbstractAccess> & list, AbstractAccess & lmad);
00239
00240 int
00241 ar_effort_limit ( );
00242
00243 void
00244 ar_replace_with_approx(List<AbstractAccess> & list);
00245
00246 bool
00247 divides_diff (Expression & expr, Expression * diff,
00248 AbstractAccess & ard1, AbstractAccess & ard2,
00249 AR_CONSERVATIVE direction);
00250
00251 bool
00252 is_singleton(Symbol & index, Expression & expr);
00253
00254 #endif