C-Breeze
C Compiler Infrastructure

[ Project home page]
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Location Class Reference

#include <location.h>

Inheritance diagram for Location:

PerClassHeap< PointersHeap > basicblockLocation Path procLocation stmtLocation List of all members.

Public Types

enum  LocationKind { Statement, BasicBlock, Procedure }
 Kind of location. More...


Public Member Functions

 Location (Location *parent, LocationKind kind)
 Create a new location.

void visit ()
 Visit.

void finish ()
 Finish.

virtual void adjust_depth ()=0
 Adjust depths.

virtual void print (ostream &o) const=0
virtual void print_path (ostream &o) const=0
virtual ~Location ()
Location * parent () const
LocationKind kind () const
unsigned int subtree_id () const
Location * dominator () const
void set_dominator (Location *d)
void clear_dominator ()
int num_children () const
void increment_children ()
void decrement_children ()
unsigned int tree_min () const
void set_tree_min (unsigned int m)
unsigned int tree_max () const
void set_tree_max (unsigned int m)

Static Public Member Functions

bool dominates (const Location *dom, const Location *cur)
 Interprocedure dominance test.

bool strictly_dominates (const Location *dom, const Location *cur)
 Interprocedure strict dominance test.

procLocationprocedure (Location *where)
 Find the enclosing procedure.

bool is_prefix (const Location *prefix, const Location *longer)
 See if one location is a prefix of the other.

void stats ()

Static Public Attributes

unsigned int stmt_count = 0
unsigned int block_count = 0
unsigned int proc_count = 0
unsigned int dom_calls = 0

Static Protected Member Functions

unsigned int next_tree_number ()
 Get the next tree number.


Protected Attributes

Location * _parent
 Parent.

unsigned int _kind:2
 The kind of location.

unsigned int _subtree_id:16
 Subtree ID.

unsigned int _num_children:8
 Number of dominator children.

Location * _dominator
 Immediate dominator.

unsigned int _tree_min
unsigned int _tree_max

Static Protected Attributes

unsigned int current_subtree_id = 0
 Global subtree ID counter.

unsigned int current_tree_number = 0
 The current tree number to assign.


Private Member Functions

Location & operator= (const Location &other)

Friends

ostream & operator<< (ostream &o, const Location &loc)

Member Enumeration Documentation

enum Location::LocationKind
 

Kind of location.

Enumeration values:
Statement 
BasicBlock 
Procedure 

Definition at line 93 of file location.h.


Constructor & Destructor Documentation

Location::Location Location *    parent,
LocationKind    kind
 

Create a new location.

Store the given parent and kind information. Initialize all of the flags and numberings.

Definition at line 54 of file location.cc.

References _subtree_id, BasicBlock, kind(), Procedure, and subtree_id().

Location::~Location   [virtual]
 

Definition at line 449 of file location.cc.


Member Function Documentation

virtual void Location::adjust_depth   [pure virtual]
 

Adjust depths.

These methods are needed to fix the depths of all Location nodes during a context-insensitive reparenting.

Implemented in stmtLocation, basicblockLocation, and procLocation.

void Location::clear_dominator  
 

Definition at line 87 of file location.cc.

References _dominator, and decrement_children().

Referenced by stmtLocation::remove_call(), and stmtLocation::setup_cs_call().

void Location::decrement_children   [inline]
 

Definition at line 251 of file location.h.

References _num_children.

Referenced by clear_dominator(), and finish().

bool Location::dominates const Location *    dom,
const Location *    cur
[static]
 

Interprocedure dominance test.

Definition at line 441 of file location.cc.

References strictly_dominates().

Location* Location::dominator   const [inline]
 

Definition at line 245 of file location.h.

Referenced by finish(), stmtLocation::remove_call(), and stmtLocation::setup_cs_call().

void Location::finish  
 

Finish.

Assign the post-order "tree max" (up the tree) number for a location. We call this method only when we find a location that doesn't dominate anything, and is therefore a leaf in the dominator tree. We move up the tree assigning tree max values until we find a sibling that has not been numbered yet. This siutation is indicated by a parent with num_children != 0.

Definition at line 474 of file location.cc.

References decrement_children(), dominator(), next_tree_number(), num_children(), set_tree_max(), tree_max(), and tree_min().

Referenced by Pointers::analyze_procedure().

void Location::increment_children   [inline]
 

Definition at line 250 of file location.h.

References _num_children.

Referenced by set_dominator().

bool Location::is_prefix const Location *    prefix,
const Location *    longer
[static]
 

