Polaris: PropRangeWS.cc Source File

PropRangeWS.cc

Go to the documentation of this file.
00001 ///
00002 ///
00003 /// \file PropRangeWS.cc
00004 ///
00005 #include "../Collection/Iterator.h"
00006 #include "../utilities/equivalence_util.h"
00007 
00008 #include "PropRangeWS.h"
00009 
00010 /// Template instantiations
00011 
00012 template class TypedCollection<PropRangeEdge>;
00013 template class List<PropRangeEdge>;
00014 template ostream & operator << (ostream &, const List<PropRangeEdge> &);
00015 template class RefSet<PropRangeEdge>;
00016 template ostream & operator << (ostream &, const RefSet<PropRangeEdge> &);
00017 template class Assign<PropRangeEdge>;
00018 template class Iterator<PropRangeEdge>;
00019 
00020 void
00021 PropRangeWS::_add_to_mod_set(const RefSet<Expression> &refs)
00022 {
00023     Iterator<Expression> iter = refs;
00024 
00025     for ( ; iter.valid(); ++iter) {
00026     Symbol *symbol = iter.current().base_variable_ref();
00027 
00028     if (symbol && symbol->sym_class() == VARIABLE_CLASS)
00029         if (symbol->type().data_type() == INTEGER_TYPE)
00030         _mod_set.ins(*symbol);
00031 
00032     /// ...  Also place any aliased variables in the set.
00033     
00034     RefSet<Symbol> *aliases = equiv_aliases(*symbol);
00035     
00036     if (aliases) {
00037         Iterator<Symbol> alias_iter = *aliases;
00038         
00039         for ( ; alias_iter.valid(); ++alias_iter) {
00040         Symbol &alias_symbol = alias_iter.current();
00041         
00042         if (alias_symbol.type().data_type() == INTEGER_TYPE)
00043             _mod_set.ins(alias_symbol);
00044         }
00045         
00046         delete aliases;
00047     }
00048     }
00049 }
00050 
00051 PropRangeWS::PropRangeWS(unsigned long pass_tag, const Statement &stmt)
00052 : WorkSpace(pass_tag)
00053 {
00054     _add_to_mod_set(stmt.out_refs());
00055     /// ...  _add_to_mod_set(stmt.act_refs());
00056     _ranges = 0;
00057     _loop_variants = 0;
00058     _num_visits = 0;
00059     _visited = false;
00060     _toporder = -1;
00061     _needs_widening = false;
00062     _use_widener = false;
00063 }
00064 
00065 PropRangeWS::PropRangeWS(const PropRangeWS &other) : WorkSpace(other)
00066 {
00067     _mod_set = other._mod_set;
00068     _loop_variants = 0;
00069 
00070     if (other._loop_variants)
00071     _loop_variants = new RefSet<Symbol>(*other._loop_variants);
00072 
00073     _ranges = 0;
00074 
00075     if (other._ranges)
00076     _ranges = new StmtRanges(*other._ranges);
00077 
00078     _pred = other._pred;
00079     _succ = other._succ;
00080     _num_visits = other._num_visits;
00081     _visited = other._visited;
00082     _toporder = other._toporder;
00083     _needs_widening = other._needs_widening;
00084     _use_widener = other._use_widener;
00085 }
00086 
00087 PropRangeWS::~PropRangeWS()
00088 {
00089     loop_variants(0);
00090     ranges(0);
00091 }
00092 
00093 void
00094 PropRangeWS::loop_variants(RefSet<Symbol> *lv)
00095 {
00096     if (_loop_variants != lv) {
00097     if (_loop_variants)
00098         delete _loop_variants;
00099 
00100     _loop_variants = lv;
00101     }
00102 }
00103 
00104 void
00105 PropRangeWS::ranges(StmtRanges *c)
00106 {
00107     if (_ranges != c) {
00108     if (_ranges)
00109         delete _ranges;
00110 
00111     _ranges = c;
00112     }
00113 }
00114 
00115 static void
00116 _print_var_set(ostream &o, const RefSet<Symbol> &var_set)
00117 {
00118     Iterator<Symbol> var_iter = var_set;
00119 
00120     o << "{";
00121 
00122     if (var_iter.valid()) {
00123     o << var_iter.current().name_ref();
00124     ++var_iter;
00125     
00126     for ( ; var_iter.valid(); ++var_iter)
00127         o << ", " << var_iter.current().name_ref();
00128     }
00129 
00130     o << "}";
00131 }
00132     
00133 void
00134 PropRangeWS::print(ostream &o) const
00135 {
00136     o << "RangeWS:{";
00137     o << "mod=";
00138     _print_var_set(o, _mod_set);
00139     o << ", ";
00140     o << "loop_var=";
00141 
00142     if (_loop_variants)
00143     _print_var_set(o, *_loop_variants);
00144     else
00145     o << "NULL";
00146 
00147     o << ", ";
00148     o << "num_visits=" << _num_visits << ", ";
00149     o << "toporder=" << _toporder << ", ";
00150     o << "needs_widening=" << _needs_widening << ", ";
00151     o << "use_widener=" << _use_widener << ", ";
00152     o << "pred=" << _pred << ", ";
00153     o << "succ=" << _succ << ", ";
00154     o << "ranges=";
00155 
00156     if (_ranges)
00157     o << *_ranges;
00158     else
00159     o << "NULL";
00160 
00161     o << "}";
00162 }
00163 
00164 int
00165 PropRangeWS::structures_OK() const
00166 {
00167     if (! _mod_set.structures_OK())
00168     return 0;
00169 
00170     if (_loop_variants && ! _loop_variants->structures_OK())
00171     return 0;
00172 
00173     if (_ranges && ! _ranges->structures_OK())
00174     return 0;
00175 
00176     if (! _pred.structures_OK() || ! _succ.structures_OK())
00177     return 0;
00178 
00179     return 1;
00180 }
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:03 2005