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
16
bool
abstract_eventt::unsafe_pair_lwfence_param
(
const
abstract_eventt
&next,
17
memory_modelt
model,
18
bool
lwsync_met)
const
19
{
20
/* pairs with fences are not properly pairs */
21
if
(
operation
==
operationt::Fence
|| next.
operation
==
operationt::Fence
22
||
operation
==
operationt::Lwfence
|| next.
operation
==
operationt::Lwfence
23
||
operation
==
operationt::ASMfence
|| next.
operation
==
operationt::ASMfence
)
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
&&
34
operation
==
operationt::Write
&&
35
next.
operation
==
operationt::Read
);
36
37
case
PSO
:
38
return
(
thread
==next.
thread
&&
operation
==
operationt::Write
39
/* lwsyncWW -> mfenceWW */
40
&& !(
operation
==
operationt::Write
&&
41
next.
operation
==
operationt::Write
&&
42
lwsync_met));
43
44
case
RMO
:
45
return
46
thread
==next.
thread
&&
47
/* lwsyncWW -> mfenceWW */
48
!(
operation
==
operationt::Write
&&
49
next.
operation
==
operationt::Write
&&
50
lwsync_met) &&
51
/* lwsyncRW -> mfenceRW */
52
!(
operation
==
operationt::Read
&&
53
next.
operation
==
operationt::Write
&&
54
lwsync_met) &&
55
/* lwsyncRR -> mfenceRR */
56
!(
operation
==
operationt::Read
&&
57
next.
operation
==
operationt::Read
&&
58
lwsync_met) &&
59
/* if posWW, wsi maintained by the processor */
60
!(
variable
==next.
variable
&&
61
operation
==
operationt::Write
&&
62
next.
operation
==
operationt::Write
) &&
63
/* if posRW, fri maintained by the processor */
64
!(
variable
==next.
variable
&&
65
operation
==
operationt::Read
&&
66
next.
operation
==
operationt::Write
);
67
68
case
Power
:
69
return
((
thread
==next.
thread
70
/* lwsyncWW -> mfenceWW */
71
&& !(
operation
==
operationt::Write
&&
72
next.
operation
==
operationt::Write
&&
73
lwsync_met)
74
/* lwsyncRW -> mfenceRW */
75
&& !(
operation
==
operationt::Read
&&
76
next.
operation
==
operationt::Write
&&
77
lwsync_met)
78
/* lwsyncRR -> mfenceRR */
79
&& !(
operation
==
operationt::Read
&&
80
next.
operation
==
operationt::Read
&&
81
lwsync_met)
82
/* if posWW, wsi maintained by the processor */
83
&& (
variable
!=next.
variable
||
84
operation
!=
operationt::Write
||
85
next.
operation
!=
operationt::Write
))
86
/* rfe */
87
|| (
thread
!=next.
thread
&&
88
operation
==
operationt::Write
&&
89
next.
operation
==
operationt::Read
&&
90
variable
==next.
variable
));
91
92
case
Unknown
:
93
{
94
}
95
}
96
UNREACHABLE
;
97
/* unknown memory model */
98
return
true
;
99
}
100
101
bool
abstract_eventt::unsafe_pair_asm
(
const
abstract_eventt
&next,
102
memory_modelt
model,
103
unsigned
char
met)
const
104
{
105
/* pairs with fences are not properly pairs */
106
if
(
operation
==
operationt::Fence
||
107
next.
operation
==
operationt::Fence
||
108
operation
==
operationt::Lwfence
||
109
next.
operation
==
operationt::Lwfence
||
110
operation
==
operationt::ASMfence
||
111
next.
operation
==
operationt::ASMfence
)
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
&&
122
operation
==
operationt::Write
&&
123
next.
operation
==
operationt::Read
&&
124
(met&1)==0);
125
case
PSO
:
126
return
(
thread
==next.
thread
&&
127
operation
==
operationt::Write
&&
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
&&
135
operation
==
operationt::Write
&&
136
next.
operation
==
operationt::Write
) &&
137
/* if posRW, fri maintained by the processor */
138
!(
variable
==next.
variable
&&
139
operation
==
operationt::Read
&&
140
next.
operation
==
operationt::Write
);
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
||
147
operation
!=
operationt::Write
||
148
next.
operation
!=
operationt::Write
)) ||
149
/* rfe */
150
(
thread
!=next.
thread
&&
151
operation
==
operationt::Write
&&
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_event.h
abstract events
abstract_eventt
Definition:
abstract_event.h:23
abstract_eventt::operationt::Write
@ Write
abstract_eventt::operationt::Read
@ Read
abstract_eventt::operationt::Lwfence
@ Lwfence
abstract_eventt::operationt::ASMfence
@ ASMfence
abstract_eventt::operationt::Fence
@ Fence
abstract_eventt::thread
unsigned thread
Definition:
abstract_event.h:33
abstract_eventt::unsafe_pair_asm
bool unsafe_pair_asm(const abstract_eventt &next, memory_modelt model, unsigned char met) const
Definition:
abstract_event.cpp:101
abstract_eventt::unsafe_pair_lwfence_param
bool unsafe_pair_lwfence_param(const abstract_eventt &next, memory_modelt model, bool lwsync_met) const
Definition:
abstract_event.cpp:16
abstract_eventt::variable
irep_idt variable
Definition:
abstract_event.h:34
abstract_eventt::operation
operationt operation
Definition:
abstract_event.h:32
abstract_eventt::local
bool local
Definition:
abstract_event.h:38
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition:
invariant.h:525
memory_modelt
memory_modelt
Definition:
wmm.h:18
Unknown
@ Unknown
Definition:
wmm.h:19
TSO
@ TSO
Definition:
wmm.h:20
RMO
@ RMO
Definition:
wmm.h:22
PSO
@ PSO
Definition:
wmm.h:21
Power
@ Power
Definition:
wmm.h:23
src
goto-instrument
wmm
abstract_event.cpp
Generated by
1.9.1