aboutsummaryrefslogtreecommitdiffstats
path: root/ia32
diff options
context:
space:
mode:
Diffstat (limited to 'ia32')
-rw-r--r--ia32/SelectOp.vp7
-rw-r--r--ia32/SelectOpproof.v23
2 files changed, 30 insertions, 0 deletions
diff --git a/ia32/SelectOp.vp b/ia32/SelectOp.vp
index 98db3885..62de4ce1 100644
--- a/ia32/SelectOp.vp
+++ b/ia32/SelectOp.vp
@@ -429,3 +429,10 @@ Nondetfunction addressing (chunk: memory_chunk) (e: expr) :=
| _ => (Aindexed Int.zero, e:::Enil)
end.
+(** ** Turning an expression into a condition *)
+
+Nondetfunction cond_of_expr (e: expr) :=
+ match e with
+ | Eop (Oandimm n) (t1:::Enil) => (Cmasknotzero n, t1:::Enil)
+ | _ => (Ccompuimm Cne Int.zero, e:::Enil)
+ end.
diff --git a/ia32/SelectOpproof.v b/ia32/SelectOpproof.v
index e6fd8098..658a7550 100644
--- a/ia32/SelectOpproof.v
+++ b/ia32/SelectOpproof.v
@@ -753,4 +753,27 @@ Proof.
exists (v :: nil); split. constructor; auto. constructor. subst; simpl. rewrite Int.add_zero; auto.
Qed.
+Theorem eval_cond_of_expr:
+ forall le a v b,
+ eval_expr ge sp e m le a v ->
+ Val.bool_of_val v b ->
+ match cond_of_expr a with (cond, args) =>
+ exists vl,
+ eval_exprlist ge sp e m le args vl /\
+ eval_condition cond vl m = Some b
+ end.
+Proof.
+ intros until v. unfold cond_of_expr; case (cond_of_expr_match a); intros; InvEval.
+ subst v. exists (v1 :: nil); split; auto with evalexpr.
+ simpl. destruct b.
+ generalize (Val.bool_of_true_val2 _ H0); clear H0; intro ISTRUE.
+ destruct v1; simpl in ISTRUE; try contradiction.
+ rewrite Int.eq_false; auto.
+ generalize (Val.bool_of_false_val2 _ H0); clear H0; intro ISFALSE.
+ destruct v1; simpl in ISFALSE; try contradiction.
+ rewrite ISFALSE. rewrite Int.eq_true; auto.
+ exists (v :: nil); split; auto with evalexpr.
+ simpl. inversion H0; simpl. rewrite Int.eq_false; auto. auto. auto.
+Qed.
+
End CMCONSTR.