summaryrefslogtreecommitdiffstats
path: root/llvm/bindings/ocaml/target/target_ocaml.c
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2014-10-29 08:15:54 +0000
committerPeter Zotov <whitequark@whitequark.org>2014-10-29 08:15:54 +0000
commit662538ac404c94ddfb92bd9def67d0e5034b45ec (patch)
treed9c72364adb81b10779fb8f900720d9518027255 /llvm/bindings/ocaml/target/target_ocaml.c
parente447b61c5036a7d0e3ff680ed46a9dfab33c431a (diff)
downloadbcm5719-llvm-662538ac404c94ddfb92bd9def67d0e5034b45ec.tar.gz
bcm5719-llvm-662538ac404c94ddfb92bd9def67d0e5034b45ec.zip
[OCaml] Drop support for 3.12.1 and earlier.
In practice this means: * Always using -g flag. * Embedding -cclib -lstdc++ into the corresponding cma/cmxa file. This also moves -lstdc++ in a single place. * Using caml_named_value instead of a homegrown mechanism. llvm-svn: 220843
Diffstat (limited to 'llvm/bindings/ocaml/target/target_ocaml.c')
-rw-r--r--llvm/bindings/ocaml/target/target_ocaml.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/llvm/bindings/ocaml/target/target_ocaml.c b/llvm/bindings/ocaml/target/target_ocaml.c
index 74e81858271..fea3eff174a 100644
--- a/llvm/bindings/ocaml/target/target_ocaml.c
+++ b/llvm/bindings/ocaml/target/target_ocaml.c
@@ -21,17 +21,10 @@
#include "caml/fail.h"
#include "caml/memory.h"
#include "caml/custom.h"
+#include "caml/callback.h"
/*===---- Exceptions ------------------------------------------------------===*/
-static value llvm_target_error_exn;
-
-CAMLprim value llvm_register_target_exns(value Error) {
- llvm_target_error_exn = Field(Error, 0);
- register_global_root(&llvm_target_error_exn);
- return Val_unit;
-}
-
static void llvm_raise(value Prototype, char *Message) {
CAMLparam1(Prototype);
CAMLlocal1(CamlMessage);
@@ -40,10 +33,7 @@ static void llvm_raise(value Prototype, char *Message) {
LLVMDisposeMessage(Message);
raise_with_arg(Prototype, CamlMessage);
- abort(); /* NOTREACHED */
-#ifdef CAMLnoreturn
- CAMLnoreturn; /* Silences warnings, but is missing in some versions. */
-#endif
+ CAMLnoreturn;
}
static value llvm_string_of_message(char* Message) {
@@ -62,15 +52,13 @@ static void llvm_finalize_data_layout(value DataLayout) {
}
static struct custom_operations llvm_data_layout_ops = {
- (char *) "LLVMDataLayout",
+ (char *) "Llvm_target.DataLayout.t",
llvm_finalize_data_layout,
custom_compare_default,
custom_hash_default,
custom_serialize_default,
- custom_deserialize_default
-#ifdef custom_compare_ext_default
- , custom_compare_ext_default
-#endif
+ custom_deserialize_default,
+ custom_compare_ext_default
};
value llvm_alloc_data_layout(LLVMTargetDataRef DataLayout) {
@@ -219,7 +207,7 @@ CAMLprim LLVMTargetRef llvm_target_by_triple(value Triple) {
char *Error;
if(LLVMGetTargetFromTriple(String_val(Triple), &T, &Error))
- llvm_raise(llvm_target_error_exn, Error);
+ llvm_raise(*caml_named_value("Llvm_target.Error"), Error);
return T;
}
@@ -258,15 +246,13 @@ static void llvm_finalize_target_machine(value Machine) {
}
static struct custom_operations llvm_target_machine_ops = {
- (char *) "LLVMTargetMachine",
+ (char *) "Llvm_target.TargetMachine.t",
llvm_finalize_target_machine,
custom_compare_default,
custom_hash_default,
custom_serialize_default,
- custom_deserialize_default
-#ifdef custom_compare_ext_default
- , custom_compare_ext_default
-#endif
+ custom_deserialize_default,
+ custom_compare_ext_default
};
static value llvm_alloc_targetmachine(LLVMTargetMachineRef Machine) {
@@ -337,6 +323,7 @@ CAMLprim value llvm_targetmachine_features(value Machine) {
CAMLprim value llvm_targetmachine_data_layout(value Machine) {
CAMLparam1(Machine);
CAMLlocal1(DataLayout);
+ char *TargetDataCStr;
/* LLVMGetTargetMachineData returns a pointer owned by the TargetMachine,
so it is impossible to wrap it with llvm_alloc_target_data, which assumes
@@ -344,7 +331,6 @@ CAMLprim value llvm_targetmachine_data_layout(value Machine) {
LLVMTargetDataRef OrigDataLayout;
OrigDataLayout = LLVMGetTargetMachineData(TargetMachine_val(Machine));
- char* TargetDataCStr;
TargetDataCStr = LLVMCopyStringRepOfTargetData(OrigDataLayout);
DataLayout = llvm_alloc_data_layout(LLVMCreateTargetData(TargetDataCStr));
LLVMDisposeMessage(TargetDataCStr);
@@ -361,12 +347,12 @@ CAMLprim value llvm_targetmachine_set_verbose_asm(value Verb, value Machine) {
/* Llvm.llmodule -> CodeGenFileType.t -> string -> TargetMachine.t -> unit */
CAMLprim value llvm_targetmachine_emit_to_file(LLVMModuleRef Module,
value FileType, value FileName, value Machine) {
- char* ErrorMessage;
+ char *ErrorMessage;
if(LLVMTargetMachineEmitToFile(TargetMachine_val(Machine), Module,
String_val(FileName), Int_val(FileType),
&ErrorMessage)) {
- llvm_raise(llvm_target_error_exn, ErrorMessage);
+ llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage);
}
return Val_unit;
@@ -377,13 +363,13 @@ CAMLprim value llvm_targetmachine_emit_to_file(LLVMModuleRef Module,
CAMLprim LLVMMemoryBufferRef llvm_targetmachine_emit_to_memory_buffer(
LLVMModuleRef Module, value FileType,
value Machine) {
- char* ErrorMessage;
+ char *ErrorMessage;
LLVMMemoryBufferRef Buffer;
if(LLVMTargetMachineEmitToMemoryBuffer(TargetMachine_val(Machine), Module,
Int_val(FileType), &ErrorMessage,
&Buffer)) {
- llvm_raise(llvm_target_error_exn, ErrorMessage);
+ llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage);
}
return Buffer;
OpenPOWER on IntegriCloud