Section CONSTRUCTORS.
Variable ge: genv.
Variable fn: function.
(** Properties of comparisons. *)
(** Loading a constant. *)
(** Add integer immediate. *)
(** And integer immediate. *)
(** Or integer immediate. *)
(** Xor integer immediate. *)
(** Rotate and mask. *)
(** Load int64 constant. *)
(** Alternate load int64 immediate *)
(** Add int64 immediate. *)
(** Or int64 immediate. *)
(** Xor int64 immediate. *)
(** And int64 immediate. *)
(** Rotate-and-mask for int64 *)
(** Indexed memory loads. *)
(** Indexed memory stores. *)
(** Float comparisons. *)
(** Translation of conditions. *)
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 *)
Remark add_carry_eq0:
forall i,
Vint (Int.add (Int.add (Int.sub Int.zero i) i)
(Int.add_carry Int.zero (Int.xor i Int.mone) Int.one)) =
Val.of_bool (Int.eq i Int.zero).
Remark add_carry_ne0:
forall i,
Vint (Int.add (Int.add i (Int.xor (Int.add i Int.mone) Int.mone))
(Int.add_carry i Int.mone Int.zero)) =
Val.of_bool (negb (Int.eq i Int.zero)).
(** Translation of arithmetic operations. *)
Ltac TranslOpSimpl :=
econstructor; split;
[ apply exec_straight_one; [simpl; eauto | reflexivity]
| split; [ apply Val.lessdef_same; Simpl; fail | intros; Simpl; fail ] ].
(** Translation of memory accesses *)
(** Translation of loads *)
(** Translation of stores *)
(** Translation of function epilogues *)

Lemma transl_epilogue_correct:
forall ge0 f m stk soff cs m' ms rs k tm,
load_stack m (Vptr stk soff) Tptr f.(fn_link_ofs) = Some (parent_sp cs) ->
load_stack m (Vptr stk soff) Tptr f.(fn_retaddr_ofs) = Some (parent_ra cs) ->
Mem.free m stk 0 f.(fn_stacksize) = Some m' ->
agree ms (Vptr stk soff) rs ->
(is_leaf_function f = true -> rs#LR = parent_ra cs) ->
Mem.extends m tm ->
match_stack ge0 cs ->
exists rs', exists tm',
exec_straight ge fn (transl_epilogue f k) rs tm k rs' tm'
/\ agree ms (parent_sp cs) rs'
/\ Mem.extends m' tm'
/\ rs'#LR = parent_ra cs
/\ rs'#SP = parent_sp cs
/\ (forall r, r <> PC -> r <> LR -> r <> SP -> r <> GPR0 -> rs'#r = rs#r).