model: replace TreeNode with NodeStack
[cdsspec-compiler.git] / action.h
1 #ifndef __ACTION_H__
2 #define __ACTION_H__
3
4 #include <list>
5
6 #include "threads.h"
7 #include "libatomic.h"
8
9 #define VALUE_NONE -1
10
11 typedef enum action_type {
12         THREAD_CREATE,
13         THREAD_YIELD,
14         THREAD_JOIN,
15         ATOMIC_READ,
16         ATOMIC_WRITE
17 } action_type_t;
18
19 /* Forward declaration */
20 class Node;
21
22 class ModelAction {
23 public:
24         ModelAction(action_type_t type, memory_order order, void *loc, int value);
25         void print(void);
26
27         thread_id_t get_tid() { return tid; }
28         action_type get_type() { return type; }
29         memory_order get_mo() { return order; }
30         void * get_location() { return location; }
31         int get_seq_number() const { return seq_number; }
32
33         Node * get_node() { return node; }
34         void set_node(Node *n) { node = n; }
35
36         bool is_read();
37         bool is_write();
38         bool is_acquire();
39         bool is_release();
40         bool same_var(ModelAction *act);
41         bool same_thread(ModelAction *act);
42         bool is_dependent(ModelAction *act);
43
44         inline bool operator <(const ModelAction& act) const {
45                 return get_seq_number() < act.get_seq_number();
46         }
47         inline bool operator >(const ModelAction& act) const {
48                 return get_seq_number() > act.get_seq_number();
49         }
50 private:
51         action_type type;
52         memory_order order;
53         void *location;
54         thread_id_t tid;
55         int value;
56         Node *node;
57         int seq_number;
58 };
59
60 typedef std::list<class ModelAction *> action_list_t;
61
62 #endif /* __ACTION_H__ */