See if one location is a prefix of the other.

Definition at line 413 of file location.cc.

References parent().

Referenced by Pointers::record_external_inputs_and_outputs().

LocationKind Location::kind   const [inline]
 

Definition at line 234 of file location.h.

References _kind.

Referenced by Pointers::assignment_operator(), memoryModel::create_memory_object(), memoryBlock::def_at(), orderedUses::find_uses_at(), livenessAnalyzer::isLive(), Location(), procedure(), Pointers::self_assignment(), and Pointers::star_operator().

unsigned int Location::next_tree_number   [inline, static, protected]
 

Get the next tree number.

Increment the global counter and return it.

Definition at line 216 of file location.h.

Referenced by finish(), procLocation::procLocation(), and visit().

int Location::num_children   const [inline]
 

Definition at line 249 of file location.h.

References _num_children.

Referenced by finish().

Location& Location::operator= const Location &    other [inline, private]
 

Definition at line 107 of file location.h.

Location* Location::parent   const [inline]
 

Fields

Reimplemented in Path.

Definition at line 233 of file location.h.

Referenced by is_prefix().

virtual void Location::print ostream &    o const [pure virtual]
 

Implemented in stmtLocation, basicblockLocation, and procLocation.

Referenced by Path::print_shallow().

virtual void Location::print_path ostream &    o const [pure virtual]
 

Implemented in stmtLocation, basicblockLocation, and procLocation.

procLocation * Location::procedure Location *    where [static]
 

Find the enclosing procedure.

Definition at line 395 of file location.cc.

References BasicBlock, stmtLocation::block_location(), kind(), basicblockLocation::proc_location(), Procedure, and Statement.

Referenced by Pointers::compute_accuracy(), memoryModel::create_memory_object(), Pointers::determine_call_targets(), Pointers::eval(), memoryModel::lookup(), and memoryBlock::name().

void Location::set_dominator Location *    d
 

Definition at line 76 of file location.cc.

References _dominator, and increment_children().

Referenced by basicblockLocation::basicblockLocation(), procLocation::procLocation(), stmtLocation::remove_call(), and stmtLocation::setup_cs_call().

void Location::set_tree_max unsigned int    m [inline]
 

Definition at line 257 of file location.h.

Referenced by finish().

void Location::set_tree_min unsigned int    m [inline]
 

Definition at line 254 of file location.h.

Referenced by procLocation::procLocation(), stmtLocation::setup_cs_call(), and visit().

void Location::stats   [static]
 

Definition at line 424 of file location.cc.

References block_count, proc_count, and stmt_count.

Referenced by pointers_phase::run().

bool Location::strictly_dominates const Location *    dom,
const Location *    cur
[static]
 

Interprocedure strict dominance test.

Definition at line 101 of file location.cc.

References dom_calls, subtree_id(), tree_max(), and tree_min().

Referenced by dominates(), PathDB::intern(), memoryBlock::setup_merge_uses_at(), and PathDB::strictly_dominates().

unsigned int Location::subtree_id   const [inline]
 

Definition at line 243 of file location.h.

References _subtree_id.

Referenced by procLocation::adjust_depth(), basicblockLocation::adjust_depth(), stmtLocation::adjust_depth(), orderedDefs::find_dominating_def(), orderedDefs::find_strictly_dominating_def(), Location(), orderedDefs::make_def_at(), and strictly_dominates().

unsigned int Location::tree_max   const [inline]
 

Definition at line 256 of file location.h.

Referenced by orderedDefs::find_dominating_def(), orderedDefs::find_strictly_dominating_def(), finish(), orderedDefs::make_def_at(), and strictly_dominates().

unsigned int Location::tree_min   const [inline]
 

Definition at line 253 of file location.h.

Referenced by orderedDefs::find_dominating_def(), orderedDefs::find_strictly_dominating_def(), finish(), orderedDefs::make_def_at(), strictly_dominates(), and visit().

void Location::visit  
 

Visit.

Assign the pre-order "tree min" (down the tree) number for a location. We call this method as we encounter each location during analysis.

Definition at line 457 of file location.cc.

References next_tree_number(), set_tree_min(), and tree_min().

Referenced by Pointers::analyze_procedure(), Pointers::analyze_procedure_at(), stmtLocation::remove_call(), and stmtLocation::setup_cs_call().


Friends And Related Function Documentation

ostream& operator<< ostream &    o,
const Location &    loc
[friend]
 

Definition at line 321 of file location.h.


Member Data Documentation

