Polaris: WorkSpace Class Reference

WorkSpace Class Reference

An abstract class for holding temporary pass-specific data. More...

#include <WorkSpace.h>

Inheritance diagram for WorkSpace:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 WorkSpace (unsigned int pass_tag)
 WorkSpace (const WorkSpace &other)
virtual ~WorkSpace ()
unsigned int pass_tag () const
 Return the pass tag associated with the WorkSpace.
virtual Listablelistable_clone () const =0
 Copy and return a pointer to any Listable item (MUST be implemented correctly by subclasses for List copy functions to work).
virtual void print (ostream &o) const =0
virtual int structures_OK () const =0
 Pure methods inherited from Listable.h.

Detailed Description

An abstract class for holding temporary pass-specific data.

Polaris Base

See also:
WorkSpace.h

WorkSpace.h

WorkSpace.cc

Overview

A WorkSpace class serves a placeholder for temporary data associated with Polaris' data structures, for example Statement or ProgamUnit objects.

Description

When a pass needs to annotate Statements or ProgramUnits with its own local data, it should create objects of a subclass of WorkSpace, which has fields for the temporary data, and push these objects onto the work stacks of these data structures (see WorkPlaceStack.h). When the pass is finished, it must pop its WorkSpace objects off of the work stacks.

Each pass must have its own unique pass tag. Pass tags are needed by WorkSpaceStacks to differentiate between multiple WorkSpaces on their stacks (see WorkSpaceStack.h). A pass can receive its own pass tag by calling the function create_pass_tag().

WorkSpaces differ from Directive or Assertion objects in that they are temporary and local to one pass. The pass is responsible for keeping the WorkSpace objects up to date when a Statement or Expression is modified. Additionally, it is assumed that the pass discards all of its WorkSpace objects upon its exit.

Examples

An example of a pass using WorkSpaces is:

void my_pass(ProgramUnit *pgm) {

Initialization

unsigned int my_pass_tag = create_pass_tag();

for (stmt = each statement in the program pgm) stmt->work_stack.push(new myWorkSpace(my_pass_tag, stmt));

Perform my analysis

while (not done with my analysis) { Visit statement stmt

myWorkSpace &ws = * (myWorkSpace *) stmt->work_stack.top_ref( my_pass_tag);

Use ws }

Exiting

pgm->clean_workspace(my_pass_tag); }

Definition at line 77 of file WorkSpace.h.


Constructor & Destructor Documentation

WorkSpace::WorkSpace unsigned int  pass_tag  )  [inline]
 

Definition at line 103 of file WorkSpace.h.

References register_instance().

WorkSpace::WorkSpace const WorkSpace other  )  [inline]
 

Definition at line 113 of file WorkSpace.h.

References register_instance().

WorkSpace::~WorkSpace  )  [virtual]
 

Definition at line 27 of file WorkSpace.cc.

References unregister_instance().


Member Function Documentation

unsigned int WorkSpace::pass_tag  )  const [inline]
 

Return the pass tag associated with the WorkSpace.

Definition at line 123 of file WorkSpace.h.

Referenced by DFS(), Dominator(), WorkSpaceStack::find_ref(), MyWorkSpace::listable_clone(), pDFS(), pDominator(), WorkSpaceStack::pop(), MyWorkSpace::print(), WorkSpaceStack::push(), WorkSpaceStack::structures_OK(), and WorkSpaceStack::top_ref().

virtual Listable* WorkSpace::listable_clone  )  const [pure virtual]
 

Copy and return a pointer to any Listable item (MUST be implemented correctly by subclasses for List copy functions to work).

Implements Listable.

Implemented in myWorkSpace, PropConstWS, DeadCodeElimWS, DominatorWorkSpace, GSAWorkSpace, InlineWorkSpace, pDominatorWorkSpace, PropCtrlRangeWS, PropRangeWS, StmtTopOrderWS, MyWorkSpace, and MyWorkSpace.

virtual void WorkSpace::print ostream &  o  )  const [pure virtual]
 

Implements Listable.

Implemented in myWorkSpace, PropConstWS, DeadCodeElimWS, DominatorWorkSpace, GSAWorkSpace, InlineWorkSpace, pDominatorWorkSpace, PropCtrlRangeWS, PropRangeWS, StmtTopOrderWS, MyWorkSpace, and MyWorkSpace.

virtual int WorkSpace::structures_OK  )  const [pure virtual]
 

Pure methods inherited from Listable.h.

Implemented in myWorkSpace, PropConstWS, DeadCodeElimWS, DominatorWorkSpace, GSAWorkSpace, InlineWorkSpace, pDominatorWorkSpace, PropCtrlRangeWS, PropRangeWS, StmtTopOrderWS, MyWorkSpace, and MyWorkSpace.


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:08:42 2005