X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=predicate.h;h=4243a0d88cc98bc47ece42b96f07839c1bf3fe4c;hp=3849e2d88e0e4b2c519c4bd61717597a0d53f2e3;hb=3cc10cd7ba94e6a8eeedd0904c75ee613700a8ff;hpb=7594d7ae8eda38fbb5a3ac3d6f33fffbb365b7bd diff --git a/predicate.h b/predicate.h index 3849e2d8..4243a0d8 100644 --- a/predicate.h +++ b/predicate.h @@ -2,13 +2,15 @@ #define __PREDICATE_H__ #include "funcinst.h" +#include "hashset.h" unsigned int pred_expr_hash (struct pred_expr *); bool pred_expr_equal(struct pred_expr *, struct pred_expr *); -typedef HashSet PredicateSet; +typedef HashSet PredExprSet; +typedef HSIterator PredExprSetIter; typedef enum predicate_token { - EQUALITY, NULLITY + NOPREDICATE, EQUALITY, NULLITY } token_t; /* If token is EQUALITY, then the predicate asserts whether @@ -16,27 +18,76 @@ typedef enum predicate_token { * read at memory location specified in predicate_expr. */ struct pred_expr { + pred_expr(token_t token, FuncInst * inst, bool value) : + token(token), + func_inst(inst), + value(value) + {} + token_t token; - void * location; + FuncInst * func_inst; bool value; + + MEMALLOC +}; + +/* Used by predicate generator */ +struct half_pred_expr { + half_pred_expr(token_t token, FuncInst * inst) : + token(token), + func_inst(inst) + {} + + token_t token; + FuncInst * func_inst; + + SNAPSHOTALLOC }; class Predicate { public: - Predicate(FuncInst * func_inst); + Predicate(FuncInst * func_inst, bool is_entry = false); ~Predicate(); FuncInst * get_func_inst() { return func_inst; } - PredicateSet * get_predicates() { return &predicates; } - void add_predicate(token_t token, void * location, bool value); + PredExprSet * get_pred_expressions() { return &pred_expressions; } + + void add_predicate_expr(token_t token, FuncInst * func_inst, bool value); + void add_child(Predicate * child); + 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 * get_children() { return &children; } + Predicate * get_parent() { return parent; } + PredSet * get_backedges() { return &backedges; } + + bool is_entry_predicate() { return entry_predicate; } + void set_entry_predicate() { entry_predicate = true; } + + /* Whether func_inst does write or not */ + bool is_write() { return does_write; } + void set_write(bool is_write) { does_write = is_write; } + + void print_predicate(); + void print_pred_subtree(); MEMALLOC private: FuncInst * func_inst; - /* may have multiple precicates */ - PredicateSet predicates; + bool entry_predicate; + bool does_write; + + /* May have multiple predicate expressions */ + PredExprSet pred_expressions; ModelVector children; + + /* Only a single parent may exist */ + Predicate * parent; + + /* May have multiple back edges, e.g. nested loops */ + PredSet backedges; }; #endif /* __PREDICATE_H__ */