bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | This file is part of drd, a data race detector. |
| 3 | |
| 4 | Copyright (C) 2006-2008 Bart Van Assche |
| 5 | bart.vanassche@gmail.com |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the |
| 10 | License, or (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307, USA. |
| 21 | |
| 22 | The GNU General Public License is contained in the file COPYING. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | #ifndef __DRD_THREAD_BITMAP_H |
| 27 | #define __DRD_THREAD_BITMAP_H |
| 28 | |
| 29 | #include "drd_bitmap.h" |
| 30 | |
| 31 | static __inline__ |
| 32 | Bool bm_access_load_1_triggers_conflict(const Addr a1) |
| 33 | { |
| 34 | bm_access_load_1(running_thread_get_segment()->bm, a1); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 35 | return bm_load_1_has_conflict_with(thread_get_conflict_set(), a1); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static __inline__ |
| 39 | Bool bm_access_load_2_triggers_conflict(const Addr a1) |
| 40 | { |
| 41 | if ((a1 & 1) == 0) |
| 42 | { |
| 43 | bm_access_aligned_load(running_thread_get_segment()->bm, a1, 2); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 44 | return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 2); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 45 | } |
| 46 | else |
| 47 | { |
| 48 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eLoad); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 49 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 2, eLoad); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | static __inline__ |
| 54 | Bool bm_access_load_4_triggers_conflict(const Addr a1) |
| 55 | { |
| 56 | if ((a1 & 3) == 0) |
| 57 | { |
| 58 | bm_access_aligned_load(running_thread_get_segment()->bm, a1, 4); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 59 | return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 4); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 60 | } |
| 61 | else |
| 62 | { |
| 63 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eLoad); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 64 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 4, eLoad); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
| 68 | static __inline__ |
| 69 | Bool bm_access_load_8_triggers_conflict(const Addr a1) |
| 70 | { |
| 71 | if ((a1 & 7) == 0) |
| 72 | { |
| 73 | bm_access_aligned_load(running_thread_get_segment()->bm, a1, 8); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 74 | return bm_aligned_load_has_conflict_with(thread_get_conflict_set(), a1, 8); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 75 | } |
| 76 | else if ((a1 & 3) == 0) |
| 77 | { |
| 78 | bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 0, 4); |
| 79 | bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 4, 4); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 80 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eLoad); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 81 | } |
| 82 | else |
| 83 | { |
| 84 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eLoad); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 85 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eLoad); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
| 89 | static __inline__ |
| 90 | Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2) |
| 91 | { |
| 92 | bm_access_range_load(running_thread_get_segment()->bm, a1, a2); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 93 | return bm_load_has_conflict_with(thread_get_conflict_set(), a1, a2); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static __inline__ |
| 97 | Bool bm_access_store_1_triggers_conflict(const Addr a1) |
| 98 | { |
| 99 | bm_access_store_1(running_thread_get_segment()->bm, a1); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 100 | return bm_store_1_has_conflict_with(thread_get_conflict_set(), a1); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static __inline__ |
| 104 | Bool bm_access_store_2_triggers_conflict(const Addr a1) |
| 105 | { |
| 106 | if ((a1 & 1) == 0) |
| 107 | { |
| 108 | bm_access_aligned_store(running_thread_get_segment()->bm, a1, 2); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 109 | return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 2); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 110 | } |
| 111 | else |
| 112 | { |
| 113 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eStore); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 114 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 2, eStore); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 115 | } |
| 116 | } |
| 117 | |
| 118 | static __inline__ |
| 119 | Bool bm_access_store_4_triggers_conflict(const Addr a1) |
| 120 | { |
| 121 | if ((a1 & 3) == 0) |
| 122 | { |
| 123 | bm_access_aligned_store(running_thread_get_segment()->bm, a1, 4); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 124 | return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 4); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 125 | } |
| 126 | else |
| 127 | { |
| 128 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eStore); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 129 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 4, eStore); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
| 133 | static __inline__ |
| 134 | Bool bm_access_store_8_triggers_conflict(const Addr a1) |
| 135 | { |
| 136 | if ((a1 & 7) == 0) |
| 137 | { |
| 138 | bm_access_aligned_store(running_thread_get_segment()->bm, a1, 8); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 139 | return bm_aligned_store_has_conflict_with(thread_get_conflict_set(), a1, 8); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 140 | } |
| 141 | else if ((a1 & 3) == 0) |
| 142 | { |
| 143 | bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 0, 4); |
| 144 | bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 4, 4); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 145 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eStore); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 146 | } |
| 147 | else |
| 148 | { |
| 149 | bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eStore); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 150 | return bm_has_conflict_with(thread_get_conflict_set(), a1, a1 + 8, eStore); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | static __inline__ |
| 155 | Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2) |
| 156 | { |
| 157 | bm_access_range_store(running_thread_get_segment()->bm, a1, a2); |
bart | e73b0aa | 2008-06-28 07:19:56 +0000 | [diff] [blame] | 158 | return bm_store_has_conflict_with(thread_get_conflict_set(), a1, a2); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | #endif // __DRD_THREAD_BITMAP_H |