Polaris: BaseStmtRanges Class Reference

BaseStmtRanges Class Reference

Abstract collection of ranges for a single statement. More...

#include <BaseStmtRanges.h>

Inheritance diagram for BaseStmtRanges:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 BaseStmtRanges (const Symtab &symtab)
 BaseStmtRanges.
 BaseStmtRanges (const BaseStmtRanges &other)
virtual ~BaseStmtRanges ()
 ~BaseStmtRanges
void extract_ranges (const Expression &expr, bool complement_expr=false)
 Extract all possible ranges from the given logical expression and intersect these ranges with the current constraints.
void subst_in_ranges (const Symbol &var, const Expression *subst_expr)
 Replace all uses of variable var in all of the ranges in myself with the given substitution expression.
void union_ranges (BaseStmtRanges &other)
 Union all ranges in the other range dictionary with myself.
void widen_ranges (BaseStmtRanges &other)
 Widen all ranges in the other range dictionary with myself.
void widen_some_ranges (BaseStmtRanges &other, const RefSet< Symbol > &vars_to_widen)
 Widen the ranges of the given vars in the other range dictionary with myself.
void narrow_ranges (BaseStmtRanges &other)
 Narrow all ranges in the other constraint dictionary with myself.
virtual int operator== (const BaseStmtRanges &other) const
 operator ==
virtual int operator!= (const BaseStmtRanges &other) const
 Value comparisons of stmt range dictionaries.
void widen_range (const Symbol &var, const Expression &range)
 Widen the range of the given variable access with the given range.
void narrow_range (const Symbol &var, const Expression &range)
 Narrow the range of the given variable access with the given range.
BaseStmtRangesoperator= (const BaseStmtRanges &other)
 Completely copy the contents of the other constraint dictionary into myself.
const Expressionget_range_ref (const Symbol &var)
 Return the range associated with the given variable.
virtual int entries () const =0
 Return the number of constrained variable entries in myself.
virtual void clear ()=0
 Discard all constraints within myself.
virtual RefSet< Symbol > * range_vars () const =0
 Return the set of variables that have ranges.
virtual void print (ostream &out) const
 Print out the constraint dictionary.
void pretty_print (ostream &out) const
 Print out the constraint dictionary in a more user-readable manner.
virtual int structures_OK () const
 Methods required by Listable.

Protected Member Functions

virtual const Expression_get_range_ref_c (const Symbol &var) const =0
 Like get_range_ref(), but is a const method.

Detailed Description

Abstract collection of ranges for a single statement.

Polaris Range

See also:
BaseStmtRanges.h

BaseStmtRanges.h

BaseStmtRanges.cc

Overview

A BaseStmtRanges object is a collection of ranges for each program variable for a single statement. This class is abstract in that it doesn't actually describe how these ranges are stored.

Description

This object holds all the ranges of a single statement. However, the data structures that hold these ranges are not provided. The user must create a subclass that holds these ranges as well as provide the interfaces to these data structures, (i.e, get_range_ref(), etc.).

Several methods have been provided to aid the computation of ranges in a ProgramUnit. The method extract_ranges() will extract all the ranges that can be determined from a logical expression and intersect (AND) these ranges with the ranges in the BaseStmtRanges. The method union_constriants() unions (ORs) the ranges of two BaseStmtRangess. The method subst_in_ranges() can be used to replace all accesses of a certain variable in all ranges with some other value. This method is useful for handling variable modifications by statements. Finally, a set of low level methods are provided for accessing and modifying individual ranges in a BaseStmtRanges.

Definition at line 50 of file BaseStmtRanges.h.


Constructor & Destructor Documentation

BaseStmtRanges::BaseStmtRanges const Symtab symtab  ) 
 

BaseStmtRanges.

... nothing to do

Definition at line 23 of file BaseStmtRanges.cc.

BaseStmtRanges::BaseStmtRanges const BaseStmtRanges other  ) 
 

... Nothing to do.

Definition at line 29 of file BaseStmtRanges.cc.

BaseStmtRanges::~BaseStmtRanges  )  [virtual]
 

~BaseStmtRanges

... nothing to do

Definition at line 38 of file BaseStmtRanges.cc.


Member Function Documentation

void BaseStmtRanges::extract_ranges const Expression expr,
bool  complement_expr = false
 

Extract all possible ranges from the given logical expression and intersect these ranges with the current constraints.

The given expression must be a logical expression (i.e. made up of relation and .AND., .OR., and .NOT. operators) or it will be ignored. If complement_expr is true, this method will extract the ranges from the complement of this expression.

Referenced by _update_do_succs(), and _update_if_succs().

void BaseStmtRanges::subst_in_ranges const Symbol var,
const Expression subst_expr
 

Replace all uses of variable var in all of the ranges in myself with the given substitution expression.

If subst_expr is NULL, the variable references are instead replaced by an unconstrained range. ([-Inf:Inf])

Reimplemented from RangeComparator.

Definition at line 141 of file BaseStmtRanges.cc.

References _get_range_ref_c(), Expression::clone(), Iterator< T >::current(), is_var_in_expr(), range_vars(), RangeComparator::set_range(), RangeComparator::subst_var_and_simplify(), and Iterator< T >::valid().

Referenced by _update_succ_edges().

void BaseStmtRanges::union_ranges BaseStmtRanges other  ) 
 

