(** Expressing 64-bit operations in terms of 32-bit operations *)

(* Specifications: *)
Lemma decompose_bitwise_binop:
forall f f64 f32 xh xl yh yl,
(forall x y i, 0 <= i < zwordsize -> testbit (f64 x y) i = f (testbit x i) (testbit y i)) ->
(forall x y i, 0 <= i < Int.zwordsize -> Int.testbit (f32 x y) i = f (Int.testbit x i) (Int.testbit y i)) ->
f64 (ofwords xh xl) (ofwords yh yl) = ofwords (f32 xh yh) (f32 xl yl).
Lemma decompose_and:
forall xh xl yh yl,
and (ofwords xh xl) (ofwords yh yl) = ofwords (Int.and xh yh) (Int.and xl yl).
Lemma decompose_or:
forall xh xl yh yl,
or (ofwords xh xl) (ofwords yh yl) = ofwords (Int.or xh yh) (Int.or xl yl).
Lemma decompose_xor:
forall xh xl yh yl,
xor (ofwords xh xl) (ofwords yh yl) = ofwords (Int.xor xh yh) (Int.xor xl yl).
Lemma decompose_not:
forall xh xl,
not (ofwords xh xl) = ofwords (Int.not xh) (Int.not xl).
Lemma decompose_shl_1:
forall xh xl y,
0 <= Int.unsigned y < Int.zwordsize ->
shl' (ofwords xh xl) y =
ofwords (Int.or (Int.shl xh y) (Int.shru xl (Int.sub Int.iwordsize y)))
(Int.shl xl y).
Lemma decompose_shl_2:
forall xh xl y,
Int.zwordsize <= Int.unsigned y < zwordsize ->
shl' (ofwords xh xl) y =
ofwords (Int.shl xl (Int.sub y Int.iwordsize)) Int.zero.
Lemma decompose_shru_1:
forall xh xl y,
0 <= Int.unsigned y < Int.zwordsize ->
shru' (ofwords xh xl) y =
ofwords (Int.shru xh y)
(Int.or (Int.shru xl y) (Int.shl xh (Int.sub Int.iwordsize y))).
Lemma decompose_shru_2:
forall xh xl y,
Int.zwordsize <= Int.unsigned y < zwordsize ->
shru' (ofwords xh xl) y =
ofwords Int.zero (Int.shru xh (Int.sub y Int.iwordsize)).
Lemma decompose_shr_1:
forall xh xl y,
0 <= Int.unsigned y < Int.zwordsize ->
shr' (ofwords xh xl) y =
ofwords (Int.shr xh y)
(Int.or (Int.shru xl y) (Int.shl xh (Int.sub Int.iwordsize y))).
Lemma decompose_shr_2:
forall xh xl y,
Int.zwordsize <= Int.unsigned y < zwordsize ->
shr' (ofwords xh xl) y =
ofwords (Int.shr xh (Int.sub Int.iwordsize Int.one))
(Int.shr xh (Int.sub y Int.iwordsize)).
Lemma decompose_add:
forall xh xl yh yl,
add (ofwords xh xl) (ofwords yh yl) =
ofwords (Int.add (Int.add xh yh) (Int.add_carry xl yl Int.zero))
(Int.add xl yl).
Lemma decompose_sub:
forall xh xl yh yl,
sub (ofwords xh xl) (ofwords yh yl) =
ofwords (Int.sub (Int.sub xh yh) (Int.sub_borrow xl yl Int.zero))
(Int.sub xl yl).
Lemma decompose_sub':
forall xh xl yh yl,
sub (ofwords xh xl) (ofwords yh yl) =
ofwords (Int.add (Int.add xh (Int.not yh)) (Int.add_carry xl (Int.not yl) Int.one))
(Int.sub xl yl).