Anonymous avatar Anonymous committed 7040d4f

Small expansion of the LLVM primitive support; dbl- dbl* dbl/ operations.

Comments (0)

Files changed (3)

 ;;
 
 let init e =
-  let mk_dbl_bin op name =
+  let mk_dbl_bin (op, name, llvm_op) =
     let bin_op (Sfloat a) (Sfloat b) = Sfloat (op a b) in
     set_pf2 e bin_op 
       ~type_:(Fun ([|Float64; Float64|], Float64)) 
       ~llvm:(fun builder (arg1 :: arg2 :: []) -> 
-	       Llvm.build_add arg1 arg2 "" builder)
+	       llvm_op arg1 arg2 "" builder)
       name
   in
 
-  List.iter2 mk_dbl_bin 
-    [(+.); (-.); ( *. ); (/.)]
-    ["dbl+"; "dbl-"; "dbl*"; "dbl/"];
+  List.iter mk_dbl_bin
+    [(+.), "dbl+", Llvm.build_add; 
+     (-.), "dbl-", Llvm.build_sub; 
+     ( *. ), "dbl*", Llvm.build_mul; 
+     (/.), "dbl/", Llvm.build_fdiv] ;
 
   set_pfn e addn "+";
   set_pf1 e add1 "add1";

blub_typecheck.ml

 	  tcheck env e2
 *)
 
+      | A_set (var, expr) ->
+	  let tmap = tcheck r expr in
+	  PMap.add e (PMap.find expr tmap) tmap
+
       | A_let _ | A_set _ | A_callcc _ | A_abs _ ->
 	  printf "sorry, Shawn is lazy and hasn't got this stuff working again yet!!";
 	  raise (Tcheck_failed "")
 	      globals.vars bound_vars
 	    in
 
-	    let () =
+	    let () = try
 	      let free_vars = Blub_closure.find_free bound_vars body in
 	      let num_free = Blub_closure.VarSet.cardinal free_vars in
 	      printf "Function has %d free variables\n%!" num_free;
 		lambda.lam_jitcode <- ([||], llvm_code) :: lambda.lam_jitcode
 	      end;
 	      ()
+	    with Not_found ->
+	      printf "Llvm compilation not successful\n%!"
 	    in
 	    B_abs (lambda , next)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.