Commits

camlspotter committed 72c57e2

added sqrt_intr.ml, a use of intrinsics

  • Participants
  • Parent commits 03bcdcb

Comments (0)

Files changed (3)

 \#.*
 examples/pi$
 examples/sqrt$
+examples/sqrt_intr$
+

File lib/build.ml

   let icmp c = cmp "icmped" (Llvm.build_icmp c)
   let fcmp c = cmp "fcmped" (Llvm.build_fcmp c)
 
+  let ( +! )  x = add  ?name:None x
+  let ( -! )  x = sub  ?name:None x
+  let ( *! )  x = mul  ?name:None x
+  let ( /! )  x = sdiv ?name:None x
+  let ( +.! ) x = fadd ?name:None x
+  let ( -.! ) x = fsub ?name:None x
+  let ( *.! ) x = fmul ?name:None x
+  let ( /.! ) x = fdiv ?name:None x
+  (* let icmp c = cmp "icmped" (Llvm.build_icmp c)
+     let fcmp c = cmp "fcmped" (Llvm.build_fcmp c) *)
+
   (** Arithmetic type conversion *)
 
   let sitofp ?(name="sitofped") i ty = 
   let alloca ?(name="inStack") ty =
     unsafeM & Llvm.build_alloca !<ty name
 
+  let alloca_with ?name ty v = perform
+    ptr <-- alloca ?name ty;
+    Gep.(gep_store v ~dst:ptr (pos 0) end_);
+    return ptr
+
   (** Useful libc functions *)
 
   let printf : string -> unknown v list -> unit m = 

File lib/build_intf.ml

   val icmp : Llvm.Icmp.t -> ?name:string -> ([>`int] as 'a) v -> 'a v -> i1 v m
   val fcmp : Llvm.Fcmp.t -> ?name:string -> ([>`floating] as 'a) v -> 'a v -> i1 v m
 
+  (* To remember _E_xclamation for _E_lElVeeEm *)
+  val ( +!  ) : ([>`int] as 'a) v -> 'a v -> 'a v m
+  val ( -!  ) :  ([>`int] as 'a) v -> 'a v -> 'a v m
+  val ( *!  ) :  ([>`int] as 'a) v -> 'a v -> 'a v m
+  val ( /!  ) : ([>`int] as 'a) v -> 'a v -> 'a v m
+  val ( +.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
+  val ( -.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
+  val ( *.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
+  val ( /.! ) : ([>`floating] as 'a) v -> 'a v -> 'a v m
 
   (** {6 Arithmetic type conversion} *)
 
   (** {6 Memory}  *)
 
   val alloca : ?name:string -> 'a typ -> 'a pointer v m
-
+  val alloca_with : ?name:string -> 'a typ -> 'a v -> 'a pointer v m
 
   (** {6 Useful libc functions} *)