2001-07-24 17:14:13 +00:00
|
|
|
/* Title: ValueSet.h
|
|
|
|
Author: Ruchira Sasanka
|
|
|
|
Date: Jun 30, 01
|
|
|
|
Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
|
2001-08-20 21:11:01 +00:00
|
|
|
this. Contains both class and method definitions.
|
2001-07-24 17:14:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VALUE_SET_H
|
|
|
|
#define VALUE_SET_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <hash_set>
|
|
|
|
#include <algorithm>
|
2001-09-30 23:22:45 +00:00
|
|
|
//#include <fstream>
|
2001-07-24 17:14:13 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "llvm/Value.h"
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------ Support functions ---------------------------------
|
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
struct hashFuncValue { // sturcture containing the hash func
|
2001-07-24 17:14:13 +00:00
|
|
|
inline size_t operator () (const Value *const val) const
|
|
|
|
{ return (size_t) val; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
//------------------- Class Definition for ValueSet --------------------------
|
2001-07-24 17:14:13 +00:00
|
|
|
|
|
|
|
void printValue( const Value *const v); // func to print a Value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ValueSet : public hash_set<const Value *, hashFuncValue >
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2001-08-20 21:11:01 +00:00
|
|
|
ValueSet(); // constructor
|
2001-07-24 17:14:13 +00:00
|
|
|
|
|
|
|
inline void add(const Value *const val)
|
2001-08-20 21:11:01 +00:00
|
|
|
{ assert( val ); insert(val);} // for adding a live variable to set
|
2001-07-24 17:14:13 +00:00
|
|
|
|
|
|
|
inline void remove(const Value *const val)
|
2001-08-20 21:11:01 +00:00
|
|
|
{ assert( val ); erase(val); } // for removing a live var from set
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
bool setUnion( const ValueSet *const set1); // for performing set union
|
|
|
|
void setSubtract( const ValueSet *const set1); // for performing set diff
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
|
2001-07-24 17:14:13 +00:00
|
|
|
void setDifference( const ValueSet *const set1, const ValueSet *const set2);
|
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
void printSet() const; // for printing a live variable set
|
2001-07-24 17:14:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|