1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|
(****************************************************************************)
(* the diy toolsuite *)
(* *)
(* Jade Alglave, University College London, UK. *)
(* Luc Maranget, INRIA Paris-Rocquencourt, France. *)
(* *)
(* Copyright 2015-present Institut National de Recherche en Informatique et *)
(* en Automatique and the authors. All rights reserved. *)
(* *)
(* This software is governed by the CeCILL-B license under French law and *)
(* abiding by the rules of distribution of free software. You can use, *)
(* modify and/ or redistribute the software under the terms of the CeCILL-B *)
(* license as circulated by CEA, CNRS and INRIA at the following URL *)
(* "http://www.cecill.info". We also give a copy in LICENSE.txt. *)
(****************************************************************************)
module Make (A : Arch_herd.S) : sig
type action =
| Access of Dir.dirn * A.location * A.V.v * AccessModes.t * MachSize.sz
| Fence of AccessModes.t
| RMW of A.location * A.V.v * A.V.v * AccessModes.t * MachSize.sz
| CutOff of string
include Action.S with type action := action and module A = A
end = struct
module A = A
module V = A.V
open Dir
open Printf
type action =
| Access of Dir.dirn * A.location * A.V.v * AccessModes.t * MachSize.sz
| Fence of AccessModes.t
| RMW of A.location * A.V.v * A.V.v * AccessModes.t * MachSize.sz
| CutOff of string
let mk_init_write l sz v = Access (W, l, v, AccessModes.NA, sz)
let par f x = sprintf "(%s)" (f x) (*for access modes*)
let pp_action a =
match a with
| Access (d, l, v, am, _) ->
(sprintf "%s%s%s=%s"
(pp_dirn d)
(par AccessModes.pp_access_modes am)
(A.pp_location l)
(V.pp_v v))
| Fence b ->
sprintf "Fence%s" (par AccessModes.pp_access_modes b)
| RMW (l, v1, v2, am, _) ->
(sprintf "RMW(%s)%s(%s>%s)"
(AccessModes.pp_access_modes am)
(A.pp_location l)
(V.pp_v v1)
(V.pp_v v2))
| CutOff m -> (sprintf "CutOff: %s" m)
let is_isync _ = raise Misc.NoIsync
let pp_isync = "???"
let is_barrier a = match a with
| Fence _ -> true
| _ -> false
let barrier_of _ = assert false
let same_barrier_id _ _ = assert false
let is_rmw a = match a with
| RMW _ -> true
| _ -> false
let is_reg a (p:int) = match a with
| Access (_,A.Location_reg (q,_),_,_,_) -> p = q
| _ -> false
let is_mem a = match a with
| Access (_,A.Location_global _,_,_,_) -> true
| RMW (A.Location_global _,_,_,_,_) -> true
| _ -> false
let is_ifetch _ = false
let is_additional_mem _ = false
let is_additional_mem_load _ = false
let is_atomic a = match a with
| Access (_,A.Location_global _,_,_,_) -> true
| RMW _ -> true
| _ -> false
let to_fault _ = None
let is_reg_store a (p:int) = match a with
| Access (W,A.Location_reg (q,_),_,_,_) -> p = q
| _ -> false
let is_reg_load a (p:int) = match a with
| Access (R,A.Location_reg (q,_),_,_,_) -> p = q
| _ -> false
(* let is_reg_any a = match a with
| Access (_,A.Location_reg _,_,_,_) -> true
| _ -> false *)
let get_mem_dir a = match a with
| Access (d,A.Location_global _,_,_,_) -> d
| _ -> assert false
let get_mem_size a = match a with
| Access (_,A.Location_global _,_,_,sz) -> sz
| _ -> assert false
let is_pte_access _ = false
let is_mem_store a = match a with
| Access (W,A.Location_global _,_,_,_)
| RMW (A.Location_global _,_,_,_,_)
-> true
| _ -> false
let is_mem_load a = match a with
| Access (R,A.Location_global _,_,_,_)
| RMW (A.Location_global _,_,_,_,_)
-> true
| _ -> false
let value_of a = match a with
| Access (_,_,v,_,_) -> Some v
| _ -> None
let read_of a = match a with
| Access (R,_ , v,_,_)
| RMW (_,v,_,_,_)
-> Some v
| _ -> None
let written_of a = match a with
| Access (W,_ , v,_,_)
| RMW (_,_,v,_,_)
-> Some v
| _ -> None
let location_of a = match a with
| Access (_, l, _,_,_) -> Some l
| RMW (l,_,_,_,_) -> Some l
| Fence _ -> None
| _ -> None
(* Store/Load anywhere *)
let is_store a = match a with
| Access (W,_,_,_,_)
| RMW _
-> true
| _ -> false
let is_load a = match a with
| Access (R,_,_,_,_)
| RMW _ -> true
| _ -> false
let is_reg_any a = match a with
| Access (_,A.Location_reg _,_,_,_) -> true
| _ -> false
let is_reg_store_any a = match a with
| Access (W,A.Location_reg _,_,_,_) -> true
| _ -> false
let is_reg_load_any a = match a with
| Access (R,A.Location_reg _,_,_,_) -> true
| _ -> false
let compatible_accesses a1 a2 =
(is_mem a1 && is_mem a2) || (is_reg_any a1 && is_reg_any a2)
let arch_rels = []
let arch_dirty = []
let is_fault _ = false
let is_tag _ = false
let cutoff msg = CutOff msg
let is_cutoff = function
| CutOff _ -> true
| _ -> false
let as_cutoff = function
| CutOff msg -> Some msg
| _ -> None
let is_bcc _ = false
let is_pred ?cond:_ _ = false
let is_commit _ = false
include Explicit.NoAction
let annot_in_list _ _ = false
let mo_matches target a =
match a with
| Access(_,_,_,mo,_)
| RMW (_,_,_,mo,_)
| Fence (mo) -> (mo = target)
| _ -> false
let undetermined_vars_in_action a =
match a with
| Access (_,l,v,_,_)->
V.ValueSet.union
(A.undetermined_vars_in_loc l)
(V.undetermined_vars v)
| RMW (l,v1,v2,_,_) ->
V.ValueSet.union3
(A.undetermined_vars_in_loc l)
(V.undetermined_vars v1)
(V.undetermined_vars v2)
| Fence _ -> V.ValueSet.empty
| CutOff _ -> assert false
let simplify_vars_in_action soln a =
match a with
| Access (d,l,v,mo,sz) ->
let l' = A.simplify_vars_in_loc soln l in
let v' = V.simplify_var soln v in
Access (d,l',v',mo,sz)
| RMW(l,v1,v2,mo,sz) ->
let l' = A.simplify_vars_in_loc soln l in
let v1' = V.simplify_var soln v1 in
let v2' = V.simplify_var soln v2 in
RMW(l',v1',v2',mo,sz)
| Fence _ -> a
| CutOff _ -> assert false
let arch_sets = [
"RMW", (fun e -> is_rmw e);
"REL", mo_matches AccessModes.Release;
"V", mo_matches AccessModes.Volatile;
"ACQ", mo_matches AccessModes.Acquire;
"RA", (fun e ->
mo_matches AccessModes.Acquire e ||
mo_matches AccessModes.Release e);
"O", mo_matches AccessModes.Opaque
]
(* let arch_fences = [] *)
end
|