Location* Location::_dominator [protected]
 

Immediate dominator.

This points to the immediate dominator of this node. It is set up during the construction of the location tree. It embodies the dominance rules discussed above.

Definition at line 178 of file location.h.

Referenced by clear_dominator(), and set_dominator().

unsigned int Location::_kind [protected]
 

The kind of location.

There are only three kinds, so we only need two bits.

Definition at line 129 of file location.h.

Referenced by kind().

unsigned int Location::_num_children [protected]
 

Number of dominator children.

This is the number of locations immediately dominated by this one. We use this number to control the depth-first tree numbering algorithm. When the number is greater than one, we know that we still have dominator subtrees to number. Each time we finish a subtree, we decrement this number on the immediate dominator. When it reaches zero, the whole subtree is numbered.

We limit this field to 8 bits, which only allows a node to immediately dominate 256 other nodes. This is probably way higher than it needs to be, but we'll play it safe.

Definition at line 170 of file location.h.

Referenced by decrement_children(), increment_children(), and num_children().

Location* Location::_parent [protected]
 

Parent.

A pointer to the containing location (strictly in terms of program structure). For stmtLocations, this points to the containing basic block. For basicblockLocations, it points to the procLocation. For procLocations, it points to the callsite stmtLocation (if there is one).

Reimplemented in Path.

Definition at line 123 of file location.h.

Referenced by procLocation::adjust_depth(), basicblockLocation::adjust_depth(), stmtLocation::adjust_depth(), stmtLocation::block_location(), procLocation::parent_proc(), basicblockLocation::proc_location(), procLocation::remove_from_tree(), and procLocation::stmt_location().

unsigned int Location::_subtree_id [protected]
 

Subtree ID.

This number is used for context-insensitive analysis to quickly determine whether two locations can have a dominance relationship. Each context-sensitive program region has a unique subtree ID. If two locations have difference subtree IDs, then they are incomparable, and therefore cannot have a dominance relationship.

We arbitrarily choose 16 bits for this field, which would effectively limit the analyzer to 32K procedures (but that seems reasonable).

Definition at line 151 of file location.h.

Referenced by procLocation::adjust_depth(), basicblockLocation::adjust_depth(), stmtLocation::adjust_depth(), Location(), procLocation::procLocation(), procLocation::remove_from_tree(), and subtree_id().

unsigned int Location::_tree_max [protected]
 

Definition at line 204 of file location.h.

unsigned int Location::_tree_min [protected]
 

Tree numbering

These two numbers implement the tree numbering scheme (from communication from Mark Wegman) that allows a constant time interprocedural dominance test. The scheme works as follows: we perform a depth-first traversal of the dominator tree, both pre-order and post-order, assigning consecutive numbers to "tree min" value on the way down, and the "tree max" value on the way up.

This numbering results in the following invariant: the min-max range of each node contains the min-max ranges of all nodes that it dominates.

Since we compute this numbering on-line, we need to test dominance for nodes on the way down the tree. This means we have to do without a tree max value in some cases. Therefore, we have a special case: the tree max defaults to MAX_INT until it is given a specific value.

These number can get large, so we use full 32-bit ints (limits us to 4 billion program locations).

Definition at line 203 of file location.h.

unsigned int Location::block_count = 0 [static]
 

Definition at line 47 of file location.cc.

Referenced by basicblockLocation::basicblockLocation(), stats(), and basicblockLocation::~basicblockLocation().

unsigned int Location::current_subtree_id = 0 [static, protected]
 

Global subtree ID counter.

Definition at line 51 of file location.cc.

Referenced by procLocation::procLocation(), and procLocation::remove_from_tree().

unsigned int Location::current_tree_number = 0 [static, protected]
 

The current tree number to assign.

Definition at line 52 of file location.cc.

Referenced by procLocation::procLocation().

unsigned int Location::dom_calls = 0 [static]
 

Definition at line 49 of file location.cc.

Referenced by pointers_phase::run(), and strictly_dominates().

unsigned int Location::proc_count = 0 [static]
 

Definition at line 48 of file location.cc.

Referenced by procLocation::procLocation(), stats(), and procLocation::~procLocation().

unsigned int Location::stmt_count = 0 [static]
 

Some global counters.

Definition at line 46 of file location.cc.

Referenced by basicblockLocation::basicblockLocation(), stats(), stmtLocation::stmtLocation(), and stmtLocation::~stmtLocation().


The documentation for this class was generated from the following files:

Generated on August 27, 2003
Back to the C-Breeze home page