Library mcertikos.multicore.refins.AsmReorderSemtoReorderSem
Require Import Coqlib.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Events.
Require Import Globalenvs.
Require Import Conventions.
Require Import AuxLemma.
Require Import GlobIdent.
Require Import Smallstep.
Require Import CommonTactic.
Require Import Coq.Logic.FunctionalExtensionality.
Require Import AuxFunctions.
Require Import LAsm.
Require Import GlobalOracle.
Require Import liblayers.compat.CompatLayers.
Require Import MBoot.
Require Import RealParams.
Require Import AbstractDataType.
Require Import FlatMemory.
Require Import Decision.
Require Import LAsmModuleSem.
Require Import Soundness.
Require Import CompatExternalCalls.
Require Import LinkTactic.
Require Import I64Layer.
Require Import StencilImpl.
Require Import MakeProgram.
Require Import MakeProgramImpl.
Require Import LAsmModuleSemAux.
Require Import liblayers.compat.CompatGenSem.
Require Import TacticsForTesting.
Require Import Concurrent_Linking_Lib.
Require Import Concurrent_Linking_Def.
Require Import Concurrent_Linking_Prop.
Require Import HWSemImpl.
Require Import ConcurrentOracle.
Require Import ReorderSemImpl.
Section LinkwithLAsm.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Context `{builtin_idents_norepet_prf: CompCertBuiltins.BuiltinIdentsNorepet}.
Notation LDATA := RData.
Notation LDATAOps := (cdata (cdata_ops := mboot_data_ops) LDATA).
Local Open Scope Z_scope.
Context `{pmap: PartialMap}.
Context `{fair: Fairness}.
Context `{zset_op: ZSet_operation}.
Existing Instance hdseting.
Existing Instance op_sep.
Context `{mc_oracle: !MCLinkOracle}.
Context `{mc_oracle_cond: !MCLinkOracleCond}.
Section WITH_GE.
Variables (ge: genv) (sten: stencil) (M: module).
Context {Hmakege: make_globalenv (module_ops:= LAsm.module_ops) (mkp_ops:= make_program_ops)
sten M (mboot ⊕ L64) = ret ge}.
Definition single_reorder_low_step_aux_ge´ :=
@single_reorder_step_aux_ge mem memory_model_ops Hmem Hmwd
real_params_ops oracle_ops0 oracle_ops big_ops
builtin_idents_norepet_prf zset_op
ge sten M Hmakege reorder_oracle.
Definition single_reorder_high_step_aux_ge´ :=
@single_reorder_step_aux_ge mem memory_model_ops Hmem Hmwd
real_params_ops oracle_ops0 oracle_ops big_ops
builtin_idents_norepet_prf zset_op
ge sten M Hmakege reorder_oracle_red.
Lemma single_reorder_step_aux_eq :
∀ (ge:genv) sten M
(Hmakege: make_globalenv sten M (mboot ⊕ L64) = ret ge)
s t s´ o,
single_reorder_step_aux_ge ge sten M (Hmakege:=Hmakege) o ge s t s´ ↔
single_reorder_step_aux ge sten M (Hmakege:=Hmakege) o s t s´.
Proof.
intros; split; intros.
inversion H; auto.
constructor; auto.
Qed.
Definition match_rrstate_link := match_rrstate (hdset:= hdseting).
Hint Unfold match_rrstate_link.
Existing Instance op_reorder.
Lemma one_step_reorder_refines_reorder_concrete:
∀ s s0 s´ t
(Hone: single_reorder_high_step_aux_ge´ ge s t s´)
(Hmatch: match_rrstate_link s s0),
∃ s0´,
single_reorder_low_step_aux_ge´ ge s0 t s0´
∧ match_rrstate_link s´ s0´.
Proof.
simpl in ×.
unfold single_reorder_low_step_aux_ge´.
unfold single_reorder_high_step_aux_ge´.
intros.
rewrite single_reorder_step_aux_eq in Hone.
unfold single_reorder_step_aux in Hone; simpl in ×.
unfold match_rrstate_link in Hmatch.
destruct s, s0.
assert (l = reduce_log l0).
{ inv Hmatch; auto. }
subst.
rename l0 into l.
eapply one_step_reorder_refines_reorder with (hi_re_o := reorder_oracle_red)
(lo_re_o := reorder_oracle) in Hone; eauto.
{ destruct Hone as (s0´ & Hone1 & Hone2).
∃ s0´; split; auto.
rewrite single_reorder_step_aux_eq.
unfold single_reorder_step_aux; simpl; eauto. }
{ intros.
generalize relate_reorder_oracles; unfold relate_reorder_oracles_def.
intros.
eapply H1 in H; eauto. }
Qed.
End WITH_GE.
End LinkwithLAsm.
Section LinkSim.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Context `{builtin_idents_norepet_prf: CompCertBuiltins.BuiltinIdentsNorepet}.
Notation LDATA := RData.
Notation LDATAOps := (cdata (cdata_ops := mboot_data_ops) LDATA).
Local Open Scope Z_scope.
Context `{pmap: PartialMap}.
Context `{fair: Fairness}.
Context `{zset_op: ZSet_operation}.
Context `{mc_oracle: !MCLinkOracle}.
Context `{mc_oracle_cond: !MCLinkOracleCond}.
Theorem cl_backward_simulation:
∀ (s: stencil) (CTXT: LAsm.module) (ph: AST.program fundef unit)
(Hmakep: make_program (module_ops:= LAsm.module_ops) s CTXT (mboot ⊕ L64) = OK ph),
backward_simulation
(single_reorder_semantics
(Hmakege := make_program_globalenv (make_program_ops := make_program_ops) _ _ _ _ Hmakep)
(Genv.globalenv ph) s CTXT reorder_oracle_red ph)
(single_reorder_semantics
(Hmakege := make_program_globalenv (make_program_ops := make_program_ops) _ _ _ _ Hmakep)
(Genv.globalenv ph) s CTXT reorder_oracle ph).
Proof.
intros. apply forward_to_backward_simulation; eauto.
- eapply forward_simulation_plus with
(match_states:= match_rrstate_link); intros; eauto; simpl in *; unfold match_rrstate_link in *;
simpl in ×.
+ inv H.
∃ (RState (hdset := hdseting) (Asm.State rs0 m0) nil).
split.
× constructor; eauto.
× constructor; eauto.
+ generalize one_step_reorder_refines_reorder_concrete; simpl.
unfold single_reorder_high_step_aux_ge´.
unfold single_reorder_low_step_aux_ge´.
unfold match_rrstate_link.
intros Hstep.
exploit Hstep; eauto.
intros.
destruct H1 as (s0´ & H1 & H2).
∃ s0´.
split; auto.
apply plus_one; auto.
-
eapply single_reorder_semantics_receptive.
-
eapply single_reorder_semantics_determinate; eauto.
Qed.
End LinkSim.