Commit Graph

7 Commits

Author SHA1 Message Date
Erick Tryzelaar 19e1eec248 Replace ocamlc tests with ocamlopt tests since they're less noisy.
There's a bug with ocamlc that uses "char*" instead of "const char*" for
global string variables. This causes g++ to be very noisy when linking
ocamlc programs. That's why the ocaml test used to cat to /dev/null.
ocamlopt doesn't have this problem, so we can get rid of the >/dev/null,
which may obscure some problems.

llvm-svn: 80968
2009-09-03 23:27:31 +00:00
Erick Tryzelaar 8ce532bfea Convert the rest of the ocaml types and functions to use context.
llvm-svn: 79430
2009-08-19 17:32:24 +00:00
Erick Tryzelaar 5c35b5cf91 Allow passing around LLVMContext in ocaml.
llvm-svn: 79410
2009-08-19 06:40:29 +00:00
Gordon Henriksen e38d542d89 [PR2886] Ignore stderr from ocamlc since it prints unresolvable warnings on some platforms.
llvm-svn: 57976
2008-10-22 12:41:54 +00:00
Gordon Henriksen 0c43064daf Fix a partial application typo.
llvm-svn: 45317
2007-12-22 19:41:30 +00:00
Gordon Henriksen c23b66c58b Added C and Ocaml bindings for functions, basic blocks, and
instruction creation. No support yet for instruction introspection.

Also eliminated allocas from the Ocaml bindings for portability,
and avoided unnecessary casts.

llvm-svn: 42367
2007-09-26 20:56:12 +00:00
Gordon Henriksen 37582f74cd Adding ocaml language bindings for the vmcore and bitwriter libraries. These are
built atop the C language bindings, and user programs can link with them as 
such:

  # Bytecode
  ocamlc -cc g++ llvm.cma llvmbitwriter.cma -o example example.ml
  # Native
  ocamlopt -cc g++ llvm.cmxa llvmbitwriter.cmxa -o example.opt example.ml

The vmcore.ml test exercises most/all of the APIs thus far bound. Unfortunately,
they're not yet numerous enough to write hello world. But:

  $ cat example.ml
  (* example.ml *)
  
  open Llvm
  open Llvm_bitwriter
  
  let _ =
    let filename = Sys.argv.(1) in
    let m = create_module filename in
    
    let v = make_int_constant i32_type 42 false in
    let g = define_global "hello_world" v m in
    
    if not (write_bitcode_file m filename) then exit 1;
    
    dispose_module m;

  $ ocamlc -cc g++ llvm.cma llvm_bitwriter.cma -o example example.ml
  File "example.ml", line 11, characters 6-7:
  Warning Y: unused variable g.
  $ ./example example.bc
  $ llvm-dis < example.bc
  ; ModuleID = '<stdin>'
  @hello_world = global i32 42            ; <i32*> [#uses=0]

The ocaml test cases provide effective tests for the C interfaces.

llvm-svn: 42093
2007-09-18 12:49:39 +00:00