HomeresearchPeopleGeneral InfoSeminarsResources
| Software & Systems | Home | People | Publications | Links
Tips for Using the Mini/Polaris Compiler


Tips


TEN USEFUL THINGS TO DO WHILE YOU ARE IN POLARIS


1. ProgramUnit & pgm has a lot of good objects in it.
2. How to build a listable object.

As you can see you need a copy operator, print, and clone functions. You also need to inherit from Class Listable. Now you can use Iterators, Mutators, Maps.
// track variable count usage
class Counter : public Listable
{ public: INLINE Counter() { _count = 1; } INLINE ~Counter() {} // object classes to do work INLINE incr() { _count++;} INLINE int number() { return _count; } // for Listable Counter & operator = (const Counter & counter); INLINE Counter *clone() const { return new Counter( *this ); } INLINE Listable *listable_clone() const { return (Listable *) clone(); } INLINE void print(ostream &o) const { o << "Counter : " << _count; } private: int _count; }; // for usage in constructs template class TypedCollection; template class List; template class Iterator; template class Assign; template class RefSet;

3. You can use a Listable Object in Maps.

A Map is a one to one correspondence between objects of any Listable type. You do need template definitions for the correspondence. Templates exist for objects already defined such as Statement and Symbol so check first.

template class Map<symbol ,counter="">
template class KeyIterator<symbol ,counter="">
template class ProtoMap<symbol ,counter="">
template class TypedBaseMap<symbol ,counter="">

Then you can use the Map as follows:
Map<symbol ,counter=""> * ct_map = new Map<symbol ,counter="">
Symbol sym;
Counter count;
// notice count is cloned as Map takes ownership ct_map->ins(sym, count.clone());
KeyIterator out(*ct_map, STOP_ON_GHOSTS); for (; out.valid(); ++out) { Symbol & sym = out.current_key(); Counter & ct = out.current_data(); cout << sym << " "; ct.print(cout); cout << endl; }

4. Mutators and Iterators are different.

One allows change and one does not. Do not mix the two. Also in deleting an object on a list be careful not to blow up the Iterator.A RefList just points to a real List, you cannot delete in a RefList.



5. Use the convenience functions to build Expressions and Statements.


6. Read the Include files to find the convenience functions.


7. The utilities directory has a lot of useful auxiliary functions.

There are DominanceFrontiers and other goodies.




8. Read the Polaris Internal Representation paper.

It has some good examples of manipulating the code.




9. Do read the MAN pages

However, do not depend solely on them. MAN pages are woefully incomplete.




10. Do USE GDB to step through your code.

Asserts will bite you. Read them very carefully and hope you changed very little code.


Parasol Home | Research | People | General info | Seminars | Resources  

Parasol Lab, 301 Harvey R. Bright Bldg, 3112 TAMU, College Station, TX 77843-3112 
Contact Webmaster      Phone 979.458.0722     Fax 979.458.0718 
Dwight Look College of Engineering
Department of Computer Science and Engineering | Dwight Look College of Engineering | Texas A&M University
    
Privacy statement: Computer Science and Engineering Engineering TAMU