summaryrefslogtreecommitdiff
path: root/arm/SelectOp.vp
diff options
context:
space:
mode:
Diffstat (limited to 'arm/SelectOp.vp')
-rw-r--r--arm/SelectOp.vp17
1 files changed, 15 insertions, 2 deletions
diff --git a/arm/SelectOp.vp b/arm/SelectOp.vp
index 432db94..7b8851c 100644
--- a/arm/SelectOp.vp
+++ b/arm/SelectOp.vp
@@ -68,11 +68,24 @@ Nondetfunction notint (e: expr) :=
| _ => Eop Onot (e:::Enil)
end.
-(** ** Boolean negation *)
+(** ** 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.
Fixpoint notbool (e: expr) {struct e} : expr :=
let default := Eop (Ocmp (Ccompuimm Ceq Int.zero)) (e ::: Enil) in
- match e with
+ match e with
| Eop (Ointconst n) Enil =>
Eop (Ointconst (if Int.eq n Int.zero then Int.one else Int.zero)) Enil
| Eop (Ocmp cond) args =>