Commits

camlspotter committed 2a921e8

added land (&!) and not_

  • Participants
  • Parent commits 72c57e2

Comments (0)

Files changed (2)

File lib/build.ml

   (** Arithmetic operations *)
 
   (* CR jfuruse: unfortunately no arith type check is done yet *)      
-  let arith (defname : string) f = 
+  let arith_binop (defname : string) f = 
     fun ?(name=defname) (x : 'a v) (y : 'a v) ->
       (unsafeM (f !<x !<y name) : 'a v m)
   let cmp (defname : string) f = 
     fun ?(name=defname) (x : 'a v) (y : 'a v) ->
       (unsafeM (f !<x !<y name) : i1 v m)
 
-  let add  ?name = arith "added" Llvm.build_add ?name
-  let sub  ?name = arith "subed" Llvm.build_sub ?name
-  let mul  ?name = arith "muled" Llvm.build_mul ?name
-  let sdiv ?name = arith "sdived" Llvm.build_sdiv ?name
-  let fadd ?name = arith "fadded" Llvm.build_fadd ?name
-  let fsub ?name = arith "fsubed" Llvm.build_fsub ?name
-  let fmul ?name = arith "fmuled" Llvm.build_fmul ?name
-  let fdiv ?name = arith "fdived" Llvm.build_fdiv ?name
+  let add  ?name = arith_binop "added" Llvm.build_add ?name
+  let sub  ?name = arith_binop "subed" Llvm.build_sub ?name
+  let mul  ?name = arith_binop "muled" Llvm.build_mul ?name
+  let sdiv ?name = arith_binop "sdived" Llvm.build_sdiv ?name
+  let fadd ?name = arith_binop "fadded" Llvm.build_fadd ?name
+  let fsub ?name = arith_binop "fsubed" Llvm.build_fsub ?name
+  let fmul ?name = arith_binop "fmuled" Llvm.build_fmul ?name
+  let fdiv ?name = arith_binop "fdived" Llvm.build_fdiv ?name
   let icmp c = cmp "icmped" (Llvm.build_icmp c)
   let fcmp c = cmp "fcmped" (Llvm.build_fcmp c)
 
   (* let icmp c = cmp "icmped" (Llvm.build_icmp c)
      let fcmp c = cmp "fcmped" (Llvm.build_fcmp c) *)
 
+  let land_ ?name = arith_binop "anded" Llvm.build_and ?name
+  let ( &! )  x = land_ ?name:None x
+
+  let arith_unop (defname : string) f = 
+    fun ?(name=defname) (x : 'a v) ->
+      (unsafeM (f !<x name) : 'a v m)
+  let not_ ?name = arith_unop "noted" Llvm.build_not ?name
+
   (** Arithmetic type conversion *)
 
   let sitofp ?(name="sitofped") i ty = 

File lib/build_intf.ml

   val ( *.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
   val ( /.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
 
+  val land_ : ?name:string -> ([>`int] as 'a) Value.v -> 'a Value.v -> 'a Value.v m
+  val ( &! ) : ([>`int] as 'a) Value.v -> 'a Value.v -> 'a Value.v m
+
+  val not_ : ?name:string -> ([>`int] as 'a) Value.v -> 'a Value.v m
+  (* CR jfuruse: or i1? *)
+
   (** {6 Arithmetic type conversion} *)
 
   val sitofp : ?name:string -> [>`int] v -> ([>`floating] as 'a) typ -> 'a v m