X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=predicate.h;h=0512835f6aadfbcab4ce7689dfd3e43ce689a863;hp=2f15a126653f724e510c3c7a1fb0145fe781a1cd;hb=57748ff26d916528ba0df0b1d2c699a901386d5f;hpb=7ecb1872e35ceba59b6949aa3942521e01920bd6 diff --git a/predicate.h b/predicate.h index 2f15a126..0512835f 100644 --- a/predicate.h +++ b/predicate.h @@ -1,56 +1,63 @@ -#ifndef __PREDICTAE_H__ +#ifndef __PREDICATE_H__ #define __PREDICATE_H__ -#include "funcinst.h" #include "hashset.h" +#include "predicatetypes.h" +#include "classlist.h" + +#define MAX_DEPTH 0x7fffffff unsigned int pred_expr_hash (struct pred_expr *); bool pred_expr_equal(struct pred_expr *, struct pred_expr *); typedef HashSet PredExprSet; typedef HSIterator PredExprSetIter; -typedef enum predicate_token { - EQUALITY, NULLITY -} token_t; - -/* If token is EQUALITY, then the predicate asserts whether - * this load should read the same value as the last value - * read at memory location specified in predicate_expr. - */ -struct pred_expr { - pred_expr(token_t token, void * location, bool value) : - token(token), - location(location), - value(value) - {} - - token_t token; - void * location; - bool value; - - MEMALLOC -}; - - class Predicate { public: - Predicate(FuncInst * func_inst, bool is_entry = false); + Predicate(FuncInst * func_inst, bool is_entry = false, bool is_exit = false); ~Predicate(); 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); + void set_exit(Predicate * exit_pred); + void add_backedge(Predicate * back_pred) { backedges.add(back_pred); } + void set_weight(double weight_) { weight = weight_; } + void copy_predicate_expr(Predicate * other); + Predicate * get_single_child(FuncInst * inst); ModelVector * get_children() { return &children; } - ModelVector * get_parents() { return &parents; } - Predicate * get_backedge() { return backedge; } + Predicate * get_parent() { return parent; } + Predicate * get_exit() { return exit; } + PredSet * get_backedges() { return &backedges; } + double get_weight() { return weight; } bool is_entry_predicate() { return entry_predicate; } void set_entry_predicate() { entry_predicate = true; } + void alloc_pre_exit_predicates(); + void add_pre_exit_predicate(Predicate * pred); + + /* Whether func_inst does write or not */ + bool is_write() { return does_write; } + void set_write(bool is_write) { does_write = is_write; } + + ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid); + + uint32_t get_expl_count() { return exploration_count; } + uint32_t get_store_visible_count() { return store_visible_count; } + uint32_t get_total_checking_count() { return total_checking_count; } + + void incr_expl_count() { exploration_count++; } + void incr_store_visible_count() { store_visible_count++; } + void incr_total_checking_count() { total_checking_count++; } + + uint32_t get_depth() { return depth; } + void set_depth(uint32_t depth_) { depth = depth_; } + void print_predicate(); void print_pred_subtree(); @@ -58,14 +65,30 @@ public: private: FuncInst * func_inst; bool entry_predicate; + bool exit_predicate; + bool does_write; - /* may have multiple predicates */ + /* Height of this predicate node in the predicate tree */ + uint32_t depth; + double weight; + + uint32_t exploration_count; + uint32_t store_visible_count; + uint32_t total_checking_count; /* The number of times the store visibility is checked */ + + /* May have multiple predicate expressions */ PredExprSet pred_expressions; ModelVector children; - ModelVector parents; - /* assume almost one back edge exists */ - Predicate * backedge; + /* Only a single parent may exist */ + Predicate * parent; + Predicate * exit; + + /* Predicates precede exit nodes. Only used by exit predicates */ + ModelVector * pre_exit_predicates; + + /* May have multiple back edges, e.g. nested loops */ + PredSet backedges; }; -#endif /* __PREDICATE_H__ */ +#endif /* __PREDICATE_H__ */