00001 #ifndef _ABSTRACTACCESS_H
00002 #define _ABSTRACTACCESS_H
00003
00004 #ifdef POLARIS_GNU_PRAGMAS
00005 #pragma interface
00006 #endif
00007
00008 #include <fstream.h>
00009 #include "ClassNames.h"
00010
00011 extern int _ipa;
00012
00013 extern int _ipa_reasons;
00014
00015 extern int _ar_coalesce;
00016
00017 extern int _ar_aggregate;
00018
00019 extern int _ar_interleave;
00020
00021 extern int _ar_match_dims;
00022
00023 extern int _ar_logging;
00024
00025 extern ofstream arlog;
00026
00027 extern int _ar_leave_descr;
00028
00029 extern int _ar_prtstats;
00030
00031 extern int _ar_approx_thresh;
00032
00033
00034 extern int _ar_effort;
00035
00036
00037 extern int _ar_reshape;
00038 extern ofstream stats_out;
00039
00040
00041
00042 enum AR_MONOTON {
00043 AR_PROVEN_NON_MONO,
00044 AR_PROVEN_MONO,
00045 AR_MONO_UNSURE,
00046 AR_UNKNOWN_MONO
00047 };
00048
00049 enum AR_TYPE {
00050 AR_UNKNOWN,
00051 AR_READ,
00052 AR_WRITE,
00053 AR_READWRITE
00054 };
00055
00056 enum RED_OP {
00057 RED_OP_NONE,
00058 RED_OP_PLUS,
00059 RED_OP_MUL,
00060 RED_OP_MIN,
00061 RED_OP_MAX
00062 };
00063
00064 class ProgramUnit;
00065 class Statement;
00066 class Symbol;
00067
00068 class RangeAccessor;
00069 class UGraphIterator;
00070
00071 #include "Collection/RefList.h"
00072 #include "AccessDimension.h"
00073 #include "Expression/Expression.h"
00074
00075 class AbstractAccess : public Listable {
00076
00077 friend class SimGraph;
00078 friend class SimBiGraph;
00079
00080 protected:
00081 Symbol * _symbol;
00082
00083 List<AccessDimension> _dims;
00084
00085 Expression * _start;
00086
00087 Expression * _correctness;
00088 int _exec_pred;
00089
00090 ACCURACY _accuracy;
00091
00092 Expression * _actual;
00093 Statement * _actual_stmt;
00094
00095 bool _read_only, _write_first, _imprecise_sorting, _possible_reduction, _possible_induction, _approximate;
00096
00097 Statement * _summarized_to;
00098
00099 ProgramUnit * _pgm_summarized_to;
00100
00101 int _diagonal:1,_triangular:1,_subsub:1,_nonaffine:1,_monoton:4,_access_type:3,
00102 _visited:1,_no_overlap:3,_bytesize:6,_reduct_op:4;
00103
00104 int _nesting_level;
00105
00106
00107
00108
00109 public:
00110 AbstractAccess( );
00111 AbstractAccess( const Symbol & sym, const List<AccessDimension> & dims, Expression * start );
00112 AbstractAccess( const Symbol & sym, const List<AccessDimension> & dims, Expression * start, ACCURACY accu, AR_TYPE artype );
00113 AbstractAccess( const Symbol & sym, const List<AccessDimension> & dims, Expression * start, AbstractAccess * model_aa );
00114 AbstractAccess( const AbstractAccess & other );
00115
00116 ~AbstractAccess( );
00117
00118 Symbol & symbol( ) const;
00119 virtual Listable *listable_clone() const;
00120
00121 virtual AbstractAccess *clone() const;
00122
00123 void relink_eptrs( ProgramUnit & p );
00124
00125 int byte_size( );
00126 void byte_size(int bytes);
00127
00128 void convert_size(int new_size);
00129
00130
00131
00132
00133
00134
00135
00136 int sort_add_dim(AccessDimension * newdim, RangeAccessor & range_acc);
00137
00138 bool coalesce();
00139 bool try_coalescing(RangeAccessor & range_acc, AccessDimension & dim_lo, int lodim,
00140 AccessDimension & dim_hi, int hidim, UGraphIterator & ugi);
00141
00142
00143 Expression * correctness( );
00144 void correctness(Expression * e );
00145 bool exec_predicate_exists( ) const;
00146 bool exec_predicate_true( ) const;
00147 bool exec_predicate_false( ) const;
00148 int exec_predicate( );
00149 void exec_predicate( int pred );
00150
00151 void accuracy( ACCURACY accu );
00152 ACCURACY accuracy ( ) const;
00153
00154 void add_actual ( Statement *stmt, Expression * expr );
00155 Expression & actual_guarded ( ) const;
00156 void remove_actual ( );
00157 Boolean actual_exists ( ) const;
00158 Statement * actual_stmt() const;
00159 int number_of_dimensions( ) const;
00160
00161 void check_sort( );
00162
00163 void add_dimension( const AccessDimension * dim );
00164 void add_dimension( const AccessDimension * dim, int which_dim );
00165
00166
00167 void del_dimension( int which_dim );
00168
00169
00170 int nesting_level();
00171 void nesting_level( int level );
00172 void inc_nesting( );
00173
00174
00175
00176
00177
00178
00179
00180 int compute_new_dimension( ProgramUnit & pgm, Statement & stmt,
00181 Symbol & index,
00182 Expression & lo, Expression & hi, Expression & by);
00183
00184
00185
00186 AccessDimension & dimension( int i );
00187
00188 Iterator<AccessDimension> iter_dims( );
00189
00190 Boolean start_exists( ) const;
00191 void start( Expression * start );
00192 Expression & start_guarded( ) const;
00193
00194 Expression * lastoffset( ) const;
00195
00196 Statement * summarized_to();
00197 void summarized_to( Statement * stmt );
00198
00199 ProgramUnit * pgm_summarized_to();
00200 void pgm_summarized_to( ProgramUnit * stmt );
00201
00202 void check_access_patterns( );
00203
00204
00205 void mark_visited( );
00206 bool was_visited( );
00207
00208 void mark_imprecise( );
00209 void mark_precise( );
00210 bool is_imprecise( );
00211
00212 void mark_diagonal( );
00213 void mark_not_diagonal( );
00214 bool is_diagonal( );
00215
00216 void mark_triangular( );
00217 void mark_not_triangular( );
00218 bool is_triangular( );
00219
00220 void mark_subsub( );
00221 bool is_subsub( );
00222
00223 void mark_nonaffine( );
00224 bool is_nonaffine( );
00225
00226 void monoton( AR_MONOTON mono );
00227 AR_MONOTON monoton( );
00228
00229 void reduct_op( RED_OP op );
00230 RED_OP reduct_op( );
00231
00232 AbstractAccess * remap_interface_vars(InlineObject * inline_object,
00233 Statement & stmt,
00234 const Symbol & sym,
00235 REF_TYPE ref,
00236 int exec_pred=-1) const;
00237
00238 bool read_only();
00239 bool write_first();
00240 bool approximate();
00241 void set_approximate();
00242
00243 int no_overlap();
00244
00245 bool poss_reduct();
00246 bool poss_induct();
00247
00248 void read_only (bool val);
00249 void write_first(bool val);
00250 void no_overlap (bool val);
00251 void no_overlap (int val);
00252 void poss_reduct(bool val);
00253 void poss_induct(bool val);
00254
00255 void set_check_overlap( int which_dim, bool value );
00256 void calc_overlap (int which_dim);
00257
00258 void translate_GSA_symbols( TranslateObject * tobj );
00259
00260
00261
00262
00263
00264
00265 bool match( AbstractAccess * aa );
00266 bool match_by_dims( AbstractAccess * aa );
00267 int match_dims( AbstractAccess * aa );
00268 int match_dims_stride( AbstractAccess * aa );
00269 bool match_by_strides( AbstractAccess * aa );
00270 bool match_by_dims_except_1( AbstractAccess * aa );
00271 bool match_by_start_dims_except_1( AbstractAccess * aa );
00272
00273
00274 virtual void print(ostream & o) const;
00275
00276 friend ostream & operator << (ostream & o, const AbstractAccess & aa);
00277 };
00278
00279 inline Expression *
00280 AbstractAccess::correctness( )
00281 {
00282 return _correctness;
00283 }
00284
00285 inline void
00286 AbstractAccess::mark_imprecise( )
00287 {
00288 _imprecise_sorting = true;
00289 }
00290 inline void
00291 AbstractAccess::mark_precise( )
00292 {
00293 _imprecise_sorting = false;
00294 }
00295 inline bool
00296 AbstractAccess::is_imprecise( )
00297 {
00298 return _imprecise_sorting;
00299 }
00300
00301 inline void
00302 AbstractAccess::mark_subsub( )
00303 {
00304 _subsub = 1;
00305 }
00306
00307 inline bool
00308 AbstractAccess::is_subsub( )
00309 {
00310 if (_subsub) {
00311 return true;
00312 } else {
00313 return false;
00314 }
00315 }
00316 inline void
00317 AbstractAccess::mark_nonaffine( )
00318 {
00319 _nonaffine = 1;
00320 }
00321
00322 inline bool
00323 AbstractAccess::is_nonaffine( )
00324 {
00325 if (_nonaffine) {
00326 return true;
00327 } else {
00328 return false;
00329 }
00330 }
00331 inline void
00332 AbstractAccess::mark_triangular( )
00333 {
00334 _triangular = 1;
00335 }
00336
00337 inline void
00338 AbstractAccess::mark_not_triangular( )
00339 {
00340 _triangular = 0;
00341 }
00342
00343 inline bool
00344 AbstractAccess::is_triangular( )
00345 {
00346 if (_triangular) {
00347 return true;
00348 } else {
00349 return false;
00350 }
00351 }
00352
00353 inline void
00354 AbstractAccess::mark_visited( )
00355 {
00356 _visited = 1;
00357 }
00358
00359 inline bool
00360 AbstractAccess::was_visited( )
00361 {
00362 if (_visited) {
00363 return true;
00364 } else {
00365 return false;
00366 }
00367 }
00368
00369 inline void
00370 AbstractAccess::mark_diagonal( )
00371 {
00372 _diagonal = 1;
00373 }
00374
00375 inline void
00376 AbstractAccess::mark_not_diagonal( )
00377 {
00378 _diagonal = 0;
00379 }
00380
00381 inline bool
00382 AbstractAccess::is_diagonal( )
00383 {
00384 if (_diagonal) {
00385 return true;
00386 } else {
00387 return false;
00388 }
00389 }
00390
00391 inline void
00392 AbstractAccess::monoton( AR_MONOTON mono )
00393 {
00394 _monoton = mono;
00395 }
00396
00397 inline AR_MONOTON
00398 AbstractAccess::monoton( )
00399 {
00400 return (AR_MONOTON) _monoton;
00401 }
00402
00403 inline bool
00404 AbstractAccess:: read_only()
00405 {
00406 return (_read_only == 1);
00407 }
00408
00409 inline void
00410 AbstractAccess:: set_approximate()
00411 {
00412 _approximate = true;
00413 }
00414
00415 inline bool
00416 AbstractAccess:: approximate()
00417 {
00418 return _approximate;
00419 }
00420
00421 inline bool
00422 AbstractAccess:: write_first()
00423 {
00424 return (_write_first == 1);
00425 }
00426
00427 inline int
00428 AbstractAccess:: no_overlap()
00429 {
00430 return _no_overlap;
00431 }
00432
00433 inline void
00434 AbstractAccess:: read_only(bool val)
00435 {
00436 _read_only = val;
00437 }
00438
00439 inline void
00440 AbstractAccess:: write_first(bool val)
00441 {
00442 _write_first = val;
00443 }
00444
00445 inline void
00446 AbstractAccess:: no_overlap(bool val)
00447 {
00448 if (val) {
00449 _no_overlap = 1;
00450 } else {
00451 _no_overlap = 0;
00452 }
00453 }
00454
00455 inline void
00456 AbstractAccess:: no_overlap(int val)
00457 {
00458 _no_overlap = val;
00459 }
00460
00461
00462 #endif