aboutsummaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2021-02-27 20:55:19 +0100
committerAndrzej Janik <[email protected]>2024-02-11 20:45:51 +0100
commit1b9ba2b2333746c5e2b05a2bf24fa6ec3828dcdf (patch)
tree0b77ca4a41d4f232bd181e2bddc886475c608784 /ext
parent60d2124a16a7a2a1a6be3707247afe82892a4163 (diff)
downloadZLUDA-1b9ba2b2333746c5e2b05a2bf24fa6ec3828dcdf.tar.gz
ZLUDA-1b9ba2b2333746c5e2b05a2bf24fa6ec3828dcdf.zip
Nobody expects the Red Teamv3
Too many changes to list, but broadly: * Remove Intel GPU support from the compiler * Add AMD GPU support to the compiler * Remove Intel GPU host code * Add AMD GPU host code * More device instructions. From 40 to 68 * More host functions. From 48 to 184 * Add proof of concept implementation of OptiX framework * Add minimal support of cuDNN, cuBLAS, cuSPARSE, cuFFT, NCCL, NVML * Improve ZLUDA launcher for Windows
Diffstat (limited to 'ext')
m---------ext/llvm-project0
-rw-r--r--ext/llvm-sys.rs/.gitignore3
-rw-r--r--ext/llvm-sys.rs/.gitlab-ci.yml19
-rw-r--r--ext/llvm-sys.rs/Cargo.toml21
-rw-r--r--ext/llvm-sys.rs/LICENSE19
-rw-r--r--ext/llvm-sys.rs/README.md188
-rw-r--r--ext/llvm-sys.rs/appveyor.yml20
-rw-r--r--ext/llvm-sys.rs/build.cmake2
-rw-r--r--ext/llvm-sys.rs/build.rs140
-rw-r--r--ext/llvm-sys.rs/scripts/RELEASE_CHECKLIST.md24
-rw-r--r--ext/llvm-sys.rs/scripts/build-binaries.sh32
-rw-r--r--ext/llvm-sys.rs/src/analysis.rs35
-rw-r--r--ext/llvm-sys.rs/src/bit_reader.rs70
-rw-r--r--ext/llvm-sys.rs/src/bit_writer.rs23
-rw-r--r--ext/llvm-sys.rs/src/blake3.rs66
-rw-r--r--ext/llvm-sys.rs/src/comdat.rs34
-rw-r--r--ext/llvm-sys.rs/src/core.rs2095
-rw-r--r--ext/llvm-sys.rs/src/debuginfo.rs880
-rw-r--r--ext/llvm-sys.rs/src/disassembler.rs147
-rw-r--r--ext/llvm-sys.rs/src/error.rs18
-rw-r--r--ext/llvm-sys.rs/src/error_handling.rs17
-rw-r--r--ext/llvm-sys.rs/src/execution_engine.rs212
-rw-r--r--ext/llvm-sys.rs/src/initialization.rs19
-rw-r--r--ext/llvm-sys.rs/src/ir_reader.rs16
-rw-r--r--ext/llvm-sys.rs/src/lib.rs500
-rw-r--r--ext/llvm-sys.rs/src/linker.rs19
-rw-r--r--ext/llvm-sys.rs/src/lto.rs442
-rw-r--r--ext/llvm-sys.rs/src/object.rs164
-rw-r--r--ext/llvm-sys.rs/src/orc2/ee.rs11
-rw-r--r--ext/llvm-sys.rs/src/orc2/lljit.rs74
-rw-r--r--ext/llvm-sys.rs/src/orc2/mod.rs539
-rw-r--r--ext/llvm-sys.rs/src/remarks.rs134
-rw-r--r--ext/llvm-sys.rs/src/support.rs22
-rw-r--r--ext/llvm-sys.rs/src/target.rs195
-rw-r--r--ext/llvm-sys.rs/src/target_machine.rs111
-rw-r--r--ext/llvm-sys.rs/src/transforms.rs8
-rw-r--r--ext/llvm-sys.rs/src/transforms/aggressive_instcombine.rs5
-rw-r--r--ext/llvm-sys.rs/src/transforms/instcombine.rs5
-rw-r--r--ext/llvm-sys.rs/src/transforms/ipo.rs25
-rw-r--r--ext/llvm-sys.rs/src/transforms/pass_builder.rs64
-rw-r--r--ext/llvm-sys.rs/src/transforms/pass_manager_builder.rs43
-rw-r--r--ext/llvm-sys.rs/src/transforms/scalar.rs51
-rw-r--r--ext/llvm-sys.rs/src/transforms/util.rs9
-rw-r--r--ext/llvm-sys.rs/src/transforms/vectorize.rs8
-rw-r--r--ext/llvm-sys.rs/wrappers/target.c48
-rw-r--r--ext/optix_ext/README.md10
-rw-r--r--ext/optix_ext/optix_ext_compile_no_inline.h56
-rw-r--r--ext/optix_ext/optix_ext_compile_no_inline_function_table_definition.h39
-rw-r--r--ext/optix_ext/optix_ext_compile_no_inline_stubs.h98
-rw-r--r--ext/optix_ext/optix_ext_knobs.h67
-rw-r--r--ext/optix_ext/optix_ext_knobs_function_table_definition.h39
-rw-r--r--ext/optix_ext/optix_ext_knobs_stubs.h98
-rw-r--r--ext/optix_ext/optix_ext_ptx_encryption.h82
-rw-r--r--ext/optix_ext/optix_ext_ptx_encryption_function_table_definition.h39
-rw-r--r--ext/optix_ext/optix_ext_ptx_encryption_stubs.h109
-rw-r--r--ext/optix_ext/optix_ptx_encryption.h416
m---------ext/spirv-headers0
m---------ext/spirv-tools0
58 files changed, 7630 insertions, 0 deletions
diff --git a/ext/llvm-project b/ext/llvm-project
new file mode 160000
+Subproject 8dfdcc7b7bf66834a761bd8de445840ef68e4d1
diff --git a/ext/llvm-sys.rs/.gitignore b/ext/llvm-sys.rs/.gitignore
new file mode 100644
index 0000000..c6613a1
--- /dev/null
+++ b/ext/llvm-sys.rs/.gitignore
@@ -0,0 +1,3 @@
+# Generated by Cargo.
+/target
+Cargo.lock
diff --git a/ext/llvm-sys.rs/.gitlab-ci.yml b/ext/llvm-sys.rs/.gitlab-ci.yml
new file mode 100644
index 0000000..b5cb4ae
--- /dev/null
+++ b/ext/llvm-sys.rs/.gitlab-ci.yml
@@ -0,0 +1,19 @@
+image: rust:buster
+
+variables:
+ LLVM_SYS_150_FFI_WORKAROUND: "YES"
+
+before_script:
+ - apt-get update -qq && apt-get install -qq -y lsb-release software-properties-common
+ - wget https://apt.llvm.org/llvm.sh
+ - chmod +x llvm.sh
+ - ./llvm.sh 15
+ - apt-get install libpolly-15-dev
+
+test:
+ script:
+ - cargo build
+ - cargo test
+ - cargo run --example nop-function
+ - cargo run --example jit-function
+ - echo "Hello, world!" | cargo run --example disassembler
diff --git a/ext/llvm-sys.rs/Cargo.toml b/ext/llvm-sys.rs/Cargo.toml
new file mode 100644
index 0000000..72e84fe
--- /dev/null
+++ b/ext/llvm-sys.rs/Cargo.toml
@@ -0,0 +1,21 @@
+[package]
+description = "Bindings to LLVM's C API"
+repository = "https://gitlab.com/taricorp/llvm-sys.rs"
+readme = "README.md"
+license = "MIT"
+keywords = ["bindings", "llvm"]
+categories = ["external-ffi-bindings"]
+links = "llvm-15"
+name = "llvm-sys"
+version = "150.1.2"
+authors = [
+ "Peter Marheine <[email protected]>",
+]
+build = "build.rs"
+
+[dependencies]
+libc = "0.2"
+
+[build-dependencies]
+cmake = "0.1"
+convert_case = "0.5"
diff --git a/ext/llvm-sys.rs/LICENSE b/ext/llvm-sys.rs/LICENSE
new file mode 100644
index 0000000..91b97a6
--- /dev/null
+++ b/ext/llvm-sys.rs/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2015 Peter Marheine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/ext/llvm-sys.rs/README.md b/ext/llvm-sys.rs/README.md
new file mode 100644
index 0000000..70e53d0
--- /dev/null
+++ b/ext/llvm-sys.rs/README.md
@@ -0,0 +1,188 @@
+Rust bindings to LLVM's C API.
+
+# Usage
+
+```toml
+[dependencies]
+llvm-sys = "150"
+```
+
+There must be a compatible version of LLVM available. By default `llvm-sys`
+will look for `llvm-config` on `PATH` to find a system-wide copy of LLVM and
+use that if it is a compatible version. Custom options for finding LLVM
+on your system can be specified via environment variables. See
+[LLVM compatibility](#llvm-compatibility) for more information.
+
+## Documentation
+
+See the `examples` directory in this repository for API examples. There also
+exist some other projects using these bindings which may be
+informative or useful:
+
+ * Safe, "Rusty" APIs for using LLVM:
+ * [Inkwell](https://github.com/TheDan64/inkwell)
+ * [llvm-ir](https://github.com/cdisselkoen/llvm-ir)
+ * [Tari's merthc](https://bitbucket.org/tari/merthc)
+ * [Wilfred's BF compiler](https://crates.io/crates/bfc)
+ * Jay Phelps wrote about [building a minimal compiler targeting
+ WebAssembly](https://medium.com/@jayphelps/93e8c193fdb4)
+
+Most of the interfaces are not documented in these bindings. Refer to the
+[LLVM documentation](http://llvm.org/docs/) for more information, particularly
+the [generated API documentation](http://llvm.org/doxygen/).
+
+If you have your own project using these bindings that you think is worth
+mentioning here, by all means let me know.
+
+## LLVM compatibility
+
+Because the LLVM C [API stability guarantees][c-api-stability] are relatively
+weak, this crate enforces that the LLVM release in use match the one it was made
+for. The crate version is constructed by treating the LLVM version as a real
+number and multiplying by 10, ignoring any fractional part. Thus `llvm-sys`
+version 37 is compatible with LLVM 3.7.x, and `llvm-sys` 41 would be compatible
+with LLVM 4.1.x.
+
+[c-api-stability]: http://llvm.org/docs/DeveloperPolicy.html#c-api-changes
+
+The build scripts will not enforce this compatibility matrix strictly,
+permitting compilation against any version of LLVM that is at least as new as
+the crate target version. This is safe in most cases because the LLVM C API is
+meant to maintain binary compatibility across releases with the exception of
+when functions are deprecated and later removed. An incompatible LLVM version
+will generally fail to compile with a link-time error, rather than cause runtime
+errors. Where versions are known to break binary compatibility, the build script
+will prevent compilation.
+
+Depending on your use of the C API, your program may require that only a
+version of LLVM exactly matching your crate version be allowed. This can be set
+with the cargo feature flag `strict-versioning` or by setting the environment
+variable `LLVM_SYS_<version>_STRICT_VERSIONING` (where `<version>` is the target
+crate version) to any value.
+
+llvm-sys blocklists some versions of LLVM that are known to be
+binary-incompatible. If you're feeling lucky, setting
+`LLVM_SYS_<version>_IGNORE_BLOCKLIST` to "YES" will permit the use of
+blocklisted library versions (which may cause vexing bugs).
+
+---
+
+This crate declares that it links to `llvm-<MAJOR VERSION>`, not just `llvm`.
+This makes it possible to declare a crate that depends on multiple
+versions of `llvm-sys` (corresponding to different versions of LLVM) as long as
+only one of them is actually used:
+
+```toml
+llvm-sys-90 = { package = "llvm-sys", version = "90", optional = true }
+llvm-sys-100 = { package = "llvm-sys", version = "100", optional = true }
+```
+
+This requires that the target LLVM version (`llvm-10` for instance) be declared
+as the linking target rather than just `llvm` because Cargo requires that all
+linked libraries be unique regardless of what is actually enabled. Note that
+although Cargo will not prevent you from enabling multiple versions of LLVM at
+once as a result, doing so will likely cause errors at link time.
+
+---
+
+It may be difficult or even impossible to provide a compatible LLVM version
+system-wide for a given project (consider a program using two libraries that
+internally use different versions of LLVM!) so environment variables can be set
+to help the build scripts find your copy of the libraries. This is also helpful
+if you are unable to provide a system-wide version of LLVM but can still
+compile it yourself.
+
+`LLVM_SYS_<version>_PREFIX` specifies the install prefix for a compiled and
+installed copy of the libraries, where `<version>` is the major version of
+`llvm-sys` (for example, `LLVM_SYS_37_PREFIX`). For information on compiling
+a copy of LLVM yourself, see [Compiling LLVM](#compiling-llvm).
+
+In the future this library may offer the ability to download and compile LLVM
+automatically, but such a feature should only be considered for building
+one-off releases because its high cost is ill-suited to repeated builds.
+
+## Compiling LLVM
+
+If you need to compile LLVM or manage multiple versions,
+[llvmenv](https://crates.io/crates/llvmenv) may simplify the process. Consider
+using it if you don't have special requirements or previous experience with
+LLVM!
+
+While the [getting started guide](http://llvm.org/docs/GettingStarted.html) is
+the official guide to compiling LLVM, this section will attempt to provide
+minimum guidance in creating usable libraries. If you encounter problems, refer
+to the official documentation.
+
+### Download sources
+
+Download and unpack a copy of the source for the required version.
+
+```sh
+wget https://llvm.org/releases/3.9.0/llvm-3.9.0.src.tar.xz
+tar xJf llvm-3.9.0.src.tar.xz
+```
+
+Note that you do not need to compile Clang or the test suite.
+
+### Configure
+
+Configure the build using [CMake][cmake] (you will need a copy of CMake
+installed).
+
+[cmake]: https://cmake.org/
+
+```sh
+mkdir -p llvm-3.9.0.src/build
+cd llvm-3.9.0.src/build
+cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/llvm-3.9.0
+```
+
+Some of the useful options that can be specified at configuration-time
+(via `-D` passed to CMake):
+
+ * `CMAKE_INSTALL_PREFIX` sets the location to install everything in the install
+ step (later). In the above example this is under your home directory.
+ * `CMAKE_BUILD_TYPE` specifies the build mode, one of Debug, Release,
+ MinSizeRel or RelWithDebInfo. Unless you plan to debug LLVM itself,
+ Release or MinSizeRel is probably a good choice.
+ * `LLVM_ENABLE_ASSERTIONS` enables internal sanity checks, highly recommended
+ when writing and debugging your own program that uses LLVM because it can
+ detect many usage errors that could otherwise result in hard-to-debug
+ crashes.
+
+Passing `-G <generator>` to CMake will make it use a different build system, but
+by default it will select one appropriate to your system. If you have
+[ninja][ninja] available, it is recommended due to its speed (`-G Ninja`).
+
+[ninja]: https://ninja-build.org/
+
+### Compile and install
+
+```sh
+cmake --build . --target install
+```
+
+This will automatically invoke the build system and copy binaries into the
+prefix specified at configuration-time when done. Then you can compile llvm-sys
+against it.
+
+```sh
+cd your/crate/path
+LLVM_SYS_39_PREFIX=$HOME/llvm-3.9.0 cargo build
+```
+
+Some build tools (like Visual Studio on Windows) support all configurations
+concurrently so you also need to specify the build type (which defaults to Debug
+on Windows), adding an option like `--config MinSizeRel` to this invocation of
+cmake.
+
+## Windows
+
+You must use a version of Rust that uses the same compiler as you build LLVM
+with, either MSVC or MinGW. Fortunately, a mismatch like this will cause errors
+at compile-time when llvm-config provides options which are supported by only
+one of them, so if you're using the other it will cause the build to fail.
+
+## Cross-compilation
+
+Will theoretically work, but hasn't been tested. Let us know if you try.
diff --git a/ext/llvm-sys.rs/appveyor.yml b/ext/llvm-sys.rs/appveyor.yml
new file mode 100644
index 0000000..db5e257
--- /dev/null
+++ b/ext/llvm-sys.rs/appveyor.yml
@@ -0,0 +1,20 @@
+version: 1.0.{build}
+
+image: macos
+install:
+ - sh: >-
+ brew install llvm
+ - sh: >-
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh && sh rustup.sh -y
+build: off
+test_script:
+ - sh: |
+ export PATH=/usr/local/bin:$PATH
+ source ~/.cargo/env
+ export LLVM_SYS_110_PREFIX=/usr/local/opt/llvm
+ export LLVM_CONFIG_PATH=${LLVM_SYS_110_PREFIX}/bin/llvm-config
+
+ cargo test
+ cargo run --example nop-function
+ cargo run --example jit-function
+ echo "Hello, world!" | cargo run --example disassembler
diff --git a/ext/llvm-sys.rs/build.cmake b/ext/llvm-sys.rs/build.cmake
new file mode 100644
index 0000000..da09740
--- /dev/null
+++ b/ext/llvm-sys.rs/build.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0091 NEW)
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
diff --git a/ext/llvm-sys.rs/build.rs b/ext/llvm-sys.rs/build.rs
new file mode 100644
index 0000000..a7363a9
--- /dev/null
+++ b/ext/llvm-sys.rs/build.rs
@@ -0,0 +1,140 @@
+extern crate cmake;
+extern crate convert_case;
+
+use convert_case::{Case, Casing, StateConverter};
+use std::{
+ env,
+ path::PathBuf,
+ process::{Command, Stdio},
+};
+
+use cmake::Config;
+
+fn main() {
+ println!("cargo:rerun-if-changed=build.rs");
+ let llvm_components = ["core", "analysis", "bit_reader", "bit_writer", "i_r_reader"]
+ .iter()
+ .map(|comp| comp.from_case(Case::Snake));
+ let msvc = is_msvc();
+ let (llvm_dir, additonal_cmake_file) = get_llvm_dir();
+ let out_dir = build_cmake_targets(llvm_components.clone(), llvm_dir, additonal_cmake_file);
+ emit_compile_and_linking_information(llvm_components, out_dir, msvc)
+}
+
+fn is_msvc() -> bool {
+ env::var("CARGO_CFG_TARGET_ENV").unwrap() == "msvc"
+}
+
+fn get_llvm_dir() -> (PathBuf, PathBuf) {
+ let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
+ let mut additional_cmake_file = manifest_dir.clone();
+ additional_cmake_file.push("build.cmake");
+ let mut llvm_dir = manifest_dir.parent().unwrap().to_path_buf();
+ llvm_dir.push("llvm-project");
+ llvm_dir.push("llvm");
+ println!("cargo:rerun-if-changed={}", llvm_dir.display());
+ println!("cargo:rerun-if-changed={}", additional_cmake_file.display());
+ (llvm_dir, additional_cmake_file)
+}
+
+fn build_cmake_targets<'a>(
+ components: impl Iterator<Item = StateConverter<'a, &'static str>>,
+ llvm_dir: PathBuf,
+ additional_cmake_file: PathBuf,
+) -> PathBuf {
+ let mut cmake = Config::new(llvm_dir);
+ use_ninja(&mut cmake);
+ cmake
+ .always_configure(true)
+ .define("LLVM_ENABLE_TERMINFO", "OFF")
+ .define("LLVM_BUILD_TOOLS", "OFF")
+ .define("LLVM_TARGETS_TO_BUILD", "")
+ .define("LLVM_ENABLE_PROJECTS", "")
+ .define("CMAKE_PROJECT_INCLUDE_BEFORE", additional_cmake_file);
+ // Unfortunately CMake crate does not support building mutliple targets at once
+ for component in components {
+ cmake
+ .build_target(&format!("LLVM{}", component.to_case(Case::Pascal)))
+ .build();
+ }
+ cmake.build_target("llvm-config").build()
+}
+
+fn use_ninja(cmake: &mut Config) {
+ if let Ok(exit_status) = Command::new("ninja")
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .arg("--version")
+ .status()
+ {
+ if !exit_status.success() {
+ return;
+ }
+ cmake.generator("Ninja");
+ }
+}
+
+fn emit_compile_and_linking_information<'a>(
+ llvm_components: impl Iterator<Item = StateConverter<'a, &'static str>>,
+ out_dir: PathBuf,
+ is_msvc: bool,
+) {
+ let mut llvm_config_path = out_dir.clone();
+ llvm_config_path.push("build");
+ llvm_config_path.push("bin");
+ llvm_config_path.push("llvm-config");
+ let mut llvm_config_cmd = Command::new(&llvm_config_path);
+ llvm_config_cmd.args([
+ "--cxxflags",
+ "--ldflags",
+ "--libdir",
+ "--libnames",
+ "--system-libs",
+ "--link-static",
+ ]);
+ for component in llvm_components {
+ llvm_config_cmd.arg(&component.to_case(Case::Flat));
+ }
+ let llvm_config_output = llvm_config_cmd
+ .stdin(Stdio::null())
+ .stderr(Stdio::null())
+ .output()
+ .unwrap();
+ if !llvm_config_output.status.success() {
+ panic!()
+ }
+ let output = String::from_utf8_lossy(&llvm_config_output.stdout);
+ let lines = (&output).lines().collect::<Vec<_>>();
+ let (cxxflags, ldflags, libdir, libnames, system_libs) = match &*lines {
+ [cxxflags, ldflags, libdir, libnames, system_libs, ..] => {
+ (cxxflags, ldflags, libdir, libnames, system_libs)
+ }
+ _ => panic!(),
+ };
+ println!("cargo:cxxflags={}", cxxflags);
+ println!("cargo:rustc-link-arg={}", ldflags);
+ println!("cargo:rustc-link-search={}", libdir);
+ for lib in libnames.split_ascii_whitespace() {
+ let lib = if is_msvc {
+ // For some reason rustc appends .lib twice on msvc
+ &lib[..lib.len() - 4]
+ } else {
+ // On Linux, we get "libLLVMIRReader.a", so we cut "lib" and ".a"
+ &lib[3..lib.len() - 2]
+ };
+ println!("cargo:rustc-link-lib=static={}", lib);
+ }
+ for lib in system_libs.split_ascii_whitespace() {
+ let lib = if is_msvc {
+ &lib[..lib.len() - 4]
+ } else {
+ // On Linux, we get it as "-lxml2", so we cut "-l" part
+ &lib[2..]
+ };
+ println!("cargo:rustc-link-lib={}", lib);
+ }
+ if !is_msvc {
+ println!("cargo:rustc-link-lib=stdc++");
+ }
+}
diff --git a/ext/llvm-sys.rs/scripts/RELEASE_CHECKLIST.md b/ext/llvm-sys.rs/scripts/RELEASE_CHECKLIST.md
new file mode 100644
index 0000000..57ed876
--- /dev/null
+++ b/ext/llvm-sys.rs/scripts/RELEASE_CHECKLIST.md
@@ -0,0 +1,24 @@
+For new LLVM major versions:
+
+ * [ ] Diff llvm/include/llvm-c/ between previous and current release.
+ This requires a local repo that's in sync with the remote, and tags
+ will be needed. A bare repository is fine, however.
+
+ ```
+ git clone --mirror https://github.com/llvm/llvm-project.git
+ git diff llvmorg-9.0.0 llvmorg-10.0.0 -- llvm/include/llvm-c/
+ ```
+
+ Apply matching changes to Rust bindings.
+ * [ ] Update `links` key in Cargo.toml for new LLVM version
+ * [ ] Update usage example in README.md for new crate version
+ * [ ] Update CI to refer to new version
+
+For all versions:
+
+ * [ ] Update `version` key in Cargo.toml for new crate version
+ * [ ] Commit changes
+ * [ ] Tag new version; `git tag v100.1.0`
+ * [ ] Update latest branch to follow master: `git branch -f llvm-10.0 master`
+ * [ ] Test and publish
+ * [ ] Push changes and tags; `git push --all && git push --tags`
diff --git a/ext/llvm-sys.rs/scripts/build-binaries.sh b/ext/llvm-sys.rs/scripts/build-binaries.sh
new file mode 100644
index 0000000..b1c95d3
--- /dev/null
+++ b/ext/llvm-sys.rs/scripts/build-binaries.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+set -e
+
+if [ $? -lt 1 ]
+then
+ echo "Usage: $0 <version>" >&2
+ echo "Example: $0 3.9.1" >&2
+ exit 1
+fi
+
+VERSION=$1
+
+# Dependencies (for Ubuntu):
+# * wget
+# * xz-utils
+# * ninja-build
+# * cmake
+# * build-essential
+# * python
+
+wget http://releases.llvm.org/$VERSION/llvm-$VERSION.src.tar.xz
+tar xJf llvm-$VERSION.src.tar.xz
+mkdir build llvm-$VERSION
+cd build
+cmake -G Ninja ../llvm-$VERSION.src -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_INSTALL_PREFIX=/usr/local/llvm-$VERSION -DCMAKE_INSTALL_UTILS
+cmake --build . --target install
+cd ..
+tar cJf llvm-$VERSION.linux.tar.xz /usr/local/llvm-$VERSION
+
+# Additional flags for MSVC
+# (CXX) /GL /Gy /Gw
+# (link) /LTCG /OPT:REF,ICF
diff --git a/ext/llvm-sys.rs/src/analysis.rs b/ext/llvm-sys.rs/src/analysis.rs
new file mode 100644
index 0000000..3284fe3
--- /dev/null
+++ b/ext/llvm-sys.rs/src/analysis.rs
@@ -0,0 +1,35 @@
+//! Various analyses of the LLVM IR.
+
+use super::prelude::*;
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMVerifierFailureAction {
+ /// Print to stderr and abort the process.
+ LLVMAbortProcessAction = 0,
+ /// Print to stderr and return 1.
+ LLVMPrintMessageAction = 1,
+ /// Return 1 and print nothing.
+ LLVMReturnStatusAction = 2,
+}
+
+extern "C" {
+ /// Verify that a module is valid, taking the specified action if not.
+ ///
+ /// Optionally returns a human-readable description of any invalid constructs,
+ /// which must be disposed with `LLVMDisposeMessage`.
+ pub fn LLVMVerifyModule(
+ M: LLVMModuleRef,
+ Action: LLVMVerifierFailureAction,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ /// Verify that a single function is valid, taking the specified action.
+ ///
+ /// Useful for debugging.
+ pub fn LLVMVerifyFunction(Fn: LLVMValueRef, Action: LLVMVerifierFailureAction) -> LLVMBool;
+ /// Open a ghostview window displaying the CFG of the given function.
+ ///
+ /// Useful for debugging.
+ pub fn LLVMViewFunctionCFG(Fn: LLVMValueRef);
+ pub fn LLVMViewFunctionCFGOnly(Fn: LLVMValueRef);
+}
diff --git a/ext/llvm-sys.rs/src/bit_reader.rs b/ext/llvm-sys.rs/src/bit_reader.rs
new file mode 100644
index 0000000..5ca7f45
--- /dev/null
+++ b/ext/llvm-sys.rs/src/bit_reader.rs
@@ -0,0 +1,70 @@
+//! Input of the LLVM bitcode format.
+
+use super::prelude::*;
+
+extern "C" {
+ ///// Build a module from the bitcode in the specified memory buffer.
+ /////
+ ///// Returns 0 on success and the generated module in `OutModule`.
+ ///// Optionally returns a human-readable error message in `OutMessage`.
+ //#[deprecated(since = "3.8", note = "Use LLVMParseBitcode2")]
+ //pub fn LLVMParseBitcode(
+ // MemBuf: LLVMMemoryBufferRef,
+ // OutModule: *mut LLVMModuleRef,
+ // OutMessage: *mut *mut ::libc::c_char,
+ //) -> LLVMBool;
+ ///// Build a module from the bitcode in the specified memory buffer.
+ /////
+ ///// Returns the created module in OutModule, returns 0 on success.
+ //pub fn LLVMParseBitcode2(
+ // MemBuf: LLVMMemoryBufferRef,
+ // OutModule: *mut LLVMModuleRef,
+ //) -> LLVMBool;
+
+ #[deprecated(since = "3.8", note = "Use LLVMParseBitcodeInContext2")]
+ pub fn LLVMParseBitcodeInContext(
+ ContextRef: LLVMContextRef,
+ MemBuf: LLVMMemoryBufferRef,
+ OutModule: *mut LLVMModuleRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMParseBitcodeInContext2(
+ ContextRef: LLVMContextRef,
+ MemBuf: LLVMMemoryBufferRef,
+ OutModule: *mut LLVMModuleRef,
+ ) -> LLVMBool;
+
+ /// Read a module from the specified path, returning a module provider
+ /// performing lazy deserialization.
+ ///
+ /// Returns 0 on success and an optional error message.
+ #[deprecated(since = "3.8", note = "Use LLVMGetBitcodeModuleInContext2")]
+ pub fn LLVMGetBitcodeModuleInContext(
+ ContextRef: LLVMContextRef,
+ MemBuf: LLVMMemoryBufferRef,
+ OutM: *mut LLVMModuleRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ /// Read a module from the specified path, returning a module provider
+ /// performing lazy deserialization.
+ ///
+ /// Returns 0 on success.
+ pub fn LLVMGetBitcodeModuleInContext2(
+ ContextRef: LLVMContextRef,
+ MemBuf: LLVMMemoryBufferRef,
+ OutM: *mut LLVMModuleRef,
+ ) -> LLVMBool;
+
+ #[deprecated(since = "3.8", note = "Use LLVMGetBitcodeModule2")]
+ pub fn LLVMGetBitcodeModule(
+ MemBuf: LLVMMemoryBufferRef,
+ OutM: *mut LLVMModuleRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ /// Read a module from the specified path.
+ ///
+ /// Outputs a module provider which performs lazy deserialization.
+ /// Returns 0 on success.
+ pub fn LLVMGetBitcodeModule2(MemBuf: LLVMMemoryBufferRef, OutM: *mut LLVMModuleRef)
+ -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/bit_writer.rs b/ext/llvm-sys.rs/src/bit_writer.rs
new file mode 100644
index 0000000..cd4d794
--- /dev/null
+++ b/ext/llvm-sys.rs/src/bit_writer.rs
@@ -0,0 +1,23 @@
+//! Output of the LLVM bitcode format.
+
+use super::prelude::*;
+
+extern "C" {
+ /// Write a module to the specified path.
+ ///
+ /// Returns 0 on success.
+ pub fn LLVMWriteBitcodeToFile(M: LLVMModuleRef, Path: *const ::libc::c_char) -> ::libc::c_int;
+ /// Write a module to an open file descriptor.
+ ///
+ /// Returns 0 on success.
+ pub fn LLVMWriteBitcodeToFD(
+ M: LLVMModuleRef,
+ FD: ::libc::c_int,
+ ShouldClose: ::libc::c_int,
+ Unbuffered: ::libc::c_int,
+ ) -> ::libc::c_int;
+ /// Deprecated: use LLVMWriteBitcodeToFD
+ pub fn LLVMWriteBitcodeToFileHandle(M: LLVMModuleRef, Handle: ::libc::c_int) -> ::libc::c_int;
+ /// Writes a module to a new memory buffer.
+ pub fn LLVMWriteBitcodeToMemoryBuffer(M: LLVMModuleRef) -> LLVMMemoryBufferRef;
+}
diff --git a/ext/llvm-sys.rs/src/blake3.rs b/ext/llvm-sys.rs/src/blake3.rs
new file mode 100644
index 0000000..dfa86d1
--- /dev/null
+++ b/ext/llvm-sys.rs/src/blake3.rs
@@ -0,0 +1,66 @@
+//! LLVM's BLAKE3 implementation.
+//! Original BLAKE3 C API: <https://github.com/BLAKE3-team/BLAKE3/tree/1.3.1/c>
+
+pub const LLVM_BLAKE3_VERSION_STRING: &str = "1.3.1";
+pub const LLVM_BLAKE3_KEY_LEN: usize = 32;
+pub const LLVM_BLAKE3_OUT_LEN: usize = 32;
+pub const LLVM_BLAKE3_BLOCK_LEN: usize = 64;
+pub const LLVM_BLAKE3_CHUNK_LEN: usize = 1024;
+pub const LLVM_BLAKE3_MAX_DEPTH: usize = 54;
+
+/// This struct is a private implementation detail. It has to be here because
+/// it's part of llvm_blake3_hasher below.
+#[repr(C)]
+struct llvm_blake3_chunk_state {
+ cv: [u32; 8],
+ chunk_counter: u64,
+ buf: [u8; LLVM_BLAKE3_BLOCK_LEN],
+ buf_len: u8,
+ blocks_compressed: u8,
+ flags: u8,
+}
+
+#[repr(C)]
+pub struct llvm_blake3_hasher {
+ key: [u32; 8],
+ chunk: llvm_blake3_chunk_state,
+ cv_stack_len: u8,
+ /// The stack size is MAX_DEPTH + 1 because we do lazy merging. For example,
+ /// with 7 chunks, we have 3 entries in the stack. Adding an 8th chunk
+ /// requires a 4th entry, rather than merging everything down to 1, because we
+ /// don't know whether more input is coming. This is different from how the
+ /// reference implementation does things.
+ cv_stack: [u8; (LLVM_BLAKE3_MAX_DEPTH + 1) * LLVM_BLAKE3_OUT_LEN],
+}
+
+extern "C" {
+ pub fn llvm_blake3_version() -> *const ::libc::c_char;
+ pub fn llvm_blake3_hasher_init(hasher: *mut llvm_blake3_hasher);
+ pub fn llvm_blake3_hasher_init_keyed(hasher: *mut llvm_blake3_hasher, key: *const u8);
+ pub fn llvm_blake3_hasher_init_derive_key(
+ hasher: *mut llvm_blake3_hasher,
+ context: *const ::libc::c_char,
+ );
+ pub fn llvm_blake3_hasher_init_derive_key_raw(
+ hasher: *mut llvm_blake3_hasher,
+ context: *const ::libc::c_char,
+ context_len: usize,
+ );
+ pub fn llvm_blake3_hasher_update(
+ hasher: *mut llvm_blake3_hasher,
+ input: *const ::libc::c_void,
+ input_len: usize,
+ );
+ pub fn llvm_blake3_hasher_finalize(
+ hasher: *mut llvm_blake3_hasher,
+ out: *mut u8,
+ out_len: usize,
+ );
+ pub fn llvm_blake3_hasher_finalize_seek(
+ hasher: *mut llvm_blake3_hasher,
+ seek: u64,
+ out: *mut u8,
+ out_len: usize,
+ );
+ pub fn llvm_blake3_hasher_reset(hasher: *mut llvm_blake3_hasher);
+}
diff --git a/ext/llvm-sys.rs/src/comdat.rs b/ext/llvm-sys.rs/src/comdat.rs
new file mode 100644
index 0000000..31a4b15
--- /dev/null
+++ b/ext/llvm-sys.rs/src/comdat.rs
@@ -0,0 +1,34 @@
+//! COMDAT
+use super::*;
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMComdatSelectionKind {
+ /// The linker may choose any COMDAT.
+ LLVMAnyComdatSelectionKind,
+ /// The data referenced by the COMDAT must be the same.
+ LLVMExactMatchComdatSelectionKind,
+ /// The linker will choose the largest COMDAT.
+ LLVMLargestComdatSelectionKind,
+ /// No deduplication is performed.
+ LLVMNoDuplicatesComdatSelectionKind,
+ /// The data referenced by the COMDAT must be the same size.
+ LLVMSameSizeComdatSelectionKind,
+}
+
+extern "C" {
+ /// Return the Comdat in the module with the specified name. It is created if it didn't already exist.
+ pub fn LLVMGetOrInsertComdat(M: LLVMModuleRef, Name: *const ::libc::c_char) -> LLVMComdatRef;
+
+ /// Get the Comdat assigned to the given global object.
+ pub fn LLVMGetComdat(V: LLVMValueRef) -> LLVMComdatRef;
+
+ /// Assign the Comdat to the given global object.
+ pub fn LLVMSetComdat(V: LLVMValueRef, C: LLVMComdatRef);
+
+ /// Get the conflict resolution selection kind for the Comdat.
+ pub fn LLVMGetComdatSelectionKind(C: LLVMComdatRef) -> LLVMComdatSelectionKind;
+
+ /// Set the conflict resolution selection kind for the Comdat.
+ pub fn LLVMSetComdatSelectionKind(C: LLVMComdatRef, Kind: LLVMComdatSelectionKind);
+}
diff --git a/ext/llvm-sys.rs/src/core.rs b/ext/llvm-sys.rs/src/core.rs
new file mode 100644
index 0000000..f1523f0
--- /dev/null
+++ b/ext/llvm-sys.rs/src/core.rs
@@ -0,0 +1,2095 @@
+//! The LLVM intermediate representation.
+
+use super::*;
+
+// Core
+extern "C" {
+ pub fn LLVMShutdown();
+ pub fn LLVMCreateMessage(Message: *const ::libc::c_char) -> *mut ::libc::c_char;
+ pub fn LLVMDisposeMessage(Message: *mut ::libc::c_char);
+}
+
+// Core->Contexts
+extern "C" {
+ pub fn LLVMContextCreate() -> LLVMContextRef;
+ //pub fn LLVMGetGlobalContext() -> LLVMContextRef;
+ pub fn LLVMContextSetDiagnosticHandler(
+ C: LLVMContextRef,
+ Handler: LLVMDiagnosticHandler,
+ DiagnosticContext: *mut ::libc::c_void,
+ );
+ /// Get the diagnostic handler of this context.
+ pub fn LLVMContextGetDiagnosticHandler(C: LLVMContextRef) -> LLVMDiagnosticHandler;
+ /// Get the diagnostic context of this context.
+ pub fn LLVMContextGetDiagnosticContext(C: LLVMContextRef) -> *mut ::libc::c_void;
+ pub fn LLVMContextSetYieldCallback(
+ C: LLVMContextRef,
+ Callback: LLVMYieldCallback,
+ OpaqueHandle: *mut ::libc::c_void,
+ );
+ pub fn LLVMContextShouldDiscardValueNames(C: LLVMContextRef) -> LLVMBool;
+ pub fn LLVMContextSetDiscardValueNames(C: LLVMContextRef, Discard: LLVMBool);
+ /// Set whether the given context is in opaque pointer mode.
+ pub fn LLVMContextSetOpaquePointers(C: LLVMContextRef, OpaquePointers: LLVMBool);
+ pub fn LLVMContextDispose(C: LLVMContextRef);
+ pub fn LLVMGetDiagInfoDescription(DI: LLVMDiagnosticInfoRef) -> *mut ::libc::c_char;
+ pub fn LLVMGetDiagInfoSeverity(DI: LLVMDiagnosticInfoRef) -> LLVMDiagnosticSeverity;
+ pub fn LLVMGetMDKindIDInContext(
+ C: LLVMContextRef,
+ Name: *const ::libc::c_char,
+ SLen: ::libc::c_uint,
+ ) -> ::libc::c_uint;
+ //pub fn LLVMGetMDKindID(Name: *const ::libc::c_char, SLen: ::libc::c_uint) -> ::libc::c_uint;
+
+ /// Return a unique id given the name of an enum attribute, or 0 if no attribute
+ /// by that name exists.
+ ///
+ /// See <http://llvm.org/docs/LangRef.html#parameter-attributes>
+ /// and <http://llvm.org/docs/LangRef.html#function-attributes>
+ /// for the list of available attributes.
+ ///
+ /// Note that attribute names and IDs are not subject to the same stability
+ /// guarantees as this API.
+ pub fn LLVMGetEnumAttributeKindForName(
+ Name: *const ::libc::c_char,
+ SLen: ::libc::size_t,
+ ) -> ::libc::c_uint;
+ pub fn LLVMGetLastEnumAttributeKind() -> ::libc::c_uint;
+
+ /// Create an enum attribute.
+ pub fn LLVMCreateEnumAttribute(
+ C: LLVMContextRef,
+ KindID: ::libc::c_uint,
+ Val: u64,
+ ) -> LLVMAttributeRef;
+ /// Get the unique id corresponding to the provided enum attribute.
+ pub fn LLVMGetEnumAttributeKind(A: LLVMAttributeRef) -> ::libc::c_uint;
+ /// Get the value of an enum attribute.
+ ///
+ /// Returns 0 if none exists.
+ pub fn LLVMGetEnumAttributeValue(A: LLVMAttributeRef) -> u64;
+
+ /// Create a type attribute.
+ pub fn LLVMCreateTypeAttribute(
+ C: LLVMContextRef,
+ KindID: ::libc::c_uint,
+ type_ref: LLVMTypeRef,
+ ) -> LLVMAttributeRef;
+ /// Get the type attribute's value.
+ pub fn LLVMGetTypeAttributeValue(A: LLVMAttributeRef) -> LLVMTypeRef;
+
+ /// Create a string attribute.
+ pub fn LLVMCreateStringAttribute(
+ C: LLVMContextRef,
+ K: *const ::libc::c_char,
+ KLength: ::libc::c_uint,
+ V: *const ::libc::c_char,
+ VLength: ::libc::c_uint,
+ ) -> LLVMAttributeRef;
+ /// Get a string attribute's kind.
+ pub fn LLVMGetStringAttributeKind(
+ A: LLVMAttributeRef,
+ Length: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ /// Get a string attribute's value.
+ pub fn LLVMGetStringAttributeValue(
+ A: LLVMAttributeRef,
+ Length: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMIsEnumAttribute(A: LLVMAttributeRef) -> LLVMBool;
+ pub fn LLVMIsStringAttribute(A: LLVMAttributeRef) -> LLVMBool;
+ pub fn LLVMIsTypeAttribute(A: LLVMAttributeRef) -> LLVMBool;
+
+ /// Obtain a Type from a context by its registered name.
+ pub fn LLVMGetTypeByName2(C: LLVMContextRef, Name: *const ::libc::c_char) -> LLVMTypeRef;
+}
+
+// Core->Modules
+extern "C" {
+ //pub fn LLVMModuleCreateWithName(ModuleID: *const ::libc::c_char) -> LLVMModuleRef;
+ pub fn LLVMModuleCreateWithNameInContext(
+ ModuleID: *const ::libc::c_char,
+ C: LLVMContextRef,
+ ) -> LLVMModuleRef;
+ pub fn LLVMCloneModule(M: LLVMModuleRef) -> LLVMModuleRef;
+ pub fn LLVMDisposeModule(M: LLVMModuleRef);
+ /// Get the identifier of a module.
+ ///
+ /// `Len` is written to contains the length of the returned string.
+ pub fn LLVMGetModuleIdentifier(
+ M: LLVMModuleRef,
+ Len: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ /// Set the identifier of a module.
+ ///
+ /// `Len` is the length of the string pointed to by `Ident`.
+ pub fn LLVMSetModuleIdentifier(
+ M: LLVMModuleRef,
+ Ident: *const ::libc::c_char,
+ Len: ::libc::size_t,
+ );
+
+ /// Obtain the module's original source file name.
+ ///
+ /// Len holds the length of the returned string, returns the original source file name of M.
+ pub fn LLVMGetSourceFileName(
+ M: LLVMModuleRef,
+ Len: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ /// Set the original source file name of a module to a string Name with length Len.
+ pub fn LLVMSetSourceFileName(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ Len: ::libc::size_t,
+ );
+
+ #[deprecated(since = "3.9", note = "Confusingly named. Use LLVMGetDataLayoutStr.")]
+ pub fn LLVMGetDataLayout(M: LLVMModuleRef) -> *const ::libc::c_char;
+ /// Obtain the data layout for a module.
+ pub fn LLVMGetDataLayoutStr(M: LLVMModuleRef) -> *const ::libc::c_char;
+ pub fn LLVMSetDataLayout(M: LLVMModuleRef, DataLayoutStr: *const ::libc::c_char);
+ pub fn LLVMGetTarget(M: LLVMModuleRef) -> *const ::libc::c_char;
+ pub fn LLVMSetTarget(M: LLVMModuleRef, Triple: *const ::libc::c_char);
+
+ /// Returns the module flags as an array of flag-key-value triples. The caller is responsible for freeing this array by calling LLVMDisposeModuleFlagsMetadata.
+ pub fn LLVMCopyModuleFlagsMetadata(
+ M: LLVMModuleRef,
+ Len: *mut ::libc::size_t,
+ ) -> *mut LLVMModuleFlagEntry;
+ /// Destroys module flags metadata entries.
+ pub fn LLVMDisposeModuleFlagsMetadata(Entries: *mut LLVMModuleFlagEntry);
+ /// Returns the flag behavior for a module flag entry at a specific index.
+ pub fn LLVMModuleFlagEntriesGetFlagBehavior(
+ Entries: *mut LLVMModuleFlagEntry,
+ Index: ::libc::c_uint,
+ ) -> LLVMModuleFlagBehavior;
+ /// Returns the key for a module flag entry at a specific index.
+ pub fn LLVMModuleFlagEntriesGetKey(
+ Entries: *mut LLVMModuleFlagEntry,
+ Index: ::libc::c_uint,
+ Len: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ /// Returns the metadata for a module flag entry at a specific index.
+ pub fn LLVMModuleFlagEntriesGetMetadata(
+ Entries: *mut LLVMModuleFlagEntry,
+ Index: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+ /// Add a module-level flag to the module-level flags metadata if it doesn't already exist.
+ pub fn LLVMGetModuleFlag(
+ M: LLVMModuleRef,
+ Key: *const ::libc::c_char,
+ KeyLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+ /// Add a module-level flag to the module-level flags metadata if it doesn't already exist.
+ pub fn LLVMAddModuleFlag(
+ M: LLVMModuleRef,
+ Behavior: LLVMModuleFlagBehavior,
+ Key: *const ::libc::c_char,
+ KeyLen: ::libc::size_t,
+ Val: LLVMMetadataRef,
+ );
+
+ pub fn LLVMDumpModule(M: LLVMModuleRef);
+ pub fn LLVMPrintModuleToFile(
+ M: LLVMModuleRef,
+ Filename: *const ::libc::c_char,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMPrintModuleToString(M: LLVMModuleRef) -> *mut ::libc::c_char;
+
+ pub fn LLVMGetModuleInlineAsm(
+ M: LLVMModuleRef,
+ Len: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ #[deprecated(since = "7.0", note = "Use LLVMSetModuleInlineAsm2 instead")]
+ pub fn LLVMSetModuleInlineAsm(M: LLVMModuleRef, Asm: *const ::libc::c_char);
+ pub fn LLVMSetModuleInlineAsm2(
+ M: LLVMModuleRef,
+ Asm: *const ::libc::c_char,
+ Len: ::libc::size_t,
+ );
+ pub fn LLVMAppendModuleInlineAsm(
+ M: LLVMModuleRef,
+ Asm: *const ::libc::c_char,
+ Len: ::libc::size_t,
+ );
+ pub fn LLVMGetInlineAsm(
+ Ty: LLVMTypeRef,
+ AsmString: *mut ::libc::c_char,
+ AsmStringSize: ::libc::size_t,
+ Constraints: *mut ::libc::c_char,
+ ConstraintsSize: ::libc::size_t,
+ HasSideEffects: LLVMBool,
+ IsAlignStack: LLVMBool,
+ Dialect: LLVMInlineAsmDialect,
+ CanThrow: LLVMBool,
+ ) -> LLVMValueRef;
+
+ pub fn LLVMGetModuleContext(M: LLVMModuleRef) -> LLVMContextRef;
+ #[deprecated(since = "12.0.0", note = "Use LLVMGetTypeByName2 instead")]
+ pub fn LLVMGetTypeByName(M: LLVMModuleRef, Name: *const ::libc::c_char) -> LLVMTypeRef;
+ pub fn LLVMGetFirstNamedMetadata(M: LLVMModuleRef) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetLastNamedMetadata(M: LLVMModuleRef) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetNextNamedMetadata(NamedMDNode: LLVMNamedMDNodeRef) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetPreviousNamedMetadata(NamedMDNode: LLVMNamedMDNodeRef) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetNamedMetadata(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetOrInsertNamedMetadata(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMNamedMDNodeRef;
+ pub fn LLVMGetNamedMetadataName(
+ NamedMD: LLVMNamedMDNodeRef,
+ NameLen: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMGetNamedMetadataNumOperands(
+ M: LLVMModuleRef,
+ name: *const ::libc::c_char,
+ ) -> ::libc::c_uint;
+ pub fn LLVMGetNamedMetadataOperands(
+ M: LLVMModuleRef,
+ name: *const ::libc::c_char,
+ Dest: *mut LLVMValueRef,
+ );
+ pub fn LLVMAddNamedMetadataOperand(
+ M: LLVMModuleRef,
+ name: *const ::libc::c_char,
+ Val: LLVMValueRef,
+ );
+ pub fn LLVMGetDebugLocDirectory(
+ Val: LLVMValueRef,
+ Length: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMGetDebugLocFilename(
+ Val: LLVMValueRef,
+ Length: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMGetDebugLocLine(Val: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetDebugLocColumn(Val: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMAddFunction(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ FunctionTy: LLVMTypeRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetNamedFunction(M: LLVMModuleRef, Name: *const ::libc::c_char) -> LLVMValueRef;
+ pub fn LLVMGetFirstFunction(M: LLVMModuleRef) -> LLVMValueRef;
+ pub fn LLVMGetLastFunction(M: LLVMModuleRef) -> LLVMValueRef;
+ pub fn LLVMGetNextFunction(Fn: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetPreviousFunction(Fn: LLVMValueRef) -> LLVMValueRef;
+}
+
+// Core->Types
+extern "C" {
+ pub fn LLVMGetTypeKind(Ty: LLVMTypeRef) -> LLVMTypeKind;
+ pub fn LLVMTypeIsSized(Ty: LLVMTypeRef) -> LLVMBool;
+ pub fn LLVMGetTypeContext(Ty: LLVMTypeRef) -> LLVMContextRef;
+ pub fn LLVMDumpType(Val: LLVMTypeRef);
+ pub fn LLVMPrintTypeToString(Val: LLVMTypeRef) -> *mut ::libc::c_char;
+
+ // Core->Types->Integer
+ pub fn LLVMInt1TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMInt8TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMInt16TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMInt32TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMInt64TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMInt128TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMIntTypeInContext(C: LLVMContextRef, NumBits: ::libc::c_uint) -> LLVMTypeRef;
+ //pub fn LLVMInt1Type() -> LLVMTypeRef;
+ //pub fn LLVMInt8Type() -> LLVMTypeRef;
+ //pub fn LLVMInt16Type() -> LLVMTypeRef;
+ //pub fn LLVMInt32Type() -> LLVMTypeRef;
+ //pub fn LLVMInt64Type() -> LLVMTypeRef;
+ //pub fn LLVMInt128Type() -> LLVMTypeRef;
+ //pub fn LLVMIntType(NumBits: ::libc::c_uint) -> LLVMTypeRef;
+ pub fn LLVMGetIntTypeWidth(IntegerTy: LLVMTypeRef) -> ::libc::c_uint;
+
+ // Core->Types->Floating-Point
+ pub fn LLVMHalfTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMBFloatTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMFloatTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMDoubleTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMX86FP80TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMFP128TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMPPCFP128TypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ //pub fn LLVMHalfType() -> LLVMTypeRef;
+ //pub fn LLVMBFloatType() -> LLVMTypeRef;
+ //pub fn LLVMFloatType() -> LLVMTypeRef;
+ //pub fn LLVMDoubleType() -> LLVMTypeRef;
+ //pub fn LLVMX86FP80Type() -> LLVMTypeRef;
+ //pub fn LLVMFP128Type() -> LLVMTypeRef;
+ //pub fn LLVMPPCFP128Type() -> LLVMTypeRef;
+
+ // Core->Types->Function
+ pub fn LLVMFunctionType(
+ ReturnType: LLVMTypeRef,
+ ParamTypes: *mut LLVMTypeRef,
+ ParamCount: ::libc::c_uint,
+ IsVarArg: LLVMBool,
+ ) -> LLVMTypeRef;
+ pub fn LLVMIsFunctionVarArg(FunctionTy: LLVMTypeRef) -> LLVMBool;
+ pub fn LLVMGetReturnType(FunctionTy: LLVMTypeRef) -> LLVMTypeRef;
+ pub fn LLVMCountParamTypes(FunctionTy: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMGetParamTypes(FunctionTy: LLVMTypeRef, Dest: *mut LLVMTypeRef);
+
+ // Core->Types->Struct
+ pub fn LLVMStructTypeInContext(
+ C: LLVMContextRef,
+ ElementTypes: *mut LLVMTypeRef,
+ ElementCount: ::libc::c_uint,
+ Packed: LLVMBool,
+ ) -> LLVMTypeRef;
+ //pub fn LLVMStructType(
+ // ElementTypes: *mut LLVMTypeRef,
+ // ElementCount: ::libc::c_uint,
+ // Packed: LLVMBool,
+ //) -> LLVMTypeRef;
+ pub fn LLVMStructCreateNamed(C: LLVMContextRef, Name: *const ::libc::c_char) -> LLVMTypeRef;
+ pub fn LLVMGetStructName(Ty: LLVMTypeRef) -> *const ::libc::c_char;
+ pub fn LLVMStructSetBody(
+ StructTy: LLVMTypeRef,
+ ElementTypes: *mut LLVMTypeRef,
+ ElementCount: ::libc::c_uint,
+ Packed: LLVMBool,
+ );
+ pub fn LLVMCountStructElementTypes(StructTy: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMGetStructElementTypes(StructTy: LLVMTypeRef, Dest: *mut LLVMTypeRef);
+ /// Get the type of the element at the given index in a structure.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn LLVMStructGetTypeAtIndex(StructTy: LLVMTypeRef, i: ::libc::c_uint) -> LLVMTypeRef;
+ /// Determine whether a structure is packed.
+ pub fn LLVMIsPackedStruct(StructTy: LLVMTypeRef) -> LLVMBool;
+ pub fn LLVMIsOpaqueStruct(StructTy: LLVMTypeRef) -> LLVMBool;
+ pub fn LLVMIsLiteralStruct(StructTy: LLVMTypeRef) -> LLVMBool;
+
+ // Core->Types->Sequential
+ pub fn LLVMGetElementType(Ty: LLVMTypeRef) -> LLVMTypeRef;
+ /// Get the subtypes of the given type.
+ pub fn LLVMGetSubtypes(Tp: LLVMTypeRef, Arr: *mut LLVMTypeRef);
+ /// Return the number of types in the derived type.
+ pub fn LLVMGetNumContainedTypes(Tp: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMArrayType(ElementType: LLVMTypeRef, ElementCount: ::libc::c_uint) -> LLVMTypeRef;
+ pub fn LLVMGetArrayLength(ArrayTy: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMPointerType(ElementType: LLVMTypeRef, AddressSpace: ::libc::c_uint) -> LLVMTypeRef;
+ /// Determine whether a pointer is opaque.
+ ///
+ /// True if this is an instance of an opaque PointerType.
+ pub fn LLVMPointerTypeIsOpaque(Ty: LLVMTypeRef) -> LLVMBool;
+ /// Create an opaque pointer type in a context.
+ pub fn LLVMPointerTypeInContext(C: LLVMContextRef, AddressSpace: ::libc::c_uint) -> LLVMTypeRef;
+ pub fn LLVMGetPointerAddressSpace(PointerTy: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMVectorType(ElementType: LLVMTypeRef, ElementCount: ::libc::c_uint) -> LLVMTypeRef;
+ /// Create a vector type that contains a defined type and has a scalable
+ /// number of elements.
+ ///
+ /// The created type will exist in the context that its element type
+ /// exists in.
+ pub fn LLVMScalableVectorType(
+ ElementType: LLVMTypeRef,
+ ElementCount: ::libc::c_uint,
+ ) -> LLVMTypeRef;
+ /// Obtain the (possibly scalable) number of elements in a vector type.
+ pub fn LLVMGetVectorSize(VectorTy: LLVMTypeRef) -> ::libc::c_uint;
+
+ // Core->Types->Other
+ pub fn LLVMVoidTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMLabelTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMX86MMXTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMX86AMXTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMTokenTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ pub fn LLVMMetadataTypeInContext(C: LLVMContextRef) -> LLVMTypeRef;
+ //pub fn LLVMVoidType() -> LLVMTypeRef;
+ //pub fn LLVMLabelType() -> LLVMTypeRef;
+ //pub fn LLVMX86MMXType() -> LLVMTypeRef;
+ //pub fn LLVMX86AMXType() -> LLVMTypeRef;
+}
+
+// Core->Values
+extern "C" {
+ // Core->Values->General
+ // Get the enumerated kind of a Value instance.
+ pub fn LLVMGetValueKind(Val: LLVMValueRef) -> LLVMValueKind;
+ pub fn LLVMTypeOf(Val: LLVMValueRef) -> LLVMTypeRef;
+
+ #[deprecated(since = "7.0", note = "Use LLVMGetValueName2 instead")]
+ pub fn LLVMGetValueName(Val: LLVMValueRef) -> *const ::libc::c_char;
+ pub fn LLVMGetValueName2(
+ Val: LLVMValueRef,
+ Length: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ #[deprecated(since = "7.0", note = "Use LLVMSetValueName2 instead")]
+ pub fn LLVMSetValueName(Val: LLVMValueRef, Name: *const ::libc::c_char);
+ pub fn LLVMSetValueName2(
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ );
+
+ pub fn LLVMDumpValue(Val: LLVMValueRef);
+ pub fn LLVMPrintValueToString(Val: LLVMValueRef) -> *mut ::libc::c_char;
+ pub fn LLVMReplaceAllUsesWith(OldVal: LLVMValueRef, NewVal: LLVMValueRef);
+ /// Determine whether the specified value instance is constant.
+ pub fn LLVMIsConstant(Val: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMIsUndef(Val: LLVMValueRef) -> LLVMBool;
+ /// Determine whether a value instance is poisonous.
+ pub fn LLVMIsPoison(Val: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMIsAMDNode(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAMDString(Val: LLVMValueRef) -> LLVMValueRef;
+
+ // Core->Values->Usage
+ pub fn LLVMGetFirstUse(Val: LLVMValueRef) -> LLVMUseRef;
+ pub fn LLVMGetNextUse(U: LLVMUseRef) -> LLVMUseRef;
+ pub fn LLVMGetUser(U: LLVMUseRef) -> LLVMValueRef;
+ pub fn LLVMGetUsedValue(U: LLVMUseRef) -> LLVMValueRef;
+
+ // Core->Values->User value
+ pub fn LLVMGetOperand(Val: LLVMValueRef, Index: ::libc::c_uint) -> LLVMValueRef;
+ pub fn LLVMGetOperandUse(Val: LLVMValueRef, Index: ::libc::c_uint) -> LLVMUseRef;
+ pub fn LLVMSetOperand(User: LLVMValueRef, Index: ::libc::c_uint, Val: LLVMValueRef);
+ pub fn LLVMGetNumOperands(Val: LLVMValueRef) -> ::libc::c_int;
+
+ // Core->Values->Constants
+ pub fn LLVMConstNull(Ty: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstAllOnes(Ty: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMGetUndef(Ty: LLVMTypeRef) -> LLVMValueRef;
+ /// Obtain a constant value referring to a poison value of a type.
+ pub fn LLVMGetPoison(Ty: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMIsNull(Val: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMConstPointerNull(Ty: LLVMTypeRef) -> LLVMValueRef;
+
+ // Core->Values->Constants->Scalar
+ pub fn LLVMConstInt(
+ IntTy: LLVMTypeRef,
+ N: ::libc::c_ulonglong,
+ SignExtend: LLVMBool,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstIntOfArbitraryPrecision(
+ IntTy: LLVMTypeRef,
+ NumWords: ::libc::c_uint,
+ Words: *const u64,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstIntOfString(
+ IntTy: LLVMTypeRef,
+ Text: *const ::libc::c_char,
+ Radix: u8,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstIntOfStringAndSize(
+ IntTy: LLVMTypeRef,
+ Text: *const ::libc::c_char,
+ SLen: ::libc::c_uint,
+ Radix: u8,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstReal(RealTy: LLVMTypeRef, N: ::libc::c_double) -> LLVMValueRef;
+ pub fn LLVMConstRealOfString(RealTy: LLVMTypeRef, Text: *const ::libc::c_char) -> LLVMValueRef;
+ pub fn LLVMConstRealOfStringAndSize(
+ RealTy: LLVMTypeRef,
+ Text: *const ::libc::c_char,
+ SLen: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstIntGetZExtValue(ConstantVal: LLVMValueRef) -> ::libc::c_ulonglong;
+ pub fn LLVMConstIntGetSExtValue(ConstantVal: LLVMValueRef) -> ::libc::c_longlong;
+ pub fn LLVMConstRealGetDouble(
+ ConstantVal: LLVMValueRef,
+ losesInfo: *mut LLVMBool,
+ ) -> ::libc::c_double;
+
+ // Core->Values->Constants->Composite
+ pub fn LLVMConstStringInContext(
+ C: LLVMContextRef,
+ Str: *const ::libc::c_char,
+ Length: ::libc::c_uint,
+ DontNullTerminate: LLVMBool,
+ ) -> LLVMValueRef;
+ //pub fn LLVMConstString(
+ // Str: *const ::libc::c_char,
+ // Length: ::libc::c_uint,
+ // DontNullTerminate: LLVMBool,
+ //) -> LLVMValueRef;
+ pub fn LLVMIsConstantString(c: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMGetAsString(C: LLVMValueRef, Length: *mut ::libc::size_t) -> *const ::libc::c_char;
+ pub fn LLVMConstStructInContext(
+ C: LLVMContextRef,
+ ConstantVals: *mut LLVMValueRef,
+ Count: ::libc::c_uint,
+ Packed: LLVMBool,
+ ) -> LLVMValueRef;
+ //pub fn LLVMConstStruct(
+ // ConstantVals: *mut LLVMValueRef,
+ // Count: ::libc::c_uint,
+ // Packed: LLVMBool,
+ //) -> LLVMValueRef;
+ pub fn LLVMConstArray(
+ ElementTy: LLVMTypeRef,
+ ConstantVals: *mut LLVMValueRef,
+ Length: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstNamedStruct(
+ StructTy: LLVMTypeRef,
+ ConstantVals: *mut LLVMValueRef,
+ Count: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetAggregateElement(C: LLVMValueRef, idx: ::libc::c_uint) -> LLVMValueRef;
+ #[deprecated(since = "15.0", note = "Use LLVMGetAggregateElement instead")]
+ pub fn LLVMGetElementAsConstant(C: LLVMValueRef, idx: ::libc::c_uint) -> LLVMValueRef;
+ pub fn LLVMConstVector(
+ ScalarConstantVals: *mut LLVMValueRef,
+ Size: ::libc::c_uint,
+ ) -> LLVMValueRef;
+
+ // Core->Values->Constants->Constant expressions
+ pub fn LLVMGetConstOpcode(ConstantVal: LLVMValueRef) -> LLVMOpcode;
+ pub fn LLVMAlignOf(Ty: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMSizeOf(Ty: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNSWNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNUWNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstFNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNot(ConstantVal: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstAdd(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNSWAdd(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNUWAdd(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstSub(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNSWSub(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNUWSub(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstMul(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNSWMul(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstNUWMul(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstAnd(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstOr(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstXor(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstICmp(
+ Predicate: LLVMIntPredicate,
+ LHSConstant: LLVMValueRef,
+ RHSConstant: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstFCmp(
+ Predicate: LLVMRealPredicate,
+ LHSConstant: LLVMValueRef,
+ RHSConstant: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstShl(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstLShr(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMConstAShr(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMConstGEP2 instead to support opaque pointers."
+ )]
+ pub fn LLVMConstGEP(
+ ConstantVal: LLVMValueRef,
+ ConstantIndices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstGEP2(
+ Ty: LLVMTypeRef,
+ ConstantVal: LLVMValueRef,
+ ConstantIndices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMConstInBoundsGEP2 instead to support opaque pointers."
+ )]
+ pub fn LLVMConstInBoundsGEP(
+ ConstantVal: LLVMValueRef,
+ ConstantIndices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstInBoundsGEP2(
+ Ty: LLVMTypeRef,
+ ConstantVal: LLVMValueRef,
+ ConstantIndices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstTrunc(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstSExt(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstZExt(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstFPTrunc(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstFPExt(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstUIToFP(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstSIToFP(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstFPToUI(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstFPToSI(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstPtrToInt(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstIntToPtr(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstBitCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstAddrSpaceCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstZExtOrBitCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstSExtOrBitCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstTruncOrBitCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstPointerCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstIntCast(
+ ConstantVal: LLVMValueRef,
+ ToType: LLVMTypeRef,
+ isSigned: LLVMBool,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstFPCast(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef) -> LLVMValueRef;
+ pub fn LLVMConstSelect(
+ ConstantCondition: LLVMValueRef,
+ ConstantIfTrue: LLVMValueRef,
+ ConstantIfFalse: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstExtractElement(
+ VectorConstant: LLVMValueRef,
+ IndexConstant: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstInsertElement(
+ VectorConstant: LLVMValueRef,
+ ElementValueConstant: LLVMValueRef,
+ IndexConstant: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMConstShuffleVector(
+ VectorAConstant: LLVMValueRef,
+ VectorBConstant: LLVMValueRef,
+ MaskConstant: LLVMValueRef,
+ ) -> LLVMValueRef;
+ #[deprecated(since = "7.0", note = "Use LLVMGetInlineAsm instead")]
+ pub fn LLVMConstInlineAsm(
+ Ty: LLVMTypeRef,
+ AsmString: *const ::libc::c_char,
+ Constraints: *const ::libc::c_char,
+ HasSideEffects: LLVMBool,
+ IsAlignStack: LLVMBool,
+ ) -> LLVMValueRef;
+ pub fn LLVMBlockAddress(F: LLVMValueRef, BB: LLVMBasicBlockRef) -> LLVMValueRef;
+
+ // Core->Values->Constants->Global Values
+ pub fn LLVMGetGlobalParent(Global: LLVMValueRef) -> LLVMModuleRef;
+ pub fn LLVMIsDeclaration(Global: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMGetLinkage(Global: LLVMValueRef) -> LLVMLinkage;
+ pub fn LLVMSetLinkage(Global: LLVMValueRef, Linkage: LLVMLinkage);
+ pub fn LLVMGetSection(Global: LLVMValueRef) -> *const ::libc::c_char;
+ pub fn LLVMSetSection(Global: LLVMValueRef, Section: *const ::libc::c_char);
+ pub fn LLVMGetVisibility(Global: LLVMValueRef) -> LLVMVisibility;
+ pub fn LLVMSetVisibility(Global: LLVMValueRef, Viz: LLVMVisibility);
+ pub fn LLVMGetDLLStorageClass(Global: LLVMValueRef) -> LLVMDLLStorageClass;
+ pub fn LLVMSetDLLStorageClass(Global: LLVMValueRef, Class: LLVMDLLStorageClass);
+
+ pub fn LLVMGetUnnamedAddress(Global: LLVMValueRef) -> LLVMUnnamedAddr;
+ pub fn LLVMSetUnnamedAddress(Global: LLVMValueRef, UnnamedAddr: LLVMUnnamedAddr);
+ pub fn LLVMGlobalGetValueType(Global: LLVMValueRef) -> LLVMTypeRef;
+ #[deprecated(since = "7.0", note = "Use LLVMGetUnnamedAddress instead")]
+ pub fn LLVMHasUnnamedAddr(Global: LLVMValueRef) -> LLVMBool;
+ #[deprecated(since = "7.0", note = "Use LLVMSetUnnamedAddress instead")]
+ pub fn LLVMSetUnnamedAddr(Global: LLVMValueRef, HasUnnamedAddr: LLVMBool);
+
+ pub fn LLVMGetAlignment(V: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMSetAlignment(V: LLVMValueRef, Bytes: ::libc::c_uint);
+
+ pub fn LLVMGlobalSetMetadata(Global: LLVMValueRef, Kind: ::libc::c_uint, MD: LLVMMetadataRef);
+ pub fn LLVMGlobalEraseMetadata(Global: LLVMValueRef, Kind: ::libc::c_uint);
+ pub fn LLVMGlobalClearMetadata(Global: LLVMValueRef);
+ pub fn LLVMGlobalCopyAllMetadata(
+ Value: LLVMValueRef,
+ NumEntries: *mut ::libc::size_t,
+ ) -> *mut LLVMValueMetadataEntry;
+ pub fn LLVMDisposeValueMetadataEntries(Entries: *mut LLVMValueMetadataEntry);
+ pub fn LLVMValueMetadataEntriesGetKind(
+ Entries: *mut LLVMValueMetadataEntry,
+ Index: ::libc::c_uint,
+ ) -> ::libc::c_uint;
+ pub fn LLVMValueMetadataEntriesGetMetadata(
+ Entries: *mut LLVMValueMetadataEntry,
+ Index: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ // Core->Values->Constants->Global Variables
+ pub fn LLVMAddGlobal(
+ M: LLVMModuleRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMAddGlobalInAddressSpace(
+ M: LLVMModuleRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ AddressSpace: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetNamedGlobal(M: LLVMModuleRef, Name: *const ::libc::c_char) -> LLVMValueRef;
+ pub fn LLVMGetFirstGlobal(M: LLVMModuleRef) -> LLVMValueRef;
+ pub fn LLVMGetLastGlobal(M: LLVMModuleRef) -> LLVMValueRef;
+ pub fn LLVMGetNextGlobal(GlobalVar: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetPreviousGlobal(GlobalVar: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMDeleteGlobal(GlobalVar: LLVMValueRef);
+ pub fn LLVMGetInitializer(GlobalVar: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMSetInitializer(GlobalVar: LLVMValueRef, ConstantVal: LLVMValueRef);
+ pub fn LLVMIsThreadLocal(GlobalVar: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetThreadLocal(GlobalVar: LLVMValueRef, IsThreadLocal: LLVMBool);
+ pub fn LLVMIsGlobalConstant(GlobalVar: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetGlobalConstant(GlobalVar: LLVMValueRef, IsConstant: LLVMBool);
+ pub fn LLVMGetThreadLocalMode(GlobalVar: LLVMValueRef) -> LLVMThreadLocalMode;
+ pub fn LLVMSetThreadLocalMode(GlobalVar: LLVMValueRef, Mode: LLVMThreadLocalMode);
+ pub fn LLVMIsExternallyInitialized(GlobalVar: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetExternallyInitialized(GlobalVar: LLVMValueRef, IsExtInit: LLVMBool);
+
+ // Core->Values->Constants->Global Aliases
+ /// Obtain a GlobalAlias value from a Module by its name.
+ ///
+ /// The returned value corresponds to a llvm::GlobalAlias value.
+ pub fn LLVMGetNamedGlobalAlias(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMValueRef;
+ /// Obtain an iterator to the first GlobalAlias in a Module.
+ pub fn LLVMGetFirstGlobalAlias(M: LLVMModuleRef) -> LLVMValueRef;
+ /// Obtain an iterator to the last GlobalAlias in a Module.
+ pub fn LLVMGetLastGlobalAlias(M: LLVMModuleRef) -> LLVMValueRef;
+ /// Advance a GlobalAlias iterator to the next GlobalAlias.
+ ///
+ /// Returns NULL if the iterator was already at the end and there are no more global aliases.
+ pub fn LLVMGetNextGlobalAlias(GA: LLVMValueRef) -> LLVMValueRef;
+ /// Decrement a GlobalAlias iterator to the previous GlobalAlias.
+ ///
+ /// Returns NULL if the iterator was already at the beginning and there are no previous global aliases.
+ pub fn LLVMGetPreviousGlobalAlias(GA: LLVMValueRef) -> LLVMValueRef;
+ /// Retrieve the target value of an alias.
+ pub fn LLVMAliasGetAliasee(Alias: LLVMValueRef) -> LLVMValueRef;
+ /// Set the target value of an alias.
+ pub fn LLVMAliasSetAliasee(Alias: LLVMValueRef, Aliasee: LLVMValueRef);
+
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMAddAlias2 instead to support opaque pointers."
+ )]
+ pub fn LLVMAddAlias(
+ M: LLVMModuleRef,
+ Ty: LLVMTypeRef,
+ Aliasee: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+
+ pub fn LLVMAddAlias2(
+ M: LLVMModuleRef,
+ ValueTy: LLVMTypeRef,
+ AddrSpace: ::libc::c_uint,
+ Aliasee: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+
+ // ..->Function Values
+ pub fn LLVMDeleteFunction(Fn: LLVMValueRef);
+ /// Check whether the given function has a personality function.
+ pub fn LLVMHasPersonalityFn(Fn: LLVMValueRef) -> LLVMBool;
+ /// Obtain the personality function attached to the function.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn LLVMGetPersonalityFn(Fn: LLVMValueRef) -> LLVMValueRef;
+ /// Set the personality function attached to the function.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn LLVMSetPersonalityFn(Fn: LLVMValueRef, PersonalityFn: LLVMValueRef);
+ /// Obtain the intrinsic ID number which matches the given function name.
+ pub fn LLVMLookupIntrinsicID(
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> ::libc::c_uint;
+ /// Obtain the ID number from a function instance.
+ pub fn LLVMGetIntrinsicID(Fn: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetIntrinsicDeclaration(
+ Mod: LLVMModuleRef,
+ ID: ::libc::c_uint,
+ ParamTypes: *mut LLVMTypeRef,
+ ParamCount: ::libc::size_t,
+ ) -> LLVMValueRef;
+ pub fn LLVMIntrinsicGetType(
+ Ctx: LLVMContextRef,
+ ID: ::libc::c_uint,
+ ParamTypes: *mut LLVMTypeRef,
+ ParamCount: ::libc::size_t,
+ ) -> LLVMTypeRef;
+ pub fn LLVMIntrinsicGetName(
+ ID: ::libc::c_uint,
+ NameLength: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ #[deprecated = "Use LLVMIntrinsicCopyOverloadedName2 instead."]
+ pub fn LLVMIntrinsicCopyOverloadedName(
+ ID: ::libc::c_uint,
+ ParamTypes: *mut LLVMTypeRef,
+ ParamCount: ::libc::size_t,
+ NameLength: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMIntrinsicCopyOverloadedName2(
+ Mod: LLVMModuleRef,
+ ID: ::libc::c_uint,
+ ParamTypes: *mut LLVMTypeRef,
+ ParamCount: ::libc::size_t,
+ NameLength: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMIntrinsicIsOverloaded(ID: ::libc::c_uint) -> LLVMBool;
+ pub fn LLVMGetFunctionCallConv(Fn: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMSetFunctionCallConv(Fn: LLVMValueRef, CC: ::libc::c_uint);
+ pub fn LLVMGetGC(Fn: LLVMValueRef) -> *const ::libc::c_char;
+ pub fn LLVMSetGC(Fn: LLVMValueRef, Name: *const ::libc::c_char);
+ pub fn LLVMAddAttributeAtIndex(F: LLVMValueRef, Idx: LLVMAttributeIndex, A: LLVMAttributeRef);
+ pub fn LLVMGetAttributeCountAtIndex(F: LLVMValueRef, Idx: LLVMAttributeIndex)
+ -> ::libc::c_uint;
+ pub fn LLVMGetAttributesAtIndex(
+ F: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ Attrs: *mut LLVMAttributeRef,
+ );
+ pub fn LLVMGetEnumAttributeAtIndex(
+ F: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ KindID: ::libc::c_uint,
+ ) -> LLVMAttributeRef;
+ pub fn LLVMGetStringAttributeAtIndex(
+ F: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ K: *const ::libc::c_char,
+ KLen: ::libc::c_uint,
+ ) -> LLVMAttributeRef;
+ pub fn LLVMRemoveEnumAttributeAtIndex(
+ F: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ KindID: ::libc::c_uint,
+ );
+ pub fn LLVMRemoveStringAttributeAtIndex(
+ F: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ K: *const ::libc::c_char,
+ KLen: ::libc::c_uint,
+ );
+ pub fn LLVMAddTargetDependentFunctionAttr(
+ Fn: LLVMValueRef,
+ A: *const ::libc::c_char,
+ V: *const ::libc::c_char,
+ );
+
+ // ..->Function Values->Function Parameters
+ pub fn LLVMCountParams(Fn: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetParams(Fn: LLVMValueRef, Params: *mut LLVMValueRef);
+ pub fn LLVMGetParam(Fn: LLVMValueRef, Index: ::libc::c_uint) -> LLVMValueRef;
+ pub fn LLVMGetParamParent(Inst: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetFirstParam(Fn: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetLastParam(Fn: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetNextParam(Arg: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetPreviousParam(Arg: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMSetParamAlignment(Arg: LLVMValueRef, Align: ::libc::c_uint);
+}
+
+// Core->Metadata
+extern "C" {
+ #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDStringInContext2 instead.")]
+ pub fn LLVMMDStringInContext(
+ C: LLVMContextRef,
+ Str: *const ::libc::c_char,
+ SLen: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ //#[deprecated(since = "LLVM 9.0", note = "Use LLVMMDStringInContext2 instead.")]
+ //pub fn LLVMMDString(Str: *const ::libc::c_char, SLen: ::libc::c_uint) -> LLVMValueRef;
+ #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDNodeInContext2 instead.")]
+ pub fn LLVMMDNodeInContext(
+ C: LLVMContextRef,
+ Vals: *mut LLVMValueRef,
+ Count: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ //#[deprecated(since = "LLVM 9.0", note = "Use LLVMMDNodeInContext2 instead.")]
+ //pub fn LLVMMDNode(Vals: *mut LLVMValueRef, Count: ::libc::c_uint) -> LLVMValueRef;
+
+ /// Add a global indirect function to a module under a specified name.
+ pub fn LLVMAddGlobalIFunc(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Ty: LLVMTypeRef,
+ AddrSpace: ::libc::c_uint,
+ Resolver: LLVMValueRef,
+ ) -> LLVMValueRef;
+
+ /// Obtain a GlobalIFunc value from a Module by its name.
+ pub fn LLVMGetNamedGlobalIFunc(
+ M: LLVMModuleRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMValueRef;
+
+ /// Obtain an iterator to the first GlobalIFunc in a Module.
+ pub fn LLVMGetFirstGlobalIFunc(M: LLVMModuleRef) -> LLVMValueRef;
+
+ /// Obtain an iterator to the last GlobalIFunc in a Module.
+ pub fn LLVMGetLastGlobalIFunc(M: LLVMModuleRef) -> LLVMValueRef;
+
+ /// Advance a GlobalIFunc iterator to the next GlobalIFunc.
+ pub fn LLVMGetNextGlobalIFunc(IFunc: LLVMValueRef) -> LLVMValueRef;
+
+ /// Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
+ pub fn LLVMGetPreviousGlobalIFunc(IFunc: LLVMValueRef) -> LLVMValueRef;
+
+ /// Retrieves the resolver function associated with this indirect function, or
+ /// NULL if it doesn't not exist.
+ pub fn LLVMGetGlobalIFuncResolver(IFunc: LLVMValueRef) -> LLVMValueRef;
+
+ /// Sets the resolver function associated with this indirect function.
+ pub fn LLVMSetGlobalIFuncResolver(IFunc: LLVMValueRef, Resolver: LLVMValueRef);
+
+ /// Remove a global indirect function from its parent module and delete it.
+ pub fn LLVMEraseGlobalIFunc(IFunc: LLVMValueRef);
+
+ /// Remove a global indirect function from its parent module.
+ pub fn LLVMRemoveGlobalIFunc(IFunc: LLVMValueRef);
+
+ /// Create an MDString value from a given string value.
+ pub fn LLVMMDStringInContext2(
+ C: LLVMContextRef,
+ Str: *const ::libc::c_char,
+ SLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create an MDNode value with the given array of operands.
+ pub fn LLVMMDNodeInContext2(
+ C: LLVMContextRef,
+ MDs: *mut LLVMMetadataRef,
+ Count: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Obtain Metadata as a Value.
+ pub fn LLVMMetadataAsValue(C: LLVMContextRef, MD: LLVMMetadataRef) -> LLVMValueRef;
+ /// Obtain a Value as Metadata.
+ pub fn LLVMValueAsMetadata(Val: LLVMValueRef) -> LLVMMetadataRef;
+ /// Obtain the underlying string from a MDString value.
+ ///
+ /// `Len` is written to contain the length of the returned string.
+ pub fn LLVMGetMDString(V: LLVMValueRef, Len: *mut ::libc::c_uint) -> *const ::libc::c_char;
+ pub fn LLVMGetMDNodeNumOperands(V: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetMDNodeOperands(V: LLVMValueRef, Dest: *mut LLVMValueRef);
+}
+
+// Core->Basic Block
+extern "C" {
+ pub fn LLVMBasicBlockAsValue(BB: LLVMBasicBlockRef) -> LLVMValueRef;
+ pub fn LLVMValueIsBasicBlock(Val: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMValueAsBasicBlock(Val: LLVMValueRef) -> LLVMBasicBlockRef;
+ /// Get the string name of a basic block.
+ pub fn LLVMGetBasicBlockName(BB: LLVMBasicBlockRef) -> *const ::libc::c_char;
+ pub fn LLVMGetBasicBlockParent(BB: LLVMBasicBlockRef) -> LLVMValueRef;
+ pub fn LLVMGetBasicBlockTerminator(BB: LLVMBasicBlockRef) -> LLVMValueRef;
+ pub fn LLVMCountBasicBlocks(Fn: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetBasicBlocks(Fn: LLVMValueRef, BasicBlocks: *mut LLVMBasicBlockRef);
+ pub fn LLVMGetFirstBasicBlock(Fn: LLVMValueRef) -> LLVMBasicBlockRef;
+ pub fn LLVMGetLastBasicBlock(Fn: LLVMValueRef) -> LLVMBasicBlockRef;
+ pub fn LLVMGetNextBasicBlock(BB: LLVMBasicBlockRef) -> LLVMBasicBlockRef;
+ pub fn LLVMGetPreviousBasicBlock(BB: LLVMBasicBlockRef) -> LLVMBasicBlockRef;
+ pub fn LLVMGetEntryBasicBlock(Fn: LLVMValueRef) -> LLVMBasicBlockRef;
+ /// Insert the given basic block after the insertion point of the given builder.
+ pub fn LLVMInsertExistingBasicBlockAfterInsertBlock(
+ Builder: LLVMBuilderRef,
+ BB: LLVMBasicBlockRef,
+ );
+ /// Append the given basic block to the basic block list of the given function.
+ pub fn LLVMAppendExistingBasicBlock(Fn: LLVMValueRef, BB: LLVMBasicBlockRef);
+ pub fn LLVMCreateBasicBlockInContext(
+ C: LLVMContextRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMBasicBlockRef;
+ pub fn LLVMAppendBasicBlockInContext(
+ C: LLVMContextRef,
+ Fn: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMBasicBlockRef;
+ //pub fn LLVMAppendBasicBlock(Fn: LLVMValueRef, Name: *const ::libc::c_char)
+ // -> LLVMBasicBlockRef;
+ pub fn LLVMInsertBasicBlockInContext(
+ C: LLVMContextRef,
+ BB: LLVMBasicBlockRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMBasicBlockRef;
+ //pub fn LLVMInsertBasicBlock(
+ // InsertBeforeBB: LLVMBasicBlockRef,
+ // Name: *const ::libc::c_char,
+ //) -> LLVMBasicBlockRef;
+ pub fn LLVMDeleteBasicBlock(BB: LLVMBasicBlockRef);
+ pub fn LLVMRemoveBasicBlockFromParent(BB: LLVMBasicBlockRef);
+ pub fn LLVMMoveBasicBlockBefore(BB: LLVMBasicBlockRef, MovePos: LLVMBasicBlockRef);
+ pub fn LLVMMoveBasicBlockAfter(BB: LLVMBasicBlockRef, MovePos: LLVMBasicBlockRef);
+ pub fn LLVMGetFirstInstruction(BB: LLVMBasicBlockRef) -> LLVMValueRef;
+ pub fn LLVMGetLastInstruction(BB: LLVMBasicBlockRef) -> LLVMValueRef;
+}
+
+// Core->Instructions
+extern "C" {
+ pub fn LLVMHasMetadata(Val: LLVMValueRef) -> ::libc::c_int;
+ pub fn LLVMGetMetadata(Val: LLVMValueRef, KindID: ::libc::c_uint) -> LLVMValueRef;
+ pub fn LLVMSetMetadata(Val: LLVMValueRef, KindID: ::libc::c_uint, Node: LLVMValueRef);
+ pub fn LLVMInstructionGetAllMetadataOtherThanDebugLoc(
+ Instr: LLVMValueRef,
+ NumEntries: *mut ::libc::size_t,
+ ) -> *mut LLVMValueMetadataEntry;
+ pub fn LLVMGetInstructionParent(Inst: LLVMValueRef) -> LLVMBasicBlockRef;
+ pub fn LLVMGetNextInstruction(Inst: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMGetPreviousInstruction(Inst: LLVMValueRef) -> LLVMValueRef;
+ /// Remove the given instruction from its containing building block but
+ /// kept alive.
+ pub fn LLVMInstructionRemoveFromParent(Inst: LLVMValueRef);
+ /// Remove the given instruction from its containing building block and
+ /// delete it.
+ pub fn LLVMInstructionEraseFromParent(Inst: LLVMValueRef);
+ /// Remove the given instruction that is not inserted into a basic block.
+ /// It must have previously been removed from its containing building block.
+ pub fn LLVMDeleteInstruction(Inst: LLVMValueRef);
+ pub fn LLVMGetInstructionOpcode(Inst: LLVMValueRef) -> LLVMOpcode;
+ pub fn LLVMGetICmpPredicate(Inst: LLVMValueRef) -> LLVMIntPredicate;
+ pub fn LLVMGetFCmpPredicate(Inst: LLVMValueRef) -> LLVMRealPredicate;
+ pub fn LLVMInstructionClone(Inst: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsATerminatorInst(Inst: LLVMValueRef) -> LLVMValueRef;
+
+ // Instructions->Call Sites and Invocations
+ // Obtain the argument count for a call instruction.
+ //
+ // The provided value should be either a CallInst, InvokeInst or FuncletPadInst.
+ pub fn LLVMGetNumArgOperands(Instr: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMSetInstructionCallConv(Instr: LLVMValueRef, CC: ::libc::c_uint);
+ pub fn LLVMGetInstructionCallConv(Instr: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMSetInstrParamAlignment(
+ Instr: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ Align: ::libc::c_uint,
+ );
+ pub fn LLVMAddCallSiteAttribute(C: LLVMValueRef, Idx: LLVMAttributeIndex, A: LLVMAttributeRef);
+ pub fn LLVMGetCallSiteAttributeCount(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ ) -> ::libc::c_uint;
+ pub fn LLVMGetCallSiteAttributes(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ Attrs: *mut LLVMAttributeRef,
+ );
+ pub fn LLVMGetCallSiteEnumAttribute(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ KindID: ::libc::c_uint,
+ ) -> LLVMAttributeRef;
+ pub fn LLVMGetCallSiteStringAttribute(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ K: *const ::libc::c_char,
+ KLen: ::libc::c_uint,
+ ) -> LLVMAttributeRef;
+ pub fn LLVMRemoveCallSiteEnumAttribute(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ KindID: ::libc::c_uint,
+ );
+ pub fn LLVMRemoveCallSiteStringAttribute(
+ C: LLVMValueRef,
+ Idx: LLVMAttributeIndex,
+ K: *const ::libc::c_char,
+ KLen: ::libc::c_uint,
+ );
+ pub fn LLVMGetCalledFunctionType(C: LLVMValueRef) -> LLVMTypeRef;
+ /// Get a pointer to the function invoked by this instruction.
+ ///
+ /// The provided value should be a CallInst or InvokeInst.
+ pub fn LLVMGetCalledValue(Instr: LLVMValueRef) -> LLVMValueRef;
+ /// Get whether a call instruction is a tail call.
+ pub fn LLVMIsTailCall(CallInst: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetTailCall(CallInst: LLVMValueRef, IsTailCall: LLVMBool);
+ /// Return the normal destination basic block of an invoke instruction.
+ pub fn LLVMGetNormalDest(InvokeInst: LLVMValueRef) -> LLVMBasicBlockRef;
+ /// Return the unwind destination basic block.
+ pub fn LLVMGetUnwindDest(InvokeInst: LLVMValueRef) -> LLVMBasicBlockRef;
+ /// Set the normal destination basic block.
+ pub fn LLVMSetNormalDest(InvokeInst: LLVMValueRef, B: LLVMBasicBlockRef);
+ /// Set the unwind destination basic block.
+ pub fn LLVMSetUnwindDest(InvokeInst: LLVMValueRef, B: LLVMBasicBlockRef);
+
+ // Instructions->Terminators
+ pub fn LLVMGetNumSuccessors(Term: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetSuccessor(Term: LLVMValueRef, i: ::libc::c_uint) -> LLVMBasicBlockRef;
+ pub fn LLVMSetSuccessor(Term: LLVMValueRef, i: ::libc::c_uint, block: LLVMBasicBlockRef);
+ pub fn LLVMIsConditional(Branch: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMGetCondition(Branch: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMSetCondition(Branch: LLVMValueRef, Cond: LLVMValueRef);
+ pub fn LLVMGetSwitchDefaultDest(SwitchInstr: LLVMValueRef) -> LLVMBasicBlockRef;
+
+ // Instructions->Allocas
+ // Obtain the type being allocated by an alloca instruction.
+ pub fn LLVMGetAllocatedType(Alloca: LLVMValueRef) -> LLVMTypeRef;
+
+ // Instructions->GEPs
+ // Check whether the given GEP operator is inbounds.
+ pub fn LLVMIsInBounds(GEP: LLVMValueRef) -> LLVMBool;
+ /// Set the given GEP instruction to be inbounds or not.
+ pub fn LLVMSetIsInBounds(GEP: LLVMValueRef, InBounds: LLVMBool);
+
+ /// Get the source element type of the given GEP operator.
+ pub fn LLVMGetGEPSourceElementType(GEP: LLVMValueRef) -> LLVMTypeRef;
+
+ // Instruction->PHI Nodes
+ pub fn LLVMAddIncoming(
+ PhiNode: LLVMValueRef,
+ IncomingValues: *mut LLVMValueRef,
+ IncomingBlocks: *mut LLVMBasicBlockRef,
+ Count: ::libc::c_uint,
+ );
+ pub fn LLVMCountIncoming(PhiNode: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetIncomingValue(PhiNode: LLVMValueRef, Index: ::libc::c_uint) -> LLVMValueRef;
+ pub fn LLVMGetIncomingBlock(PhiNode: LLVMValueRef, Index: ::libc::c_uint) -> LLVMBasicBlockRef;
+
+}
+
+// Core->Values again; these don't appear in Doxygen because they're macro-generated.
+extern "C" {
+ pub fn LLVMIsAArgument(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsABasicBlock(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAInlineAsm(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUser(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstant(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsABlockAddress(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantAggregateZero(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantArray(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantDataSequential(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantDataArray(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantDataVector(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantExpr(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantFP(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantInt(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantPointerNull(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantStruct(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantTokenNone(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAConstantVector(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGlobalValue(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGlobalAlias(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGlobalIFunc(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGlobalObject(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFunction(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGlobalVariable(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUndefValue(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAPoisonValue(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAInstruction(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUnaryOperator(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsABinaryOperator(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACallInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAIntrinsicInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsADbgInfoIntrinsic(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsADbgVariableIntrinsic(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsADbgDeclareInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsADbgLabelInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAMemIntrinsic(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAMemCpyInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAMemMoveInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAMemSetInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACmpInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFCmpInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAICmpInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAExtractElementInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAGetElementPtrInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAInsertElementInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAInsertValueInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsALandingPadInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAPHINode(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsASelectInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAShuffleVectorInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAStoreInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsABranchInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAIndirectBrInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAInvokeInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAReturnInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsASwitchInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUnreachableInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAResumeInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACleanupReturnInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACatchReturnInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACatchSwitchInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACallBrInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFuncletPadInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACatchPadInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACleanupPadInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUnaryInstruction(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAAllocaInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsACastInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAAddrSpaceCastInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsABitCastInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFPExtInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFPToSIInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFPToUIInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFPTruncInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAIntToPtrInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAPtrToIntInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsASExtInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsASIToFPInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsATruncInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAUIToFPInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAZExtInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAExtractValueInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsALoadInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAVAArgInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFreezeInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAAtomicCmpXchgInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAAtomicRMWInst(Val: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMIsAFenceInst(Val: LLVMValueRef) -> LLVMValueRef;
+}
+
+// Core->Extract/Insert Value
+extern "C" {
+ /// Get the number of indices on an ExtractValue, InsertValue or GEP operator.
+ pub fn LLVMGetNumIndices(Inst: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetIndices(Inst: LLVMValueRef) -> *const ::libc::c_uint;
+}
+
+// Core->Instruction Builders
+extern "C" {
+ pub fn LLVMCreateBuilderInContext(C: LLVMContextRef) -> LLVMBuilderRef;
+ //pub fn LLVMCreateBuilder() -> LLVMBuilderRef;
+ pub fn LLVMPositionBuilder(
+ Builder: LLVMBuilderRef,
+ Block: LLVMBasicBlockRef,
+ Instr: LLVMValueRef,
+ );
+ pub fn LLVMPositionBuilderBefore(Builder: LLVMBuilderRef, Instr: LLVMValueRef);
+ pub fn LLVMPositionBuilderAtEnd(Builder: LLVMBuilderRef, Block: LLVMBasicBlockRef);
+ pub fn LLVMGetInsertBlock(Builder: LLVMBuilderRef) -> LLVMBasicBlockRef;
+ pub fn LLVMClearInsertionPosition(Builder: LLVMBuilderRef);
+ pub fn LLVMInsertIntoBuilder(Builder: LLVMBuilderRef, Instr: LLVMValueRef);
+ pub fn LLVMInsertIntoBuilderWithName(
+ Builder: LLVMBuilderRef,
+ Instr: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ );
+ pub fn LLVMDisposeBuilder(Builder: LLVMBuilderRef);
+
+ // Metadata
+ /// Get location information used by debugging information.
+ pub fn LLVMGetCurrentDebugLocation2(Builder: LLVMBuilderRef) -> LLVMMetadataRef;
+ /// Set location information used by debugging information.
+ pub fn LLVMSetCurrentDebugLocation2(Builder: LLVMBuilderRef, Loc: LLVMMetadataRef);
+ /// Attempts to set the debug location for the given instruction using the
+ /// current debug location for the given builder. If the builder has no current
+ /// debug location, this function is a no-op.
+ #[deprecated(
+ since = "14.0",
+ note = "Deprecated in favor of the more general LLVMAddMetadataToInst."
+ )]
+ pub fn LLVMSetInstDebugLocation(Builder: LLVMBuilderRef, Inst: LLVMValueRef);
+ /// Adds the metadata registered with the given builder to the given instruction.
+ pub fn LLVMAddMetadataToInst(Builder: LLVMBuilderRef, Inst: LLVMValueRef);
+ /// Get the dafult floating-point math metadata for a given builder.
+ pub fn LLVMBuilderGetDefaultFPMathTag(Builder: LLVMBuilderRef) -> LLVMMetadataRef;
+ /// Set the default floating-point math metadata for the given builder.
+ pub fn LLVMBuilderSetDefaultFPMathTag(Builder: LLVMBuilderRef, FPMathTag: LLVMMetadataRef);
+ #[deprecated(since = "LLVM 9.0", note = "Use LLVMGetCurrentDebugLocation2 instead.")]
+ pub fn LLVMSetCurrentDebugLocation(Builder: LLVMBuilderRef, L: LLVMValueRef);
+ pub fn LLVMGetCurrentDebugLocation(Builder: LLVMBuilderRef) -> LLVMValueRef;
+
+ // Terminators
+ pub fn LLVMBuildRetVoid(arg1: LLVMBuilderRef) -> LLVMValueRef;
+ pub fn LLVMBuildRet(arg1: LLVMBuilderRef, V: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMBuildAggregateRet(
+ arg1: LLVMBuilderRef,
+ RetVals: *mut LLVMValueRef,
+ N: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildBr(arg1: LLVMBuilderRef, Dest: LLVMBasicBlockRef) -> LLVMValueRef;
+ pub fn LLVMBuildCondBr(
+ arg1: LLVMBuilderRef,
+ If: LLVMValueRef,
+ Then: LLVMBasicBlockRef,
+ Else: LLVMBasicBlockRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSwitch(
+ arg1: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Else: LLVMBasicBlockRef,
+ NumCases: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIndirectBr(
+ B: LLVMBuilderRef,
+ Addr: LLVMValueRef,
+ NumDests: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildInvoke2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildInvoke(
+ arg1: LLVMBuilderRef,
+ Fn: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Then: LLVMBasicBlockRef,
+ Catch: LLVMBasicBlockRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildInvoke2(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Fn: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Then: LLVMBasicBlockRef,
+ Catch: LLVMBasicBlockRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildUnreachable(B: LLVMBuilderRef) -> LLVMValueRef;
+
+ pub fn LLVMBuildResume(B: LLVMBuilderRef, Exn: LLVMValueRef) -> LLVMValueRef;
+ pub fn LLVMBuildLandingPad(
+ B: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ PersFn: LLVMValueRef,
+ NumClauses: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCleanupRet(
+ B: LLVMBuilderRef,
+ CatchPad: LLVMValueRef,
+ BB: LLVMBasicBlockRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCatchRet(
+ B: LLVMBuilderRef,
+ CatchPad: LLVMValueRef,
+ BB: LLVMBasicBlockRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCatchPad(
+ B: LLVMBuilderRef,
+ ParentPad: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCleanupPad(
+ B: LLVMBuilderRef,
+ ParentPad: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCatchSwitch(
+ B: LLVMBuilderRef,
+ ParentPad: LLVMValueRef,
+ UnwindBB: LLVMBasicBlockRef,
+ NumHandler: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+
+ /// Add a case to a `switch` instruction
+ pub fn LLVMAddCase(Switch: LLVMValueRef, OnVal: LLVMValueRef, Dest: LLVMBasicBlockRef);
+
+ /// Add a destination to an `indirectbr` instruction
+ pub fn LLVMAddDestination(IndirectBr: LLVMValueRef, Dest: LLVMBasicBlockRef);
+
+ /// Get the number of clauses on a landingpad instruction.
+ pub fn LLVMGetNumClauses(LandingPad: LLVMValueRef) -> ::libc::c_uint;
+
+ /// Get the value of the clause with the given index on a landingpad instruction.
+ pub fn LLVMGetClause(LandingPad: LLVMValueRef, Idx: ::libc::c_uint) -> LLVMValueRef;
+
+ /// Add a catch or filter clause to a `landingpad` instruction
+ pub fn LLVMAddClause(LandingPad: LLVMValueRef, ClauseVal: LLVMValueRef);
+
+ /// Get the cleanup flag in a landingpad instruction.
+ pub fn LLVMIsCleanup(LandingPad: LLVMValueRef) -> LLVMBool;
+
+ /// Set the cleanup flag in a `landingpad` instruction.
+ pub fn LLVMSetCleanup(LandingPad: LLVMValueRef, Val: LLVMBool);
+
+ /// Add a destination to the catchswitch instruction
+ pub fn LLVMAddHandler(CatchSwitch: LLVMValueRef, Dest: LLVMBasicBlockRef);
+
+ /// Get the number of handlers on the catchswitch instruction
+ pub fn LLVMGetNumHandlers(CatchSwitch: LLVMValueRef) -> ::libc::c_uint;
+
+ /// Obtain the basic blocks acting as handlers for a catchswitch instruction.
+ ///
+ /// The Handlers parameter should point to a pre-allocated array of LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the first LLVMGetNumHandlers() entries in the array will be populated with LLVMBasicBlockRef instances.
+ pub fn LLVMGetHandlers(CatchSwitch: LLVMValueRef, Handlers: *mut LLVMBasicBlockRef);
+
+ // Funclets
+ /// Get the number of funcletpad arguments.
+ pub fn LLVMGetArgOperand(Funclet: LLVMValueRef, i: ::libc::c_uint) -> LLVMValueRef;
+
+ /// Set a funcletpad argument at the given index.
+ pub fn LLVMSetArgOperand(Funclet: LLVMValueRef, i: ::libc::c_uint, value: LLVMValueRef);
+
+ /// Get the parent catchswitch instruction of a catchpad instruction.
+ ///
+ /// This only works on llvm::CatchPadInst instructions.
+ pub fn LLVMGetParentCatchSwitch(CatchPad: LLVMValueRef) -> LLVMValueRef;
+
+ /// Set the parent catchswitch instruction of a catchpad instruction.
+ /// This only works on llvm::CatchPadInst instructions.
+ pub fn LLVMSetParentCatchSwitch(CatchPad: LLVMValueRef, CatchSwitch: LLVMValueRef);
+
+ // Arithmetic
+ pub fn LLVMBuildAdd(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNSWAdd(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNUWAdd(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFAdd(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSub(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNSWSub(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNUWSub(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFSub(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildMul(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNSWMul(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNUWMul(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFMul(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildUDiv(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildExactUDiv(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSDiv(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildExactSDiv(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFDiv(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildURem(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSRem(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFRem(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildShl(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildLShr(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAShr(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAnd(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildOr(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildXor(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildBinOp(
+ B: LLVMBuilderRef,
+ Op: LLVMOpcode,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNeg(
+ arg1: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNSWNeg(
+ B: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNUWNeg(
+ B: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFNeg(
+ arg1: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildNot(
+ arg1: LLVMBuilderRef,
+ V: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+
+ // Memory
+ pub fn LLVMBuildMalloc(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildArrayMalloc(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildMemSet(
+ B: LLVMBuilderRef,
+ Ptr: LLVMValueRef,
+ Val: LLVMValueRef,
+ Len: LLVMValueRef,
+ Align: ::libc::c_uint,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildMemCpy(
+ B: LLVMBuilderRef,
+ Dst: LLVMValueRef,
+ DstAlign: ::libc::c_uint,
+ Src: LLVMValueRef,
+ SrcAlign: ::libc::c_uint,
+ Size: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildMemMove(
+ B: LLVMBuilderRef,
+ Dst: LLVMValueRef,
+ DstAlign: ::libc::c_uint,
+ Src: LLVMValueRef,
+ SrcAlign: ::libc::c_uint,
+ Size: LLVMValueRef,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAlloca(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildArrayAlloca(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFree(arg1: LLVMBuilderRef, PointerVal: LLVMValueRef) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildLoad2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildLoad(
+ arg1: LLVMBuilderRef,
+ PointerVal: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildLoad2(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ PointerVal: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildStore(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ Ptr: LLVMValueRef,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildGEP2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildGEP(
+ B: LLVMBuilderRef,
+ Pointer: LLVMValueRef,
+ Indices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildInBoundsGEP2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildInBoundsGEP(
+ B: LLVMBuilderRef,
+ Pointer: LLVMValueRef,
+ Indices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildStructGEP2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildStructGEP(
+ B: LLVMBuilderRef,
+ Pointer: LLVMValueRef,
+ Idx: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildGEP2(
+ B: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Pointer: LLVMValueRef,
+ Indices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildInBoundsGEP2(
+ B: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Pointer: LLVMValueRef,
+ Indices: *mut LLVMValueRef,
+ NumIndices: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildStructGEP2(
+ B: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Pointer: LLVMValueRef,
+ Idx: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildGlobalString(
+ B: LLVMBuilderRef,
+ Str: *const ::libc::c_char,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildGlobalStringPtr(
+ B: LLVMBuilderRef,
+ Str: *const ::libc::c_char,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetVolatile(MemoryAccessInst: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetVolatile(MemoryAccessInst: LLVMValueRef, IsVolatile: LLVMBool);
+ pub fn LLVMGetWeak(CmpXchgInst: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetWeak(CmpXchgInst: LLVMValueRef, IsWeak: LLVMBool);
+ pub fn LLVMGetOrdering(MemoryAccessInst: LLVMValueRef) -> LLVMAtomicOrdering;
+ pub fn LLVMSetOrdering(MemoryAccessInst: LLVMValueRef, Ordering: LLVMAtomicOrdering);
+ pub fn LLVMGetAtomicRMWBinOp(AtomicRMWInst: LLVMValueRef) -> LLVMAtomicRMWBinOp;
+ pub fn LLVMSetAtomicRMWBinOp(AtomicRMWInst: LLVMValueRef, BinOp: LLVMAtomicRMWBinOp);
+
+ // Casts
+ pub fn LLVMBuildTrunc(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildZExt(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSExt(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFPToUI(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFPToSI(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildUIToFP(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSIToFP(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFPTrunc(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFPExt(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildPtrToInt(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIntToPtr(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildBitCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAddrSpaceCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildZExtOrBitCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSExtOrBitCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildTruncOrBitCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCast(
+ B: LLVMBuilderRef,
+ Op: LLVMOpcode,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildPointerCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIntCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIntCast2(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ IsSigned: LLVMBool,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFPCast(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ DestTy: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetCastOpcode(
+ arg1: LLVMValueRef,
+ SrcIsSigned: LLVMBool,
+ DestTy: LLVMTypeRef,
+ DestIsSigned: LLVMBool,
+ ) -> LLVMOpcode;
+
+ // Comparisons
+ pub fn LLVMBuildICmp(
+ arg1: LLVMBuilderRef,
+ Op: LLVMIntPredicate,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFCmp(
+ arg1: LLVMBuilderRef,
+ Op: LLVMRealPredicate,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+
+ // Miscellaneous instructions
+ pub fn LLVMBuildPhi(
+ arg1: LLVMBuilderRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildCall2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildCall(
+ arg1: LLVMBuilderRef,
+ Fn: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildCall2(
+ arg1: LLVMBuilderRef,
+ arg2: LLVMTypeRef,
+ Fn: LLVMValueRef,
+ Args: *mut LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildSelect(
+ arg1: LLVMBuilderRef,
+ If: LLVMValueRef,
+ Then: LLVMValueRef,
+ Else: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildVAArg(
+ arg1: LLVMBuilderRef,
+ List: LLVMValueRef,
+ Ty: LLVMTypeRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildExtractElement(
+ arg1: LLVMBuilderRef,
+ VecVal: LLVMValueRef,
+ Index: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildInsertElement(
+ arg1: LLVMBuilderRef,
+ VecVal: LLVMValueRef,
+ EltVal: LLVMValueRef,
+ Index: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildShuffleVector(
+ arg1: LLVMBuilderRef,
+ V1: LLVMValueRef,
+ V2: LLVMValueRef,
+ Mask: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildExtractValue(
+ arg1: LLVMBuilderRef,
+ AggVal: LLVMValueRef,
+ Index: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildInsertValue(
+ arg1: LLVMBuilderRef,
+ AggVal: LLVMValueRef,
+ EltVal: LLVMValueRef,
+ Index: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFreeze(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIsNull(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildIsNotNull(
+ arg1: LLVMBuilderRef,
+ Val: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ #[deprecated(
+ since = "14.0",
+ note = "Use LLVMBuildPtrDiff2 instead to support opaque pointers."
+ )]
+ pub fn LLVMBuildPtrDiff(
+ arg1: LLVMBuilderRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildPtrDiff2(
+ arg1: LLVMBuilderRef,
+ ElemTy: LLVMTypeRef,
+ LHS: LLVMValueRef,
+ RHS: LLVMValueRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildFence(
+ B: LLVMBuilderRef,
+ ordering: LLVMAtomicOrdering,
+ singleThread: LLVMBool,
+ Name: *const ::libc::c_char,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAtomicRMW(
+ B: LLVMBuilderRef,
+ op: LLVMAtomicRMWBinOp,
+ PTR: LLVMValueRef,
+ Val: LLVMValueRef,
+ ordering: LLVMAtomicOrdering,
+ singleThread: LLVMBool,
+ ) -> LLVMValueRef;
+ pub fn LLVMBuildAtomicCmpXchg(
+ B: LLVMBuilderRef,
+ Ptr: LLVMValueRef,
+ Cmp: LLVMValueRef,
+ New: LLVMValueRef,
+ SuccessOrdering: LLVMAtomicOrdering,
+ FailureOrdering: LLVMAtomicOrdering,
+ SingleThread: LLVMBool,
+ ) -> LLVMValueRef;
+ pub fn LLVMGetNumMaskElements(ShuffleVectorInst: LLVMValueRef) -> ::libc::c_uint;
+ pub fn LLVMGetUndefMaskElem() -> ::libc::c_int;
+ pub fn LLVMGetMaskValue(ShuffleVectorInst: LLVMValueRef, Elt: ::libc::c_uint) -> ::libc::c_int;
+ pub fn LLVMIsAtomicSingleThread(AtomicInst: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMSetAtomicSingleThread(AtomicInst: LLVMValueRef, SingleThread: LLVMBool);
+ pub fn LLVMGetCmpXchgSuccessOrdering(CmpXchgInst: LLVMValueRef) -> LLVMAtomicOrdering;
+ pub fn LLVMSetCmpXchgSuccessOrdering(CmpXchgInst: LLVMValueRef, Ordering: LLVMAtomicOrdering);
+ pub fn LLVMGetCmpXchgFailureOrdering(CmpXchgInst: LLVMValueRef) -> LLVMAtomicOrdering;
+ pub fn LLVMSetCmpXchgFailureOrdering(CmpXchgInst: LLVMValueRef, Ordering: LLVMAtomicOrdering);
+}
+
+// Core->Module Providers
+extern "C" {
+ pub fn LLVMCreateModuleProviderForExistingModule(M: LLVMModuleRef) -> LLVMModuleProviderRef;
+ pub fn LLVMDisposeModuleProvider(M: LLVMModuleProviderRef);
+}
+
+// Core->Memory Buffers
+extern "C" {
+ pub fn LLVMCreateMemoryBufferWithContentsOfFile(
+ Path: *const ::libc::c_char,
+ OutMemBuf: *mut LLVMMemoryBufferRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMCreateMemoryBufferWithSTDIN(
+ OutMemBuf: *mut LLVMMemoryBufferRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMCreateMemoryBufferWithMemoryRange(
+ InputData: *const ::libc::c_char,
+ InputDataLength: ::libc::size_t,
+ BufferName: *const ::libc::c_char,
+ RequiresNullTerminator: LLVMBool,
+ ) -> LLVMMemoryBufferRef;
+ pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(
+ InputData: *const ::libc::c_char,
+ InputDataLength: ::libc::size_t,
+ BufferName: *const ::libc::c_char,
+ ) -> LLVMMemoryBufferRef;
+ pub fn LLVMGetBufferStart(MemBuf: LLVMMemoryBufferRef) -> *const ::libc::c_char;
+ pub fn LLVMGetBufferSize(MemBuf: LLVMMemoryBufferRef) -> ::libc::size_t;
+ pub fn LLVMDisposeMemoryBuffer(MemBuf: LLVMMemoryBufferRef);
+}
+
+// Core->pass registry
+extern "C" {
+ pub fn LLVMGetGlobalPassRegistry() -> LLVMPassRegistryRef;
+}
+
+// Core->Pass managers
+extern "C" {
+ pub fn LLVMCreatePassManager() -> LLVMPassManagerRef;
+ pub fn LLVMCreateFunctionPassManagerForModule(M: LLVMModuleRef) -> LLVMPassManagerRef;
+ pub fn LLVMCreateFunctionPassManager(MP: LLVMModuleProviderRef) -> LLVMPassManagerRef;
+ pub fn LLVMRunPassManager(PM: LLVMPassManagerRef, M: LLVMModuleRef) -> LLVMBool;
+ pub fn LLVMInitializeFunctionPassManager(FPM: LLVMPassManagerRef) -> LLVMBool;
+ pub fn LLVMRunFunctionPassManager(FPM: LLVMPassManagerRef, F: LLVMValueRef) -> LLVMBool;
+ pub fn LLVMFinalizeFunctionPassManager(FPM: LLVMPassManagerRef) -> LLVMBool;
+ pub fn LLVMDisposePassManager(PM: LLVMPassManagerRef);
+}
+
+// Core->Threading
+extern "C" {
+ /// Deprecated: LLVM threading is configured at compile-time with `LLVM_ENABLE_THREADS`
+ pub fn LLVMStartMultithreaded() -> LLVMBool;
+ /// Deprecated: LLVM threading is configured at compile-time with `LLVM_ENABLE_THREADS`
+ pub fn LLVMStopMultithreaded();
+ pub fn LLVMIsMultithreaded() -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/debuginfo.rs b/ext/llvm-sys.rs/src/debuginfo.rs
new file mode 100644
index 0000000..ba906d9
--- /dev/null
+++ b/ext/llvm-sys.rs/src/debuginfo.rs
@@ -0,0 +1,880 @@
+//! Generation of DWARF debug info.
+use super::*;
+
+// Debug info flags.
+pub type LLVMDIFlags = ::libc::c_int;
+pub const LLVMDIFlagZero: LLVMDIFlags = 0;
+pub const LLVMDIFlagPrivate: LLVMDIFlags = 1;
+pub const LLVMDIFlagProtected: LLVMDIFlags = 2;
+pub const LLVMDIFlagPublic: LLVMDIFlags = 3;
+pub const LLVMDIFlagFwdDecl: LLVMDIFlags = 1 << 2;
+pub const LLVMDIFlagAppleBlock: LLVMDIFlags = 1 << 3;
+pub const LLVMDIFlagReservedBit4: LLVMDIFlags = 1 << 4;
+pub const LLVMDIFlagVirtual: LLVMDIFlags = 1 << 5;
+pub const LLVMDIFlagArtificial: LLVMDIFlags = 1 << 6;
+pub const LLVMDIFlagExplicit: LLVMDIFlags = 1 << 7;
+pub const LLVMDIFlagPrototyped: LLVMDIFlags = 1 << 8;
+pub const LLVMDIFlagObjcClassComplete: LLVMDIFlags = 1 << 9;
+pub const LLVMDIFlagObjectPointer: LLVMDIFlags = 1 << 10;
+pub const LLVMDIFlagVector: LLVMDIFlags = 1 << 11;
+pub const LLVMDIFlagStaticMember: LLVMDIFlags = 1 << 12;
+pub const LLVMDIFlagLValueReference: LLVMDIFlags = 1 << 13;
+pub const LLVMDIFlagRValueReference: LLVMDIFlags = 1 << 14;
+pub const LLVMDIFlagReserved: LLVMDIFlags = 1 << 15;
+pub const LLVMDIFlagSingleInheritance: LLVMDIFlags = 1 << 16;
+pub const LLVMDIFlagMultipleInheritance: LLVMDIFlags = 2 << 16;
+pub const LLVMDIFlagVirtualInheritance: LLVMDIFlags = 3 << 16;
+pub const LLVMDIFlagIntroducedVirtual: LLVMDIFlags = 1 << 18;
+pub const LLVMDIFlagBitField: LLVMDIFlags = 1 << 19;
+pub const LLVMDIFlagNoReturn: LLVMDIFlags = 1 << 20;
+pub const LLVMDIFlagTypePassByValue: LLVMDIFlags = 1 << 22;
+pub const LLVMDIFlagTypePassByReference: LLVMDIFlags = 1 << 23;
+pub const LLVMDIFlagEnumClass: LLVMDIFlags = 1 << 24;
+pub const LLVMDIFlagThunk: LLVMDIFlags = 1 << 25;
+pub const LLVMDIFlagNonTrivial: LLVMDIFlags = 1 << 26;
+pub const LLVMDIFlagBigendian: LLVMDIFlags = 1 << 27;
+pub const LLVMDIFlagLittleEndian: LLVMDIFlags = 1 << 28;
+pub const LLVMDIFlagIndirectVirtualBase: LLVMDIFlags = (1 << 2) | (1 << 5);
+pub const LLVMDIFlagAccessibility: LLVMDIFlags =
+ LLVMDIFlagProtected | LLVMDIFlagPrivate | LLVMDIFlagPublic;
+pub const LLVMDIFlagPtrToMemberRep: LLVMDIFlags =
+ LLVMDIFlagSingleInheritance | LLVMDIFlagMultipleInheritance | LLVMDIFlagVirtualInheritance;
+
+/// Source languages known by DWARF.
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMDWARFSourceLanguage {
+ LLVMDWARFSourceLanguageC89,
+ LLVMDWARFSourceLanguageC,
+ LLVMDWARFSourceLanguageAda83,
+ LLVMDWARFSourceLanguageC_plus_plus,
+ LLVMDWARFSourceLanguageCobol74,
+ LLVMDWARFSourceLanguageCobol85,
+ LLVMDWARFSourceLanguageFortran77,
+ LLVMDWARFSourceLanguageFortran90,
+ LLVMDWARFSourceLanguagePascal83,
+ LLVMDWARFSourceLanguageModula2,
+ // New in DWARF v3:
+ LLVMDWARFSourceLanguageJava,
+ LLVMDWARFSourceLanguageC99,
+ LLVMDWARFSourceLanguageAda95,
+ LLVMDWARFSourceLanguageFortran95,
+ LLVMDWARFSourceLanguagePLI,
+ LLVMDWARFSourceLanguageObjC,
+ LLVMDWARFSourceLanguageObjC_plus_plus,
+ LLVMDWARFSourceLanguageUPC,
+ LLVMDWARFSourceLanguageD,
+ // New in DWARF v4:
+ LLVMDWARFSourceLanguagePython,
+ // New in DWARF v5:
+ LLVMDWARFSourceLanguageOpenCL,
+ LLVMDWARFSourceLanguageGo,
+ LLVMDWARFSourceLanguageModula3,
+ LLVMDWARFSourceLanguageHaskell,
+ LLVMDWARFSourceLanguageC_plus_plus_03,
+ LLVMDWARFSourceLanguageC_plus_plus_11,
+ LLVMDWARFSourceLanguageOCaml,
+ LLVMDWARFSourceLanguageRust,
+ LLVMDWARFSourceLanguageC11,
+ LLVMDWARFSourceLanguageSwift,
+ LLVMDWARFSourceLanguageJulia,
+ LLVMDWARFSourceLanguageDylan,
+ LLVMDWARFSourceLanguageC_plus_plus_14,
+ LLVMDWARFSourceLanguageFortran03,
+ LLVMDWARFSourceLanguageFortran08,
+ LLVMDWARFSourceLanguageRenderScript,
+ LLVMDWARFSourceLanguageBLISS,
+ // Vendor extensions:
+ LLVMDWARFSourceLanguageMips_Assembler,
+ LLVMDWARFSourceLanguageGOOGLE_RenderScript,
+ LLVMDWARFSourceLanguageBORLAND_Delphi,
+}
+
+/// The amount of debug information to emit.
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMDWARFEmissionKind {
+ LLVMDWARFEmissionKindNone = 0,
+ LLVMDWARFEmissionKindFull,
+ LLVMDWARFEmissionKindLineTablesOnly,
+}
+
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMMetadataKind {
+ LLVMMDStringMetadataKind,
+ LLVMConstantAsMetadataMetadataKind,
+ LLVMLocalAsMetadataMetadataKind,
+ LLVMDistinctMDOperandPlaceholderMetadataKind,
+ LLVMMDTupleMetadataKind,
+ LLVMDILocationMetadataKind,
+ LLVMDIExpressionMetadataKind,
+ LLVMDIGlobalVariableExpressionMetadataKind,
+ LLVMGenericDINodeMetadataKind,
+ LLVMDISubrangeMetadataKind,
+ LLVMDIEnumeratorMetadataKind,
+ LLVMDIBasicTypeMetadataKind,
+ LLVMDIDerivedTypeMetadataKind,
+ LLVMDICompositeTypeMetadataKind,
+ LLVMDISubroutineTypeMetadataKind,
+ LLVMDIFileMetadataKind,
+ LLVMDICompileUnitMetadataKind,
+ LLVMDISubprogramMetadataKind,
+ LLVMDILexicalBlockMetadataKind,
+ LLVMDILexicalBlockFileMetadataKind,
+ LLVMDINamespaceMetadataKind,
+ LLVMDIModuleMetadataKind,
+ LLVMDITemplateTypeParameterMetadataKind,
+ LLVMDITemplateValueParameterMetadataKind,
+ LLVMDIGlobalVariableMetadataKind,
+ LLVMDILocalVariableMetadataKind,
+ LLVMDILabelMetadataKind,
+ LLVMDIObjCPropertyMetadataKind,
+ LLVMDIImportedEntityMetadataKind,
+ LLVMDIMacroMetadataKind,
+ LLVMDIMacroFileMetadataKind,
+ LLVMDICommonBlockMetadataKind,
+ LLVMDIStringTypeMetadataKind,
+ LLVMDIGenericSubrangeMetadataKind,
+ LLVMDIArgListMetadataKind,
+}
+
+pub type LLVMDWARFTypeEncoding = ::libc::c_uint;
+
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMDWARFMacinfoRecordType {
+ LLVMDWARFMacinfoRecordTypeDefine = 0x01,
+ LLVMDWARFMacinfoRecordTypeMacro = 0x02,
+ LLVMDWARFMacinfoRecordTypeStartFile = 0x03,
+ LLVMDWARFMacinfoRecordTypeEndFile = 0x04,
+ LLVMDWARFMacinfoRecordTypeVendorExt = 0xff,
+}
+
+extern "C" {
+ /// The current debug metadata version number.
+ pub fn LLVMDebugMetadataVersion() -> ::libc::c_uint;
+ /// The version of debug metadata that's present in the provided Module.
+ pub fn LLVMGetModuleDebugMetadataVersion(Module: LLVMModuleRef) -> ::libc::c_uint;
+ /// Strip debug info in the module if it exists.
+ pub fn LLVMStripModuleDebugInfo(Module: LLVMModuleRef) -> LLVMBool;
+ /// Construct a builder for a module, do not allow unresolved nodes.
+ pub fn LLVMCreateDIBuilderDisallowUnresolved(M: LLVMModuleRef) -> LLVMDIBuilderRef;
+ /// Construct a builder for a module and collect unresolved nodes.
+ pub fn LLVMCreateDIBuilder(M: LLVMModuleRef) -> LLVMDIBuilderRef;
+ /// Deallocate a builder and everything it owns.
+ ///
+ /// The builder must be finalized before this.
+ pub fn LLVMDisposeDIBuilder(Builder: LLVMDIBuilderRef);
+ /// Construct any deferred debug info descriptors.
+ pub fn LLVMDIBuilderFinalize(Builder: LLVMDIBuilderRef);
+ /// Finalize a specific subprogram.
+ /// No new variables may be added to this subprogram afterwards.
+ pub fn LLVMDIBuilderFinalizeSubprogram(Builder: LLVMDIBuilderRef, Subprogram: LLVMMetadataRef);
+ pub fn LLVMDIBuilderCreateCompileUnit(
+ Builder: LLVMDIBuilderRef,
+ Lang: LLVMDWARFSourceLanguage,
+ FileRef: LLVMMetadataRef,
+ Producer: *const ::libc::c_char,
+ ProducerLen: ::libc::size_t,
+ isOptimized: LLVMBool,
+ Flags: *const ::libc::c_char,
+ FlagsLen: ::libc::size_t,
+ RuntimeVer: ::libc::c_uint,
+ SplitName: *const ::libc::c_char,
+ SplitNameLen: ::libc::size_t,
+ Kind: LLVMDWARFEmissionKind,
+ DWOId: ::libc::c_uint,
+ SplitDebugInlining: LLVMBool,
+ DebugInfoForProfiling: LLVMBool,
+ SysRoot: *const ::libc::c_char,
+ SysRootLen: ::libc::size_t,
+ SDK: *const ::libc::c_char,
+ SDKLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+ /// Create a file descriptor to hold debugging information for a file.
+ pub fn LLVMDIBuilderCreateFile(
+ Builder: LLVMDIBuilderRef,
+ Filename: *const ::libc::c_char,
+ FilenameLen: ::libc::size_t,
+ Directory: *const ::libc::c_char,
+ DirectoryLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Creates a new descriptor for a module with the specified parent scope.
+ pub fn LLVMDIBuilderCreateModule(
+ Builder: LLVMDIBuilderRef,
+ ParentScope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ConfigMacros: *const ::libc::c_char,
+ ConfigMacrosLen: ::libc::size_t,
+ IncludePath: *const ::libc::c_char,
+ IncludePathLen: ::libc::size_t,
+ APINotesFile: *const ::libc::c_char,
+ APINotesFileLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Creates a new descriptor for a namespace with the specified parent scope.
+ pub fn LLVMDIBuilderCreateNameSpace(
+ Builder: LLVMDIBuilderRef,
+ ParentScope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ExportSymbols: LLVMBool,
+ ) -> LLVMMetadataRef;
+
+ /// Create a new descriptor for the specified subprogram.
+ pub fn LLVMDIBuilderCreateFunction(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ LinkageName: *const ::libc::c_char,
+ LinkageNameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ IsLocalToUnit: LLVMBool,
+ IsDefinition: LLVMBool,
+ ScopeLine: ::libc::c_uint,
+ Flags: LLVMDIFlags,
+ IsOptimized: LLVMBool,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for a lexical block with the specified parent context.
+ pub fn LLVMDIBuilderCreateLexicalBlock(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ Column: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for a lexical block with a new file attached.
+ pub fn LLVMDIBuilderCreateLexicalBlockFile(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Discriminator: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for an imported namespace. Suitable for e.g. C++ using declarations.
+ pub fn LLVMDIBuilderCreateImportedModuleFromNamespace(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ NS: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for an imported module that aliases another imported entity descriptor.
+ pub fn LLVMDIBuilderCreateImportedModuleFromAlias(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ ImportedEntity: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for an imported module.
+ pub fn LLVMDIBuilderCreateImportedModuleFromModule(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ M: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a descriptor for an imported function, type, or variable.
+ ///
+ /// Suitable for e.g. FORTRAN-style USE declarations.
+ pub fn LLVMDIBuilderCreateImportedDeclaration(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Decl: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Creates a new DebugLocation that describes a source location.
+ pub fn LLVMDIBuilderCreateDebugLocation(
+ Ctx: LLVMContextRef,
+ Line: ::libc::c_uint,
+ Column: ::libc::c_uint,
+ Scope: LLVMMetadataRef,
+ InlinedAt: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Get the line number of this debug location.
+ pub fn LLVMDILocationGetLine(Location: LLVMMetadataRef) -> ::libc::c_uint;
+
+ /// Get the column number of this debug location.
+ pub fn LLVMDILocationGetColumn(Location: LLVMMetadataRef) -> ::libc::c_uint;
+
+ /// Get the local scope associated with this debug location.
+ pub fn LLVMDILocationGetScope(Location: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Get the "inline at" location associated with this debug location.
+ pub fn LLVMDILocationGetInlinedAt(Location: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Get the metadata of the file associated with a given scope.
+ pub fn LLVMDIScopeGetFile(Scope: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Get the directory of a given file.
+ pub fn LLVMDIFileGetDirectory(
+ File: LLVMMetadataRef,
+ Len: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+
+ /// Get the name of a given file.
+ pub fn LLVMDIFileGetFilename(
+ File: LLVMMetadataRef,
+ Len: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+
+ /// Get the source of a given file.
+ pub fn LLVMDIFileGetSource(
+ File: LLVMMetadataRef,
+ Len: *mut ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+
+ /// Create a type array.
+ pub fn LLVMDIBuilderGetOrCreateTypeArray(
+ Builder: LLVMDIBuilderRef,
+ Data: *mut LLVMMetadataRef,
+ NumElements: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create subroutine type.
+ pub fn LLVMDIBuilderCreateSubroutineType(
+ Builder: LLVMDIBuilderRef,
+ File: LLVMMetadataRef,
+ ParameterTypes: *mut LLVMMetadataRef,
+ NumParameterTypes: ::libc::c_uint,
+ Flags: LLVMDIFlags,
+ ) -> LLVMMetadataRef;
+
+ pub fn LLVMDIBuilderCreateMacro(
+ Builder: LLVMDIBuilderRef,
+ ParentMacroFile: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ RecordType: LLVMDWARFMacinfoRecordType,
+ Name: *const ::libc::c_char,
+ NameLen: usize,
+ Value: *const ::libc::c_char,
+ ValueLen: usize,
+ ) -> LLVMMetadataRef;
+
+ pub fn LLVMDIBuilderCreateTempMacroFile(
+ Builder: LLVMDIBuilderRef,
+ ParentMacroFile: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ File: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for an enumerator.
+ pub fn LLVMDIBuilderCreateEnumerator(
+ Builder: LLVMDIBuilderRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Value: i64,
+ IsUnsigned: LLVMBool,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for an enumeration.
+ pub fn LLVMDIBuilderCreateEnumerationType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ ClassTy: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a union.
+ pub fn LLVMDIBuilderCreateUnionType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Flags: LLVMDIFlags,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ RunTimeLang: ::libc::c_uint,
+ UniqueId: *const ::libc::c_char,
+ UniqueIdLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for an array.
+ pub fn LLVMDIBuilderCreateArrayType(
+ Builder: LLVMDIBuilderRef,
+ Size: u64,
+ AlignInBits: u32,
+ Ty: LLVMMetadataRef,
+ Subscripts: *mut LLVMMetadataRef,
+ NumSubscripts: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a vector type.
+ pub fn LLVMDIBuilderCreateVectorType(
+ Builder: LLVMDIBuilderRef,
+ Size: u64,
+ AlignInBits: u32,
+ Ty: LLVMMetadataRef,
+ Subscripts: *mut LLVMMetadataRef,
+ NumSubscripts: ::libc::c_uint,
+ ) -> LLVMMetadataRef;
+
+ /// Create a DWARF unspecified type.
+ pub fn LLVMDIBuilderCreateUnspecifiedType(
+ Builder: LLVMDIBuilderRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a basic type.
+ pub fn LLVMDIBuilderCreateBasicType(
+ Builder: LLVMDIBuilderRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ SizeInBits: u64,
+ Encoding: LLVMDWARFTypeEncoding,
+ Flags: LLVMDIFlags,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a pointer.
+ pub fn LLVMDIBuilderCreatePointerType(
+ Builder: LLVMDIBuilderRef,
+ PointeeTy: LLVMMetadataRef,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ AddressSpace: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a struct.
+ pub fn LLVMDIBuilderCreateStructType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Flags: LLVMDIFlags,
+ DerivedFrom: LLVMMetadataRef,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ RunTimeLang: ::libc::c_uint,
+ VTableHolder: LLVMMetadataRef,
+ UniqueId: *const ::libc::c_char,
+ UniqueIdLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a member.
+ pub fn LLVMDIBuilderCreateMemberType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ OffsetInBits: u64,
+ Flags: LLVMDIFlags,
+ Ty: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a C++ static data member.
+ pub fn LLVMDIBuilderCreateStaticMemberType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ Type: LLVMMetadataRef,
+ Flags: LLVMDIFlags,
+ ConstantVal: LLVMValueRef,
+ AlignInBits: u32,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a pointer to member.
+ pub fn LLVMDIBuilderCreateMemberPointerType(
+ Builder: LLVMDIBuilderRef,
+ PointeeType: LLVMMetadataRef,
+ ClassType: LLVMMetadataRef,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Flags: LLVMDIFlags,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for Objective-C instance variable.
+ pub fn LLVMDIBuilderCreateObjCIVar(
+ Builder: LLVMDIBuilderRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ OffsetInBits: u64,
+ Flags: LLVMDIFlags,
+ Ty: LLVMMetadataRef,
+ PropertyNode: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for Objective-C property.
+ pub fn LLVMDIBuilderCreateObjCProperty(
+ Builder: LLVMDIBuilderRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ GetterName: *const ::libc::c_char,
+ GetterNameLen: ::libc::size_t,
+ SetterName: *const ::libc::c_char,
+ SetterNameLen: ::libc::size_t,
+ PropertyAttributes: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
+ pub fn LLVMDIBuilderCreateObjectPointerType(
+ Builder: LLVMDIBuilderRef,
+ Type: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a qualified type, e.g. 'const int'.
+ pub fn LLVMDIBuilderCreateQualifiedType(
+ Builder: LLVMDIBuilderRef,
+ Tag: ::libc::c_uint,
+ Type: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a c++ style reference or rvalue reference type.
+ pub fn LLVMDIBuilderCreateReferenceType(
+ Builder: LLVMDIBuilderRef,
+ Tag: ::libc::c_uint,
+ Type: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create C++11 nullptr type.
+ pub fn LLVMDIBuilderCreateNullPtrType(Builder: LLVMDIBuilderRef) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a typedef.
+ pub fn LLVMDIBuilderCreateTypedef(
+ Builder: LLVMDIBuilderRef,
+ Type: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Scope: LLVMMetadataRef,
+ AlignInBits: u32,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry to establish inheritance relationship between two types.
+ pub fn LLVMDIBuilderCreateInheritance(
+ Builder: LLVMDIBuilderRef,
+ Ty: LLVMMetadataRef,
+ BaseTy: LLVMMetadataRef,
+ BaseOffset: u64,
+ VBPtrOffset: u32,
+ Flags: LLVMDIFlags,
+ ) -> LLVMMetadataRef;
+
+ /// Create a permanent forward-declared type.
+ pub fn LLVMDIBuilderCreateForwardDecl(
+ Builder: LLVMDIBuilderRef,
+ Tag: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Scope: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ RuntimeLang: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ UniqueIdentifier: *const ::libc::c_char,
+ UniqueIdentifierLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create a temporary forward-declared type.
+ pub fn LLVMDIBuilderCreateReplaceableCompositeType(
+ Builder: LLVMDIBuilderRef,
+ Tag: ::libc::c_uint,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Scope: LLVMMetadataRef,
+ File: LLVMMetadataRef,
+ Line: ::libc::c_uint,
+ RuntimeLang: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Flags: LLVMDIFlags,
+ UniqueIdentifier: *const ::libc::c_char,
+ UniqueIdentifierLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a bit field member.
+ pub fn LLVMDIBuilderCreateBitFieldMemberType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ SizeInBits: u64,
+ OffsetInBits: u64,
+ StorageOffsetInBits: u64,
+ Flags: LLVMDIFlags,
+ Type: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Create debugging information entry for a class.
+ pub fn LLVMDIBuilderCreateClassType(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNumber: ::libc::c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ OffsetInBits: u64,
+ Flags: LLVMDIFlags,
+ DerivedFrom: LLVMMetadataRef,
+ Elements: *mut LLVMMetadataRef,
+ NumElements: ::libc::c_uint,
+ VTableHolder: LLVMMetadataRef,
+ TemplateParamsNode: LLVMMetadataRef,
+ UniqueIdentifier: *const ::libc::c_char,
+ UniqueIdentifierLen: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create a uniqued DIType* clone with FlagArtificial set.
+ pub fn LLVMDIBuilderCreateArtificialType(
+ Builder: LLVMDIBuilderRef,
+ Type: LLVMMetadataRef,
+ ) -> LLVMMetadataRef;
+
+ /// Get the name of this DIType.
+ pub fn LLVMDITypeGetName(
+ DType: LLVMMetadataRef,
+ Length: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+
+ /// Get the size of this DIType in bits.
+ pub fn LLVMDITypeGetSizeInBits(DType: LLVMMetadataRef) -> u64;
+
+ /// Get the offset of this DIType in bits.
+ pub fn LLVMDITypeGetOffsetInBits(DType: LLVMMetadataRef) -> u64;
+
+ /// Get the alignment of this DIType in bits.
+ pub fn LLVMDITypeGetAlignInBits(DType: LLVMMetadataRef) -> u32;
+
+ /// Get the source line where this DIType is declared.
+ pub fn LLVMDITypeGetLine(DType: LLVMMetadataRef) -> ::libc::c_uint;
+
+ /// Get the flags associated with this DIType.
+ pub fn LLVMDITypeGetFlags(DType: LLVMMetadataRef) -> LLVMDIFlags;
+
+ /// Create a descriptor for a value range.
+ pub fn LLVMDIBuilderGetOrCreateSubrange(
+ Builder: LLVMDIBuilderRef,
+ LowerBound: i64,
+ Count: i64,
+ ) -> LLVMMetadataRef;
+
+ /// Create an array of DI Nodes.
+ pub fn LLVMDIBuilderGetOrCreateArray(
+ Builder: LLVMDIBuilderRef,
+ Data: *mut LLVMMetadataRef,
+ NumElements: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create a new descriptor for the specified variable which has a complex
+ pub fn LLVMDIBuilderCreateExpression(
+ Builder: LLVMDIBuilderRef,
+ Addr: *mut u64,
+ Length: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Create a new descriptor for the specified variable that does not have an
+ pub fn LLVMDIBuilderCreateConstantValueExpression(
+ Builder: LLVMDIBuilderRef,
+ Value: u64,
+ ) -> LLVMMetadataRef;
+
+ /// Create a new descriptor for the specified variable.
+ pub fn LLVMDIBuilderCreateGlobalVariableExpression(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Linkage: *const ::libc::c_char,
+ LinkLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ LocalToUnit: LLVMBool,
+ Expr: LLVMMetadataRef,
+ Decl: LLVMMetadataRef,
+ AlignInBits: u32,
+ ) -> LLVMMetadataRef;
+
+ /// Retrieves the DIVariable associated with this global variable expression.
+ pub fn LLVMDIGlobalVariableExpressionGetVariable(GVE: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Retrieves the DIExpression associated with this global variable expression.
+ pub fn LLVMDIGlobalVariableExpressionGetExpression(GVE: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ ///Get the metadata of the file associated with a given variable.
+ pub fn LLVMDIVariableGetFile(Var: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Get the metadata of the scope associated with a given variable.
+ pub fn LLVMDIVariableGetScope(Var: LLVMMetadataRef) -> LLVMMetadataRef;
+
+ /// Get the source line where this \c DIVariable is declared.
+ pub fn LLVMDIVariableGetLine(Var: LLVMMetadataRef) -> ::libc::c_uint;
+
+ /// Create a new temporary \c MDNode. Suitable for use in constructing cyclic
+ pub fn LLVMTemporaryMDNode(
+ Ctx: LLVMContextRef,
+ Data: *mut LLVMMetadataRef,
+ NumElements: ::libc::size_t,
+ ) -> LLVMMetadataRef;
+
+ /// Deallocate a temporary node.
+ pub fn LLVMDisposeTemporaryMDNode(TempNode: LLVMMetadataRef);
+
+ /// Replace all uses of temporary metadata.
+ pub fn LLVMMetadataReplaceAllUsesWith(
+ TempTargetMetadata: LLVMMetadataRef,
+ Replacement: LLVMMetadataRef,
+ );
+
+ /// Create a new descriptor for the specified global variable that is temporary
+ pub fn LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ Linkage: *const ::libc::c_char,
+ LnkLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ LocalToUnit: LLVMBool,
+ Decl: LLVMMetadataRef,
+ AlignInBits: u32,
+ ) -> LLVMMetadataRef;
+
+ /// Insert a new llvm.dbg.declare intrinsic call before the given instruction.
+ pub fn LLVMDIBuilderInsertDeclareBefore(
+ Builder: LLVMDIBuilderRef,
+ Storage: LLVMValueRef,
+ VarInfo: LLVMMetadataRef,
+ Expr: LLVMMetadataRef,
+ DebugLoc: LLVMMetadataRef,
+ Instr: LLVMValueRef,
+ ) -> LLVMValueRef;
+
+ /// Insert a new llvm.dbg.declare intrinsic call at the end of the given basic block. If the basic block has a terminator instruction, the intrinsic is inserted before that terminator instruction.
+ pub fn LLVMDIBuilderInsertDeclareAtEnd(
+ Builder: LLVMDIBuilderRef,
+ Storage: LLVMValueRef,
+ VarInfo: LLVMMetadataRef,
+ Expr: LLVMMetadataRef,
+ DebugLoc: LLVMMetadataRef,
+ Block: LLVMBasicBlockRef,
+ ) -> LLVMValueRef;
+
+ /// Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ pub fn LLVMDIBuilderInsertDbgValueBefore(
+ Builder: LLVMDIBuilderRef,
+ Val: LLVMValueRef,
+ VarInfo: LLVMMetadataRef,
+ Expr: LLVMMetadataRef,
+ DebugLoc: LLVMMetadataRef,
+ Instr: LLVMValueRef,
+ ) -> LLVMValueRef;
+
+ /// Insert a new llvm.dbg.value intrinsic call at the end of the given basic block. If the basic block has a terminator instruction, the intrinsic is inserted before that terminator instruction.
+ pub fn LLVMDIBuilderInsertDbgValueAtEnd(
+ Builder: LLVMDIBuilderRef,
+ Val: LLVMValueRef,
+ VarInfo: LLVMMetadataRef,
+ Expr: LLVMMetadataRef,
+ DebugLoc: LLVMMetadataRef,
+ Block: LLVMBasicBlockRef,
+ ) -> LLVMValueRef;
+
+ /// Create a new descriptor for a local auto variable.
+ pub fn LLVMDIBuilderCreateAutoVariable(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ AlwaysPreserve: LLVMBool,
+ Flags: LLVMDIFlags,
+ AlignInBits: u32,
+ ) -> LLVMMetadataRef;
+
+ /// Create a new descriptor for a function parameter variable.
+ pub fn LLVMDIBuilderCreateParameterVariable(
+ Builder: LLVMDIBuilderRef,
+ Scope: LLVMMetadataRef,
+ Name: *const ::libc::c_char,
+ NameLen: ::libc::size_t,
+ ArgNo: ::libc::c_uint,
+ File: LLVMMetadataRef,
+ LineNo: ::libc::c_uint,
+ Ty: LLVMMetadataRef,
+ AlwaysPreserve: LLVMBool,
+ Flags: LLVMDIFlags,
+ ) -> LLVMMetadataRef;
+
+ /// Get the metadata of the subprogram attached to a function.
+ pub fn LLVMGetSubprogram(Func: LLVMValueRef) -> LLVMMetadataRef;
+
+ /// Set the subprogram attached to a function.
+ pub fn LLVMSetSubprogram(Func: LLVMValueRef, SP: LLVMMetadataRef);
+
+ /// Get the line associated with a given subprogram.
+ pub fn LLVMDISubprogramGetLine(Subprogram: LLVMMetadataRef) -> ::libc::c_uint;
+
+ /// Get the debug location for the given instruction.
+ pub fn LLVMInstructionGetDebugLoc(Inst: LLVMValueRef) -> LLVMMetadataRef;
+
+ /// Set the debug location for the given instruction.
+ pub fn LLVMInstructionSetDebugLoc(Inst: LLVMValueRef, Loc: LLVMMetadataRef);
+
+ /// Obtain the enumerated type of a metadata instance.
+ pub fn LLVMGetMetadataKind(Metadata: LLVMMetadataRef) -> LLVMMetadataKind;
+}
diff --git a/ext/llvm-sys.rs/src/disassembler.rs b/ext/llvm-sys.rs/src/disassembler.rs
new file mode 100644
index 0000000..3eed4a3
--- /dev/null
+++ b/ext/llvm-sys.rs/src/disassembler.rs
@@ -0,0 +1,147 @@
+//! A disassembler library.
+
+#![allow(non_upper_case_globals, non_snake_case)]
+
+#[derive(Debug)]
+pub enum LLVMOpaqueDisasmContext {}
+
+pub type LLVMDisasmContextRef = *mut LLVMOpaqueDisasmContext;
+
+pub type LLVMOpInfoCallback = Option<
+ extern "C" fn(
+ DisInfo: *mut ::libc::c_void,
+ PC: u64,
+ Offset: u64,
+ OpSize: u64,
+ InstSize: u64,
+ TagType: ::libc::c_int,
+ TagBuf: *mut ::libc::c_void,
+ ) -> ::libc::c_int,
+>;
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOpInfoSymbol1 {
+ /// 1 if this symbol is present.
+ pub Present: u64,
+ /// Symbol name if not NULL.
+ pub Name: *const ::libc::c_char,
+ /// Symbol value if name is NULL.
+ pub Value: u64,
+}
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct Struct_LLVMOpInfo1 {
+ pub AddSymbol: LLVMOpInfoSymbol1,
+ pub SubtractSymbol: LLVMOpInfoSymbol1,
+ pub Value: u64,
+ pub VariantKind: u64,
+}
+
+pub const LLVMDisassembler_VariantKind_None: u64 = 0;
+pub const LLVMDisassembler_VariantKind_ARM_HI16: u64 = 1;
+pub const LLVMDisassembler_VariantKind_ARM_LO16: u64 = 2;
+pub const LLVMDisassembler_VariantKind_ARM64_PAGE: u64 = 1;
+pub const LLVMDisassembler_VariantKind_ARM64_PAGEOFF: u64 = 2;
+pub const LLVMDisassembler_VariantKind_ARM64_GOTPAGE: u64 = 3;
+pub const LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF: u64 = 4;
+pub const LLVMDisassembler_VariantKind_ARM64_TLVP: u64 = 5;
+pub const LLVMDisassembler_VariantKind_ARM64_TLVOFF: u64 = 6;
+
+/// No input reference type or no output reference type.
+pub const LLVMDisassembler_ReferenceType_InOut_None: u64 = 0;
+
+/// The input reference is from a branch instruction.
+pub const LLVMDisassembler_ReferenceType_In_Branch: u64 = 1;
+/// The input reference is from a PC relative load instruction.
+pub const LLVMDisassembler_ReferenceType_In_PCrel_Load: u64 = 2;
+
+/// The input reference is from an ARM64::ADRP instruction.
+pub const LLVMDisassembler_ReferenceType_In_ARM64_ADRP: u64 = 0x100000001;
+/// The input reference is from an ARM64::ADDXri instruction.
+pub const LLVMDisassembler_ReferenceType_In_ARM64_ADDXri: u64 = 0x100000002;
+/// The input reference is from an ARM64::LDRXui instruction.
+pub const LLVMDisassembler_ReferenceType_In_ARM64_LDRXui: u64 = 0x100000003;
+/// The input reference is from an ARM64::LDRXl instruction.
+pub const LLVMDisassembler_ReferenceType_In_ARM64_LDRXl: u64 = 0x100000004;
+/// The input reference is from an ARM64::ADR instruction.
+pub const LLVMDisassembler_ReferenceType_In_ARM64_ADR: u64 = 0x100000005;
+
+/// The output reference is to as symbol stub.
+pub const LLVMDisassembler_ReferenceType_Out_SymbolStub: u64 = 1;
+/// The output reference is to a symbol address in a literal pool.
+pub const LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr: u64 = 2;
+/// The output reference is to a cstring address in a literal pool.
+pub const LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr: u64 = 3;
+
+/// The output reference is to a Objective-C CoreFoundation string.
+pub const LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref: u64 = 4;
+/// The output reference is to a Objective-C message.
+pub const LLVMDisassembler_ReferenceType_Out_Objc_Message: u64 = 5;
+/// The output reference is to a Objective-C message ref.
+pub const LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref: u64 = 6;
+/// The output reference is to a Objective-C selector ref.
+pub const LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref: u64 = 7;
+/// The output reference is to a Objective-C class ref.
+pub const LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref: u64 = 8;
+/// The output reference is to a C++ symbol name.
+pub const LLVMDisassembler_ReferenceType_DeMangled_Name: u64 = 9;
+
+/// The option to produce marked up assembly.
+pub const LLVMDisassembler_Option_UseMarkup: u64 = 1;
+/// The option to print immediates as hex.
+pub const LLVMDisassembler_Option_PrintImmHex: u64 = 2;
+/// The option use the other assembler printer variant
+pub const LLVMDisassembler_Option_AsmPrinterVariant: u64 = 4;
+/// The option to set comment on instructions
+pub const LLVMDisassembler_Option_SetInstrComments: u64 = 8;
+/// The option to print latency information alongside instructions
+pub const LLVMDisassembler_Option_PrintLatency: u64 = 16;
+
+pub type LLVMSymbolLookupCallback = Option<
+ extern "C" fn(
+ DisInfo: *mut ::libc::c_void,
+ ReferenceValue: u64,
+ ReferenceType: *mut u64,
+ ReferencePC: u64,
+ ReferenceName: *mut *const ::libc::c_char,
+ ) -> *const ::libc::c_char,
+>;
+
+extern "C" {
+ pub fn LLVMCreateDisasm(
+ TripleName: *const ::libc::c_char,
+ DisInfo: *mut ::libc::c_void,
+ TagType: ::libc::c_int,
+ GetOpInfo: LLVMOpInfoCallback,
+ SymbolLookUp: LLVMSymbolLookupCallback,
+ ) -> LLVMDisasmContextRef;
+ pub fn LLVMCreateDisasmCPU(
+ Triple: *const ::libc::c_char,
+ CPU: *const ::libc::c_char,
+ DisInfo: *mut ::libc::c_void,
+ TagType: ::libc::c_int,
+ GetOpInfo: LLVMOpInfoCallback,
+ SymbolLookUp: LLVMSymbolLookupCallback,
+ ) -> LLVMDisasmContextRef;
+ pub fn LLVMCreateDisasmCPUFeatures(
+ Triple: *const ::libc::c_char,
+ CPU: *const ::libc::c_char,
+ Features: *const ::libc::c_char,
+ DisInfo: *mut ::libc::c_void,
+ TagType: ::libc::c_int,
+ GetOpInfo: LLVMOpInfoCallback,
+ SymbolLookUp: LLVMSymbolLookupCallback,
+ ) -> LLVMDisasmContextRef;
+ pub fn LLVMSetDisasmOptions(DC: LLVMDisasmContextRef, Options: u64) -> ::libc::c_int;
+ pub fn LLVMDisasmDispose(DC: LLVMDisasmContextRef);
+ pub fn LLVMDisasmInstruction(
+ DC: LLVMDisasmContextRef,
+ Bytes: *mut u8,
+ BytesSize: u64,
+ PC: u64,
+ OutString: *mut ::libc::c_char,
+ OutStringSize: ::libc::size_t,
+ ) -> ::libc::size_t;
+}
diff --git a/ext/llvm-sys.rs/src/error.rs b/ext/llvm-sys.rs/src/error.rs
new file mode 100644
index 0000000..eddfbfa
--- /dev/null
+++ b/ext/llvm-sys.rs/src/error.rs
@@ -0,0 +1,18 @@
+pub const LLVMErrorSuccess: ::libc::c_int = 0;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueError {}
+
+pub type LLVMErrorRef = *mut LLVMOpaqueError;
+
+pub type LLVMErrorTypeId = *const ::libc::c_void;
+
+extern "C" {
+ pub fn LLVMGetErrorTypeId(Err: LLVMErrorRef) -> LLVMErrorTypeId;
+ pub fn LLVMConsumeError(Err: LLVMErrorRef);
+ pub fn LLVMGetErrorMessage(Err: LLVMErrorRef) -> *mut ::libc::c_char;
+ pub fn LLVMDisposeErrorMessage(ErrMsg: *mut ::libc::c_char);
+ pub fn LLVMGetStringErrorTypeId() -> LLVMErrorTypeId;
+ /// Create a StringError.
+ pub fn LLVMCreateStringError(ErrMst: *const ::libc::c_char) -> LLVMErrorRef;
+}
diff --git a/ext/llvm-sys.rs/src/error_handling.rs b/ext/llvm-sys.rs/src/error_handling.rs
new file mode 100644
index 0000000..c60a831
--- /dev/null
+++ b/ext/llvm-sys.rs/src/error_handling.rs
@@ -0,0 +1,17 @@
+pub type LLVMFatalErrorHandler = Option<extern "C" fn(Reason: *const ::libc::c_char)>;
+
+extern "C" {
+ /// Install a fatal error handler.
+ ///
+ /// LLVM will call `exit(1)` if it detects a fatal error. A callback
+ /// registered with this function will be invoked before the program is
+ /// exited.
+ pub fn LLVMInstallFatalErrorHandler(Handler: LLVMFatalErrorHandler);
+ /// Reset fatal error handling to the default.
+ pub fn LLVMResetFatalErrorHandler();
+ /// Enable LLVM's build-in stack trace code.
+ ///
+ /// This intercepts the OS's crash signals and prints which component
+ /// of LLVM you were in at the time of the crash.
+ pub fn LLVMEnablePrettyStackTrace();
+}
diff --git a/ext/llvm-sys.rs/src/execution_engine.rs b/ext/llvm-sys.rs/src/execution_engine.rs
new file mode 100644
index 0000000..8aa440b
--- /dev/null
+++ b/ext/llvm-sys.rs/src/execution_engine.rs
@@ -0,0 +1,212 @@
+//! Runtime code generation and execution.
+
+use super::prelude::*;
+use super::target::LLVMTargetDataRef;
+use super::target_machine::{LLVMCodeModel, LLVMTargetMachineRef};
+
+#[derive(Debug)]
+pub enum LLVMOpaqueGenericValue {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueExecutionEngine {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueMCJITMemoryManager {}
+
+pub type LLVMGenericValueRef = *mut LLVMOpaqueGenericValue;
+pub type LLVMExecutionEngineRef = *mut LLVMOpaqueExecutionEngine;
+pub type LLVMMCJITMemoryManagerRef = *mut LLVMOpaqueMCJITMemoryManager;
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+#[allow(non_snake_case)]
+pub struct LLVMMCJITCompilerOptions {
+ pub OptLevel: ::libc::c_uint,
+ pub CodeModel: LLVMCodeModel,
+ pub NoFramePointerElim: LLVMBool,
+ pub EnableFastISel: LLVMBool,
+ pub MCJMM: LLVMMCJITMemoryManagerRef,
+}
+
+pub type LLVMMemoryManagerAllocateCodeSectionCallback = extern "C" fn(
+ Opaque: *mut ::libc::c_void,
+ Size: ::libc::uintptr_t,
+ Alignment: ::libc::c_uint,
+ SectionID: ::libc::c_uint,
+ SectionName: *const ::libc::c_char,
+) -> *mut u8;
+pub type LLVMMemoryManagerAllocateDataSectionCallback = extern "C" fn(
+ Opaque: *mut ::libc::c_void,
+ Size: ::libc::uintptr_t,
+ Alignment: ::libc::c_uint,
+ SectionID: ::libc::c_uint,
+ SectionName: *const ::libc::c_char,
+ IsReadOnly: LLVMBool,
+) -> *mut u8;
+pub type LLVMMemoryManagerFinalizeMemoryCallback =
+ extern "C" fn(Opaque: *mut ::libc::c_void, ErrMsg: *mut *mut ::libc::c_char) -> LLVMBool;
+pub type LLVMMemoryManagerDestroyCallback = Option<extern "C" fn(Opaque: *mut ::libc::c_void)>;
+
+extern "C" {
+ pub fn LLVMLinkInMCJIT();
+ pub fn LLVMLinkInInterpreter();
+
+ // Operations on generic values
+ pub fn LLVMCreateGenericValueOfInt(
+ Ty: LLVMTypeRef,
+ N: ::libc::c_ulonglong,
+ IsSigned: LLVMBool,
+ ) -> LLVMGenericValueRef;
+ pub fn LLVMCreateGenericValueOfPointer(P: *mut ::libc::c_void) -> LLVMGenericValueRef;
+ pub fn LLVMCreateGenericValueOfFloat(
+ Ty: LLVMTypeRef,
+ N: ::libc::c_double,
+ ) -> LLVMGenericValueRef;
+ pub fn LLVMGenericValueIntWidth(GenValRef: LLVMGenericValueRef) -> ::libc::c_uint;
+ pub fn LLVMGenericValueToInt(
+ GenVal: LLVMGenericValueRef,
+ IsSigned: LLVMBool,
+ ) -> ::libc::c_ulonglong;
+ pub fn LLVMGenericValueToPointer(GenVal: LLVMGenericValueRef) -> *mut ::libc::c_void;
+ pub fn LLVMGenericValueToFloat(
+ TyRef: LLVMTypeRef,
+ GenVal: LLVMGenericValueRef,
+ ) -> ::libc::c_double;
+ pub fn LLVMDisposeGenericValue(GenVal: LLVMGenericValueRef);
+
+ // Operations on execution engines
+ pub fn LLVMCreateExecutionEngineForModule(
+ OutEE: *mut LLVMExecutionEngineRef,
+ M: LLVMModuleRef,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMCreateInterpreterForModule(
+ OutInterp: *mut LLVMExecutionEngineRef,
+ M: LLVMModuleRef,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMCreateJITCompilerForModule(
+ OutJIT: *mut LLVMExecutionEngineRef,
+ M: LLVMModuleRef,
+ OptLevel: ::libc::c_uint,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMInitializeMCJITCompilerOptions(
+ Options: *mut LLVMMCJITCompilerOptions,
+ SizeOfOptions: ::libc::size_t,
+ );
+
+ /// Create an MCJIT execution engine for a module, with the given options.
+ ///
+ /// It is
+ /// the responsibility of the caller to ensure that all fields in Options up to
+ /// the given SizeOfOptions are initialized. It is correct to pass a smaller
+ /// value of SizeOfOptions that omits some fields. The canonical way of using
+ /// this is:
+ ///
+ /// ```c++
+ /// LLVMMCJITCompilerOptions options;
+ /// LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
+ /// // ... fill in those options you care about
+ /// LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options),
+ /// &error);
+ /// ```
+ ///
+ /// Note that this is also correct, though possibly suboptimal:
+ ///
+ /// ```c++
+ /// LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
+ /// ```
+ ///
+ /// 0 is returned on success, or 1 on failure.
+ pub fn LLVMCreateMCJITCompilerForModule(
+ OutJIT: *mut LLVMExecutionEngineRef,
+ M: LLVMModuleRef,
+ Options: *mut LLVMMCJITCompilerOptions,
+ SizeOfOptions: ::libc::size_t,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+
+ pub fn LLVMDisposeExecutionEngine(EE: LLVMExecutionEngineRef);
+ pub fn LLVMRunStaticConstructors(EE: LLVMExecutionEngineRef);
+ pub fn LLVMRunStaticDestructors(EE: LLVMExecutionEngineRef);
+ pub fn LLVMRunFunctionAsMain(
+ EE: LLVMExecutionEngineRef,
+ F: LLVMValueRef,
+ ArgC: ::libc::c_uint,
+ ArgV: *const *const ::libc::c_char,
+ EnvP: *const *const ::libc::c_char,
+ ) -> ::libc::c_int;
+ pub fn LLVMRunFunction(
+ EE: LLVMExecutionEngineRef,
+ F: LLVMValueRef,
+ NumArgs: ::libc::c_uint,
+ Args: *mut LLVMGenericValueRef,
+ ) -> LLVMGenericValueRef;
+ pub fn LLVMFreeMachineCodeForFunction(EE: LLVMExecutionEngineRef, F: LLVMValueRef);
+ pub fn LLVMAddModule(EE: LLVMExecutionEngineRef, M: LLVMModuleRef);
+ pub fn LLVMRemoveModule(
+ EE: LLVMExecutionEngineRef,
+ M: LLVMModuleRef,
+ OutMod: *mut LLVMModuleRef,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMFindFunction(
+ EE: LLVMExecutionEngineRef,
+ Name: *const ::libc::c_char,
+ OutFn: *mut LLVMValueRef,
+ ) -> LLVMBool;
+ pub fn LLVMRecompileAndRelinkFunction(
+ EE: LLVMExecutionEngineRef,
+ Fn: LLVMValueRef,
+ ) -> *mut ::libc::c_void;
+ pub fn LLVMGetExecutionEngineTargetData(EE: LLVMExecutionEngineRef) -> LLVMTargetDataRef;
+ pub fn LLVMGetExecutionEngineTargetMachine(EE: LLVMExecutionEngineRef) -> LLVMTargetMachineRef;
+ pub fn LLVMAddGlobalMapping(
+ EE: LLVMExecutionEngineRef,
+ Global: LLVMValueRef,
+ Addr: *mut ::libc::c_void,
+ );
+ pub fn LLVMGetPointerToGlobal(
+ EE: LLVMExecutionEngineRef,
+ Global: LLVMValueRef,
+ ) -> *mut ::libc::c_void;
+ pub fn LLVMGetGlobalValueAddress(
+ EE: LLVMExecutionEngineRef,
+ Name: *const ::libc::c_char,
+ ) -> u64;
+ pub fn LLVMGetFunctionAddress(EE: LLVMExecutionEngineRef, Name: *const ::libc::c_char) -> u64;
+
+ pub fn LLVMExecutionEngineGetErrMsg(
+ EE: LLVMExecutionEngineRef,
+ OutError: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+
+ // Operations on memory managers
+ // Create a simple custom MCJIT memory manager.
+ //
+ // This memory manager can intercept allocations in a module-oblivious way. It will
+ // return NULL if any of the passed functions are NULL.
+ //
+ // `AllocateCodeSection` and `AllocateDataSection` are called to allocate blocks
+ // of memory for executable code and data, respectively. `FinalizeMemory` is called
+ // to set page permissions and flush caches, returning 0 on success and 1 on error.
+ //
+ // `Opaque` will be passed to the callbacks.
+ pub fn LLVMCreateSimpleMCJITMemoryManager(
+ Opaque: *mut ::libc::c_void,
+ AllocateCodeSection: LLVMMemoryManagerAllocateCodeSectionCallback,
+ AllocateDataSection: LLVMMemoryManagerAllocateDataSectionCallback,
+ FinalizeMemory: LLVMMemoryManagerFinalizeMemoryCallback,
+ Destroy: LLVMMemoryManagerDestroyCallback,
+ ) -> LLVMMCJITMemoryManagerRef;
+
+ pub fn LLVMDisposeMCJITMemoryManager(MM: LLVMMCJITMemoryManagerRef);
+
+ // JIT event listener functions
+ pub fn LLVMCreateGDBRegistrationListener() -> LLVMJITEventListenerRef;
+ pub fn LLVMCreateIntelJITEventListener() -> LLVMJITEventListenerRef;
+ pub fn LLVMCreateOProfileJITEventListener() -> LLVMJITEventListenerRef;
+ pub fn LLVMCreatePerfJITEventListener() -> LLVMJITEventListenerRef;
+
+}
diff --git a/ext/llvm-sys.rs/src/initialization.rs b/ext/llvm-sys.rs/src/initialization.rs
new file mode 100644
index 0000000..9e811b6
--- /dev/null
+++ b/ext/llvm-sys.rs/src/initialization.rs
@@ -0,0 +1,19 @@
+//! Initialization routines which must be called before using library features.
+
+use super::prelude::*;
+
+extern "C" {
+ pub fn LLVMInitializeCore(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeTransformUtils(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeScalarOpts(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeObjCARCOpts(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeVectorization(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeInstCombine(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeAggressiveInstCombiner(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeIPO(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeInstrumentation(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeAnalysis(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeIPA(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeCodeGen(R: LLVMPassRegistryRef);
+ pub fn LLVMInitializeTarget(R: LLVMPassRegistryRef);
+}
diff --git a/ext/llvm-sys.rs/src/ir_reader.rs b/ext/llvm-sys.rs/src/ir_reader.rs
new file mode 100644
index 0000000..e5c9f2b
--- /dev/null
+++ b/ext/llvm-sys.rs/src/ir_reader.rs
@@ -0,0 +1,16 @@
+//! The IR reader
+
+use super::prelude::*;
+
+extern "C" {
+ /// Read LLVM IR from a memory buffer and convert it to an in-memory Module.
+ ///
+ /// Returns 0 on success, and an optional human-readable description of any
+ /// errors that occurred.
+ pub fn LLVMParseIRInContext(
+ ContextRef: LLVMContextRef,
+ MemBuf: LLVMMemoryBufferRef,
+ OutM: *mut LLVMModuleRef,
+ OutMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/lib.rs b/ext/llvm-sys.rs/src/lib.rs
new file mode 100644
index 0000000..33315d8
--- /dev/null
+++ b/ext/llvm-sys.rs/src/lib.rs
@@ -0,0 +1,500 @@
+//! Bindings to LLVM's C API.
+//!
+//! Refer to the [LLVM documentation](http://llvm.org/docs/) for more
+//! information.
+
+#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+
+extern crate libc;
+
+use self::prelude::*;
+
+#[derive(Debug)]
+pub enum LLVMMemoryBuffer {}
+
+#[derive(Debug)]
+pub enum LLVMContext {}
+
+#[derive(Debug)]
+pub enum LLVMModule {}
+
+#[derive(Debug)]
+pub enum LLVMType {}
+
+#[derive(Debug)]
+pub enum LLVMValue {}
+
+#[derive(Debug)]
+pub enum LLVMBasicBlock {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueMetadata {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueNamedMDNode {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueValueMetadataEntry {}
+
+#[derive(Debug)]
+pub enum LLVMBuilder {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueDIBuilder {}
+
+#[derive(Debug)]
+pub enum LLVMModuleProvider {}
+
+#[derive(Debug)]
+pub enum LLVMPassManager {}
+
+#[derive(Debug)]
+pub enum LLVMPassRegistry {}
+
+#[derive(Debug)]
+pub enum LLVMUse {}
+
+#[derive(Debug)]
+pub enum LLVMDiagnosticInfo {}
+
+#[derive(Debug)]
+pub enum LLVMComdat {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueModuleFlagEntry {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueJITEventListener {}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueAttributeRef {}
+
+/// Core types used throughout LLVM.
+///
+/// In most cases you will want to `use llvm::prelude::*`.
+pub mod prelude {
+ pub type LLVMBool = ::libc::c_int;
+ pub type LLVMMemoryBufferRef = *mut super::LLVMMemoryBuffer;
+ pub type LLVMContextRef = *mut super::LLVMContext;
+ pub type LLVMModuleRef = *mut super::LLVMModule;
+ pub type LLVMTypeRef = *mut super::LLVMType;
+ pub type LLVMValueRef = *mut super::LLVMValue;
+ pub type LLVMBasicBlockRef = *mut super::LLVMBasicBlock;
+ pub type LLVMMetadataRef = *mut super::LLVMOpaqueMetadata;
+ pub type LLVMNamedMDNodeRef = *mut super::LLVMOpaqueNamedMDNode;
+ pub type LLVMValueMetadataEntry = *mut super::LLVMOpaqueValueMetadataEntry;
+ pub type LLVMBuilderRef = *mut super::LLVMBuilder;
+ pub type LLVMDIBuilderRef = *mut super::LLVMOpaqueDIBuilder;
+ pub type LLVMModuleProviderRef = *mut super::LLVMModuleProvider;
+ pub type LLVMPassManagerRef = *mut super::LLVMPassManager;
+ pub type LLVMPassRegistryRef = *mut super::LLVMPassRegistry;
+ pub type LLVMUseRef = *mut super::LLVMUse;
+ pub type LLVMDiagnosticInfoRef = *mut super::LLVMDiagnosticInfo;
+ pub type LLVMComdatRef = *mut super::LLVMComdat;
+ pub type LLVMModuleFlagEntry = *mut super::LLVMOpaqueModuleFlagEntry;
+ pub type LLVMJITEventListenerRef = *mut super::LLVMOpaqueJITEventListener;
+ pub type LLVMAttributeRef = *mut super::LLVMOpaqueAttributeRef;
+}
+
+pub mod analysis;
+pub mod bit_reader;
+pub mod bit_writer;
+pub mod blake3;
+pub mod comdat;
+pub mod core;
+pub mod debuginfo;
+pub mod disassembler;
+pub mod error;
+pub mod error_handling;
+pub mod execution_engine;
+pub mod initialization;
+pub mod ir_reader;
+pub mod linker;
+pub mod lto;
+pub mod object;
+pub mod orc2;
+pub mod remarks;
+pub mod support;
+pub mod target;
+pub mod target_machine;
+
+pub mod transforms {
+ pub mod aggressive_instcombine;
+ pub mod instcombine;
+ pub mod ipo;
+ pub mod pass_builder;
+ pub mod pass_manager_builder;
+ pub mod scalar;
+ pub mod util;
+ pub mod vectorize;
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMOpcode {
+ LLVMRet = 1,
+ LLVMBr = 2,
+ LLVMSwitch = 3,
+ LLVMIndirectBr = 4,
+ LLVMInvoke = 5,
+ LLVMUnreachable = 7,
+ LLVMCallBr = 67,
+ LLVMFNeg = 66,
+ LLVMAdd = 8,
+ LLVMFAdd = 9,
+ LLVMSub = 10,
+ LLVMFSub = 11,
+ LLVMMul = 12,
+ LLVMFMul = 13,
+ LLVMUDiv = 14,
+ LLVMSDiv = 15,
+ LLVMFDiv = 16,
+ LLVMURem = 17,
+ LLVMSRem = 18,
+ LLVMFRem = 19,
+ LLVMShl = 20,
+ LLVMLShr = 21,
+ LLVMAShr = 22,
+ LLVMAnd = 23,
+ LLVMOr = 24,
+ LLVMXor = 25,
+ LLVMAlloca = 26,
+ LLVMLoad = 27,
+ LLVMStore = 28,
+ LLVMGetElementPtr = 29,
+ LLVMTrunc = 30,
+ LLVMZExt = 31,
+ LLVMSExt = 32,
+ LLVMFPToUI = 33,
+ LLVMFPToSI = 34,
+ LLVMUIToFP = 35,
+ LLVMSIToFP = 36,
+ LLVMFPTrunc = 37,
+ LLVMFPExt = 38,
+ LLVMPtrToInt = 39,
+ LLVMIntToPtr = 40,
+ LLVMBitCast = 41,
+ LLVMAddrSpaceCast = 60,
+ LLVMICmp = 42,
+ LLVMFCmp = 43,
+ LLVMPHI = 44,
+ LLVMCall = 45,
+ LLVMSelect = 46,
+ LLVMUserOp1 = 47,
+ LLVMUserOp2 = 48,
+ LLVMVAArg = 49,
+ LLVMExtractElement = 50,
+ LLVMInsertElement = 51,
+ LLVMShuffleVector = 52,
+ LLVMExtractValue = 53,
+ LLVMInsertValue = 54,
+ LLVMFreeze = 68,
+ LLVMFence = 55,
+ LLVMAtomicCmpXchg = 56,
+ LLVMAtomicRMW = 57,
+ LLVMResume = 58,
+ LLVMLandingPad = 59,
+ LLVMCleanupRet = 61,
+ LLVMCatchRet = 62,
+ LLVMCatchPad = 63,
+ LLVMCleanupPad = 64,
+ LLVMCatchSwitch = 65,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMTypeKind {
+ LLVMVoidTypeKind = 0,
+ LLVMHalfTypeKind = 1,
+ LLVMFloatTypeKind = 2,
+ LLVMDoubleTypeKind = 3,
+ LLVMX86_FP80TypeKind = 4,
+ LLVMFP128TypeKind = 5,
+ LLVMPPC_FP128TypeKind = 6,
+ LLVMLabelTypeKind = 7,
+ LLVMIntegerTypeKind = 8,
+ LLVMFunctionTypeKind = 9,
+ LLVMStructTypeKind = 10,
+ LLVMArrayTypeKind = 11,
+ LLVMPointerTypeKind = 12,
+ LLVMVectorTypeKind = 13,
+ LLVMMetadataTypeKind = 14,
+ LLVMX86_MMXTypeKind = 15,
+ LLVMTokenTypeKind = 16,
+ LLVMScalableVectorTypeKind = 17,
+ LLVMBFloatTypeKind = 18,
+ LLVMX86_AMXTypeKind = 19,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMLinkage {
+ LLVMExternalLinkage = 0,
+ LLVMAvailableExternallyLinkage = 1,
+ LLVMLinkOnceAnyLinkage = 2,
+ LLVMLinkOnceODRLinkage = 3,
+ LLVMLinkOnceODRAutoHideLinkage = 4,
+ LLVMWeakAnyLinkage = 5,
+ LLVMWeakODRLinkage = 6,
+ LLVMAppendingLinkage = 7,
+ LLVMInternalLinkage = 8,
+ LLVMPrivateLinkage = 9,
+ LLVMDLLImportLinkage = 10,
+ LLVMDLLExportLinkage = 11,
+ LLVMExternalWeakLinkage = 12,
+ LLVMGhostLinkage = 13,
+ LLVMCommonLinkage = 14,
+ LLVMLinkerPrivateLinkage = 15,
+ LLVMLinkerPrivateWeakLinkage = 16,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMVisibility {
+ LLVMDefaultVisibility = 0,
+ LLVMHiddenVisibility = 1,
+ LLVMProtectedVisibility = 2,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMUnnamedAddr {
+ /// Address of the GV is significant.
+ LLVMNoUnnamedAddr,
+ /// Address of the GV is locally insignificant.
+ LLVMLocalUnnamedAddr,
+ /// Address of the GV is globally insignificant.
+ LLVMGlobalUnnamedAddr,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMDLLStorageClass {
+ LLVMDefaultStorageClass = 0,
+ LLVMDLLImportStorageClass = 1,
+ LLVMDLLExportStorageClass = 2,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMCallConv {
+ LLVMCCallConv = 0,
+ LLVMFastCallConv = 8,
+ LLVMColdCallConv = 9,
+ LLVMGHCCallConv = 10,
+ LLVMHiPECallConv = 11,
+ LLVMWebKitJSCallConv = 12,
+ LLVMAnyRegCallConv = 13,
+ LLVMPreserveMostCallConv = 14,
+ LLVMPreserveAllCallConv = 15,
+ LLVMSwiftCallConv = 16,
+ LLVMCXXFASTTLSCallConv = 17,
+ LLVMX86StdcallCallConv = 64,
+ LLVMX86FastcallCallConv = 65,
+ LLVMARMAPCSCallConv = 66,
+ LLVMARMAAPCSCallConv = 67,
+ LLVMARMAAPCSVFPCallConv = 68,
+ LLVMMSP430INTRCallConv = 69,
+ LLVMX86ThisCallCallConv = 70,
+ LLVMPTXKernelCallConv = 71,
+ LLVMPTXDeviceCallConv = 72,
+ LLVMSPIRFUNCCallConv = 75,
+ LLVMSPIRKERNELCallConv = 76,
+ LLVMIntelOCLBICallConv = 77,
+ LLVMX8664SysVCallConv = 78,
+ LLVMWin64CallConv = 79,
+ LLVMX86VectorCallCallConv = 80,
+ LLVMHHVMCallConv = 81,
+ LLVMHHVMCCallConv = 82,
+ LLVMX86INTRCallConv = 83,
+ LLVMAVRINTRCallConv = 84,
+ LLVMAVRSIGNALCallConv = 85,
+ LLVMAVRBUILTINCallConv = 86,
+ LLVMAMDGPUVSCallConv = 87,
+ LLVMAMDGPUGSCallConv = 88,
+ LLVMAMDGPUPSCallConv = 89,
+ LLVMAMDGPUCSCallConv = 90,
+ LLVMAMDGPUKERNELCallConv = 91,
+ LLVMX86RegCallCallConv = 92,
+ LLVMAMDGPUHSCallConv = 93,
+ LLVMMSP430BUILTINCallConv = 94,
+ LLVMAMDGPULSCallConv = 95,
+ LLVMAMDGPUESCallConv = 96,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMValueKind {
+ LLVMArgumentValueKind,
+ LLVMBasicBlockValueKind,
+ LLVMMemoryUseValueKind,
+ LLVMMemoryDefValueKind,
+ LLVMMemoryPhiValueKind,
+
+ LLVMFunctionValueKind,
+ LLVMGlobalAliasValueKind,
+ LLVMGlobalIFuncValueKind,
+ LLVMGlobalVariableValueKind,
+ LLVMBlockAddressValueKind,
+ LLVMConstantExprValueKind,
+ LLVMConstantArrayValueKind,
+ LLVMConstantStructValueKind,
+ LLVMConstantVectorValueKind,
+ LLVMUndefValueValueKind,
+ LLVMConstantAggregateZeroValueKind,
+ LLVMConstantDataArrayValueKind,
+ LLVMConstantDataVectorValueKind,
+ LLVMConstantIntValueKind,
+ LLVMConstantFPValueKind,
+ LLVMConstantPointerNullValueKind,
+ LLVMConstantTokenNoneValueKind,
+
+ LLVMMetadataAsValueValueKind,
+ LLVMInlineAsmValueKind,
+
+ LLVMInstructionValueKind,
+ LLVMPoisonValueKind,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMIntPredicate {
+ LLVMIntEQ = 32,
+ LLVMIntNE = 33,
+ LLVMIntUGT = 34,
+ LLVMIntUGE = 35,
+ LLVMIntULT = 36,
+ LLVMIntULE = 37,
+ LLVMIntSGT = 38,
+ LLVMIntSGE = 39,
+ LLVMIntSLT = 40,
+ LLVMIntSLE = 41,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMRealPredicate {
+ LLVMRealPredicateFalse = 0,
+ LLVMRealOEQ = 1,
+ LLVMRealOGT = 2,
+ LLVMRealOGE = 3,
+ LLVMRealOLT = 4,
+ LLVMRealOLE = 5,
+ LLVMRealONE = 6,
+ LLVMRealORD = 7,
+ LLVMRealUNO = 8,
+ LLVMRealUEQ = 9,
+ LLVMRealUGT = 10,
+ LLVMRealUGE = 11,
+ LLVMRealULT = 12,
+ LLVMRealULE = 13,
+ LLVMRealUNE = 14,
+ LLVMRealPredicateTrue = 15,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMLandingPadClauseTy {
+ LLVMLandingPadCatch = 0,
+ LLVMLandingPadFilter = 1,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMThreadLocalMode {
+ LLVMNotThreadLocal = 0,
+ LLVMGeneralDynamicTLSModel = 1,
+ LLVMLocalDynamicTLSModel = 2,
+ LLVMInitialExecTLSModel = 3,
+ LLVMLocalExecTLSModel = 4,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMAtomicOrdering {
+ LLVMAtomicOrderingNotAtomic = 0,
+ LLVMAtomicOrderingUnordered = 1,
+ LLVMAtomicOrderingMonotonic = 2,
+ LLVMAtomicOrderingAcquire = 4,
+ LLVMAtomicOrderingRelease = 5,
+ LLVMAtomicOrderingAcquireRelease = 6,
+ LLVMAtomicOrderingSequentiallyConsistent = 7,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMAtomicRMWBinOp {
+ LLVMAtomicRMWBinOpXchg = 0,
+ LLVMAtomicRMWBinOpAdd = 1,
+ LLVMAtomicRMWBinOpSub = 2,
+ LLVMAtomicRMWBinOpAnd = 3,
+ LLVMAtomicRMWBinOpNand = 4,
+ LLVMAtomicRMWBinOpOr = 5,
+ LLVMAtomicRMWBinOpXor = 6,
+ LLVMAtomicRMWBinOpMax = 7,
+ LLVMAtomicRMWBinOpMin = 8,
+ LLVMAtomicRMWBinOpUMax = 9,
+ LLVMAtomicRMWBinOpUMin = 10,
+ LLVMAtomicRMWBinOpFAdd = 11,
+ LLVMAtomicRMWBinOpFSub = 12,
+ LLVMAtomicRMWBinOpFMax = 13,
+ LLVMAtomicRMWBinOpFMin = 14,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMDiagnosticSeverity {
+ LLVMDSError = 0,
+ LLVMDSWarning = 1,
+ LLVMDSRemark = 2,
+ LLVMDSNote = 3,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMInlineAsmDialect {
+ LLVMInlineAsmDialectATT,
+ LLVMInlineAsmDialectIntel,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMModuleFlagBehavior {
+ /// Emits an error if two values disagree, otherwise the resulting value is that of the operands.
+ LLVMModuleFlagBehaviorError,
+ /// Emits a warning if two values disagree. The result value will be the operand for the flag from the first module being linked.
+ LLVMModuleFlagBehaviorWarning,
+ /// Adds a requirement that another module flag be present and have a specified value after linking is performed. The value must be a metadata pair, where the first element of the pair is the ID of the module flag to be restricted, and the second element of the pair is the value the module flag should be restricted to. This behavior can be used to restrict the allowable results (via triggering of an error) of linking IDs with the **Override** behavior.
+ LLVMModuleFlagBehaviorRequire,
+ /// Uses the specified value, regardless of the behavior or value of the other module. If both modules specify **Override**, but the values differ, an error will be emitted.
+ LLVMModuleFlagBehaviorOverride,
+ /// Appends the two values, which are required to be metadata nodes.
+ LLVMModuleFlagBehaviorAppend,
+ /// Appends the two values, which are required to be metadata nodes. However, duplicate entries in the second list are dropped during the append operation.
+ LLVMModuleFlagBehaviorAppendUnique,
+}
+
+pub const LLVMAttributeReturnIndex: ::libc::c_uint = 0;
+pub const LLVMAttributeFunctionIndex: ::libc::c_uint = !0; // -1
+/// Either LLVMAttributeReturnIndex, LLVMAttributeFunctionIndex, or a parameter
+/// number from 1 to N.
+pub type LLVMAttributeIndex = ::libc::c_uint;
+
+pub type LLVMDiagnosticHandler =
+ Option<extern "C" fn(arg1: LLVMDiagnosticInfoRef, arg2: *mut ::libc::c_void)>;
+pub type LLVMYieldCallback = Option<extern "C" fn(arg1: LLVMContextRef, arg2: *mut ::libc::c_void)>;
+
+#[cfg(all(not(doc), not(feature = "no-llvm-linking"), LLVM_SYS_NOT_FOUND))]
+std::compile_error!(concat!(
+ "No suitable version of LLVM was found system-wide or pointed
+ to by LLVM_SYS_",
+ env!("CARGO_PKG_VERSION_MAJOR"),
+ "_PREFIX.
+
+ Consider using `llvmenv` to compile an appropriate copy of LLVM, and
+ refer to the llvm-sys documentation for more information.
+
+ llvm-sys: https://crates.io/crates/llvm-sys
+ llvmenv: https://crates.io/crates/llvmenv"
+));
diff --git a/ext/llvm-sys.rs/src/linker.rs b/ext/llvm-sys.rs/src/linker.rs
new file mode 100644
index 0000000..60e79db
--- /dev/null
+++ b/ext/llvm-sys.rs/src/linker.rs
@@ -0,0 +1,19 @@
+//! The module/file/archive linker
+
+use super::prelude::*;
+
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMLinkerMode {
+ LLVMLinkerDestroySource = 0,
+ #[deprecated(since = "3.7.0", note = "LLVMLinkerPreserveSource has no effect")]
+ LLVMLinkerPreserveSource_Removed = 1,
+}
+
+extern "C" {
+ /// Link the source module into the destination module.
+ ///
+ /// Destroys the source module, returns true on error. Use the diagnostic
+ /// handler to get any diagnostic message.
+ pub fn LLVMLinkModules2(Dest: LLVMModuleRef, Src: LLVMModuleRef) -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/lto.rs b/ext/llvm-sys.rs/src/lto.rs
new file mode 100644
index 0000000..7efddd9
--- /dev/null
+++ b/ext/llvm-sys.rs/src/lto.rs
@@ -0,0 +1,442 @@
+//! Abstract link time optimization.
+//!
+//! ## ThinLTO
+//!
+//! ThinLTO is designed to do LTO while requiring fewer resources than regular
+//! LTO. It can run much faster and in less memory (comparable to linking
+//! without LTO) than regular LTO, with essentially no loss in optimization.
+
+#![allow(non_camel_case_types)]
+
+pub type lto_bool_t = u8;
+
+// This looks kind of like bitflags but I'm not sure.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum lto_symbol_attributes {
+ LTO_SYMBOL_ALIGNMENT_MASK = 31,
+ LTO_SYMBOL_PERMISSIONS_MASK = 224,
+ LTO_SYMBOL_PERMISSIONS_CODE = 160,
+ LTO_SYMBOL_PERMISSIONS_DATA = 192,
+ LTO_SYMBOL_PERMISSIONS_RODATA = 128,
+ LTO_SYMBOL_DEFINITION_MASK = 1792,
+ LTO_SYMBOL_DEFINITION_REGULAR = 256,
+ LTO_SYMBOL_DEFINITION_TENTATIVE = 512,
+ LTO_SYMBOL_DEFINITION_WEAK = 768,
+ LTO_SYMBOL_DEFINITION_UNDEFINED = 1024,
+ LTO_SYMBOL_DEFINITION_WEAKUNDEF = 1280,
+ LTO_SYMBOL_SCOPE_MASK = 14336,
+ LTO_SYMBOL_SCOPE_INTERNAL = 2048,
+ LTO_SYMBOL_SCOPE_HIDDEN = 0x1000,
+ LTO_SYMBOL_SCOPE_PROTECTED = 0x2000,
+ LTO_SYMBOL_SCOPE_DEFAULT = 0x1800,
+ LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x2800,
+ /// Added in LLVM 3.7.
+ LTO_SYMBOL_COMDAT = 0x4000,
+ /// Added in LLVM 3.7.
+ LTO_SYMBOL_ALIAS = 0x8000,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum lto_debug_model {
+ LTO_DEBUG_MODEL_NONE = 0,
+ LTO_DEBUG_MODEL_DWARF = 1,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum lto_codegen_model {
+ LTO_CODEGEN_PIC_MODEL_STATIC = 0,
+ LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
+ LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
+ LTO_CODEGEN_PIC_MODEL_DEFAULT = 3,
+}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueLTOModule {}
+
+pub type lto_module_t = *mut LLVMOpaqueLTOModule;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueLTOCodeGenerator {}
+
+pub type lto_code_gen_t = *mut LLVMOpaqueLTOCodeGenerator;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueThinLTOCodeGenerator {}
+
+pub type thinlto_code_gen_t = *mut LLVMOpaqueThinLTOCodeGenerator;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueLTOInput {}
+
+pub type lto_input_t = *mut LLVMOpaqueLTOInput;
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum lto_codegen_diagnostic_severity_t {
+ LTO_DS_ERROR = 0,
+ LTO_DS_WARNING = 1,
+ LTO_DS_REMARK = 3,
+ LTO_DS_NOTE = 2,
+}
+
+pub type lto_diagnostic_handler_t = Option<
+ extern "C" fn(
+ severity: lto_codegen_diagnostic_severity_t,
+ diag: *const ::libc::c_char,
+ ctxt: *mut ::libc::c_void,
+ ),
+>;
+
+extern "C" {
+ pub fn lto_get_version() -> *const ::libc::c_char;
+ pub fn lto_get_error_message() -> *const ::libc::c_char;
+ pub fn lto_module_is_object_file(path: *const ::libc::c_char) -> lto_bool_t;
+ pub fn lto_module_is_object_file_for_target(
+ path: *const ::libc::c_char,
+ target_triple_prefix: *const ::libc::c_char,
+ ) -> lto_bool_t;
+ /// Return true if `Buffer` contains a bitcode file with ObjC code
+ /// (category or class) in it.
+ pub fn lto_module_has_objc_category(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ ) -> lto_bool_t;
+ /// Checks if a buffer is a loadable object file.
+ pub fn lto_module_is_object_file_in_memory(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ ) -> lto_bool_t;
+ pub fn lto_module_is_object_file_in_memory_for_target(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ target_triple_prefix: *const ::libc::c_char,
+ ) -> lto_bool_t;
+ pub fn lto_module_create(path: *const ::libc::c_char) -> lto_module_t;
+ pub fn lto_module_create_from_memory(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ ) -> lto_module_t;
+ pub fn lto_module_create_from_memory_with_path(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ path: *const ::libc::c_char,
+ ) -> lto_module_t;
+ pub fn lto_module_create_in_local_context(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ path: *const ::libc::c_char,
+ ) -> lto_module_t;
+ pub fn lto_module_create_in_codegen_context(
+ mem: *const ::libc::c_void,
+ length: ::libc::size_t,
+ path: *const ::libc::c_char,
+ cg: lto_code_gen_t,
+ ) -> lto_module_t;
+ pub fn lto_module_create_from_fd(
+ fd: ::libc::c_int,
+ path: *const ::libc::c_char,
+ file_size: ::libc::size_t,
+ ) -> lto_module_t;
+ pub fn lto_module_create_from_fd_at_offset(
+ fd: ::libc::c_int,
+ path: *const ::libc::c_char,
+ file_size: ::libc::size_t,
+ map_size: ::libc::size_t,
+ offset: ::libc::off_t,
+ ) -> lto_module_t;
+ pub fn lto_module_dispose(_mod: lto_module_t);
+ pub fn lto_module_get_target_triple(_mod: lto_module_t) -> *const ::libc::c_char;
+ pub fn lto_module_set_target_triple(_mod: lto_module_t, triple: *const ::libc::c_char);
+ pub fn lto_module_get_num_symbols(_mod: lto_module_t) -> ::libc::c_uint;
+ pub fn lto_module_get_symbol_name(
+ _mod: lto_module_t,
+ index: ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ pub fn lto_module_get_symbol_attribute(
+ _mod: lto_module_t,
+ index: ::libc::c_uint,
+ ) -> lto_symbol_attributes;
+ /// Returns the module's linker options.
+ ///
+ /// The linker options may consist of multiple flags. It is the linker's
+ /// responsibility to split the flags using a platform-specific mechanism.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_module_get_linkeropts(_mod: lto_module_t) -> *const ::libc::c_char;
+ pub fn lto_module_get_macho_cputype(
+ _mod: lto_module_t,
+ out_cputype: *mut ::libc::c_uint,
+ out_cpusubtype: *mut ::libc::c_uint,
+ ) -> lto_bool_t;
+ /// Return true if the module has either the `@llvm.global_ctors` or the `@llvm.global_dtors`
+ /// symbol.
+ ///
+ /// Added in API version 29 (LLVM 14).
+ pub fn lto_module_has_ctor_dtor(mod_: lto_module_t) -> lto_bool_t;
+ pub fn lto_codegen_set_diagnostic_handler(
+ arg1: lto_code_gen_t,
+ arg2: lto_diagnostic_handler_t,
+ arg3: *mut ::libc::c_void,
+ );
+ pub fn lto_codegen_create() -> lto_code_gen_t;
+ pub fn lto_codegen_create_in_local_context() -> lto_code_gen_t;
+ pub fn lto_codegen_dispose(arg1: lto_code_gen_t);
+ pub fn lto_codegen_add_module(cg: lto_code_gen_t, _mod: lto_module_t) -> lto_bool_t;
+ /// Sets the object module for code gneeration. This will transfer ownership
+ /// of the module to the code generator.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_codegen_set_module(cg: lto_code_gen_t, _mod: lto_module_t);
+ pub fn lto_codegen_set_debug_model(cg: lto_code_gen_t, arg1: lto_debug_model) -> lto_bool_t;
+ pub fn lto_codegen_set_pic_model(cg: lto_code_gen_t, arg1: lto_codegen_model) -> lto_bool_t;
+ pub fn lto_codegen_set_cpu(cg: lto_code_gen_t, cpu: *const ::libc::c_char);
+ pub fn lto_codegen_set_assembler_path(cg: lto_code_gen_t, path: *const ::libc::c_char);
+ pub fn lto_codegen_set_assembler_args(
+ cg: lto_code_gen_t,
+ args: *mut *const ::libc::c_char,
+ nargs: ::libc::c_int,
+ );
+ pub fn lto_codegen_add_must_preserve_symbol(cg: lto_code_gen_t, symbol: *const ::libc::c_char);
+ pub fn lto_codegen_write_merged_modules(
+ cg: lto_code_gen_t,
+ path: *const ::libc::c_char,
+ ) -> lto_bool_t;
+ pub fn lto_codegen_compile(
+ cg: lto_code_gen_t,
+ length: *mut ::libc::size_t,
+ ) -> *const ::libc::c_void;
+ pub fn lto_codegen_compile_to_file(
+ cg: lto_code_gen_t,
+ name: *mut *const ::libc::c_char,
+ ) -> lto_bool_t;
+ /// Runs optimization for the merged module.
+ ///
+ /// Returns true on error.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_codegen_optimize(cg: lto_code_gen_t) -> lto_bool_t;
+ /// Generates code for the optimized merged module into one native object file.
+ ///
+ /// Does not run IR optimizations on the merged module.
+ ///
+ /// Returns a pointer to the generated mach-o/ELF buffer with length
+ /// set to the buffer size. This buffer is owned by `cg` and will be
+ /// freed when `lto_codegen_dispose` is called or `lto_codegen_compile_optimized`
+ /// is called again. Returns null on failure.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_codegen_compile_optimized(
+ cg: lto_code_gen_t,
+ length: *mut ::libc::size_t,
+ ) -> *mut ::libc::c_void;
+ /// Returns the runtime API version.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_api_version() -> ::libc::c_uint;
+ pub fn lto_set_debug_options(options: *mut *const ::libc::c_char, number: ::libc::c_int);
+ pub fn lto_codegen_debug_options(cg: lto_code_gen_t, arg1: *const ::libc::c_char);
+ pub fn lto_codegen_debug_options_array(
+ cg: lto_code_gen_t,
+ arg2: *const *const ::libc::c_char,
+ number: ::libc::c_int,
+ );
+ pub fn lto_initialize_disassembler();
+ /// Sets if we should run the internalize pass during optimization and code generation.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_codegen_set_should_internalize(cg: lto_code_gen_t, ShouldInternalize: lto_bool_t);
+ /// Set whether to embed uselists in bitcode.
+ ///
+ /// Sets whether `lto_codegen_write_merged_modules` should embed uselists in
+ /// output bitcode. This should be turned on for all -save-temps output.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn lto_codegen_set_should_embed_uselists(
+ cg: lto_code_gen_t,
+ ShouldEmbedUselists: lto_bool_t,
+ );
+}
+
+/// Type to wrap a single object returned by ThinLTO.
+#[repr(C)]
+#[derive(Debug)]
+#[allow(non_snake_case)]
+pub struct LTOObjectBuffer {
+ Buffer: *const ::libc::c_char,
+ Size: ::libc::size_t,
+}
+
+extern "C" {
+ /// Instantiates a ThinLTO code generator.
+ ///
+ /// Returns null on error (check `lto_get_error_message` for details).
+ ///
+ /// The code generator should not be reused.
+ pub fn thinlto_create_codegen() -> thinlto_code_gen_t;
+ /// Frees a code generator.
+ pub fn thinlto_codegen_dispose(cg: thinlto_code_gen_t);
+ /// Add a module to a code generator.
+ ///
+ /// Identifier must be unique among all the modules in the code generator.
+ /// The data buffer remains owned by the client, and must live at least
+ /// as long as the code generator.
+ ///
+ /// Returns null on failure.
+ pub fn thinlto_codegen_add_module(
+ cg: thinlto_code_gen_t,
+ identifier: *const ::libc::c_char,
+ data: *const ::libc::c_char,
+ length: ::libc::c_int,
+ );
+ /// Optimize and codegen all modules attached to the code generator.
+ ///
+ /// Resulting objects are accessible with `thinlto_module_get_object`.
+ pub fn thinlto_codegen_process(cg: thinlto_code_gen_t);
+ /// Return the number of object files produced by the code generator.
+ ///
+ /// This usually matches the number of input files, but is not guaranteed
+ /// to.
+ pub fn thinlto_module_get_num_objects(cg: thinlto_code_gen_t) -> ::libc::c_int;
+ /// Return a reference to the `index`th object file produced by the
+ /// code generator.
+ pub fn thinlto_module_get_object(
+ cg: thinlto_code_gen_t,
+ index: ::libc::c_uint,
+ ) -> LTOObjectBuffer;
+ /// Return the number of object files produced by the code generator.
+ ///
+ /// Usually the same as the number of input files, but not guaranteed.
+ pub fn thinlto_module_get_num_object_files(cg: thinlto_code_gen_t) -> ::libc::c_uint;
+ /// Return the path to the ith output object file.
+ ///
+ /// Use `thinlto_module_get_num_object_files` to get the number of available objects.
+ pub fn thinlto_module_get_object_file(
+ cg: thinlto_code_gen_t,
+ index: ::libc::c_uint,
+ ) -> *const ::libc::c_char;
+ /// Set which PIC code model to generate.
+ ///
+ /// Returns true on error.
+ pub fn thinlto_codegen_set_pic_model(
+ cg: thinlto_code_gen_t,
+ model: lto_codegen_model,
+ ) -> lto_bool_t;
+
+ // ThinLTO cache control.
+ // Set the path to a directory to use as cache for increment build.
+ //
+ // Setting this activates caching.
+ pub fn thinlto_codegen_set_cache_dir(cg: thinlto_code_gen_t, cache_dir: *const ::libc::c_char);
+ /// Set the cache pruning interval, in seconds.
+ ///
+ /// A negative value disables pruning, and 0 will force pruning to occur.
+ pub fn thinlto_codegen_set_cache_pruning_interval(
+ cg: thinlto_code_gen_t,
+ interval: ::libc::c_int,
+ );
+ /// Set the maximum cache size to persist across builds.
+ ///
+ /// This is expressed as a percentage of available disk space. 100 means no limit,
+ /// and 50 means no more than half of the available disk space. 0 is ignored, and
+ /// values over 100 will be reduced to 100.
+ pub fn thinlto_codegen_set_final_cache_size_relative_to_available_space(
+ cg: thinlto_code_gen_t,
+ percentage: ::libc::c_uint,
+ );
+ /// Set the expiration (in seconds) for cache entries.
+ pub fn thinlto_codegen_set_cache_entry_expiration(
+ cg: thinlto_code_gen_t,
+ expiration: ::libc::c_uint,
+ );
+ /// Set the maximum size of the cache directory (in bytes). A value over the
+ /// amount of available space on the disk will be reduced to the amount of
+ /// available space. An unspecified default value will be applied. A value of 0
+ /// will be ignored.
+ pub fn thinlto_codegen_set_cache_size_bytes(
+ cg: thinlto_code_gen_t,
+ max_size_bytes: ::libc::c_uint,
+ );
+ /// Same as thinlto_codegen_set_cache_size_bytes, except the maximum size is in
+ /// megabytes (2^20 bytes).
+ pub fn thinlto_codegen_set_cache_size_megabytes(
+ cg: thinlto_code_gen_t,
+ max_size_megabytes: ::libc::c_uint,
+ );
+ /// Sets the maximum number of files in the cache directory. An unspecified default value will be applied. A value of 0 will be ignored.
+ pub fn thinlto_codegen_set_cache_size_files(
+ cg: thinlto_code_gen_t,
+ max_size_files: ::libc::c_uint,
+ );
+
+ /// Create an LTO input file from a buffer.
+ pub fn lto_input_create(
+ buffer: *const ::libc::c_void,
+ buffer_size: ::libc::size_t,
+ path: *const ::libc::c_char,
+ ) -> lto_input_t;
+ /// Free all memory allocated by the input file.
+ pub fn lto_input_dispose(input: lto_input_t);
+ /// Get the number of dependent library specifiers for the given input.
+ pub fn lto_input_get_num_dependent_libraries(input: lto_input_t) -> ::libc::c_uint;
+ /// Get the `i`th dependent library specifier for the given input file.
+ ///
+ /// The returned string is not null-terminated.
+ pub fn lto_input_get_dependent_library(
+ input: lto_input_t,
+ index: ::libc::size_t,
+ size: *mut ::libc::size_t,
+ ) -> *const ::libc::c_char;
+ /// Return the list of libcall symbols that can be generated by LTO
+ /// that might not be visible from the symbol table of bitcode files.
+ pub fn lto_runtime_lib_symbols_list(size: *mut usize) -> *const *const ::libc::c_char;
+
+ /// Set the path to a directory to use as temporary bitcode storage.
+ ///
+ /// This is meant to make the bitcode files available for debugging.
+ pub fn thinlto_codegen_set_savetemps_dir(
+ cg: thinlto_code_gen_t,
+ save_temps_dir: *const ::libc::c_char,
+ );
+ /// Set the path to a directory to save generated object files.
+ ///
+ /// Set this to request on-disk rather than in-memory buffers. When set, use
+ /// `thinlto_module_get_object_file` instead of `thinlto_module_get_object`.
+ pub fn thinlto_set_generated_objects_dir(
+ cg: thinlto_code_gen_t,
+ save_temps_dir: *const ::libc::c_char,
+ );
+ /// Set the CPU to generate code for.
+ pub fn thinlto_codegen_set_cpu(cg: thinlto_code_gen_t, cpu: *const ::libc::c_char);
+ /// Disable code generation (running all stages until codegen).
+ ///
+ /// The output with codegen disabled is bitcode.
+ pub fn thinlto_codegen_disable_codegen(cg: thinlto_code_gen_t, disable: lto_bool_t);
+ /// Perform codegen only; disable all other stages.
+ pub fn thinlto_codegen_set_codegen_only(cg: thinlto_code_gen_t, codegen_only: lto_bool_t);
+ /// Parse -mllvm style debug options.
+ pub fn thinlto_debug_options(options: *const *const ::libc::c_char, number: ::libc::c_int);
+ /// Test if a module has ThinLTO linking support.
+ pub fn lto_module_is_thinlto(module: lto_module_t) -> lto_bool_t;
+ /// Add a symbol to the list of global symbols that must exist in the
+ /// final generated code.
+ ///
+ /// Functions not listed may be inlined in every usage and optimized away.
+ pub fn thinlto_codegen_add_must_preserve_symbol(
+ cg: thinlto_code_gen_t,
+ name: *const ::libc::c_char,
+ length: ::libc::c_int,
+ );
+ /// Add a symbol to the list of global symbols that are cross-referenced
+ /// between ThinLTO files.
+ ///
+ /// Symbols listed can be discarded if every reference from a ThinLTO module
+ /// to a symbol is optimized away, then the symbol can be discarded.
+ pub fn thinlto_codegen_add_cross_referenced_symbol(
+ cg: thinlto_code_gen_t,
+ name: *const ::libc::c_char,
+ length: ::libc::c_int,
+ );
+}
diff --git a/ext/llvm-sys.rs/src/object.rs b/ext/llvm-sys.rs/src/object.rs
new file mode 100644
index 0000000..d8c7c78
--- /dev/null
+++ b/ext/llvm-sys.rs/src/object.rs
@@ -0,0 +1,164 @@
+//! Object file reading and writing
+
+use super::prelude::*;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueSectionIterator {}
+
+pub type LLVMSectionIteratorRef = *mut LLVMOpaqueSectionIterator;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueSymbolIterator {}
+
+pub type LLVMSymbolIteratorRef = *mut LLVMOpaqueSymbolIterator;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueRelocationIterator {}
+
+pub type LLVMRelocationIteratorRef = *mut LLVMOpaqueRelocationIterator;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueBinary {}
+
+pub type LLVMBinaryRef = *mut LLVMOpaqueBinary;
+
+#[repr(C)]
+#[derive(Debug)]
+pub enum LLVMBinaryType {
+ /// Archive file
+ LLVMBinaryTypeArchive,
+ /// Mach-O Universal Binary file
+ LLVMBinaryTypeMachOUniversalBinary,
+ /// COFF Import file
+ LLVMBinaryTypeCOFFImportFile,
+ /// LLVM IR
+ LLVMBinaryTypeIR,
+ /// Windows resource (.res) file
+ LLVMBinaryTypeWinRes,
+ /// COFF Object file
+ LLVMBinaryTypeCOFF,
+ /// ELF 32-bit, little endian
+ LLVMBinaryTypeELF32L,
+ /// ELF 32-bit, big endian
+ LLVMBinaryTypeELF32B,
+ /// ELF 64-bit, little endian
+ LLVMBinaryTypeELF64L,
+ /// ELF 64-bit, big endian
+ LLVMBinaryTypeELF64B,
+ /// MachO 32-bit, little endian
+ LLVMBinaryTypeMachO32L,
+ /// MachO 32-bit, big endian
+ LLVMBinaryTypeMachO32B,
+ /// MachO 64-bit, little endian
+ LLVMBinaryTypeMachO64L,
+ /// MachO 64-bit, big endian
+ LLVMBinaryTypeMachO64B,
+ /// Web assembly
+ LLVMBinaryTypeWasm,
+ /// Offloading fatbinary
+ LLVMBinaryTypeOffload,
+}
+
+#[deprecated(since = "LLVM 9.0")]
+pub enum LLVMOpaqueObjectFile {}
+
+#[allow(deprecated)]
+#[deprecated(since = "LLVM 9.0")]
+pub type LLVMObjectFileRef = *mut LLVMOpaqueObjectFile;
+
+extern "C" {
+ /// Create a binary file from the given memory buffer.
+ pub fn LLVMCreateBinary(
+ MemBuf: LLVMMemoryBufferRef,
+ Context: LLVMContextRef,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBinaryRef;
+ /// Dispose of a binary file
+ pub fn LLVMDisposeBinary(BR: LLVMBinaryRef);
+
+ pub fn LLVMBinaryCopyMemoryBuffer(BR: LLVMBinaryRef) -> LLVMMemoryBufferRef;
+ pub fn LLVMBinaryGetType(BR: LLVMBinaryRef) -> LLVMBinaryType;
+ pub fn LLVMMachOUniversalBinaryCopyObjectForArch(
+ BR: LLVMBinaryRef,
+ Arch: *const ::libc::c_char,
+ ArchLen: ::libc::size_t,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBinaryRef;
+
+ pub fn LLVMObjectFileCopySectionIterator(BR: LLVMBinaryRef) -> LLVMSectionIteratorRef;
+ pub fn LLVMObjectFileIsSectionIteratorAtEnd(
+ BR: LLVMBinaryRef,
+ SI: LLVMSectionIteratorRef,
+ ) -> LLVMBool;
+ pub fn LLVMObjectFileCopySymbolIterator(BR: LLVMBinaryRef) -> LLVMSymbolIteratorRef;
+ pub fn LLVMObjectFileIsSymbolIteratorAtEnd(
+ BR: LLVMBinaryRef,
+ SI: LLVMSymbolIteratorRef,
+ ) -> LLVMBool;
+ pub fn LLVMDisposeSectionIterator(SI: LLVMSectionIteratorRef);
+
+ pub fn LLVMMoveToNextSection(SI: LLVMSectionIteratorRef);
+ pub fn LLVMMoveToContainingSection(Sect: LLVMSectionIteratorRef, Sym: LLVMSymbolIteratorRef);
+ pub fn LLVMDisposeSymbolIterator(SI: LLVMSymbolIteratorRef);
+ pub fn LLVMMoveToNextSymbol(SI: LLVMSymbolIteratorRef);
+ pub fn LLVMGetSectionName(SI: LLVMSectionIteratorRef) -> *const ::libc::c_char;
+ pub fn LLVMGetSectionSize(SI: LLVMSectionIteratorRef) -> u64;
+ pub fn LLVMGetSectionContents(SI: LLVMSectionIteratorRef) -> *const ::libc::c_char;
+ pub fn LLVMGetSectionAddress(SI: LLVMSectionIteratorRef) -> u64;
+ pub fn LLVMGetSectionContainsSymbol(
+ SI: LLVMSectionIteratorRef,
+ Sym: LLVMSymbolIteratorRef,
+ ) -> LLVMBool;
+ pub fn LLVMGetRelocations(Section: LLVMSectionIteratorRef) -> LLVMRelocationIteratorRef;
+ pub fn LLVMDisposeRelocationIterator(RI: LLVMRelocationIteratorRef);
+ pub fn LLVMIsRelocationIteratorAtEnd(
+ Section: LLVMSectionIteratorRef,
+ RI: LLVMRelocationIteratorRef,
+ ) -> LLVMBool;
+ pub fn LLVMMoveToNextRelocation(RI: LLVMRelocationIteratorRef);
+ pub fn LLVMGetSymbolName(SI: LLVMSymbolIteratorRef) -> *const ::libc::c_char;
+ pub fn LLVMGetSymbolAddress(SI: LLVMSymbolIteratorRef) -> u64;
+ pub fn LLVMGetSymbolSize(SI: LLVMSymbolIteratorRef) -> u64;
+ pub fn LLVMGetRelocationOffset(RI: LLVMRelocationIteratorRef) -> u64;
+ pub fn LLVMGetRelocationSymbol(RI: LLVMRelocationIteratorRef) -> LLVMSymbolIteratorRef;
+ pub fn LLVMGetRelocationType(RI: LLVMRelocationIteratorRef) -> u64;
+ pub fn LLVMGetRelocationTypeName(RI: LLVMRelocationIteratorRef) -> *const ::libc::c_char;
+ pub fn LLVMGetRelocationValueString(RI: LLVMRelocationIteratorRef) -> *const ::libc::c_char;
+
+ #[allow(deprecated)]
+ #[deprecated(since = "LLVM 9.0", note = "Use LLVMCreateBinary instead")]
+ pub fn LLVMCreateObjectFile(MemBuf: LLVMMemoryBufferRef) -> LLVMObjectFileRef;
+ #[allow(deprecated)]
+ #[deprecated(since = "LLVM 9.0", note = "Use LLVMDisposeBinary instead")]
+ pub fn LLVMDisposeObjectFile(ObjectFile: LLVMObjectFileRef);
+ #[allow(deprecated)]
+ #[deprecated(
+ since = "LLVM 9.0",
+ note = "Use LLVMObjectFileCopySectionIterator instead"
+ )]
+ pub fn LLVMGetSections(ObjectFile: LLVMObjectFileRef) -> LLVMSectionIteratorRef;
+ #[allow(deprecated)]
+ #[deprecated(
+ since = "LLVM 9.0",
+ note = "Use LLVMObjectFileIsSectionIteratorAtEnd instead"
+ )]
+ pub fn LLVMIsSectionIteratorAtEnd(
+ ObjectFile: LLVMObjectFileRef,
+ SI: LLVMSectionIteratorRef,
+ ) -> LLVMBool;
+ #[allow(deprecated)]
+ #[deprecated(
+ since = "LLVM 9.0",
+ note = "Use LLVMObjectFileCopySymbolIterator instead"
+ )]
+ pub fn LLVMGetSymbols(ObjectFile: LLVMObjectFileRef) -> LLVMSymbolIteratorRef;
+ #[allow(deprecated)]
+ #[deprecated(
+ since = "LLVM 9.0",
+ note = "Use LLVMObjectFileIsSymbolIteratorAtEnd instead"
+ )]
+ pub fn LLVMIsSymbolIteratorAtEnd(
+ ObjectFile: LLVMObjectFileRef,
+ SI: LLVMSymbolIteratorRef,
+ ) -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/orc2/ee.rs b/ext/llvm-sys.rs/src/orc2/ee.rs
new file mode 100644
index 0000000..45f52d6
--- /dev/null
+++ b/ext/llvm-sys.rs/src/orc2/ee.rs
@@ -0,0 +1,11 @@
+use super::*;
+
+extern "C" {
+ pub fn LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(
+ ES: LLVMOrcExecutionSessionRef,
+ ) -> LLVMOrcObjectLayerRef;
+ pub fn LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(
+ RTDyldObjLinkingLayer: LLVMOrcObjectLayerRef,
+ Listener: LLVMJITEventListenerRef,
+ );
+}
diff --git a/ext/llvm-sys.rs/src/orc2/lljit.rs b/ext/llvm-sys.rs/src/orc2/lljit.rs
new file mode 100644
index 0000000..1b82a13
--- /dev/null
+++ b/ext/llvm-sys.rs/src/orc2/lljit.rs
@@ -0,0 +1,74 @@
+use super::*;
+use error::LLVMErrorRef;
+use prelude::*;
+
+pub type LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction =
+ extern "C" fn(
+ Ctx: *mut ::libc::c_void,
+ ES: LLVMOrcExecutionSessionRef,
+ Triple: *const ::libc::c_char,
+ ) -> LLVMOrcObjectLayerRef;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueLLJITBuilder {}
+pub type LLVMOrcLLJITBuilderRef = *mut LLVMOrcOpaqueLLJITBuilder;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueLLJIT {}
+pub type LLVMOrcLLJITRef = *mut LLVMOrcOpaqueLLJIT;
+
+extern "C" {
+ pub fn LLVMOrcCreateLLJITBuilder() -> LLVMOrcLLJITBuilderRef;
+ pub fn LLVMOrcDisposeLLJITBuilder(Builder: LLVMOrcLLJITBuilderRef);
+ pub fn LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(
+ Builder: LLVMOrcLLJITBuilderRef,
+ JTMB: LLVMOrcJITTargetMachineBuilderRef,
+ );
+ pub fn LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator(
+ Builder: LLVMOrcLLJITBuilderRef,
+ F: LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction,
+ Ctx: *mut ::libc::c_void,
+ );
+ pub fn LLVMOrcCreateLLJIT(
+ Result: *mut LLVMOrcLLJITRef,
+ Builder: LLVMOrcLLJITBuilderRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcDisposeLLJIT(J: LLVMOrcLLJITRef) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITGetExecutionSession(J: LLVMOrcLLJITRef) -> LLVMOrcExecutionSessionRef;
+ pub fn LLVMOrcLLJITGetMainJITDylib(J: LLVMOrcLLJITRef) -> LLVMOrcJITDylibRef;
+ pub fn LLVMOrcLLJITGetTripleString(J: LLVMOrcLLJITRef) -> *const ::libc::c_char;
+ pub fn LLVMOrcLLJITGetGlobalPrefix(J: LLVMOrcLLJITRef) -> ::libc::c_char;
+ pub fn LLVMOrcLLJITMangleAndIntern(
+ J: LLVMOrcLLJITRef,
+ UnmangledName: *const ::libc::c_char,
+ ) -> LLVMOrcSymbolStringPoolEntryRef;
+ pub fn LLVMOrcLLJITAddObjectFile(
+ J: LLVMOrcLLJITRef,
+ JD: LLVMOrcJITDylibRef,
+ ObjBuffer: LLVMMemoryBufferRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITAddObjectFileWithRT(
+ J: LLVMOrcLLJITRef,
+ RT: LLVMOrcResourceTrackerRef,
+ ObjBuffer: LLVMMemoryBufferRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITAddLLVMIRModule(
+ J: LLVMOrcLLJITRef,
+ JD: LLVMOrcJITDylibRef,
+ TSM: LLVMOrcThreadSafeModuleRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITAddLLVMIRModuleWithRT(
+ J: LLVMOrcLLJITRef,
+ JD: LLVMOrcResourceTrackerRef,
+ TSM: LLVMOrcThreadSafeModuleRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITLookup(
+ J: LLVMOrcLLJITRef,
+ Result: *mut LLVMOrcExecutorAddress,
+ Name: *const ::libc::c_char,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcLLJITGetObjLinkingLayer(J: LLVMOrcLLJITRef) -> LLVMOrcObjectLayerRef;
+ pub fn LLVMOrcLLJITGetObjTransformLayer(J: LLVMOrcLLJITRef) -> LLVMOrcObjectTransformLayerRef;
+ pub fn LLVMOrcLLJITGetIRTransformLayer(J: LLVMOrcLLJITRef) -> LLVMOrcIRTransformLayerRef;
+ pub fn LLVMOrcLLJITGetDataLayoutStr(J: LLVMOrcLLJITRef) -> *const ::libc::c_char;
+}
diff --git a/ext/llvm-sys.rs/src/orc2/mod.rs b/ext/llvm-sys.rs/src/orc2/mod.rs
new file mode 100644
index 0000000..afca862
--- /dev/null
+++ b/ext/llvm-sys.rs/src/orc2/mod.rs
@@ -0,0 +1,539 @@
+#![allow(non_snake_case)]
+//! OrcV2
+
+pub mod ee;
+pub mod lljit;
+
+use error::LLVMErrorRef;
+use prelude::*;
+use target_machine::LLVMTargetMachineRef;
+
+/// Represents an address in the executor process.
+pub type LLVMOrcJITTargetAddress = u64;
+
+/// Represents an address in the executor process
+pub type LLVMOrcExecutorAddress = u64;
+
+/// Generic linkage flags for a symbol definition.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMJITSymbolGenericFlags {
+ LLVMJITSymbolGenericFlagsNone = 0,
+ LLVMJITSymbolGenericFlagsExported = 1,
+ LLVMJITSymbolGenericFlagsWeak = 2,
+ LLVMJITSymbolGenericFlagsCallable = 4,
+ LLVMJITSymbolGenericFlagsMaterializationSideEffectsOnly = 8,
+}
+
+/// Target specific flags for a symbol definition.
+pub type LLVMJITSymbolTargetFlags = u8;
+
+/// Linkage flags for a symbol definition.
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMJITSymbolFlags {
+ pub GenericFlags: u8,
+ pub TargetFlags: u8,
+}
+
+/// An evaluated symbol address and flags.
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMJITEvaluatedSymbol {
+ pub Address: LLVMOrcExecutorAddress,
+ pub Flags: LLVMJITSymbolFlags,
+}
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueExecutionSession {}
+pub type LLVMOrcExecutionSessionRef = *mut LLVMOrcOpaqueExecutionSession;
+
+/// Error reporter function.
+pub type LLVMOrcErrorReporterFunction = extern "C" fn(Ctx: *mut ::libc::c_void, Err: LLVMErrorRef);
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueSymbolStringPool {}
+/// A reference to an orc::SymbolStringPool.
+pub type LLVMOrcSymbolStringPoolRef = *mut LLVMOrcOpaqueSymbolStringPool;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueSymbolStringPoolEntry {}
+pub type LLVMOrcSymbolStringPoolEntryRef = *mut LLVMOrcOpaqueSymbolStringPoolEntry;
+
+/// A pair of a symbol name and LLVMJITSymbolFlags.
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCSymbolFlagsMapPair {
+ pub Name: LLVMOrcSymbolStringPoolEntryRef,
+ pub Flags: LLVMJITSymbolFlags,
+}
+
+pub type LLVMOrcCSymbolFlagsMapPairs = *mut LLVMOrcCSymbolFlagsMapPair;
+
+/// A pair of a symbol name and an evaluated symbol.
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCSymbolMapPair {
+ pub Name: LLVMOrcSymbolStringPoolEntryRef,
+ pub Sym: LLVMJITEvaluatedSymbol,
+}
+
+/// A list of (SymbolStringPtr, JITEvaluatedSymbol) pairs that can be
+/// used to construct a SymbolMap.
+pub type LLVMOrcCSymbolMapPairs = *mut LLVMOrcCSymbolMapPair;
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCSymbolAliasMapEntry {
+ pub Name: LLVMOrcSymbolStringPoolEntryRef,
+ pub Flags: LLVMJITSymbolFlags,
+}
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCSymbolAliasMapPair {
+ pub Name: LLVMOrcSymbolStringPoolEntryRef,
+ pub Entry: LLVMOrcCSymbolAliasMapEntry,
+}
+
+pub type LLVMOrcCSymbolAliasMapPairs = *mut LLVMOrcCSymbolAliasMapPair;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueJITDylib {}
+pub type LLVMOrcJITDylibRef = *mut LLVMOrcOpaqueJITDylib;
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCSymbolsList {
+ pub Symbols: *mut LLVMOrcSymbolStringPoolEntryRef,
+ pub Length: ::libc::size_t,
+}
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCDependenceMapPair {
+ pub JD: LLVMOrcJITDylibRef,
+ pub Names: LLVMOrcCSymbolsList,
+}
+
+pub type LLVMOrcCDependenceMapPairs = *mut LLVMOrcCDependenceMapPair;
+
+/// Lookup kind. This can be used by definition generators when deciding whether
+/// to produce a definition for a requested symbol.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMOrcLookupKind {
+ LLVMOrcLookupKindStatic,
+ LLVMOrcLookupKindDLSym,
+}
+
+/// JITDylib lookup flags. This can be used by definition generators when
+/// deciding whether to produce a definition for a requested symbol.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMOrcJITDylibLookupFlags {
+ LLVMOrcJITDylibLookupFlagsMatchExportedSymbolsOnly,
+ LLVMOrcJITDylibLookupFlagsMatchAllSymbols,
+}
+
+/// An element type for a JITDylib search order.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub struct LLVMOrcCJITDylibSearchOrderElement {
+ pub JD: LLVMOrcJITDylibRef,
+ pub JDLookupFlags: LLVMOrcJITDylibLookupFlags,
+}
+
+/// A JITDylib search order.
+///
+/// The list is terminated with an element containing a null pointer for the JD
+/// field.
+pub type LLVMOrcCJITDylibSearchOrder = *mut LLVMOrcCJITDylibSearchOrderElement;
+
+/// Symbol lookup flags for lookup sets.
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMOrcSymbolLookupFlags {
+ LLVMOrcSymbolLookupFlagsRequiredSymbol,
+ LLVMOrcSymbolLookupFlagsWeaklyReferencedSymbol,
+}
+
+/// An element type for a symbol lookup set.
+#[repr(C)]
+#[derive(Debug)]
+pub struct LLVMOrcCLookupSetElement {
+ pub Name: LLVMOrcSymbolStringPoolEntryRef,
+ pub LookupFlags: LLVMOrcSymbolLookupFlags,
+}
+
+/// A set of symbols to look up / generate.
+///
+/// The list is terminated with an element containing a null pointer for the
+/// Name field.
+///
+/// The creator is responsible for freeing the set and ensuring all strings
+/// are retained for the set's lifetime.
+pub type LLVMOrcCLookupSet = *mut LLVMOrcCLookupSetElement;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueMaterializationUnit {}
+pub type LLVMOrcMaterializationUnitRef = *mut LLVMOrcOpaqueMaterializationUnit;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueMaterializationResponsibility {}
+pub type LLVMOrcMaterializationResponsibilityRef = *mut LLVMOrcOpaqueMaterializationResponsibility;
+
+pub type LLVMOrcMaterializationUnitMaterializeFunction =
+ extern "C" fn(Ctx: *mut ::libc::c_void, MR: LLVMOrcMaterializationResponsibilityRef);
+
+pub type LLVMOrcMaterializationUnitDiscardFunction = extern "C" fn(
+ Ctx: *mut ::libc::c_void,
+ JD: LLVMOrcJITDylibRef,
+ Symbol: LLVMOrcSymbolStringPoolEntryRef,
+);
+
+pub type LLVMOrcMaterializationUnitDestroyFunction = extern "C" fn(Ctx: *mut ::libc::c_void);
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueResourceTracker {}
+pub type LLVMOrcResourceTrackerRef = *mut LLVMOrcOpaqueResourceTracker;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueDefinitionGenerator {}
+pub type LLVMOrcDefinitionGeneratorRef = *mut LLVMOrcOpaqueDefinitionGenerator;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueLookupState {}
+pub type LLVMOrcLookupStateRef = *mut LLVMOrcOpaqueLookupState;
+
+pub type LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction = extern "C" fn(
+ GeneratorObj: LLVMOrcDefinitionGeneratorRef,
+ Ctx: *mut ::libc::c_void,
+ LookupState: *mut LLVMOrcLookupStateRef,
+ Kind: LLVMOrcLookupKind,
+ JD: LLVMOrcJITDylibRef,
+ JDLookupFlags: LLVMOrcJITDylibLookupFlags,
+ LookupSet: LLVMOrcCLookupSet,
+ LookupSetSize: usize,
+) -> LLVMErrorRef;
+
+/// Disposer for a custom generator.
+///
+/// Will be called by ORC when the JITDylib that the generator is attached to
+/// is destroyed.
+pub type LLVMOrcDisposeCAPIDefinitionGeneratorFunction = extern "C" fn(Ctx: *mut ::libc::c_void);
+
+pub type LLVMOrcSymbolPredicate = Option<
+ extern "C" fn(Ctx: *mut ::libc::c_void, Sym: LLVMOrcSymbolStringPoolEntryRef) -> ::libc::c_int,
+>;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueThreadSafeContext {}
+pub type LLVMOrcThreadSafeContextRef = *mut LLVMOrcOpaqueThreadSafeContext;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueThreadSafeModule {}
+pub type LLVMOrcThreadSafeModuleRef = *mut LLVMOrcOpaqueThreadSafeModule;
+
+pub type LLVMOrcGenericIRModuleOperationFunction =
+ extern "C" fn(Ctx: *mut ::libc::c_void, M: LLVMModuleRef) -> LLVMErrorRef;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueJITTargetMachineBuilder {}
+pub type LLVMOrcJITTargetMachineBuilderRef = *mut LLVMOrcOpaqueJITTargetMachineBuilder;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueObjectLayer {}
+pub type LLVMOrcObjectLayerRef = *mut LLVMOrcOpaqueObjectLayer;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueObjectLinkingLayer {}
+pub type LLVMOrcObjectLinkingLayerRef = *mut LLVMOrcOpaqueObjectLayer;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueIRTransformLayer {}
+pub type LLVMOrcIRTransformLayerRef = *mut LLVMOrcOpaqueIRTransformLayer;
+
+pub type LLVMOrcIRTransformLayerTransformFunction = extern "C" fn(
+ Ctx: *mut ::libc::c_void,
+ ModInOut: *mut LLVMOrcThreadSafeModuleRef,
+ MR: LLVMOrcMaterializationResponsibilityRef,
+) -> LLVMErrorRef;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueObjectTransformLayer {}
+pub type LLVMOrcObjectTransformLayerRef = *mut LLVMOrcOpaqueObjectTransformLayer;
+
+pub type LLVMOrcObjectTransformLayerTransformFunction =
+ extern "C" fn(Ctx: *mut ::libc::c_void, ObjInOut: *mut LLVMMemoryBufferRef) -> LLVMErrorRef;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueIndirectStubsManager {}
+pub type LLVMOrcIndirectStubsManagerRef = *mut LLVMOrcOpaqueIndirectStubsManager;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueLazyCallThroughManager {}
+pub type LLVMOrcLazyCallThroughManagerRef = *mut LLVMOrcOpaqueLazyCallThroughManager;
+
+#[derive(Debug)]
+pub enum LLVMOrcOpaqueDumpObjects {}
+pub type LLVMOrcDumpObjectsRef = *mut LLVMOrcOpaqueDumpObjects;
+
+extern "C" {
+ pub fn LLVMOrcExecutionSessionSetErrorReporter(
+ ES: LLVMOrcExecutionSessionRef,
+ ReportError: LLVMOrcErrorReporterFunction,
+ Ctx: *mut ::libc::c_void,
+ );
+ pub fn LLVMOrcExecutionSessionGetSymbolStringPool(
+ ES: LLVMOrcExecutionSessionRef,
+ ) -> LLVMOrcSymbolStringPoolRef;
+ pub fn LLVMOrcSymbolStringPoolClearDeadEntries(SSP: LLVMOrcSymbolStringPoolRef);
+ pub fn LLVMOrcExecutionSessionIntern(
+ ES: LLVMOrcExecutionSessionRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMOrcSymbolStringPoolEntryRef;
+}
+
+pub type LLVMOrcExecutionSessionLookupHandleResultFunction = extern "C" fn(
+ Err: LLVMErrorRef,
+ Result: LLVMOrcCSymbolMapPairs,
+ NumPairs: usize,
+ Ctx: *mut ::libc::c_void,
+);
+
+extern "C" {
+ pub fn LLVMOrcExecutionSessionLookup(
+ ES: LLVMOrcExecutionSessionRef,
+ K: LLVMOrcLookupKind,
+ SearchOrder: LLVMOrcCJITDylibSearchOrder,
+ SearchOrderSize: usize,
+ Symbols: LLVMOrcCLookupSet,
+ SymbolsSize: usize,
+ HandleResult: LLVMOrcExecutionSessionLookupHandleResultFunction,
+ Ctx: *mut ::libc::c_void,
+ );
+ pub fn LLVMOrcRetainSymbolStringPoolEntry(S: LLVMOrcSymbolStringPoolEntryRef);
+ pub fn LLVMOrcReleaseSymbolStringPoolEntry(S: LLVMOrcSymbolStringPoolEntryRef);
+ pub fn LLVMOrcSymbolStringPoolEntryStr(
+ S: LLVMOrcSymbolStringPoolEntryRef,
+ ) -> *const ::libc::c_char;
+ pub fn LLVMOrcReleaseResourceTracker(RT: LLVMOrcResourceTrackerRef);
+ pub fn LLVMOrcResourceTrackerTransferTo(
+ SrcRT: LLVMOrcResourceTrackerRef,
+ DstRT: LLVMOrcResourceTrackerRef,
+ );
+ pub fn LLVMOrcResourceTrackerRemove(RT: LLVMOrcResourceTrackerRef) -> LLVMErrorRef;
+ pub fn LLVMOrcDisposeDefinitionGenerator(DG: LLVMOrcDefinitionGeneratorRef);
+ pub fn LLVMOrcDisposeMaterializationUnit(MU: LLVMOrcMaterializationUnitRef);
+ pub fn LLVMOrcCreateCustomMaterializationUnit(
+ Name: *const ::libc::c_char,
+ Ctx: *mut ::libc::c_void,
+ Syms: LLVMOrcCSymbolFlagsMapPairs,
+ NumSyms: ::libc::size_t,
+ InitSym: LLVMOrcSymbolStringPoolEntryRef,
+ Materialize: LLVMOrcMaterializationUnitMaterializeFunction,
+ Discard: LLVMOrcMaterializationUnitDiscardFunction,
+ Destroy: LLVMOrcMaterializationUnitDestroyFunction,
+ ) -> LLVMOrcMaterializationUnitRef;
+ pub fn LLVMOrcAbsoluteSymbols(
+ Syms: LLVMOrcCSymbolMapPairs,
+ NumPairs: usize,
+ ) -> LLVMOrcMaterializationUnitRef;
+ pub fn LLVMOrcLazyReexports(
+ LCTM: LLVMOrcLazyCallThroughManagerRef,
+ ISM: LLVMOrcIndirectStubsManagerRef,
+ SourceRef: LLVMOrcJITDylibRef,
+ CallableAliases: LLVMOrcCSymbolAliasMapPairs,
+ NumPairs: ::libc::size_t,
+ ) -> LLVMOrcMaterializationUnitRef;
+ pub fn LLVMOrcDisposeMaterializationResponsibility(MR: LLVMOrcMaterializationResponsibilityRef);
+ pub fn LLVMOrcMaterializationResponsibilityGetTargetDylib(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ ) -> LLVMOrcJITDylibRef;
+ pub fn LLVMOrcMaterializationResponsibilityGetExecutionSession(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ ) -> LLVMOrcExecutionSessionRef;
+ pub fn LLVMOrcMaterializationResponsibilityGetSymbols(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ NumPairs: *mut ::libc::size_t,
+ ) -> LLVMOrcCSymbolFlagsMapPairs;
+ pub fn LLVMOrcDisposeCSymbolFlagsMap(Pairs: LLVMOrcCSymbolFlagsMapPairs);
+ pub fn LLVMOrcMaterializationResponsibilityGetInitializerSymbol(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ ) -> LLVMOrcSymbolStringPoolEntryRef;
+ pub fn LLVMOrcMaterializationResponsibilityGetRequestedSymbols(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ NumSymbols: *mut ::libc::size_t,
+ ) -> *mut LLVMOrcSymbolStringPoolEntryRef;
+ pub fn LLVMOrcDisposeSymbols(Symbols: *mut LLVMOrcSymbolStringPoolEntryRef);
+ pub fn LLVMOrcMaterializationResponsibilityNotifyResolved(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ Symbols: LLVMOrcCSymbolMapPairs,
+ NumPairs: ::libc::size_t,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcMaterializationResponsibilityNotifyEmitted(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcMaterializationResponsibilityDefineMaterializing(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ Pairs: LLVMOrcCSymbolFlagsMapPairs,
+ NumPairs: ::libc::size_t,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcMaterializationResponsibilityFailMaterialization(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ );
+ pub fn LLVMOrcMaterializationResponsibilityReplace(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ MU: LLVMOrcMaterializationUnitRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcMaterializationResponsibilityDelegate(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ Symbols: *mut LLVMOrcSymbolStringPoolEntryRef,
+ NumSymbols: ::libc::size_t,
+ Result: *mut LLVMOrcMaterializationResponsibilityRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcMaterializationResponsibilityAddDependencies(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ Name: LLVMOrcSymbolStringPoolEntryRef,
+ Dependencies: LLVMOrcCDependenceMapPairs,
+ NumPairs: ::libc::size_t,
+ );
+ pub fn LLVMOrcMaterializationResponsibilityAddDependenciesForAll(
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ Dependencies: LLVMOrcCDependenceMapPairs,
+ NumPairs: ::libc::size_t,
+ );
+ pub fn LLVMOrcExecutionSessionCreateBareJITDylib(
+ ES: LLVMOrcExecutionSessionRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMOrcJITDylibRef;
+ pub fn LLVMOrcExecutionSessionCreateJITDylib(
+ ES: LLVMOrcExecutionSessionRef,
+ Result_: *mut LLVMOrcJITDylibRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcExecutionSessionGetJITDylibByName(
+ ES: LLVMOrcExecutionSessionRef,
+ Name: *const ::libc::c_char,
+ ) -> LLVMOrcJITDylibRef;
+ pub fn LLVMOrcJITDylibCreateResourceTracker(
+ JD: LLVMOrcJITDylibRef,
+ ) -> LLVMOrcResourceTrackerRef;
+ pub fn LLVMOrcJITDylibGetDefaultResourceTracker(
+ JD: LLVMOrcJITDylibRef,
+ ) -> LLVMOrcResourceTrackerRef;
+ pub fn LLVMOrcJITDylibDefine(
+ JD: LLVMOrcJITDylibRef,
+ MU: LLVMOrcMaterializationUnitRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcJITDylibClear(JD: LLVMOrcJITDylibRef) -> LLVMErrorRef;
+ pub fn LLVMOrcJITDylibAddGenerator(JD: LLVMOrcJITDylibRef, DG: LLVMOrcDefinitionGeneratorRef);
+ pub fn LLVMOrcCreateCustomCAPIDefinitionGenerator(
+ F: LLVMOrcCAPIDefinitionGeneratorTryToGenerateFunction,
+ Ctx: *mut ::libc::c_void,
+ Dispose: LLVMOrcDisposeCAPIDefinitionGeneratorFunction,
+ ) -> LLVMOrcDefinitionGeneratorRef;
+ pub fn LLVMOrcLookupStateContinueLookup(
+ S: LLVMOrcLookupStateRef,
+ Err: LLVMErrorRef,
+ );
+ pub fn LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(
+ Result: *mut LLVMOrcDefinitionGeneratorRef,
+ GlobalPrefix: ::libc::c_char,
+ Filter: LLVMOrcSymbolPredicate,
+ FilterCtx: *mut ::libc::c_void,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcCreateDynamicLibrarySearchGeneratorForPath(
+ Result: *mut LLVMOrcDefinitionGeneratorRef,
+ FileName: *const ::libc::c_char,
+ GlobalPrefix: ::libc::c_char,
+ Filter: LLVMOrcSymbolPredicate,
+ FilterCtx: *mut ::libc::c_void,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcCreateStaticLibrarySearchGeneratorForPath(
+ Result: *mut LLVMOrcDefinitionGeneratorRef,
+ ObjLayer: LLVMOrcObjectLayerRef,
+ FileName: *const ::libc::c_char,
+ TargetTriple: *const ::libc::c_char,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcCreateNewThreadSafeContext() -> LLVMOrcThreadSafeContextRef;
+ pub fn LLVMOrcThreadSafeContextGetContext(TSCtx: LLVMOrcThreadSafeContextRef)
+ -> LLVMContextRef;
+ pub fn LLVMOrcDisposeThreadSafeContext(TSCtx: LLVMOrcThreadSafeContextRef);
+ pub fn LLVMOrcCreateNewThreadSafeModule(
+ M: LLVMModuleRef,
+ TSCtx: LLVMOrcThreadSafeContextRef,
+ ) -> LLVMOrcThreadSafeModuleRef;
+ pub fn LLVMOrcDisposeThreadSafeModule(TSM: LLVMOrcThreadSafeModuleRef);
+ pub fn LLVMOrcThreadSafeModuleWithModuleDo(
+ TSM: LLVMOrcThreadSafeModuleRef,
+ F: LLVMOrcGenericIRModuleOperationFunction,
+ Ctx: *mut ::libc::c_void,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcJITTargetMachineBuilderDetectHost(
+ Result: *mut LLVMOrcJITTargetMachineBuilderRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(
+ TM: LLVMTargetMachineRef,
+ ) -> LLVMOrcJITTargetMachineBuilderRef;
+ pub fn LLVMOrcDisposeJITTargetMachineBuilder(JTMB: LLVMOrcJITTargetMachineBuilderRef);
+ pub fn LLVMOrcJITTargetMachineBuilderGetTargetTriple(
+ JTMB: LLVMOrcJITTargetMachineBuilderRef,
+ ) -> *mut ::libc::c_char;
+ pub fn LLVMOrcJITTargetMachineBuilderSetTargetTriple(
+ JTMB: LLVMOrcJITTargetMachineBuilderRef,
+ TargetTriple: *const ::libc::c_char,
+ );
+ pub fn LLVMOrcObjectLayerAddObjectFile(
+ ObjLayer: LLVMOrcObjectLayerRef,
+ JD: LLVMOrcJITDylibRef,
+ ObjBuffer: LLVMMemoryBufferRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcObjectLayerAddObjectFileWithRT(
+ ObjLayer: LLVMOrcObjectLayerRef,
+ RT: LLVMOrcResourceTrackerRef,
+ ObjBuffer: LLVMMemoryBufferRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcObjectLayerEmit(
+ ObjLayer: LLVMOrcObjectLayerRef,
+ R: LLVMOrcMaterializationResponsibilityRef,
+ ObjBuffer: LLVMMemoryBufferRef,
+ );
+ pub fn LLVMOrcDisposeObjectLayer(ObjLayer: LLVMOrcObjectLayerRef);
+ pub fn LLVMOrcIRTransformLayerEmit(
+ IRTransformLayer: LLVMOrcIRTransformLayerRef,
+ MR: LLVMOrcMaterializationResponsibilityRef,
+ TSM: LLVMOrcThreadSafeModuleRef,
+ );
+ pub fn LLVMOrcIRTransformLayerSetTransform(
+ IRTransformLayer: LLVMOrcIRTransformLayerRef,
+ TransformFunction: LLVMOrcIRTransformLayerTransformFunction,
+ Ctx: *mut ::libc::c_void,
+ );
+ pub fn LLVMOrcObjectTransformLayerSetTransform(
+ ObjTransformLayer: LLVMOrcObjectTransformLayerRef,
+ TransformFunction: LLVMOrcObjectTransformLayerTransformFunction,
+ Ctx: *mut ::libc::c_void,
+ );
+ pub fn LLVMOrcCreateLocalIndirectStubsManager(
+ TargetTriple: *const ::libc::c_char,
+ ) -> LLVMOrcIndirectStubsManagerRef;
+ pub fn LLVMOrcDisposeIndirectStubsManager(ISM: LLVMOrcIndirectStubsManagerRef);
+ pub fn LLVMOrcCreateLocalLazyCallThroughManager(
+ TargetTriple: *const ::libc::c_char,
+ ES: LLVMOrcExecutionSessionRef,
+ ErrorHandlerAddr: LLVMOrcJITTargetAddress,
+ LCTM: *mut LLVMOrcLazyCallThroughManagerRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMOrcDisposeLazyCallThroughManager(LCTM: LLVMOrcLazyCallThroughManagerRef);
+ pub fn LLVMOrcCreateDumpObjects(
+ DumpDir: *const ::libc::c_char,
+ IdentifierOverride: *const ::libc::c_char,
+ ) -> LLVMOrcDumpObjectsRef;
+ pub fn LLVMOrcDisposeDumpObjects(DumpObjects: LLVMOrcDumpObjectsRef);
+ pub fn LLVMOrcDumpObjects_CallOperator(
+ DumpObjects: LLVMOrcDumpObjectsRef,
+ ObjBuffer: *mut LLVMMemoryBufferRef,
+ ) -> LLVMErrorRef;
+}
diff --git a/ext/llvm-sys.rs/src/remarks.rs b/ext/llvm-sys.rs/src/remarks.rs
new file mode 100644
index 0000000..b8b022c
--- /dev/null
+++ b/ext/llvm-sys.rs/src/remarks.rs
@@ -0,0 +1,134 @@
+//! Remark diagnostics library.
+use prelude::LLVMBool;
+
+#[repr(C)]
+pub enum LLVMRemarkType {
+ LLVMRemarkTypeUnknown,
+ LLVMRemarkTypePassed,
+ LLVMRemarkTypeMissed,
+ LLVMRemarkTypeAnalysis,
+ LLVMRemarkTypeAnalysisFPCommute,
+ LLVMRemarkTypeAnalysisAliasing,
+ LLVMRemarkTypeFailure,
+}
+
+pub enum LLVMRemarkOpaqueString {}
+
+/// String containing a buffer and a length. The buffer is not guaranteed to be zero-terminated.
+pub type LLVMRemarkStringRef = *mut LLVMRemarkOpaqueString;
+
+extern "C" {
+ /// Returns the buffer holding the string.
+ pub fn LLVMRemarkStringGetData(String: LLVMRemarkStringRef) -> *const ::libc::c_char;
+
+ /// Returns the size of the string.
+ pub fn LLVMRemarkStringGetLen(String: LLVMRemarkStringRef) -> u32;
+}
+
+pub enum LLVMRemarkOpaqueDebugLoc {}
+
+/// DebugLoc containing File, Line and Column.
+pub type LLVMRemarkDebugLocRef = *mut LLVMRemarkOpaqueDebugLoc;
+
+extern "C" {
+ /// Return the path to the source file for a debug location.
+ pub fn LLVMRemarkDebugLocGetSourceFilePath(DL: LLVMRemarkDebugLocRef) -> LLVMRemarkStringRef;
+
+ /// Return the line in the source file for a debug location.
+ pub fn LLVMRemarkDebugLocGetSourceLine(DL: LLVMRemarkDebugLocRef) -> u32;
+
+ /// Return the column in the source file for a debug location.
+ pub fn LLVMRemarkDebugLocGetSourceColumn(DL: LLVMRemarkDebugLocRef) -> u32;
+}
+
+pub enum LLVMRemarkOpaqueArg {}
+
+/// Element of the "Args" list. The key might give more information about what
+/// the semantics of the value are, e.g. "Callee" will tell you that the value
+/// is a symbol that names a function.
+pub type LLVMRemarkArgRef = *mut LLVMRemarkOpaqueArg;
+
+extern "C" {
+ /// Returns the key of an argument. The key defines what the value is, and the
+ /// same key can appear multiple times in the list of arguments.
+ pub fn LLVMRemarkArgGetKey(Arg: LLVMRemarkArgRef) -> LLVMRemarkStringRef;
+
+ /// Returns the value of an argument. This is a string that can contain newlines.
+ pub fn LLVMRemarkArgGetValue(Arg: LLVMRemarkArgRef) -> LLVMRemarkStringRef;
+
+ /// Returns the debug location that is attached to the value of this argument.
+ pub fn LLVMRemarkArgGetDebugLoc(Arg: LLVMRemarkArgRef) -> LLVMRemarkDebugLocRef;
+}
+
+pub enum LLVMRemarkOpaqueEntry {}
+/// A remark emitted by the compiler.
+pub type LLVMRemarkEntryRef = *mut LLVMRemarkOpaqueEntry;
+
+extern "C" {
+ /// Free the resources used by the remark entry.
+ pub fn LLVMRemarkEntryDispose(Remark: LLVMRemarkEntryRef);
+
+ /// The type of the remark. For example, it can allow users to only keep the
+ /// missed optimizations from the compiler.
+ pub fn LLVMRemarkEntryGetType(Remark: LLVMRemarkEntryRef) -> LLVMRemarkType;
+
+ /// Get the name of the pass that emitted this remark.
+ pub fn LLVMRemarkEntryGetPassName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;
+
+ /// Get an identifier of the remark.
+ pub fn LLVMRemarkEntryGetRemarkName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;
+
+ /// Get the name of the function being processed when the remark was emitted.
+ pub fn LLVMRemarkEntryGetFunctionName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;
+
+ /// Returns the debug location that is attached to this remark.
+ pub fn LLVMRemarkEntryGetDebugLoc(Remark: LLVMRemarkEntryRef) -> LLVMRemarkDebugLocRef;
+
+ /// Return the hotness of the remark.
+ pub fn LLVMRemarkEntryGetHotness(Remark: LLVMRemarkEntryRef) -> u64;
+
+ /// The number of arguments the remark holds.
+ pub fn LLVMRemarkEntryGetNumArgs(Remark: LLVMRemarkEntryRef) -> u32;
+
+ /// Get a new iterator to iterate over a remark's argument.
+ pub fn LLVMRemarkEntryGetFirstArg(Remark: LLVMRemarkEntryRef) -> LLVMRemarkArgRef;
+
+ /// Get the next argument in Remark from the position of It.
+ pub fn LLVMRemarkEntryGetNextArg(
+ It: LLVMRemarkArgRef,
+ Remark: LLVMRemarkEntryRef,
+ ) -> LLVMRemarkArgRef;
+}
+
+pub enum LLVMRemarkOpaqueParser {}
+pub type LLVMRemarkParserRef = *mut LLVMRemarkOpaqueParser;
+
+extern "C" {
+ /// Creates a remark parser that can be used to parse the buffer located in
+ /// Buf of size Size bytes.
+ pub fn LLVMRemarkParserCreateYAML(Buf: *const ::libc::c_void, Size: u64)
+ -> LLVMRemarkParserRef;
+
+ pub fn LLVMRemarkParserCreateBitstream(
+ Buf: *const ::libc::c_void,
+ Size: u64,
+ ) -> LLVMRemarkParserRef;
+
+ /// Returns the next remark in the file.
+ pub fn LLVMRemarkParserGetNext(Parser: LLVMRemarkParserRef) -> LLVMRemarkEntryRef;
+
+ /// Returns `1` if the parser encountered an error while parsing the buffer.
+ pub fn LLVMRemarkParserHasError(Parser: LLVMRemarkParserRef) -> LLVMBool;
+
+ /// Returns a null-terminated string containing an error message.
+ pub fn LLVMRemarkParserGetErrorMessage(Parser: LLVMRemarkParserRef) -> *const ::libc::c_char;
+
+ pub fn LLVMRemarkParserDispose(Parser: LLVMRemarkParserRef);
+}
+
+pub const REMARKS_API_VERSION: u32 = 1;
+
+extern "C" {
+ /// Returns the version of the remarks library.
+ pub fn LLVMRemarkVersion() -> u32;
+}
diff --git a/ext/llvm-sys.rs/src/support.rs b/ext/llvm-sys.rs/src/support.rs
new file mode 100644
index 0000000..d22c083
--- /dev/null
+++ b/ext/llvm-sys.rs/src/support.rs
@@ -0,0 +1,22 @@
+use super::prelude::*;
+
+extern "C" {
+ pub fn LLVMLoadLibraryPermanently(Filename: *const ::libc::c_char) -> LLVMBool;
+ pub fn LLVMParseCommandLineOptions(
+ argc: ::libc::c_int,
+ argv: *const *const ::libc::c_char,
+ Overview: *const ::libc::c_char,
+ );
+ /// Search all previously loaded dynamic libraries for the named symbol.
+ ///
+ /// Returns its address if found, otherwise null.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn LLVMSearchForAddressOfSymbol(symbolName: *const ::libc::c_char) -> *mut ::libc::c_void;
+ /// Permanently add the named symbol with the provided value.
+ ///
+ /// Symbols added this way are searched before any libraries.
+ ///
+ /// Added in LLVM 3.7.
+ pub fn LLVMAddSymbol(symbolName: *const ::libc::c_char, symbolValue: *mut ::libc::c_void);
+}
diff --git a/ext/llvm-sys.rs/src/target.rs b/ext/llvm-sys.rs/src/target.rs
new file mode 100644
index 0000000..8620790
--- /dev/null
+++ b/ext/llvm-sys.rs/src/target.rs
@@ -0,0 +1,195 @@
+//! Target information
+
+use super::prelude::*;
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMByteOrdering {
+ LLVMBigEndian = 0,
+ LLVMLittleEndian = 1,
+}
+
+#[derive(Debug)]
+pub enum LLVMOpaqueTargetData {}
+
+pub type LLVMTargetDataRef = *mut LLVMOpaqueTargetData;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueTargetLibraryInfotData {}
+
+pub type LLVMTargetLibraryInfoRef = *mut LLVMOpaqueTargetLibraryInfotData;
+
+extern "C" {
+ pub fn LLVMInitializeAMDGPUTargetInfo();
+ pub fn LLVMInitializeAMDGPUTarget();
+ pub fn LLVMInitializeAMDGPUTargetMC();
+ pub fn LLVMInitializeAMDGPUAsmPrinter();
+ pub fn LLVMInitializeAMDGPUAsmParser();
+ // Disassembler?
+
+ pub fn LLVMInitializeSystemZTargetInfo();
+ pub fn LLVMInitializeSystemZTarget();
+ pub fn LLVMInitializeSystemZTargetMC();
+ pub fn LLVMInitializeSystemZAsmPrinter();
+ pub fn LLVMInitializeSystemZAsmParser();
+ pub fn LLVMInitializeSystemZDisassembler();
+
+ pub fn LLVMInitializeHexagonTargetInfo();
+ pub fn LLVMInitializeHexagonTarget();
+ pub fn LLVMInitializeHexagonTargetMC();
+ pub fn LLVMInitializeHexagonAsmPrinter();
+ // AsmParser?
+ pub fn LLVMInitializeHexagonDisassembler();
+
+ pub fn LLVMInitializeNVPTXTargetInfo();
+ pub fn LLVMInitializeNVPTXTarget();
+ pub fn LLVMInitializeNVPTXTargetMC();
+ pub fn LLVMInitializeNVPTXAsmPrinter();
+ // AsmParser?
+
+ pub fn LLVMInitializeMSP430TargetInfo();
+ pub fn LLVMInitializeMSP430Target();
+ pub fn LLVMInitializeMSP430TargetMC();
+ pub fn LLVMInitializeMSP430AsmPrinter();
+ // AsmParser?
+
+ pub fn LLVMInitializeXCoreTargetInfo();
+ pub fn LLVMInitializeXCoreTarget();
+ pub fn LLVMInitializeXCoreTargetMC();
+ pub fn LLVMInitializeXCoreAsmPrinter();
+ // AsmParser?
+ pub fn LLVMInitializeXCoreDisassembler();
+
+ pub fn LLVMInitializeMipsTargetInfo();
+ pub fn LLVMInitializeMipsTarget();
+ pub fn LLVMInitializeMipsTargetMC();
+ pub fn LLVMInitializeMipsAsmPrinter();
+ pub fn LLVMInitializeMipsAsmParser();
+ pub fn LLVMInitializeMipsDisassembler();
+
+ pub fn LLVMInitializeAArch64TargetInfo();
+ pub fn LLVMInitializeAArch64Target();
+ pub fn LLVMInitializeAArch64TargetMC();
+ pub fn LLVMInitializeAArch64AsmPrinter();
+ pub fn LLVMInitializeAArch64AsmParser();
+ pub fn LLVMInitializeAArch64Disassembler();
+
+ pub fn LLVMInitializeARMTargetInfo();
+ pub fn LLVMInitializeARMTarget();
+ pub fn LLVMInitializeARMTargetMC();
+ pub fn LLVMInitializeARMAsmPrinter();
+ pub fn LLVMInitializeARMAsmParser();
+ pub fn LLVMInitializeARMDisassembler();
+
+ pub fn LLVMInitializePowerPCTargetInfo();
+ pub fn LLVMInitializePowerPCTarget();
+ pub fn LLVMInitializePowerPCTargetMC();
+ pub fn LLVMInitializePowerPCAsmPrinter();
+ pub fn LLVMInitializePowerPCAsmParser();
+ pub fn LLVMInitializePowerPCDisassembler();
+
+ pub fn LLVMInitializeSparcTargetInfo();
+ pub fn LLVMInitializeSparcTarget();
+ pub fn LLVMInitializeSparcTargetMC();
+ pub fn LLVMInitializeSparcAsmPrinter();
+ pub fn LLVMInitializeSparcAsmParser();
+ pub fn LLVMInitializeSparcDisassembler();
+
+ pub fn LLVMInitializeX86TargetInfo();
+ pub fn LLVMInitializeX86Target();
+ pub fn LLVMInitializeX86TargetMC();
+ pub fn LLVMInitializeX86AsmPrinter();
+ pub fn LLVMInitializeX86AsmParser();
+ pub fn LLVMInitializeX86Disassembler();
+
+ pub fn LLVMInitializeBPFTargetInfo();
+ pub fn LLVMInitializeBPFTarget();
+ pub fn LLVMInitializeBPFTargetMC();
+ pub fn LLVMInitializeBPFAsmPrinter();
+ // No AsmParser
+ pub fn LLVMInitializeBPFDisassembler();
+
+ pub fn LLVMInitializeLanaiTargetInfo();
+ pub fn LLVMInitializeLanaiTarget();
+ pub fn LLVMInitializeLanaiTargetMC();
+ pub fn LLVMInitializeLanaiAsmPrinter();
+ pub fn LLVMInitializeLanaiAsmParser();
+ pub fn LLVMInitializeLanaiDisassembler();
+
+ pub fn LLVMInitializeRISCVTargetInfo();
+ pub fn LLVMInitializeRISCVTarget();
+ pub fn LLVMInitializeRISCVTargetMC();
+ pub fn LLVMInitializeRISCVAsmPrinter();
+ pub fn LLVMInitializeRISCVAsmParser();
+ pub fn LLVMInitializeRISCVDisassembler();
+
+ pub fn LLVMInitializeWebAssemblyTargetInfo();
+ pub fn LLVMInitializeWebAssemblyTarget();
+ pub fn LLVMInitializeWebAssemblyTargetMC();
+ pub fn LLVMInitializeWebAssemblyAsmPrinter();
+ pub fn LLVMInitializeWebAssemblyAsmParser();
+ pub fn LLVMInitializeWebAssemblyDisassembler();
+}
+
+extern "C" {
+ /// Get the data layout for a module.
+ pub fn LLVMGetModuleDataLayout(M: LLVMModuleRef) -> LLVMTargetDataRef;
+ /// Set the data layout for a module.
+ pub fn LLVMSetModuleDataLayout(M: LLVMModuleRef, R: LLVMTargetDataRef);
+ /// Create target data from a target layout string.
+ pub fn LLVMCreateTargetData(StringRep: *const ::libc::c_char) -> LLVMTargetDataRef;
+ pub fn LLVMAddTargetLibraryInfo(TLI: LLVMTargetLibraryInfoRef, PM: LLVMPassManagerRef);
+ pub fn LLVMCopyStringRepOfTargetData(TD: LLVMTargetDataRef) -> *mut ::libc::c_char;
+ pub fn LLVMByteOrder(TD: LLVMTargetDataRef) -> LLVMByteOrdering;
+ pub fn LLVMPointerSize(TD: LLVMTargetDataRef) -> ::libc::c_uint;
+ pub fn LLVMPointerSizeForAS(TD: LLVMTargetDataRef, AS: ::libc::c_uint) -> ::libc::c_uint;
+ //pub fn LLVMIntPtrType(TD: LLVMTargetDataRef) -> LLVMTypeRef;
+ //pub fn LLVMIntPtrTypeForAS(TD: LLVMTargetDataRef, AS: ::libc::c_uint) -> LLVMTypeRef;
+ pub fn LLVMIntPtrTypeInContext(C: LLVMContextRef, TD: LLVMTargetDataRef) -> LLVMTypeRef;
+ pub fn LLVMIntPtrTypeForASInContext(
+ C: LLVMContextRef,
+ TD: LLVMTargetDataRef,
+ AS: ::libc::c_uint,
+ ) -> LLVMTypeRef;
+ pub fn LLVMSizeOfTypeInBits(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_ulonglong;
+ pub fn LLVMStoreSizeOfType(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_ulonglong;
+ pub fn LLVMABISizeOfType(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_ulonglong;
+ pub fn LLVMABIAlignmentOfType(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMCallFrameAlignmentOfType(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMPreferredAlignmentOfType(TD: LLVMTargetDataRef, Ty: LLVMTypeRef) -> ::libc::c_uint;
+ pub fn LLVMPreferredAlignmentOfGlobal(
+ TD: LLVMTargetDataRef,
+ GlobalVar: LLVMValueRef,
+ ) -> ::libc::c_uint;
+ pub fn LLVMElementAtOffset(
+ TD: LLVMTargetDataRef,
+ StructTy: LLVMTypeRef,
+ Offset: ::libc::c_ulonglong,
+ ) -> ::libc::c_uint;
+ pub fn LLVMOffsetOfElement(
+ TD: LLVMTargetDataRef,
+ StructTy: LLVMTypeRef,
+ Element: ::libc::c_uint,
+ ) -> ::libc::c_ulonglong;
+ pub fn LLVMDisposeTargetData(TD: LLVMTargetDataRef);
+}
+
+// Functions from our target wrappers, since the C interface defines them with
+// macros (wrappers/target.c).
+extern "C" {
+ pub fn LLVM_InitializeAllTargetInfos();
+ pub fn LLVM_InitializeAllTargets();
+ pub fn LLVM_InitializeAllTargetMCs();
+ pub fn LLVM_InitializeAllAsmPrinters();
+ pub fn LLVM_InitializeAllAsmParsers();
+ pub fn LLVM_InitializeAllDisassemblers();
+
+ /// Returns 1 on failure.
+ pub fn LLVM_InitializeNativeTarget() -> LLVMBool;
+ /// Returns 1 on failure.
+ pub fn LLVM_InitializeNativeAsmParser() -> LLVMBool;
+ /// Returns 1 on failure.
+ pub fn LLVM_InitializeNativeAsmPrinter() -> LLVMBool;
+ /// Returns 1 on failure.
+ pub fn LLVM_InitializeNativeDisassembler() -> LLVMBool;
+}
diff --git a/ext/llvm-sys.rs/src/target_machine.rs b/ext/llvm-sys.rs/src/target_machine.rs
new file mode 100644
index 0000000..6189db2
--- /dev/null
+++ b/ext/llvm-sys.rs/src/target_machine.rs
@@ -0,0 +1,111 @@
+//! Target machine information, to generate assembly or object files.
+
+use super::prelude::*;
+use super::target::LLVMTargetDataRef;
+
+#[derive(Debug)]
+pub enum LLVMOpaqueTargetMachine {}
+
+pub type LLVMTargetMachineRef = *mut LLVMOpaqueTargetMachine;
+
+#[derive(Debug)]
+pub enum LLVMTarget {}
+
+pub type LLVMTargetRef = *mut LLVMTarget;
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMCodeGenOptLevel {
+ LLVMCodeGenLevelNone = 0,
+ LLVMCodeGenLevelLess = 1,
+ LLVMCodeGenLevelDefault = 2,
+ LLVMCodeGenLevelAggressive = 3,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMRelocMode {
+ LLVMRelocDefault = 0,
+ LLVMRelocStatic = 1,
+ LLVMRelocPIC = 2,
+ LLVMRelocDynamicNoPic = 3,
+ LLVMRelocROPI = 4,
+ LLVMRelocRWPI = 5,
+ LLVMRelocROPI_RWPI = 6,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMCodeModel {
+ LLVMCodeModelDefault = 0,
+ LLVMCodeModelJITDefault = 1,
+ LLVMCodeModelTiny = 2,
+ LLVMCodeModelSmall = 3,
+ LLVMCodeModelKernel = 4,
+ LLVMCodeModelMedium = 5,
+ LLVMCodeModelLarge = 6,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum LLVMCodeGenFileType {
+ LLVMAssemblyFile = 0,
+ LLVMObjectFile = 1,
+}
+
+extern "C" {
+ pub fn LLVMGetFirstTarget() -> LLVMTargetRef;
+ pub fn LLVMGetNextTarget(T: LLVMTargetRef) -> LLVMTargetRef;
+ pub fn LLVMGetTargetFromName(Name: *const ::libc::c_char) -> LLVMTargetRef;
+ pub fn LLVMGetTargetFromTriple(
+ Triple: *const ::libc::c_char,
+ T: *mut LLVMTargetRef,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMGetTargetName(T: LLVMTargetRef) -> *const ::libc::c_char;
+ pub fn LLVMGetTargetDescription(T: LLVMTargetRef) -> *const ::libc::c_char;
+ pub fn LLVMTargetHasJIT(T: LLVMTargetRef) -> LLVMBool;
+ pub fn LLVMTargetHasTargetMachine(T: LLVMTargetRef) -> LLVMBool;
+ pub fn LLVMTargetHasAsmBackend(T: LLVMTargetRef) -> LLVMBool;
+ pub fn LLVMCreateTargetMachine(
+ T: LLVMTargetRef,
+ Triple: *const ::libc::c_char,
+ CPU: *const ::libc::c_char,
+ Features: *const ::libc::c_char,
+ Level: LLVMCodeGenOptLevel,
+ Reloc: LLVMRelocMode,
+ CodeModel: LLVMCodeModel,
+ ) -> LLVMTargetMachineRef;
+ pub fn LLVMDisposeTargetMachine(T: LLVMTargetMachineRef);
+ pub fn LLVMGetTargetMachineTarget(T: LLVMTargetMachineRef) -> LLVMTargetRef;
+ pub fn LLVMGetTargetMachineTriple(T: LLVMTargetMachineRef) -> *mut ::libc::c_char;
+ pub fn LLVMGetTargetMachineCPU(T: LLVMTargetMachineRef) -> *mut ::libc::c_char;
+ pub fn LLVMGetTargetMachineFeatureString(T: LLVMTargetMachineRef) -> *mut ::libc::c_char;
+ /// Create a DataLayout based on the target machine.
+ pub fn LLVMCreateTargetDataLayout(T: LLVMTargetMachineRef) -> LLVMTargetDataRef;
+ pub fn LLVMSetTargetMachineAsmVerbosity(T: LLVMTargetMachineRef, VerboseAsm: LLVMBool);
+ pub fn LLVMTargetMachineEmitToFile(
+ T: LLVMTargetMachineRef,
+ M: LLVMModuleRef,
+ Filename: *mut ::libc::c_char,
+ codegen: LLVMCodeGenFileType,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ ) -> LLVMBool;
+ pub fn LLVMTargetMachineEmitToMemoryBuffer(
+ T: LLVMTargetMachineRef,
+ M: LLVMModuleRef,
+ codegen: LLVMCodeGenFileType,
+ ErrorMessage: *mut *mut ::libc::c_char,
+ OutMemBuf: *mut LLVMMemoryBufferRef,
+ ) -> LLVMBool;
+
+ pub fn LLVMGetDefaultTargetTriple() -> *mut ::libc::c_char;
+ /// Normalize a target triple. The result needs to be disposed with LLVMDisposeMessage.
+ pub fn LLVMNormalizeTargetTriple(triple: *const ::libc::c_char) -> *mut ::libc::c_char;
+ /// Get the host CPU as a string. The result needs to be disposed with LLVMDisposeMessage.
+ pub fn LLVMGetHostCPUName() -> *mut ::libc::c_char;
+ /// Get the host CPU's features as a string. The result needs to be disposed with LLVMDisposeMessage.
+ pub fn LLVMGetHostCPUFeatures() -> *mut ::libc::c_char;
+
+ pub fn LLVMAddAnalysisPasses(T: LLVMTargetMachineRef, PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms.rs b/ext/llvm-sys.rs/src/transforms.rs
new file mode 100644
index 0000000..2d8f0b0
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms.rs
@@ -0,0 +1,8 @@
+use super::*;
+
+// Util
+extern "C" {
+ pub fn LLVMAddLowerSwitchPass(PM: LLVMPassManagerRef );
+
+pub fn LLVMAddPromoteMemoryToRegisterPass(PM: LLVMPassManagerRef );
+}
diff --git a/ext/llvm-sys.rs/src/transforms/aggressive_instcombine.rs b/ext/llvm-sys.rs/src/transforms/aggressive_instcombine.rs
new file mode 100644
index 0000000..e3bebde
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/aggressive_instcombine.rs
@@ -0,0 +1,5 @@
+use prelude::*;
+
+extern "C" {
+ pub fn LLVMAddAggressiveInstCombinerPass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/instcombine.rs b/ext/llvm-sys.rs/src/transforms/instcombine.rs
new file mode 100644
index 0000000..afc0269
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/instcombine.rs
@@ -0,0 +1,5 @@
+use super::super::prelude::*;
+
+extern "C" {
+ pub fn LLVMAddInstructionCombiningPass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/ipo.rs b/ext/llvm-sys.rs/src/transforms/ipo.rs
new file mode 100644
index 0000000..17c470b
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/ipo.rs
@@ -0,0 +1,25 @@
+//! Interprocedural transformations of LLVM IR.
+
+use super::super::prelude::*;
+
+extern "C" {
+ pub fn LLVMAddConstantMergePass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddMergeFunctionsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddCalledValuePropagationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddDeadArgEliminationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddFunctionAttrsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddFunctionInliningPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddAlwaysInlinerPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddGlobalDCEPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddGlobalOptimizerPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddPruneEHPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddIPSCCPPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddInternalizePass(arg1: LLVMPassManagerRef, AllButMain: ::libc::c_uint);
+ pub fn LLVMAddInternalizePassWithMustPreservePredicate(
+ PM: LLVMPassManagerRef,
+ Context: *mut ::libc::c_void,
+ MustPreserve: Option<extern "C" fn(LLVMValueRef, *mut ::libc::c_void) -> LLVMBool>,
+ );
+ pub fn LLVMAddStripDeadPrototypesPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddStripSymbolsPass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/pass_builder.rs b/ext/llvm-sys.rs/src/transforms/pass_builder.rs
new file mode 100644
index 0000000..42c4d94
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/pass_builder.rs
@@ -0,0 +1,64 @@
+#![allow(non_snake_case)]
+
+use super::super::prelude::*;
+use error::LLVMErrorRef;
+use target_machine::LLVMTargetMachineRef;
+
+#[derive(Debug)]
+pub enum LLVMOpaquePassBuilderOptions {}
+pub type LLVMPassBuilderOptionsRef = *mut LLVMOpaquePassBuilderOptions;
+
+extern "C" {
+ pub fn LLVMRunPasses(
+ M: LLVMModuleRef,
+ Passes: *const ::libc::c_char,
+ TM: LLVMTargetMachineRef,
+ Options: LLVMPassBuilderOptionsRef,
+ ) -> LLVMErrorRef;
+ pub fn LLVMCreatePassBuilderOptions() -> LLVMPassBuilderOptionsRef;
+ pub fn LLVMPassBuilderOptionsSetVerifyEach(
+ Options: LLVMPassBuilderOptionsRef,
+ VerifyEach: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetDebugLogging(
+ Options: LLVMPassBuilderOptionsRef,
+ DebugLogging: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetLoopInterleaving(
+ Options: LLVMPassBuilderOptionsRef,
+ LoopInterleaving: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetLoopVectorization(
+ Options: LLVMPassBuilderOptionsRef,
+ LoopVectorization: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetSLPVectorization(
+ Options: LLVMPassBuilderOptionsRef,
+ SLPVectorization: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetLoopUnrolling(
+ Options: LLVMPassBuilderOptionsRef,
+ LoopUnrolling: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(
+ Options: LLVMPassBuilderOptionsRef,
+ ForgetAllSCEVInLoopUnroll: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetLicmMssaOptCap(
+ Options: LLVMPassBuilderOptionsRef,
+ LicmMssaOptCap: ::libc::c_uint,
+ );
+ pub fn LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(
+ Options: LLVMPassBuilderOptionsRef,
+ LicmMssaNoAccForPromotionCap: ::libc::c_uint,
+ );
+ pub fn LLVMPassBuilderOptionsSetCallGraphProfile(
+ Options: LLVMPassBuilderOptionsRef,
+ CallGraphProfile: LLVMBool,
+ );
+ pub fn LLVMPassBuilderOptionsSetMergeFunctions(
+ Options: LLVMPassBuilderOptionsRef,
+ MergeFunctions: LLVMBool,
+ );
+ pub fn LLVMDisposePassBuilderOptions(Options: LLVMPassBuilderOptionsRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/pass_manager_builder.rs b/ext/llvm-sys.rs/src/transforms/pass_manager_builder.rs
new file mode 100644
index 0000000..61f5404
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/pass_manager_builder.rs
@@ -0,0 +1,43 @@
+use super::super::prelude::*;
+
+#[derive(Debug)]
+pub enum LLVMOpaquePassManagerBuilder {}
+
+pub type LLVMPassManagerBuilderRef = *mut LLVMOpaquePassManagerBuilder;
+
+extern "C" {
+ pub fn LLVMPassManagerBuilderCreate() -> LLVMPassManagerBuilderRef;
+ pub fn LLVMPassManagerBuilderDispose(PMB: LLVMPassManagerBuilderRef);
+ pub fn LLVMPassManagerBuilderSetOptLevel(
+ PMB: LLVMPassManagerBuilderRef,
+ OptLevel: ::libc::c_uint,
+ );
+ pub fn LLVMPassManagerBuilderSetSizeLevel(
+ PMB: LLVMPassManagerBuilderRef,
+ SizeLevel: ::libc::c_uint,
+ );
+ pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
+ PMB: LLVMPassManagerBuilderRef,
+ Value: LLVMBool,
+ );
+ pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
+ PMB: LLVMPassManagerBuilderRef,
+ Value: LLVMBool,
+ );
+ pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
+ PMB: LLVMPassManagerBuilderRef,
+ Value: LLVMBool,
+ );
+ pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
+ PMB: LLVMPassManagerBuilderRef,
+ Threshold: ::libc::c_uint,
+ );
+ pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
+ PMB: LLVMPassManagerBuilderRef,
+ PM: LLVMPassManagerRef,
+ );
+ pub fn LLVMPassManagerBuilderPopulateModulePassManager(
+ PMB: LLVMPassManagerBuilderRef,
+ PM: LLVMPassManagerRef,
+ );
+}
diff --git a/ext/llvm-sys.rs/src/transforms/scalar.rs b/ext/llvm-sys.rs/src/transforms/scalar.rs
new file mode 100644
index 0000000..d4e1a96
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/scalar.rs
@@ -0,0 +1,51 @@
+//! Scalar transformations of LLVM IR.
+
+use super::super::prelude::*;
+
+extern "C" {
+ pub fn LLVMAddAggressiveDCEPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddDCEPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddBitTrackingDCEPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddAlignmentFromAssumptionsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddCFGSimplificationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddDeadStoreEliminationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddScalarizerPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddMergedLoadStoreMotionPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddGVNPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddNewGVNPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddIndVarSimplifyPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddInstructionCombiningPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddInstructionSimplifyPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddJumpThreadingPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLICMPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopDeletionPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopIdiomPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopRotatePass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopRerollPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopUnrollPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLoopUnrollAndJamPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLowerAtomicPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddMemCpyOptPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddPartiallyInlineLibCallsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddReassociatePass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddSCCPPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddScalarReplAggregatesPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddScalarReplAggregatesPassSSA(PM: LLVMPassManagerRef);
+ pub fn LLVMAddScalarReplAggregatesPassWithThreshold(
+ PM: LLVMPassManagerRef,
+ Threshold: ::libc::c_int,
+ );
+ pub fn LLVMAddSimplifyLibCallsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddTailCallEliminationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddDemoteMemoryToRegisterPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddVerifierPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddCorrelatedValuePropagationPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddEarlyCSEPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddEarlyCSEMemSSAPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLowerExpectIntrinsicPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddLowerConstantIntrinsicsPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddScopedNoAliasAAPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddBasicAliasAnalysisPass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddUnifyFunctionExitNodesPass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/util.rs b/ext/llvm-sys.rs/src/transforms/util.rs
new file mode 100644
index 0000000..6193902
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/util.rs
@@ -0,0 +1,9 @@
+use super::super::prelude::*;
+
+extern "C" {
+ pub fn LLVMAddLowerSwitchPass(PM: LLVMPassManagerRef);
+
+ pub fn LLVMAddPromoteMemoryToRegisterPass(PM: LLVMPassManagerRef);
+
+ pub fn LLVMAddAddDiscriminatorsPass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/src/transforms/vectorize.rs b/ext/llvm-sys.rs/src/transforms/vectorize.rs
new file mode 100644
index 0000000..2a4bd9c
--- /dev/null
+++ b/ext/llvm-sys.rs/src/transforms/vectorize.rs
@@ -0,0 +1,8 @@
+//! Vectorization transformations of LLVM IR.
+
+use super::super::prelude::*;
+
+extern "C" {
+ pub fn LLVMAddLoopVectorizePass(PM: LLVMPassManagerRef);
+ pub fn LLVMAddSLPVectorizePass(PM: LLVMPassManagerRef);
+}
diff --git a/ext/llvm-sys.rs/wrappers/target.c b/ext/llvm-sys.rs/wrappers/target.c
new file mode 100644
index 0000000..66035c1
--- /dev/null
+++ b/ext/llvm-sys.rs/wrappers/target.c
@@ -0,0 +1,48 @@
+/* llvm-c/Target.h helper functions wrappers.
+ *
+ * The LLVMInitializeAll* functions and friends are defined `static inline`, so
+ * we can't bind directly to them (the function body is generated via macro),
+ * so here are some wrappers.
+ */
+#include <llvm-c/Target.h>
+
+void LLVM_InitializeAllTargetInfos(void) {
+ LLVMInitializeAllTargetInfos();
+}
+
+void LLVM_InitializeAllTargets(void) {
+ LLVMInitializeAllTargets();
+}
+
+void LLVM_InitializeAllTargetMCs(void) {
+ LLVMInitializeAllTargetMCs();
+}
+
+void LLVM_InitializeAllAsmPrinters(void) {
+ LLVMInitializeAllAsmPrinters();
+}
+
+void LLVM_InitializeAllAsmParsers(void) {
+ LLVMInitializeAllAsmParsers();
+}
+
+void LLVM_InitializeAllDisassemblers(void) {
+ LLVMInitializeAllDisassemblers();
+}
+
+/* These functions return true on failure. */
+LLVMBool LLVM_InitializeNativeTarget(void) {
+ return LLVMInitializeNativeTarget();
+}
+
+LLVMBool LLVM_InitializeNativeAsmParser(void) {
+ return LLVMInitializeNativeAsmParser();
+}
+
+LLVMBool LLVM_InitializeNativeAsmPrinter(void) {
+ return LLVMInitializeNativeAsmPrinter();
+}
+
+LLVMBool LLVM_InitializeNativeDisassembler(void) {
+ return LLVMInitializeNativeDisassembler();
+}
diff --git a/ext/optix_ext/README.md b/ext/optix_ext/README.md
new file mode 100644
index 0000000..3214139
--- /dev/null
+++ b/ext/optix_ext/README.md
@@ -0,0 +1,10 @@
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__compile__no__inline_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__compile__no__inline__function__table__definition_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__compile__no__inline__stubs_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__knobs_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__knobs__function__table__definition_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__knobs__stubs_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__ptx__encryption_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__ptx__encryption__function__table__definition_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__ptx__encryption__stubs_8h_source.html
+https://raytracing-docs.nvidia.com/optix6/api_6_5/html/optix__ext__ptx__encryption__utilities_8h_source.html \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_compile_no_inline.h b/ext/optix_ext/optix_ext_compile_no_inline.h
new file mode 100644
index 0000000..9d39161
--- /dev/null
+++ b/ext/optix_ext/optix_ext_compile_no_inline.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_compile_no_inline_h__
+#define __optix_optix_ext_compile_no_inline_h__
+
+#include <optix_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// This will enable or disable the compilation of non-inlined functions as seen by OptiX in any known modules.
+// The property cannot be changed after the compilation of the first module.
+OptixResult optixExtCompileNoInlineSetEnabled( OptixDeviceContext contextAPI, bool enabled );
+// Query the current value, i.e., whether or not the compilation of non-inlined functions is enabled.
+bool optixExtCompileNoInlineIsEnabled( OptixDeviceContext contextAPI );
+
+
+#ifdef OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+// When changing the ABI version make sure you know exactly what you are doing. See
+// apps/optix/exp/functionTable/functionTable.cpp for instructions. See
+// https://confluence.nvidia.com/display/RAV/ABI+Versions+in+the+Wild for released ABI versions.
+#endif // OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+#define OPTIX_EXT_COMPILE_NO_INLINE_ABI_VERSION 3001
+
+typedef struct OptixExtCompileNoInlineFunctionTable
+{
+ OptixResult ( *optixExtCompileNoInlineSetEnabled )( OptixDeviceContext contextAPI, bool enabled );
+ bool ( *optixExtCompileNoInlineIsEnabled )( OptixDeviceContext contextAPI );
+
+} OptixExtCompileNoInlineFunctionTable;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_compile_no_inline_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_compile_no_inline_function_table_definition.h b/ext/optix_ext/optix_ext_compile_no_inline_function_table_definition.h
new file mode 100644
index 0000000..116cbab
--- /dev/null
+++ b/ext/optix_ext/optix_ext_compile_no_inline_function_table_definition.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_compile_no_inline_function_table_definition_h__
+#define __optix_optix_ext_compile_no_inline_function_table_definition_h__
+
+#include "optix_ext_compile_no_inline.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* If the stubs in optix_ext_compile_no_inline_stubs.h are used, then the function table needs to be
+ defined in exactly one translation unit. This can be achieved by including this header file in
+ that translation unit. */
+OptixExtCompileNoInlineFunctionTable g_optixExtCompileNoInlineFunctionTable;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_compile_no_inline_function_table_definition_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_compile_no_inline_stubs.h b/ext/optix_ext/optix_ext_compile_no_inline_stubs.h
new file mode 100644
index 0000000..22c8c35
--- /dev/null
+++ b/ext/optix_ext/optix_ext_compile_no_inline_stubs.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of NVIDIA CORPORATION nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __optix_optix_ext_compile_no_inline_stubs_h__
+#define __optix_optix_ext_compile_no_inline_stubs_h__
+
+#include "optix_ext_compile_no_inline.h"
+
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The function table needs to be defined in exactly one translation unit. This can be
+ achieved by including optix_ext_compile_no_inline_function_table_definition.h in that translation unit.
+ */
+extern OptixExtCompileNoInlineFunctionTable g_optixExtCompileNoInlineFunctionTable;
+
+// Initializes the function table used by the stubs for the extension API for compile_no_inline.
+//
+// The function requires a handle to the loaded OptiX library. This handle can be obtained by using
+// optixInitWithHandle() instead of optixInit(), for example (error handling ommitted):
+//
+// void* handle;
+// optixInitWithHandle( &handle );
+// optixExtCompileNoInlineInit( handle );
+//
+inline OptixResult optixExtCompileNoInlineInit( void* handle )
+{
+ if( !handle )
+ return OPTIX_ERROR_INVALID_VALUE;
+
+#ifdef _WIN32
+ void* symbol = GetProcAddress( (HMODULE)handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#else
+ void* symbol = dlsym( handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#endif
+
+ OptixQueryFunctionTable_t* optixQueryFunctionTable = (OptixQueryFunctionTable_t*)symbol;
+
+ return optixQueryFunctionTable( OPTIX_EXT_COMPILE_NO_INLINE_ABI_VERSION, 0, 0, 0, &g_optixExtCompileNoInlineFunctionTable,
+ sizeof( g_optixExtCompileNoInlineFunctionTable ) );
+}
+
+/* Stub functions that forward calls to the corresponding function pointer in the function table. */
+
+inline OptixResult optixExtCompileNoInlineSetEnabled( OptixDeviceContext contextAPI, bool enabled )
+{
+ return g_optixExtCompileNoInlineFunctionTable.optixExtCompileNoInlineSetEnabled( contextAPI, enabled );
+}
+
+inline bool optixExtCompileNoInlineIsEnabled( OptixDeviceContext contextAPI )
+{
+ return g_optixExtCompileNoInlineFunctionTable.optixExtCompileNoInlineIsEnabled( contextAPI );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_compile_no_inline_stubs_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_knobs.h b/ext/optix_ext/optix_ext_knobs.h
new file mode 100644
index 0000000..ac86018
--- /dev/null
+++ b/ext/optix_ext/optix_ext_knobs.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_knobs_h__
+#define __optix_optix_ext_knobs_h__
+
+#include <optix_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// Sets values of multiple knobs based on some configuration file.
+//
+// Comments start with two slashes and are stripped. Whitespace at the begin and end of each line is also stripped.
+// Empty lines are ignored. The first non-whitespace to whitespace transition marks the end of the name of the knob,
+// the following whitespace is also stripped. The remainder of the line is the value of the knob, unless it is quoted
+// by double apostrophes, which are also stripped.
+//
+// This method can only be used before the first device context has been created.
+OptixResult optixExtKnobsSetKnobsFromFile( const char* filename );
+
+// Sets the value of a single knob.
+//
+// This method can only be used before the first device context has been created.
+OptixResult optixExtKnobsSetKnob( const char* name, const char* value );
+
+
+#ifdef OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+// When changing the ABI version make sure you know exactly what you are doing. See
+// apps/optix/exp/functionTable/functionTable.cpp for instructions. See
+// https://confluence.nvidia.com/display/RAV/ABI+Versions+in+the+Wild for released ABI versions.
+#endif // OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+#define OPTIX_EXT_KNOBS_ABI_VERSION 1001
+
+typedef struct OptixExtKnobsFunctionTable
+{
+ OptixResult ( *optixExtKnobsSetKnobsFromFile )( const char* filename );
+
+ OptixResult ( *optixExtKnobsSetKnob )( const char* name, const char* value );
+
+} OptixExtKnobsFunctionTable;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_knobs_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_knobs_function_table_definition.h b/ext/optix_ext/optix_ext_knobs_function_table_definition.h
new file mode 100644
index 0000000..30bdde8
--- /dev/null
+++ b/ext/optix_ext/optix_ext_knobs_function_table_definition.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_knobs_function_table_definition_h__
+#define __optix_optix_ext_knobs_function_table_definition_h__
+
+#include "optix_ext_knobs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* If the stubs in optix_ext_knobs_stubs.h are used, then the function table needs to be
+ defined in exactly one translation unit. This can be achieved by including this header file in
+ that translation unit. */
+OptixExtKnobsFunctionTable g_optixExtKnobsFunctionTable;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_knobs_function_table_definition_h__ */
diff --git a/ext/optix_ext/optix_ext_knobs_stubs.h b/ext/optix_ext/optix_ext_knobs_stubs.h
new file mode 100644
index 0000000..18e1837
--- /dev/null
+++ b/ext/optix_ext/optix_ext_knobs_stubs.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of NVIDIA CORPORATION nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __optix_optix_ext_knobs_stubs_h__
+#define __optix_optix_ext_knobs_stubs_h__
+
+#include "optix_ext_knobs.h"
+
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The function table needs to be defined in exactly one translation unit. This can be
+ achieved by including optix_ext_knobs_function_table_definition.h in that translation unit.
+ */
+extern OptixExtKnobsFunctionTable g_optixExtKnobsFunctionTable;
+
+// Initializes the function table used by the stubs for the extension API for knobs.
+//
+// The function requires a handle to the loaded OptiX library. This handle can be obtained by using
+// optixInitWithHandle() instead of optixInit(), for example (error handling ommitted):
+//
+// void* handle;
+// optixInitWithHandle( &handle );
+// optixExtKnobsInit( handle );
+//
+inline OptixResult optixExtKnobsInit( void* handle )
+{
+ if( !handle )
+ return OPTIX_ERROR_INVALID_VALUE;
+
+#ifdef _WIN32
+ void* symbol = GetProcAddress( (HMODULE)handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#else
+ void* symbol = dlsym( handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#endif
+
+ OptixQueryFunctionTable_t* optixQueryFunctionTable = (OptixQueryFunctionTable_t*)symbol;
+
+ return optixQueryFunctionTable( OPTIX_EXT_KNOBS_ABI_VERSION, 0, 0, 0, &g_optixExtKnobsFunctionTable,
+ sizeof( g_optixExtKnobsFunctionTable ) );
+}
+
+/* Stub functions that forward calls to the corresponding function pointer in the function table. */
+
+inline OptixResult optixExtKnobsSetKnobsFromFile( const char* filename )
+{
+ return g_optixExtKnobsFunctionTable.optixExtKnobsSetKnobsFromFile( filename );
+}
+
+inline OptixResult optixExtKnobsSetKnob( const char* name, const char* value )
+{
+ return g_optixExtKnobsFunctionTable.optixExtKnobsSetKnob( name, value );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_knobs_stubs_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_ptx_encryption.h b/ext/optix_ext/optix_ext_ptx_encryption.h
new file mode 100644
index 0000000..23cc62b
--- /dev/null
+++ b/ext/optix_ext/optix_ext_ptx_encryption.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_ptx_encryption_h__
+#define __optix_optix_ext_ptx_encryption_h__
+
+#include <optix_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// Returns the OptiX salt for PTX encryption. The buffer for the salt value must consist of 32 bytes.
+//
+// Instead of using this function directly, consider using the C++ interface optix::PtxEncryption. This utility class
+// also takes care of computing the session key needed for encryption.
+OptixResult optixExtPtxEncryptionGetOptixSalt( OptixDeviceContext context, void* optixSalt, size_t optixSaltSizeInBytes );
+
+// Sets the OptiX salt for PTX encryption. The salt value must consist of 32 bytes.
+//
+// Instead of using this function directly, consider using the C++ interface optix::PtxEncryption. This utility class
+// also takes care of computing the session key needed for encryption.
+OptixResult optixExtPtxEncryptionSetOptixSalt( OptixDeviceContext context, const void* optixSalt, size_t optixSaltSizeInBytes );
+
+// Sets the vendor salt for PTX encryption. The salt value must consist of 32 bytes.
+//
+// Instead of using this function directly, consider using the C++ interface optix::PtxEncryption. This utility class
+// also takes care of computing the session key needed for encryption.
+OptixResult optixExtPtxEncryptionSetVendorSalt( OptixDeviceContext context, const void* vendorSalt, size_t vendorSaltSizeInBytes );
+
+// Sets the public vendor key for PTX encryption.
+//
+// Instead of using this function directly, consider using the C++ interface optix::PtxEncryption. This utility class
+// also takes care of computing the session key needed for encryption.
+OptixResult optixExtPtxEncryptionSetPublicVendorKey( OptixDeviceContext context, const void* publicVendorKey, size_t publicVendorKeySizeInBytes );
+
+
+#ifdef OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+// When changing the ABI version make sure you know exactly what you are doing. See
+// apps/optix/exp/functionTable/functionTable.cpp for instructions. See
+// https://confluence.nvidia.com/display/RAV/ABI+Versions+in+the+Wild for released ABI versions.
+#endif // OPTIX_OPTIONAL_FEATURE_OPTIX7_INTERNAL_DOCUMENTATION
+#define OPTIX_EXT_PTX_ENCRYPTION_ABI_VERSION 2001
+
+typedef struct OptixExtPtxEncryptionFunctionTable
+{
+ OptixResult ( *optixExtPtxEncryptionGetOptixSalt )( OptixDeviceContext context, void* optixSalt, size_t optixSaltSizeInBytes );
+
+ OptixResult ( *optixExtPtxEncryptionSetOptixSalt )( OptixDeviceContext context, const void* optixSalt, size_t optixSaltSizeInBytes );
+
+ OptixResult ( *optixExtPtxEncryptionSetVendorSalt )( OptixDeviceContext context, const void* vendorSalt, size_t vendorSaltSizeInBytes );
+
+ OptixResult ( *optixExtPtxEncryptionSetPublicVendorKey )( OptixDeviceContext context,
+ const void* publicVendorKey,
+ size_t publicVendorKeySizeInBytes );
+
+} OptixExtPtxEncryptionFunctionTable;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_ptx_encryption_h__ */ \ No newline at end of file
diff --git a/ext/optix_ext/optix_ext_ptx_encryption_function_table_definition.h b/ext/optix_ext/optix_ext_ptx_encryption_function_table_definition.h
new file mode 100644
index 0000000..35415ac
--- /dev/null
+++ b/ext/optix_ext/optix_ext_ptx_encryption_function_table_definition.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+ * rights in and to this software, related documentation and any modifications thereto.
+ * Any use, reproduction, disclosure or distribution of this software and related
+ * documentation without an express license agreement from NVIDIA Corporation is strictly
+ * prohibited.
+ *
+ * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
+ * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
+ * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
+ * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGES
+ */
+
+#ifndef __optix_optix_ext_ptx_encryption_function_table_definition_h__
+#define __optix_optix_ext_ptx_encryption_function_table_definition_h__
+
+#include "optix_ext_ptx_encryption.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* If the stubs in optix_ext_ptx_encryption_stubs.h are used, then the function table needs to be
+ defined in exactly one translation unit. This can be achieved by including this header file in
+ that translation unit. */
+OptixExtPtxEncryptionFunctionTable g_optixExtPtxEncryptionFunctionTable;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_ptx_encryption_function_table_definition_h__ */
diff --git a/ext/optix_ext/optix_ext_ptx_encryption_stubs.h b/ext/optix_ext/optix_ext_ptx_encryption_stubs.h
new file mode 100644
index 0000000..4157d95
--- /dev/null
+++ b/ext/optix_ext/optix_ext_ptx_encryption_stubs.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of NVIDIA CORPORATION nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __optix_optix_ext_ptx_encryption_stubs_h__
+#define __optix_optix_ext_ptx_encryption_stubs_h__
+
+#include "optix_ext_ptx_encryption.h"
+
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The function table needs to be defined in exactly one translation unit. This can be
+ achieved by including optix_ext_ptx_encryption_function_table_definition.h in that translation unit.
+ */
+extern OptixExtPtxEncryptionFunctionTable g_optixExtPtxEncryptionFunctionTable;
+
+// Initializes the function table used by the stubs for the extension API for PTX encryption.
+//
+// The function requires a handle to the loaded OptiX library. This handle can be obtained by using
+// optixInitWithHandle() instead of optixInit(), for example (error handling ommitted):
+//
+// void* handle;
+// optixInitWithHandle( &handle );
+// optixExtPtxEncryptionInit( handle );
+//
+inline OptixResult optixExtPtxEncryptionInit( void* handle )
+{
+ if( !handle )
+ return OPTIX_ERROR_INVALID_VALUE;
+
+#ifdef _WIN32
+ void* symbol = GetProcAddress( (HMODULE)handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#else
+ void* symbol = dlsym( handle, "optixQueryFunctionTable" );
+ if( !symbol )
+ return OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND;
+#endif
+
+ OptixQueryFunctionTable_t* optixQueryFunctionTable = (OptixQueryFunctionTable_t*)symbol;
+
+ return optixQueryFunctionTable( OPTIX_EXT_PTX_ENCRYPTION_ABI_VERSION, 0, 0, 0, &g_optixExtPtxEncryptionFunctionTable,
+ sizeof( g_optixExtPtxEncryptionFunctionTable ) );
+}
+
+/* Stub functions that forward calls to the corresponding function pointer in the function table. */
+
+inline OptixResult optixExtPtxEncryptionGetOptixSalt( OptixDeviceContext context, void* optixSalt, size_t optixSaltSizeInBytes )
+{
+ return g_optixExtPtxEncryptionFunctionTable.optixExtPtxEncryptionGetOptixSalt( context, optixSalt, optixSaltSizeInBytes );
+}
+
+inline OptixResult optixExtPtxEncryptionSetOptixSalt( OptixDeviceContext context, const void* optixSalt, size_t optixSaltSizeInBytes )
+{
+ return g_optixExtPtxEncryptionFunctionTable.optixExtPtxEncryptionSetOptixSalt( context, optixSalt, optixSaltSizeInBytes );
+}
+
+inline OptixResult optixExtPtxEncryptionSetVendorSalt( OptixDeviceContext context, const void* vendorSalt, size_t vendorSaltSizeInBytes )
+{
+ return g_optixExtPtxEncryptionFunctionTable.optixExtPtxEncryptionSetVendorSalt( context, vendorSalt, vendorSaltSizeInBytes );
+}
+
+inline OptixResult optixExtPtxEncryptionSetPublicVendorKey( OptixDeviceContext context, const void* publicVendorKey, size_t publicVendorKeySizeInBytes )
+{
+ return g_optixExtPtxEncryptionFunctionTable.optixExtPtxEncryptionSetPublicVendorKey( context, publicVendorKey,
+ publicVendorKeySizeInBytes );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __optix_optix_ext_ptx_encryption_stubs_h__ */
diff --git a/ext/optix_ext/optix_ptx_encryption.h b/ext/optix_ext/optix_ptx_encryption.h
new file mode 100644
index 0000000..0168723
--- /dev/null
+++ b/ext/optix_ext/optix_ptx_encryption.h
@@ -0,0 +1,416 @@
+// Copyright (c) 2017, NVIDIA CORPORATION.
+// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+// *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+// BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+// WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+// BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+// ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+// BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+#pragma once
+
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#undef min
+#undef max
+#undef IGNORE
+#else
+#include <cstdlib>
+#include <ctime>
+#include <sys/time.h>
+#endif
+
+#include <cassert>
+#include <cstdint>
+#include <cstring>
+#include <vector>
+
+#ifndef OPTIX_PTX_ENCRYPTION_STANDALONE
+#include <optixu/optixpp_namespace.h>
+#endif // OPTIX_PTX_ENCRYPTION_STANDALONE
+
+namespace optix {
+
+#ifndef OPTIX_PTX_ENCRYPTION_STANDALONE
+
+class PtxEncryption
+{
+ public:
+ PtxEncryption( RTcontext context, const char* publicVendorKey, const char* secretVendorKey );
+
+ PtxEncryption( Context context, const char* publicVendorKey, const char* secretVendorKey );
+
+ PtxEncryption( RTcontext context, const char* publicVendorKey, const char* secretVendorKey, const char* optixSalt, const char* vendorSalt );
+
+ PtxEncryption( Context context, const char* publicVendorKey, const char* secretVendorKey, const char* optixSalt, const char* vendorSalt );
+
+ ::std::string encrypt( const ::std::string& ptx ) const;
+
+ static ::std::string getPrefix() { return "eptx0001"; }
+
+ private:
+ // Magic number used by the TEA algorithm.
+ static const uint32_t MAGIC = 0x9e3779b9;
+ // Uses TEA to encrypt 8 bytes v[0] and v[1] using the key k.
+ static void encryptTeaBlock( uint32_t* v, const uint32_t k[4] );
+ // Uses TEA to encrypt \p sz bytes at \p data using the key \p key.
+ static void encryptTea( unsigned char* data, size_t sz, const uint32_t key[4] );
+ // Encodes the given string to ensure that it does not contain any null bytes.
+ static ::std::string encode( const ::std::vector<unsigned char>& input );
+
+ // The session key used by #encrypt().
+ ::std::vector<unsigned char> m_sessionKey;
+};
+
+#endif // OPTIX_PTX_ENCRYPTION_STANDALONE
+
+namespace detail {
+
+// Generates a salt.
+//
+// \param[out] buffer The buffer for the salt. Needs to be able to hold 32 bytes.
+void generateSalt( unsigned char* buffer );
+
+// Computes a SHA256 hash value.
+//
+// \param input The input for which to compute the SHA256 hash value.
+// \param input_length The size of the input.
+// \param[out] buffer The buffer for the SHA256 hash value. Needs to be able to hold 32 bytes.
+void sha256( const unsigned char* input, unsigned int input_length, unsigned char* buffer );
+
+} // end namespace detail
+
+#ifndef OPTIX_PTX_ENCRYPTION_STANDALONE
+
+// Magic key used to obfuscate the last incomplete block.
+const unsigned char KEY[7] = {164, 195, 147, 255, 203, 161, 184};
+
+inline PtxEncryption::PtxEncryption( RTcontext context, const char* publicVendorKey, const char* secretVendorKeyHex )
+{
+ // Get optix salt
+ const size_t optixSaltLength = 32;
+ unsigned char optixSalt[optixSaltLength];
+ RTresult result = rtContextGetAttribute( context, RT_CONTEXT_ATTRIBUTE_OPTIX_SALT, 32, &optixSalt[0] );
+ assert( result == RT_SUCCESS );
+ (void)result;
+
+ // Generate and set vendor salt
+ const size_t vendorSaltLength = 32;
+ unsigned char vendorSalt[vendorSaltLength];
+ detail::generateSalt( &vendorSalt[0] );
+ result = rtContextSetAttribute( context, RT_CONTEXT_ATTRIBUTE_VENDOR_SALT, 32, &vendorSalt[0] );
+ assert( result == RT_SUCCESS );
+
+ // Set vendor public key
+ const size_t publicVendorKeyLength = strlen( publicVendorKey );
+ result = rtContextSetAttribute( context, RT_CONTEXT_ATTRIBUTE_PUBLIC_VENDOR_KEY, publicVendorKeyLength, &publicVendorKey[0] );
+ assert( result == RT_SUCCESS );
+
+ // Generate sessionKey = hash(optixSalt, secretVendorKeyHex, vendorSalt).
+ const size_t secretVendorKeyHexLength = strlen( secretVendorKeyHex );
+ const size_t sessionKeyInputLength = optixSaltLength + secretVendorKeyHexLength + vendorSaltLength;
+ ::std::vector<unsigned char> sessionKeyInput( sessionKeyInputLength );
+ memcpy( &sessionKeyInput[0], &optixSalt[0], optixSaltLength );
+ memcpy( &sessionKeyInput[optixSaltLength], secretVendorKeyHex, secretVendorKeyHexLength );
+ memcpy( &sessionKeyInput[optixSaltLength + secretVendorKeyHexLength], vendorSalt, vendorSaltLength );
+
+ m_sessionKey.resize( 32 );
+ detail::sha256( &sessionKeyInput[0], static_cast<unsigned int>( sessionKeyInputLength ), &m_sessionKey[0] );
+
+ for( size_t i = 0; i < 16; ++i )
+ m_sessionKey[i] += m_sessionKey[i + 16];
+ m_sessionKey.resize( 16 );
+}
+
+inline PtxEncryption::PtxEncryption( Context context, const char* publicVendorKey, const char* secretVendorKeyHex )
+ : PtxEncryption( context->get(), publicVendorKey, secretVendorKeyHex )
+{
+}
+
+inline PtxEncryption::PtxEncryption( RTcontext context,
+ const char* publicVendorKey,
+ const char* secretVendorKeyHex,
+ const char* optixSalt,
+ const char* vendorSalt )
+{
+ // Set optix salt
+ const size_t optixSaltLength = strlen( optixSalt );
+ RTresult result = rtContextSetAttribute( context, RT_CONTEXT_ATTRIBUTE_OPTIX_SALT, optixSaltLength, optixSalt );
+ assert( result == RT_SUCCESS );
+ (void)result;
+
+ // Set vendor salt
+ const size_t vendorSaltLength = strlen( vendorSalt );
+ result = rtContextSetAttribute( context, RT_CONTEXT_ATTRIBUTE_VENDOR_SALT, vendorSaltLength, vendorSalt );
+ assert( result == RT_SUCCESS );
+
+ // Set vendor public key
+ const size_t publicVendorKeyLength = strlen( publicVendorKey );
+ result = rtContextSetAttribute( context, RT_CONTEXT_ATTRIBUTE_PUBLIC_VENDOR_KEY, publicVendorKeyLength, &publicVendorKey[0] );
+ assert( result == RT_SUCCESS );
+
+ // Generate sessionKey = hash(optixSalt, secretVendorKeyHex, vendorSalt).
+ const size_t secretVendorKeyHexLength = strlen( secretVendorKeyHex );
+ const size_t sessionKeyInputLength = optixSaltLength + secretVendorKeyHexLength + vendorSaltLength;
+ ::std::vector<unsigned char> sessionKeyInput( sessionKeyInputLength );
+ memcpy( &sessionKeyInput[0], &optixSalt[0], optixSaltLength );
+ memcpy( &sessionKeyInput[optixSaltLength], secretVendorKeyHex, secretVendorKeyHexLength );
+ memcpy( &sessionKeyInput[optixSaltLength + secretVendorKeyHexLength], vendorSalt, vendorSaltLength );
+
+ m_sessionKey.resize( 32 );
+ detail::sha256( &sessionKeyInput[0], static_cast<unsigned int>( sessionKeyInputLength ), &m_sessionKey[0] );
+
+ for( size_t i = 0; i < 16; ++i )
+ m_sessionKey[i] += m_sessionKey[i + 16];
+ m_sessionKey.resize( 16 );
+}
+
+inline PtxEncryption::PtxEncryption( Context context,
+ const char* publicVendorKey,
+ const char* secretVendorKeyHex,
+ const char* optixSalt,
+ const char* vendorSalt )
+ : PtxEncryption( context->get(), publicVendorKey, secretVendorKeyHex, optixSalt, vendorSalt )
+{
+}
+
+inline ::std::string PtxEncryption::encrypt( const ::std::string& ptx ) const
+{
+ uint32_t teaKey[4];
+ assert( m_sessionKey.size() == sizeof( teaKey ) );
+ memcpy( &teaKey[0], &m_sessionKey[0], sizeof( teaKey ) );
+
+ ::std::vector<unsigned char> result( ptx.size() );
+ memcpy( &result[0], &ptx[0], ptx.size() );
+ encryptTea( &result[0], result.size(), teaKey );
+
+ return getPrefix() + encode( result );
+}
+
+inline ::std::string PtxEncryption::encode( const ::std::vector<unsigned char>& input )
+{
+ ::std::string output;
+
+ // Replace '\0' by '\1\1' and '\1' by '\1\2'.
+ for( size_t i = 0; i < input.size(); ++i )
+ {
+ char c = input[i];
+ if( c == '\0' || c == '\1' )
+ {
+ output.push_back( '\1' );
+ output.push_back( c + 1 );
+ }
+ else
+ output.push_back( c );
+ }
+
+ return output;
+}
+
+inline void PtxEncryption::encryptTeaBlock( uint32_t* v, const uint32_t k[4] )
+{
+ uint32_t v0 = v[0];
+ uint32_t v1 = v[1];
+ uint32_t s0 = 0;
+
+ for( uint32_t n = 0; n < 16; n++ )
+ {
+ s0 += MAGIC;
+ v0 += ( ( v1 << 4 ) + k[0] ) ^ ( v1 + s0 ) ^ ( ( v1 >> 5 ) + k[1] );
+ v1 += ( ( v0 << 4 ) + k[2] ) ^ ( v0 + s0 ) ^ ( ( v0 >> 5 ) + k[3] );
+ }
+
+ v[0] = v0;
+ v[1] = v1;
+}
+
+inline void PtxEncryption::encryptTea( unsigned char* data, size_t sz, const uint32_t key[4] )
+{
+ // Encrypt 8 byte blocks with TEA
+ const size_t n = sz / static_cast<size_t>( 8 );
+ uint32_t* v = reinterpret_cast<uint32_t*>( data );
+ for( size_t i = 0; i < n; ++i )
+ encryptTeaBlock( &v[2 * i], key );
+
+ // Slightly obfuscate leftover bytes (at most 7) with simple xor.
+ for( size_t i = 8 * n, k = 0; i < sz; ++i, ++k )
+ data[i] = data[i] ^ KEY[k];
+}
+
+#endif // OPTIX_PTX_ENCRYPTION_STANDALONE
+
+namespace detail {
+
+inline void generateSalt( unsigned char* buffer )
+{
+ if( buffer == 0 )
+ return;
+
+ uint64_t number = 0;
+#ifdef _WIN32
+ srand( GetTickCount() );
+ LARGE_INTEGER tmp;
+ QueryPerformanceCounter( &tmp );
+ number += tmp.QuadPart + GetCurrentProcessId() + GetTickCount();
+#else
+ srand( static_cast<unsigned>( time( 0 ) ) );
+ struct timeval tv;
+ gettimeofday( &tv, 0 );
+ number += static_cast<uint64_t>( tv.tv_sec + tv.tv_usec );
+#endif
+
+ unsigned char buf[sizeof( uint32_t ) + 3 * sizeof( uint64_t )] = {0};
+ int r = rand();
+ memcpy( buf, &r, sizeof( uint32_t ) );
+ memcpy( buf + sizeof( uint32_t ), &number, sizeof( uint64_t ) );
+ memcpy( buf + sizeof( uint32_t ) + sizeof( uint64_t ), &number, sizeof( uint64_t ) );
+ number += static_cast<uint64_t>( rand() );
+ memcpy( buf + sizeof( uint32_t ) + 2 * sizeof( uint64_t ), &number, sizeof( uint64_t ) );
+ sha256( buf, static_cast<uint32_t>( sizeof( buf ) ), buffer );
+}
+
+namespace {
+
+// Table of round constants.
+// First 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311
+const uint32_t sha256_constants[] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4,
+ 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,
+ 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f,
+ 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
+ 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
+ 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116,
+ 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7,
+ 0xc67178f2};
+
+// Reverses the byte order of the bytes of \p x
+uint32_t flip32( uint32_t x )
+{
+ return ( ( ( (x)&0xff000000 ) >> 24 ) | ( ( (x)&0x00ff0000 ) >> 8 ) | ( ( (x)&0x0000ff00 ) << 8 )
+ | ( ( (x)&0x000000ff ) << 24 ) );
+}
+
+// Rotates the bits of \p x to the right by \p y bits
+uint32_t rightrotate( uint32_t x, uint32_t y )
+{
+ return ( ( x >> y ) | ( x << ( 32 - y ) ) );
+}
+
+} // end namespace
+
+inline void sha256( const unsigned char* input, unsigned int input_length, unsigned char* buffer )
+{
+ if( ( input_length <= 0 ) || ( input == 0 ) || ( buffer == 0 ) )
+ return;
+
+ // First 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
+ uint32_t state[] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
+
+ // k is the number of '0' bits >= 0 such that the resulting message length is 448 (mod 512)
+ unsigned int r = ( input_length * 8 + 1 ) % 512;
+ unsigned int k = r > 448 ? 960 - r : 448 - r;
+
+ unsigned int pos = 0;
+ for( unsigned int chunk = 0; k != 0; ++chunk )
+ {
+ uint32_t W[64] = {0};
+ uint8_t* ptr = reinterpret_cast<uint8_t*>( W );
+ unsigned int to_copy = input_length - pos;
+ to_copy = to_copy > 64 ? 64 : to_copy;
+ if( to_copy > 0 )
+ {
+ memcpy( ptr, input + pos, to_copy );
+ pos += to_copy;
+ }
+
+ // If we are at the end of input message
+ if( pos == input_length )
+ {
+ // If we still have not padded and have space to add a 1, add it
+ if( ( k > 0 ) && ( pos / 64 == chunk ) )
+ ptr[pos % 64] |= static_cast<uint8_t>( 0x80 );
+ // If we can pad and still have space to add the length, add it
+ if( ( pos * 8 + 1 + k ) - ( chunk * 512 ) <= 448 )
+ {
+ uint64_t value = input_length * 8;
+ ptr = reinterpret_cast<uint8_t*>( &W[14] );
+ ptr[0] = static_cast<uint8_t>( ( value >> 56 ) & 0xff );
+ ptr[1] = static_cast<uint8_t>( ( value >> 48 ) & 0xff );
+ ptr[2] = static_cast<uint8_t>( ( value >> 40 ) & 0xff );
+ ptr[3] = static_cast<uint8_t>( ( value >> 32 ) & 0xff );
+ ptr[4] = static_cast<uint8_t>( ( value >> 24 ) & 0xff );
+ ptr[5] = static_cast<uint8_t>( ( value >> 16 ) & 0xff );
+ ptr[6] = static_cast<uint8_t>( ( value >> 8 ) & 0xff );
+ ptr[7] = static_cast<uint8_t>( value & 0xff );
+ k = 0;
+ }
+ }
+
+ // Flip to big endian
+ for( int i = 0; i < 16; ++i )
+ W[i] = flip32( W[i] );
+
+ // Extend the sixteen 32-bit words into 64 32-bit words
+ for( uint32_t i = 16; i < 64; ++i )
+ {
+ uint32_t s0 = rightrotate( W[i - 15], 7 ) ^ rightrotate( W[i - 15], 18 ) ^ ( W[i - 15] >> 3 );
+ uint32_t s1 = rightrotate( W[i - 2], 17 ) ^ rightrotate( W[i - 2], 19 ) ^ ( W[i - 2] >> 10 );
+ W[i] = W[i - 16] + s0 + W[i - 7] + s1;
+ }
+
+ // Initialize hash value for this chunk
+ uint32_t a = state[0];
+ uint32_t b = state[1];
+ uint32_t c = state[2];
+ uint32_t d = state[3];
+ uint32_t e = state[4];
+ uint32_t f = state[5];
+ uint32_t g = state[6];
+ uint32_t h = state[7];
+
+ for( uint32_t j = 0; j < 64; ++j )
+ {
+ uint32_t s0 = rightrotate( a, 2 ) ^ rightrotate( a, 13 ) ^ rightrotate( a, 22 );
+ uint32_t maj = ( a & b ) ^ ( a & c ) ^ ( b & c );
+ uint32_t t2 = s0 + maj;
+ uint32_t s1 = rightrotate( e, 6 ) ^ rightrotate( e, 11 ) ^ rightrotate( e, 25 );
+ uint32_t ch = ( e & f ) ^ ( ( ~e ) & g );
+ uint32_t t1 = h + s1 + ch + sha256_constants[j] + W[j];
+
+ h = g;
+ g = f;
+ f = e;
+ e = d + t1;
+ d = c;
+ c = b;
+ b = a;
+ a = t1 + t2;
+ }
+
+ // Add this chunk's hash value to result so far
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ state[5] += f;
+ state[6] += g;
+ state[7] += h;
+ }
+
+ // Flip to little endian
+ for( int i = 0; i < 8; ++i )
+ state[i] = flip32( state[i] );
+
+ memcpy( buffer, reinterpret_cast<char*>( state ), 32 );
+}
+
+} // end namespace detail
+
+} // end namespace optix \ No newline at end of file
diff --git a/ext/spirv-headers b/ext/spirv-headers
deleted file mode 160000
-Subproject 308bd07424350a6000f35a77b5f85cd4f3da319
diff --git a/ext/spirv-tools b/ext/spirv-tools
deleted file mode 160000
-Subproject e128ab0d624ce7beb08eb9656bb260c597a46d0