summaryrefslogtreecommitdiff
path: root/powerpc/SelectOp.vp
diff options
context:
space:
mode:
Diffstat (limited to 'powerpc/SelectOp.vp')
-rw-r--r--powerpc/SelectOp.vp15
1 files changed, 14 insertions, 1 deletions
diff --git a/powerpc/SelectOp.vp b/powerpc/SelectOp.vp
index 3bb5544..08968f7 100644
--- a/powerpc/SelectOp.vp
+++ b/powerpc/SelectOp.vp
@@ -69,7 +69,20 @@ Nondetfunction notint (e: expr) :=
| _ => Elet e (Eop Onor (Eletvar O ::: Eletvar O ::: 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