SVF
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::BddCondManager Class Reference

#include <Conditions.h>

Public Member Functions

 BddCondManager ()
 Constructor. More...
 
 ~BddCondManager ()
 Destructor. More...
 
DdNodeCudd_bdd (u32_t i)
 
unsigned BddVarNum ()
 
DdNodegetTrueCond () const
 
DdNodegetFalseCond () const
 
u32_t getBDDMemUsage ()
 
u32_t getCondNumber ()
 
u32_t getMaxLiveCondNumber ()
 
void markForRelease (DdNode *cond)
 
void ddClearFlag (DdNode *f) const
 
void BddSupportStep (DdNode *f, NodeBS &support) const
 
void BddSupport (DdNode *f, NodeBS &support) const
 
void dump (DdNode *lhs, raw_ostream &O)
 
std::string dumpStr (DdNode *lhs) const
 
void printMinterms (DdNode *d)
 print minterms and debug information for the Ddnode More...
 
void printDbg (DdNode *d)
 
DdNodeAND (DdNode *lhs, DdNode *rhs)
 Operations on conditions. More...
 
DdNodeOR (DdNode *lhs, DdNode *rhs)
 
DdNodeNEG (DdNode *lhs)
 

Private Member Functions

DdNodeBddOne () const
 
DdNodeBddZero () const
 

Private Attributes

DdManagerm_bdd_mgr
 

Detailed Description

Using Cudd as conditions.

Definition at line 43 of file Conditions.h.

Constructor & Destructor Documentation

◆ BddCondManager()

SVF::BddCondManager::BddCondManager ( )
inline

Constructor.

Definition at line 48 of file Conditions.h.

