3 Predicate::Predicate(FuncInst * func_inst, bool is_entry) :
5 entry_predicate(is_entry),
12 unsigned int pred_expr_hash(struct pred_expr * expr)
14 return (unsigned int)((uintptr_t)expr);
17 bool pred_expr_equal(struct pred_expr * p1, struct pred_expr * p2)
19 if (p1->token != p2->token)
21 if (p1->token == EQUALITY && p1->location != p2->location)
23 if (p1->value != p2->value)
28 void Predicate::add_predicate(token_t token, void * location, bool value)
30 struct pred_expr *ptr = new pred_expr(token, location, value);
31 pred_expressions.add(ptr);
34 void Predicate::add_child(Predicate * child)
36 /* check duplication? */
37 children.push_back(child);
40 void Predicate::add_parent(Predicate * parent)
42 /* check duplication? */
43 parents.push_back(parent);
46 void Predicate::print_predicate()
48 model_print("\"%p\" [shape=box, label=\"\n", this);
49 if (entry_predicate) {
50 model_print("entry node\"];\n");
56 PredExprSetIter * it = pred_expressions.iterator();
58 if (pred_expressions.getSize() == 0)
59 model_print("no predicate\n");
61 while (it->hasNext()) {
62 struct pred_expr * expr = it->next();
63 model_print("predicate: token: %d, location: %p, value: %d\n", expr->token, expr->location, expr->value);
65 model_print("\"];\n");
68 void Predicate::print_pred_subtree()
71 for (uint i = 0; i < children.size(); i++) {
72 Predicate * child = children[i];
73 child->print_pred_subtree();
74 model_print("\"%p\" -> \"%p\"\n", this, child);
78 model_print("\"%p\" -> \"%p\"[style=dashed, color=grey]\n", this, backedge);