From 25b9b003178002360d666919f2e49e7f5f4a36e2 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 4 Feb 2012 19:14:14 +0000 Subject: Merge of the "volatile" branch: - native treatment of volatile accesses in CompCert C's semantics - translation of volatile accesses to built-ins in SimplExpr - native treatment of struct assignment and passing struct parameter by value - only passing struct result by value remains emulated - in cparser, remove emulations that are no longer used - added C99's type _Bool and used it to express || and && more efficiently. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1814 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- ia32/Asm.v | 2 +- ia32/SelectOp.vp | 15 +++++++++++++++ ia32/SelectOpproof.v | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) (limited to 'ia32') diff --git a/ia32/Asm.v b/ia32/Asm.v index 63149aa..e2176fd 100644 --- a/ia32/Asm.v +++ b/ia32/Asm.v @@ -848,7 +848,7 @@ Ltac Equalities := exploit external_call_determ. eexact H3. eexact H8. intros [A B]. split. auto. intros. destruct B; auto. subst. auto. (* trace length *) - inv H; simpl. + red; intros; inv H; simpl. omega. eapply external_call_trace_length; eauto. eapply external_call_trace_length; eauto. diff --git a/ia32/SelectOp.vp b/ia32/SelectOp.vp index 71dc83b..98db388 100644 --- a/ia32/SelectOp.vp +++ b/ia32/SelectOp.vp @@ -62,6 +62,21 @@ Definition addrstack (ofs: int) := Definition notint (e: expr) := Eop (Oxorimm Int.mone) (e ::: Enil). +(** ** Boolean value and boolean negation *) + +Fixpoint boolval (e: expr) {struct e} : expr := + let default := Eop (Ocmp (Ccompuimm Cne Int.zero)) (e ::: Enil) in + match e with + | Eop (Ointconst n) Enil => + Eop (Ointconst (if Int.eq n Int.zero then Int.zero else Int.one)) Enil + | Eop (Ocmp cond) args => + Eop (Ocmp cond) args + | Econdition e1 e2 e3 => + Econdition e1 (boolval e2) (boolval e3) + | _ => + default + end. + (** ** Boolean negation *) Fixpoint notbool (e: expr) {struct e} : expr := diff --git a/ia32/SelectOpproof.v b/ia32/SelectOpproof.v index f14b6a9..e6fd809 100644 --- a/ia32/SelectOpproof.v +++ b/ia32/SelectOpproof.v @@ -138,6 +138,31 @@ Proof. unfold notint; red; intros. TrivialExists. Qed. +Theorem eval_boolval: unary_constructor_sound boolval Val.boolval. +Proof. + assert (DFL: + forall le a x, + eval_expr ge sp e m le a x -> + exists v, eval_expr ge sp e m le (Eop (Ocmp (Ccompuimm Cne Int.zero)) (a ::: Enil)) v + /\ Val.lessdef (Val.boolval x) v). + intros. TrivialExists. simpl. destruct x; simpl; auto. + + red. induction a; simpl; intros; eauto. destruct o; eauto. +(* intconst *) + destruct e0; eauto. InvEval. TrivialExists. simpl. destruct (Int.eq i Int.zero); auto. +(* cmp *) + inv H. simpl in H5. + destruct (eval_condition c vl m) as []_eqn. + TrivialExists. simpl. inv H5. rewrite Heqo. destruct b; auto. + simpl in H5. inv H5. + exists Vundef; split; auto. EvalOp; simpl. rewrite Heqo; auto. + +(* condition *) + inv H. destruct v1. + exploit IHa1; eauto. intros [v [A B]]. exists v; split; auto. eapply eval_Econdition; eauto. + exploit IHa2; eauto. intros [v [A B]]. exists v; split; auto. eapply eval_Econdition; eauto. +Qed. + Theorem eval_notbool: unary_constructor_sound notbool Val.notbool. Proof. assert (DFL: -- cgit v1.2.3