From b4e19177cbe87bdea74b7c707938a9df66c37df7 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 14 Sep 2009 21:54:32 +0000 Subject: [PATCH] Expose initializing the native target for the execution engine. llvm-svn: 81800 --- .../ocaml/executionengine/executionengine_ocaml.c | 8 ++++++-- .../ocaml/executionengine/llvm_executionengine.ml | 3 +++ .../ocaml/executionengine/llvm_executionengine.mli | 3 +++ llvm/docs/tutorial/OCamlLangImpl4.html | 2 ++ llvm/docs/tutorial/OCamlLangImpl5.html | 2 ++ llvm/docs/tutorial/OCamlLangImpl6.html | 2 ++ llvm/docs/tutorial/OCamlLangImpl7.html | 2 ++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c b/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c index 647759fb0744..072d583bf8fb 100644 --- a/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c +++ b/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c @@ -24,11 +24,15 @@ #include #include -/* Force the LLVM interpreter, JIT, and native target to be linked in. */ +/* Force the LLVM interpreter and JIT to be linked in. */ void llvm_initialize(void) { LLVMLinkInInterpreter(); LLVMLinkInJIT(); - LLVMInitializeNativeTarget(); +} + +/* unit -> bool */ +CAMLprim value llvm_initialize_native_target(value Unit) { + return Val_bool(LLVMInitializeNativeTarget()); } /* Can't use the recommended caml_named_value mechanism for backwards diff --git a/llvm/bindings/ocaml/executionengine/llvm_executionengine.ml b/llvm/bindings/ocaml/executionengine/llvm_executionengine.ml index cf9acc7cb6b8..c9e8f18b2240 100644 --- a/llvm/bindings/ocaml/executionengine/llvm_executionengine.ml +++ b/llvm/bindings/ocaml/executionengine/llvm_executionengine.ml @@ -109,3 +109,6 @@ module ExecutionEngine = struct *) end + +external initialize_native_target : unit -> bool + = "llvm_initialize_native_target" diff --git a/llvm/bindings/ocaml/executionengine/llvm_executionengine.mli b/llvm/bindings/ocaml/executionengine/llvm_executionengine.mli index 32e2fdf65451..6c2fdfb7868c 100644 --- a/llvm/bindings/ocaml/executionengine/llvm_executionengine.mli +++ b/llvm/bindings/ocaml/executionengine/llvm_executionengine.mli @@ -161,3 +161,6 @@ module ExecutionEngine: sig [ee]. *) val target_data: t -> Llvm_target.TargetData.t end + +external initialize_native_target : unit -> bool + = "llvm_initialize_native_target" diff --git a/llvm/docs/tutorial/OCamlLangImpl4.html b/llvm/docs/tutorial/OCamlLangImpl4.html index 7cd54d9beafd..238fc53392d1 100644 --- a/llvm/docs/tutorial/OCamlLangImpl4.html +++ b/llvm/docs/tutorial/OCamlLangImpl4.html @@ -962,6 +962,8 @@ open Llvm_target open Llvm_scalar_opts let main () = + ignore (initialize_native_target ()); + (* Install standard binary operators. * 1 is the lowest precedence. *) Hashtbl.add Parser.binop_precedence '<' 10; diff --git a/llvm/docs/tutorial/OCamlLangImpl5.html b/llvm/docs/tutorial/OCamlLangImpl5.html index bd22c5e229b4..f19e900c00bd 100644 --- a/llvm/docs/tutorial/OCamlLangImpl5.html +++ b/llvm/docs/tutorial/OCamlLangImpl5.html @@ -1487,6 +1487,8 @@ open Llvm_target open Llvm_scalar_opts let main () = + ignore (initialize_native_target ()); + (* Install standard binary operators. * 1 is the lowest precedence. *) Hashtbl.add Parser.binop_precedence '<' 10; diff --git a/llvm/docs/tutorial/OCamlLangImpl6.html b/llvm/docs/tutorial/OCamlLangImpl6.html index 57131883ada5..2edb22edf632 100644 --- a/llvm/docs/tutorial/OCamlLangImpl6.html +++ b/llvm/docs/tutorial/OCamlLangImpl6.html @@ -1486,6 +1486,8 @@ open Llvm_target open Llvm_scalar_opts let main () = + ignore (initialize_native_target ()); + (* Install standard binary operators. * 1 is the lowest precedence. *) Hashtbl.add Parser.binop_precedence '<' 10; diff --git a/llvm/docs/tutorial/OCamlLangImpl7.html b/llvm/docs/tutorial/OCamlLangImpl7.html index 411e040b93d2..07768214b9a5 100644 --- a/llvm/docs/tutorial/OCamlLangImpl7.html +++ b/llvm/docs/tutorial/OCamlLangImpl7.html @@ -1816,6 +1816,8 @@ open Llvm_target open Llvm_scalar_opts let main () = + ignore (initialize_native_target ()); + (* Install standard binary operators. * 1 is the lowest precedence. *) Hashtbl.add Parser.binop_precedence '=' 2;