change the way to detect loops
[c11tester.git] / predicate.h
index c4390f11f33b0d4da8e808bc363c073c9571e44c..732e39abd8b7644d5f5d9d37df1e9a133594b06e 100644 (file)
@@ -10,7 +10,7 @@ typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, mo
 typedef HSIterator<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredExprSetIter;
 
 typedef enum predicate_token {
-       EQUALITY, NULLITY
+       NOPREDICATE, EQUALITY, NULLITY
 } token_t;
 
 /* If token is EQUALITY, then the predicate asserts whether
@@ -18,14 +18,14 @@ typedef enum predicate_token {
  * read at memory location specified in predicate_expr.
  */
 struct pred_expr {
-       pred_expr(token_t token, void * location, bool value) :
+       pred_expr(token_t token, FuncInst * inst, bool value) :
                token(token),
-               location(location),
+               func_inst(inst),
                value(value)
        {}
 
        token_t token;
-       void * location;
+       FuncInst * func_inst;
        bool value;
 
        MEMALLOC
@@ -39,14 +39,16 @@ public:
 
        FuncInst * get_func_inst() { return func_inst; }
        PredExprSet * get_pred_expressions() { return &pred_expressions; }
-       void add_predicate(token_t token, void * location, bool value);
+
+       void add_predicate_expr(token_t token, FuncInst * func_inst, bool value);
        void add_child(Predicate * child);
-       void add_parent(Predicate * parent);
-       void set_backedge(Predicate * back_pred) { backedge = back_pred; }
+       void set_parent(Predicate * parent_pred) { parent = parent_pred; }
+       void add_backedge(Predicate * back_pred) { backedges.add(back_pred); }
+       void copy_predicate_expr(Predicate * other);
 
        ModelVector<Predicate *> * get_children() { return &children; }
-       ModelVector<Predicate *> * get_parents() { return &parents; }
-       Predicate * get_backedge() { return backedge; }
+       Predicate * get_parent() { return parent; }
+       PredSet * get_backedges() { return &backedges; }
 
        bool is_entry_predicate() { return entry_predicate; }
        void set_entry_predicate() { entry_predicate = true; }
@@ -58,12 +60,16 @@ public:
 private:
        FuncInst * func_inst;
        bool entry_predicate;
-       /* may have multiple predicates */
+
+       /* may have multiple predicate expressions */
        PredExprSet pred_expressions;
        ModelVector<Predicate *> children;
-       ModelVector<Predicate *> parents;
-       /* assume almost one back edge exists */
-       Predicate * backedge;
+
+       /* only a single parent may exist */
+       Predicate * parent;
+
+       /* may have multiple back edges, e.g. nested loops */
+       PredSet backedges;
 };
 
 #endif /* __PREDICATE_H__ */