blob: 9a41b7cda0492af19d54a0cd33eaa34169905058 [file] [log] [blame]
bartd59bb0f2008-06-08 08:08:31 +00001/*
bart86562bd2009-02-16 19:43:56 +00002 This file is part of drd, a thread error detector.
bartd59bb0f2008-06-08 08:08:31 +00003
Elliott Hughesed398002017-06-21 14:41:24 -07004 Copyright (C) 2006-2017 Bart Van Assche <bvanassche@acm.org>.
bartd59bb0f2008-06-08 08:08:31 +00005
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
20
21 The GNU General Public License is contained in the file COPYING.
22*/
23
24
25#ifndef __DRD_THREAD_BITMAP_H
26#define __DRD_THREAD_BITMAP_H
27
bart09dc13f2009-02-14 15:13:31 +000028
bartd59bb0f2008-06-08 08:08:31 +000029#include "drd_bitmap.h"
bart09dc13f2009-02-14 15:13:31 +000030#include "drd_thread.h" /* running_thread_get_segment() */
31#include "pub_drd_bitmap.h"
32
bartd59bb0f2008-06-08 08:08:31 +000033
34static __inline__
35Bool bm_access_load_1_triggers_conflict(const Addr a1)
36{
bart8f822af2009-06-08 18:20:42 +000037 DRD_(bm_access_load_1)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1);
bartbedfd232009-03-26 19:07:15 +000038 return DRD_(bm_load_1_has_conflict_with)(DRD_(thread_get_conflict_set)(),
39 a1);
bartd59bb0f2008-06-08 08:08:31 +000040}
41
42static __inline__
43Bool bm_access_load_2_triggers_conflict(const Addr a1)
44{
bartbedfd232009-03-26 19:07:15 +000045 if ((a1 & 1) == 0)
46 {
bart8f822af2009-06-08 18:20:42 +000047 bm_access_aligned_load(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 2);
bartbedfd232009-03-26 19:07:15 +000048 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(),
49 a1, 2);
50 }
51 else
52 {
bart8f822af2009-06-08 18:20:42 +000053 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +000054 a1, a1 + 2, eLoad);
55 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
56 a1, a1 + 2, eLoad);
57 }
bartd59bb0f2008-06-08 08:08:31 +000058}
59
60static __inline__
61Bool bm_access_load_4_triggers_conflict(const Addr a1)
62{
bartbedfd232009-03-26 19:07:15 +000063 if ((a1 & 3) == 0)
64 {
bart8f822af2009-06-08 18:20:42 +000065 bm_access_aligned_load(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 4);
bartbedfd232009-03-26 19:07:15 +000066 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(),
67 a1, 4);
68 }
69 else
70 {
bart8f822af2009-06-08 18:20:42 +000071 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +000072 a1, a1 + 4, eLoad);
73 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
74 a1, a1 + 4, eLoad);
75 }
bartd59bb0f2008-06-08 08:08:31 +000076}
77
78static __inline__
79Bool bm_access_load_8_triggers_conflict(const Addr a1)
80{
bartbedfd232009-03-26 19:07:15 +000081 if ((a1 & 7) == 0)
82 {
bart8f822af2009-06-08 18:20:42 +000083 bm_access_aligned_load(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 8);
bartbedfd232009-03-26 19:07:15 +000084 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(),
85 a1, 8);
86 }
87 else if ((a1 & 3) == 0)
88 {
bart8f822af2009-06-08 18:20:42 +000089 bm_access_aligned_load(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1 + 0, 4);
90 bm_access_aligned_load(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1 + 4, 4);
bartbedfd232009-03-26 19:07:15 +000091 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
92 a1, a1 + 8, eLoad);
93 }
94 else
95 {
bart8f822af2009-06-08 18:20:42 +000096 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +000097 a1, a1 + 8, eLoad);
98 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
99 a1, a1 + 8, eLoad);
100 }
bartd59bb0f2008-06-08 08:08:31 +0000101}
102
103static __inline__
104Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2)
105{
bart8f822af2009-06-08 18:20:42 +0000106 DRD_(bm_access_range_load)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, a2);
bartbedfd232009-03-26 19:07:15 +0000107 return DRD_(bm_load_has_conflict_with)(DRD_(thread_get_conflict_set)(),
108 a1, a2);
bartd59bb0f2008-06-08 08:08:31 +0000109}
110
111static __inline__
112Bool bm_access_store_1_triggers_conflict(const Addr a1)
113{
bart8f822af2009-06-08 18:20:42 +0000114 DRD_(bm_access_store_1)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1);
bartbedfd232009-03-26 19:07:15 +0000115 return DRD_(bm_store_1_has_conflict_with)(DRD_(thread_get_conflict_set)(),
116 a1);
bartd59bb0f2008-06-08 08:08:31 +0000117}
118
119static __inline__
120Bool bm_access_store_2_triggers_conflict(const Addr a1)
121{
bartbedfd232009-03-26 19:07:15 +0000122 if ((a1 & 1) == 0)
123 {
bart8f822af2009-06-08 18:20:42 +0000124 bm_access_aligned_store(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 2);
bartbedfd232009-03-26 19:07:15 +0000125 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(),
126 a1, 2);
127 }
128 else
129 {
bart8f822af2009-06-08 18:20:42 +0000130 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +0000131 a1, a1 + 2, eStore);
132 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
133 a1, a1 + 2, eStore);
134 }
bartd59bb0f2008-06-08 08:08:31 +0000135}
136
137static __inline__
138Bool bm_access_store_4_triggers_conflict(const Addr a1)
139{
bartbedfd232009-03-26 19:07:15 +0000140 if ((a1 & 3) == 0)
141 {
bart8f822af2009-06-08 18:20:42 +0000142 bm_access_aligned_store(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 4);
bartbedfd232009-03-26 19:07:15 +0000143 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(),
144 a1, 4);
145 }
146 else
147 {
bart8f822af2009-06-08 18:20:42 +0000148 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +0000149 a1, a1 + 4, eStore);
150 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
151 a1, a1 + 4, eStore);
152 }
bartd59bb0f2008-06-08 08:08:31 +0000153}
154
155static __inline__
156Bool bm_access_store_8_triggers_conflict(const Addr a1)
157{
bartbedfd232009-03-26 19:07:15 +0000158 if ((a1 & 7) == 0)
159 {
bart8f822af2009-06-08 18:20:42 +0000160 bm_access_aligned_store(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, 8);
bartbedfd232009-03-26 19:07:15 +0000161 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(),
162 a1, 8);
163 }
164 else if ((a1 & 3) == 0)
165 {
bart8f822af2009-06-08 18:20:42 +0000166 bm_access_aligned_store(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +0000167 a1 + 0, 4);
bart8f822af2009-06-08 18:20:42 +0000168 bm_access_aligned_store(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +0000169 a1 + 4, 4);
170 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
171 a1, a1 + 8, eStore);
172 }
173 else
174 {
bart8f822af2009-06-08 18:20:42 +0000175 DRD_(bm_access_range)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()),
bartbedfd232009-03-26 19:07:15 +0000176 a1, a1 + 8, eStore);
177 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(),
178 a1, a1 + 8, eStore);
179 }
bartd59bb0f2008-06-08 08:08:31 +0000180}
181
182static __inline__
183Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2)
184{
bart8f822af2009-06-08 18:20:42 +0000185 DRD_(bm_access_range_store)(DRD_(sg_bm)(DRD_(running_thread_get_segment)()), a1, a2);
bartbedfd232009-03-26 19:07:15 +0000186 return DRD_(bm_store_has_conflict_with)(DRD_(thread_get_conflict_set)(),
187 a1, a2);
bartd59bb0f2008-06-08 08:08:31 +0000188}
189
190#endif // __DRD_THREAD_BITMAP_H