CBMC
abstract_event.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: abstract events
4 
5 Author: Vincent Nimal
6 
7 Date: 2012
8 
9 \*******************************************************************/
10 
13 
14 #include "abstract_event.h"
15 
17  memory_modelt model,
18  bool lwsync_met) const
19 {
20  /* pairs with fences are not properly pairs */
24  return false;
25 
26  /* pairs of shared variables */
27  if(local || next.local)
28  return false;
29 
30  switch(model)
31  {
32  case TSO:
33  return (thread==next.thread &&
36 
37  case PSO:
38  return (thread==next.thread && operation==operationt::Write
39  /* lwsyncWW -> mfenceWW */
42  lwsync_met));
43 
44  case RMO:
45  return
46  thread==next.thread &&
47  /* lwsyncWW -> mfenceWW */
50  lwsync_met) &&
51  /* lwsyncRW -> mfenceRW */
54  lwsync_met) &&
55  /* lwsyncRR -> mfenceRR */
58  lwsync_met) &&
59  /* if posWW, wsi maintained by the processor */
60  !(variable==next.variable &&
63  /* if posRW, fri maintained by the processor */
64  !(variable==next.variable &&
67 
68  case Power:
69  return ((thread==next.thread
70  /* lwsyncWW -> mfenceWW */
73  lwsync_met)
74  /* lwsyncRW -> mfenceRW */
77  lwsync_met)
78  /* lwsyncRR -> mfenceRR */
81  lwsync_met)
82  /* if posWW, wsi maintained by the processor */
83  && (variable!=next.variable ||
86  /* rfe */
87  || (thread!=next.thread &&
90  variable==next.variable));
91 
92  case Unknown:
93  {
94  }
95  }
97  /* unknown memory model */
98  return true;
99 }
100 
102  memory_modelt model,
103  unsigned char met) const
104 {
105  /* pairs with fences are not properly pairs */
112  return false;
113 
114  /* pairs of shared variables */
115  if(local || next.local)
116  return false;
117 
118  switch(model)
119  {
120  case TSO:
121  return (thread==next.thread &&
123  next.operation==operationt::Read &&
124  (met&1)==0);
125  case PSO:
126  return (thread==next.thread &&
128  (met&3)==0);
129  case RMO:
130  return
131  thread==next.thread &&
132  (met&15)==0 &&
133  /* if posWW, wsi maintained by the processor */
134  !(variable==next.variable &&
136  next.operation==operationt::Write) &&
137  /* if posRW, fri maintained by the processor */
138  !(variable==next.variable &&
141  case Power:
142  return
143  (thread==next.thread &&
144  (met&15)==0 &&
145  /* if posWW, wsi maintained by the processor */
146  (variable!=next.variable ||
148  next.operation!=operationt::Write)) ||
149  /* rfe */
150  (thread!=next.thread &&
152  next.operation==operationt::Read &&
153  variable==next.variable);
154 
155  case Unknown:
156  {
157  }
158  }
159  UNREACHABLE;
160  /* unknown memory model */
161  return true;
162 }
abstract events
bool unsafe_pair_asm(const abstract_eventt &next, memory_modelt model, unsigned char met) const
bool unsafe_pair_lwfence_param(const abstract_eventt &next, memory_modelt model, bool lwsync_met) const
operationt operation
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:525
memory_modelt
Definition: wmm.h:18
@ Unknown
Definition: wmm.h:19
@ TSO
Definition: wmm.h:20
@ RMO
Definition: wmm.h:22
@ PSO
Definition: wmm.h:21
@ Power
Definition: wmm.h:23