(** * Breaking 64-bit memory accesses into two 32-bit accesses *)

(* Specifications: *)
Lemma int_of_bytes_append:
forall l2 l1,
int_of_bytes (l1 ++ l2) = int_of_bytes l1 + int_of_bytes l2 * two_p (Z.of_nat (length l1) * 8).
Lemma int_of_bytes_range:
forall l, 0 <= int_of_bytes l < two_p (Z.of_nat (length l) * 8).
Lemma length_proj_bytes:
forall l b, proj_bytes l = Some b -> length b = length l.
Lemma proj_bytes_append:
forall l2 l1,
proj_bytes (l1 ++ l2) =
match proj_bytes l1, proj_bytes l2 with
| Some b1, Some b2 => Some (b1 ++ b2)
| _, _ => None
end.
Lemma decode_val_int64:
forall l1 l2,
length l1 = 4%nat -> length l2 = 4%nat -> Archi.ptr64 = false ->
Val.lessdef
(decode_val Mint64 (l1 ++ l2))
(Val.longofwords (decode_val Mint32 (if Archi.big_endian then l1 else l2))
(decode_val Mint32 (if Archi.big_endian then l2 else l1))).
Lemma bytes_of_int_append:
forall n2 x2 n1 x1,
0 <= x1 < two_p (Z.of_nat n1 * 8) ->
bytes_of_int (n1 + n2) (x1 + x2 * two_p (Z.of_nat n1 * 8)) =
bytes_of_int n1 x1 ++ bytes_of_int n2 x2.
Lemma bytes_of_int64:
forall i,
bytes_of_int 8 (Int64.unsigned i) =
bytes_of_int 4 (Int.unsigned (Int64.loword i)) ++ bytes_of_int 4 (Int.unsigned (Int64.hiword i)).
Lemma encode_val_int64:
forall v,
Archi.ptr64 = false ->
encode_val Mint64 v =
encode_val Mint32 (if Archi.big_endian then Val.hiword v else Val.loword v)
++ encode_val Mint32 (if Archi.big_endian then Val.loword v else Val.hiword v).