Union all ranges in the other range dictionary with myself.

Definition at line 48 of file BaseStmtRanges.cc.

References Iterator< T >::current(), RangeComparator::del_range(), range_vars(), RangeComparator::union_range(), and Iterator< T >::valid().

Referenced by _calc_loop_range(), and _iterate_to_fixed_point_phase().

void BaseStmtRanges::widen_ranges BaseStmtRanges other  ) 
 

Widen all ranges in the other range dictionary with myself.

Definition at line 88 of file BaseStmtRanges.cc.

References range_vars(), and widen_some_ranges().

Referenced by _iterate_to_fixed_point_phase().

void BaseStmtRanges::widen_some_ranges BaseStmtRanges other,
const RefSet< Symbol > &  vars_to_widen
 

Widen the ranges of the given vars in the other range dictionary with myself.

Definition at line 69 of file BaseStmtRanges.cc.

References Iterator< T >::current(), RangeComparator::del_range(), Iterator< T >::valid(), and widen_range().

Referenced by _iterate_to_fixed_point_phase(), and widen_ranges().

void BaseStmtRanges::narrow_ranges BaseStmtRanges other  ) 
 

Narrow all ranges in the other constraint dictionary with myself.

Definition at line 99 of file BaseStmtRanges.cc.

References Iterator< T >::current(), narrow_range(), range_vars(), and Iterator< T >::valid().

Referenced by _iterate_to_fixed_point_phase().

int BaseStmtRanges::operator== const BaseStmtRanges other  )  const [virtual]
 

operator ==

Definition at line 254 of file BaseStmtRanges.cc.

References _get_range_ref_c(), Expression::compare(), Iterator< T >::current(), entries(), range_vars(), and Iterator< T >::valid().

int BaseStmtRanges::operator!= const BaseStmtRanges other  )  const [virtual]
 

Value comparisons of stmt range dictionaries.

Definition at line 281 of file BaseStmtRanges.cc.

void BaseStmtRanges::widen_range const Symbol var,
const Expression range
 

Widen the range of the given variable access with the given range.

Definition at line 168 of file BaseStmtRanges.cc.

References _get_range_ref_c(), OMEGA_OP, Expression::op(), and RangeComparator::set_range().

Referenced by widen_some_ranges().

void BaseStmtRanges::narrow_range const Symbol var,
const Expression range
 

Narrow the range of the given variable access with the given range.

Definition at line 198 of file BaseStmtRanges.cc.

References _get_range_ref_c(), and RangeComparator::set_range().

Referenced by narrow_ranges().

BaseStmtRanges & BaseStmtRanges::operator= const BaseStmtRanges other  ) 
 

Completely copy the contents of the other constraint dictionary into myself.

Definition at line 242 of file BaseStmtRanges.cc.

References RangeComparator::operator=().

Referenced by StmtRefRanges::operator=(), and StmtRanges::operator=().

const Expression * BaseStmtRanges::get_range_ref const Symbol var  )  [virtual]
 

Return the range associated with the given variable.

If the variable doesn't have an associated range, return 0;

Implements RangeComparator.

Definition at line 233 of file BaseStmtRanges.cc.

References _get_range_ref_c().

Referenced by AIRangeDict::_get_range_ref(), and _update_succ_edges().

virtual int BaseStmtRanges::entries  )  const [pure virtual]
 

Return the number of constrained variable entries in myself.

Implemented in StmtRanges, and StmtRefRanges.

Referenced by operator==().

virtual void BaseStmtRanges::clear  )  [pure virtual]
 

Discard all constraints within myself.

Implemented in StmtRanges, and StmtRefRanges.

virtual RefSet<Symbol>* BaseStmtRanges::range_vars  )  const [pure virtual]
 

Return the set of variables that have ranges.

Implemented in StmtRanges, and StmtRefRanges.

Referenced by narrow_ranges(), operator==(), pretty_print(), print(), subst_in_ranges(), union_ranges(), and widen_ranges().

void BaseStmtRanges::print ostream &  out  )  const [virtual]
 

Print out the constraint dictionary.

Reimplemented from RangeComparator.

Definition at line 290 of file BaseStmtRanges.cc.

References _get_range_ref_c(), Iterator< T >::current(), Symbol::name_ref(), RangeComparator::print(), range_vars(), and Iterator< T >::valid().

void BaseStmtRanges::pretty_print ostream &  out  )  const
 

Print out the constraint dictionary in a more user-readable manner.

Definition at line 320 of file BaseStmtRanges.cc.

References _get_range_ref_c(), Iterator< T >::current(), RefList< T >::ins_last(), pretty_print_range(), range_vars(), sort_sym_list(), and Iterator< T >::valid().

Referenced by _iterate_to_fixed_point_phase(), and AIRangeDict::pretty_print().

int BaseStmtRanges::structures_OK  )  const [virtual]
 

Methods required by Listable.

Reimplemented from RangeComparator.

Reimplemented in StmtRanges, and StmtRefRanges.

Definition at line 354 of file BaseStmtRanges.cc.

References RangeComparator::structures_OK().

virtual const Expression* BaseStmtRanges::_get_range_ref_c const Symbol var  )  const [protected, pure virtual]
 

Like get_range_ref(), but is a const method.

Referenced by get_range_ref(), narrow_range(), operator==(), pretty_print(), print(), subst_in_ranges(), and widen_range().


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:02 2005