Section CONSTRUCTORS.
Variable ge: genv.
Variable fn: function.
(** 32-bit integer constants and arithmetic *)
(** 64-bit integer constants and arithmetic *)
(** Add offset to pointer *)
(** Translation of conditional branches *)
Remark branch_on_X31:
forall normal lbl (rs: regset) m b,
rs#X31 = Val.of_bool (eqb normal b) ->
exec_instr ge fn (if normal then Pbnew X31 X0 lbl else Pbeqw X31 X0 lbl) rs m =
eval_branch fn lbl rs m (Some b).
Ltac ArgsInv :=
repeat (match goal with
| [ H: Error _ = OK _ |- _ ] => discriminate
| [ H: match ?args with nil => _ | _ :: _ => _ end = OK _ |- _ ] => destruct args
| [ H: bind _ _ = OK _ |- _ ] => monadInv H
| [ H: match _ with left _ => _ | right _ => assertion_failed end = OK _ |- _ ] => monadInv H; ArgsInv
| [ H: match _ with true => _ | false => assertion_failed end = OK _ |- _ ] => monadInv H; ArgsInv
end);
subst;
repeat (match goal with
| [ H: ireg_of _ = OK _ |- _ ] => simpl in *; rewrite (ireg_of_eq _ _ H) in *
| [ H: freg_of _ = OK _ |- _ ] => simpl in *; rewrite (freg_of_eq _ _ H) in *
end).
(** Translation of condition operators *)
(** Some arithmetic properties. *)
Remark cast32unsigned_from_cast32signed:
forall i, Int64.repr (Int.unsigned i) = Int64.zero_ext 32 (Int64.repr (Int.signed i)).
(* Translation of arithmetic operations *)
Ltac SimplEval H :=
match type of H with
| Some _ = None _ => discriminate
| Some _ = Some _ => inv H
| ?a = Some ?b => let A := fresh in assert (A: Val.maketotal a = b) by (rewrite H; reflexivity)
end.
Ltac TranslOpSimpl :=
econstructor; split;
[ apply exec_straight_one; [simpl; eauto | reflexivity]
| split; [ apply Val.lessdef_same; Simpl; fail | intros; Simpl; fail ] ].
(** Memory accesses *)

Lemma transl_load_access_correct:
forall chunk (mk_instr: ireg -> offset -> instruction) addr args k c rd (rs: regset) m v v',
(forall base ofs rs,
exec_instr ge fn (mk_instr base ofs) rs m = exec_load ge chunk rs m rd base ofs) ->
transl_memory_access mk_instr addr args k = OK c ->
eval_addressing ge rs#SP addr (map rs (map preg_of args)) = Some v ->
Mem.loadv chunk m v = Some v' ->
rd <> PC ->
exists rs',
exec_straight ge fn c rs m k rs' m
/\ rs'#rd = v'
/\ forall r, r <> PC -> r <> X31 -> r <> rd -> rs'#r = rs#r.