diff --git a/llvm/bindings/ocaml/all_backends/all_backends_ocaml.c b/llvm/bindings/ocaml/all_backends/all_backends_ocaml.c --- a/llvm/bindings/ocaml/all_backends/all_backends_ocaml.c +++ b/llvm/bindings/ocaml/all_backends/all_backends_ocaml.c @@ -10,6 +10,9 @@ |* This file glues LLVM's OCaml interface to its C interface. These functions *| |* are by and large transparent wrappers to the corresponding C functions. *| |* *| +|* Note that these functions intentionally take liberties with the CAMLparamX *| +|* macros, since most of the parameters are not GC heap objects. *| +|* *| \*===----------------------------------------------------------------------===*/ #include "llvm-c/Target.h" diff --git a/llvm/bindings/ocaml/analysis/analysis_ocaml.c b/llvm/bindings/ocaml/analysis/analysis_ocaml.c --- a/llvm/bindings/ocaml/analysis/analysis_ocaml.c +++ b/llvm/bindings/ocaml/analysis/analysis_ocaml.c @@ -10,6 +10,9 @@ |* This file glues LLVM's OCaml interface to its C interface. These functions *| |* are by and large transparent wrappers to the corresponding C functions. *| |* *| +|* Note that these functions intentionally take liberties with the CAMLparamX *| +|* macros, since most of the parameters are not GC heap objects. *| +|* *| \*===----------------------------------------------------------------------===*/ #include "llvm-c/Analysis.h" @@ -42,23 +45,20 @@ /* Llvm.llvalue -> bool */ value llvm_verify_function(value Fn) { - CAMLparam1(Fn); - CAMLreturn( - Val_bool(LLVMVerifyFunction(Value_val(Fn), LLVMReturnStatusAction) == 0)); + return Val_bool(LLVMVerifyFunction(Value_val(Fn), LLVMReturnStatusAction) == + 0); } /* Llvm.llmodule -> unit */ value llvm_assert_valid_module(value M) { - CAMLparam1(M); LLVMVerifyModule(Module_val(M), LLVMAbortProcessAction, 0); - CAMLreturn(Val_unit); + return Val_unit; } /* Llvm.llvalue -> unit */ value llvm_assert_valid_function(value Fn) { - CAMLparam1(Fn); LLVMVerifyFunction(Value_val(Fn), LLVMAbortProcessAction); - CAMLreturn(Val_unit); + return Val_unit; } /* Llvm.llvalue -> unit */ diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.h b/llvm/bindings/ocaml/llvm/llvm_ocaml.h --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.h +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.h @@ -33,6 +33,8 @@ value caml_alloc_some(value); #endif +/* ASSUME: Pointer is at least 2-bit aligned! Does not allocate on the OCaml + heap. */ value to_val(void *ptr); void *from_val(value v); diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -10,6 +10,9 @@ |* This file glues LLVM's OCaml interface to its C interface. These functions *| |* are by and large transparent wrappers to the corresponding C functions. *| |* *| +|* Note that these functions intentionally take liberties with the CAMLparamX *| +|* macros, since most of the parameters are not GC heap objects. *| +|* *| \*===----------------------------------------------------------------------===*/ #include @@ -32,23 +35,9 @@ } #endif -value to_val(void *ptr) { - if ((((value)ptr) & 1) == 0) { - return ((value)ptr) + 1; - } else { - value v = caml_alloc(1, Abstract_tag); - *((void **)Data_abstract_val(v)) = ptr; - return v; - } -} +value to_val(void *ptr) { return ((value)ptr) + 1; } -void *from_val(value v) { - if (Is_long(v)) { - return (void *)(v - 1); - } else { - return *((void **)Data_abstract_val(v)); - } -} +void *from_val(value v) { return (void *)(v - 1); } value llvm_string_of_message(char *Message) { value String = caml_copy_string(Message); @@ -140,42 +129,34 @@ #define DEFINE_ITERATORS(camlname, cname, pty_val, cty, cty_val, pfun) \ /* llmodule -> ('a, 'b) llpos */ \ value llvm_##camlname##_begin(value Mom) { \ - CAMLparam1(Mom); \ cty First = LLVMGetFirst##cname(pty_val(Mom)); \ - if (First) { \ - CAMLreturn(alloc_variant(1, to_val(First))); \ - } \ - CAMLreturn(alloc_variant(0, Mom)); \ + if (First) \ + return alloc_variant(1, to_val(First)); \ + return alloc_variant(0, Mom); \ } \ \ /* llvalue -> ('a, 'b) llpos */ \ value llvm_##camlname##_succ(value Kid) { \ - CAMLparam1(Kid); \ cty Next = LLVMGetNext##cname(cty_val(Kid)); \ - if (Next) { \ - CAMLreturn(alloc_variant(1, to_val(Next))); \ - } \ - CAMLreturn(alloc_variant(0, to_val(pfun(cty_val(Kid))))); \ + if (Next) \ + return alloc_variant(1, to_val(Next)); \ + return alloc_variant(0, to_val(pfun(cty_val(Kid)))); \ } \ \ /* llmodule -> ('a, 'b) llrev_pos */ \ value llvm_##camlname##_end(value Mom) { \ - CAMLparam1(Mom); \ cty Last = LLVMGetLast##cname(pty_val(Mom)); \ - if (Last) { \ - CAMLreturn(alloc_variant(1, to_val(Last))); \ - } \ - CAMLreturn(alloc_variant(0, Mom)); \ + if (Last) \ + return alloc_variant(1, to_val(Last)); \ + return alloc_variant(0, Mom); \ } \ \ /* llvalue -> ('a, 'b) llrev_pos */ \ value llvm_##camlname##_pred(value Kid) { \ - CAMLparam1(Kid); \ cty Prev = LLVMGetPrevious##cname(cty_val(Kid)); \ - if (Prev) { \ - CAMLreturn(alloc_variant(1, to_val(Prev))); \ - } \ - CAMLreturn(alloc_variant(0, to_val(pfun(cty_val(Kid))))); \ + if (Prev) \ + return alloc_variant(1, to_val(Prev)); \ + return alloc_variant(0, to_val(pfun(cty_val(Kid)))); \ } /*===-- Context error handling --------------------------------------------===*/ @@ -197,7 +178,7 @@ } static void llvm_remove_diagnostic_handler(value C) { - CAMLparam1(C); + CAMLparam0(); LLVMContextRef context = Context_val(C); if (LLVMContextGetDiagnosticHandler(context) == llvm_diagnostic_handler_trampoline) { @@ -210,7 +191,7 @@ /* llcontext -> (Diagnostic.t -> unit) option -> unit */ value llvm_set_diagnostic_handler(value C, value Handler) { - CAMLparam2(C, Handler); + CAMLparam1(Handler); LLVMContextRef context = Context_val(C); llvm_remove_diagnostic_handler(C); if (Handler == Val_none) { @@ -230,28 +211,21 @@ /*===-- Contexts ----------------------------------------------------------===*/ /* unit -> llcontext */ -value llvm_create_context(value Unit) { - CAMLparam1(Unit); - CAMLreturn(to_val(LLVMContextCreate())); -} +value llvm_create_context(value Unit) { return to_val(LLVMContextCreate()); } /* llcontext -> unit */ value llvm_dispose_context(value C) { - CAMLparam1(C); llvm_remove_diagnostic_handler(C); LLVMContextDispose(Context_val(C)); - CAMLreturn(Val_unit); + return Val_unit; } /* unit -> llcontext */ -value llvm_global_context(value Unit) { - CAMLparam1(Unit); - CAMLreturn(to_val(LLVMGetGlobalContext())); -} +value llvm_global_context(value Unit) { return to_val(LLVMGetGlobalContext()); } /* llcontext -> string -> int */ value llvm_mdkind_id(value C, value Name) { - CAMLparam2(C, Name); + CAMLparam1(Name); unsigned MDKindID = LLVMGetMDKindIDInContext(Context_val(C), String_val(Name), caml_string_length(Name)); CAMLreturn(Val_int(MDKindID)); @@ -271,32 +245,29 @@ /* llcontext -> int -> int64 -> llattribute */ value llvm_create_enum_attr_by_kind(value C, value Kind, value Value) { - CAMLparam3(C, Kind, Value); + CAMLparam1(Value); CAMLreturn(to_val(LLVMCreateEnumAttribute(Context_val(C), Int_val(Kind), Int64_val(Value)))); } /* llattribute -> bool */ value llvm_is_enum_attr(value A) { - CAMLparam1(A); - CAMLreturn(Val_int(LLVMIsEnumAttribute(Attribute_val(A)))); + return Val_int(LLVMIsEnumAttribute(Attribute_val(A))); } /* llattribute -> llattrkind */ value llvm_get_enum_attr_kind(value A) { - CAMLparam1(A); - CAMLreturn(Val_int(LLVMGetEnumAttributeKind(Attribute_val(A)))); + return Val_int(LLVMGetEnumAttributeKind(Attribute_val(A))); } /* llattribute -> int64 */ value llvm_get_enum_attr_value(value A) { - CAMLparam1(A); - CAMLreturn(caml_copy_int64(LLVMGetEnumAttributeValue(Attribute_val(A)))); + return caml_copy_int64(LLVMGetEnumAttributeValue(Attribute_val(A))); } /* llcontext -> kind:string -> name:string -> llattribute */ value llvm_create_string_attr(value C, value Kind, value Value) { - CAMLparam3(C, Kind, Value); + CAMLparam2(Kind, Value); CAMLreturn(to_val(LLVMCreateStringAttribute( Context_val(C), String_val(Kind), caml_string_length(Kind), String_val(Value), caml_string_length(Value)))); @@ -304,78 +275,71 @@ /* llattribute -> bool */ value llvm_is_string_attr(value A) { - CAMLparam1(A); - CAMLreturn(Val_int(LLVMIsStringAttribute(Attribute_val(A)))); + return Val_int(LLVMIsStringAttribute(Attribute_val(A))); } /* llattribute -> string */ value llvm_get_string_attr_kind(value A) { - CAMLparam1(A); unsigned Length; const char *String = LLVMGetStringAttributeKind(Attribute_val(A), &Length); - CAMLreturn(cstr_to_string(String, Length)); + return cstr_to_string(String, Length); } /* llattribute -> string */ value llvm_get_string_attr_value(value A) { - CAMLparam1(A); unsigned Length; const char *String = LLVMGetStringAttributeValue(Attribute_val(A), &Length); - CAMLreturn(cstr_to_string(String, Length)); + return cstr_to_string(String, Length); } /*===-- Modules -----------------------------------------------------------===*/ /* llcontext -> string -> llmodule */ value llvm_create_module(value C, value ModuleID) { - CAMLparam2(C, ModuleID); + CAMLparam1(ModuleID); CAMLreturn(to_val( LLVMModuleCreateWithNameInContext(String_val(ModuleID), Context_val(C)))); } /* llmodule -> unit */ value llvm_dispose_module(value M) { - CAMLparam1(M); LLVMDisposeModule(Module_val(M)); - CAMLreturn(Val_unit); + return Val_unit; } /* llmodule -> string */ value llvm_target_triple(value M) { - CAMLparam1(M); - CAMLreturn(caml_copy_string(LLVMGetTarget(Module_val(M)))); + return caml_copy_string(LLVMGetTarget(Module_val(M))); } /* string -> llmodule -> unit */ value llvm_set_target_triple(value Trip, value M) { - CAMLparam2(Trip, M); + CAMLparam1(Trip); LLVMSetTarget(Module_val(M), String_val(Trip)); CAMLreturn(Val_unit); } /* llmodule -> string */ value llvm_data_layout(value M) { - CAMLparam1(M); - CAMLreturn(caml_copy_string(LLVMGetDataLayout(Module_val(M)))); + return caml_copy_string(LLVMGetDataLayout(Module_val(M))); } /* string -> llmodule -> unit */ value llvm_set_data_layout(value Layout, value M) { - CAMLparam2(Layout, M); + CAMLparam1(Layout); LLVMSetDataLayout(Module_val(M), String_val(Layout)); CAMLreturn(Val_unit); } /* llmodule -> unit */ value llvm_dump_module(value M) { - CAMLparam1(M); LLVMDumpModule(Module_val(M)); - CAMLreturn(Val_unit); + return Val_unit; } /* string -> llmodule -> unit */ value llvm_print_module(value Filename, value M) { - CAMLparam2(Filename, M); + CAMLparam1(Filename); char *Message; if (LLVMPrintModuleToFile(Module_val(M), String_val(Filename), &Message)) @@ -386,25 +350,23 @@ /* llmodule -> string */ value llvm_string_of_llmodule(value M) { - CAMLparam1(M); char *ModuleCStr = LLVMPrintModuleToString(Module_val(M)); value ModuleStr = caml_copy_string(ModuleCStr); LLVMDisposeMessage(ModuleCStr); - CAMLreturn(ModuleStr); + return ModuleStr; } /* llmodule -> string */ value llvm_get_module_identifier(value M) { - CAMLparam1(M); size_t Len; const char *Name = LLVMGetModuleIdentifier(Module_val(M), &Len); - CAMLreturn(cstr_to_string(Name, (mlsize_t)Len)); + return cstr_to_string(Name, (mlsize_t)Len); } /* llmodule -> string -> unit */ value llvm_set_module_identifier(value M, value Id) { - CAMLparam2(M, Id); + CAMLparam1(Id); LLVMSetModuleIdentifier(Module_val(M), String_val(Id), caml_string_length(Id)); CAMLreturn(Val_unit); @@ -412,21 +374,21 @@ /* llmodule -> string -> unit */ value llvm_set_module_inline_asm(value M, value Asm) { - CAMLparam2(M, Asm); + CAMLparam1(Asm); LLVMSetModuleInlineAsm(Module_val(M), String_val(Asm)); CAMLreturn(Val_unit); } /* llmodule -> string -> llmetadata option */ value llvm_get_module_flag(value M, value Key) { - CAMLparam2(M, Key); + CAMLparam1(Key); CAMLreturn(ptr_to_option(LLVMGetModuleFlag(Module_val(M), String_val(Key), caml_string_length(Key)))); } /* llmodule -> ModuleFlagBehavior.t -> string -> llmetadata -> unit */ value llvm_add_module_flag(value M, value Behaviour, value Key, value Val) { - CAMLparam4(M, Behaviour, Key, Val); + CAMLparam1(Key); LLVMAddModuleFlag(Module_val(M), Int_val(Behaviour), String_val(Key), caml_string_length(Key), Metadata_val(Val)); CAMLreturn(Val_unit); @@ -436,37 +398,33 @@ /* lltype -> TypeKind.t */ value llvm_classify_type(value Ty) { - CAMLparam1(Ty); - CAMLreturn(Val_int(LLVMGetTypeKind(Type_val(Ty)))); + return Val_int(LLVMGetTypeKind(Type_val(Ty))); } /* lltype -> bool */ value llvm_type_is_sized(value Ty) { - CAMLparam1(Ty); - CAMLreturn(Val_bool(LLVMTypeIsSized(Type_val(Ty)))); + return Val_bool(LLVMTypeIsSized(Type_val(Ty))); } /* lltype -> llcontext */ value llvm_type_context(value Ty) { - CAMLparam1(Ty); - CAMLreturn(to_val(LLVMGetTypeContext(Type_val(Ty)))); + return to_val(LLVMGetTypeContext(Type_val(Ty))); } /* lltype -> unit */ value llvm_dump_type(value Val) { - CAMLparam1(Val); #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVMDumpType(Type_val(Val)); #else caml_raise_with_arg(*caml_named_value("Llvm.FeatureDisabled"), caml_copy_string("dump")); #endif - CAMLreturn(Val_unit); + return Val_unit; } /* lltype -> string */ value llvm_string_of_lltype(value M) { - CAMLparam1(M); + CAMLparam0(); CAMLlocal1(TypeStr); char *TypeCStr = LLVMPrintTypeToString(Type_val(M)); TypeStr = caml_copy_string(TypeCStr); @@ -479,84 +437,71 @@ /* llcontext -> lltype */ value llvm_i1_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMInt1TypeInContext(Context_val(Context)))); + return to_val(LLVMInt1TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_i8_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMInt8TypeInContext(Context_val(Context)))); + return to_val(LLVMInt8TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_i16_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMInt16TypeInContext(Context_val(Context)))); + return to_val(LLVMInt16TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_i32_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMInt32TypeInContext(Context_val(Context)))); + return to_val(LLVMInt32TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_i64_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMInt64TypeInContext(Context_val(Context)))); + return to_val(LLVMInt64TypeInContext(Context_val(Context))); } /* llcontext -> int -> lltype */ value llvm_integer_type(value Context, value Width) { - CAMLparam2(Context, Width); - CAMLreturn( - to_val(LLVMIntTypeInContext(Context_val(Context), Int_val(Width)))); + return to_val(LLVMIntTypeInContext(Context_val(Context), Int_val(Width))); } /* lltype -> int */ value llvm_integer_bitwidth(value IntegerTy) { - CAMLparam1(IntegerTy); - CAMLreturn(Val_int(LLVMGetIntTypeWidth(Type_val(IntegerTy)))); + return Val_int(LLVMGetIntTypeWidth(Type_val(IntegerTy))); } /*--... Operations on real types ...........................................--*/ /* llcontext -> lltype */ value llvm_float_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMFloatTypeInContext(Context_val(Context)))); + return to_val(LLVMFloatTypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_double_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMDoubleTypeInContext(Context_val(Context)))); + return to_val(LLVMDoubleTypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_x86fp80_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMX86FP80TypeInContext(Context_val(Context)))); + return to_val(LLVMX86FP80TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_fp128_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMFP128TypeInContext(Context_val(Context)))); + return to_val(LLVMFP128TypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_ppc_fp128_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMPPCFP128TypeInContext(Context_val(Context)))); + return to_val(LLVMPPCFP128TypeInContext(Context_val(Context))); } /*--... Operations on function types .......................................--*/ /* lltype -> lltype array -> lltype */ value llvm_function_type(value RetTy, value ParamTys) { - CAMLparam2(RetTy, ParamTys); + CAMLparam1(ParamTys); size_t len = Wosize_val(ParamTys); LLVMTypeRef *Temp = alloc_temp(ParamTys); LLVMTypeRef Type = LLVMFunctionType(Type_val(RetTy), Temp, len, 0); @@ -566,7 +511,7 @@ /* lltype -> lltype array -> lltype */ value llvm_var_arg_function_type(value RetTy, value ParamTys) { - CAMLparam2(RetTy, ParamTys); + CAMLparam1(ParamTys); size_t len = Wosize_val(ParamTys); LLVMTypeRef *Temp = alloc_temp(ParamTys); LLVMTypeRef Type = LLVMFunctionType(Type_val(RetTy), Temp, len, 1); @@ -576,20 +521,18 @@ /* lltype -> bool */ value llvm_is_var_arg(value FunTy) { - CAMLparam1(FunTy); - CAMLreturn(Val_bool(LLVMIsFunctionVarArg(Type_val(FunTy)))); + return Val_bool(LLVMIsFunctionVarArg(Type_val(FunTy))); } /* lltype -> lltype */ value llvm_return_type(value FunTy) { - CAMLparam1(FunTy); LLVMTypeRef Type = LLVMGetReturnType(Type_val(FunTy)); - CAMLreturn(to_val(Type)); + return to_val(Type); } /* lltype -> lltype array */ value llvm_param_types(value FunTy) { - CAMLparam1(FunTy); + CAMLparam0(); CAMLlocal1(Tys); unsigned Length = LLVMCountParamTypes(Type_val(FunTy)); LLVMTypeRef *Temp = malloc(sizeof(LLVMTypeRef) * Length); @@ -606,7 +549,7 @@ /* llcontext -> lltype array -> lltype */ value llvm_struct_type(value C, value ElementTypes) { - CAMLparam2(C, ElementTypes); + CAMLparam1(ElementTypes); size_t Length = Wosize_val(ElementTypes); LLVMTypeRef *Temp = alloc_temp(ElementTypes); LLVMTypeRef Type = LLVMStructTypeInContext(Context_val(C), Temp, Length, 0); @@ -616,7 +559,7 @@ /* llcontext -> lltype array -> lltype */ value llvm_packed_struct_type(value C, value ElementTypes) { - CAMLparam2(C, ElementTypes); + CAMLparam1(ElementTypes); size_t Length = Wosize_val(ElementTypes); LLVMTypeRef *Temp = alloc_temp(ElementTypes); LLVMTypeRef Type = LLVMStructTypeInContext(Context_val(C), Temp, Length, 1); @@ -626,13 +569,13 @@ /* llcontext -> string -> lltype */ value llvm_named_struct_type(value C, value Name) { - CAMLparam2(C, Name); + CAMLparam1(Name); CAMLreturn(to_val(LLVMStructCreateNamed(Context_val(C), String_val(Name)))); } /* lltype -> lltype array -> bool -> unit */ value llvm_struct_set_body(value Ty, value ElementTypes, value Packed) { - CAMLparam3(Ty, ElementTypes, Packed); + CAMLparam1(ElementTypes); unsigned Length = Wosize_val(ElementTypes); LLVMTypeRef *Temp = alloc_temp(ElementTypes); LLVMStructSetBody(Type_val(Ty), Temp, Length, Bool_val(Packed)); @@ -641,19 +584,17 @@ /* lltype -> string option */ value llvm_struct_name(value Ty) { - CAMLparam1(Ty); const char *CStr = LLVMGetStructName(Type_val(Ty)); size_t Len; - if (!CStr) { - CAMLreturn(Val_none); - } + if (!CStr) + return Val_none; Len = strlen(CStr); - CAMLreturn(cstr_to_string_option(CStr, Len)); + return cstr_to_string_option(CStr, Len); } /* lltype -> lltype array */ value llvm_struct_element_types(value StructTy) { - CAMLparam1(StructTy); + CAMLparam0(); CAMLlocal1(Tys); unsigned Length = LLVMCountStructElementTypes(Type_val(StructTy)); LLVMTypeRef *Temp = alloc_temp(sizeof(LLVMTypeRef) * Length); @@ -668,27 +609,24 @@ /* lltype -> bool */ value llvm_is_packed(value StructTy) { - CAMLparam1(StructTy); - CAMLreturn(Val_bool(LLVMIsPackedStruct(Type_val(StructTy)))); + return Val_bool(LLVMIsPackedStruct(Type_val(StructTy))); } /* lltype -> bool */ value llvm_is_opaque(value StructTy) { - CAMLparam1(StructTy); - CAMLreturn(Val_bool(LLVMIsOpaqueStruct(Type_val(StructTy)))); + return Val_bool(LLVMIsOpaqueStruct(Type_val(StructTy))); } /* lltype -> bool */ value llvm_is_literal(value StructTy) { - CAMLparam1(StructTy); - CAMLreturn(Val_bool(LLVMIsLiteralStruct(Type_val(StructTy)))); + return Val_bool(LLVMIsLiteralStruct(Type_val(StructTy))); } /*--... Operations on array, pointer, and vector types .....................--*/ /* lltype -> lltype array */ value llvm_subtypes(value Ty) { - CAMLparam1(Ty); + CAMLparam0(); CAMLlocal1(Arr); unsigned Length = LLVMGetNumContainedTypes(Type_val(Ty)); Arr = caml_alloc_tuple(Length); @@ -703,82 +641,69 @@ /* lltype -> int -> lltype */ value llvm_array_type(value ElementTy, value Count) { - CAMLparam2(ElementTy, Count); - CAMLreturn(to_val(LLVMArrayType(Type_val(ElementTy), Int_val(Count)))); + return to_val(LLVMArrayType(Type_val(ElementTy), Int_val(Count))); } /* llcontext -> lltype */ value llvm_pointer_type(value C) { - CAMLparam1(C); LLVMTypeRef Type = LLVMPointerTypeInContext(Context_val(C), 0); - CAMLreturn(to_val(Type)); + return to_val(Type); } /* llcontext -> int -> lltype */ value llvm_qualified_pointer_type(value C, value AddressSpace) { - CAMLparam2(C, AddressSpace); LLVMTypeRef Type = LLVMPointerTypeInContext(Context_val(C), Int_val(AddressSpace)); - CAMLreturn(to_val(Type)); + return to_val(Type); } /* lltype -> int -> lltype */ value llvm_vector_type(value ElementTy, value Count) { - CAMLparam2(ElementTy, Count); - CAMLreturn(to_val(LLVMVectorType(Type_val(ElementTy), Int_val(Count)))); + return to_val(LLVMVectorType(Type_val(ElementTy), Int_val(Count))); } /* lltype -> int */ value llvm_array_length(value ArrayTy) { - CAMLparam1(ArrayTy); - CAMLreturn(Val_int(LLVMGetArrayLength(Type_val(ArrayTy)))); + return Val_int(LLVMGetArrayLength(Type_val(ArrayTy))); } /* lltype -> int */ value llvm_address_space(value PtrTy) { - CAMLparam1(PtrTy); - CAMLreturn(Val_int(LLVMGetPointerAddressSpace(Type_val(PtrTy)))); + return Val_int(LLVMGetPointerAddressSpace(Type_val(PtrTy))); } /* lltype -> int */ value llvm_vector_size(value VectorTy) { - CAMLparam1(VectorTy); - CAMLreturn(Val_int(LLVMGetVectorSize(Type_val(VectorTy)))); + return Val_int(LLVMGetVectorSize(Type_val(VectorTy))); } /*--... Operations on other types ..........................................--*/ /* llcontext -> lltype */ value llvm_void_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMVoidTypeInContext(Context_val(Context)))); + return to_val(LLVMVoidTypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_label_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMLabelTypeInContext(Context_val(Context)))); + return to_val(LLVMLabelTypeInContext(Context_val(Context))); } /* llcontext -> lltype */ value llvm_x86_mmx_type(value Context) { - CAMLparam1(Context); - CAMLreturn(to_val(LLVMX86MMXTypeInContext(Context_val(Context)))); + return to_val(LLVMX86MMXTypeInContext(Context_val(Context))); } /* llmodule -> string -> lltype option */ value llvm_type_by_name(value M, value Name) { - CAMLparam2(M, Name); + CAMLparam1(Name); CAMLreturn(ptr_to_option(LLVMGetTypeByName(Module_val(M), String_val(Name)))); } /*===-- VALUES ------------------------------------------------------------===*/ /* llvalue -> lltype */ -value llvm_type_of(value Val) { - CAMLparam1(Val); - CAMLreturn(to_val(LLVMTypeOf(Value_val(Val)))); -} +value llvm_type_of(value Val) { return to_val(LLVMTypeOf(Value_val(Val))); } /* keep in sync with ValueKind.t */ enum ValueKind { @@ -816,7 +741,7 @@ } while (0) value llvm_classify_value(value V) { - CAMLparam1(V); + CAMLparam0(); CAMLlocal1(Result); LLVMValueRef Val = Value_val(V); if (!Val) { @@ -858,27 +783,25 @@ /* llvalue -> string */ value llvm_value_name(value Val) { - CAMLparam1(Val); - CAMLreturn(caml_copy_string(LLVMGetValueName(Value_val(Val)))); + return caml_copy_string(LLVMGetValueName(Value_val(Val))); } /* string -> llvalue -> unit */ value llvm_set_value_name(value Name, value Val) { - CAMLparam2(Name, Val); + CAMLparam1(Name); LLVMSetValueName(Value_val(Val), String_val(Name)); CAMLreturn(Val_unit); } /* llvalue -> unit */ value llvm_dump_value(value Val) { - CAMLparam1(Val); LLVMDumpValue(Value_val(Val)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> string */ value llvm_string_of_llvalue(value M) { - CAMLparam1(M); + CAMLparam0(); CAMLlocal1(ValueStr); char *ValueCStr = LLVMPrintValueToString(Value_val(M)); ValueStr = caml_copy_string(ValueCStr); @@ -889,41 +812,36 @@ /* llvalue -> llvalue -> unit */ value llvm_replace_all_uses_with(value OldVal, value NewVal) { - CAMLparam2(OldVal, NewVal); LLVMReplaceAllUsesWith(Value_val(OldVal), Value_val(NewVal)); - CAMLreturn(Val_unit); + return Val_unit; } /*--... Operations on users ................................................--*/ /* llvalue -> int -> llvalue */ value llvm_operand(value V, value I) { - CAMLparam2(V, I); - CAMLreturn(to_val(LLVMGetOperand(Value_val(V), Int_val(I)))); + return to_val(LLVMGetOperand(Value_val(V), Int_val(I))); } /* llvalue -> int -> lluse */ value llvm_operand_use(value V, value I) { - CAMLparam2(V, I); - CAMLreturn(to_val(LLVMGetOperandUse(Value_val(V), Int_val(I)))); + return to_val(LLVMGetOperandUse(Value_val(V), Int_val(I))); } /* llvalue -> int -> llvalue -> unit */ value llvm_set_operand(value U, value I, value V) { - CAMLparam3(U, I, V); LLVMSetOperand(Value_val(U), Int_val(I), Value_val(V)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int */ value llvm_num_operands(value V) { - CAMLparam1(V); - CAMLreturn(Val_int(LLVMGetNumOperands(Value_val(V)))); + return Val_int(LLVMGetNumOperands(Value_val(V))); } /* llvalue -> int array */ value llvm_indices(value Instr) { - CAMLparam1(Instr); + CAMLparam0(); CAMLlocal1(Array); unsigned Length = LLVMGetNumIndices(Value_val(Instr)); const unsigned *Indices = LLVMGetIndices(Value_val(Instr)); @@ -938,111 +856,93 @@ /* llvalue -> bool */ value llvm_is_constant(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMIsConstant(Value_val(Val)))); + return Val_bool(LLVMIsConstant(Value_val(Val))); } /* lltype -> llvalue */ value llvm_const_null(value Ty) { - CAMLparam1(Ty); LLVMValueRef Value = LLVMConstNull(Type_val(Ty)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue */ value llvm_const_all_ones(value Ty) { - CAMLparam1(Ty); LLVMValueRef Value = LLVMConstAllOnes(Type_val(Ty)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue */ value llvm_const_pointer_null(value Ty) { - CAMLparam1(Ty); LLVMValueRef Value = LLVMConstPointerNull(Type_val(Ty)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue */ value llvm_get_undef(value Ty) { - CAMLparam1(Ty); LLVMValueRef Value = LLVMGetUndef(Type_val(Ty)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue */ value llvm_get_poison(value Ty) { - CAMLparam1(Ty); LLVMValueRef Value = LLVMGetPoison(Type_val(Ty)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> bool */ -value llvm_is_null(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMIsNull(Value_val(Val)))); -} +value llvm_is_null(value Val) { return Val_bool(LLVMIsNull(Value_val(Val))); } /* llvalue -> bool */ -value llvm_is_undef(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMIsUndef(Value_val(Val)))); -} +value llvm_is_undef(value Val) { return Val_bool(LLVMIsUndef(Value_val(Val))); } /* llvalue -> bool */ value llvm_is_poison(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMIsPoison(Value_val(Val)))); + return Val_bool(LLVMIsPoison(Value_val(Val))); } /* llvalue -> Opcode.t */ value llvm_constexpr_get_opcode(value Val) { - CAMLparam1(Val); - CAMLreturn(LLVMIsAConstantExpr(Value_val(Val)) - ? Val_int(LLVMGetConstOpcode(Value_val(Val))) - : Val_int(0)); + return LLVMIsAConstantExpr(Value_val(Val)) + ? Val_int(LLVMGetConstOpcode(Value_val(Val))) + : Val_int(0); } /*--... Operations on instructions .........................................--*/ /* llvalue -> bool */ value llvm_has_metadata(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMHasMetadata(Value_val(Val)))); + return Val_bool(LLVMHasMetadata(Value_val(Val))); } /* llvalue -> int -> llvalue option */ value llvm_metadata(value Val, value MDKindID) { - CAMLparam2(Val, MDKindID); - CAMLreturn(ptr_to_option(LLVMGetMetadata(Value_val(Val), Int_val(MDKindID)))); + return ptr_to_option(LLVMGetMetadata(Value_val(Val), Int_val(MDKindID))); } /* llvalue -> int -> llvalue -> unit */ value llvm_set_metadata(value Val, value MDKindID, value MD) { - CAMLparam3(Val, MDKindID, MD); LLVMSetMetadata(Value_val(Val), Int_val(MDKindID), Value_val(MD)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int -> unit */ value llvm_clear_metadata(value Val, value MDKindID) { - CAMLparam2(Val, MDKindID); LLVMSetMetadata(Value_val(Val), Int_val(MDKindID), NULL); - CAMLreturn(Val_unit); + return Val_unit; } /*--... Operations on metadata .............................................--*/ /* llcontext -> string -> llvalue */ value llvm_mdstring(value C, value S) { - CAMLparam2(C, S); + CAMLparam1(S); CAMLreturn(to_val(LLVMMDStringInContext(Context_val(C), String_val(S), caml_string_length(S)))); } /* llcontext -> llvalue array -> llvalue */ value llvm_mdnode(value C, value ElementVals) { - CAMLparam2(C, ElementVals); + CAMLparam1(ElementVals); unsigned Length = Wosize_val(ElementVals); LLVMValueRef *Temp = alloc_temp(ElementVals); LLVMValueRef Value = LLVMMDNodeInContext(Context_val(C), Temp, Length); @@ -1051,22 +951,18 @@ } /* llcontext -> llvalue */ -value llvm_mdnull(value C) { - CAMLparam1(C); - CAMLreturn(to_val(NULL)); -} +value llvm_mdnull(value C) { return to_val(NULL); } /* llvalue -> string option */ value llvm_get_mdstring(value V) { - CAMLparam1(V); unsigned Len; const char *CStr = LLVMGetMDString(Value_val(V), &Len); - CAMLreturn(cstr_to_string_option(CStr, Len)); + return cstr_to_string_option(CStr, Len); } /* llvalue -> llvalue array */ value llvm_get_mdnode_operands(value Value) { - CAMLparam1(Value); + CAMLparam0(); CAMLlocal1(Operands); LLVMValueRef V = Value_val(Value); unsigned Length = LLVMGetMDNodeNumOperands(V); @@ -1082,7 +978,7 @@ /* llmodule -> string -> llvalue array */ value llvm_get_namedmd(value M, value Name) { - CAMLparam2(M, Name); + CAMLparam1(Name); CAMLlocal1(Nodes); unsigned Length = LLVMGetNamedMetadataNumOperands(Module_val(M), String_val(Name)); @@ -1098,81 +994,71 @@ /* llmodule -> string -> llvalue -> unit */ value llvm_append_namedmd(value M, value Name, value Val) { - CAMLparam3(M, Name, Val); LLVMAddNamedMetadataOperand(Module_val(M), String_val(Name), Value_val(Val)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llmetadata */ value llvm_value_as_metadata(value Val) { - CAMLparam1(Val); - CAMLreturn(to_val(LLVMValueAsMetadata(Value_val(Val)))); + return to_val(LLVMValueAsMetadata(Value_val(Val))); } /* llcontext -> llmetadata -> llvalue */ value llvm_metadata_as_value(value C, value MD) { - CAMLparam2(C, MD); - CAMLreturn(to_val(LLVMMetadataAsValue(Context_val(C), Metadata_val(MD)))); + return to_val(LLVMMetadataAsValue(Context_val(C), Metadata_val(MD))); } /*--... Operations on scalar constants .....................................--*/ /* lltype -> int -> llvalue */ value llvm_const_int(value IntTy, value N) { - CAMLparam2(IntTy, N); - CAMLreturn(to_val(LLVMConstInt(Type_val(IntTy), (long long)Long_val(N), 1))); + return to_val(LLVMConstInt(Type_val(IntTy), (long long)Long_val(N), 1)); } /* lltype -> Int64.t -> bool -> llvalue */ value llvm_const_of_int64(value IntTy, value N, value SExt) { - CAMLparam3(IntTy, N, SExt); - CAMLreturn( - to_val(LLVMConstInt(Type_val(IntTy), Int64_val(N), Bool_val(SExt)))); + return to_val(LLVMConstInt(Type_val(IntTy), Int64_val(N), Bool_val(SExt))); } /* llvalue -> Int64.t option */ value llvm_int64_of_const(value C) { - CAMLparam1(C); LLVMValueRef Const = Value_val(C); if (!(LLVMIsAConstantInt(Const)) || !(LLVMGetIntTypeWidth(LLVMTypeOf(Const)) <= 64)) { - CAMLreturn(Val_none); + return Val_none; } - CAMLreturn(caml_alloc_some(caml_copy_int64(LLVMConstIntGetSExtValue(Const)))); + return caml_alloc_some(caml_copy_int64(LLVMConstIntGetSExtValue(Const))); } /* lltype -> string -> int -> llvalue */ value llvm_const_int_of_string(value IntTy, value S, value Radix) { - CAMLparam3(IntTy, S, Radix); - CAMLreturn(to_val(LLVMConstIntOfStringAndSize( - Type_val(IntTy), String_val(S), caml_string_length(S), Int_val(Radix)))); + return to_val(LLVMConstIntOfStringAndSize( + Type_val(IntTy), String_val(S), caml_string_length(S), Int_val(Radix))); } /* lltype -> float -> llvalue */ value llvm_const_float(value RealTy, value N) { - CAMLparam2(RealTy, N); - CAMLreturn(to_val(LLVMConstReal(Type_val(RealTy), Double_val(N)))); + return to_val(LLVMConstReal(Type_val(RealTy), Double_val(N))); } /* llvalue -> float option */ value llvm_float_of_const(value C) { - CAMLparam1(C); LLVMValueRef Const = Value_val(C); LLVMBool LosesInfo; double Result; if (!LLVMIsAConstantFP(Const)) { - CAMLreturn(Val_none); + return Val_none; } Result = LLVMConstRealGetDouble(Const, &LosesInfo); if (LosesInfo) { - CAMLreturn(Val_none); + return Val_none; } - CAMLreturn(caml_alloc_some(caml_copy_double(Result))); + return caml_alloc_some(caml_copy_double(Result)); } /* lltype -> string -> llvalue */ value llvm_const_float_of_string(value RealTy, value S) { - CAMLparam2(RealTy, S); + CAMLparam1(S); CAMLreturn(to_val(LLVMConstRealOfStringAndSize( Type_val(RealTy), String_val(S), caml_string_length(S)))); } @@ -1180,22 +1066,22 @@ /*--... Operations on composite constants ..................................--*/ /* llcontext -> string -> llvalue */ -value llvm_const_string(value Context, value Str, value NullTerminate) { - CAMLparam3(Context, Str, NullTerminate); +value llvm_const_string(value Context, value Str) { + CAMLparam1(Str); CAMLreturn(to_val(LLVMConstStringInContext( Context_val(Context), String_val(Str), caml_string_length(Str), 1))); } /* llcontext -> string -> llvalue */ -value llvm_const_stringz(value Context, value Str, value NullTerminate) { - CAMLparam3(Context, Str, NullTerminate); +value llvm_const_stringz(value Context, value Str) { + CAMLparam1(Str); CAMLreturn(to_val(LLVMConstStringInContext( Context_val(Context), String_val(Str), caml_string_length(Str), 0))); } /* lltype -> llvalue array -> llvalue */ value llvm_const_array(value ElementTy, value ElementVals) { - CAMLparam2(ElementTy, ElementVals); + CAMLparam1(ElementVals); unsigned Length = Wosize_val(ElementVals); LLVMValueRef *Temp = alloc_temp(ElementVals); LLVMValueRef Value = LLVMConstArray(Type_val(ElementTy), Temp, Length); @@ -1205,7 +1091,7 @@ /* llcontext -> llvalue array -> llvalue */ value llvm_const_struct(value C, value ElementVals) { - CAMLparam2(C, ElementVals); + CAMLparam1(ElementVals); unsigned Length = Wosize_val(ElementVals); LLVMValueRef *Temp = alloc_temp(ElementVals); LLVMValueRef Value = @@ -1216,7 +1102,7 @@ /* lltype -> llvalue array -> llvalue */ value llvm_const_named_struct(value Ty, value ElementVals) { - CAMLparam2(Ty, ElementVals); + CAMLparam1(ElementVals); unsigned Length = Wosize_val(ElementVals); LLVMValueRef *Temp = alloc_temp(ElementVals); LLVMValueRef Value = @@ -1227,7 +1113,7 @@ /* llcontext -> llvalue array -> llvalue */ value llvm_const_packed_struct(value C, value ElementVals) { - CAMLparam2(C, ElementVals); + CAMLparam1(ElementVals); unsigned Length = Wosize_val(ElementVals); LLVMValueRef *Temp = alloc_temp(ElementVals); LLVMValueRef Value = @@ -1248,190 +1134,164 @@ /* llvalue -> string option */ value llvm_string_of_const(value C) { - CAMLparam1(C); size_t Len; const char *CStr; LLVMValueRef Const = Value_val(C); if (!LLVMIsAConstantDataSequential(Const) || !LLVMIsConstantString(Const)) { - CAMLreturn(Val_none); + return Val_none; } CStr = LLVMGetAsString(Const, &Len); - CAMLreturn(cstr_to_string_option(CStr, Len)); + return cstr_to_string_option(CStr, Len); } /* llvalue -> int -> llvalue */ value llvm_const_element(value Const, value N) { - CAMLparam2(Const, N); - CAMLreturn(to_val(LLVMGetElementAsConstant(Value_val(Const), Int_val(N)))); + return to_val(LLVMGetElementAsConstant(Value_val(Const), Int_val(N))); } /*--... Constant expressions ...............................................--*/ /* lltype -> llvalue */ value llvm_align_of(value Type) { - CAMLparam1(Type); LLVMValueRef Value = LLVMAlignOf(Type_val(Type)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue */ value llvm_size_of(value Type) { - CAMLparam1(Type); LLVMValueRef Value = LLVMSizeOf(Type_val(Type)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue */ value llvm_const_neg(value Value) { - CAMLparam1(Value); LLVMValueRef NegValue = LLVMConstNeg(Value_val(Value)); - CAMLreturn(to_val(NegValue)); + return to_val(NegValue); } /* llvalue -> llvalue */ value llvm_const_nsw_neg(value Value) { - CAMLparam1(Value); LLVMValueRef NegValue = LLVMConstNSWNeg(Value_val(Value)); - CAMLreturn(to_val(NegValue)); + return to_val(NegValue); } /* llvalue -> llvalue */ value llvm_const_nuw_neg(value Value) { - CAMLparam1(Value); LLVMValueRef NegValue = LLVMConstNUWNeg(Value_val(Value)); - CAMLreturn(to_val(NegValue)); + return to_val(NegValue); } /* llvalue -> llvalue */ value llvm_const_not(value Value) { - CAMLparam1(Value); LLVMValueRef NotValue = LLVMConstNot(Value_val(Value)); - CAMLreturn(to_val(NotValue)); + return to_val(NotValue); } /* llvalue -> llvalue -> llvalue */ value llvm_const_add(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstAdd(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nsw_add(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNSWAdd(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nuw_add(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNUWAdd(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_sub(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstSub(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nsw_sub(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNSWSub(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nuw_sub(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNUWSub(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_mul(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstMul(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nsw_mul(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNSWMul(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_nuw_mul(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstNUWMul(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_and(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstAnd(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_or(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstOr(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_xor(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstXor(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* Icmp.t -> llvalue -> llvalue -> llvalue */ value llvm_const_icmp(value Pred, value LHSConstant, value RHSConstant) { - CAMLparam3(Pred, LHSConstant, RHSConstant); - CAMLreturn( - to_val(LLVMConstICmp(Int_val(Pred) + LLVMIntEQ, Value_val(LHSConstant), - Value_val(RHSConstant)))); + return to_val(LLVMConstICmp(Int_val(Pred) + LLVMIntEQ, Value_val(LHSConstant), + Value_val(RHSConstant))); } /* Fcmp.t -> llvalue -> llvalue -> llvalue */ value llvm_const_fcmp(value Pred, value LHSConstant, value RHSConstant) { - CAMLparam3(Pred, LHSConstant, RHSConstant); - CAMLreturn(to_val(LLVMConstFCmp(Int_val(Pred), Value_val(LHSConstant), - Value_val(RHSConstant)))); + return to_val(LLVMConstFCmp(Int_val(Pred), Value_val(LHSConstant), + Value_val(RHSConstant))); } /* llvalue -> llvalue -> llvalue */ value llvm_const_shl(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstShl(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_lshr(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstLShr(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_ashr(value LHS, value RHS) { - CAMLparam2(LHS, RHS); LLVMValueRef Value = LLVMConstAShr(Value_val(LHS), Value_val(RHS)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue -> llvalue array -> llvalue */ value llvm_const_gep(value Ty, value ConstantVal, value Indices) { - CAMLparam3(Ty, ConstantVal, Indices); + CAMLparam1(Indices); unsigned Length = Wosize_val(Indices); LLVMValueRef *Temp = alloc_temp(Indices); LLVMValueRef Value = @@ -1442,7 +1302,7 @@ /* llvalue -> llvalue array -> llvalue */ value llvm_const_in_bounds_gep(value ConstantVal, value Indices) { - CAMLparam2(ConstantVal, Indices); + CAMLparam1(Indices); unsigned Length = Wosize_val(Indices); LLVMValueRef *Temp = alloc_temp(Indices); LLVMValueRef Value = @@ -1452,165 +1312,143 @@ /* llvalue -> lltype -> llvalue */ value llvm_const_trunc(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstTrunc(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_sext(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstSExt(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_zext(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstZExt(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_fptrunc(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstFPTrunc(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_fpext(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstFPExt(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_uitofp(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstUIToFP(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_sitofp(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstSIToFP(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_fptoui(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstFPToUI(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_fptosi(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstFPToSI(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_ptrtoint(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstPtrToInt(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_inttoptr(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstIntToPtr(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_bitcast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstBitCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_zext_or_bitcast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstZExtOrBitCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_sext_or_bitcast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstSExtOrBitCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_trunc_or_bitcast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstTruncOrBitCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> llvalue */ value llvm_const_pointercast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstPointerCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> lltype -> is_signed:bool -> llvalue */ value llvm_const_intcast(value CV, value T, value IsSigned) { - CAMLparam3(CV, T, IsSigned); - CAMLreturn( - to_val(LLVMConstIntCast(Value_val(CV), Type_val(T), Bool_val(IsSigned)))); + return to_val( + LLVMConstIntCast(Value_val(CV), Type_val(T), Bool_val(IsSigned))); } /* llvalue -> lltype -> llvalue */ value llvm_const_fpcast(value CV, value T) { - CAMLparam2(CV, T); LLVMValueRef Value = LLVMConstFPCast(Value_val(CV), Type_val(T)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue -> llvalue */ value llvm_const_select(value Cond, value IfTrue, value IfFalse) { - CAMLparam3(Cond, IfTrue, IfFalse); LLVMValueRef Value = LLVMConstSelect(Value_val(Cond), Value_val(IfTrue), Value_val(IfFalse)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue */ value llvm_const_extractelement(value V, value I) { - CAMLparam2(V, I); LLVMValueRef Value = LLVMConstExtractElement(Value_val(V), Value_val(I)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue -> llvalue */ value llvm_const_insertelement(value V, value E, value I) { - CAMLparam3(V, E, I); LLVMValueRef Value = LLVMConstInsertElement(Value_val(V), Value_val(E), Value_val(I)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llvalue -> llvalue -> llvalue -> llvalue */ value llvm_const_shufflevector(value VA, value VB, value Mask) { - CAMLparam3(VA, VB, Mask); LLVMValueRef Value = LLVMConstShuffleVector(Value_val(VA), Value_val(VB), Value_val(Mask)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> string -> string -> bool -> bool -> llvalue */ value llvm_const_inline_asm(value Ty, value Asm, value Constraints, value HasSideEffects, value IsAlignStack) { - CAMLparam5(Ty, Asm, Constraints, HasSideEffects, IsAlignStack); + CAMLparam2(Asm, Constraints); CAMLreturn(to_val( LLVMConstInlineAsm(Type_val(Ty), String_val(Asm), String_val(Constraints), Bool_val(HasSideEffects), Bool_val(IsAlignStack)))); @@ -1618,107 +1456,93 @@ /* llvalue -> llbasicblock -> llvalue */ value llvm_blockaddress(value V, value B) { - CAMLparam2(V, B); LLVMValueRef Value = LLVMBlockAddress(Value_val(V), BasicBlock_val(B)); - CAMLreturn(to_val(Value)); + return to_val(Value); } /*--... Operations on global variables, functions, and aliases (globals) ...--*/ /* llvalue -> llmodule */ value llvm_global_parent(value Value) { - CAMLparam1(Value); LLVMModuleRef Module = LLVMGetGlobalParent(Value_val(Value)); - CAMLreturn(to_val(Module)); + return to_val(Module); } /* llvalue -> bool */ value llvm_is_declaration(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_bool(LLVMIsDeclaration(Value_val(Global)))); + return Val_bool(LLVMIsDeclaration(Value_val(Global))); } /* llvalue -> Linkage.t */ value llvm_linkage(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_int(LLVMGetLinkage(Value_val(Global)))); + return Val_int(LLVMGetLinkage(Value_val(Global))); } /* Linkage.t -> llvalue -> unit */ value llvm_set_linkage(value Linkage, value Global) { - CAMLparam2(Linkage, Global); LLVMSetLinkage(Value_val(Global), Int_val(Linkage)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_unnamed_addr(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_bool(LLVMHasUnnamedAddr(Value_val(Global)))); + return Val_bool(LLVMHasUnnamedAddr(Value_val(Global))); } /* bool -> llvalue -> unit */ value llvm_set_unnamed_addr(value UseUnnamedAddr, value Global) { - CAMLparam2(UseUnnamedAddr, Global); LLVMSetUnnamedAddr(Value_val(Global), Bool_val(UseUnnamedAddr)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> string */ value llvm_section(value Global) { - CAMLparam1(Global); - CAMLreturn(caml_copy_string(LLVMGetSection(Value_val(Global)))); + return caml_copy_string(LLVMGetSection(Value_val(Global))); } /* string -> llvalue -> unit */ value llvm_set_section(value Section, value Global) { - CAMLparam2(Section, Global); + CAMLparam1(Section); LLVMSetSection(Value_val(Global), String_val(Section)); CAMLreturn(Val_unit); } /* llvalue -> Visibility.t */ value llvm_visibility(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_int(LLVMGetVisibility(Value_val(Global)))); + return Val_int(LLVMGetVisibility(Value_val(Global))); } /* Visibility.t -> llvalue -> unit */ value llvm_set_visibility(value Viz, value Global) { - CAMLparam2(Viz, Global); LLVMSetVisibility(Value_val(Global), Int_val(Viz)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> DLLStorageClass.t */ value llvm_dll_storage_class(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_int(LLVMGetDLLStorageClass(Value_val(Global)))); + return Val_int(LLVMGetDLLStorageClass(Value_val(Global))); } /* DLLStorageClass.t -> llvalue -> unit */ value llvm_set_dll_storage_class(value Viz, value Global) { - CAMLparam2(Viz, Global); LLVMSetDLLStorageClass(Value_val(Global), Int_val(Viz)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int */ value llvm_alignment(value Global) { - CAMLparam1(Global); - CAMLreturn(Val_int(LLVMGetAlignment(Value_val(Global)))); + return Val_int(LLVMGetAlignment(Value_val(Global))); } /* int -> llvalue -> unit */ value llvm_set_alignment(value Bytes, value Global) { - CAMLparam2(Bytes, Global); LLVMSetAlignment(Value_val(Global), Int_val(Bytes)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> (llmdkind * llmetadata) array */ value llvm_global_copy_all_metadata(value Global) { - CAMLparam1(Global); + CAMLparam0(); CAMLlocal1(Array); size_t NumEntries; LLVMValueMetadataEntry *Entries = @@ -1739,26 +1563,20 @@ /* llvalue -> lluse option */ value llvm_use_begin(value Val) { - CAMLparam1(Val); - CAMLreturn(ptr_to_option(LLVMGetFirstUse(Value_val(Val)))); + return ptr_to_option(LLVMGetFirstUse(Value_val(Val))); } /* lluse -> lluse option */ value llvm_use_succ(value U) { - CAMLparam1(U); - CAMLreturn(ptr_to_option(LLVMGetNextUse(Use_val(U)))); + return ptr_to_option(LLVMGetNextUse(Use_val(U))); } /* lluse -> llvalue */ -value llvm_user(value UR) { - CAMLparam1(UR); - CAMLreturn(to_val(LLVMGetUser(Use_val(UR)))); -} +value llvm_user(value UR) { return to_val(LLVMGetUser(Use_val(UR))); } /* lluse -> llvalue */ value llvm_used_value(value UR) { - CAMLparam1(UR); - CAMLreturn(to_val(LLVMGetUsedValue(Use_val(UR)))); + return to_val(LLVMGetUsedValue(Use_val(UR))); } /*--... Operations on global variables .....................................--*/ @@ -1768,7 +1586,7 @@ /* lltype -> string -> llmodule -> llvalue */ value llvm_declare_global(value Ty, value Name, value M) { - CAMLparam3(Ty, Name, M); + CAMLparam1(Name); LLVMValueRef GlobalVar; if ((GlobalVar = LLVMGetNamedGlobal(Module_val(M), String_val(Name)))) { if (LLVMGlobalGetValueType(GlobalVar) != Type_val(Ty)) { @@ -1784,7 +1602,7 @@ /* lltype -> string -> int -> llmodule -> llvalue */ value llvm_declare_qualified_global(value Ty, value Name, value AddressSpace, value M) { - CAMLparam4(Ty, Name, AddressSpace, M); + CAMLparam1(Name); LLVMValueRef GlobalVar; if ((GlobalVar = LLVMGetNamedGlobal(Module_val(M), String_val(Name)))) { if (LLVMGlobalGetValueType(GlobalVar) != Type_val(Ty)) { @@ -1799,14 +1617,14 @@ /* string -> llmodule -> llvalue option */ value llvm_lookup_global(value Name, value M) { - CAMLparam2(Name, M); + CAMLparam1(Name); CAMLreturn( ptr_to_option(LLVMGetNamedGlobal(Module_val(M), String_val(Name)))); } /* string -> llvalue -> llmodule -> llvalue */ value llvm_define_global(value Name, value Initializer, value M) { - CAMLparam3(Name, Initializer, M); + CAMLparam1(Name); LLVMValueRef GlobalVar = LLVMAddGlobal( Module_val(M), LLVMTypeOf(Value_val(Initializer)), String_val(Name)); LLVMSetInitializer(GlobalVar, Value_val(Initializer)); @@ -1816,7 +1634,7 @@ /* string -> llvalue -> int -> llmodule -> llvalue */ value llvm_define_qualified_global(value Name, value Initializer, value AddressSpace, value M) { - CAMLparam4(Name, Initializer, AddressSpace, M); + CAMLparam1(Name); LLVMValueRef GlobalVar = LLVMAddGlobalInAddressSpace( Module_val(M), LLVMTypeOf(Value_val(Initializer)), String_val(Name), Int_val(AddressSpace)); @@ -1826,83 +1644,71 @@ /* llvalue -> unit */ value llvm_delete_global(value GlobalVar) { - CAMLparam1(GlobalVar); LLVMDeleteGlobal(Value_val(GlobalVar)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llvalue option */ value llvm_global_initializer(value GlobalVar) { - CAMLparam1(GlobalVar); - CAMLreturn(ptr_to_option(LLVMGetInitializer(Value_val(GlobalVar)))); + return ptr_to_option(LLVMGetInitializer(Value_val(GlobalVar))); } /* llvalue -> llvalue -> unit */ value llvm_set_initializer(value ConstantVal, value GlobalVar) { - CAMLparam2(ConstantVal, GlobalVar); LLVMSetInitializer(Value_val(GlobalVar), Value_val(ConstantVal)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> unit */ value llvm_remove_initializer(value GlobalVar) { - CAMLparam1(GlobalVar); LLVMSetInitializer(Value_val(GlobalVar), NULL); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_thread_local(value GlobalVar) { - CAMLparam1(GlobalVar); - CAMLreturn(Val_bool(LLVMIsThreadLocal(Value_val(GlobalVar)))); + return Val_bool(LLVMIsThreadLocal(Value_val(GlobalVar))); } /* bool -> llvalue -> unit */ value llvm_set_thread_local(value IsThreadLocal, value GlobalVar) { - CAMLparam2(IsThreadLocal, GlobalVar); LLVMSetThreadLocal(Value_val(GlobalVar), Bool_val(IsThreadLocal)); - CAMLreturn(Val_unit); + Val_unit; } /* llvalue -> ThreadLocalMode.t */ value llvm_thread_local_mode(value GlobalVar) { - CAMLparam1(GlobalVar); - CAMLreturn(Val_int(LLVMGetThreadLocalMode(Value_val(GlobalVar)))); + return Val_int(LLVMGetThreadLocalMode(Value_val(GlobalVar))); } /* ThreadLocalMode.t -> llvalue -> unit */ value llvm_set_thread_local_mode(value ThreadLocalMode, value GlobalVar) { - CAMLparam2(ThreadLocalMode, GlobalVar); LLVMSetThreadLocalMode(Value_val(GlobalVar), Int_val(ThreadLocalMode)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_externally_initialized(value GlobalVar) { - CAMLparam1(GlobalVar); - CAMLreturn(Val_bool(LLVMIsExternallyInitialized(Value_val(GlobalVar)))); + return Val_bool(LLVMIsExternallyInitialized(Value_val(GlobalVar))); } /* bool -> llvalue -> unit */ value llvm_set_externally_initialized(value IsExternallyInitialized, value GlobalVar) { - CAMLparam2(IsExternallyInitialized, GlobalVar); LLVMSetExternallyInitialized(Value_val(GlobalVar), Bool_val(IsExternallyInitialized)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_global_constant(value GlobalVar) { - CAMLparam1(GlobalVar); - CAMLreturn(Val_bool(LLVMIsGlobalConstant(Value_val(GlobalVar)))); + return Val_bool(LLVMIsGlobalConstant(Value_val(GlobalVar))); } /* bool -> llvalue -> unit */ value llvm_set_global_constant(value Flag, value GlobalVar) { - CAMLparam2(Flag, GlobalVar); LLVMSetGlobalConstant(Value_val(GlobalVar), Bool_val(Flag)); - CAMLreturn(Val_unit); + return Val_unit; } /*--... Operations on aliases ..............................................--*/ @@ -1910,7 +1716,7 @@ /* llmodule -> lltype -> int -> llvalue -> string -> llvalue */ value llvm_add_alias(value M, value ValueTy, value AddrSpace, value Aliasee, value Name) { - CAMLparam5(M, ValueTy, AddrSpace, Aliasee, Name); + CAMLparam1(Name); CAMLreturn( to_val(LLVMAddAlias2(Module_val(M), Type_val(ValueTy), Int_val(AddrSpace), Value_val(Aliasee), String_val(Name)))); @@ -1923,7 +1729,7 @@ /* string -> lltype -> llmodule -> llvalue */ value llvm_declare_function(value Name, value Ty, value M) { - CAMLparam3(Name, Ty, M); + CAMLparam1(Name); LLVMValueRef Fn; if ((Fn = LLVMGetNamedFunction(Module_val(M), String_val(Name)))) { if (LLVMGlobalGetValueType(Fn) != Type_val(Ty)) { @@ -1938,14 +1744,14 @@ /* string -> llmodule -> llvalue option */ value llvm_lookup_function(value Name, value M) { - CAMLparam2(Name, M); + CAMLparam1(Name); CAMLreturn( ptr_to_option(LLVMGetNamedFunction(Module_val(M), String_val(Name)))); } /* string -> lltype -> llmodule -> llvalue */ value llvm_define_function(value Name, value Ty, value M) { - CAMLparam3(Name, Ty, M); + CAMLparam1(Name); LLVMValueRef Fn = LLVMAddFunction(Module_val(M), String_val(Name), Type_val(Ty)); LLVMAppendBasicBlockInContext(LLVMGetTypeContext(Type_val(Ty)), Fn, "entry"); @@ -1954,57 +1760,51 @@ /* llvalue -> unit */ value llvm_delete_function(value Fn) { - CAMLparam1(Fn); LLVMDeleteFunction(Value_val(Fn)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_intrinsic(value Fn) { - CAMLparam1(Fn); - CAMLreturn(Val_bool(LLVMGetIntrinsicID(Value_val(Fn)))); + return Val_bool(LLVMGetIntrinsicID(Value_val(Fn))); } /* llvalue -> int */ value llvm_function_call_conv(value Fn) { - CAMLparam1(Fn); - CAMLreturn(Val_int(LLVMGetFunctionCallConv(Value_val(Fn)))); + return Val_int(LLVMGetFunctionCallConv(Value_val(Fn))); } /* int -> llvalue -> unit */ value llvm_set_function_call_conv(value Id, value Fn) { - CAMLparam1(Fn); LLVMSetFunctionCallConv(Value_val(Fn), Int_val(Id)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> string option */ value llvm_gc(value Fn) { - CAMLparam1(Fn); const char *GC = LLVMGetGC(Value_val(Fn)); if (!GC) { - CAMLreturn(Val_none); + return Val_none; } - CAMLreturn(caml_alloc_some(caml_copy_string(GC))); + return caml_alloc_some(caml_copy_string(GC)); } /* string option -> llvalue -> unit */ value llvm_set_gc(value GC, value Fn) { - CAMLparam2(GC, Fn); + CAMLparam1(GC); LLVMSetGC(Value_val(Fn), GC == Val_none ? 0 : String_val(Field(GC, 0))); CAMLreturn(Val_unit); } /* llvalue -> llattribute -> int -> unit */ value llvm_add_function_attr(value F, value A, value Index) { - CAMLparam3(F, A, Index); LLVMAddAttributeAtIndex(Value_val(F), Int_val(Index), Attribute_val(A)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int -> llattribute array */ value llvm_function_attrs(value F, value Index) { - CAMLparam2(F, Index); + CAMLparam0(); CAMLlocal1(Array); unsigned Length = LLVMGetAttributeCountAtIndex(Value_val(F), Int_val(Index)); Array = caml_alloc_tuple(Length); @@ -2019,14 +1819,13 @@ /* llvalue -> llattrkind -> int -> unit */ value llvm_remove_enum_function_attr(value F, value Kind, value Index) { - CAMLparam3(F, Kind, Index); LLVMRemoveEnumAttributeAtIndex(Value_val(F), Int_val(Index), Int_val(Kind)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> string -> int -> unit */ value llvm_remove_string_function_attr(value F, value Kind, value Index) { - CAMLparam3(F, Kind, Index); + CAMLparam1(Kind); LLVMRemoveStringAttributeAtIndex(Value_val(F), Int_val(Index), String_val(Kind), caml_string_length(Kind)); CAMLreturn(Val_unit); @@ -2039,13 +1838,12 @@ /* llvalue -> int -> llvalue */ value llvm_param(value Fn, value Index) { - CAMLparam2(Fn, Index); - CAMLreturn(to_val(LLVMGetParam(Value_val(Fn), Int_val(Index)))); + return to_val(LLVMGetParam(Value_val(Fn), Int_val(Index))); } /* llvalue -> llvalue array */ value llvm_params(value Fn) { - CAMLparam1(Fn); + CAMLparam0(); CAMLlocal1(Params); unsigned Length = LLVMCountParams(Value_val(Fn)); LLVMValueRef *Temp = malloc(sizeof(LLVMValueRef) * Length); @@ -2060,40 +1858,35 @@ /* llvalue -> llvalue */ value llvm_param_parent(value Value) { - CAMLparam1(Value); LLVMValueRef Parent = LLVMGetParamParent(Value_val(Value)); - CAMLreturn(to_val(Parent)); + return to_val(Parent); } /*--... Operations on basic blocks .........................................--*/ /* llbasicblock -> llvalue */ value llvm_value_of_block(value BB) { - CAMLparam1(BB); - CAMLreturn(to_val(LLVMBasicBlockAsValue(BasicBlock_val(BB)))); + return to_val(LLVMBasicBlockAsValue(BasicBlock_val(BB))); } /* llvalue -> bool */ value llvm_value_is_block(value Val) { - CAMLparam1(Val); - CAMLreturn(Val_bool(LLVMValueIsBasicBlock(Value_val(Val)))); + return Val_bool(LLVMValueIsBasicBlock(Value_val(Val))); } /* llbasicblock -> llvalue */ value llvm_block_of_value(value Val) { - CAMLparam1(Val); - CAMLreturn(to_val(LLVMValueAsBasicBlock(Value_val(Val)))); + return to_val(LLVMValueAsBasicBlock(Value_val(Val))); } /* llbasicblock -> llvalue */ value llvm_block_parent(value BB) { - CAMLparam1(BB); - CAMLreturn(to_val(LLVMGetBasicBlockParent(BasicBlock_val(BB)))); + return to_val(LLVMGetBasicBlockParent(BasicBlock_val(BB))); } /* llvalue -> llbasicblock array */ value llvm_basic_blocks(value Fn) { - CAMLparam1(Fn); + CAMLparam0(); CAMLlocal1(MLArray); unsigned Length = LLVMCountBasicBlocks(Value_val(Fn)); LLVMBasicBlockRef *Temp = malloc(sizeof(LLVMBasicBlockRef) * Length); @@ -2108,9 +1901,8 @@ /* llvalue -> llbasicblock */ value llvm_entry_block(value Val) { - CAMLparam1(Val); LLVMBasicBlockRef BB = LLVMGetEntryBasicBlock(Value_val(Val)); - CAMLreturn(to_val(BB)); + return to_val(BB); } DEFINE_ITERATORS(block, BasicBlock, Value_val, LLVMBasicBlockRef, @@ -2118,48 +1910,43 @@ /* llbasicblock -> llvalue option */ value llvm_block_terminator(value Block) { - CAMLparam1(Block); - CAMLreturn(ptr_to_option(LLVMGetBasicBlockTerminator(BasicBlock_val(Block)))); + return ptr_to_option(LLVMGetBasicBlockTerminator(BasicBlock_val(Block))); } /* llbasicblock -> unit */ value llvm_delete_block(value BB) { - CAMLparam1(BB); LLVMDeleteBasicBlock(BasicBlock_val(BB)); - CAMLreturn(Val_unit); + return Val_unit; } /* llbasicblock -> unit */ value llvm_remove_block(value BB) { - CAMLparam1(BB); LLVMRemoveBasicBlockFromParent(BasicBlock_val(BB)); - CAMLreturn(Val_unit); + return Val_unit; } /* llbasicblock -> llbasicblock -> unit */ value llvm_move_block_before(value Pos, value BB) { - CAMLparam2(Pos, BB); LLVMMoveBasicBlockBefore(BasicBlock_val(BB), BasicBlock_val(Pos)); - CAMLreturn(Val_unit); + return Val_unit; } /* llbasicblock -> llbasicblock -> unit */ value llvm_move_block_after(value Pos, value BB) { - CAMLparam2(Pos, BB); LLVMMoveBasicBlockAfter(BasicBlock_val(BB), BasicBlock_val(Pos)); - CAMLreturn(Val_unit); + return Val_unit; } /* string -> llvalue -> llbasicblock */ value llvm_append_block(value Context, value Name, value Fn) { - CAMLparam3(Context, Name, Fn); + CAMLparam1(Name); CAMLreturn(to_val(LLVMAppendBasicBlockInContext( Context_val(Context), Value_val(Fn), String_val(Name)))); } /* llcontext -> string -> llbasicblock -> llbasicblock */ value llvm_insert_block(value Context, value Name, value BB) { - CAMLparam3(Context, Name, BB); + CAMLparam1(Name); CAMLreturn(to_val(LLVMInsertBasicBlockInContext( Context_val(Context), BasicBlock_val(BB), String_val(Name)))); } @@ -2168,9 +1955,8 @@ /* llvalue -> llbasicblock */ value llvm_instr_parent(value Inst) { - CAMLparam1(Inst); LLVMBasicBlockRef BB = LLVMGetInstructionParent(Value_val(Inst)); - CAMLreturn(to_val(BB)); + return to_val(BB); } DEFINE_ITERATORS(instr, Instruction, BasicBlock_val, LLVMValueRef, Value_val, @@ -2178,68 +1964,59 @@ /* llvalue -> Opcode.t */ value llvm_instr_get_opcode(value Inst) { - CAMLparam1(Inst); LLVMOpcode o; if (!LLVMIsAInstruction(Value_val(Inst))) caml_failwith("Not an instruction"); o = LLVMGetInstructionOpcode(Value_val(Inst)); assert(o <= LLVMFreeze); - CAMLreturn(Val_int(o)); + return Val_int(o); } /* llvalue -> ICmp.t option */ value llvm_instr_icmp_predicate(value Val) { - CAMLparam1(Val); int x = LLVMGetICmpPredicate(Value_val(Val)); - if (!x) { - CAMLreturn(Val_none); - } - CAMLreturn(caml_alloc_some(Val_int(x - LLVMIntEQ))); + if (!x) + return Val_none; + return caml_alloc_some(Val_int(x - LLVMIntEQ)); } /* llvalue -> FCmp.t option */ value llvm_instr_fcmp_predicate(value Val) { - CAMLparam1(Val); int x = LLVMGetFCmpPredicate(Value_val(Val)); - if (!x) { - CAMLreturn(Val_none); - } - CAMLreturn(caml_alloc_some(Val_int(x - LLVMRealPredicateFalse))); + if (!x) + return Val_none; + return caml_alloc_some(Val_int(x - LLVMRealPredicateFalse)); } /* llvalue -> llvalue */ value llvm_instr_clone(value Inst) { - CAMLparam1(Inst); if (!LLVMIsAInstruction(Value_val(Inst))) caml_failwith("Not an instruction"); - CAMLreturn(to_val(LLVMInstructionClone(Value_val(Inst)))); + return to_val(LLVMInstructionClone(Value_val(Inst))); } /*--... Operations on call sites ...........................................--*/ /* llvalue -> int */ value llvm_instruction_call_conv(value Inst) { - CAMLparam1(Inst); - CAMLreturn(Val_int(LLVMGetInstructionCallConv(Value_val(Inst)))); + return Val_int(LLVMGetInstructionCallConv(Value_val(Inst))); } /* int -> llvalue -> unit */ value llvm_set_instruction_call_conv(value CC, value Inst) { - CAMLparam2(CC, Inst); LLVMSetInstructionCallConv(Value_val(Inst), Int_val(CC)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llattribute -> int -> unit */ value llvm_add_call_site_attr(value F, value A, value Index) { - CAMLparam3(F, A, Index); LLVMAddCallSiteAttribute(Value_val(F), Int_val(Index), Attribute_val(A)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int -> llattribute array */ value llvm_call_site_attrs(value F, value Index) { - CAMLparam2(F, Index); + CAMLparam0(); CAMLlocal2(Temp, Array); unsigned Length = LLVMGetCallSiteAttributeCount(Value_val(F), Int_val(Index)); Temp = caml_alloc(1, Abstract_tag); @@ -2254,14 +2031,13 @@ /* llvalue -> llattrkind -> int -> unit */ value llvm_remove_enum_call_site_attr(value F, value Kind, value Index) { - CAMLparam3(F, Kind, Index); LLVMRemoveCallSiteEnumAttribute(Value_val(F), Int_val(Index), Int_val(Kind)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> string -> int -> unit */ value llvm_remove_string_call_site_attr(value F, value Kind, value Index) { - CAMLparam3(F, Kind, Index); + CAMLparam1(Kind); LLVMRemoveCallSiteStringAttribute(Value_val(F), Int_val(Index), String_val(Kind), caml_string_length(Kind)); CAMLreturn(Val_unit); @@ -2271,99 +2047,84 @@ /* llvalue -> int */ value llvm_num_arg_operands(value V) { - CAMLparam1(V); - CAMLreturn(Val_int(LLVMGetNumArgOperands(Value_val(V)))); + return Val_int(LLVMGetNumArgOperands(Value_val(V))); } /* llvalue -> bool */ value llvm_is_tail_call(value CallInst) { - CAMLparam1(CallInst); - CAMLreturn(Val_bool(LLVMIsTailCall(Value_val(CallInst)))); + return Val_bool(LLVMIsTailCall(Value_val(CallInst))); } /* bool -> llvalue -> unit */ value llvm_set_tail_call(value IsTailCall, value CallInst) { - CAMLparam2(IsTailCall, CallInst); LLVMSetTailCall(Value_val(CallInst), Bool_val(IsTailCall)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llbasicblock */ value llvm_get_normal_dest(value Val) { - CAMLparam1(Val); LLVMBasicBlockRef BB = LLVMGetNormalDest(Value_val(Val)); - CAMLreturn(to_val(BB)); + return to_val(BB); } /* llvalue -> llbasicblock */ value llvm_get_unwind_dest(value Val) { - CAMLparam1(Val); LLVMBasicBlockRef BB = LLVMGetUnwindDest(Value_val(Val)); - CAMLreturn(to_val(BB)); + return to_val(BB); } /*--... Operations on load/store instructions (only)........................--*/ /* llvalue -> bool */ value llvm_is_volatile(value MemoryInst) { - CAMLparam1(MemoryInst); - CAMLreturn(Val_bool(LLVMGetVolatile(Value_val(MemoryInst)))); + return Val_bool(LLVMGetVolatile(Value_val(MemoryInst))); } /* bool -> llvalue -> unit */ value llvm_set_volatile(value IsVolatile, value MemoryInst) { - CAMLparam1(MemoryInst); LLVMSetVolatile(Value_val(MemoryInst), Bool_val(IsVolatile)); - CAMLreturn(Val_unit); + return Val_unit; } /*--.. Operations on terminators ...........................................--*/ /* llvalue -> int -> llbasicblock */ value llvm_successor(value V, value I) { - CAMLparam2(V, I); - CAMLreturn(to_val(LLVMGetSuccessor(Value_val(V), Int_val(I)))); + return to_val(LLVMGetSuccessor(Value_val(V), Int_val(I))); } /* llvalue -> int -> llvalue -> unit */ value llvm_set_successor(value U, value I, value B) { - CAMLparam3(U, I, B); LLVMSetSuccessor(Value_val(U), Int_val(I), BasicBlock_val(B)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> int */ value llvm_num_successors(value V) { - CAMLparam1(V); - CAMLreturn(Val_int(LLVMGetNumSuccessors(Value_val(V)))); + return Val_int(LLVMGetNumSuccessors(Value_val(V))); } /*--.. Operations on branch ................................................--*/ /* llvalue -> llvalue */ -value llvm_condition(value V) { - CAMLparam1(V); - CAMLreturn(to_val(LLVMGetCondition(Value_val(V)))); -} +value llvm_condition(value V) { return to_val(LLVMGetCondition(Value_val(V))); } /* llvalue -> llvalue -> unit */ value llvm_set_condition(value B, value C) { - CAMLparam2(B, C); LLVMSetCondition(Value_val(B), Value_val(C)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_conditional(value V) { - CAMLparam1(V); - CAMLreturn(Val_bool(LLVMIsConditional(Value_val(V)))); + return Val_bool(LLVMIsConditional(Value_val(V))); } /*--... Operations on phi nodes ............................................--*/ /* (llvalue * llbasicblock) -> llvalue -> unit */ value llvm_add_incoming(value Incoming, value PhiNode) { - CAMLparam2(Incoming, PhiNode); + CAMLparam1(Incoming); LLVMValueRef V = Value_val(Field(Incoming, 0)); LLVMBasicBlockRef BB = BasicBlock_val(Field(Incoming, 1)); LLVMAddIncoming(Value_val(PhiNode), &V, &BB, 1); @@ -2372,7 +2133,7 @@ /* llvalue -> (llvalue * llbasicblock) list */ value llvm_incoming(value Phi) { - CAMLparam1(Phi); + CAMLparam0(); CAMLlocal5(Hd, Tl, V, BB, List); LLVMValueRef PhiNode = Value_val(Phi); @@ -2396,9 +2157,8 @@ /* llvalue -> unit */ value llvm_delete_instruction(value Instruction) { - CAMLparam1(Instruction); LLVMInstructionEraseFromParent(Value_val(Instruction)); - CAMLreturn(Val_unit); + return Val_unit; } /*===-- Instruction builders ----------------------------------------------===*/ @@ -2423,13 +2183,11 @@ /* llcontext -> llbuilder */ value llvm_builder(value C) { - CAMLparam1(C); - CAMLreturn(alloc_builder(LLVMCreateBuilderInContext(Context_val(C)))); + return alloc_builder(LLVMCreateBuilderInContext(Context_val(C))); } /* (llbasicblock, llvalue) llpos -> llbuilder -> unit */ value llvm_position_builder(value Pos, value B) { - CAMLparam2(Pos, B); if (Tag_val(Pos) == 0) { LLVMBasicBlockRef BB = BasicBlock_val(Field(Pos, 0)); LLVMPositionBuilderAtEnd(Builder_val(B), BB); @@ -2437,7 +2195,7 @@ LLVMValueRef I = Value_val(Field(Pos, 0)); LLVMPositionBuilderBefore(Builder_val(B), I); } - CAMLreturn(Val_unit); + return Val_unit; } /* llbuilder -> llbasicblock */ @@ -2451,25 +2209,22 @@ /* llvalue -> string -> llbuilder -> unit */ value llvm_insert_into_builder(value I, value Name, value B) { - CAMLparam3(I, Name, B); LLVMInsertIntoBuilderWithName(Builder_val(B), Value_val(I), String_val(Name)); - CAMLreturn(Val_unit); + return Val_unit; } /*--... Metadata ...........................................................--*/ /* llbuilder -> llvalue -> unit */ value llvm_set_current_debug_location(value B, value V) { - CAMLparam2(B, V); LLVMSetCurrentDebugLocation(Builder_val(B), Value_val(V)); - CAMLreturn(Val_unit); + return Val_unit; } /* llbuilder -> unit */ value llvm_clear_current_debug_location(value B) { - CAMLparam1(B); LLVMSetCurrentDebugLocation(Builder_val(B), NULL); - CAMLreturn(Val_unit); + return Val_unit; } /* llbuilder -> llvalue option */ @@ -2480,118 +2235,100 @@ /* llbuilder -> llvalue -> unit */ value llvm_set_inst_debug_location(value B, value V) { - CAMLparam2(B, V); LLVMSetInstDebugLocation(Builder_val(B), Value_val(V)); - CAMLreturn(Val_unit); + return Val_unit; } /*--... Terminators ........................................................--*/ /* llbuilder -> llvalue */ value llvm_build_ret_void(value B) { - CAMLparam1(B); - CAMLreturn(to_val(LLVMBuildRetVoid(Builder_val(B)))); + return to_val(LLVMBuildRetVoid(Builder_val(B))); } /* llvalue -> llbuilder -> llvalue */ value llvm_build_ret(value Val, value B) { - CAMLparam2(Val, B); - CAMLreturn(to_val(LLVMBuildRet(Builder_val(B), Value_val(Val)))); + return to_val(LLVMBuildRet(Builder_val(B), Value_val(Val))); } /* llvalue array -> llbuilder -> llvalue */ value llvm_build_aggregate_ret(value RetVals, value B) { - CAMLparam2(RetVals, B); unsigned Length = Wosize_val(RetVals); LLVMValueRef *Temp = alloc_temp(RetVals); LLVMValueRef Value = LLVMBuildAggregateRet(Builder_val(B), Temp, Length); free(Temp); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* llbasicblock -> llbuilder -> llvalue */ value llvm_build_br(value BB, value B) { - CAMLparam2(BB, B); - CAMLreturn(to_val(LLVMBuildBr(Builder_val(B), BasicBlock_val(BB)))); + return to_val(LLVMBuildBr(Builder_val(B), BasicBlock_val(BB))); } /* llvalue -> llbasicblock -> llbasicblock -> llbuilder -> llvalue */ value llvm_build_cond_br(value If, value Then, value Else, value B) { - CAMLparam4(If, Then, Else, B); - CAMLreturn( - to_val(LLVMBuildCondBr(Builder_val(B), Value_val(If), - BasicBlock_val(Then), BasicBlock_val(Else)))); + return to_val(LLVMBuildCondBr(Builder_val(B), Value_val(If), + BasicBlock_val(Then), BasicBlock_val(Else))); } /* llvalue -> llbasicblock -> int -> llbuilder -> llvalue */ value llvm_build_switch(value Of, value Else, value EstimatedCount, value B) { - CAMLparam4(Of, Else, EstimatedCount, B); - CAMLreturn( - to_val(LLVMBuildSwitch(Builder_val(B), Value_val(Of), - BasicBlock_val(Else), Int_val(EstimatedCount)))); + return to_val(LLVMBuildSwitch(Builder_val(B), Value_val(Of), + BasicBlock_val(Else), Int_val(EstimatedCount))); } /* lltype -> string -> llbuilder -> llvalue */ value llvm_build_malloc(value Ty, value Name, value B) { - CAMLparam3(Ty, Name, B); - CAMLreturn( - to_val(LLVMBuildMalloc(Builder_val(B), Type_val(Ty), String_val(Name)))); + return to_val( + LLVMBuildMalloc(Builder_val(B), Type_val(Ty), String_val(Name))); } /* lltype -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_array_malloc(value Ty, value Val, value Name, value B) { - CAMLparam4(Ty, Val, Name, B); - CAMLreturn(to_val(LLVMBuildArrayMalloc(Builder_val(B), Type_val(Ty), - Value_val(Val), String_val(Name)))); + return to_val(LLVMBuildArrayMalloc(Builder_val(B), Type_val(Ty), + Value_val(Val), String_val(Name))); } /* llvalue -> llbuilder -> llvalue */ value llvm_build_free(value P, value B) { - CAMLparam2(P, B); - CAMLreturn(to_val(LLVMBuildFree(Builder_val(B), Value_val(P)))); + return to_val(LLVMBuildFree(Builder_val(B), Value_val(P))); } /* llvalue -> llvalue -> llbasicblock -> unit */ value llvm_add_case(value Switch, value OnVal, value Dest) { - CAMLparam3(Switch, OnVal, Dest); LLVMAddCase(Value_val(Switch), Value_val(OnVal), BasicBlock_val(Dest)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llbasicblock */ value llvm_switch_default_dest(value Val) { - CAMLparam1(Val); LLVMBasicBlockRef BB = LLVMGetSwitchDefaultDest(Value_val(Val)); - CAMLreturn(to_val(BB)); + return to_val(BB); } /* llvalue -> int -> llbuilder -> llvalue */ value llvm_build_indirect_br(value Addr, value EstimatedDests, value B) { - CAMLparam3(Addr, EstimatedDests, B); - CAMLreturn(to_val(LLVMBuildIndirectBr(Builder_val(B), Value_val(Addr), - Int_val(EstimatedDests)))); + return to_val(LLVMBuildIndirectBr(Builder_val(B), Value_val(Addr), + Int_val(EstimatedDests))); } /* llvalue -> llbasicblock -> unit */ value llvm_add_destination(value IndirectBr, value Dest) { - CAMLparam2(IndirectBr, Dest); LLVMAddDestination(Value_val(IndirectBr), BasicBlock_val(Dest)); - CAMLreturn(Val_unit); + return Val_unit; } /* lltype -> llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string -> llbuilder -> llvalue */ value llvm_build_invoke_nat(value FnTy, value Fn, value Args, value Then, value Catch, value Name, value B) { - CAMLparam5(FnTy, Fn, Args, Then, Catch); - CAMLxparam2(Name, B); unsigned Length = Wosize_val(Args); LLVMValueRef *Temp = alloc_temp(Args); LLVMValueRef Value = LLVMBuildInvoke2( Builder_val(B), Type_val(FnTy), Value_val(Fn), Temp, Length, BasicBlock_val(Then), BasicBlock_val(Catch), String_val(Name)); free(Temp); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue -> llvalue array -> llbasicblock -> llbasicblock -> @@ -2604,297 +2341,252 @@ /* lltype -> llvalue -> int -> string -> llbuilder -> llvalue */ value llvm_build_landingpad(value Ty, value PersFn, value NumClauses, value Name, value B) { - CAMLparam5(Ty, PersFn, NumClauses, Name, B); - CAMLreturn(to_val(LLVMBuildLandingPad(Builder_val(B), Type_val(Ty), - Value_val(PersFn), Int_val(NumClauses), - String_val(Name)))); + return to_val(LLVMBuildLandingPad(Builder_val(B), Type_val(Ty), + Value_val(PersFn), Int_val(NumClauses), + String_val(Name))); } /* llvalue -> llvalue -> unit */ value llvm_add_clause(value LandingPadInst, value ClauseVal) { - CAMLparam2(LandingPadInst, ClauseVal); LLVMAddClause(Value_val(LandingPadInst), Value_val(ClauseVal)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> bool */ value llvm_is_cleanup(value LandingPadInst) { - CAMLparam1(LandingPadInst); - CAMLreturn(Val_bool(LLVMIsCleanup(Value_val(LandingPadInst)))); + return Val_bool(LLVMIsCleanup(Value_val(LandingPadInst))); } /* llvalue -> bool -> unit */ value llvm_set_cleanup(value LandingPadInst, value flag) { - CAMLparam2(LandingPadInst, flag); LLVMSetCleanup(Value_val(LandingPadInst), Bool_val(flag)); - CAMLreturn(Val_unit); + return Val_unit; } /* llvalue -> llbuilder -> llvalue */ value llvm_build_resume(value Exn, value B) { - CAMLparam2(Exn, B); - CAMLreturn(to_val(LLVMBuildResume(Builder_val(B), Value_val(Exn)))); + return to_val(LLVMBuildResume(Builder_val(B), Value_val(Exn))); } /* llbuilder -> llvalue */ value llvm_build_unreachable(value B) { - CAMLparam1(B); - CAMLreturn(to_val(LLVMBuildUnreachable(Builder_val(B)))); + return to_val(LLVMBuildUnreachable(Builder_val(B))); } /*--... Arithmetic .........................................................--*/ /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_add(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildAdd(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildAdd(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nsw_add(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNSWAdd(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNSWAdd(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nuw_add(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNUWAdd(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNUWAdd(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fadd(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFAdd(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFAdd(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_sub(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildSub(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildSub(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nsw_sub(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNSWSub(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNSWSub(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nuw_sub(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNUWSub(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNUWSub(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fsub(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFSub(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFSub(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_mul(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildMul(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildMul(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nsw_mul(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNSWMul(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNSWMul(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nuw_mul(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildNUWMul(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildNUWMul(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fmul(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFMul(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFMul(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_udiv(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildUDiv(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildUDiv(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_sdiv(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildSDiv(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildSDiv(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_exact_sdiv(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildExactSDiv(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildExactSDiv(Builder_val(B), Value_val(LHS), + Value_val(RHS), String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fdiv(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFDiv(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFDiv(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_urem(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildURem(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildURem(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_srem(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildSRem(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildSRem(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_frem(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFRem(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFRem(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_shl(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildShl(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildShl(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_lshr(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildLShr(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildLShr(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_ashr(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildAShr(Builder_val(B), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildAShr(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_and(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildAnd(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildAnd(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_or(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildOr(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildOr(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_xor(value LHS, value RHS, value Name, value B) { - CAMLparam4(LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildXor(Builder_val(B), Value_val(LHS), Value_val(RHS), - String_val(Name)))); + return to_val(LLVMBuildXor(Builder_val(B), Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_neg(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildNeg(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val(LLVMBuildNeg(Builder_val(B), Value_val(X), String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nsw_neg(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildNSWNeg(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val( + LLVMBuildNSWNeg(Builder_val(B), Value_val(X), String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_nuw_neg(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildNUWNeg(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val( + LLVMBuildNUWNeg(Builder_val(B), Value_val(X), String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fneg(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildFNeg(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val(LLVMBuildFNeg(Builder_val(B), Value_val(X), String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_not(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildNot(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val(LLVMBuildNot(Builder_val(B), Value_val(X), String_val(Name))); } /*--... Memory .............................................................--*/ /* lltype -> string -> llbuilder -> llvalue */ value llvm_build_alloca(value Ty, value Name, value B) { - CAMLparam3(Ty, Name, B); - CAMLreturn( - to_val(LLVMBuildAlloca(Builder_val(B), Type_val(Ty), String_val(Name)))); + return to_val( + LLVMBuildAlloca(Builder_val(B), Type_val(Ty), String_val(Name))); } /* lltype -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_array_alloca(value Ty, value Size, value Name, value B) { - CAMLparam4(Ty, Size, Name, B); - CAMLreturn(to_val(LLVMBuildArrayAlloca(Builder_val(B), Type_val(Ty), - Value_val(Size), String_val(Name)))); + return to_val(LLVMBuildArrayAlloca(Builder_val(B), Type_val(Ty), + Value_val(Size), String_val(Name))); } /* lltype -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_load(value Ty, value Pointer, value Name, value B) { - CAMLparam4(Ty, Pointer, Name, B); - CAMLreturn(to_val(LLVMBuildLoad2(Builder_val(B), Type_val(Ty), - Value_val(Pointer), String_val(Name)))); + return to_val(LLVMBuildLoad2(Builder_val(B), Type_val(Ty), Value_val(Pointer), + String_val(Name))); } /* llvalue -> llvalue -> llbuilder -> llvalue */ value llvm_build_store(value Value, value Pointer, value B) { - CAMLparam3(Value, Pointer, B); - CAMLreturn(to_val( - LLVMBuildStore(Builder_val(B), Value_val(Value), Value_val(Pointer)))); + return to_val( + LLVMBuildStore(Builder_val(B), Value_val(Value), Value_val(Pointer))); } /* AtomicRMWBinOp.t -> llvalue -> llvalue -> AtomicOrdering.t -> bool -> string -> llbuilder -> llvalue */ value llvm_build_atomicrmw_native(value BinOp, value Ptr, value Val, value Ord, value ST, value Name, value B) { - CAMLparam5(BinOp, Ptr, Val, Ord, ST); - CAMLxparam2(Name, B); LLVMValueRef Instr; Instr = LLVMBuildAtomicRMW(Builder_val(B), Int_val(BinOp), Value_val(Ptr), Value_val(Val), Int_val(Ord), Bool_val(ST)); LLVMSetValueName(Instr, String_val(Name)); - CAMLreturn(to_val(Instr)); + return to_val(Instr); } value llvm_build_atomicrmw_bytecode(value *argv, int argn) { @@ -2905,195 +2597,170 @@ /* lltype -> llvalue -> llvalue array -> string -> llbuilder -> llvalue */ value llvm_build_gep(value Ty, value Pointer, value Indices, value Name, value B) { - CAMLparam5(Ty, Pointer, Indices, Name, B); unsigned Length = Wosize_val(Indices); LLVMValueRef *Temp = alloc_temp(Indices); LLVMValueRef Value = LLVMBuildGEP2(Builder_val(B), Type_val(Ty), Value_val(Pointer), Temp, Length, String_val(Name)); free(Temp); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue -> llvalue array -> string -> llbuilder -> llvalue */ value llvm_build_in_bounds_gep(value Ty, value Pointer, value Indices, value Name, value B) { - CAMLparam5(Ty, Pointer, Indices, Name, B); unsigned Length = Wosize_val(Indices); LLVMValueRef *Temp = alloc_temp(Indices); LLVMValueRef Value = LLVMBuildInBoundsGEP2(Builder_val(B), Type_val(Ty), Value_val(Pointer), Temp, Length, String_val(Name)); free(Temp); - CAMLreturn(to_val(Value)); + return to_val(Value); } /* lltype -> llvalue -> int -> string -> llbuilder -> llvalue */ value llvm_build_struct_gep(value Ty, value Pointer, value Index, value Name, value B) { - CAMLparam5(Ty, Pointer, Index, Name, B); - CAMLreturn(to_val(LLVMBuildStructGEP2(Builder_val(B), Type_val(Ty), - Value_val(Pointer), Int_val(Index), - String_val(Name)))); + return to_val(LLVMBuildStructGEP2(Builder_val(B), Type_val(Ty), + Value_val(Pointer), Int_val(Index), + String_val(Name))); } /* string -> string -> llbuilder -> llvalue */ value llvm_build_global_string(value Str, value Name, value B) { - CAMLparam3(Str, Name, B); - CAMLreturn(to_val(LLVMBuildGlobalString(Builder_val(B), String_val(Str), - String_val(Name)))); + return to_val( + LLVMBuildGlobalString(Builder_val(B), String_val(Str), String_val(Name))); } /* string -> string -> llbuilder -> llvalue */ value llvm_build_global_stringptr(value Str, value Name, value B) { - CAMLparam3(Str, Name, B); - CAMLreturn(to_val(LLVMBuildGlobalStringPtr(Builder_val(B), String_val(Str), - String_val(Name)))); + return to_val(LLVMBuildGlobalStringPtr(Builder_val(B), String_val(Str), + String_val(Name))); } /*--... Casts ..............................................................--*/ /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_trunc(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildTrunc(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildTrunc(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_zext(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildZExt(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildZExt(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_sext(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildSExt(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildSExt(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_fptoui(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildFPToUI(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildFPToUI(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_fptosi(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildFPToSI(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildFPToSI(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_uitofp(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildUIToFP(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildUIToFP(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_sitofp(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildSIToFP(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildSIToFP(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_fptrunc(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildFPTrunc(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildFPTrunc(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_fpext(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildFPExt(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildFPExt(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_prttoint(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildPtrToInt(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildPtrToInt(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_inttoptr(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildIntToPtr(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildIntToPtr(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_bitcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildBitCast(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildBitCast(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_zext_or_bitcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildZExtOrBitCast(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildZExtOrBitCast(Builder_val(B), Value_val(X), + Type_val(Ty), String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_sext_or_bitcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildSExtOrBitCast(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildSExtOrBitCast(Builder_val(B), Value_val(X), + Type_val(Ty), String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_trunc_or_bitcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildTruncOrBitCast(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildTruncOrBitCast(Builder_val(B), Value_val(X), + Type_val(Ty), String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_pointercast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildPointerCast(Builder_val(B), Value_val(X), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildPointerCast(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_intcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildIntCast(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildIntCast(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_fpcast(value X, value Ty, value Name, value B) { - CAMLparam4(X, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildFPCast(Builder_val(B), Value_val(X), Type_val(Ty), - String_val(Name)))); + return to_val(LLVMBuildFPCast(Builder_val(B), Value_val(X), Type_val(Ty), + String_val(Name))); } /*--... Comparisons ........................................................--*/ /* Icmp.t -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_icmp(value Pred, value LHS, value RHS, value Name, value B) { - CAMLparam5(Pred, LHS, RHS, Name, B); - CAMLreturn( - to_val(LLVMBuildICmp(Builder_val(B), Int_val(Pred) + LLVMIntEQ, - Value_val(LHS), Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildICmp(Builder_val(B), Int_val(Pred) + LLVMIntEQ, + Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* Fcmp.t -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_fcmp(value Pred, value LHS, value RHS, value Name, value B) { - CAMLparam5(Pred, LHS, RHS, Name, B); - CAMLreturn(to_val(LLVMBuildFCmp(Builder_val(B), Int_val(Pred), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildFCmp(Builder_val(B), Int_val(Pred), Value_val(LHS), + Value_val(RHS), String_val(Name))); } /*--... Miscellaneous instructions .........................................--*/ @@ -3122,9 +2789,7 @@ /* lltype -> string -> llbuilder -> value */ value llvm_build_empty_phi(value Type, value Name, value B) { - CAMLparam3(Type, Name, B); - CAMLreturn( - to_val(LLVMBuildPhi(Builder_val(B), Type_val(Type), String_val(Name)))); + return to_val(LLVMBuildPhi(Builder_val(B), Type_val(Type), String_val(Name))); } /* lltype -> llvalue -> llvalue array -> string -> llbuilder -> llvalue */ @@ -3141,88 +2806,76 @@ /* llvalue -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_select(value If, value Then, value Else, value Name, value B) { - CAMLparam5(If, Then, Else, Name, B); - CAMLreturn( - to_val(LLVMBuildSelect(Builder_val(B), Value_val(If), Value_val(Then), - Value_val(Else), String_val(Name)))); + return to_val(LLVMBuildSelect(Builder_val(B), Value_val(If), Value_val(Then), + Value_val(Else), String_val(Name))); } /* llvalue -> lltype -> string -> llbuilder -> llvalue */ value llvm_build_va_arg(value List, value Ty, value Name, value B) { - CAMLparam4(List, Ty, Name, B); - CAMLreturn(to_val(LLVMBuildVAArg(Builder_val(B), Value_val(List), - Type_val(Ty), String_val(Name)))); + return to_val(LLVMBuildVAArg(Builder_val(B), Value_val(List), Type_val(Ty), + String_val(Name))); } /* llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_extractelement(value Vec, value Idx, value Name, value B) { - CAMLparam4(Vec, Idx, Name, B); - CAMLreturn(to_val(LLVMBuildExtractElement(Builder_val(B), Value_val(Vec), - Value_val(Idx), String_val(Name)))); + return to_val(LLVMBuildExtractElement(Builder_val(B), Value_val(Vec), + Value_val(Idx), String_val(Name))); } /* llvalue -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_insertelement(value Vec, value Element, value Idx, value Name, value B) { - CAMLparam5(Vec, Element, Idx, Name, B); - CAMLreturn(to_val(LLVMBuildInsertElement(Builder_val(B), Value_val(Vec), - Value_val(Element), Value_val(Idx), - String_val(Name)))); + return to_val(LLVMBuildInsertElement(Builder_val(B), Value_val(Vec), + Value_val(Element), Value_val(Idx), + String_val(Name))); } /* llvalue -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_shufflevector(value V1, value V2, value Mask, value Name, value B) { - CAMLparam5(V1, V2, Mask, Name, B); - CAMLreturn(to_val(LLVMBuildShuffleVector(Builder_val(B), Value_val(V1), - Value_val(V2), Value_val(Mask), - String_val(Name)))); + return to_val(LLVMBuildShuffleVector(Builder_val(B), Value_val(V1), + Value_val(V2), Value_val(Mask), + String_val(Name))); } /* llvalue -> int -> string -> llbuilder -> llvalue */ value llvm_build_extractvalue(value Aggregate, value Idx, value Name, value B) { - CAMLparam4(Aggregate, Idx, Name, B); - CAMLreturn(to_val(LLVMBuildExtractValue(Builder_val(B), Value_val(Aggregate), - Int_val(Idx), String_val(Name)))); + return to_val(LLVMBuildExtractValue(Builder_val(B), Value_val(Aggregate), + Int_val(Idx), String_val(Name))); } /* llvalue -> llvalue -> int -> string -> llbuilder -> llvalue */ value llvm_build_insertvalue(value Aggregate, value Val, value Idx, value Name, value B) { - CAMLparam5(Aggregate, Val, Idx, Name, B); - CAMLreturn(to_val(LLVMBuildInsertValue(Builder_val(B), Value_val(Aggregate), - Value_val(Val), Int_val(Idx), - String_val(Name)))); + return to_val(LLVMBuildInsertValue(Builder_val(B), Value_val(Aggregate), + Value_val(Val), Int_val(Idx), + String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_is_null(value Val, value Name, value B) { - CAMLparam3(Val, Name, B); - CAMLreturn(to_val( - LLVMBuildIsNull(Builder_val(B), Value_val(Val), String_val(Name)))); + return to_val( + LLVMBuildIsNull(Builder_val(B), Value_val(Val), String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_is_not_null(value Val, value Name, value B) { - CAMLparam3(Val, Name, B); - CAMLreturn(to_val( - LLVMBuildIsNotNull(Builder_val(B), Value_val(Val), String_val(Name)))); + return to_val( + LLVMBuildIsNotNull(Builder_val(B), Value_val(Val), String_val(Name))); } /* lltype -> llvalue -> llvalue -> string -> llbuilder -> llvalue */ value llvm_build_ptrdiff(value ElemTy, value LHS, value RHS, value Name, value B) { - CAMLparam5(ElemTy, LHS, RHS, Name, B); - CAMLreturn( - to_val(LLVMBuildPtrDiff2(Builder_val(B), Type_val(ElemTy), Value_val(LHS), - Value_val(RHS), String_val(Name)))); + return to_val(LLVMBuildPtrDiff2(Builder_val(B), Type_val(ElemTy), + Value_val(LHS), Value_val(RHS), + String_val(Name))); } /* llvalue -> string -> llbuilder -> llvalue */ value llvm_build_freeze(value X, value Name, value B) { - CAMLparam3(X, Name, B); - CAMLreturn( - to_val(LLVMBuildFreeze(Builder_val(B), Value_val(X), String_val(Name)))); + return to_val( + LLVMBuildFreeze(Builder_val(B), Value_val(X), String_val(Name))); } /*===-- Memory buffers ----------------------------------------------------===*/ @@ -3279,54 +2932,45 @@ /* llmemorybuffer -> unit */ value llvm_memorybuffer_dispose(value MemBuf) { - CAMLparam1(MemBuf); LLVMDisposeMemoryBuffer(MemoryBuffer_val(MemBuf)); - CAMLreturn(Val_unit); + return Val_unit; } /*===-- Pass Managers -----------------------------------------------------===*/ /* unit -> [ `Module ] PassManager.t */ value llvm_passmanager_create(value Unit) { - CAMLparam1(Unit); - CAMLreturn(to_val(LLVMCreatePassManager())); + return to_val(LLVMCreatePassManager()); } /* llmodule -> [ `Function ] PassManager.t */ value llvm_passmanager_create_function(value Module) { - CAMLparam1(Module); - CAMLreturn( - to_val(LLVMCreateFunctionPassManagerForModule(Module_val(Module)))); + return to_val(LLVMCreateFunctionPassManagerForModule(Module_val(Module))); } /* llmodule -> [ `Function ] PassManager.t -> bool */ value llvm_passmanager_run_module(value M, value PM) { - CAMLparam2(M, PM); - CAMLreturn(Val_bool(LLVMRunPassManager(PassManager_val(PM), Module_val(M)))); + return Val_bool(LLVMRunPassManager(PassManager_val(PM), Module_val(M))); } /* [ `Function ] PassManager.t -> bool */ value llvm_passmanager_initialize(value FPM) { - CAMLparam1(FPM); - CAMLreturn(Val_bool(LLVMInitializeFunctionPassManager(PassManager_val(FPM)))); + return Val_bool(LLVMInitializeFunctionPassManager(PassManager_val(FPM))); } /* llvalue -> [ `Function ] PassManager.t -> bool */ value llvm_passmanager_run_function(value F, value FPM) { - CAMLparam2(F, FPM); - CAMLreturn( - Val_bool(LLVMRunFunctionPassManager(PassManager_val(FPM), Value_val(F)))); + return Val_bool( + LLVMRunFunctionPassManager(PassManager_val(FPM), Value_val(F))); } /* [ `Function ] PassManager.t -> bool */ value llvm_passmanager_finalize(value FPM) { - CAMLparam1(FPM); - CAMLreturn(Val_bool(LLVMFinalizeFunctionPassManager(PassManager_val(FPM)))); + return Val_bool(LLVMFinalizeFunctionPassManager(PassManager_val(FPM))); } /* PassManager.any PassManager.t -> unit */ value llvm_passmanager_dispose(value PM) { - CAMLparam1(PM); LLVMDisposePassManager(PassManager_val(PM)); - CAMLreturn(Val_unit); + return Val_unit; }