From 173e6c25b2937d6e6941973aa7b116e1d6405513 Mon Sep 17 00:00:00 2001 From: Léo Gourdin Date: Tue, 2 Nov 2021 10:10:34 +0100 Subject: Porting the BTL non-trap loads approach to RTL --- backend/Unusedglobproof.v | 88 ++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 43 deletions(-) (limited to 'backend/Unusedglobproof.v') diff --git a/backend/Unusedglobproof.v b/backend/Unusedglobproof.v index aaacf9d1..b9d73a42 100644 --- a/backend/Unusedglobproof.v +++ b/backend/Unusedglobproof.v @@ -910,50 +910,52 @@ Proof. econstructor; eauto. apply set_reg_inject; auto. - (* load *) - assert (A: exists ta, - eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = Some ta - /\ Val.inject j a ta). - { apply eval_addressing_inj with (ge1 := ge) (sp1 := Vptr sp0 Ptrofs.zero) (vl1 := rs##args). - intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. - apply KEPT. red. exists pc, (Iload trap chunk addr args dst pc'); auto. - econstructor; eauto. - apply regs_inject; auto. - assumption. } - destruct A as (ta & B & C). - exploit Mem.loadv_inject; eauto. intros (tv & D & E). - econstructor; split. eapply exec_Iload; eauto. - econstructor; eauto. apply set_reg_inject; auto. - -- (* load notrap1 *) - assert (eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = None). - { eapply eval_addressing_inj_none. - intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. - apply KEPT. red. exists pc, (Iload NOTRAP chunk addr args dst pc'); auto. - econstructor; eauto. - rewrite Ptrofs.add_zero; reflexivity. - apply regs_inject; auto. - eassumption. - assumption. } - - econstructor; split. eapply exec_Iload_notrap1; eauto. - econstructor; eauto. apply set_reg_inject; auto. - -- (* load notrap2 *) - assert (A: exists ta, - eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = Some ta - /\ Val.inject j a ta). - { apply eval_addressing_inj with (ge1 := ge) (sp1 := Vptr sp0 Ptrofs.zero) (vl1 := rs##args). - intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. - apply KEPT. red. exists pc, (Iload NOTRAP chunk addr args dst pc'); auto. - econstructor; eauto. - apply regs_inject; auto. - assumption. } - destruct A as (ta & B & C). - destruct (Mem.loadv chunk tm ta) eqn:Echunk2. - + econstructor; split. eapply exec_Iload; eauto. - econstructor; eauto. apply set_reg_inject; auto. - + econstructor; split. eapply exec_Iload_notrap2; eauto. + inv H0. + + assert (A: exists ta, + eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = Some ta + /\ Val.inject j a ta). + { apply eval_addressing_inj with (ge1 := ge) (sp1 := Vptr sp0 Ptrofs.zero) (vl1 := rs##args). + intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. + apply KEPT. red. exists pc, (Iload trap chunk addr args dst pc'); auto. + econstructor; eauto. + apply regs_inject; auto. + assumption. } + destruct A as (ta & B & C). + exploit Mem.loadv_inject; eauto. intros (tv & D & E). + econstructor; split. eapply exec_Iload; eauto. eapply has_loaded_normal; eauto. econstructor; eauto. apply set_reg_inject; auto. + + destruct (eval_addressing) eqn:EVAL in LOAD. + * specialize (LOAD v). + assert (A: exists ta, + eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = Some ta + /\ Val.inject j v ta). + { apply eval_addressing_inj with (ge1 := ge) (sp1 := Vptr sp0 Ptrofs.zero) (vl1 := rs##args). + intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. + apply KEPT. red. exists pc, (Iload NOTRAP chunk addr args dst pc'); auto. + econstructor; eauto. + apply regs_inject; auto. + assumption. } + destruct A as (ta & B & C). + destruct (Mem.loadv chunk tm ta) eqn:Echunk2. + ** econstructor; split. eapply exec_Iload; eauto. eapply has_loaded_normal; eauto. + econstructor; eauto. apply set_reg_inject; auto. + ** econstructor; split. eapply exec_Iload; eauto. eapply has_loaded_default; eauto. + intros a EVAL'; rewrite B in EVAL'; inv EVAL'. auto. + econstructor; eauto. apply set_reg_inject; auto. + * assert (eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = None). + { eapply eval_addressing_inj_none. + intros. apply symbol_address_inject. eapply match_stacks_preserves_globals; eauto. + apply KEPT. red. exists pc, (Iload NOTRAP chunk addr args dst pc'); auto. + econstructor; eauto. + rewrite Ptrofs.add_zero; reflexivity. + apply regs_inject; auto. + eassumption. + assumption. } + + econstructor; split. eapply exec_Iload; eauto. eapply has_loaded_default; eauto. + intros a EVAL'; rewrite H0 in EVAL'; inv EVAL'. + econstructor; eauto. apply set_reg_inject; auto. + - (* store *) assert (A: exists ta, eval_addressing tge (Vptr tsp Ptrofs.zero) addr trs##args = Some ta -- cgit