From fb350e779fb2f9322c0233ef99d278b26dabc166 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 8 Apr 2021 13:47:13 -0700 Subject: [PATCH] [sledge][llvm] Pull in upstream changes Summary: This diff pulls in upstream changes to the LLVM OCaml bindings. Includes upstream commits: > Add (get/set)_module_identifer functions > Fix documentation for verify_function and const_of_int64 > DebugInfo support for OCaml bindings > llvmbuildectomy - compatibility with ocaml bindings > Remove ConstantPropagation > Remove and move tests to SCCP. Also includes updates to llvm-dune to adapt the build to the added header file. Reviewed By: ngorogiannis Differential Revision: D27564717 fbshipit-source-id: af63e2aba --- .../llvm/bindings/ocaml/.ocamlformat | 1 + .../llvm/bindings/ocaml/CMakeLists.txt | 1 + .../llvm/bindings/ocaml/README.txt | 3 +- .../bindings/ocaml/analysis/CMakeLists.txt | 2 +- .../bindings/ocaml/analysis/llvm_analysis.mli | 5 +- .../bindings/ocaml/bitreader/CMakeLists.txt | 2 +- .../bindings/ocaml/bitwriter/CMakeLists.txt | 2 +- .../bindings/ocaml/debuginfo/CMakeLists.txt | 6 + .../ocaml/debuginfo/debuginfo_ocaml.c | 916 ++++++++++++++++++ .../ocaml/debuginfo/llvm_debuginfo.ml | 567 +++++++++++ .../ocaml/debuginfo/llvm_debuginfo.mli | 625 ++++++++++++ .../ocaml/executionengine/CMakeLists.txt | 2 +- .../bindings/ocaml/irreader/CMakeLists.txt | 2 +- .../llvm/bindings/ocaml/linker/CMakeLists.txt | 2 +- .../llvm/bindings/ocaml/llvm/CMakeLists.txt | 3 +- .../llvm/bindings/ocaml/llvm/META.llvm.in | 8 + .../llvm/bindings/ocaml/llvm/llvm.ml | 27 + .../llvm/bindings/ocaml/llvm/llvm.mli | 46 +- .../llvm/bindings/ocaml/llvm/llvm_ocaml.c | 73 +- .../llvm/bindings/ocaml/llvm/llvm_ocaml.h | 30 + .../llvm/bindings/ocaml/target/CMakeLists.txt | 2 +- .../bindings/ocaml/transforms/ipo/ipo_ocaml.c | 6 - .../bindings/ocaml/transforms/ipo/llvm_ipo.ml | 3 - .../ocaml/transforms/ipo/llvm_ipo.mli | 5 - .../transforms/scalar_opts/CMakeLists.txt | 2 +- .../scalar_opts/llvm_scalar_opts.ml | 3 - .../scalar_opts/llvm_scalar_opts.mli | 5 - .../scalar_opts/scalar_opts_ocaml.c | 6 - .../ocaml/transforms/utils/CMakeLists.txt | 2 +- .../ocaml/transforms/vectorize/CMakeLists.txt | 2 +- sledge/vendor/llvm-dune/setup.sh | 13 +- 31 files changed, 2320 insertions(+), 52 deletions(-) create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/.ocamlformat create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/CMakeLists.txt create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli create mode 100644 sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.h diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/.ocamlformat b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/.ocamlformat new file mode 100644 index 000000000..e3346c163 --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/.ocamlformat @@ -0,0 +1 @@ +disable=true diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/CMakeLists.txt index 20583682c..7fe960b67 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(analysis) add_subdirectory(backends) add_subdirectory(bitreader) add_subdirectory(bitwriter) +add_subdirectory(debuginfo) add_subdirectory(irreader) add_subdirectory(linker) add_subdirectory(target) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/README.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/README.txt index 68216b679..a6a595e75 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/README.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/README.txt @@ -20,7 +20,8 @@ The bindings can also be built out-of-tree, i.e. targeting a preinstalled LLVM. To do this, configure the LLVM build tree as follows: $ cmake -DLLVM_OCAML_OUT_OF_TREE=TRUE \ - -DCMAKE_INSTALL_PREFIX=[OCaml install prefix] \ + -DCMAKE_INSTALL_PREFIX=[Preinstalled LLVM path] \ + -DLLVM_OCAML_INSTALL_PATH=[OCaml install prefix] \ [... any other options] then build and install it as: diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/CMakeLists.txt index f8ca84ddb..5eb04b66a 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_analysis OCAML llvm_analysis OCAMLDEP llvm C analysis_ocaml - LLVM analysis) + LLVM Analysis) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/llvm_analysis.mli b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/llvm_analysis.mli index cf323b547..3dd397425 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/llvm_analysis.mli +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/analysis/llvm_analysis.mli @@ -16,9 +16,8 @@ human-readable validation report. See [llvm::verifyModule]. *) external verify_module : Llvm.llmodule -> string option = "llvm_verify_module" -(** [verify_function f] returns [None] if the function [f] is valid, and - [Some reason] if it is invalid. [reason] is a string containing a - human-readable validation report. See [llvm::verifyFunction]. *) +(** [verify_function f] returns [true] if the function [f] is valid, and + [false] if it is invalid. See [llvm::verifyFunction]. *) external verify_function : Llvm.llvalue -> bool = "llvm_verify_function" (** [verify_module m] returns if the module [m] is valid, but prints a diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitreader/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitreader/CMakeLists.txt index 8d1610320..d71f51c28 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitreader/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitreader/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_bitreader OCAML llvm_bitreader OCAMLDEP llvm C bitreader_ocaml - LLVM bitreader) + LLVM BitReader) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitwriter/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitwriter/CMakeLists.txt index 5a14498cb..6462d65c8 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitwriter/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/bitwriter/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_bitwriter OCAML llvm_bitwriter OCAMLDEP llvm C bitwriter_ocaml - LLVM bitwriter) + LLVM BitWriter) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/CMakeLists.txt new file mode 100644 index 000000000..07f4956cc --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/CMakeLists.txt @@ -0,0 +1,6 @@ +add_ocaml_library(llvm_debuginfo + OCAML llvm_debuginfo + OCAMLDEP llvm + C debuginfo_ocaml + CFLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/../llvm" + LLVM Core) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c new file mode 100644 index 000000000..217214f0b --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c @@ -0,0 +1,916 @@ +/*===-- debuginfo_ocaml.c - LLVM OCaml Glue ---------------------*- C++ -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* 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 + +#include "caml/memory.h" +#include "caml/mlvalues.h" +#include "llvm-c/Core.h" +#include "llvm-c/DebugInfo.h" +#include "llvm-c/Support.h" + +#include "llvm_ocaml.h" + +// This is identical to the definition in llvm_debuginfo.ml:DIFlag.t +typedef enum { + i_DIFlagZero, + i_DIFlagPrivate, + i_DIFlagProtected, + i_DIFlagPublic, + i_DIFlagFwdDecl, + i_DIFlagAppleBlock, + i_DIFlagReservedBit4, + i_DIFlagVirtual, + i_DIFlagArtificial, + i_DIFlagExplicit, + i_DIFlagPrototyped, + i_DIFlagObjcClassComplete, + i_DIFlagObjectPointer, + i_DIFlagVector, + i_DIFlagStaticMember, + i_DIFlagLValueReference, + i_DIFlagRValueReference, + i_DIFlagReserved, + i_DIFlagSingleInheritance, + i_DIFlagMultipleInheritance, + i_DIFlagVirtualInheritance, + i_DIFlagIntroducedVirtual, + i_DIFlagBitField, + i_DIFlagNoReturn, + i_DIFlagTypePassByValue, + i_DIFlagTypePassByReference, + i_DIFlagEnumClass, + i_DIFlagFixedEnum, + i_DIFlagThunk, + i_DIFlagNonTrivial, + i_DIFlagBigEndian, + i_DIFlagLittleEndian, + i_DIFlagIndirectVirtualBase, + i_DIFlagAccessibility, + i_DIFlagPtrToMemberRep +} LLVMDIFlag_i; + +static LLVMDIFlags map_DIFlag(LLVMDIFlag_i DIF) { + switch (DIF) { + case i_DIFlagZero: + return LLVMDIFlagZero; + case i_DIFlagPrivate: + return LLVMDIFlagPrivate; + case i_DIFlagProtected: + return LLVMDIFlagProtected; + case i_DIFlagPublic: + return LLVMDIFlagPublic; + case i_DIFlagFwdDecl: + return LLVMDIFlagFwdDecl; + case i_DIFlagAppleBlock: + return LLVMDIFlagAppleBlock; + case i_DIFlagReservedBit4: + return LLVMDIFlagReservedBit4; + case i_DIFlagVirtual: + return LLVMDIFlagVirtual; + case i_DIFlagArtificial: + return LLVMDIFlagArtificial; + case i_DIFlagExplicit: + return LLVMDIFlagExplicit; + case i_DIFlagPrototyped: + return LLVMDIFlagPrototyped; + case i_DIFlagObjcClassComplete: + return LLVMDIFlagObjcClassComplete; + case i_DIFlagObjectPointer: + return LLVMDIFlagObjectPointer; + case i_DIFlagVector: + return LLVMDIFlagVector; + case i_DIFlagStaticMember: + return LLVMDIFlagStaticMember; + case i_DIFlagLValueReference: + return LLVMDIFlagLValueReference; + case i_DIFlagRValueReference: + return LLVMDIFlagRValueReference; + case i_DIFlagReserved: + return LLVMDIFlagReserved; + case i_DIFlagSingleInheritance: + return LLVMDIFlagSingleInheritance; + case i_DIFlagMultipleInheritance: + return LLVMDIFlagMultipleInheritance; + case i_DIFlagVirtualInheritance: + return LLVMDIFlagVirtualInheritance; + case i_DIFlagIntroducedVirtual: + return LLVMDIFlagIntroducedVirtual; + case i_DIFlagBitField: + return LLVMDIFlagBitField; + case i_DIFlagNoReturn: + return LLVMDIFlagNoReturn; + case i_DIFlagTypePassByValue: + return LLVMDIFlagTypePassByValue; + case i_DIFlagTypePassByReference: + return LLVMDIFlagTypePassByReference; + case i_DIFlagEnumClass: + return LLVMDIFlagEnumClass; + case i_DIFlagFixedEnum: + return LLVMDIFlagFixedEnum; + case i_DIFlagThunk: + return LLVMDIFlagThunk; + case i_DIFlagNonTrivial: + return LLVMDIFlagNonTrivial; + case i_DIFlagBigEndian: + return LLVMDIFlagBigEndian; + case i_DIFlagLittleEndian: + return LLVMDIFlagLittleEndian; + case i_DIFlagIndirectVirtualBase: + return LLVMDIFlagIndirectVirtualBase; + case i_DIFlagAccessibility: + return LLVMDIFlagAccessibility; + case i_DIFlagPtrToMemberRep: + return LLVMDIFlagPtrToMemberRep; + } +} + +CAMLprim value llvm_debug_metadata_version(value Unit) { + return Val_int(LLVMDebugMetadataVersion()); +} + +CAMLprim value llvm_get_module_debug_metadata_version(LLVMModuleRef Module) { + return Val_int(LLVMGetModuleDebugMetadataVersion(Module)); +} + +#define DIFlags_val(v) (*(LLVMDIFlags *)(Data_custom_val(v))) + +static struct custom_operations diflags_ops = { + (char *)"DebugInfo.lldiflags", custom_finalize_default, + custom_compare_default, custom_hash_default, + custom_serialize_default, custom_deserialize_default, + custom_compare_ext_default}; + +static value alloc_diflags(LLVMDIFlags Flags) { + value V = alloc_custom(&diflags_ops, sizeof(LLVMDIFlags), 0, 1); + DIFlags_val(V) = Flags; + return V; +} + +CAMLprim LLVMDIFlags llvm_diflags_get(value i_Flag) { + LLVMDIFlags Flags = map_DIFlag(Int_val(i_Flag)); + return alloc_diflags(Flags); +} + +CAMLprim LLVMDIFlags llvm_diflags_set(value Flags, value i_Flag) { + LLVMDIFlags FlagsNew = DIFlags_val(Flags) | map_DIFlag(Int_val(i_Flag)); + return alloc_diflags(FlagsNew); +} + +CAMLprim value llvm_diflags_test(value Flags, value i_Flag) { + LLVMDIFlags Flag = map_DIFlag(Int_val(i_Flag)); + return Val_bool((DIFlags_val(Flags) & Flag) == Flag); +} + +#define DIBuilder_val(v) (*(LLVMDIBuilderRef *)(Data_custom_val(v))) + +static void llvm_finalize_dibuilder(value B) { + LLVMDIBuilderFinalize(DIBuilder_val(B)); + LLVMDisposeDIBuilder(DIBuilder_val(B)); +} + +static struct custom_operations dibuilder_ops = { + (char *)"DebugInfo.lldibuilder", llvm_finalize_dibuilder, + custom_compare_default, custom_hash_default, + custom_serialize_default, custom_deserialize_default, + custom_compare_ext_default}; + +static value alloc_dibuilder(LLVMDIBuilderRef B) { + value V = alloc_custom(&dibuilder_ops, sizeof(LLVMDIBuilderRef), 0, 1); + DIBuilder_val(V) = B; + return V; +} + +/* llmodule -> lldibuilder */ +CAMLprim value llvm_dibuilder(LLVMModuleRef M) { + return alloc_dibuilder(LLVMCreateDIBuilder(M)); +} + +CAMLprim value llvm_dibuild_finalize(value Builder) { + LLVMDIBuilderFinalize(DIBuilder_val(Builder)); + return Val_unit; +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_compile_unit_native( + value Builder, value Lang, LLVMMetadataRef FileRef, value Producer, + value IsOptimized, value Flags, value RuntimeVer, value SplitName, + value Kind, value DWOId, value SplitDebugInline, + value DebugInfoForProfiling, value SysRoot, value SDK) { + return LLVMDIBuilderCreateCompileUnit( + DIBuilder_val(Builder), Int_val(Lang), FileRef, String_val(Producer), + caml_string_length(Producer), Bool_val(IsOptimized), String_val(Flags), + caml_string_length(Flags), Int_val(RuntimeVer), String_val(SplitName), + caml_string_length(SplitName), Int_val(Kind), Int_val(DWOId), + Bool_val(SplitDebugInline), Bool_val(DebugInfoForProfiling)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_compile_unit_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_compile_unit_native( + argv[0], // Builder + argv[1], // Lang + (LLVMMetadataRef)argv[2], // FileRef + argv[3], // Producer + argv[4], // IsOptimized + argv[5], // Flags + argv[6], // RuntimeVer + argv[7], // SplitName + argv[8], // Kind + argv[9], // DWOId + argv[10], // SplitDebugInline + argv[11], // DebugInfoForProfiling + argv[12], // SysRoot + argv[13] // SDK + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_file(value Builder, value Filename, + value Directory) { + return LLVMDIBuilderCreateFile(DIBuilder_val(Builder), String_val(Filename), + caml_string_length(Filename), + String_val(Directory), + caml_string_length(Directory)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_module_native( + value Builder, LLVMMetadataRef ParentScope, value Name, value ConfigMacros, + value IncludePath, value SysRoot) { + return LLVMDIBuilderCreateModule( + DIBuilder_val(Builder), ParentScope, String_val(Name), + caml_string_length(Name), String_val(ConfigMacros), + caml_string_length(ConfigMacros), String_val(IncludePath), + caml_string_length(IncludePath), String_val(SysRoot), + caml_string_length(SysRoot)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_module_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_module_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // ParentScope + argv[2], // Name + argv[3], // ConfigMacros + argv[4], // IncludePath + argv[5] // SysRoot + ); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_namespace(value Builder, LLVMMetadataRef ParentScope, + value Name, value ExportSymbols) { + return LLVMDIBuilderCreateNameSpace( + DIBuilder_val(Builder), ParentScope, String_val(Name), + caml_string_length(Name), Bool_val(ExportSymbols)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_function_native( + value Builder, LLVMMetadataRef Scope, value Name, value LinkageName, + LLVMMetadataRef File, value LineNo, LLVMMetadataRef Ty, value IsLocalToUnit, + value IsDefinition, value ScopeLine, value Flags, value IsOptimized) { + return LLVMDIBuilderCreateFunction( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + String_val(LinkageName), caml_string_length(LinkageName), File, + Int_val(LineNo), Ty, Bool_val(IsLocalToUnit), Bool_val(IsDefinition), + Int_val(ScopeLine), DIFlags_val(Flags), Bool_val(IsOptimized)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_function_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_function_native(argv[0], // Builder, + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + argv[3], // LinkageName + (LLVMMetadataRef)argv[4], // File + argv[5], // LineNo + (LLVMMetadataRef)argv[6], // Ty + argv[7], // IsLocalUnit + argv[8], // IsDefinition + argv[9], // ScopeLine + argv[10], // Flags + argv[11] // IsOptimized + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_lexical_block( + value Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, value Line, + value Column) { + return LLVMDIBuilderCreateLexicalBlock(DIBuilder_val(Builder), Scope, File, + Int_val(Line), Int_val(Column)); +} + +CAMLprim LLVMMetadataRef llvm_metadata_null() { return (LLVMMetadataRef)NULL; } + +CAMLprim LLVMMetadataRef llvm_dibuild_create_debug_location( + LLVMContextRef Ctx, value Line, value Column, LLVMMetadataRef Scope, + LLVMMetadataRef InlinedAt) { + return LLVMDIBuilderCreateDebugLocation(Ctx, Int_val(Line), Int_val(Column), + Scope, InlinedAt); +} + +CAMLprim value llvm_di_location_get_line(LLVMMetadataRef Location) { + return Val_int(LLVMDILocationGetLine(Location)); +} + +CAMLprim value llvm_di_location_get_column(LLVMMetadataRef Location) { + return Val_int(LLVMDILocationGetColumn(Location)); +} + +CAMLprim LLVMMetadataRef llvm_di_location_get_scope(LLVMMetadataRef Location) { + return LLVMDILocationGetScope(Location); +} + +CAMLprim value llvm_di_location_get_inlined_at(LLVMMetadataRef Location) { + return (ptr_to_option(LLVMDILocationGetInlinedAt(Location))); +} + +CAMLprim value llvm_di_scope_get_file(LLVMMetadataRef Scope) { + return (ptr_to_option(LLVMDIScopeGetFile(Scope))); +} + +CAMLprim value llvm_di_file_get_directory(LLVMMetadataRef File) { + unsigned Len; + const char *Directory = LLVMDIFileGetDirectory(File, &Len); + return cstr_to_string(Directory, Len); +} + +CAMLprim value llvm_di_file_get_filename(LLVMMetadataRef File) { + unsigned Len; + const char *Filename = LLVMDIFileGetFilename(File, &Len); + return cstr_to_string(Filename, Len); +} + +CAMLprim value llvm_di_file_get_source(LLVMMetadataRef File) { + unsigned Len; + const char *Source = LLVMDIFileGetSource(File, &Len); + return cstr_to_string(Source, Len); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_get_or_create_type_array(value Builder, + value Data) { + + return LLVMDIBuilderGetOrCreateTypeArray(DIBuilder_val(Builder), + (LLVMMetadataRef *)Op_val(Data), + Wosize_val(Data)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_get_or_create_array(value Builder, + value Data) { + + return LLVMDIBuilderGetOrCreateArray(DIBuilder_val(Builder), + (LLVMMetadataRef *)Op_val(Data), + Wosize_val(Data)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_subroutine_type( + value Builder, LLVMMetadataRef File, value ParameterTypes, value Flags) { + + return LLVMDIBuilderCreateSubroutineType( + DIBuilder_val(Builder), File, (LLVMMetadataRef *)Op_val(ParameterTypes), + Wosize_val(ParameterTypes), DIFlags_val(Flags)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_enumerator(value Builder, + value Name, value Value, + value IsUnsigned) { + return LLVMDIBuilderCreateEnumerator( + DIBuilder_val(Builder), String_val(Name), caml_string_length(Name), + (int64_t)Int_val(Value), Bool_val(IsUnsigned)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_enumeration_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, value SizeInBits, value AlignInBits, value Elements, + LLVMMetadataRef ClassTy) { + return LLVMDIBuilderCreateEnumerationType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), (LLVMMetadataRef *)Op_val(Elements), + Wosize_val(Elements), ClassTy); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_enumeration_type_bytecode(value *argv, int argn) { + return llvm_dibuild_create_enumeration_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + argv[5], // SizeInBits + argv[6], // AlignInBits + argv[7], // Elements + (LLVMMetadataRef)argv[8] // ClassTy + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_union_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, value SizeInBits, value AlignInBits, value Flags, + value Elements, value RunTimeLanguage, value UniqueId) { + + return LLVMDIBuilderCreateUnionType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), DIFlags_val(Flags), + (LLVMMetadataRef *)Op_val(Elements), Wosize_val(Elements), + Int_val(RunTimeLanguage), String_val(UniqueId), + caml_string_length(UniqueId)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_union_type_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_union_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + argv[5], // SizeInBits + argv[6], // AlignInBits + argv[7], // Flags + argv[8], // Elements + argv[9], // RunTimeLanguage + argv[10] // UniqueId + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_array_type(value Builder, + value Size, + value AlignInBits, + LLVMMetadataRef Ty, + value Subscripts) { + return LLVMDIBuilderCreateArrayType( + DIBuilder_val(Builder), (uint64_t)Int_val(Size), Int_val(AlignInBits), Ty, + (LLVMMetadataRef *)Op_val(Subscripts), Wosize_val(Subscripts)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_vector_type(value Builder, + value Size, + value AlignInBits, + LLVMMetadataRef Ty, + value Subscripts) { + return LLVMDIBuilderCreateVectorType( + DIBuilder_val(Builder), (uint64_t)Int_val(Size), Int_val(AlignInBits), Ty, + (LLVMMetadataRef *)Op_val(Subscripts), Wosize_val(Subscripts)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_unspecified_type(value Builder, + value Name) { + return LLVMDIBuilderCreateUnspecifiedType( + DIBuilder_val(Builder), String_val(Name), caml_string_length(Name)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_basic_type( + value Builder, value Name, value SizeInBits, value Encoding, value Flags) { + + return LLVMDIBuilderCreateBasicType( + DIBuilder_val(Builder), String_val(Name), caml_string_length(Name), + (uint64_t)Int_val(SizeInBits), Int_val(Encoding), DIFlags_val(Flags)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_pointer_type_native( + value Builder, LLVMMetadataRef PointeeTy, value SizeInBits, + value AlignInBits, value AddressSpace, value Name) { + return LLVMDIBuilderCreatePointerType( + DIBuilder_val(Builder), PointeeTy, (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), Int_val(AddressSpace), String_val(Name), + caml_string_length(Name)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_pointer_type_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_pointer_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // PointeeTy + argv[2], // SizeInBits + argv[3], // AlignInBits + argv[4], // AddressSpace + argv[5] // Name + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_struct_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, value SizeInBits, value AlignInBits, value Flags, + LLVMMetadataRef DerivedFrom, value Elements, value RunTimeLanguage, + LLVMMetadataRef VTableHolder, value UniqueId) { + + return LLVMDIBuilderCreateStructType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), DIFlags_val(Flags), DerivedFrom, + (LLVMMetadataRef *)Op_val(Elements), Wosize_val(Elements), + Int_val(RunTimeLanguage), VTableHolder, String_val(UniqueId), + caml_string_length(UniqueId)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_struct_type_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_struct_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + argv[5], // SizeInBits + argv[6], // AlignInBits + argv[7], // Flags + (LLVMMetadataRef)argv[8], // DeriviedFrom + argv[9], // Elements + argv[10], // RunTimeLanguage + (LLVMMetadataRef)argv[11], // VTableHolder + argv[12] // UniqueId + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_member_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, value SizeInBits, value AlignInBits, value OffsetInBits, + value Flags, LLVMMetadataRef Ty) { + + return LLVMDIBuilderCreateMemberType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), (uint64_t)Int_val(OffsetInBits), DIFlags_val(Flags), + Ty); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_member_type_bytecode(value *argv, + int argn) { + return llvm_dibuild_create_member_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + argv[5], // SizeInBits + argv[6], // AlignInBits + argv[7], // OffsetInBits + argv[8], // Flags + (LLVMMetadataRef)argv[9] // Ty + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_static_member_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, LLVMMetadataRef Type, value Flags, + LLVMValueRef ConstantVal, value AlignInBits) { + + return LLVMDIBuilderCreateStaticMemberType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), Type, DIFlags_val(Flags), ConstantVal, + Int_val(AlignInBits)); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_static_member_type_bytecode(value *argv, int argn) { + return llvm_dibuild_create_static_member_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + (LLVMMetadataRef)argv[5], // Type + argv[6], // Flags, + (LLVMValueRef)argv[7], // ConstantVal + argv[8] // AlignInBits + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_member_pointer_type_native( + value Builder, LLVMMetadataRef PointeeType, LLVMMetadataRef ClassType, + uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags) { + + return LLVMDIBuilderCreateMemberPointerType( + DIBuilder_val(Builder), PointeeType, ClassType, + (uint64_t)Int_val(SizeInBits), Int_val(AlignInBits), Flags); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_member_pointer_type_bytecode(value *argv, int argn) { + return llvm_dibuild_create_member_pointer_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // PointeeType + (LLVMMetadataRef)argv[2], // ClassType + argv[3], // SizeInBits + argv[4], // AlignInBits + argv[5] // Flags + ); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_object_pointer_type(value Builder, LLVMMetadataRef Type) { + return LLVMDIBuilderCreateObjectPointerType(DIBuilder_val(Builder), Type); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_qualified_type( + value Builder, value Tag, LLVMMetadataRef Type) { + + return LLVMDIBuilderCreateQualifiedType(DIBuilder_val(Builder), Int_val(Tag), + Type); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_reference_type( + value Builder, value Tag, LLVMMetadataRef Type) { + + return LLVMDIBuilderCreateReferenceType(DIBuilder_val(Builder), Int_val(Tag), + Type); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_null_ptr_type(value Builder) { + + return LLVMDIBuilderCreateNullPtrType(DIBuilder_val(Builder)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_typedef_native( + value Builder, LLVMMetadataRef Type, value Name, LLVMMetadataRef File, + value LineNo, LLVMMetadataRef Scope, value AlignInBits) { + + return LLVMDIBuilderCreateTypedef( + DIBuilder_val(Builder), Type, String_val(Name), caml_string_length(Name), + File, Int_val(LineNo), Scope, Int_val(AlignInBits)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_typedef_bytecode(value *argv, + int argn) { + + return llvm_dibuild_create_typedef_native(argv[0], // Builder + (LLVMMetadataRef)argv[1], // Type + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNo + (LLVMMetadataRef)argv[5], // Scope + argv[6] // AlignInBits + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_inheritance_native( + value Builder, LLVMMetadataRef Ty, LLVMMetadataRef BaseTy, value BaseOffset, + value VBPtrOffset, value Flags) { + + return LLVMDIBuilderCreateInheritance(DIBuilder_val(Builder), Ty, BaseTy, + (uint64_t)Int_val(BaseOffset), + Int_val(VBPtrOffset), Flags); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_inheritance_bytecode(value *argv, + int arg) { + + return llvm_dibuild_create_inheritance_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Ty + (LLVMMetadataRef)argv[2], // BaseTy + argv[3], // BaseOffset + argv[4], // VBPtrOffset + argv[5] // Flags + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_forward_decl_native( + value Builder, value Tag, value Name, LLVMMetadataRef Scope, + LLVMMetadataRef File, value Line, value RuntimeLang, value SizeInBits, + value AlignInBits, value UniqueIdentifier) { + return LLVMDIBuilderCreateForwardDecl( + DIBuilder_val(Builder), Int_val(Tag), String_val(Name), + caml_string_length(Name), Scope, File, Int_val(Line), + Int_val(RuntimeLang), (uint64_t)Int_val(SizeInBits), Int_val(AlignInBits), + String_val(UniqueIdentifier), caml_string_length(UniqueIdentifier)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_forward_decl_bytecode(value *argv, + int arg) { + + return llvm_dibuild_create_forward_decl_native( + argv[0], // Builder + argv[1], // Tag + argv[2], // Name + (LLVMMetadataRef)argv[3], // Scope + (LLVMMetadataRef)argv[4], // File + argv[5], // Line + argv[6], // RuntimeLang + argv[7], // SizeInBits + argv[8], // AlignInBits + argv[9] // UniqueIdentifier + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_replaceable_composite_type_native( + value Builder, value Tag, value Name, LLVMMetadataRef Scope, + LLVMMetadataRef File, value Line, value RuntimeLang, value SizeInBits, + value AlignInBits, value Flags, value UniqueIdentifier) { + + return LLVMDIBuilderCreateReplaceableCompositeType( + DIBuilder_val(Builder), Int_val(Tag), String_val(Name), + caml_string_length(Name), Scope, File, Int_val(Line), + Int_val(RuntimeLang), (uint64_t)Int_val(SizeInBits), Int_val(AlignInBits), + DIFlags_val(Flags), String_val(UniqueIdentifier), + caml_string_length(UniqueIdentifier)); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_replaceable_composite_type_bytecode(value *argv, int arg) { + + return llvm_dibuild_create_replaceable_composite_type_native( + argv[0], // Builder + argv[1], // Tag + argv[2], // Name + (LLVMMetadataRef)argv[3], // Scope + (LLVMMetadataRef)argv[4], // File + argv[5], // Line + argv[6], // RuntimeLang + argv[7], // SizeInBits + argv[8], // AlignInBits + argv[9], // Flags + argv[10] // UniqueIdentifier + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_bit_field_member_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNum, value SizeInBits, value OffsetInBits, + value StorageOffsetInBits, value Flags, LLVMMetadataRef Ty) { + + return LLVMDIBuilderCreateBitFieldMemberType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNum), (uint64_t)Int_val(SizeInBits), + (uint64_t)Int_val(OffsetInBits), (uint64_t)Int_val(StorageOffsetInBits), + DIFlags_val(Flags), Ty); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_bit_field_member_type_bytecode(value *argv, int arg) { + + return llvm_dibuild_create_bit_field_member_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNum + argv[5], // SizeInBits + argv[6], // OffsetInBits + argv[7], // StorageOffsetInBits + argv[8], // Flags + (LLVMMetadataRef)argv[9] // Ty + ); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_class_type_native( + value Builder, LLVMMetadataRef Scope, value Name, LLVMMetadataRef File, + value LineNumber, value SizeInBits, value AlignInBits, value OffsetInBits, + value Flags, LLVMMetadataRef DerivedFrom, value Elements, + LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode, + value UniqueIdentifier) { + + return LLVMDIBuilderCreateClassType( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + File, Int_val(LineNumber), (uint64_t)Int_val(SizeInBits), + Int_val(AlignInBits), (uint64_t)Int_val(OffsetInBits), DIFlags_val(Flags), + DerivedFrom, (LLVMMetadataRef *)Op_val(Elements), Wosize_val(Elements), + VTableHolder, TemplateParamsNode, String_val(UniqueIdentifier), + caml_string_length(UniqueIdentifier)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_class_type_bytecode(value *argv, + int arg) { + + return llvm_dibuild_create_class_type_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + (LLVMMetadataRef)argv[3], // File + argv[4], // LineNumber + argv[5], // SizeInBits + argv[6], // AlignInBits + argv[7], // OffsetInBits + argv[8], // Flags + (LLVMMetadataRef)argv[9], // DerivedFrom + argv[10], // Elements + (LLVMMetadataRef)argv[11], // VTableHolder + (LLVMMetadataRef)argv[12], // TemplateParamsNode + argv[13] // UniqueIdentifier + ); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_artificial_type(value Builder, LLVMMetadataRef Type) { + return LLVMDIBuilderCreateArtificialType(DIBuilder_val(Builder), Type); +} + +CAMLprim value llvm_di_type_get_name(LLVMMetadataRef DType) { + size_t Len; + const char *Name = LLVMDITypeGetName(DType, &Len); + return cstr_to_string(Name, Len); +} + +CAMLprim value llvm_di_type_get_size_in_bits(LLVMMetadataRef DType) { + uint64_t Size = LLVMDITypeGetSizeInBits(DType); + return Val_int((int)Size); +} + +CAMLprim value llvm_di_type_get_offset_in_bits(LLVMMetadataRef DType) { + uint64_t Size = LLVMDITypeGetOffsetInBits(DType); + return Val_int((int)Size); +} + +CAMLprim value llvm_di_type_get_align_in_bits(LLVMMetadataRef DType) { + uint32_t Size = LLVMDITypeGetAlignInBits(DType); + return Val_int(Size); +} + +CAMLprim value llvm_di_type_get_line(LLVMMetadataRef DType) { + unsigned Line = LLVMDITypeGetLine(DType); + return Val_int(Line); +} + +CAMLprim value llvm_di_type_get_flags(LLVMMetadataRef DType) { + LLVMDIFlags Flags = LLVMDITypeGetLine(DType); + return alloc_diflags(Flags); +} + +CAMLprim value llvm_get_subprogram(LLVMValueRef Func) { + return (ptr_to_option(LLVMGetSubprogram(Func))); +} + +CAMLprim value llvm_set_subprogram(LLVMValueRef Func, LLVMMetadataRef SP) { + LLVMSetSubprogram(Func, SP); + return Val_unit; +} + +CAMLprim value llvm_di_subprogram_get_line(LLVMMetadataRef Subprogram) { + return Val_int(LLVMDISubprogramGetLine(Subprogram)); +} + +CAMLprim value llvm_instr_get_debug_loc(LLVMValueRef Inst) { + return (ptr_to_option(LLVMInstructionGetDebugLoc(Inst))); +} + +CAMLprim value llvm_instr_set_debug_loc(LLVMValueRef Inst, + LLVMMetadataRef Loc) { + LLVMInstructionSetDebugLoc(Inst, Loc); + return Val_unit; +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_constant_value_expression(value Builder, value Value) { + return LLVMDIBuilderCreateConstantValueExpression(DIBuilder_val(Builder), + (int64_t)Int_val(Value)); +} + +CAMLprim LLVMMetadataRef llvm_dibuild_create_global_variable_expression_native( + value Builder, LLVMMetadataRef Scope, value Name, value Linkage, + LLVMMetadataRef File, value Line, LLVMMetadataRef Ty, value LocalToUnit, + LLVMMetadataRef Expr, LLVMMetadataRef Decl, value AlignInBits) { + return LLVMDIBuilderCreateGlobalVariableExpression( + DIBuilder_val(Builder), Scope, String_val(Name), caml_string_length(Name), + String_val(Linkage), caml_string_length(Linkage), File, Int_val(Line), Ty, + Bool_val(LocalToUnit), Expr, Decl, Int_val(AlignInBits)); +} + +CAMLprim LLVMMetadataRef +llvm_dibuild_create_global_variable_expression_bytecode(value *argv, int arg) { + + return llvm_dibuild_create_global_variable_expression_native( + argv[0], // Builder + (LLVMMetadataRef)argv[1], // Scope + argv[2], // Name + argv[3], // Linkage + (LLVMMetadataRef)argv[4], // File + argv[5], // Line + (LLVMMetadataRef)argv[6], // Ty + argv[7], // LocalToUnit + (LLVMMetadataRef)argv[8], // Expr + (LLVMMetadataRef)argv[9], // Decl + argv[10] // AlignInBits + ); +} + +CAMLprim value +llvm_di_global_variable_expression_get_variable(LLVMMetadataRef GVE) { + return (ptr_to_option(LLVMDIGlobalVariableExpressionGetVariable(GVE))); +} + +CAMLprim value llvm_di_variable_get_line(LLVMMetadataRef Variable) { + return Val_int(LLVMDIVariableGetLine(Variable)); +} + +CAMLprim value llvm_di_variable_get_file(LLVMMetadataRef Variable) { + return (ptr_to_option(LLVMDIVariableGetFile(Variable))); +} + +CAMLprim value llvm_get_metadata_kind(LLVMMetadataRef Metadata) { + return Val_int(LLVMGetMetadataKind(Metadata)); +} diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml new file mode 100644 index 000000000..232efd4cd --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml @@ -0,0 +1,567 @@ +(*===-- llvm_debuginfo.ml - LLVM OCaml Interface --------------*- OCaml -*-===* + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===----------------------------------------------------------------------===*) + +type lldibuilder + +(** Source languages known by DWARF. *) +module DWARFSourceLanguageKind = struct + type t = + | C89 + | C + | Ada83 + | C_plus_plus + | Cobol74 + | Cobol85 + | Fortran77 + | Fortran90 + | Pascal83 + | Modula2 + (* New in DWARF v3: *) + | LLVMJava + | C99 + | Ada95 + | Fortran95 + | PLI + | ObjC + | ObjC_plus_plus + | UPC + | D + (* New in DWARF v4: *) + | LLVMPython + (* New in DWARF v5: *) + | LLVMOpenCL + | Go + | Modula3 + | Haskell + | C_plus_plus_03 + | C_plus_plus_11 + | OCaml + | Rust + | C11 + | Swift + | Julia + | Dylan + | C_plus_plus_14 + | Fortran03 + | Fortran08 + | RenderScript + | BLISS + (* Vendor extensions: *) + | LLVMMips_Assembler + | GOOGLE_RenderScript + | BORLAND_Delphi +end + +module DIFlag = struct + type t = + | Zero + | Private + | Protected + | Public + | FwdDecl + | AppleBlock + | ReservedBit4 + | Virtual + | Artificial + | Explicit + | Prototyped + | ObjcClassComplete + | ObjectPointer + | Vector + | StaticMember + | LValueReference + | RValueReference + | Reserved + | SingleInheritance + | MultipleInheritance + | VirtualInheritance + | IntroducedVirtual + | BitField + | NoReturn + | TypePassByValue + | TypePassByReference + | EnumClass + | FixedEnum + | Thunk + | NonTrivial + | BigEndian + | LittleEndian + | IndirectVirtualBase + | Accessibility + | PtrToMemberRep +end + +type lldiflags + +external diflags_get : DIFlag.t -> lldiflags = "llvm_diflags_get" + +external diflags_set : lldiflags -> DIFlag.t -> lldiflags = "llvm_diflags_set" + +external diflags_test : lldiflags -> DIFlag.t -> bool = "llvm_diflags_test" + +(** The kind of metadata nodes. *) +module MetadataKind = struct + type t = + | MDStringMetadataKind + | ConstantAsMetadataMetadataKind + | LocalAsMetadataMetadataKind + | DistinctMDOperandPlaceholderMetadataKind + | MDTupleMetadataKind + | DILocationMetadataKind + | DIExpressionMetadataKind + | DIGlobalVariableExpressionMetadataKind + | GenericDINodeMetadataKind + | DISubrangeMetadataKind + | DIEnumeratorMetadataKind + | DIBasicTypeMetadataKind + | DIDerivedTypeMetadataKind + | DICompositeTypeMetadataKind + | DISubroutineTypeMetadataKind + | DIFileMetadataKind + | DICompileUnitMetadataKind + | DISubprogramMetadataKind + | DILexicalBlockMetadataKind + | DILexicalBlockFileMetadataKind + | DINamespaceMetadataKind + | DIModuleMetadataKind + | DITemplateTypeParameterMetadataKind + | DITemplateValueParameterMetadataKind + | DIGlobalVariableMetadataKind + | DILocalVariableMetadataKind + | DILabelMetadataKind + | DIObjCPropertyMetadataKind + | DIImportedEntityMetadataKind + | DIMacroMetadataKind + | DIMacroFileMetadataKind + | DICommonBlockMetadataKind +end + +(** The amount of debug information to emit. *) +module DWARFEmissionKind = struct + type t = None | Full | LineTablesOnly +end + +external debug_metadata_version : unit -> int = "llvm_debug_metadata_version" + +external get_module_debug_metadata_version : Llvm.llmodule -> int + = "llvm_get_module_debug_metadata_version" + +external dibuilder : Llvm.llmodule -> lldibuilder = "llvm_dibuilder" + +external dibuild_finalize : lldibuilder -> unit = "llvm_dibuild_finalize" + +(* See LLVMDIBuilderCreateCompileUnit for argument details. *) +external dibuild_create_compile_unit : + lldibuilder -> + DWARFSourceLanguageKind.t -> + file_ref:Llvm.llmetadata -> + producer:string -> + is_optimized:bool -> + flags:string -> + runtime_ver:int -> + split_name:string -> + DWARFEmissionKind.t -> + dwoid:int -> + di_inlining:bool -> + di_profiling:bool -> + sys_root:string -> + sdk:string -> + Llvm.llmetadata + = "llvm_dibuild_create_compile_unit_bytecode" "llvm_dibuild_create_compile_unit_native" + +external dibuild_create_file : + lldibuilder -> filename:string -> directory:string -> Llvm.llmetadata + = "llvm_dibuild_create_file" + +external dibuild_create_module : + lldibuilder -> + parent_ref:Llvm.llmetadata -> + name:string -> + config_macros:string -> + include_path:string -> + sys_root:string -> + Llvm.llmetadata + = "llvm_dibuild_create_module_bytecode" "llvm_dibuild_create_module_native" + +external dibuild_create_namespace : + lldibuilder -> + parent_ref:Llvm.llmetadata -> + name:string -> + export_symbols:bool -> + Llvm.llmetadata = "llvm_dibuild_create_namespace" + +external dibuild_create_function : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + linkage_name:string -> + file:Llvm.llmetadata -> + line_no:int -> + ty:Llvm.llmetadata -> + is_local_to_unit:bool -> + is_definition:bool -> + scope_line:int -> + flags:lldiflags -> + is_optimized:bool -> + Llvm.llmetadata + = "llvm_dibuild_create_function_bytecode" "llvm_dibuild_create_function_native" + +external dibuild_create_lexical_block : + lldibuilder -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + column:int -> + Llvm.llmetadata = "llvm_dibuild_create_lexical_block" + +external dibuild_create_debug_location_helper : + Llvm.llcontext -> + line:int -> + column:int -> + scope:Llvm.llmetadata -> + inlined_at:Llvm.llmetadata -> + Llvm.llmetadata = "llvm_dibuild_create_debug_location" + +external llmetadata_null : unit -> Llvm.llmetadata = "llvm_metadata_null" + +let dibuild_create_debug_location ?(inlined_at = llmetadata_null ()) llctx ~line + ~column ~scope = + dibuild_create_debug_location_helper llctx line column scope inlined_at + +external di_location_get_line : location:Llvm.llmetadata -> int + = "llvm_di_location_get_line" + +external di_location_get_column : location:Llvm.llmetadata -> int + = "llvm_di_location_get_column" + +external di_location_get_scope : location:Llvm.llmetadata -> Llvm.llmetadata + = "llvm_di_location_get_scope" + +external di_location_get_inlined_at : + location:Llvm.llmetadata -> Llvm.llmetadata option + = "llvm_di_location_get_inlined_at" + +external di_scope_get_file : scope:Llvm.llmetadata -> Llvm.llmetadata option + = "llvm_di_scope_get_file" + +external di_file_get_directory : file:Llvm.llmetadata -> string + = "llvm_di_file_get_directory" + +external di_file_get_filename : file:Llvm.llmetadata -> string + = "llvm_di_file_get_filename" + +external di_file_get_source : file:Llvm.llmetadata -> string + = "llvm_di_file_get_source" + +external dibuild_get_or_create_type_array : + lldibuilder -> data:Llvm.llmetadata array -> Llvm.llmetadata + = "llvm_dibuild_get_or_create_type_array" + +external dibuild_get_or_create_array : + lldibuilder -> data:Llvm.llmetadata array -> Llvm.llmetadata + = "llvm_dibuild_get_or_create_array" + +external dibuild_create_subroutine_type : + lldibuilder -> + file:Llvm.llmetadata -> + param_types:Llvm.llmetadata array -> + lldiflags -> + Llvm.llmetadata = "llvm_dibuild_create_subroutine_type" + +external dibuild_create_enumerator : + lldibuilder -> name:string -> value:int -> is_unsigned:bool -> Llvm.llmetadata + = "llvm_dibuild_create_enumerator" + +external dibuild_create_enumeration_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + elements:Llvm.llmetadata array -> + class_ty:Llvm.llmetadata -> + Llvm.llmetadata + = "llvm_dibuild_create_enumeration_type_bytecode" "llvm_dibuild_create_enumeration_type_native" + +external dibuild_create_union_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + elements:Llvm.llmetadata array -> + run_time_language:int -> + unique_id:string -> + Llvm.llmetadata + = "llvm_dibuild_create_union_type_bytecode" "llvm_dibuild_create_union_type_native" + +external dibuild_create_array_type : + lldibuilder -> + size:int -> + align_in_bits:int -> + ty:Llvm.llmetadata -> + subscripts:Llvm.llmetadata array -> + Llvm.llmetadata = "llvm_dibuild_create_array_type" + +external dibuild_create_vector_type : + lldibuilder -> + size:int -> + align_in_bits:int -> + ty:Llvm.llmetadata -> + subscripts:Llvm.llmetadata array -> + Llvm.llmetadata = "llvm_dibuild_create_array_type" + +external dibuild_create_unspecified_type : + lldibuilder -> name:string -> Llvm.llmetadata + = "llvm_dibuild_create_unspecified_type" + +external dibuild_create_basic_type : + lldibuilder -> + name:string -> + size_in_bits:int -> + encoding:int -> + lldiflags -> + Llvm.llmetadata = "llvm_dibuild_create_basic_type" + +external dibuild_create_pointer_type : + lldibuilder -> + pointee_ty:Llvm.llmetadata -> + size_in_bits:int -> + align_in_bits:int -> + address_space:int -> + name:string -> + Llvm.llmetadata + = "llvm_dibuild_create_pointer_type_bytecode" "llvm_dibuild_create_pointer_type_native" + +external dibuild_create_struct_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + derived_from:Llvm.llmetadata -> + elements:Llvm.llmetadata array -> + DWARFSourceLanguageKind.t -> + vtable_holder:Llvm.llmetadata -> + unique_id:string -> + Llvm.llmetadata + = "llvm_dibuild_create_struct_type_bytecode" "llvm_dibuild_create_struct_type_native" + +external dibuild_create_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + offset_in_bits:int -> + lldiflags -> + ty:Llvm.llmetadata -> + Llvm.llmetadata + = "llvm_dibuild_create_member_type_bytecode" "llvm_dibuild_create_member_type_native" + +external dibuild_create_static_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + ty:Llvm.llmetadata -> + lldiflags -> + const_val:Llvm.llvalue -> + align_in_bits:int -> + Llvm.llmetadata + = "llvm_dibuild_create_static_member_type_bytecode" "llvm_dibuild_create_static_member_type_native" + +external dibuild_create_member_pointer_type : + lldibuilder -> + pointee_type:Llvm.llmetadata -> + class_type:Llvm.llmetadata -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + Llvm.llmetadata + = "llvm_dibuild_create_member_pointer_type_bytecode" "llvm_dibuild_create_member_pointer_type_native" + +external dibuild_create_object_pointer_type : + lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata + = "llvm_dibuild_create_object_pointer_type" + +external dibuild_create_qualified_type : + lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata + = "llvm_dibuild_create_qualified_type" + +external dibuild_create_reference_type : + lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata + = "llvm_dibuild_create_reference_type" + +external dibuild_create_null_ptr_type : lldibuilder -> Llvm.llmetadata + = "llvm_dibuild_create_null_ptr_type" + +external dibuild_create_typedef : + lldibuilder -> + ty:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_no:int -> + scope:Llvm.llmetadata -> + align_in_bits:int -> + Llvm.llmetadata + = "llvm_dibuild_create_typedef_bytecode" "llvm_dibuild_create_typedef_native" + +external dibuild_create_inheritance : + lldibuilder -> + ty:Llvm.llmetadata -> + base_ty:Llvm.llmetadata -> + base_offset:int -> + vb_ptr_offset:int -> + lldiflags -> + Llvm.llmetadata + = "llvm_dibuild_create_inheritance_bytecode" "llvm_dibuild_create_inheritance_native" + +external dibuild_create_forward_decl : + lldibuilder -> + tag:int -> + name:string -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + runtime_lang:int -> + size_in_bits:int -> + align_in_bits:int -> + unique_identifier:string -> + Llvm.llmetadata + = "llvm_dibuild_create_forward_decl_bytecode" "llvm_dibuild_create_forward_decl_native" + +external dibuild_create_replaceable_composite_type : + lldibuilder -> + tag:int -> + name:string -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + runtime_lang:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + unique_identifier:string -> + Llvm.llmetadata + = "llvm_dibuild_create_replaceable_composite_type_bytecode" "llvm_dibuild_create_replaceable_composite_type_native" + +external dibuild_create_bit_field_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_num:int -> + size_in_bits:int -> + offset_in_bits:int -> + storage_offset_in_bits:int -> + lldiflags -> + ty:Llvm.llmetadata -> + Llvm.llmetadata + = "llvm_dibuild_create_bit_field_member_type_bytecode" "llvm_dibuild_create_bit_field_member_type_native" + +external dibuild_create_class_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + offset_in_bits:int -> + lldiflags -> + derived_from:Llvm.llmetadata -> + elements:Llvm.llmetadata array -> + vtable_holder:Llvm.llmetadata -> + template_params_node:Llvm.llmetadata -> + unique_identifier:string -> + Llvm.llmetadata + = "llvm_dibuild_create_class_type_bytecode" "llvm_dibuild_create_class_type_native" + +external dibuild_create_artificial_type : + lldibuilder -> ty:Llvm.llmetadata -> Llvm.llmetadata + = "llvm_dibuild_create_artificial_type" + +external di_type_get_name : Llvm.llmetadata -> string = "llvm_di_type_get_name" + +external di_type_get_size_in_bits : Llvm.llmetadata -> int + = "llvm_di_type_get_size_in_bits" + +external di_type_get_offset_in_bits : Llvm.llmetadata -> int + = "llvm_di_type_get_offset_in_bits" + +external di_type_get_align_in_bits : Llvm.llmetadata -> int + = "llvm_di_type_get_align_in_bits" + +external di_type_get_line : Llvm.llmetadata -> int = "llvm_di_type_get_line" + +external di_type_get_flags : Llvm.llmetadata -> lldiflags + = "llvm_di_type_get_flags" + +external get_subprogram : Llvm.llvalue -> Llvm.llmetadata option + = "llvm_get_subprogram" + +external set_subprogram : Llvm.llvalue -> Llvm.llmetadata -> unit + = "llvm_set_subprogram" + +external di_subprogram_get_line : Llvm.llmetadata -> int + = "llvm_di_subprogram_get_line" + +external instr_get_debug_loc : Llvm.llvalue -> Llvm.llmetadata option + = "llvm_instr_get_debug_loc" + +external instr_set_debug_loc_helper : Llvm.llvalue -> Llvm.llmetadata -> unit + = "llvm_instr_set_debug_loc" + +let instr_set_debug_loc i mopt = + match mopt with + | None -> instr_set_debug_loc_helper i (llmetadata_null ()) + | Some m -> instr_set_debug_loc_helper i m + +external dibuild_create_constant_value_expression : + lldibuilder -> int -> Llvm.llmetadata + = "llvm_dibuild_create_constant_value_expression" + +external dibuild_create_global_variable_expression : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + linkage:string -> + file:Llvm.llmetadata -> + line:int -> + ty:Llvm.llmetadata -> + is_local_to_unit:bool -> + expr:Llvm.llmetadata -> + decl:Llvm.llmetadata -> + align_in_bits:int -> + Llvm.llmetadata + = "llvm_dibuild_create_global_variable_expression_bytecode" "llvm_dibuild_create_global_variable_expression_native" + +external di_global_variable_expression_get_variable : + Llvm.llmetadata -> Llvm.llmetadata option + = "llvm_di_global_variable_expression_get_variable" + +external di_variable_get_line : Llvm.llmetadata -> int + = "llvm_di_variable_get_line" + +external di_variable_get_file : Llvm.llmetadata -> Llvm.llmetadata option + = "llvm_di_variable_get_file" + +external get_metadata_kind : Llvm.llmetadata -> MetadataKind.t + = "llvm_get_metadata_kind" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli new file mode 100644 index 000000000..7f2bb6dd5 --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli @@ -0,0 +1,625 @@ +(*===-- llvm_debuginfo.mli - LLVM OCaml Interface -------------*- OCaml -*-===* + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===----------------------------------------------------------------------===*) + +type lldibuilder + +(** Source languages known by DWARF. *) +module DWARFSourceLanguageKind : sig + type t = + | C89 + | C + | Ada83 + | C_plus_plus + | Cobol74 + | Cobol85 + | Fortran77 + | Fortran90 + | Pascal83 + | Modula2 + (* New in DWARF v3: *) + | LLVMJava + | C99 + | Ada95 + | Fortran95 + | PLI + | ObjC + | ObjC_plus_plus + | UPC + | D + (* New in DWARF v4: *) + | LLVMPython + (* New in DWARF v5: *) + | LLVMOpenCL + | Go + | Modula3 + | Haskell + | C_plus_plus_03 + | C_plus_plus_11 + | OCaml + | Rust + | C11 + | Swift + | Julia + | Dylan + | C_plus_plus_14 + | Fortran03 + | Fortran08 + | RenderScript + | BLISS + (* Vendor extensions: *) + | LLVMMips_Assembler + | GOOGLE_RenderScript + | BORLAND_Delphi +end + +module DIFlag : sig + type t = + | Zero + | Private + | Protected + | Public + | FwdDecl + | AppleBlock + | ReservedBit4 + | Virtual + | Artificial + | Explicit + | Prototyped + | ObjcClassComplete + | ObjectPointer + | Vector + | StaticMember + | LValueReference + | RValueReference + | Reserved + | SingleInheritance + | MultipleInheritance + | VirtualInheritance + | IntroducedVirtual + | BitField + | NoReturn + | TypePassByValue + | TypePassByReference + | EnumClass + | FixedEnum + | Thunk + | NonTrivial + | BigEndian + | LittleEndian + | IndirectVirtualBase + | Accessibility + | PtrToMemberRep +end + +type lldiflags +(** An opaque type to represent OR of multiple DIFlag.t. *) + +val diflags_get : DIFlag.t -> lldiflags +(** [diflags_set f] Construct an lldiflags value with a single flag [f]. *) + +val diflags_set : lldiflags -> DIFlag.t -> lldiflags +(** [diflags_set fs f] Include flag [f] in [fs] and return the new value. *) + +val diflags_test : lldiflags -> DIFlag.t -> bool +(** [diflags_test fs f] Does [fs] contain flag [f]? *) + +(** The kind of metadata nodes. *) +module MetadataKind : sig + type t = + | MDStringMetadataKind + | ConstantAsMetadataMetadataKind + | LocalAsMetadataMetadataKind + | DistinctMDOperandPlaceholderMetadataKind + | MDTupleMetadataKind + | DILocationMetadataKind + | DIExpressionMetadataKind + | DIGlobalVariableExpressionMetadataKind + | GenericDINodeMetadataKind + | DISubrangeMetadataKind + | DIEnumeratorMetadataKind + | DIBasicTypeMetadataKind + | DIDerivedTypeMetadataKind + | DICompositeTypeMetadataKind + | DISubroutineTypeMetadataKind + | DIFileMetadataKind + | DICompileUnitMetadataKind + | DISubprogramMetadataKind + | DILexicalBlockMetadataKind + | DILexicalBlockFileMetadataKind + | DINamespaceMetadataKind + | DIModuleMetadataKind + | DITemplateTypeParameterMetadataKind + | DITemplateValueParameterMetadataKind + | DIGlobalVariableMetadataKind + | DILocalVariableMetadataKind + | DILabelMetadataKind + | DIObjCPropertyMetadataKind + | DIImportedEntityMetadataKind + | DIMacroMetadataKind + | DIMacroFileMetadataKind + | DICommonBlockMetadataKind +end + +(** The amount of debug information to emit. *) +module DWARFEmissionKind : sig + type t = None | Full | LineTablesOnly +end + +val debug_metadata_version : unit -> int +(** [debug_metadata_version ()] The current debug metadata version number *) + +val get_module_debug_metadata_version : Llvm.llmodule -> int +(** [get_module_debug_metadata_version m] Version of metadata present in [m]. *) + +val dibuilder : Llvm.llmodule -> lldibuilder +(** [dibuilder m] Create a debug info builder for [m]. *) + +val dibuild_finalize : lldibuilder -> unit +(** [dibuild_finalize dib] Construct any deferred debug info descriptors. *) + +val dibuild_create_compile_unit : + lldibuilder -> + DWARFSourceLanguageKind.t -> + file_ref:Llvm.llmetadata -> + producer:string -> + is_optimized:bool -> + flags:string -> + runtime_ver:int -> + split_name:string -> + DWARFEmissionKind.t -> + dwoid:int -> + di_inlining:bool -> + di_profiling:bool -> + sys_root:string -> + sdk:string -> + Llvm.llmetadata +(** [dibuild_create_compile_unit] A CompileUnit provides an anchor for all + debugging information generated during this instance of compilation. + See LLVMDIBuilderCreateCompileUnit. *) + +val dibuild_create_file : + lldibuilder -> filename:string -> directory:string -> Llvm.llmetadata +(** [dibuild_create_file] Create a file descriptor to hold debugging information + for a file. See LLVMDIBuilderCreateFile. *) + +val dibuild_create_module : + lldibuilder -> + parent_ref:Llvm.llmetadata -> + name:string -> + config_macros:string -> + include_path:string -> + sys_root:string -> + Llvm.llmetadata +(** [dibuild_create_module] Create a new descriptor for a module with the + specified parent scope. See LLVMDIBuilderCreateModule. *) + +val dibuild_create_namespace : + lldibuilder -> + parent_ref:Llvm.llmetadata -> + name:string -> + export_symbols:bool -> + Llvm.llmetadata +(** [dibuild_create_namespace] Create a new descriptor for a namespace with + the specified parent scope. See LLVMDIBuilderCreateNameSpace *) + +val dibuild_create_function : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + linkage_name:string -> + file:Llvm.llmetadata -> + line_no:int -> + ty:Llvm.llmetadata -> + is_local_to_unit:bool -> + is_definition:bool -> + scope_line:int -> + flags:lldiflags -> + is_optimized:bool -> + Llvm.llmetadata +(** [dibuild_create_function] Create a new descriptor for the specified + subprogram. See LLVMDIBuilderCreateFunction. *) + +val dibuild_create_lexical_block : + lldibuilder -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + column:int -> + Llvm.llmetadata +(** [dibuild_create_lexical_block] Create a descriptor for a lexical block with + the specified parent context. See LLVMDIBuilderCreateLexicalBlock *) + +val llmetadata_null : unit -> Llvm.llmetadata +(** [llmetadata_null ()] llmetadata is a wrapper around "llvm::Metadata *". + This function returns a nullptr valued llmetadata. For example, it + can be used to convey an llmetadata for "void" type. *) + +val dibuild_create_debug_location : + ?inlined_at:Llvm.llmetadata -> + Llvm.llcontext -> + line:int -> + column:int -> + scope:Llvm.llmetadata -> + Llvm.llmetadata +(** [dibuild_create] Create a new DebugLocation that describes a source + location. See LLVMDIBuilderCreateDebugLocation *) + +val di_location_get_line : location:Llvm.llmetadata -> int +(** [di_location_get_line l] Get the line number of debug location [l]. *) + +val di_location_get_column : location:Llvm.llmetadata -> int +(** [di_location_get_column l] Get the column number of debug location [l]. *) + +val di_location_get_scope : location:Llvm.llmetadata -> Llvm.llmetadata +(** [di_location_get_scope l] Get the local scope associated with + debug location [l]. *) + +val di_location_get_inlined_at : + location:Llvm.llmetadata -> Llvm.llmetadata option +(** [di_location_get_inlined_at l] Get the "inlined at" location associated with + debug location [l], if it exists. *) + +val di_scope_get_file : scope:Llvm.llmetadata -> Llvm.llmetadata option +(** [di_scope_get_file l] Get the metadata of the file associated with scope [s] + if it exists. *) + +val di_file_get_directory : file:Llvm.llmetadata -> string +(** [di_file_get_directory f] Get the directory of file [f]. *) + +val di_file_get_filename : file:Llvm.llmetadata -> string +(** [di_file_get_filename f] Get the name of file [f]. *) + +val di_file_get_source : file:Llvm.llmetadata -> string +(** [di_file_get_source f] Get the source of file [f]. *) + +val dibuild_get_or_create_type_array : + lldibuilder -> data:Llvm.llmetadata array -> Llvm.llmetadata +(** [dibuild_get_or_create_type_array] Create a type array. + See LLVMDIBuilderGetOrCreateTypeArray. *) + +val dibuild_get_or_create_array : + lldibuilder -> data:Llvm.llmetadata array -> Llvm.llmetadata +(** [dibuild_get_or_create_array] Create an array of DI Nodes. + See LLVMDIBuilderGetOrCreateArray. *) + +val dibuild_create_constant_value_expression : + lldibuilder -> int -> Llvm.llmetadata +(** [dibuild_create_constant_value_expression] Create a new descriptor for + the specified variable that does not have an address, but does have + a constant value. See LLVMDIBuilderCreateConstantValueExpression. *) + +val dibuild_create_global_variable_expression : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + linkage:string -> + file:Llvm.llmetadata -> + line:int -> + ty:Llvm.llmetadata -> + is_local_to_unit:bool -> + expr:Llvm.llmetadata -> + decl:Llvm.llmetadata -> + align_in_bits:int -> + Llvm.llmetadata +(** [dibuild_create_global_variable_expression] Create a new descriptor for + the specified variable. See LLVMDIBuilderCreateGlobalVariableExpression. *) + +val di_global_variable_expression_get_variable : + Llvm.llmetadata -> Llvm.llmetadata option +(** [di_global_variable_expression_get_variable gve] returns the debug variable + of [gve], which must be a [DIGlobalVariableExpression]. + See LLVMDIGlobalVariableExpressionGetVariable. *) + +val di_variable_get_line : Llvm.llmetadata -> int +(** [di_variable_get_line v] returns the line number of the variable [v]. + See LLVMDIVariableGetLine. *) + +val di_variable_get_file : Llvm.llmetadata -> Llvm.llmetadata option +(** [di_variable_get_file v] returns the file of the variable [v]. + See LLVMDIVariableGetFile. *) + +val dibuild_create_subroutine_type : + lldibuilder -> + file:Llvm.llmetadata -> + param_types:Llvm.llmetadata array -> + lldiflags -> + Llvm.llmetadata +(** [dibuild_create_subroutine_type] Create subroutine type. + See LLVMDIBuilderCreateSubroutineType *) + +val dibuild_create_enumerator : + lldibuilder -> name:string -> value:int -> is_unsigned:bool -> Llvm.llmetadata +(** [dibuild_create_enumerator] Create debugging information entry for an + enumerator. See LLVMDIBuilderCreateEnumerator *) + +val dibuild_create_enumeration_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + elements:Llvm.llmetadata array -> + class_ty:Llvm.llmetadata -> + Llvm.llmetadata +(** [dibuild_create_enumeration_type] Create debugging information entry for + an enumeration. See LLVMDIBuilderCreateEnumerationType. *) + +val dibuild_create_union_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + elements:Llvm.llmetadata array -> + run_time_language:int -> + unique_id:string -> + Llvm.llmetadata +(** [dibuild_create_union_type] Create debugging information entry for a union. + See LLVMDIBuilderCreateUnionType. *) + +val dibuild_create_array_type : + lldibuilder -> + size:int -> + align_in_bits:int -> + ty:Llvm.llmetadata -> + subscripts:Llvm.llmetadata array -> + Llvm.llmetadata +(** [dibuild_create_array_type] Create debugging information entry for an array. + See LLVMDIBuilderCreateArrayType. *) + +val dibuild_create_vector_type : + lldibuilder -> + size:int -> + align_in_bits:int -> + ty:Llvm.llmetadata -> + subscripts:Llvm.llmetadata array -> + Llvm.llmetadata +(** [dibuild_create_vector_type] Create debugging information entry for a + vector type. See LLVMDIBuilderCreateVectorType. *) + +val dibuild_create_unspecified_type : + lldibuilder -> name:string -> Llvm.llmetadata +(** [dibuild_create_unspecified_type] Create a DWARF unspecified type. *) + +val dibuild_create_basic_type : + lldibuilder -> + name:string -> + size_in_bits:int -> + encoding:int -> + lldiflags -> + Llvm.llmetadata +(** [dibuild_create_basic_type] Create debugging information entry for a basic + type. See LLVMDIBuilderCreateBasicType. *) + +val dibuild_create_pointer_type : + lldibuilder -> + pointee_ty:Llvm.llmetadata -> + size_in_bits:int -> + align_in_bits:int -> + address_space:int -> + name:string -> + Llvm.llmetadata +(** [dibuild_create_pointer_type] Create debugging information entry for a + pointer. See LLVMDIBuilderCreatePointerType. *) + +val dibuild_create_struct_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + derived_from:Llvm.llmetadata -> + elements:Llvm.llmetadata array -> + DWARFSourceLanguageKind.t -> + vtable_holder:Llvm.llmetadata -> + unique_id:string -> + Llvm.llmetadata +(** [dibuild_create_struct_type] Create debugging information entry for a + struct. See LLVMDIBuilderCreateStructType *) + +val dibuild_create_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + offset_in_bits:int -> + lldiflags -> + ty:Llvm.llmetadata -> + Llvm.llmetadata +(** [dibuild_create_member_type] Create debugging information entry for a + member. See LLVMDIBuilderCreateMemberType. *) + +val dibuild_create_static_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + ty:Llvm.llmetadata -> + lldiflags -> + const_val:Llvm.llvalue -> + align_in_bits:int -> + Llvm.llmetadata +(** [dibuild_create_static_member_type] Create debugging information entry for + a C++ static data member. See LLVMDIBuilderCreateStaticMemberType *) + +val dibuild_create_member_pointer_type : + lldibuilder -> + pointee_type:Llvm.llmetadata -> + class_type:Llvm.llmetadata -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + Llvm.llmetadata +(** [dibuild_create_member_pointer_type] Create debugging information entry for + a pointer to member. See LLVMDIBuilderCreateMemberPointerType *) + +val dibuild_create_object_pointer_type : + lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata +(** [dibuild_create_object_pointer_type dib ty] Create a uniqued DIType* clone + with FlagObjectPointer and FlagArtificial set. [dib] is the dibuilder + value and [ty] the underlying type to which this pointer points. *) + +val dibuild_create_qualified_type : + lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata +(** [dibuild_create_qualified_type dib tag ty] Create debugging information + entry for a qualified type, e.g. 'const int'. [dib] is the dibuilder value, + [tag] identifyies the type and [ty] is the base type. *) + +val dibuild_create_reference_type : + lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata +(** [dibuild_create_reference_type dib tag ty] Create debugging information + entry for a reference type. [dib] is the dibuilder value, [tag] identifyies + the type and [ty] is the base type. *) + +val dibuild_create_null_ptr_type : lldibuilder -> Llvm.llmetadata +(** [dibuild_create_null_ptr_type dib] Create C++11 nullptr type. *) + +val dibuild_create_typedef : + lldibuilder -> + ty:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_no:int -> + scope:Llvm.llmetadata -> + align_in_bits:int -> + Llvm.llmetadata +(** [dibuild_create_typedef] Create debugging information entry for a typedef. + See LLVMDIBuilderCreateTypedef. *) + +val dibuild_create_inheritance : + lldibuilder -> + ty:Llvm.llmetadata -> + base_ty:Llvm.llmetadata -> + base_offset:int -> + vb_ptr_offset:int -> + lldiflags -> + Llvm.llmetadata +(** [dibuild_create_inheritance] Create debugging information entry + to establish inheritance relationship between two types. + See LLVMDIBuilderCreateInheritance. *) + +val dibuild_create_forward_decl : + lldibuilder -> + tag:int -> + name:string -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + runtime_lang:int -> + size_in_bits:int -> + align_in_bits:int -> + unique_identifier:string -> + Llvm.llmetadata +(** [dibuild_create_forward_decl] Create a permanent forward-declared type. + See LLVMDIBuilderCreateForwardDecl. *) + +val dibuild_create_replaceable_composite_type : + lldibuilder -> + tag:int -> + name:string -> + scope:Llvm.llmetadata -> + file:Llvm.llmetadata -> + line:int -> + runtime_lang:int -> + size_in_bits:int -> + align_in_bits:int -> + lldiflags -> + unique_identifier:string -> + Llvm.llmetadata +(** [dibuild_create_replaceable_composite_type] Create a temporary + forward-declared type. See LLVMDIBuilderCreateReplaceableCompositeType. *) + +val dibuild_create_bit_field_member_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_num:int -> + size_in_bits:int -> + offset_in_bits:int -> + storage_offset_in_bits:int -> + lldiflags -> + ty:Llvm.llmetadata -> + Llvm.llmetadata +(** [dibuild_create_bit_field_member_type] Create debugging information entry + for a bit field member. See LLVMDIBuilderCreateBitFieldMemberType. *) + +val dibuild_create_class_type : + lldibuilder -> + scope:Llvm.llmetadata -> + name:string -> + file:Llvm.llmetadata -> + line_number:int -> + size_in_bits:int -> + align_in_bits:int -> + offset_in_bits:int -> + lldiflags -> + derived_from:Llvm.llmetadata -> + elements:Llvm.llmetadata array -> + vtable_holder:Llvm.llmetadata -> + template_params_node:Llvm.llmetadata -> + unique_identifier:string -> + Llvm.llmetadata +(** [dibuild_create_class_type] Create debugging information entry for a class. + See LLVMDIBuilderCreateClassType. *) + +val dibuild_create_artificial_type : + lldibuilder -> ty:Llvm.llmetadata -> Llvm.llmetadata +(** [dibuild_create_artificial_type dib ty] Create a uniqued DIType* clone with + FlagArtificial set. + [dib] is the dibuilder value and [ty] the underlying type. *) + +val di_type_get_name : Llvm.llmetadata -> string +(** [di_type_get_name m] Get the name of DIType [m]. *) + +val di_type_get_size_in_bits : Llvm.llmetadata -> int +(** [di_type_get_size_in_bits m] Get size in bits of DIType [m]. *) + +val di_type_get_offset_in_bits : Llvm.llmetadata -> int +(** [di_type_get_offset_in_bits m] Get offset in bits of DIType [m]. *) + +val di_type_get_align_in_bits : Llvm.llmetadata -> int +(** [di_type_get_align_in_bits m] Get alignment in bits of DIType [m]. *) + +val di_type_get_line : Llvm.llmetadata -> int +(** [di_type_get_line m] Get source line where DIType [m] is declared. *) + +val di_type_get_flags : Llvm.llmetadata -> lldiflags +(** [di_type_get_flags m] Get the flags associated with DIType [m]. *) + +val get_subprogram : Llvm.llvalue -> Llvm.llmetadata option +(** [get_subprogram f] Get the metadata of the subprogram attached to + function [f]. *) + +val set_subprogram : Llvm.llvalue -> Llvm.llmetadata -> unit +(** [set_subprogram f m] Set the subprogram [m] attached to function [f]. *) + +val di_subprogram_get_line : Llvm.llmetadata -> int +(** [di_subprogram_get_line m] Get the line associated with subprogram [m]. *) + +val instr_get_debug_loc : Llvm.llvalue -> Llvm.llmetadata option +(** [instr_get_debug_loc i] Get the debug location for instruction [i]. *) + +val instr_set_debug_loc : Llvm.llvalue -> Llvm.llmetadata option -> unit +(** [instr_set_debug_loc i mopt] If [mopt] is None location metadata of [i] + is cleared, Otherwise location of [i] is set to the value in [mopt]. *) + +val get_metadata_kind : Llvm.llmetadata -> MetadataKind.t +(** [get_metadata_kind] Obtain the enumerated type of a Metadata instance. *) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/executionengine/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/executionengine/CMakeLists.txt index ae9af088c..0b1428aac 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/executionengine/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/executionengine/CMakeLists.txt @@ -2,5 +2,5 @@ add_ocaml_library(llvm_executionengine OCAML llvm_executionengine OCAMLDEP llvm llvm_target C executionengine_ocaml - LLVM executionengine mcjit native + LLVM ExecutionEngine MCJIT native PKG ctypes) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/irreader/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/irreader/CMakeLists.txt index 87d269b48..5654b1803 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/irreader/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/irreader/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_irreader OCAML llvm_irreader OCAMLDEP llvm C irreader_ocaml - LLVM irreader) + LLVM IRReader) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/linker/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/linker/CMakeLists.txt index b6bc8ac1e..3bb367225 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/linker/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/linker/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_linker OCAML llvm_linker OCAMLDEP llvm C linker_ocaml - LLVM linker) + LLVM Linker) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/CMakeLists.txt index db7aee2ad..5e6f74ec9 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/CMakeLists.txt @@ -1,7 +1,8 @@ add_ocaml_library(llvm OCAML llvm C llvm_ocaml - LLVM core support) + CFLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/" + LLVM Core Support) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/META.llvm.in" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/META.llvm.in b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/META.llvm.in index adafd788e..991bbc060 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/META.llvm.in +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/META.llvm.in @@ -45,6 +45,14 @@ package "ipo" ( archive(native) = "llvm_ipo.cmxa" ) +package "debuginfo" ( + requires = "llvm" + version = "@PACKAGE_VERSION@" + description = "DebugInfo support for LLVM" + archive(byte) = "llvm_debuginfo.cma" + archive(native) = "llvm_debuginfo.cmxa" +) + package "irreader" ( requires = "llvm" version = "@PACKAGE_VERSION@" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.ml b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.ml index d54ec6f1f..4fabdf469 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.ml +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.ml @@ -9,6 +9,7 @@ type llcontext type llmodule +type llmetadata type lltype type llvalue type lluse @@ -330,6 +331,16 @@ module DiagnosticSeverity = struct | Note end +module ModuleFlagBehavior = struct + type t = + | Error + | Warning + | Require + | Override + | Append + | AppendUnique +end + exception IoError of string let () = Callback.register_exception "Llvm.IoError" (IoError "") @@ -430,6 +441,17 @@ external set_module_inline_asm : llmodule -> string -> unit = "llvm_set_module_inline_asm" external module_context : llmodule -> llcontext = "LLVMGetModuleContext" +external get_module_identifier : llmodule -> string + = "llvm_get_module_identifier" + +external set_module_identifer : llmodule -> string -> unit + = "llvm_set_module_identifier" + +external get_module_flag : llmodule -> string -> llmetadata option + = "llvm_get_module_flag" +external add_module_flag : llmodule -> ModuleFlagBehavior.t -> + string -> llmetadata -> unit = "llvm_add_module_flag" + (*===-- Types -------------------------------------------------------------===*) external classify_type : lltype -> TypeKind.t = "llvm_classify_type" external type_context : lltype -> llcontext = "llvm_type_context" @@ -577,6 +599,9 @@ external get_debug_loc_directory : llvalue -> string option = "llvm_get_debug_lo external get_debug_loc_filename : llvalue -> string option = "llvm_get_debug_loc_filename" external get_debug_loc_line : llvalue -> int = "llvm_get_debug_loc_line" external get_debug_loc_column : llvalue -> int = "llvm_get_debug_loc_column" +external value_as_metadata : llvalue -> llmetadata = "llvm_value_as_metadata" +external metadata_as_value : llcontext -> llmetadata -> llvalue + = "llvm_metadata_as_value" (*--... Operations on scalar constants .....................................--*) external const_int : lltype -> int -> llvalue = "llvm_const_int" @@ -701,6 +726,8 @@ external dll_storage_class : llvalue -> DLLStorageClass.t = "llvm_dll_storage_cl external set_dll_storage_class : DLLStorageClass.t -> llvalue -> unit = "llvm_set_dll_storage_class" external alignment : llvalue -> int = "llvm_alignment" external set_alignment : int -> llvalue -> unit = "llvm_set_alignment" +external global_copy_all_metadata : llvalue -> (llmdkind * llmetadata) array + = "llvm_global_copy_all_metadata" external is_global_constant : llvalue -> bool = "llvm_is_global_constant" external set_global_constant : bool -> llvalue -> unit = "llvm_set_global_constant" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.mli b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.mli index 0a5915a7d..908ba2e74 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.mli +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm.mli @@ -24,6 +24,9 @@ type llcontext objects. See the [llvm::Module] class. *) type llmodule +(** Opaque representation of Metadata nodes. See the [llvm::Metadata] class. *) +type llmetadata + (** Each value in the LLVM IR has a type, an instance of [lltype]. See the [llvm::Type] class. *) type lltype @@ -365,6 +368,15 @@ module DiagnosticSeverity : sig | Note end +module ModuleFlagBehavior :sig + type t = + | Error + | Warning + | Require + | Override + | Append + | AppendUnique +end (** {6 Iteration} *) @@ -529,7 +541,24 @@ val set_module_inline_asm : llmodule -> string -> unit See the method [llvm::Module::getContext] *) val module_context : llmodule -> llcontext +(** [get_module_identifier m] returns the module identifier of the + specified module. See the method [llvm::Module::getModuleIdentifier] *) +val get_module_identifier : llmodule -> string +(** [set_module_identifier m id] sets the module identifier of [m] + to [id]. See the method [llvm::Module::setModuleIdentifier] *) +val set_module_identifer : llmodule -> string -> unit + +(** [get_module_flag m k] Return the corresponding value if key [k] appears in + the module flags of [m], otherwise return None + See the method [llvm::Module::getModuleFlag] *) +val get_module_flag : llmodule -> string -> llmetadata option + +(** [add_module_flag m b k v] Add a module-level flag b, with key [k] and + value [v] to the flags metadata of module [m]. It will create the + module-level flags named metadata if it doesn't already exist. *) +val add_module_flag : llmodule -> ModuleFlagBehavior.t -> + string -> llmetadata -> unit (** {6 Types} *) (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty]. @@ -940,7 +969,13 @@ val get_debug_loc_line : llvalue -> int for [v], which must be an [Instruction]. See the [llvm::Instruction::getDebugLoc()] method. *) val get_debug_loc_column : llvalue -> int +(** Obtain a Metadata as a Value. + See the method [llvm::ValueAsMetadata::get()]. *) +val value_as_metadata : llvalue -> llmetadata +(** Obtain a Value as a Metadata. + See the method [llvm::MetadataAsValue::get()]. *) +val metadata_as_value : llcontext -> llmetadata -> llvalue (** {7 Operations on scalar constants} *) @@ -948,8 +983,9 @@ val get_debug_loc_column : llvalue -> int See the method [llvm::ConstantInt::get]. *) val const_int : lltype -> int -> llvalue -(** [const_of_int64 ty i] returns the integer constant of type [ty] and value - [i]. See the method [llvm::ConstantInt::get]. *) +(** [const_of_int64 ty i s] returns the integer constant of type [ty] and value + [i]. [s] indicates whether the integer is signed or not. + See the method [llvm::ConstantInt::get]. *) val const_of_int64 : lltype -> Int64.t -> bool -> llvalue (** [int64_of_const c] returns the int64 value of the [c] constant integer. @@ -1400,6 +1436,12 @@ val alignment : llvalue -> int [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *) val set_alignment : int -> llvalue -> unit +(** [global_copy_all_metadata g] returns all the metadata associated with [g], + which must be an [Instruction] or [GlobalObject]. + See the [llvm::Instruction::getAllMetadata()] and + [llvm::GlobalObject::getAllMetadata()] methods. *) +val global_copy_all_metadata : llvalue -> (llmdkind * llmetadata) array + (** {7 Operations on global variables} *) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.c index 34ea3e36e..510ac1cad 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -22,12 +22,12 @@ #include "llvm-c/DebugInfo.h" #include "llvm-c/Support.h" #include "llvm/Config/llvm-config.h" -#include "caml/alloc.h" -#include "caml/custom.h" #include "caml/memory.h" #include "caml/fail.h" #include "caml/callback.h" +#include "llvm_ocaml.h" + value llvm_string_of_message(char* Message) { value String = caml_copy_string(Message); LLVMDisposeMessage(Message); @@ -45,6 +45,18 @@ CAMLprim value ptr_to_option(void *Ptr) { CAMLreturn(Option); } +CAMLprim value cstr_to_string(const char *Str, mlsize_t Len) { + CAMLparam0(); + CAMLlocal1(String); + if (Str) { + String = caml_alloc_string(Len); + memcpy((char *)String_val(String), Str, Len); + } else { + String = caml_alloc_string(0); + } + CAMLreturn(String); +} + CAMLprim value cstr_to_string_option(const char *CStr, mlsize_t Len) { CAMLparam0(); CAMLlocal2(Option, String); @@ -336,12 +348,39 @@ CAMLprim value llvm_string_of_llmodule(LLVMModuleRef M) { CAMLreturn(ModuleStr); } +/* llmodule -> string */ +CAMLprim value llvm_get_module_identifier(LLVMModuleRef M) { + size_t Len; + const char *Name = LLVMGetModuleIdentifier(M, &Len); + return cstr_to_string(Name, (mlsize_t)Len); +} + +/* llmodule -> string -> unit */ +CAMLprim value llvm_set_module_identifier(LLVMModuleRef M, value Id) { + LLVMSetModuleIdentifier(M, String_val(Id), caml_string_length(Id)); + return Val_unit; +} + /* llmodule -> string -> unit */ CAMLprim value llvm_set_module_inline_asm(LLVMModuleRef M, value Asm) { LLVMSetModuleInlineAsm(M, String_val(Asm)); return Val_unit; } +/* llmodule -> string -> llmetadata option */ +CAMLprim value llvm_get_module_flag(LLVMModuleRef M, value Key) { + return ptr_to_option( + LLVMGetModuleFlag(M, String_val(Key), caml_string_length(Key))); +} + +CAMLprim value llvm_add_module_flag(LLVMModuleRef M, + LLVMModuleFlagBehavior Behaviour, value Key, + LLVMMetadataRef Val) { + LLVMAddModuleFlag(M, Int_val(Behaviour), String_val(Key), + caml_string_length(Key), Val); + return Val_unit; +} + /*===-- Types -------------------------------------------------------------===*/ /* lltype -> TypeKind.t */ @@ -978,6 +1017,17 @@ CAMLprim value llvm_get_debug_loc_column(LLVMValueRef Val) { return Val_int(C); } +/* llvalue -> llmetadata */ +CAMLprim LLVMMetadataRef llvm_value_as_metadata(LLVMValueRef Val) { + return LLVMValueAsMetadata(Val); +} + +/* llcontext -> llmetadata -> llvalue */ +CAMLprim LLVMValueRef llvm_metadata_as_value(LLVMContextRef C, + LLVMMetadataRef MD) { + return LLVMMetadataAsValue(C, MD); +} + /*--... Operations on scalar constants .....................................--*/ /* lltype -> int -> llvalue */ @@ -1258,6 +1308,25 @@ CAMLprim value llvm_set_alignment(value Bytes, LLVMValueRef Global) { return Val_unit; } +/* llvalue -> (llmdkind * llmetadata) array */ +CAMLprim value llvm_global_copy_all_metadata(LLVMValueRef Global) { + CAMLparam0(); + CAMLlocal2(Array, Pair); + size_t NumEntries; + LLVMValueMetadataEntry *Entries = + LLVMGlobalCopyAllMetadata(Global, &NumEntries); + Array = caml_alloc_tuple(NumEntries); + for (int i = 0; i < NumEntries; i++) { + Pair = caml_alloc_tuple(2); + Store_field(Pair, 0, Val_int(LLVMValueMetadataEntriesGetKind(Entries, i))); + Store_field(Pair, 1, + (value)LLVMValueMetadataEntriesGetMetadata(Entries, i)); + Store_field(Array, i, Pair); + } + LLVMDisposeValueMetadataEntries(Entries); + CAMLreturn(Array); +} + /*--... Operations on uses .................................................--*/ /* llvalue -> lluse option */ diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.h b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.h new file mode 100644 index 000000000..1202cc79f --- /dev/null +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/llvm/llvm_ocaml.h @@ -0,0 +1,30 @@ +/*===-- llvm_ocaml.h - LLVM OCaml Glue --------------------------*- C++ -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* 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. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_LLVM_OCAML_H +#define LLVM_LLVM_OCAML_H + +#include "caml/alloc.h" +#include "caml/custom.h" + +/* Convert a C pointer to an OCaml option */ +CAMLprim value ptr_to_option(void *Ptr); + +/* Convert a C string into an OCaml string */ +CAMLprim value cstr_to_string(const char *Str, mlsize_t Len); + +#endif // LLVM_LLVM_OCAML_H diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/target/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/target/CMakeLists.txt index adee0fcec..6e01a27a2 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/target/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/target/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_target OCAML llvm_target OCAMLDEP llvm C target_ocaml - LLVM target) + LLVM Target) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c index 3ee5ae791..2f3e9a6e3 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c @@ -78,12 +78,6 @@ CAMLprim value llvm_add_global_optimizer(LLVMPassManagerRef PM) { return Val_unit; } -/* [`Module] Llvm.PassManager.t -> unit */ -CAMLprim value llvm_add_ip_constant_propagation(LLVMPassManagerRef PM) { - LLVMAddIPConstantPropagationPass(PM); - return Val_unit; -} - /* [`Module] Llvm.PassManager.t -> unit */ CAMLprim value llvm_add_prune_eh(LLVMPassManagerRef PM) { LLVMAddPruneEHPass(PM); diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml index 4617b688f..6149ec318 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml @@ -33,9 +33,6 @@ external add_global_dce external add_global_optimizer : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_global_optimizer" -external add_ipc_propagation - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_ip_constant_propagation" external add_prune_eh : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_prune_eh" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli index 8d48702a2..7b9ccacf8 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli @@ -56,11 +56,6 @@ external add_global_optimizer : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_global_optimizer" -(** See the [llvm::createIPConstantPropagationPass] function. *) -external add_ipc_propagation - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_ip_constant_propagation" - (** See the [llvm::createPruneEHPass] function. *) external add_prune_eh : [ `Module ] Llvm.PassManager.t -> unit diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt index 98c7c6861..d680b0204 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_scalar_opts OCAML llvm_scalar_opts OCAMLDEP llvm C scalar_opts_ocaml - LLVM scalaropts) + LLVM Scalar) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml index 4d9055339..b1b0db39a 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml @@ -96,9 +96,6 @@ external add_lib_call_simplification external add_tail_call_elimination : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_tail_call_elimination" -external add_constant_propagation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_constant_propagation" external add_memory_to_register_demotion : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_demote_memory_to_register" diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli index 117218f06..bd57ba113 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli @@ -161,11 +161,6 @@ external add_tail_call_elimination : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit = "llvm_add_tail_call_elimination" -(** See the [llvm::createConstantPropagationPass] function. *) -external add_constant_propagation - : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit - = "llvm_add_constant_propagation" - (** See the [llvm::createDemoteMemoryToRegisterPass] function. *) external add_memory_to_register_demotion : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c index 8d10989bd..1e794c924 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c @@ -200,12 +200,6 @@ CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) { return Val_unit; } -/* [ unit */ -CAMLprim value llvm_add_constant_propagation(LLVMPassManagerRef PM) { - LLVMAddConstantPropagationPass(PM); - return Val_unit; -} - /* [ unit */ CAMLprim value llvm_add_demote_memory_to_register(LLVMPassManagerRef PM) { LLVMAddDemoteMemoryToRegisterPass(PM); diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/utils/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/utils/CMakeLists.txt index 37f3eb7d8..920ed793b 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/utils/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/utils/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_transform_utils OCAML llvm_transform_utils OCAMLDEP llvm C transform_utils_ocaml - LLVM transformutils) + LLVM TransformUtils) diff --git a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt index af0ffce56..47af23928 100644 --- a/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt +++ b/sledge/vendor/llvm-dune/llvm-project/llvm/bindings/ocaml/transforms/vectorize/CMakeLists.txt @@ -2,4 +2,4 @@ add_ocaml_library(llvm_vectorize OCAML llvm_vectorize OCAMLDEP llvm C vectorize_ocaml - LLVM vectorize) + LLVM Vectorize) diff --git a/sledge/vendor/llvm-dune/setup.sh b/sledge/vendor/llvm-dune/setup.sh index c793efc01..16332a604 100755 --- a/sledge/vendor/llvm-dune/setup.sh +++ b/sledge/vendor/llvm-dune/setup.sh @@ -48,6 +48,7 @@ create_dune_file() { cfile=$4 depends=$5 components=$6 + extra_deps=$7 if test "$dirname" = "backends"; then basedir=src/$dirname/$components @@ -87,7 +88,8 @@ create_dune_file() { (foreign_stubs (language c) (names ${cfile}) - (flags ($cflags))) + (extra_deps ${extra_deps}) + (flags ($cflags -I../../llvm))) (c_library_flags ($ldflags $(llvm_config --system-libs --link-shared --libs $components)))) " >> "$basedir/shared/dune" fi @@ -105,7 +107,8 @@ create_dune_file() { (foreign_stubs (language c) (names ${cfile}) - (flags ($cflags))) + (extra_deps ${extra_deps}) + (flags ($cflags -I../../llvm))) (c_library_flags ($ldflags $(llvm_config --system-libs --link-static --libs $components)))) " >> "$basedir/static/dune" fi @@ -114,8 +117,8 @@ create_dune_file() { rm "$basedir/$cfile.c" } -# ------------------ public name -------- directory ---------------- module name -------- C file name --------- OCaml dependencies -------------- LLVM components (for the linker) -create_dune_file llvm llvm llvm llvm_ocaml "" "core support" +# ------------------ public name -------- directory ---------------- module name -------- C file name --------- OCaml dependencies -------------- LLVM components (for the linker) - extra-deps +create_dune_file llvm llvm llvm llvm_ocaml "" "core support" ../llvm_ocaml.h create_dune_file llvm.analysis analysis llvm_analysis analysis_ocaml "llvm" "analysis" create_dune_file llvm.bitreader bitreader llvm_bitreader bitreader_ocaml "llvm" "bitreader" create_dune_file llvm.bitwriter bitwriter llvm_bitwriter bitwriter_ocaml "llvm unix" "bitwriter" @@ -126,7 +129,7 @@ create_dune_file llvm.scalar_opts transforms/scalar_opts llvm_scalar create_dune_file llvm.transform_utils transforms/utils llvm_transform_utils transform_utils_ocaml "llvm" "transformutils" create_dune_file llvm.vectorize transforms/vectorize llvm_vectorize vectorize_ocaml "llvm" "vectorize" create_dune_file llvm.passmgr_builder transforms/passmgr_builder llvm_passmgr_builder passmgr_builder_ocaml "llvm" "ipo" -create_dune_file llvm.target target llvm_target target_ocaml "llvm" "target" +create_dune_file llvm.target target llvm_target target_ocaml "llvm" "target" ../../llvm/llvm_ocaml.h create_dune_file llvm.linker linker llvm_linker linker_ocaml "llvm" "linker" create_dune_file llvm.all_backends all_backends llvm_all_backends all_backends_ocaml "llvm" "$llvm_targets"