49  {
51  }
#define CUDD_UNIQUE_SLOTS
Definition: cudd.h:93
#define CUDD_CACHE_SLOTS
Definition: cudd.h:94
DdManager * Cudd_Init(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
Definition: cuddInit.c:121
DdManager * m_bdd_mgr
Definition: Conditions.h:128

◆ ~BddCondManager()

SVF::BddCondManager::~BddCondManager ( )
inline

Destructor.

Definition at line 54 of file Conditions.h.

55  {
57  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
void Cudd_Quit(DdManager *unique)
Definition: cuddInit.c:218

Member Function Documentation

◆ AND()

DdNode * BddCondManager::AND ( DdNode lhs,
DdNode rhs 
)

Operations on conditions.

use Cudd_bddAndLimit interface to avoid bdds blow up

drop the rhs condition

Definition at line 40 of file Conditions.cpp.

41 {
42  if (lhs == getFalseCond() || rhs == getFalseCond())
43  return getFalseCond();
44  else if (lhs == getTrueCond())
45  return rhs;
46  else if (rhs == getTrueCond())
47  return lhs;
48  else
49  {
51  if(tmp==nullptr)
52  {
53  SVFUtil::writeWrnMsg("exceeds max bdd size \n");
55  return lhs;
56  }
57  else
58  {
59  Cudd_Ref(tmp);
60  return tmp;
61  }
62  }
63 }
Definition: cudd.h:270
DdNode * getTrueCond() const
Definition: Conditions.h:68
DdNode * Cudd_bddAndLimit(DdManager *dd, DdNode *f, DdNode *g, unsigned int limit)
Definition: cuddBddIte.c:382
void writeWrnMsg(std::string msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:67
static const llvm::cl::opt< unsigned > MaxBddSize
Definition: Options.h:170
DdManager * m_bdd_mgr
Definition: Conditions.h:128
DdNode * getFalseCond() const
Definition: Conditions.h:72
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:125

◆ BddOne()

DdNode* SVF::BddCondManager::BddOne ( ) const
inlineprivate

Definition at line 119 of file Conditions.h.

120  {
121  return Cudd_ReadOne(m_bdd_mgr);
122  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:1227

◆ BddSupport()

void BddCondManager::BddSupport ( DdNode f,
NodeBS support 
) const

Definition at line 134 of file Conditions.cpp.

135 {
136  BddSupportStep( Cudd_Regular(f), support);
138 }
#define Cudd_Regular(node)
Definition: cudd.h:384
void BddSupportStep(DdNode *f, NodeBS &support) const
Definition: Conditions.cpp:121
void ddClearFlag(DdNode *f) const
Definition: Conditions.cpp:108

◆ BddSupportStep()

void BddCondManager::BddSupportStep ( DdNode f,
NodeBS support 
) const

Definition at line 121 of file Conditions.cpp.

122 {
123  if (cuddIsConstant(f) || Cudd_IsComplement(f->next))
124  return;
125 
126  support.set(f->index);
127 
128  BddSupportStep(cuddT(f), support);
129  BddSupportStep(Cudd_Regular(cuddE(f)), support);
130  /* Mark as visited. */
131  f->next = Cudd_Complement(f->next);
132 }
#define Cudd_Regular(node)
Definition: cudd.h:384
void BddSupportStep(DdNode *f, NodeBS &support) const
Definition: Conditions.cpp:121
#define Cudd_IsComplement(node)
Definition: cudd.h:412
DdNode * next
Definition: cudd.h:273
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define Cudd_Complement(node)
Definition: cudd.h:398
#define cuddT(node)
Definition: cuddInt.h:609
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625

◆ BddVarNum()

unsigned SVF::BddCondManager::BddVarNum ( )
inline

Definition at line 63 of file Conditions.h.

64  {
65  return Cudd_ReadSize(m_bdd_mgr);
66  }
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1681
DdManager * m_bdd_mgr
Definition: Conditions.h:128

◆ BddZero()

DdNode* SVF::BddCondManager::BddZero ( ) const
inlineprivate

Definition at line 123 of file Conditions.h.

124  {
126  }
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1298
DdManager * m_bdd_mgr
Definition: Conditions.h:128

◆ Cudd_bdd()

DdNode* SVF::BddCondManager::Cudd_bdd ( u32_t  i)
inline

Definition at line 59 of file Conditions.h.

60  {
61  return Cudd_bddIthVar(m_bdd_mgr, i);
62  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:430

◆ ddClearFlag()

void BddCondManager::ddClearFlag ( DdNode f) const

Utilities for dumping conditions. These methods use global functions from CUDD package and they can be removed outside this class scope to be used by others.

Definition at line 108 of file Conditions.cpp.

109 {
110  if (!Cudd_IsComplement(f->next))
111  return;
112  /* Clear visited flag. */
113  f->next = Cudd_Regular(f->next);
114  if (cuddIsConstant(f))
115  return;
116  ddClearFlag(cuddT(f));
118  return;
119 }
#define Cudd_Regular(node)
Definition: cudd.h:384
#define Cudd_IsComplement(node)
Definition: cudd.h:412
DdNode * next
Definition: cudd.h:273
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
void ddClearFlag(DdNode *f) const
Definition: Conditions.cpp:108
#define cuddE(node)
Definition: cuddInt.h:625

◆ dump()

void BddCondManager::dump ( DdNode lhs,
raw_ostream O 
)

Dump BDD

Definition at line 143 of file Conditions.cpp.

144 {
145  if (lhs == getTrueCond())
146  O << "T";
147  else
148  {
149  NodeBS support;
150  BddSupport(lhs, support);
151  for (NodeBS::iterator iter = support.begin(); iter != support.end();
152  ++iter)
153  {
154  unsigned rid = *iter;
155  O << rid << " ";
156  }
157  }
158 }
void BddSupport(DdNode *f, NodeBS &support) const
Definition: Conditions.cpp:134
DdNode * getTrueCond() const
Definition: Conditions.h:68
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87

◆ dumpStr()

std::string BddCondManager::dumpStr ( DdNode lhs) const

Dump BDD

Definition at line 163 of file Conditions.cpp.

164 {
165  std::string str;
166  if (lhs == getTrueCond())
167  str += "T";
168  else
169  {
170  NodeBS support;
171  BddSupport(lhs, support);
172  for (NodeBS::iterator iter = support.begin(); iter != support.end();
173  ++iter)
174  {
175  unsigned rid = *iter;
176  char int2str[16];
177  sprintf(int2str, "%d", rid);
178  str += int2str;
179  str += " ";
180  }
181  }
182  return str;
183 }
void BddSupport(DdNode *f, NodeBS &support) const
Definition: Conditions.cpp:134
DdNode * getTrueCond() const
Definition: Conditions.h:68
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87

◆ getBDDMemUsage()

u32_t SVF::BddCondManager::getBDDMemUsage ( )
inline

Definition at line 77 of file Conditions.h.

78  {
80  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
unsigned long Cudd_ReadMemoryInUse(DdManager *dd)
Definition: cuddAPI.c:3242

◆ getCondNumber()

u32_t SVF::BddCondManager::getCondNumber ( )
inline

Definition at line 81 of file Conditions.h.

82  {
84  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
long Cudd_ReadNodeCount(DdManager *dd)
Definition: cuddAPI.c:3504

◆ getFalseCond()

DdNode* SVF::BddCondManager::getFalseCond ( ) const
inline

Definition at line 72 of file Conditions.h.

73  {
74  return BddZero();
75  }
DdNode * BddZero() const
Definition: Conditions.h:123

◆ getMaxLiveCondNumber()

u32_t SVF::BddCondManager::getMaxLiveCondNumber ( )
inline

Definition at line 85 of file Conditions.h.

86  {
88  }
int Cudd_ReadPeakLiveNodeCount(DdManager *dd)
Definition: cuddAPI.c:3476
DdManager * m_bdd_mgr
Definition: Conditions.h:128

◆ getTrueCond()

DdNode* SVF::BddCondManager::getTrueCond ( ) const
inline

Definition at line 68 of file Conditions.h.

69  {
70  return BddOne();
71  }
DdNode * BddOne() const
Definition: Conditions.h:119

◆ markForRelease()

void SVF::BddCondManager::markForRelease ( DdNode cond)
inline

Definition at line 89 of file Conditions.h.

90  {
92  }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:150
DdManager * m_bdd_mgr
Definition: Conditions.h:128

◆ NEG()

DdNode * BddCondManager::NEG ( DdNode lhs)

Definition at line 93 of file Conditions.cpp.

94 {
95  if (lhs == getTrueCond())
96  return getFalseCond();
97  else if (lhs == getFalseCond())
98  return getTrueCond();
99  else
100  return Cudd_Not(lhs);
101 }
#define Cudd_Not(node)
Definition: cudd.h:354
DdNode * getTrueCond() const
Definition: Conditions.h:68
DdNode * getFalseCond() const
Definition: Conditions.h:72

◆ OR()

DdNode * BddCondManager::OR ( DdNode lhs,
DdNode rhs 
)

Use Cudd_bddOrLimit interface to avoid bdds blow up

drop the two conditions here

Definition at line 68 of file Conditions.cpp.

69 {
70  if (lhs == getTrueCond() || rhs == getTrueCond())
71  return getTrueCond();
72  else if (lhs == getFalseCond())
73  return rhs;
74  else if (rhs == getFalseCond())
75  return lhs;
76  else
77  {
79  if(tmp==nullptr)
80  {
81  SVFUtil::writeWrnMsg("exceeds max bdd size \n");
83  return getTrueCond();
84  }
85  else
86  {
87  Cudd_Ref(tmp);
88  return tmp;
89  }
90  }
91 }
Definition: cudd.h:270
DdNode * getTrueCond() const
Definition: Conditions.h:68
DdNode * Cudd_bddOrLimit(DdManager *dd, DdNode *f, DdNode *g, unsigned int limit)
Definition: cuddBddIte.c:450
void writeWrnMsg(std::string msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:67
static const llvm::cl::opt< unsigned > MaxBddSize
Definition: Options.h:170
DdManager * m_bdd_mgr
Definition: Conditions.h:128
DdNode * getFalseCond() const
Definition: Conditions.h:72
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:125

◆ printDbg()

void SVF::BddCondManager::printDbg ( DdNode d)
inline

Definition at line 114 of file Conditions.h.

115  {
116  Cudd_PrintDebug(m_bdd_mgr,d,0,3);
117  }
DdManager * m_bdd_mgr
Definition: Conditions.h:128
int Cudd_PrintDebug(DdManager *dd, DdNode *f, int n, int pr)
Definition: cuddUtil.c:386

◆ printMinterms()

void SVF::BddCondManager::printMinterms ( DdNode d)
inline

print minterms and debug information for the Ddnode

Definition at line 110 of file Conditions.h.

111  {
113  }
int Cudd_PrintMinterm(DdManager *manager, DdNode *node)
Definition: cuddUtil.c:220
DdManager * m_bdd_mgr
Definition: Conditions.h:128

Member Data Documentation

◆ m_bdd_mgr

DdManager* SVF::BddCondManager::m_bdd_mgr
private

Definition at line 128 of file Conditions.h.


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