Nobody expects the Red Team

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
This commit is contained in:
Andrzej Janik 2021-02-27 20:55:19 +01:00
parent 60d2124a16
commit 1b9ba2b233
762 changed files with 252358 additions and 39368 deletions

View file

@ -1,2 +1,8 @@
[target."x86_64-pc-windows-gnu"]
rustflags = ["-C", "link-self-contained=y"]
[target."x86_64-unknown-linux-gnu"]
rustflags = ["-C", "target-cpu=x86-64-v2"]
[target."x86_64-pc-windows-msvc"]
rustflags = ["-C", "target-cpu=x86-64-v2"]
[alias]
xtask = "run --package xtask --"

6
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,6 @@
# syntax = devthefuture/dockerfile-x
# This duplicate FROM is here purely to make dev containers happy,
# Otherwise it tries to parse the file (whyyy???) and chokes on custom syntax
FROM ubuntu:22.04
INCLUDE ./Dockerfile-common

View file

@ -0,0 +1,64 @@
WORKDIR /root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
nano \
wget \
curl \
gnupg \
ripgrep \
ltrace \
file\
python3-minimal \
build-essential \
git \
cmake \
ninja-build
ENV PATH="${PATH}:/opt/rocm/bin:/opt/rocm/llvm/bin:/usr/local/cuda/bin/"
ARG CUDA_VERSION=11-8
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb && \
dpkg -i cuda-keyring_1.0-1_all.deb && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
nvidia-headless-no-dkms-515 \
nvidia-utils-515 \
cuda-cudart-${CUDA_VERSION} \
cuda-compiler-${CUDA_VERSION} \
libcufft-dev-${CUDA_VERSION} \
libcusparse-dev-${CUDA_VERSION} \
libcublas-dev-${CUDA_VERSION} \
cuda-nvml-dev-${CUDA_VERSION} \
libcudnn8-dev
ARG RUST_VERSION=1.66.1
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=${RUST_VERSION}
RUN . $HOME/.cargo/env && cargo install bindgen-cli --locked
ARG ROCM_VERSION=5.7.3
RUN echo "Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" > /etc/apt/preferences.d/rocm-pin-600
RUN mkdir --parents --mode=0755 /etc/apt/keyrings && \
sh -c 'wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null' && \
sh -c 'echo deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${ROCM_VERSION} jammy main > /etc/apt/sources.list.d/rocm.list' && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
rocminfo \
rocm-gdb \
rocprofiler \
rocm-smi-lib \
hip-runtime-amd \
comgr \
hipblaslt-dev \
hipfft-dev \
rocblas-dev \
rocsolver-dev \
rocsparse-dev \
miopen-hip-dev \
rocm-device-libs && \
echo 'export PATH="$PATH:/opt/rocm/bin"' > /etc/profile.d/rocm.sh && \
echo '/opt/rocm/lib' > /etc/ld.so.conf.d/rocm.conf && \
ldconfig
# Default to a login shell
CMD ["bash", "-l"]

View file

@ -0,0 +1,72 @@
FROM rockylinux:8.8
WORKDIR /root
RUN dnf -y --setopt=install_weak_deps=False install \
nano \
wget \
curl \
ltrace \
file \
python3 \
git \
gcc \
gcc-c++ \
cmake
RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && \
rpm -ivh epel-release-latest-8.noarch.rpm && \
dnf -y --setopt=install_weak_deps=False install 'dnf-command(config-manager)' && \
crb enable && \
dnf -y --setopt=install_weak_deps=False install \
ripgrep \
ninja-build
ARG CUDA_VERSION=11-8
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && \
dnf -y --setopt=install_weak_deps=False module install \
nvidia-driver:515 && \
dnf -y --setopt=install_weak_deps=False install \
cuda-cudart-${CUDA_VERSION} \
cuda-compiler-${CUDA_VERSION} \
libcufft-devel-${CUDA_VERSION} \
libcusparse-devel-${CUDA_VERSION} \
libcublas-devel-${CUDA_VERSION} \
cuda-nvml-devel-${CUDA_VERSION} \
libcudnn8-devel
ARG RUST_VERSION=1.66.1
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=${RUST_VERSION}
RUN . $HOME/.cargo/env && cargo install bindgen-cli --locked
ARG ROCM_VERSION=5.7.1
RUN sh -c 'echo -e "[ROCm-${ROCM_VERSION}]\n\
name=ROCm${ROCM_VERSION}\n\
baseurl=https://repo.radeon.com/rocm/rhel8/${ROCM_VERSION}/main\n\
enabled=1\n\
priority=50\n\
gpgcheck=1\n\
gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key"' \
> /etc/yum.repos.d/rocm.repo && \
dnf -y --setopt=install_weak_deps=False install \
rocminfo \
rocm-gdb \
rocprofiler \
rocm-smi-lib \
hip-runtime-amd \
comgr \
hipblaslt-devel \
hipfft-devel \
rocblas-devel \
rocsolver-devel \
rocsparse-devel \
miopen-hip-devel \
rocm-device-libs && \
echo 'export PATH="$PATH:/opt/rocm/bin"' > /etc/profile.d/rocm.sh && \
echo '/opt/rocm/lib' > /etc/ld.so.conf.d/rocm.conf && \
ldconfig
# Default to a login shell
CMD ["bash", "-l"]

View file

@ -0,0 +1,16 @@
# syntax = devthefuture/dockerfile-x
FROM ubuntu:22.04
INCLUDE ./Dockerfile-common
ARG XGBOOST_VERSION=2.0.3
RUN git clone --branch "v${XGBOOST_VERSION}" --recurse-submodules https://github.com/dmlc/xgboost.git && \
cd xgboost && \
# Broken test, segfaults on normal CUDA
sed -i 's/TEST(Allocator, OOM) {/TEST(Allocator, OOM) { GTEST_SKIP();/g' tests/cpp/common/test_device_helpers.cu && \
mkdir build && \
cd build && \
cmake .. -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON -DUSE_CUDA=ON -GNinja && \
ninja
#

View file

@ -0,0 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "ZLUDA",
"build": {
"dockerfile": "Dockerfile"
},
"securityOpt": [
"seccomp=unconfined"
],
// Make NVIDIA and AMD GPUs available
"runArgs": [
// Uncomment on newer docker/podman
//"--runtime=nvidia",
"--device=/dev/kfd",
"--device=/dev/dri",
"--group-add=video"
],
// Cache cargo packages and compiled ZLUDA kernels
"initializeCommand": "mkdir -p ${localEnv:HOME}/.cargo/git ${localEnv:HOME}/.cargo/registry ${localEnv:HOME}/.cache/ZLUDA",
"mounts": [
{
"source": "${localEnv:HOME}/.cargo/git",
"target": "/root/.cargo/git",
"type": "bind"
},
{
"source": "${localEnv:HOME}/.cargo/registry",
"target": "/root/.cargo/registry",
"type": "bind"
},
{
"source": "${localEnv:HOME}/.cache/ZLUDA",
"target": "/root/.cache/ZLUDA",
"type": "bind"
}
],
// Rootless docker requires logging as root: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}

3
.gitattributes vendored Normal file
View file

@ -0,0 +1,3 @@
ext/** linguist-vendored
atiadlxx-sys/include/* linguist-vendored
*.ptx linguist-language=Assembly

View file

@ -1,58 +0,0 @@
name: Rust
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build_lin:
name: Build and publish (Linux)
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install GPU drivers
run: |
sudo apt-get install -y gpg-agent wget
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | sudo apt-key add -
sudo apt-add-repository 'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main'
sudo apt-get update
sudo apt-get install intel-opencl-icd intel-level-zero-gpu level-zero intel-media-va-driver-non-free libmfx1 libigc-dev intel-igc-cm libigdfcl-dev libigfxcmrt-dev level-zero-dev ocl-icd-opencl-dev
- name: Build
run: cargo build --workspace --verbose --release
- name: Rename to libcuda.so
run: |
mv target/release/libnvcuda.so target/release/libcuda.so
ln -s libcuda.so target/release/libcuda.so.1
- uses: actions/upload-artifact@v2
with:
name: Linux
path: |
target/release/libcuda.so
target/release/libcuda.so.1
build_win:
name: Build and publish (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Build
run: cargo build --workspace --verbose --release
- uses: actions/upload-artifact@v2
with:
name: Windows
path: |
target/release/nvcuda.dll
target/release/zluda_redirect.dll
target/release/zluda_with.exe
target/release/zluda_dump.dll
# TODO(take-cheeze): Support testing
# - name: Run tests
# run: cargo test --verbose

12
.gitmodules vendored
View file

@ -1,7 +1,5 @@
[submodule "ext/spirv-tools"]
path = ext/spirv-tools
url = https://github.com/KhronosGroup/SPIRV-Tools
branch = master
[submodule "ext/spirv-headers"]
path = ext/spirv-headers
url = https://github.com/KhronosGroup/SPIRV-Headers
[submodule "ext/llvm-project"]
path = ext/llvm-project
url = https://github.com/llvm/llvm-project.git
branch = release/15.x
shallow = true

197
ARCHITECTURE.md Normal file
View file

@ -0,0 +1,197 @@
# Architecture of ZLUDA
## Introduction
ZLUDA is a binary-compatible implementation of CUDA for AMD GPUs. An application built with CUDA compiler for NVIDIA GPU can be executed with near-native performance with ZLUDA on AMD GPUs without recompilation or any modifications to the application.
The principle behind ZLUDA is similar to that of WINE or WSL: to provide a highly-compatible execution environment with a near-native performance.
The design of the code follows directly from execution requirements of CUDA applications. Accordingly, this document is is split into five parts:
* Introduction
* CUDA runtime, which describes how CPU code, which controls NVIDIA GPUs is translated to control AMD GPUs
* CUDA GPU code compiler, which describes how NVIDIA GPU code is compiled for AMD GPUs
* Other projects, which describes miscellaneous ZLUDA tools for configuration and debugging
* Diagrams, which show general dependencies between code projects and typical flow of ZLUDA-enabled application
This document will avoid referring to specific files, structures or functions. The project is still in flux and those details are bound to change soon. High-level design, on the other hand will stay the same.
### Top-level design assumptions
If you are reading the code or even the rest of this document, you should be aware of assumptions made when developing the project:
* ZLUDA itself is written in Rust
C or C++ source dependencies are fine if they are are impossible to avoid (LLVM). GPU code in HIP/OpenCL C is fine - Rust support for writing GPU code is pitiful
* ZLUDA is focused on end users
By user we mean someone who uses a CUDA program, e.g. a 3D artist using Blender. Developer developing a CUDA application is not an. While we would like to support developers in the future, right now the time constraints do not allow it
* Building the project should require just `cargo build` (if possible)
That means that we avoid relying on `cargo` subcommands, `bindgen` or user setting up environment variables certain way to build the project. We can't avoid depending on some tools (cmake, Python), but that's because of C++ dependencies (LLVM)
## CUDA runtime
### Structure of a CUDA application
This is a CUDA "Hello World" application:
```
__global__ void cuda_hello(){
printf("Hello World from GPU!\n");
}
int main() {
cuda_hello<<<1,1>>>();
return 0;
}
```
Anyone familiar with C++ will instantly understand that compiling it is a complicated affair. CUDA does add special syntax for GPUs support: address spaces (`__global__` in the example above), kernel calling (`<<...>>` int the example above). Additionally CUDA allows, to a large degree, mixing CPU code and GPU code. What does all this complexity mean for ZLUDA?
Absolutely nothing
Turns out, CUDA compiler transforms CUDA source code into a normal application with calls to CUDA Driver API. The "Hello World" application gets transformed into something not too far from this:
```
char* cuda_hello_ptx = "...";
int main() {
cuInit();
CUmodule module = NULL;
cuModuleLoad(&module, cuda_hello_ptx);
CUfunction func = NULL;
cuModuleGetFunction(&func, module, "cuda_hello");
cuLaunchKernel(func, 1,1,1 1,1,1, NULL, NULL, NULL, NULL);
return 0;
}
```
All functions starting with `cu` are CUDA Driver API calls to functions in a shared library `nvcuda.dll` or `libcuda.so`. ZLUDA simply provides an alternative `nvcuda.dll` or `libcuda.so` with the same functions, which accept the same arguments. The difference is that an NVIDIA-provided library works with NVIDIA GPUs, a ZLUDA-provided library works with AMD GPUs.
This is a fairly simplified view. In reality, there is more than one CUDA API. Next section explains how to all of them relate to each other and how they are implemented by ZLUDA.
### Three CUDA APIs
More experienced CUDA programmers understand that there are two CUDA APIs. Driver API and Runtime API:
| | Driver API | Runtime API |
|---|---|---|
| __Function prefix__ | `cu` | `cuda` |
| __Dependencies__ | Kernel-mode driver | Driver API |
| __Dynamic (runtime) linking__ | ✅ | ✅ |
| __Static linking__ | ❌| ✅ |
Driver API is the lowest-level user-mode API. Runtime API builds on top of Driver API and provides miscellaneous high-level features. Since an application can dynamically link to either Driver API or Runtime API, it would seem that ZLUDA needs to provide both. In reality very few applications dynamically link to Runtime API. For the vast majority of applications it's sufficient to provide Driver API for dynamic (runtime) linking.
Driver API implementation is relatively straightforward: for each function ZLUDA calls a similarly called HIP runtime function. HIP is highly compatible with CUDA. For example, `cuDeviceGetAttribute(...)` is implemented by remapping some of the arguments to HIP versions and calling `hipDeviceGetAttribute(...)`. There's one exception: functions for compiling GPU code: `cuModuleLoadData(...)`, `cuModuleLoadDataEx(...)`. It's covered in the section [CUDA GPU code compiler](#cuda-gpu-code-compiler).
In addition to Driver API, Runtime API relies on CUDA Dark API. CUDA Driver API exposes function `cuGetExportTable(...)`. This function accepts a GUID and returns a table of function pointers. Those pointer point to undocumented functions forming CUDA Dark API. It's impossible to tell how many of them exist, but debugging experience suggests there are tens of function pointers across tens of tables. A typical application will use one or two most common. Due to they undocumented nature they are exclusively used by Runtime API and NVIDIA libraries (and in by CUDA applications in turn). We don't have names of those functions nor names or types of the arguments. This makes implementing them time-consuming. Dark API functions are are reverse-engineered and implemented by ZLUDA on case-by-case basis once we observe an application making use of it.
In addition, CUDA applications rely on various NVIDIA-provided libraries: NVML, cuBLAS, cuSPARSE. They are implemented by ZLUDA similarly - by providing a library with the same name and with the same functions, which call to native AMD libraries.
## CUDA GPU code compiler
A CUDA application ships with GPU code. This code can be either compiled into PTX or into SASS. The difference is that PTX is a textual assembly not specific to a particular NVIDIA GPU architecture (it is still specific to NVIDIA GPU hardware capabilities) while SASS is a binary asssembly specific to a given a particular NVIDIA GPU architecture. PTX is documented here: [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html). SASS is undocumented.
Majority of applications ship their GPU code in PTX. PTX is forward compatible with future GPU architectures. For all those reasons, currently, our compiler only supports PTX.
The compiler accepts PTX and outputs AMD GPU binary code. It is structured into a sequence of passes. Output of each pass is the input to the next one. Following sections contain description of the current compilation passes.
Compiler code is end-to-end tested. For every new feature or a bug fix we add a tiny PTX program that makes use of this feature. Firstly it's compiled and the output is compared to the reference LLVM IR. Next it's run and the result is compared to a saved reference result and a result of the same program running on NVIDIA CUDA.
## Other projects
Additionally, ZLUDA ships with more projects which serve some platform-specific purpose or are used for debugging.
### ZLUDA injector (Windows-only)
This is a Windows executable which starts injects process with ZLUDA redirector and a chosen CUDA Runtime API, typically either ZLUDA or ZLUDA dumper. This is a ZLUDA-specific replacement for `LD_PRELOAD`.
### ZLUDA redirector (Windows-only)
This is an injector helper library. It intercepts calls to WinAPI `LoadLibrary...(...)` function calls, detecting attempts to load NVIDIA CUDA library and instead forcing load of the CUDA Runtime API chosen by the injector. Furthermore it intercepts calls to WinAPI `CreateProcess..(...)` function calls to inject itself and the chosen CUDA Runtime API into child processes.
### ZLUDA dumper
This is a CUDA Runtime API implementation for diagnostics and debugging. The library does not have CUDA implementation per-se, but rather for each CUDA Runtime API function call, it intercepts the call, does some kind of pre-processing, routes the call to a real implementation (either ZLUDA or CUDA) and does post-processing. Currently, its main features are:
* Tracing CUDA application execution. A trace is a log of all CUDA function calls (with parameters and files with all the kernels used by the application
* Single kernel dump (in progress). This allows us to dump to disk a single `cuLaunchKernel(...)` with all the parameters (both memory and scalar). Then this kernel can be debugged without running whole application again
* Side-by-side execution (in progress). This allows to run application normally and for every call to `cuLaunchKernel(...)` also do the same call with another CUDA implementation. The differences in their outputs are then logged
## Diagrams
### Block diagram of the project
External dependencies are in rounded boxes
```mermaid
graph TD;
subgraph c["ZLUDA debug startup on Windows"];
ZLUDA_INJECT2[ZLUDA injector]-->ZLUDA_REDIRECT2[ZLUDA redirector];
ZLUDA_INJECT2-->ZLUDA_R3[ZLUDA dumper];
ZLUDA_REDIRECT2-->ZLUDA_R3;
ZLUDA_R3-->NV[NVIDIA CUDA Runtime]
end;
subgraph b[ZLUDA startup on Windows];
ZLUDA_INJECT[ZLUDA injector]-->ZLUDA_REDIRECT[ZLUDA redirector];
ZLUDA_INJECT-->ZLUDA_RT2[ZLUDA Runtime];
ZLUDA_REDIRECT-->ZLUDA_RT2;
end;
subgraph a["&nbsp;"];
ZLUDA_RT[ZLUDA Runtime]-->HIP([HIP Runtime]);
ZLUDA_RT-->ZLUDA_CMP[ZLUDA PTX Compiler];
ZLUDA_CMP--generate LLVM bitcode-->LLVM([LLVM]);
ZLUDA_CMP--compile LLVM bitcode to AMD GPU binary-->Lightning([Lightning Compiler]);
end;
```
### Flow of a typical ZLUDA-enabled application
Some details omitted and certain interactions simplified
```mermaid
sequenceDiagram
Application->>CUDA Runtime: cudaMemcpy(...)
Note over Application, CUDA Runtime: First call, can be some other function
activate CUDA Runtime
CUDA Runtime->>ZLUDA: cuInit(...)
activate ZLUDA
ZLUDA->>HIP: hipInit(...)
activate HIP
HIP-->>ZLUDA: hipSuccess
deactivate HIP
ZLUDA-->>CUDA Runtime: CUDA_SUCCESS
deactivate ZLUDA
CUDA Runtime->>ZLUDA: cuDeviceGetCount(...)
activate ZLUDA
ZLUDA->>HIP: hipDeviceGetCount(...)
activate HIP
HIP-->>ZLUDA: hipSuccess
deactivate HIP
ZLUDA-->>CUDA Runtime: CUDA_SUCCESS
deactivate ZLUDA
Note over CUDA Runtime, HIP: More calls to CUDA Device API omitted
rect rgb(200, 150, 255)
Note over CUDA Runtime, ZLUDA: Dark API region
CUDA Runtime->>ZLUDA: cuGetExportTable({6BD5FB6C-5BF4-E74A-8987-D93912FD9DF9})
activate ZLUDA
ZLUDA-->>CUDA Runtime: 0x1776e710
deactivate ZLUDA
Note right of CUDA Runtime: 0x1776e710 is the address of CUDA Dark API function table {6BD5FB6C-5BF4-E74A-8987-D93912FD9DF9}
CUDA Runtime->>ZLUDA: (0x1776e710+0x30)(0x1499e2000)
activate ZLUDA
Note right of CUDA Runtime: Calling function at index 6 from table at 0x1776e710
Note left of ZLUDA: ZLUDA recognizes this function as a private variant of cuModuleLoadData
ZLUDA->>ZLUDA: Parse and compile PTX to AMD GPU binary
ZLUDA-->>CUDA Runtime: 0x2982da70
Note right of CUDA Runtime: We return newly created module handle 0x2982da70
deactivate ZLUDA
end
Note over CUDA Runtime, HIP: More calls to CUDA Device API omitted
CUDA Runtime->>ZLUDA: cuModuleGetFunction(module: 0x2982da70, ...)
activate ZLUDA
ZLUDA->>HIP: hipModuleGetFunction(...)
activate HIP
HIP-->>ZLUDA: hipSuccess
deactivate HIP
ZLUDA-->>CUDA Runtime: CUDA_SUCCESS
deactivate ZLUDA
Note over CUDA Runtime, HIP: More calls to CUDA Device API omitted
CUDA Runtime-->>Application: cudaSuccess
deactivate CUDA Runtime
Application->>CUDA Runtime: cuLaunchKernel(...)
activate CUDA Runtime
CUDA Runtime->>ZLUDA: cuLaunchKernel(...)
activate ZLUDA
ZLUDA->>HIP: hipLaunchKernel(...)
activate HIP
HIP-->>ZLUDA: hipSuccess
deactivate HIP
ZLUDA-->>CUDA Runtime: CUDA_SUCCESS
deactivate ZLUDA
CUDA Runtime->>Application: cudaSuccess
deactivate CUDA Runtime
```

View file

@ -1,61 +0,0 @@
# Dependencies
Development builds of ZLUDA requires following dependencies:
* CMake
* Python 3
Additionally the repository has to be cloned with Git submodules initalized. If you cloned the repo without initalizing submodules, do this:
```
git submodule update --init --recursive
```
# Tests
Tests should be executed with `--workspace` option to test non-default targets:
```
cargo test --workspace
```
# Debugging
## Debuggging CUDA applications
When running an application with ZLUDA quite often you will run into subtle bugs or incompatibilities in the generated GPU code. The best way to debug an application's GPU CUDA code is to use ZLUDA dumper.
Library `zluda_dump` can be injected into a CUDA application and produce a trace which, for every launched GPU function contains:
* PTX source
* Launch arguments (block size, grid size, shared memory size)
* Dump of function arguments. Both after and before
Example use with GeekBench:
```
set ZLUDA_DUMP_KERNEL=knn_match
set ZLUDA_DUMP_DIR=C:\temp\zluda_dump
"<ZLUDA_PATH>\zluda_with.exe" "<ZLUDA_PATH>\zluda_dump.dll" -- "geekbench_x86_64.exe" --compute CUDA
```
The example above, for every execution of GPU function `knn_match`, will save its details into the directory `C:\temp\zluda_dump`
This dump can be replayed with `replay.py` script from `zluda_dump` source directory. Use it like this:
```
python replay.py "C:\temp\zluda_dump\geekbench_x86_64.exe"
```
You must copy (or symlink) ZLUDA `nvcuda.dll` into PyCUDA directory, so it will run using ZLUDA. Example output:
```
Intel(R) Graphics [0x3e92] [github.com/vosen/ZLUDA]
C:\temp\zluda_dump\geekbench_x86_64.exe\4140_scale_pyramid
C:\temp\zluda_dump\geekbench_x86_64.exe\4345_convolve_1d_vertical_grayscale
Skipping, launch block size (512) bigger than maximum block size (256)
C:\temp\zluda_dump\geekbench_x86_64.exe\4480_scale_pyramid
6:
Arrays are not equal
Mismatched elements: 1200 / 19989588 (0.006%)
Max absolute difference: 255
Max relative difference: 255.
x: array([ 7, 6, 8, ..., 193, 195, 193], dtype=uint8)
y: array([ 7, 6, 8, ..., 193, 195, 193], dtype=uint8)
```
From this output one can observe that in kernel launch 4480, 6th argument to function `scale_pyramid` differs between what was executed on an NVIDIA GPU using CUDA and Intel GPU using ZLUDA.
__Important__: It's impossible to infer what was the type (and semantics) of argument passed to a GPU function. At our level it's a buffer of bytes and by default `replay.py` simply checks if two buffers are byte-equal. That means you will have a ton of false negatives when running `replay.py`. You should override them for your particular case in `replay.py` - it already contains some overrides for GeekBench kernels

View file

@ -1,20 +1,61 @@
[workspace]
# Remember to also update the project's Cargo.toml
# if it's a top-level project
members = [
"atiadlxx-sys",
"comgr",
"cuda_base",
"cuda_types",
"detours-sys",
"level_zero-sys",
"level_zero",
"spirv_tools-sys",
"zluda",
"zluda_dump",
"zluda_lib",
"zluda_inject",
"zluda_redirect",
"ext/llvm-sys.rs",
"hip_common",
"hip_runtime-sys",
"hipblaslt-sys",
"hipfft-sys",
"hiprt-sys",
"miopen-sys",
"offline_compiler",
"optix_base",
"optix_dump",
"process_address_table",
"ptx",
"rocblas-sys",
"rocm_smi-sys",
"rocsparse-sys",
"xtask",
"zluda",
"zluda_api",
"zluda_blas",
"zluda_blaslt",
"zluda_ccl",
"zluda_dark_api",
"zluda_dnn",
"zluda_dump",
"zluda_fft",
"zluda_inject",
"zluda_lib",
"zluda_llvm",
"zluda_ml",
"zluda_redirect",
"zluda_rt",
"zluda_sparse",
]
default-members = ["zluda_lib", "zluda_inject", "zluda_redirect"]
# Cargo does not support OS-specific or profile-specific
# targets. We keep list here to bare minimum and rely on xtask
default-members = [
"zluda_lib",
"zluda_ml",
"zluda_inject",
"zluda_redirect"
]
[patch.crates-io]
rspirv = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }
spirv_headers = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }
[profile.dev.package.blake3]
opt-level = 3
[profile.dev.package.lz4-sys]
opt-level = 3
[profile.dev.package.xtask]
opt-level = 3

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 259 KiB

57
Makefile.toml Normal file
View file

@ -0,0 +1,57 @@
[config]
default_to_workspace = false
skip_core_tasks = true
[tasks.build]
run_task = [
{ name = "build-windows", condition = { platforms = ["windows"] } },
{ name = "build-linux", condition = { platforms = ["linux"] } },
]
[tasks.build-windows]
command = "cargo"
args = [
"build",
"-p", "offline_compiler",
"-p", "zluda_dump",
"-p", "zluda_inject",
"-p", "zluda_lib",
"-p", "zluda_ml",
"-p", "zluda_redirect",
]
[tasks.build-linux]
command = "cargo"
args = [
"build",
"-p", "offline_compiler",
"-p", "zluda_blas",
"-p", "zluda_blaslt",
"-p", "zluda_ccl",
"-p", "zluda_dnn",
"-p", "zluda_dump",
"-p", "zluda_fft",
"-p", "zluda_lib",
"-p", "zluda_ml",
"-p", "zluda_sparse",
]
[tasks.build-release]
command = "cargo"
args = [
"build",
"--release",
"-p", "offline_compiler",
"-p", "zluda_blas",
"-p", "zluda_blaslt",
"-p", "zluda_ccl",
"-p", "zluda_dnn",
"-p", "zluda_dump",
"-p", "zluda_fft",
"-p", "zluda_lib",
"-p", "zluda_ml",
"-p", "zluda_sparse",
]
[tasks.default]
alias = "build"

291
README.md
View file

@ -1,91 +1,250 @@
__Notice__: Due to private reasons I am currently unable to continue developing this project. If you
want to take it over, fork it and contact me at vosen@vosen.pl
# ZLUDA
ZLUDA is a drop-in replacement for CUDA on Intel GPU. ZLUDA allows to run unmodified CUDA applications using Intel GPUs with near-native performance (more below). It works with current integrated Intel UHD GPUs and will work with future Intel Xe GPUs
ZLUDA lets you run unmodified CUDA applications with near-native performance on ~~Intel~~ AMD GPUs.
## Performance
ZLUDA is currently alpha quality, but it has been confirmed to work with a variety of native CUDA applications: Geekbench, 3DF Zephyr, Blender, Reality Capture, LAMMPS, NAMD, waifu2x, OpenFOAM, Arnold (proof of concept) and more.
ZLUDA performance has been measured with GeekBench 5.2.3 on Intel UHD 630.\
One measurement has been done using OpenCL and another measurement has been done using CUDA with Intel GPU masquerading as a (relatively slow) NVIDIA GPU with the help of ZLUDA. Both measurements use the same GPU.
Performance below is normalized to OpenCL performance. 110% means that ZLUDA-implemented CUDA is 10% faster on Intel UHD 630.
![Performance graph](GeekBench_5_2_3.svg)
[ZLUDA - detailed results on Geekbench.com](https://browser.geekbench.com/v5/compute/2305009)
[OpenCL - detailed results on Geekbench.com](https://browser.geekbench.com/v5/compute/2304997)
Overall, ZLUDA is slower in GeekBench by roughly 2%.
### Explanation of the results
* Why is ZLUDA faster in some benchmarks?\
This has not been precisely pinpointed to one thing or another but it's likely a combination of things:
* ZLUDA uses [Level 0](https://spec.oneapi.com/level-zero/latest/index.html), which in general is a more low level, high performance API than OpenCL
* Tying to the previous point, currently ZLUDA does not support asynchronous execution. This gives us an unfair advantage in a benchmark like GeekBench. GeekBench exclusively uses CUDA synchronous APIs
* There is a set of GPU instructions which are available on both NVIDIA hardware and Intel hardware, but are not exposed through OpenCL. We are comparing NVIDIA GPU optimized code with the more general OpenCL code. It's a lucky coincidence (and a credit to the underlying Intel Graphics Compiler) that this code also works well on an Intel GPU
* Why is OpenCL faster in Canny and Horizon Detection?\
Authors of CUDA benchmarks used CUDA functions `atomicInc` and `atomicDec` which have direct hardware support on NVIDIA cards, but no hardware support on Intel cards. They have to be emulated in software, which limits performance
* Why is ZLUDA slower in the remaining benchmarks?\
The reason is unknown. Most likely, in some tests we compile from suboptimal NVIDIA GPU code and in other tests ZLUDA itself is emitting suboptimal Intel GPU code. For example, SFFT used to be even slower before PR [#22](https://github.com/vosen/ZLUDA/pull/22)
## Details
* Is ZLUDA a drop-in replacement for CUDA?\
Yes, but certain applications use CUDA in ways which make it incompatible with ZLUDA
* What is the status of the project?\
This project is a Proof of Concept. About the only thing that works currently is Geekbench. It's amazingly buggy and incomplete. You should not rely on it for anything serious
* Is it an Intel project? Is it an NVIDIA project?\
No, it's a private project
* What is the performance?\
Performance can be close to the performance of similarly written OpenCL code (see GeekBench results in the previous section). NVIDIA GPUs and Intel GPUs have different architecture and feature set. Consequently, certain NVIDIA features have to be emulated in ZLUDA with performance penalty. Additionally, performance of ZLUDA will be always lower than the performance of code specifically optimized for Intel GPUs
* How it's different from AMD HIP or Intel DPC++ Compatibility toolkit?\
Both are porting toolkits which require programmer's effort to port applications to the API in question. With ZLUDA existing applications "just work" on an Intel GPU (if you are lucky and ZLUDA supports the particular subset of CUDA)
* Which Intel GPU are supported?\
Intel Gen9 and newer (Skylake and newer) which are supported by Intel Level 0
* Does ZLUDA support AMD GPUs?\
Certainly not currently, but it might be technically possible
If you want to give it a try, download it from Release page to the right and read [Usage](#usage) and [Known Issues](#known-issues) sections below. If you are interested in its history and future read [FAQ](#faq) section further below.
![geekbench.svg](geekbench.svg)
## Usage
**Warning**: this is a very incomplete proof of concept. It's probably not going to work with your application. ZLUDA currently works only with applications which use CUDA Driver API or statically-linked CUDA Runtime API - dynamically-linked CUDA Runtime API is not supported at all
### Windows
You should have the most recent Intel GPU drivers installed.\
Run your application like this:
Using command line:
```
<ZLUDA_DIRECTORY>\zluda_with.exe -- <APPLICATION> <APPLICATIONS_ARGUMENTS>
<ZLUDA_DIRECTORY>\zluda.exe -- <APPLICATION> <APPLICATION_ARGUMENTS>
```
If you downloaded a ZIP file with the release and unpacked it, then `<ZLUDA_DIRECTORY>` is the `zluda` directory you have just unpacked.\
If you are building from source, then `<ZLUDA_DIRECTORY>` is subdirectory `target\release`.
### Linux
You should install most recent run-time driver packages as outlined here: https://dgpu-docs.intel.com/installation-guides/index.html.
Run your application like this:
Using command line:
```
LD_LIBRARY_PATH=<ZLUDA_DIRECTORY> <APPLICATION> <APPLICATIONS_ARGUMENTS>
LD_LIBRARY_PATH="<ZLUDA_DIRECTORY>:$LD_LIBRARY_PATH" <APPLICATION> <APPLICATION_ARGUMENTS>
```
If you downloaded a ZIP file with the release and unpacked it, then `<ZLUDA_DIRECTORY>` is the `zluda` directory you have just unpacked.\
If you are building from source, then `<ZLUDA_DIRECTORY>` is subdirectory `target\release`.
## Build
### Prerequisites
Make sure you have the following installed:
* Git
* CMake
* Python 3
* Rust (1.66.1 or newer)
* C++ compiler
* (Linux only) ROCm 5.7+ (_not ROCm 6_) (https://rocm.docs.amd.com/en/latest/deploy/linux/install_overview.html)
* (Windows only) Recent AMD Radeon Software Adrenalin (https://rocm.docs.amd.com/en/latest/deploy/linux/install_overview.html)
* (Recommended, optional) Ninja (https://ninja-build.org/)
Alternatively, if you are building for Linux, [.devcontainer](.devcontainer) directory contains various developer Dockerfiles with all the required dependencies
### Checkout
Checkout ZLUDA code with:
```
git clone --recurse-submodules https://github.com/vosen/zluda.git
```
## Building
You should have a relatively recent version of Rust installed, then you just do:
### Build
Build by running:
```
cargo build --release
```
in the main directory of the project.
### Linux
You should install most recent run-time an developer driver packages as outlined here: https://dgpu-docs.intel.com/installation-guides/index.html. Additionally, you should have `ocl-icd-opencl-dev` (or equivalent) installed.
If you are building on Linux you must also symlink (or rename) the ZLUDA output binaries after ZLUDA build finishes:
```
ln -s libnvcuda.so target/release/libcuda.so
ln -s libcuda.so target/release/libcuda.so.1
cargo xtask --release
```
## Contributing
## Known Issues
If you want to develop ZLUDA itself, read [CONTRIBUTING.md](CONTRIBUTING.md), it contains instructions how to set up dependencies and run tests
### Hardware
- If both integrated AMD GPU and dedicated AMD GPU are present in the system, ZLUDA uses the integrated GPU.
This is a bug in underying ROCm/HIP runtime. You can work around it by disabling the integrated GPU.
On Windows we recommend you use environment variable `HIP_VISIBLE_DEVICES=1` environment variable (more [here](https://rocmdocs.amd.com/en/latest/conceptual/gpu-isolation.html#hip-visible-devices)) or disable it system-wide in Device Manager.
On Linux we recommend you use environment variable `ROCR_VISIBLE_DEVICES=<UUID>` where `<UUID>` is the UUID of the dedicated GPU as reported by `rocminfo` command line tool (you can also use `HIP_VISIBLE_DEVICES=1`, but this does not seem to be stable). Alternatively you can disable integrated GPU syste-wide by passing `pci-stub.ids=<DEVICE_VENDOR>:<DEVICE_CODE>` to the kernel options. On Ubuntu you can pass additional kernel options by adding them to `/etc/default/grub` to the option `GRUB_CMDLINE_LINUX_DEFAULT`. You can find `<DEVICE_VENDOR>:<DEVICE_CODE>` with the help of `lspci -nn`. This will emit a series of lines with one of them matching you integrated GPU, for example:\
`1b:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:164e] (rev c1)`\
`<DEVICE_VENDOR>:<DEVICE_CODE>` ar at the end, in this case `1002:164e`.
- Integrated GPUs (as tested with Radeon 680M) work in a limited way. Some rarely used GPU operations (abort, printf, etc.) will hang or crash the application. Additionally, performance library support (cuBLAS, cuDNN, etc.) might be limited, rendering more complex applications inoperable.
- ZLUDA can use AMD server GPUs (as tested with Instinct MI200) with a caveat.
On Server GPUs, ZLUDA can compile CUDA GPU code to run in one of two modes:
- Fast mode, which is faster, but can make exotic (but correct) GPU code hang.
- Slow mode, which should make GPU code more stable, but can prevent some applications from running on ZLUDA.
By default, ZLUDA uses fast mode. That's because:
- There's a huge performance difference, fast mode can be twice as fast.
- The code patterns that can trip fast mode were not encountered across multiple projects (SPECFEM3D, QUDA, CHroma, MILC, Kokkos, LAMMPS, OpenFOAM, XGBoost, NAMD, LAMMPS).
You can use environment variable `ZLUDA_WAVE64_SLOW_MODE=1` to force compilation in slow mode.
Nothing of that applies to desktop and integrated GPUs (RDNA family).
### Software
- Applications using ZLUDA are slow to start.
On the first start ZLUDA needs to compile GPU code for the application. This is a one-time cost, compiled GPU code is cached in `%LOCALAPPDATA%` on Windows and in `$XDG_CACHE_HOME` or `$HOME/.cache` on Linux.\
Some applications will gradually load the GPU code as it is used. If that is undesirable you can try setting environment variable `CUDA_MODULE_LOADING=EAGER`. It depends on how the application was programmed, but it might force to load (and compile) all the kernels on startup, no matter if they are used or not.
- Applications running ZLUDA might produce slightly different values
Firstly, ZLUDA ignores some of the floating point denormal and rounding mode information present in the kernels. Secondly, for certain approximate (not IEEE 754) NVIDIA floating point operations in CUDA, ZLUDA blindly uses approximate AMD floating point operations. The two might have a different precision.
#### CUDA 12+
- Application built with CUDA 12 and using Thrust crashes with `LLVM ERROR: unsupported libcall legalization`.
This is a ROCm/HIP bug. Currently, CUDA applications built with CUDA versions pre-12 work the best. Building with CUDA 12 and a pre-CUDA 12 Thrust might also work.
#### OptiX
- ZLUDA has a bare-minimum OptiX implementation for Arnold. See details in [Arnold](#arnold) section.
#### Windows
- Antivirus flags ZLUDA as malware.
ZLUDA launcher (`zluda.exe`) uses some of the techniques used by malware, but for good. `zluda.exe` hijacks the process and redirects all uses of the original NVIDIA's CUDA libraries to use ZLUDA's CUDA instead.
<u>Don't use `zluda.exe` with games that use anti-cheat.</u> ZLUDA does not support CUDA gaming workloads (PhysX or DLSS) and anti-cheat might mistake `zluda.exe` for a malware or a cheat.
- Following error when launching an application with `zluda.exe`: `Error: OsError { function: "DetourCreateProcessWithDllsW", error_code: 740, message: "The requested operation requires elevation." }`
You are launching an application that requires Administrator rights through `zluda.exe`. Try launching `zluda.exe` from an Administrator command line.
- ZLUDA offers limited support for performance libraries (cuDNN, cuBLAS, cuSPARSE, cuFFT, OptiX, NCCL). Currently, this support is Linux-only and not available on Windows.
- ZLUDA launcher (`zluda.exe`) does not support 32 bit processes. If an application launches 32 bit subprocess `a.exe` neither the 32 bit process `a.exe`, nor its 64 bit subprocess `a64.exe` will be able to use ZLUDA. This affects e.g. SiSoft Sandra.
### Applications
#### Arnold
* ZLUDA implements minimum of OptiX framework to support Arnold. ZLUDA's OptiX is buggy, unoptimized and incomplete. It's been tested with Arnold 7.1.4.1 command line rendering on Linux.
ZLUDA-OptiX is not built by default or redistributed in the release. To use it follow those steps:
* Firstly build a newer version of ROCm LLVM. Version shipped with 5.7.1 is known to miscompile Arnold code. Get it here: https://github.com/ROCm/llvm-project. Switch to a known good commit: `0c7fd5b6d1bbf471d2c068c2b6172d9cfd76b08d` and build it.
* Then build amd_comgr: https://github.com/ROCm/ROCm-CompilerSupport with the LLVM built in the previous step. I'm using the last commit from https://github.com/ROCm/ROCm-CompilerSupport (`8276083301409001ec7643e68f5ad58b057c21fd`).
* Now build ZLUDA-OptiX:
```
cargo ctask --release
cargo build -p zluda_rt --release
cd target/release
ln -s libnvoptix.so liboptix.so.6.6.0
cp ../../hiprt-sys/lib/libhiprt64.so .
```
* After those quick and easy steps you can use it with the command line Arnold renderer:
```
LD_LIBRARY_PATH=<PATH_TO_ZLUDA>/target/release/ LD_PRELOAD="<PATH_TO_COMGR>/build/libamd_comgr.so.2 <PATH_TO_ZLUDA>/liboptix.so.6.6.0" /usr/autodesk/arnold/maya2023/bin/kick attic.ass -device gpu -o /tmp/attic.jpg -v 6 -sl
```
* Keep in mind that ZLUDA-OptiX can only successfully render the simplest Arnold scene (and possibly one more):
* Cornell box (from [here](https://help.autodesk.com/view/ARNOL/ENU/?guid=arnold_user_guide_ac_scene_source_ac_ass_examples_html)):\
[![cornell](https://imgur.com/4Vv3GO8s.jpg)](https://imgur.com/4Vv3GO8)
* (used to work, broken now) Attic scene (from [here](https://github.com/wahn/export_multi/tree/master/17_attic)):\
[![cornell](https://imgur.com/Sut2YMys.jpg)](https://imgur.com/a/2jF9Kb5)
#### PyTorch
* PyTorch received very little testing. ZLUDA's coverage of cuDNN APIs is very minimal (just enough to run ResNet-50) and realistically you won't get much running.\
However if you are interested in trying it out you need to build it from sources with the settings below. Default PyTorch does not ship PTX and uses bundled NCCL which also builds without PTX:
```
export TORCH_CUDA_ARCH_LIST="6.1+PTX"
export CUDAARCHS=61
export CMAKE_CUDA_ARCHITECTURES=61
export USE_SYSTEM_NCCL=1
export NCCL_ROOT_DIR=/usr
export NCCL_INCLUDE_DIR=/usr/include
export NCCL_LIB_DIR=/usr/lib/x86_64-linux-gnu
export USE_EXPERIMENTAL_CUDNN_V8_API=OFF
```
or (untested):
```
export TORCH_CUDA_ARCH_LIST="6.1+PTX"
export CUDAARCHS=61
export CMAKE_CUDA_ARCHITECTURES=61
export USE_SYSTEM_NCCL=1
export USE_NCCL=0
export USE_EXPERIMENTAL_CUDNN_V8_API=OFF
```
When running use the following environment variable:
```
DISABLE_ADDMM_CUDA_LT=1
```
#### 3DF Zephyr
- ZLUDA is much slower than CUDA.
3DF Zephyr is triggering an uderlying ROCm/HIP performance issue.
#### Reality Capture
- ZLUDA is much slower than CUDA.
Reality Capture is triggering an uderlying ROCm/HIP performance issue.
#### CompuBench
- When running multiple tests, first test passes and the subsequent tests fail with `CUDA_ERROR_UNKNOWN`.
This is a ROCm/HIP bug. Currently, CompuBench tests have to be run one at a time.
- Some tests output black screen.
This is due to a bug (or an unintended hardware feature) in CompuBench that just happens to work on NVIDIA GPUs.
#### V-Ray Benchmark
- Currently, ZLUDA crashes when running V-Ray benchmark. Nonetheless, certain "lucky" older combinations of ZLUDA and ROCm/HIP are known to run V-Ray Benchmark successfully.
#### Cinebench CUDA
- ZLUDA can't run it. Cinebench CUDA benchmark has not been fully compiled with PTX. It may be possible to run it (sans OptiX) if the OctaneBench developers re-compile it.
#### OctaneBench
- ZLUDA can't run it. OctaneBench has not been fully compiled with PTX. It may be possible to run it (sans OptiX) if the OctaneBench developers re-compile it.
## FAQ
- Why is this project suddenly back after 3 years? What happened to Intel GPU support?
In 2021 I was contacted by Intel about the development od ZLUDA. I was an Intel employee at the time. While we were building a case for ZLUDA internally, I was asked for a far-reaching discretion: not to advertise the fact that Intel was evaluating ZLUDA and definitely not to make any commits to the public ZLUDA repo. After some deliberation, Intel decided that there is no business case for running CUDA applications on Intel GPUs.
Shortly thereafter I got in contact with AMD and in early 2022 I have left Intel and signed a ZLUDA development contract with AMD. Once again I was asked for a far-reaching discretion: not to advertise the fact that AMD is evaluating ZLUDA and definitely not to make any commits to the public ZLUDA repo. After two years of development and some deliberation, AMD decided that there is no business case for running CUDA applications on AMD GPUs.
One of the terms of my contract with AMD was that if AMD did not find it fit for further development, I could release it. Which brings us to today.
* What's the future of the project?
With neither Intel nor AMD interested, we've run out of GPU companies. I'm open though to any offers of that could move the project forward.
Realistically, it's now abandoned and will only possibly receive updates to run workloads I am personally interested in (DLSS).
* What underlying GPU API does ZLUDA use? Is it OpenCL? ROCm? Vulkan?
ZLUDA is built purely on ROCm/HIP. On both Windows and Linux.
* I am a developer writing CUDA code, does this project help me port my code to ROCm/HIP?
Currently no, this project is strictly for end users. However this project could be used for a much more gradual porting from CUDA to HIP than anything else. You could start with an unmodified application running on ZLUDA, then have ZLUDA expose the underlying HIP objects (streams, modules, etc.), allowing to rewrite GPU kernels one at a time. Or you could have a mixed CUDA-HIP application where only the most performance sensitive GPU kernels are written in the native AMD language.
## For developers
If you are curious about ZLUDA's architecture, you can read a broad overview in [ARCHITECTURE.md](ARCHITECTURE.md).
## License

8
atiadlxx-sys/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "atiadlxx-sys"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2018"
links = "atiadlxx"
[lib]

1
atiadlxx-sys/README Normal file
View file

@ -0,0 +1 @@
bindgen include/wrapper.hpp -o src/adl.rs --no-layout-tests --default-enum-style=newtype --no-derive-debug --allowlist-function "ADL2_.*" --allowlist-var "ADL.*" --allowlist-type "ADL.*"

19
atiadlxx-sys/build.rs Normal file
View file

@ -0,0 +1,19 @@
use std::env::VarError;
use std::{env, path::PathBuf};
fn main() -> Result<(), VarError> {
println!("cargo:rustc-link-lib=dylib=atiadlxx");
if cfg!(windows) {
let env = env::var("CARGO_CFG_TARGET_ENV")?;
if env == "msvc" {
let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
path.push("lib");
println!("cargo:rustc-link-search=native={}", path.display());
} else {
println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
};
} else {
println!("cargo:rustc-link-search=native=/opt/rocm/lib/");
}
Ok(())
}

389
atiadlxx-sys/include/adapter.h vendored Normal file
View file

@ -0,0 +1,389 @@
#ifndef ADAPTER_H_
#define ADAPTER_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_Adapter_ObservedClockInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpCoreClock, int* lpMemoryClock);
ADL_EXTERNC int EXPOSED ADL_Adapter_ObservedClockInfo_Get(int iAdapterIndex, int* lpCoreClock, int* lpMemoryClock);
ADL_EXTERNC int EXPOSED ADL_Adapter_ObservedGameClockInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpBaseClock, int* lpGameClock, int* lpBoostClock, int* lpMemoryClock);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Active_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex,
int iStatus,
int* lpNewlyActivate);
ADL_EXTERNC int EXPOSED ADL_Adapter_Active_Set(int iAdapterIndex,
int iStatus,
int* lpNewlyActivate);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Active_SetPrefer(ADL_CONTEXT_HANDLE context, int iAdapterIndex,
int iStatus,
int iNumPreferTarget,
ADLDisplayTarget* lpPreferTarget,
int* lpNewlyActivate);
ADL_EXTERNC int EXPOSED ADL_Adapter_Active_SetPrefer(int iAdapterIndex,
int iStatus,
int iNumPreferTarget,
ADLDisplayTarget* lpPreferTarget,
int* lpNewlyActivate);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Primary_Get(ADL_CONTEXT_HANDLE context, int* lpPrimaryAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Adapter_Primary_Get(int* lpPrimaryAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Primary_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Adapter_Primary_Set(int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ModeSwitch(ADL_CONTEXT_HANDLE context, int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Adapter_ModeSwitch(int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Active_Get (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpStatus);
ADL_EXTERNC int EXPOSED ADL_Adapter_Active_Get ( int iAdapterIndex, int* lpStatus);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Aspects_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, char* lpAspects, int iSize );
ADL_EXTERNC int EXPOSED ADL_Adapter_Aspects_Get( int iAdapterIndex, char* lpAspects, int iSize );
ADL_EXTERNC int EXPOSED ADL2_Adapter_NumberOfAdapters_Get (ADL_CONTEXT_HANDLE context, int* lpNumAdapters );
ADL_EXTERNC int EXPOSED ADL_Adapter_NumberOfAdapters_Get ( int* lpNumAdapters );
ADL_EXTERNC int EXPOSED ADL2_Flush_Driver_Data(ADL_CONTEXT_HANDLE context,int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Flush_Driver_Data(int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AdapterInfo_Get (ADL_CONTEXT_HANDLE context,LPAdapterInfo lpInfo, int iInputSize);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VerndorID_Int_get(ADL_CONTEXT_HANDLE context, int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Adapter_AdapterInfo_Get (LPAdapterInfo lpInfo, int iInputSize);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AdapterInfoX2_Get (ADL_CONTEXT_HANDLE context,AdapterInfo **lppAdapterInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_AdapterInfoX2_Get (AdapterInfo **lppAdapterInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_RegValueString_Get(int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int iSize, char *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL_Adapter_RegValueString_Set(int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int iSize, char *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL2_Adapter_RegValueString_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int iSize, char *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL2_Adapter_RegValueString_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int iSize, char *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL2_Adapter_RegValueInt_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL_Adapter_RegValueInt_Get(int iAdapterIndex, int iDriverPathOption, char* szSubKey, char *szKeyName, int *lpKeyValue);
ADL_EXTERNC int EXPOSED ADL_Adapter_RegValueInt_Set(int iAdapterIndex, int iDriverPathOption, char *szSubKey, char *szKeyName, int iKeyValue);
ADL_EXTERNC int EXPOSED ADL2_Adapter_RegValueInt_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDriverPathOption, char *szSubKey, char *szKeyName, int iKeyValue);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ASICFamilyType_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpAsicTypes, int* lpValids);
ADL_EXTERNC int EXPOSED ADL_Adapter_ASICFamilyType_Get (int iAdapterIndex, int* lpAsicTypes, int* lpValids);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Speed_Caps (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpCaps, int* lpValid);
ADL_EXTERNC int EXPOSED ADL_Adapter_Speed_Caps (int iAdapterIndex, int* lpCaps, int* lpValid);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Speed_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL_Adapter_Speed_Get (int iAdapterIndex, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Speed_Set (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iSpeed);
ADL_EXTERNC int EXPOSED ADL_Adapter_Speed_Set (int iAdapterIndex, int iSpeed);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Accessibility_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpAccessibility);
ADL_EXTERNC int EXPOSED ADL_Adapter_Accessibility_Get (int iAdapterIndex, int *lpAccessibility);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VideoBiosInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLBiosInfo* lpBiosInfo );
ADL_EXTERNC int EXPOSED ADL_Adapter_VideoBiosInfo_Get( int iAdapterIndex, ADLBiosInfo* lpBiosInfo );
ADL_EXTERNC int EXPOSED ADL2_Adapter_ID_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpAdapterID);
ADL_EXTERNC int EXPOSED ADL_Adapter_ID_Get(int iAdapterIndex, int* lpAdapterID);
ADL_EXTERNC int EXPOSED ADL2_AdapterX2_Caps(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLAdapterCapsX2 *adapterCaps);
ADL_EXTERNC int EXPOSED ADL_AdapterX2_Caps(int iAdapterIndex, ADLAdapterCapsX2 *adapterCaps);
ADL_EXTERNC int EXPOSED ADL2_Stress_Test_Cap(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion);
ADL_EXTERNC int EXPOSED ADL2_Throttle_Notification_Cap(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AceDefaults_Restore(ADL_CONTEXT_HANDLE context, int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AdapterInfoX4_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* numAdapters, AdapterInfoX2** lppAdapterInfoX2);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AdapterInfoX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* numAdapters, AdapterInfo** lppAdapterInfo);
ADL_EXTERNC int EXPOSED ADL2_Adapter_AdapterList_Disable(ADL_CONTEXT_HANDLE context, int iNumAdapters, int *lpAdapterIndexList, bool isSkipSaveDB = false);
ADL_EXTERNC int EXPOSED ADL_Adapter_AdapterList_Disable(int iNumAdapters, int *lpAdapterIndexList);
ADL_EXTERNC int EXPOSED ADL_Adapter_BigSw_Info_Get(int iAdapterIndex, int* lpBigSwSupportMajor, int* lpBigSwSupportMinor, int* lpRedStoneSupport);
ADL_EXTERNC int EXPOSED ADL2_Adapter_BigSw_Info_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpBigSwSupportMajor, int* lpBigSwSupportMinor, int* lpRedStoneSupport);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLAdapterCaps *adapterCaps);
ADL_EXTERNC int EXPOSED ADL_Adapter_Caps(int iAdapterIndex, ADLAdapterCaps *adapterCaps);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ChipSetInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLChipSetInfo * lpChipSetInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_ChipSetInfo_Get(int iAdapterIndex, ADLChipSetInfo * lpChipSetInfo);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Feature_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_UIFEATURES_GROUP iFeatureID, int *iIsFeatureSupported);
ADL_EXTERNC int EXPOSED ADL2_Adapter_HBC_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpHbcCapable);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Headless_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpHeadless);
ADL_EXTERNC int EXPOSED ADL2_Adapter_IsGamingDriver_Info_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpCwgSupport, int* lpIsGamingMode);
ADL_EXTERNC int EXPOSED ADL2_Adapter_MemoryInfo2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLMemoryInfo2 *lpMemoryInfo2);
ADL_EXTERNC int EXPOSED ADL_Adapter_MemoryInfo2_Get(int iAdapterIndex, ADLMemoryInfo2 *lpMemoryInfo2);
ADL_EXTERNC int EXPOSED ADL2_Adapter_TRNG_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iTRNGSize, int iTRNGBufferSize, char *lpTRNGBuffer);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Modes_ReEnumerate(ADL_CONTEXT_HANDLE context);
ADL_EXTERNC int EXPOSED ADL_Adapter_Modes_ReEnumerate();
ADL_EXTERNC int EXPOSED ADL2_Feature_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_UIFEATURES_GROUP iFeatureID, int *iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Feature_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_UIFEATURES_GROUP iFeatureID, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_GcnAsicInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLGcnInfo* gcnInfo);
ADL_EXTERNC int EXPOSED ADL2_GPUVMPageSize_Info_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVMPageSizeSupport, int* iVMPageSizeType);
ADL_EXTERNC int EXPOSED ADL2_GPUVMPageSize_Info_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iVMPageSizeType);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iVRAMUsageInMB);
ADL_EXTERNC int EXPOSED ADL2_Adapter_DedicatedVRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iVRAMUsageInMB);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VideoTheaterModeInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpOverlayDisplayMode, int* lpSavedSettings);
ADL_EXTERNC int EXPOSED ADL_Adapter_VideoTheaterModeInfo_Get(int iAdapterIndex, int* lpOverlayDisplayMode, int* lpSavedSettings);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VideoTheaterModeInfo_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iOverlayDisplayMode, int iSavedSettings);
ADL_EXTERNC int EXPOSED ADL_Adapter_VideoTheaterModeInfo_Set(int iAdapterIndex, int iOverlayDisplayMode, int iSavedSettings);
ADL_EXTERNC int EXPOSED ADL2_MMD_Features_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLFeatureCaps ** lppFeatureCaps, int * lpFeatureCount);
ADL_EXTERNC int EXPOSED ADL_MMD_Features_Caps(int iAdapterIndex, ADLFeatureCaps ** lppFeatureCaps, int * lpFeatureCount);
ADL_EXTERNC int EXPOSED ADL2_MMD_FeatureValues_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLFeatureValues ** lppFeatureValues, int * lpFeatureCount);
ADL_EXTERNC int EXPOSED ADL_MMD_FeatureValues_Get(int iAdapterIndex, ADLFeatureValues ** lppFeatureValues, int * lpFeatureCount);
ADL_EXTERNC int EXPOSED ADL2_MMD_FeatureValues_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLFeatureValues * lpFeatureValues, int iFeatureCount, int ClientID);
ADL_EXTERNC int EXPOSED ADL_MMD_FeatureValues_Set(int iAdapterIndex, ADLFeatureValues * lpFeatureValues, int iFeatureCount, int ClientID);
#if defined (_WIN32) || defined(_WIN64)
ADL_EXTERNC int EXPOSED ADL2_PageMigration_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLVirtualSegmentSettingsOutput *lpVirtualSegSettings);
ADL_EXTERNC int EXPOSED ADL2_PageMigration_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iEnabled, int iNewSize);
#endif /*(_WIN32) || (_WIN64)*/
ADL_EXTERNC int EXPOSED ADL2_Adapter_Crossfire_Caps (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpPreferred, int* lpNumComb, ADLCrossfireComb **ppCrossfireComb);
ADL_EXTERNC int EXPOSED ADL_Adapter_Crossfire_Caps (int iAdapterIndex, int* lpPreferred, int* lpNumComb, ADLCrossfireComb **ppCrossfireComb);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Crossfire_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb, ADLCrossfireInfo *lpCrossfireInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_Crossfire_Get (int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb, ADLCrossfireInfo *lpCrossfireInfo);
ADL_EXTERNC int EXPOSED ADL2_Adapter_Crossfire_Set (ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb);
ADL_EXTERNC int EXPOSED ADL_Adapter_Crossfire_Set (int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb);
ADL_EXTERNC int EXPOSED ADL2_Adapter_MVPU_Set (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iState);
ADL_EXTERNC int EXPOSED ADL2_Adapter_CrossfireX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb, ADLCrossfireInfo *lpCrossfireInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_CrossfireX2_Get(int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb, ADLCrossfireInfo *lpCrossfireInfo);
ADL_EXTERNC int EXPOSED ADL2_Adapter_BoardLayout_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpValidFlags, int *lpNumberSlots, ADLBracketSlotInfo** lppBracketSlot, int* lpNumberConnector, ADLConnectorInfo** lppConnector);
ADL_EXTERNC int EXPOSED ADL_Adapter_BoardLayout_Get(int iAdapterIndex, int* lpValidFlags, int *lpNumberSlots, ADLBracketSlotInfo** lppBracketSlot, int* lpNumberConnector, ADLConnectorInfo** lppConnector);
ADL_EXTERNC int EXPOSED ADL2_Adapter_SupportedConnections_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort, ADLSupportedConnections* lpADLSupportedConnections);
ADL_EXTERNC int EXPOSED ADL_Adapter_SupportedConnections_Get(int iAdapterIndex, ADLDevicePort devicePort, ADLSupportedConnections* lpADLSupportedConnections);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ConnectionState_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort, ADLConnectionState* lpADLConnectionState);
ADL_EXTERNC int EXPOSED ADL_Adapter_ConnectionState_Get(int iAdapterIndex, ADLDevicePort devicePort, ADLConnectionState* lpADLConnectionState);
ADL_EXTERNC int EXPOSED ADL2_Adapter_EmulationMode_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort, int iEmulationMode);
ADL_EXTERNC int EXPOSED ADL_Adapter_EmulationMode_Set(int iAdapterIndex, ADLDevicePort devicePort, int iEmulationMode);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ConnectionData_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort, ADLConnectionData ConnectionData);
ADL_EXTERNC int EXPOSED ADL_Adapter_ConnectionData_Set(int iAdapterIndex, ADLDevicePort devicePort, ADLConnectionData ConnectionData);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ConnectionData_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort, int iQueryType, ADLConnectionData* lpConnectionData);
ADL_EXTERNC int EXPOSED ADL_Adapter_ConnectionData_Get(int iAdapterIndex, ADLDevicePort devicePort, int iQueryType, ADLConnectionData* lpConnectionData);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ConnectionData_Remove(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLDevicePort devicePort);
ADL_EXTERNC int EXPOSED ADL_Adapter_ConnectionData_Remove(int iAdapterIndex, ADLDevicePort devicePort);
ADL_EXTERNC int EXPOSED ADL2_Adapter_EDIDManagement_Caps(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Adapter_EDIDManagement_Caps(int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Workstation_GlobalEDIDPersistence_Get(ADL_CONTEXT_HANDLE context,int *lpCurResultValue, int *lpDefResultValue);
ADL_EXTERNC int EXPOSED ADL_Workstation_GlobalEDIDPersistence_Get(int *lpCurResultValue, int *lpDefResultValue);
ADL_EXTERNC int EXPOSED ADL2_Workstation_GlobalEDIDPersistence_Set(ADL_CONTEXT_HANDLE context,int iCurState);
ADL_EXTERNC int EXPOSED ADL_Workstation_GlobalEDIDPersistence_Set(int iCurState);
ADL_EXTERNC int EXPOSED ADL2_ElmCompatibilityMode_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_ElmCompatibilityMode_Status_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpValue);
ADL_EXTERNC int EXPOSED ADL2_ElmCompatibilityMode_Status_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iValue);
#if defined (_WIN32) || defined(_WIN64)
ADL_EXTERNC int EXPOSED ADL2_FPS_Caps (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpSupported, int *lpVersion);
ADL_EXTERNC int EXPOSED ADL2_FPS_Settings_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLFPSSettingsOutput *lpFPSSettings);
ADL_EXTERNC int EXPOSED ADL2_FPS_Settings_Set (ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLFPSSettingsInput lpFPSSettings);
ADL_EXTERNC int EXPOSED ADL2_FPS_Settings_Reset (ADL_CONTEXT_HANDLE context,int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_RIS_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_RIS_SETTINGS settings, ADL_RIS_NOTFICATION_REASON changeReason);
ADL_EXTERNC int EXPOSED ADL2_RIS_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_RIS_SETTINGS* settings);
ADL_EXTERNC int EXPOSED ADL2_CHILL_SettingsX2_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_CHILL_SETTINGS settings, ADL_CHILL_NOTFICATION_REASON changeReason, ADL_ERROR_REASON* errorReason);
ADL_EXTERNC int EXPOSED ADL2_CHILL_SettingsX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_CHILL_SETTINGS* settings);
ADL_EXTERNC int EXPOSED ADL2_DELAG_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_DELAG_SETTINGS settings, ADL_DELAG_NOTFICATION_REASON changeReason, ADL_ERROR_REASON* errorReason);
ADL_EXTERNC int EXPOSED ADL2_DELAG_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_DELAG_SETTINGS* settings);
ADL_EXTERNC int EXPOSED ADL2_BOOST_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_BOOST_SETTINGS settings, ADL_BOOST_NOTFICATION_REASON changeReason, ADL_ERROR_REASON* errorReason);
ADL_EXTERNC int EXPOSED ADL2_BOOST_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_BOOST_SETTINGS* settings);
ADL_EXTERNC int EXPOSED ADL2_PROVSR_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_PROVSR_SETTINGS settings, ADL_PROVSR_NOTFICATION_REASON changeReason, ADL_ERROR_REASON* errorReason);
ADL_EXTERNC int EXPOSED ADL2_PROVSR_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_PROVSR_SETTINGS* settings);
ADL_EXTERNC int EXPOSED ADL2_Chill_Settings_Notify(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iChanged);
ADL_EXTERNC int EXPOSED ADL2_Chill_Settings_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iEnabled);
ADL_EXTERNC int EXPOSED ADL2_Chill_Settings_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpEnabled);
ADL_EXTERNC int EXPOSED ADL2_Chill_Caps_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iSupported, int* iCheckCaps);
ADL_EXTERNC int EXPOSED ADL2_PerformanceTuning_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_PerfTuning_Status_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpPTuningValue);
ADL_EXTERNC int EXPOSED ADL2_PerfTuning_Status_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int lpPTuningValue);
ADL_EXTERNC int EXPOSED ADL2_PPW_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_PPW_Status_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpFPWValue);
ADL_EXTERNC int EXPOSED ADL2_PPW_Status_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iFPWValue);
#endif /*(_WIN32) || (_WIN64)*/
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *iIsFrameMonitorSupported);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_Start(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int VidPnSourceId);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_Stop(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int VidPnSourceId);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int VidPnSourceId, float *iFramesPerSecond);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_FrameDuration_Enable(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_FRAME_DURATION_HANDLE* frameDurationHandle);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_FrameDuration_Disable(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_FRAME_DURATION_HANDLE* frameDurationHandle);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_FrameDuration_Start(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int VidPnSourceId);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_FrameDuration_Stop(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int VidPnSourceId);
ADL_EXTERNC int EXPOSED ADL2_Adapter_FrameMetrics_FrameDuration_Get(ADL_CONTEXT_HANDLE context, ADL_FRAME_DURATION_HANDLE frameDurationHandle, unsigned long long * pFrameDurationsArr, unsigned int frameDurationsArrSize, unsigned int *elementsCopied);
// Deprecated APIs
ADL_EXTERNC int EXPOSED ADL2_Adapter_ClockInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLClockInfo* lpClockInfo);
ADL_EXTERNC int EXPOSED ADL_Adapter_ClockInfo_Get(int iAdapterIndex, ADLClockInfo* lpClockInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_AdapterID_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpAdapterID);
ADL_EXTERNC int EXPOSED ADL_Display_AdapterID_Get(int iAdapterIndex, int* lpAdapterID);
ADL_EXTERNC int EXPOSED ADL2_Adapter_EDC_ErrorRecords_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* pErrorrecordCount, ADLErrorRecord* errorRecords);
ADL_EXTERNC int EXPOSED ADL2_Adapter_EDC_ErrorInjection_Set (ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLErrorInjection* errorInjection);
#endif /* ADAPTER_H_ */

64
atiadlxx-sys/include/adl.h vendored Normal file
View file

@ -0,0 +1,64 @@
#ifndef ADL_H_
#define ADL_H_
#include "adl_sdk.h"
//#include "amd_only/amd_structures.h"
#include "adapter.h"
#include "display.h"
//#include "workstation.h"
//#include "displaysmanager.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL_Main_ControlX2_Create ( ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADLThreadingModel threadingModel );
ADL_EXTERNC int EXPOSED ADL2_Main_ControlX2_Create ( ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADL_CONTEXT_HANDLE* context, ADLThreadingModel threadingModel);
ADL_EXTERNC int EXPOSED ADL2_Main_ControlX3_Create(ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADL_CONTEXT_HANDLE* context, ADLThreadingModel threadingModel, int adlCreateOptions);
ADL_EXTERNC int EXPOSED ADL_Main_Control_Create ( ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters );
ADL_EXTERNC int EXPOSED ADL2_Main_Control_Create ( ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADL_CONTEXT_HANDLE* context);
ADL_EXTERNC int EXPOSED ADL2_Main_Control_Refresh (ADL_CONTEXT_HANDLE context);
ADL_EXTERNC int EXPOSED ADL_Main_Control_Refresh ();
ADL_EXTERNC int EXPOSED ADL_Main_Control_Destroy ();
ADL_EXTERNC int EXPOSED ADL2_Main_Control_Destroy (ADL_CONTEXT_HANDLE context);
ADL_EXTERNC EXPOSED void* ADL2_Main_Control_GetProcAddress (ADL_CONTEXT_HANDLE context, void* lpModule, char* lpProcName );
ADL_EXTERNC EXPOSED void* ADL_Main_Control_GetProcAddress ( void* lpModule, char* lpProcName );
ADL_EXTERNC int EXPOSED ADL2_RegisterEvent(ADL_CONTEXT_HANDLE context, int eventID, void* evntHandle);
ADL_EXTERNC int EXPOSED ADL2_UnRegisterEvent(ADL_CONTEXT_HANDLE context, int eventID, void* evntHandle);
ADL_EXTERNC int EXPOSED ADL2_RegisterEventX2(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int clientID, int eventID, void* evntHandle);
ADL_EXTERNC int EXPOSED ADL2_UnRegisterEventX2(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int clientID, int eventID, void* evntHandle);
ADL_EXTERNC int EXPOSED ADL2_PerGPU_GDEvent_Register(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int clientID, int eventID, void* evntHandle);
ADL_EXTERNC int EXPOSED ADL2_PerGPU_GDEvent_UnRegister(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int clientID, int eventID, void* evntHandle);
#endif /* ADL_H_ */

2596
atiadlxx-sys/include/adl_defines.h vendored Normal file

File diff suppressed because it is too large Load diff

46
atiadlxx-sys/include/adl_sdk.h vendored Normal file
View file

@ -0,0 +1,46 @@
//
// Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved.
//
// MIT LICENSE:
// 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.
/// \file adl_sdk.h
/// \brief Contains the definition of the Memory Allocation Callback.\n <b>Included in ADL SDK</b>
///
/// \n\n
/// This file contains the definition of the Memory Allocation Callback.\n
/// It also includes definitions of the respective structures and constants.\n
/// <b> This is the only header file to be included in a C/C++ project using ADL </b>
#ifndef ADL_SDK_H_
#define ADL_SDK_H_
#include "adl_structures.h"
#if defined (LINUX)
#define __stdcall
#endif /* (LINUX) */
/// Memory Allocation Call back
typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int );
#define ADL_SDK_MAJOR_VERSION 17
#define ADL_SDK_MINOR_VERSION 1
#endif /* ADL_SDK_H_ */

4289
atiadlxx-sys/include/adl_structures.h vendored Normal file

File diff suppressed because it is too large Load diff

573
atiadlxx-sys/include/display.h vendored Normal file
View file

@ -0,0 +1,573 @@
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_Display_VirtualType_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADL_VIRTUALDISPLAY_TYPE *iVirtualType);
ADL_EXTERNC int EXPOSED ADL2_Display_WriteAndReadI2CLargePayload(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLI2CLargePayload *plI2C);
ADL_EXTERNC int EXPOSED ADL_Display_WriteAndReadI2CLargePayload(int iAdapterIndex, ADLI2CLargePayload *plI2C);
ADL_EXTERNC int EXPOSED ADL2_Display_HDCP_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLHDCPSettings *lpHDCPSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_HDCP_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int iSetToDefault, int iEnable);
ADL_EXTERNC int EXPOSED ADL2_Display_HDRState_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, int *iSupport, int *iEnable);
ADL_EXTERNC int EXPOSED ADL2_Display_HDRState_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, int iEnable);
ADL_EXTERNC int EXPOSED ADL2_Display_Limits_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int* lpMaxHRes, int* lpMaxVRes, int* lpMaxRefresh);
ADL_EXTERNC int EXPOSED ADL2_Display_PreferredMode_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int* lpNumModes, ADLMode** lppModes);
ADL_EXTERNC int EXPOSED ADL_Display_Limits_Get(int iAdapterIndex, int iDisplayIndex, int* lpMaxHRes, int* lpMaxVRes, int* lpMaxRefresh);
ADL_EXTERNC int EXPOSED ADL2_Display_DisplayInfo_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex,
int* lpNumDisplays,
ADLDisplayInfo ** lppInfo,
int iForceDetect);
ADL_EXTERNC int EXPOSED ADL_Display_DisplayInfo_Get (int iAdapterIndex,
int* lpNumDisplays,
ADLDisplayInfo ** lppInfo,
int iForceDetect);
ADL_EXTERNC int EXPOSED ADL2_Display_DpMstInfo_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex,
int* lpNumDisplays,
ADLDisplayDPMSTInfo ** lppDisplayDPMstInfo,
int iForceDetect);
ADL_EXTERNC int EXPOSED ADL_Display_DpMstInfo_Get (int iAdapterIndex,
int* lpNumDisplays,
ADLDisplayDPMSTInfo ** lppDisplayDPMstInfo,
int iForceDetect);
ADL_EXTERNC int EXPOSED ADL2_Display_NumberOfDisplays_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpNumDisplays);
ADL_EXTERNC int EXPOSED ADL_Display_NumberOfDisplays_Get(int iAdapterIndex, int *lpNumDisplays);
ADL_EXTERNC int EXPOSED ADL2_Display_PreservedAspectRatio_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpSupport, int * lpCurrent, int * lpDefault);
ADL_EXTERNC int EXPOSED ADL_Display_PreservedAspectRatio_Get(int iAdapterIndex, int iDisplayIndex, int* lpSupport, int * lpCurrent, int * lpDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_PreservedAspectRatio_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_PreservedAspectRatio_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_ImageExpansion_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpSupport, int * lpCurrent, int * lpDefault);
ADL_EXTERNC int EXPOSED ADL_Display_ImageExpansion_Get(int iAdapterIndex, int iDisplayIndex, int* lpSupport, int * lpCurrent, int * lpDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_ImageExpansion_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_ImageExpansion_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_Position_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpX, int* lpY, int* lpXDefault, int* lpYDefault,
int* lpMinX, int* lpMinY, int* lpMaxX, int*lpMaxY, int* lpStepX, int* lpStepY);
ADL_EXTERNC int EXPOSED ADL_Display_Position_Get(int iAdapterIndex, int iDisplayIndex, int* lpX, int* lpY, int* lpXDefault, int* lpYDefault,
int* lpMinX, int* lpMinY, int* lpMaxX, int*lpMaxY, int* lpStepX, int* lpStepY);
ADL_EXTERNC int EXPOSED ADL2_Display_Position_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iX, int iY);
ADL_EXTERNC int EXPOSED ADL_Display_Position_Set(int iAdapterIndex, int iDisplayIndex, int iX, int iY);
ADL_EXTERNC int EXPOSED ADL2_Display_Size_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpWidth, int* lpHeight, int* lpDefaultWidth, int* lpDefaultHeight,
int* lpMinWidth, int* lpMinHeight, int* lpMaxWidth, int*lpMaxHeight, int* lpStepWidth, int* lpStepHeight);
ADL_EXTERNC int EXPOSED ADL_Display_Size_Get(int iAdapterIndex, int iDisplayIndex, int* lpWidth, int* lpHeight, int* lpDefaultWidth, int* lpDefaultHeight,
int* lpMinWidth, int* lpMinHeight, int* lpMaxWidth, int*lpMaxHeight, int* lpStepWidth, int* lpStepHeight);
ADL_EXTERNC int EXPOSED ADL2_Display_Size_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iWidth, int iHeight);
ADL_EXTERNC int EXPOSED ADL_Display_Size_Set(int iAdapterIndex, int iDisplayIndex, int iWidth, int iHeight);
ADL_EXTERNC int EXPOSED ADL2_Display_AdjustCaps_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpInfo);
ADL_EXTERNC int EXPOSED ADL_Display_AdjustCaps_Get(int iAdapterIndex, int iDisplayIndex, int* lpInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_Capabilities_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpNumberOfControlers, int* lpNumberOfDisplays);
ADL_EXTERNC int EXPOSED ADL_Display_Capabilities_Get(int iAdapterIndex, int* lpNumberOfControlers, int* lpNumberOfDisplays);
ADL_EXTERNC int EXPOSED ADL2_Display_ConnectedDisplays_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int * lpConnections);
ADL_EXTERNC int EXPOSED ADL_Display_ConnectedDisplays_Get(int iAdapterIndex, int * lpConnections);
ADL_EXTERNC int EXPOSED ADL2_Display_DeviceConfig_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayConfig * lpDisplayConfig);
ADL_EXTERNC int EXPOSED ADL_Display_DeviceConfig_Get(int iAdapterIndex, int iDisplayIndex, ADLDisplayConfig * lpDisplayConfig);
ADL_EXTERNC int EXPOSED ADL2_Display_Property_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty * lpDisplayProperty);
ADL_EXTERNC int EXPOSED ADL_Display_Property_Get(int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty * lpDisplayProperty);
ADL_EXTERNC int EXPOSED ADL2_Display_Property_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty * lpDisplayProperty);
ADL_EXTERNC int EXPOSED ADL_Display_Property_Set(int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty * lpDisplayProperty);
ADL_EXTERNC int EXPOSED ADL2_Display_SwitchingCapability_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpResult);
ADL_EXTERNC int EXPOSED ADL_Display_SwitchingCapability_Get(int iAdapterIndex, int *lpResult);
ADL_EXTERNC int EXPOSED ADL2_Display_DitherState_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpDitherState);
ADL_EXTERNC int EXPOSED ADL_Display_DitherState_Get(int iAdapterIndex, int iDisplayIndex, int *lpDitherState);
ADL_EXTERNC int EXPOSED ADL2_Display_DitherState_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iDitherState);
ADL_EXTERNC int EXPOSED ADL_Display_DitherState_Set(int iAdapterIndex, int iDisplayIndex, int iDitherState);
ADL_EXTERNC int EXPOSED ADL2_Display_SupportedPixelFormat_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
ADL_EXTERNC int EXPOSED ADL_Display_SupportedPixelFormat_Get(int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
ADL_EXTERNC int EXPOSED ADL2_Display_PixelFormat_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
ADL_EXTERNC int EXPOSED ADL_Display_PixelFormat_Get(int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
ADL_EXTERNC int EXPOSED ADL2_Display_PixelFormatDefault_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int *lpDefPixelFormat);
ADL_EXTERNC int EXPOSED ADL2_Display_PixelFormat_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iPixelFormat);
ADL_EXTERNC int EXPOSED ADL_Display_PixelFormat_Set(int iAdapterIndex, int iDisplayIndex, int iPixelFormat);
ADL_EXTERNC int EXPOSED ADL2_Display_SupportedColorDepth_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int *lpColorDepth);
ADL_EXTERNC int EXPOSED ADL_Display_SupportedColorDepth_Get(int iAdapterIndex, int iDisplayIndex, int *lpColorDepth);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorDepth_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int *lpColorDepth);
ADL_EXTERNC int EXPOSED ADL_Display_ColorDepth_Get(int iAdapterIndex, int iDisplayIndex, int *lpColorDepth);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorDepth_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int iColorDepth);
ADL_EXTERNC int EXPOSED ADL_Display_ColorDepth_Set(int iAdapterIndex, int iDisplayIndex, int iColorDepth);
ADL_EXTERNC int EXPOSED ADL2_Display_ODClockInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLAdapterODClockInfo *lpOdClockInfo);
ADL_EXTERNC int EXPOSED ADL_Display_ODClockInfo_Get(int iAdapterIndex, ADLAdapterODClockInfo *lpOdClockInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_ODClockConfig_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLAdapterODClockConfig *lpOdClockConfig);
ADL_EXTERNC int EXPOSED ADL_Display_ODClockConfig_Set(int iAdapterIndex, ADLAdapterODClockConfig *lpOdClockConfig);
ADL_EXTERNC int EXPOSED ADL2_Display_AdjustmentCoherent_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpAdjustmentCoherentCurrent, int *lpAdjustmentCoherentDefault);
ADL_EXTERNC int EXPOSED ADL_Display_AdjustmentCoherent_Get(int iAdapterIndex, int iDisplayIndex, int *lpAdjustmentCoherentCurrent, int *lpAdjustmentCoherentDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_AdjustmentCoherent_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iAdjustmentCoherent);
ADL_EXTERNC int EXPOSED ADL_Display_AdjustmentCoherent_Set(int iAdapterIndex, int iDisplayIndex, int iAdjustmentCoherent);
ADL_EXTERNC int EXPOSED ADL2_Display_ReducedBlanking_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpReducedBlankingCurrent, int *lpReducedBlankingDefault);
ADL_EXTERNC int EXPOSED ADL_Display_ReducedBlanking_Get(int iAdapterIndex, int iDisplayIndex, int *lpReducedBlankingCurrent, int *lpReducedBlankingDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_ReducedBlanking_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iReducedBlanking);
ADL_EXTERNC int EXPOSED ADL_Display_ReducedBlanking_Set(int iAdapterIndex, int iDisplayIndex, int iReducedBlanking);
ADL_EXTERNC int EXPOSED ADL2_Display_FormatsOverride_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpSettingsSupported, int* lpSettingsSupportedEx, int* lpCurSettings);
ADL_EXTERNC int EXPOSED ADL_Display_FormatsOverride_Get(int iAdapterIndex, int iDisplayIndex, int* lpSettingsSupported, int* lpSettingsSupportedEx, int* lpCurSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_FormatsOverride_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
ADL_EXTERNC int EXPOSED ADL_Display_FormatsOverride_Set(int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_MVPUCaps_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLMVPUCaps *lpMvpuCaps);
ADL_EXTERNC int EXPOSED ADL_Display_MVPUCaps_Get(int iAdapterIndex, ADLMVPUCaps *lpMvpuCaps);
ADL_EXTERNC int EXPOSED ADL2_Display_MVPUStatus_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLMVPUStatus *lpMvpuStatus);
ADL_EXTERNC int EXPOSED ADL_Display_MVPUStatus_Get(int iAdapterIndex, ADLMVPUStatus *lpMvpuStatus);
ADL_EXTERNC int EXPOSED ADL2_Display_DummyVirtual_Get(ADL_CONTEXT_HANDLE context, int iVirtualDisplayType, int* iTargetID);
ADL_EXTERNC int EXPOSED ADL2_Display_DummyVirtual_Destroy(ADL_CONTEXT_HANDLE context, int iTargetID);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VariBright_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion);
ADL_EXTERNC int EXPOSED ADL_Adapter_VariBright_Caps(int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VariBrightEnable_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iEnabled);
ADL_EXTERNC int EXPOSED ADL_Adapter_VariBrightEnable_Set(int iAdapterIndex, int iEnabled);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VariBrightLevel_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * iDefaultLevel, int * iNumberOfLevels, int * iStep, int * iCurrentLevel);
ADL_EXTERNC int EXPOSED ADL_Adapter_VariBrightLevel_Get(int iAdapterIndex, int * iDefaultLevel, int * iNumberOfLevels, int * iStep, int * iCurrentLevel);
ADL_EXTERNC int EXPOSED ADL2_Adapter_VariBrightLevel_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iCurrentLevel, int iApplyImmediately);
ADL_EXTERNC int EXPOSED ADL_Adapter_VariBrightLevel_Set(int iAdapterIndex, int iCurrentLevel, int iApplyImmediately);
ADL_EXTERNC int EXPOSED ADL2_Display_ControllerOverlayAdjustmentCaps_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLControllerOverlayInput *lpOverlayInput, ADLControllerOverlayInfo *lpCapsInfo);
ADL_EXTERNC int EXPOSED ADL_Display_ControllerOverlayAdjustmentCaps_Get(int iAdapterIndex, ADLControllerOverlayInput *lpOverlayInput, ADLControllerOverlayInfo *lpCapsInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_ControllerOverlayAdjustmentData_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLControllerOverlayInput * lpOverlay);
ADL_EXTERNC int EXPOSED ADL_Display_ControllerOverlayAdjustmentData_Get(int iAdapterIndex, ADLControllerOverlayInput * lpOverlay);
ADL_EXTERNC int EXPOSED ADL2_Display_ControllerOverlayAdjustmentData_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLControllerOverlayInput * lpOverlay);
ADL_EXTERNC int EXPOSED ADL_Display_ControllerOverlayAdjustmentData_Set(int iAdapterIndex, ADLControllerOverlayInput * lpOverlay);
ADL_EXTERNC int EXPOSED ADL2_Display_ViewPort_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLControllerMode * lpControllerMode);
ADL_EXTERNC int EXPOSED ADL_Display_ViewPort_Set(int iAdapterIndex, int iDisplayIndex, ADLControllerMode * lpControllerMode);
ADL_EXTERNC int EXPOSED ADL2_Display_ViewPort_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLControllerMode * lpControllerMode);
ADL_EXTERNC int EXPOSED ADL_Display_ViewPort_Get(int iAdapterIndex, int iDisplayIndex, ADLControllerMode * lpControllerMode);
ADL_EXTERNC int EXPOSED ADL2_Display_ViewPort_Cap(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int* lpSupported);
ADL_EXTERNC int EXPOSED ADL_Display_ViewPort_Cap(int iAdapterIndex, int* lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Display_WriteAndReadI2CRev_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpMajor, int *lpMinor);
ADL_EXTERNC int EXPOSED ADL_Display_WriteAndReadI2CRev_Get(int iAdapterIndex, int *lpMajor, int *lpMinor);
ADL_EXTERNC int EXPOSED ADL2_Display_WriteAndReadI2C(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLI2C *plI2C);
ADL_EXTERNC int EXPOSED ADL_Display_WriteAndReadI2C(int iAdapterIndex, ADLI2C *plI2C);
ADL_EXTERNC int EXPOSED ADL2_Display_DDCBlockAccess_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iOption, int iCommandIndex,int iSendMsgLen, char *lpucSendMsgBuf, int *lpulRecvMsgLen, char *lpucRecvMsgBuf);
ADL_EXTERNC int EXPOSED ADL_Display_DDCBlockAccess_Get(int iAdapterIndex, int iDisplayIndex, int iOption, int iCommandIndex,int iSendMsgLen, char *lpucSendMsgBuf, int *lpulRecvMsgLen, char *lpucRecvMsgBuf);
ADL_EXTERNC int EXPOSED ADL2_Display_DDCInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDDCInfo* lpInfo);
ADL_EXTERNC int EXPOSED ADL_Display_DDCInfo_Get(int iAdapterIndex, int iDisplayIndex, ADLDDCInfo* lpInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_DDCInfo2_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDDCInfo2* lpInfo);
ADL_EXTERNC int EXPOSED ADL_Display_DDCInfo2_Get(int iAdapterIndex, int iDisplayIndex, ADLDDCInfo2* lpInfo);
ADL_EXTERNC int EXPOSED ADL2_Display_EdidData_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayEDIDData *lpEDIDData);
ADL_EXTERNC int EXPOSED ADL_Display_EdidData_Get(int iAdapterIndex, int iDisplayIndex, ADLDisplayEDIDData *lpEDIDData);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorCaps_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpCaps, int* lpValids);
ADL_EXTERNC int EXPOSED ADL_Display_ColorCaps_Get(int iAdapterIndex, int iDisplayIndex, int* lpCaps, int* lpValids);
ADL_EXTERNC int EXPOSED ADL2_Display_Color_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iColorType, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_Color_Set(int iAdapterIndex, int iDisplayIndex, int iColorType, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_Color_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iColorType, int* lpCurrent, int* lpDefault, int* lpMin, int* lpMax, int* lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_Color_Get(int iAdapterIndex, int iDisplayIndex, int iColorType, int* lpCurrent, int* lpDefault, int* lpMin, int* lpMax, int* lpStep);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorTemperatureSource_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpTempSource);
ADL_EXTERNC int EXPOSED ADL_Display_ColorTemperatureSource_Get(int iAdapterIndex, int iDisplayIndex, int *lpTempSource);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorTemperatureSourceDefault_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpTempSourceDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_ColorTemperatureSource_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iTempSource);
ADL_EXTERNC int EXPOSED ADL_Display_ColorTemperatureSource_Set(int iAdapterIndex, int iDisplayIndex, int iTempSource);
ADL_EXTERNC int EXPOSED ADL2_Display_Gamut_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, ADLGamutInfo *lpCap);
ADL_EXTERNC int EXPOSED ADL_Display_Gamut_Caps(int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, ADLGamutInfo *lpCap);
ADL_EXTERNC int EXPOSED ADL2_Display_Gamut_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, ADLGamutData *lpSource);
ADL_EXTERNC int EXPOSED ADL_Display_Gamut_Get(int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, ADLGamutData *lpSource);
ADL_EXTERNC int EXPOSED ADL2_Display_Gamut_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, const ADLGamutData *lpSource);
ADL_EXTERNC int EXPOSED ADL_Display_Gamut_Set(int iAdapterIndex, int iDisplayIndex, ADLGamutReference gamut, const ADLGamutData *lpSource);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverride_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayMode *lpModeIn, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverride_Get(int iAdapterIndex, int iDisplayIndex, ADLDisplayMode *lpModeIn, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverride_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLDisplayModeInfo *lpMode, int iForceUpdate);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverride_Set(int iAdapterIndex, int iDisplayIndex, ADLDisplayModeInfo *lpMode, int iForceUpdate);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideList_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iMaxNumOfOverrides, ADLDisplayModeInfo *lpModeInfoList, int *lpNumOfOverrides);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverrideList_Get(int iAdapterIndex, int iDisplayIndex, int iMaxNumOfOverrides, ADLDisplayModeInfo *lpModeInfoList, int *lpNumOfOverrides);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideX2_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDisplayModeInfoX2 *lpMode, int iForceUpdate);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeX2 *lpModeIn, ADLDisplayModeInfoX2 *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideListX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, int *lpNumOfModes, ADLDisplayModeInfoX2 **lpModeInfoList);
ADL_EXTERNC int EXPOSED ADL2_Adapter_ModeTimingOverride_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Adapter_ModeTimingOverride_Caps(int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeX2 *lpModeIn, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverrideX2_Get(int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeX2 *lpModeIn, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverrideListX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, int *lpNumOfModes, ADLDisplayModeInfo **lpModeInfoList);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverrideListX2_Get(int iAdapterIndex, ADLDisplayID displayID, int *lpNumOfModes, ADLDisplayModeInfo **lpModeInfoList);
ADL_EXTERNC int EXPOSED ADL2_Display_ModeTimingOverride_Delete(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeX2 *lpMode, int iForceUpdate);
ADL_EXTERNC int EXPOSED ADL_Display_ModeTimingOverride_Delete(int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeX2 *lpMode, int iForceUpdate);
ADL_EXTERNC int EXPOSED ADL2_Display_CustomizedModeListNum_Get (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpListNum);
ADL_EXTERNC int EXPOSED ADL_Display_CustomizedModeListNum_Get (int iAdapterIndex, int iDisplayIndex, int* lpListNum);
ADL_EXTERNC int EXPOSED ADL2_Display_CustomizedModeList_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLCustomMode* lpCustomModeList, int iBuffSize);
ADL_EXTERNC int EXPOSED ADL_Display_CustomizedModeList_Get(int iAdapterIndex, int iDisplayIndex, ADLCustomMode* lpCustomModeList, int iBuffSize);
ADL_EXTERNC int EXPOSED ADL2_Display_CustomizedMode_Add (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode);
ADL_EXTERNC int EXPOSED ADL_Display_CustomizedMode_Add (int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode);
ADL_EXTERNC int EXPOSED ADL2_Display_CustomizedMode_Delete (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iIndex);
ADL_EXTERNC int EXPOSED ADL_Display_CustomizedMode_Delete (int iAdapterIndex, int iDisplayIndex, int iIndex);
ADL_EXTERNC int EXPOSED ADL2_Display_CustomizedMode_Validate(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode, int *lpValid);
ADL_EXTERNC int EXPOSED ADL_Display_CustomizedMode_Validate(int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode, int *lpValid);
ADL_EXTERNC int EXPOSED ADL2_Display_UnderscanSupport_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpSupport);
ADL_EXTERNC int EXPOSED ADL2_Display_UnderscanState_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_Display_UnderscanState_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iUnderscanEnabled);
ADL_EXTERNC int EXPOSED ADL2_Display_Underscan_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_Underscan_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_Underscan_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpCurrent, int* lpDefault, int* lpMin, int* lpMax, int* lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_Underscan_Get(int iAdapterIndex, int iDisplayIndex, int* lpCurrent, int* lpDefault, int* lpMin, int* lpMax, int* lpStep);
ADL_EXTERNC int EXPOSED ADL2_Display_Overscan_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_Overscan_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_Overscan_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefualt, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_Overscan_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefualt, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL2_DFP_BaseAudioSupport_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL_DFP_BaseAudioSupport_Get(int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL2_DFP_HDMISupport_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL_DFP_HDMISupport_Get(int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL2_DFP_MVPUAnalogSupport_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL_DFP_MVPUAnalogSupport_Get(int iAdapterIndex, int iDisplayIndex,int* lpSupport);
ADL_EXTERNC int EXPOSED ADL2_DFP_PixelFormat_Caps(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpValidBits, int *lpValidCaps);
ADL_EXTERNC int EXPOSED ADL_DFP_PixelFormat_Caps(int iAdapterIndex, int iDisplayIndex, int *lpValidBits, int *lpValidCaps);
ADL_EXTERNC int EXPOSED ADL2_DFP_PixelFormat_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurState, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL_DFP_PixelFormat_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurState, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_DFP_PixelFormat_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iState);
ADL_EXTERNC int EXPOSED ADL_DFP_PixelFormat_Set(int iAdapterIndex, int iDisplayIndex, int iState);
ADL_EXTERNC int EXPOSED ADL2_DFP_GPUScalingEnable_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL_DFP_GPUScalingEnable_Get(int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_DFP_GPUScalingEnable_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_DFP_GPUScalingEnable_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_DFP_AllowOnlyCETimings_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL_DFP_AllowOnlyCETimings_Get(int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_DFP_AllowOnlyCETimings_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_DFP_AllowOnlyCETimings_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_TVCaps_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpcaps);
ADL_EXTERNC int EXPOSED ADL_Display_TVCaps_Get(int iAdapterIndex, int iDisplayIndex, int* lpcaps);
ADL_EXTERNC int EXPOSED ADL2_TV_Standard_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_TV_Standard_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_TV_Standard_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int* lpSupportedStandards);
ADL_EXTERNC int EXPOSED ADL_TV_Standard_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int* lpSupportedStandards);
ADL_EXTERNC int EXPOSED ADL2_CV_DongleSettings_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* lpDongleSetting, int* lpOverrideSettingsSupported, int* lpCurOverrideSettings);
ADL_EXTERNC int EXPOSED ADL_CV_DongleSettings_Get(int iAdapterIndex, int iDisplayIndex, int* lpDongleSetting, int* lpOverrideSettingsSupported, int* lpCurOverrideSettings);
ADL_EXTERNC int EXPOSED ADL2_CV_DongleSettings_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
ADL_EXTERNC int EXPOSED ADL_CV_DongleSettings_Set(int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
ADL_EXTERNC int EXPOSED ADL2_CV_DongleSettings_Reset(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex);
ADL_EXTERNC int EXPOSED ADL_CV_DongleSettings_Reset(int iAdapterIndex, int iDisplayIndex);
ADL_EXTERNC int EXPOSED ADL2_Display_UnderScan_Auto_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_UnderScan_Auto_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL2_Display_UnderScan_Auto_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_UnderScan_Auto_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_Deflicker_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_Deflicker_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL2_Display_Deflicker_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayindex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_Deflicker_Set(int iAdapterIndex, int iDisplayindex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_FilterSVideo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL_Display_FilterSVideo_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
ADL_EXTERNC int EXPOSED ADL2_Display_FilterSVideo_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL_Display_FilterSVideo_Set(int iAdapterIndex, int iDisplayIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_Display_DisplayContent_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iContent);
ADL_EXTERNC int EXPOSED ADL_Display_DisplayContent_Set(int iAdapterIndex, int iDisplayIndex, int iContent);
ADL_EXTERNC int EXPOSED ADL2_Display_DisplayContent_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex,int iDisplayIndex,int* piContent);
ADL_EXTERNC int EXPOSED ADL_Display_DisplayContent_Get(int iAdapterIndex,int iDisplayIndex,int* piContent);
ADL_EXTERNC int EXPOSED ADL2_Display_DisplayContent_Cap(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int* pCapContent);
ADL_EXTERNC int EXPOSED ADL_Display_DisplayContent_Cap(int iAdapterIndex, int iDisplayIndex, int* pCapContent);
ADL_EXTERNC int EXPOSED ADL2_Display_TargetTiming_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL2_Display_TargetTimingX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeInfoX2 *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL_Display_TargetTiming_Get(int iAdapterIndex, ADLDisplayID displayID, ADLDisplayModeInfo *lpModeInfoOut);
ADL_EXTERNC int EXPOSED ADL_Display_Downscaling_Caps(int iAdapterIndex, int iDisplayID, int* lpCaps);
ADL_EXTERNC int EXPOSED ADL2_Display_Downscaling_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayID, int* lpCaps);
ADL_EXTERNC int EXPOSED ADL_Display_FreeSyncState_Get(int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMinRefreshRateInMicroHz, int *lpMaxRefreshRateInMicroHz);
ADL_EXTERNC int EXPOSED ADL2_Display_FreeSyncState_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMinRefreshRateInMicroHz, int *lpMaxRefreshRateInMicroHz);
ADL_EXTERNC int EXPOSED ADL_Display_FreeSyncState_Set(int iAdapterIndex, int iDisplayIndex, int iSetting, int iRefreshRateInMicroHz);
ADL_EXTERNC int EXPOSED ADL2_Display_FreeSyncState_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDisplayIndex, int iSetting, int iRefreshRateInMicroHz);
ADL_EXTERNC int EXPOSED ADL2_Display_DCE_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL_Display_DCE_Set(int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_DCE_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL_Display_DCE_Get(int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_FreeSync_Cap(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLFreeSyncCap *lpFreeSyncCaps);
ADL_EXTERNC int EXPOSED ADL_Display_FreeSync_Cap(int iAdapterIndex, int iDisplayIndex, ADLFreeSyncCap *lpFreeSyncCaps);
ADL_EXTERNC int EXPOSED ADL2_Display_DCE_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL_Display_DCE_Set(int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL2_Display_DCE_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL_Display_DCE_Get(int iAdapterIndex, int iDisplayIndex, ADLDceSettings *lpADLDceSettings);
ADL_EXTERNC int EXPOSED ADL_CDS_UnsafeMode_Set(int iAdapterIndex, int unsafeMode);
ADL_EXTERNC int EXPOSED ADL2_CDS_UnsafeMode_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int unsafeMode);
ADL_EXTERNC int EXPOSED ADL2_TurboSyncSupport_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iTurboSyncSupported);
ADL_EXTERNC int EXPOSED ADL2_User_Settings_Notify(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_USER_SETTINGS iSetting, int iChanged);
#endif /* DISPLAY_H_ */

85
atiadlxx-sys/include/overdrive5.h vendored Normal file
View file

@ -0,0 +1,85 @@
#ifndef OVERDRIVE5_H_
#define OVERDRIVE5_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_CurrentActivity_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLPMActivity *lpActivity);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_CurrentActivity_Get(int iAdapterIndex, ADLPMActivity *lpActivity);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_ThermalDevices_Enum(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_ThermalDevices_Enum(int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_Temperature_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_Temperature_Get(int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_FanSpeedInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_FanSpeedInfo_Get(int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_FanSpeed_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_FanSpeed_Get(int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_FanSpeed_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_FanSpeed_Set(int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_FanSpeedToDefault_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iThermalControllerIndex);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_FanSpeedToDefault_Set(int iAdapterIndex, int iThermalControllerIndex);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_ODParameters_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLODParameters *lpOdParameters);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_ODParameters_Get(int iAdapterIndex, ADLODParameters *lpOdParameters);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_ODPerformanceLevels_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_ODPerformanceLevels_Get(int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_ODPerformanceLevels_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_ODPerformanceLevels_Set(int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_PowerControl_Caps(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_PowerControl_Caps(int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_PowerControlInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLPowerControlInfo *lpPowerControlInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_PowerControlInfo_Get(int iAdapterIndex, ADLPowerControlInfo *lpPowerControlInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_PowerControl_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_PowerControl_Get(int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive5_PowerControl_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive5_PowerControl_Set(int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive_Caps (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion );
ADL_EXTERNC int EXPOSED ADL_Overdrive_Caps (int iAdapterIndex, int * iSupported, int * iEnabled, int * iVersion );
#endif /* OVERDRIVE5_H_ */

164
atiadlxx-sys/include/overdrive6.h vendored Normal file
View file

@ -0,0 +1,164 @@
#ifndef OVERDRIVE6_H_
#define OVERDRIVE6_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_Capabilities_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6Capabilities *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_Capabilities_Get(int iAdapterIndex, ADLOD6Capabilities *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_StateInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iStateType, ADLOD6StateInfo *lpStateInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_StateInfo_Get(int iAdapterIndex, int iStateType, ADLOD6StateInfo *lpStateInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_State_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iStateType, ADLOD6StateInfo *lpStateInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_State_Set(int iAdapterIndex, int iStateType, ADLOD6StateInfo *lpStateInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_State_Reset(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iStateType);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_State_Reset(int iAdapterIndex, int iStateType);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_CurrentStatus_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6CurrentStatus *lpCurrentStatus);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_CurrentStatus_Get(int iAdapterIndex, ADLOD6CurrentStatus *lpCurrentStatus);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_ThermalController_Caps(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6ThermalControllerCaps *lpThermalControllerCaps);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_ThermalController_Caps(int iAdapterIndex, ADLOD6ThermalControllerCaps *lpThermalControllerCaps);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_Temperature_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpTemperature);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_Temperature_Get(int iAdapterIndex, int *lpTemperature);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanSpeed_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanSpeed_Get(int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanSpeed_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanSpeed_Set(int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanSpeed_Reset(ADL_CONTEXT_HANDLE context,int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanSpeed_Reset(int iAdapterIndex);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_PowerControl_Caps (ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_PowerControl_Caps (int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_PowerControlInfo_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, ADLOD6PowerControlInfo *lpPowerControlInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_PowerControlInfo_Get(int iAdapterIndex, ADLOD6PowerControlInfo *lpPowerControlInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_PowerControl_Get(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_PowerControl_Get(int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_PowerControl_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_PowerControl_Set(int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_VoltageControlInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6VoltageControlInfo *lpVoltageControlInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_VoltageControlInfo_Get(int iAdapterIndex, ADLOD6VoltageControlInfo *lpVoltageControlInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_VoltageControl_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_VoltageControl_Get(int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_VoltageControl_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_VoltageControl_Set(int iAdapterIndex, int iValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_CapabilitiesEx_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6CapabilitiesEx *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_CapabilitiesEx_Get(int iAdapterIndex, ADLOD6CapabilitiesEx *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_StateEx_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, ADLOD6StateEx *lpODState);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_StateEx_Get(int iAdapterIndex, int iStateType, ADLOD6StateEx *lpODState);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_StateEx_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, ADLOD6StateEx *lpODState);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_StateEx_Set(int iAdapterIndex, int iStateType, ADLOD6StateEx *lpODState);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_ThermalLimitUnlock_Set(int iAdapterIndex, int iStateType, int iEnable);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_ThermalLimitUnlock_Set(ADL_CONTEXT_HANDLE context,int iAdapterIndex, int iStateType, int iEnable);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_ThermalLimitUnlock_Get(int iAdapterIndex, int iStateType, int* pEnabled);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_ThermalLimitUnlock_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, int* pEnabled);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_AdvancedFan_Caps (int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_AdvancedFan_Caps (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_TargetTemperatureRangeInfo_Get(int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_TargetTemperatureRangeInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_TargetTemperatureData_Get(int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_TargetTemperatureData_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_TargetTemperatureData_Set(int iAdapterIndex, int iCurrentValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_TargetTemperatureData_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iCurrentValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanPWMLimitRangeInfo_Get(int iAdapterIndex, ADLOD6ParameterRange *lpFanPWMLimitInfo);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanPWMLimitRangeInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6ParameterRange *lpFanPWMLimitInfo);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanPWMLimitData_Get(int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanPWMLimitData_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FanPWMLimitData_Set(int iAdapterIndex, int iCurrentValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FanPWMLimitData_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iCurrentValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_CurrentPower_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iPowerType, int *lpCurrentValue);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_ControlI2C(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iControl);
ADL_EXTERNC int EXPOSED ADL2_Overdrive6_FuzzyController_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL_Overdrive6_FuzzyController_Caps(int iAdapterIndex, int *lpSupported);
#endif /* OVERDRIVE6_H_ */

68
atiadlxx-sys/include/overdrive8.h vendored Normal file
View file

@ -0,0 +1,68 @@
#pragma once
#ifndef OVERDRIVE8_H_
#define OVERDRIVE8_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Init_Setting_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD8InitSetting *lpInitSetting);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Current_Setting_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD8CurrentSetting *lpCurrentSetting);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Setting_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD8SetSetting *lpSetSetting, ADLOD8CurrentSetting *lpCurrentSetting);
ADL_EXTERNC int EXPOSED ADL2_New_QueryPMLogData_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogDataOutput* lpDataOutput);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Init_SettingX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpOverdrive8Capabilities, int *lpNumberOfFeatures, ADLOD8SingleInitSetting** lppInitSettingList);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Current_SettingX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpNumberOfFeatures, int** lppCurrentSettingList);
ADL_EXTERNC int EXPOSED ADL2_AutoTuningResult_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, bool* lpDataOutput);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLogSenorRange_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpNumberOfSupportedSensorRange, ADLOD8SingleInitSetting** lppSenorRangeCapsList);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLogSenorType_Support_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpNumOfSupportedSensorType, int** lppSenroTypesList);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLog_ShareMemory_Support(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int * lpSupported, int option);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLog_ShareMemory_Start(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iSampleRate, int iNumofPMLogSendorList, int* lpPMLogSendorList, ADL_D3DKMT_HANDLE* lpHDevice, void** lppSharedMemory, int iOption);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLog_ShareMemory_Read(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iNumSensor, int *lpSensorList, void** lppSharedMemory, ADLPMLogDataOutput* lpDataOutput);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_PMLog_ShareMemory_Stop(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_D3DKMT_HANDLE *lpHDevice);
ADL_EXTERNC int EXPOSED ADL2_Device_PMLog_Device_Create(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_D3DKMT_HANDLE *pDevice);
ADL_EXTERNC int EXPOSED ADL2_Device_PMLog_Device_Destroy(ADL_CONTEXT_HANDLE context, ADL_D3DKMT_HANDLE hDevice);
ADL_EXTERNC int EXPOSED ADL2_Overdrive8_Current_SettingX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpFeatureNotAdjustableBits, int *lpNumberOfSettings, int** lppCurrentSettingList, int iOption);
ADL_EXTERNC int EXPOSED ADL2_Adapter_PMLog_Support_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogSupportInfo* pPMLogSupportInfo);
ADL_EXTERNC int EXPOSED ADL2_Adapter_PMLog_Start(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogStartInput* pPMLogStartInput, ADLPMLogStartOutput* pPMLogStartOutput, ADL_D3DKMT_HANDLE hDevice);
ADL_EXTERNC int EXPOSED ADL2_Adapter_PMLog_Stop(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADL_D3DKMT_HANDLE hDevice);
ADL_EXTERNC int EXPOSED ADL2_Adapter_PMLog_SensorLimits_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogSensorLimits* lpDataOutput);
#endif /* OVERDRIVE8_H_ */

90
atiadlxx-sys/include/overdriveN.h vendored Normal file
View file

@ -0,0 +1,90 @@
#ifndef OVERDRIVEN_H_
#define OVERDRIVEN_H_
#include "adl_structures.h"
#ifndef ADL_EXTERNC
#ifdef __cplusplus
#define ADL_EXTERNC extern "C"
#else
#define ADL_EXTERNC
#endif
#endif
#ifndef EXPOSED
#define EXPOSED
#endif /* EXPOSED */
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_Capabilities_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNCapabilities *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_CapabilitiesX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNCapabilitiesX2 *lpODCapabilities);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SystemClocks_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevels *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SystemClocks_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevels *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SystemClocksX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2 *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SystemClocksX2_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2 *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryClocksX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2 *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryClocksX2_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2 *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryClocks_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevels *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryClocks_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevels *lpODPerformanceLevels);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_FanControl_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNFanControl *lpODFanSpeed);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_FanControl_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNFanControl *lpODFanControl);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_PowerLimit_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPowerLimitSetting *lpODPowerLimit);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_PowerLimit_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPowerLimitSetting *lpODPowerLimit);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iTemperatureType, int *iTemperature);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_PerformanceStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceStatus *lpODPerformanceStatus);
// Custom fan for WS ODN vega 10
ADL_EXTERNC int EXPOSED ADL2_CustomFan_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported);
ADL_EXTERNC int EXPOSED ADL2_CustomFan_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNFanControl *lpODFanControl);
ADL_EXTERNC int EXPOSED ADL2_CustomFan_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNFanControl *lpODFanControl);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryTimingLevel_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupport, int *lpCurrentValue, int *lpDefaultValue, int *lpNumberLevels, int **lppLevelList);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_MemoryTimingLevel_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int currentValue);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_ZeroRPMFan_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupport, int *lpCurrentValue, int *lpDefaultValue);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_ZeroRPMFan_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int currentValue);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SettingsExt_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpOverdriveNExtCapabilities, int *lpNumberOfODNExtFeatures, ADLODNExtSingleInitSetting** lppInitSettingList, int** lppCurrentSettingList);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SettingsExt_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iNumberOfODNExtFeatures,int* itemValueValidList, int* lpItemValueList);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_AutoWattman_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpSupported, int *lpDefault);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_AutoWattman_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpCurrent);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_AutoWattman_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iCurrent);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_CountOfEvents_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int eventcounterType, int *eventCount);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SCLKAutoOverClock_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpStatus);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_SCLKAutoOverClock_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStatus, int *iFlags);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_Test_Set(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iEnabled);
ADL_EXTERNC int EXPOSED ADL2_OverdriveN_ThrottleNotification_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpStatus, int *lpThrottleFlags);
#endif /* OVERDRIVEN_H_ */

6
atiadlxx-sys/include/wrapper.hpp vendored Normal file
View file

@ -0,0 +1,6 @@
#include <cstddef>
#include "adl.h"
#include "overdrive5.h"
#include "overdrive6.h"
#include "overdriveN.h"
#include "overdrive8.h"

File diff suppressed because it is too large Load diff

Binary file not shown.

8540
atiadlxx-sys/src/adl.rs Normal file

File diff suppressed because it is too large Load diff

5
atiadlxx-sys/src/lib.rs Normal file
View file

@ -0,0 +1,5 @@
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
mod adl;
pub use adl::*;

12
comgr/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "comgr"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2018"
[lib]
[dependencies]
libloading = "0.8"
hip_common = { path = "../hip_common" }
itertools = "0.10.5"

1
comgr/README Normal file
View file

@ -0,0 +1 @@
bindgen .\include\amd_comgr.h --size_t-is-usize --must-use-type "amd_comgr_status_t" --no-layout-tests --no-derive-debug --default-enum-style=newtype --dynamic-loading LibComgr --dynamic-link-require-all -o src/amd_comgr.rs --whitelist-function="^amd_comgr_action_data_get_data$|^amd_comgr_action_info_set_isa_name$|^amd_comgr_action_info_set_option_list$|^amd_comgr_create_action_info$|^amd_comgr_create_data$|^amd_comgr_create_data_set$|^amd_comgr_data_set_add$|^amd_comgr_destroy_action_info$|^amd_comgr_destroy_data_set$|^amd_comgr_do_action$|^amd_comgr_get_data$|^amd_comgr_release_data$|^amd_comgr_set_data$|^amd_comgr_set_data_name$|^amd_comgr_action_info_set_language$|^amd_comgr_set_data_name$"

2344
comgr/include/amd_comgr.h Normal file

File diff suppressed because it is too large Load diff

1004
comgr/src/amd_comgr.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,4 @@
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
@__zluda_ptx_impl__COMPILATION_MODE = linkonce_odr local_unnamed_addr addrspace(4) constant i8 3, align 1

626
comgr/src/lib.rs Normal file
View file

@ -0,0 +1,626 @@
#[allow(non_camel_case_types)]
#[allow(dead_code)]
#[path = "amd_comgr.rs"]
pub mod sys;
use hip_common::CompilationMode;
use itertools::Either;
use std::{
borrow::Borrow,
ffi::{CStr, CString},
iter, mem, ptr,
rc::Rc,
sync::atomic::{AtomicU64, Ordering},
};
use sys::LibComgr;
#[cfg(windows)]
static CODE_OBJECT_VERSION_FLAG_COMGR: &'static [u8] = b"code_object_v4\0"; // Code Object v5 is broken as of Adrenaline 23.11.1
#[cfg(windows)]
static CODE_OBJECT_VERSION_FLAG_CLANG: &'static [u8] = b"-mcode-object-version=4\0"; // Code Object v5 is broken as of Adrenaline 23.11.1
#[cfg(not(windows))]
static CODE_OBJECT_VERSION_FLAG_COMGR: &'static [u8] = b"code_object_v5\0";
#[cfg(not(windows))]
static CODE_OBJECT_VERSION_FLAG_CLANG: &'static [u8] = b"-mcode-object-version=5\0";
macro_rules! call {
($expr:expr) => {
#[allow(unused_unsafe)]
{
unsafe {
let result = $expr;
if result != sys::amd_comgr_status_t::AMD_COMGR_STATUS_SUCCESS {
return Err(result);
}
}
}
};
}
pub type Result<T> = std::result::Result<T, sys::amd_comgr_status_t>;
pub struct Comgr(LibComgr, AtomicU64);
static WAVE32_MODULE: &'static [u8] = include_bytes!("wave32.ll");
static WAVE32_ON_WAVE64_MODULE: &'static [u8] = include_bytes!("wave32_on_wave64.ll");
static DOUBLE_WAVE32_ON_WAVE64_MODULE: &'static [u8] = include_bytes!("double_wave32_on_wave64.ll");
#[cfg(windows)]
static OS_MODULE: &'static [u8] = include_bytes!("windows.ll");
#[cfg(not(windows))]
static OS_MODULE: &'static [u8] = include_bytes!("linux.ll");
impl Comgr {
pub fn find_and_load() -> Result<Self> {
match unsafe { Self::load_library() } {
Ok(libcomgr) => Ok(Self(libcomgr, AtomicU64::new(1))),
Err(_) => Err(sys::amd_comgr_status_t::AMD_COMGR_STATUS_ERROR),
}
}
#[cfg(windows)]
unsafe fn load_library() -> std::result::Result<LibComgr, libloading::Error> {
LibComgr::new("amd_comgr.dll")
}
#[cfg(not(windows))]
unsafe fn load_library() -> std::result::Result<LibComgr, libloading::Error> {
LibComgr::new("libamd_comgr.so.2")
.or_else(|_| LibComgr::new("/opt/rocm/lib/libamd_comgr.so.2"))
}
fn get(&self) -> &LibComgr {
&self.0
}
pub fn compile<'a>(
&self,
compilation_mode: CompilationMode,
isa: &'a CStr,
input_bitcode: impl Iterator<Item = (impl AsRef<[u8]>, impl AsRef<CStr>)>,
linker_module: &[u8],
) -> Result<Vec<u8>> {
let bitcode = self.link_bitcode_impl(compilation_mode, isa, input_bitcode)?;
let relocatable = self.build_relocatable_impl(compilation_mode, isa, &bitcode)?;
if !linker_module.is_empty() {
let source = self.assemble_source(isa, linker_module)?;
self.link_relocatable_impl(
isa,
IntoIterator::into_iter([
&relocatable.get_data(
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
0,
)?,
&source,
]),
)
} else {
self.link_relocatable_impl(
isa,
iter::once(&relocatable.get_data(
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
0,
)?),
)
}
}
pub fn link_bitcode<'this, 'a>(
&'this self,
compilation_mode: CompilationMode,
isa: &'a CStr,
input_bitcode: impl Iterator<Item = (impl AsRef<[u8]>, &'a CStr)>,
) -> Result<Bitcode<'this>> {
let data_set_bitcode = self.link_bitcode_impl(compilation_mode, isa, input_bitcode)?;
Ok(Bitcode(data_set_bitcode))
}
pub fn bitcode_to_relocatable<'a>(
self: &Rc<Self>,
compilation_mode: CompilationMode,
isa: &'a CStr,
bc: &Bitcode,
) -> Result<Relocatable> {
let data_set_relocatable = self.build_relocatable_impl(compilation_mode, isa, &bc.0)?;
Ok(Relocatable::from_data(data_set_relocatable.get_data_rc(
self.clone(),
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
0,
)?)?)
}
pub fn build_relocatable<'a>(
self: &Rc<Self>,
compilation_mode: CompilationMode,
isa: &'a CStr,
input_bitcode: impl Iterator<Item = (impl AsRef<[u8]>, &'a CStr)>,
) -> Result<Relocatable> {
let bitcode = self.link_bitcode_impl(compilation_mode, isa, input_bitcode)?;
let data_set_relocatable = self.build_relocatable_impl(compilation_mode, isa, &bitcode)?;
Ok(Relocatable::from_data(data_set_relocatable.get_data_rc(
self.clone(),
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
0,
)?)?)
}
pub fn link_relocatable<'a>(
self: &Rc<Self>,
isa: &'a CStr,
modules: impl Iterator<Item = &'a Relocatable>,
) -> Result<Vec<u8>> {
self.link_relocatable_impl(isa, modules.map(|reloc| &reloc.0))
}
pub fn version(&self) -> Result<String> {
let mut data_set = DataSet::new(self)?;
let data = Data::new(
self,
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_SOURCE,
b"__VERSION__",
unsafe { CStr::from_bytes_with_nul_unchecked(b"version.h\0") },
)?;
data_set.add(&data)?;
let result = self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR,
&data_set,
unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") },
iter::once(unsafe { CStr::from_bytes_with_nul_unchecked(b"-nogpuinc\0") }),
Some(sys::amd_comgr_language_t::AMD_COMGR_LANGUAGE_HIP),
)?;
let result = result.get_data(sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_SOURCE, 0)?;
let result = result.get_data()?;
let end_quote = result
.iter()
.copied()
.rposition(|c| c as char == '"')
.ok_or(sys::amd_comgr_status_t::AMD_COMGR_STATUS_ERROR)?;
let start_quote = result[..end_quote]
.iter()
.copied()
.rposition(|c| c as char == '"')
.ok_or(sys::amd_comgr_status_t::AMD_COMGR_STATUS_ERROR)?;
String::from_utf8(result[start_quote + 1..end_quote].to_vec())
.map_err(|_| sys::amd_comgr_status_t::AMD_COMGR_STATUS_ERROR)
}
fn link_bitcode_impl<'this, 'a>(
&'this self,
compilation_mode: CompilationMode,
isa: &'a CStr,
input_bitcode: impl Iterator<Item = (impl AsRef<[u8]>, impl AsRef<CStr>)>,
) -> Result<DataSet<'this>> {
let mut bitcode_modules = DataSet::new(self)?;
for (bc, name) in input_bitcode {
bitcode_modules.add(&Data::new(
self,
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_BC,
bc.as_ref(),
name.as_ref(),
)?)?;
}
let wave_module_text = match compilation_mode {
CompilationMode::Wave32 => WAVE32_MODULE,
CompilationMode::Wave32OnWave64 => WAVE32_ON_WAVE64_MODULE,
CompilationMode::DoubleWave32OnWave64 => DOUBLE_WAVE32_ON_WAVE64_MODULE,
};
let wave_module = Data::new(
self,
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_BC,
wave_module_text,
unsafe { CStr::from_bytes_with_nul_unchecked(b"wave.ll\0") },
)?;
bitcode_modules.add(&wave_module)?;
let os_module = Data::new(
self,
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_BC,
OS_MODULE,
unsafe { CStr::from_bytes_with_nul_unchecked(b"os.ll\0") },
)?;
bitcode_modules.add(&os_module)?;
let lib_options = unsafe {
match compilation_mode {
CompilationMode::Wave32 => Either::Left([CStr::from_bytes_with_nul_unchecked(
CODE_OBJECT_VERSION_FLAG_COMGR,
)]),
CompilationMode::Wave32OnWave64 | CompilationMode::DoubleWave32OnWave64 => {
Either::Right([
CStr::from_bytes_with_nul_unchecked(CODE_OBJECT_VERSION_FLAG_COMGR),
CStr::from_bytes_with_nul_unchecked(b"wavefrontsize64\0"),
])
}
}
};
let device_linking_output: DataSet<'_> = self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES,
&bitcode_modules,
isa,
lib_options.into_iter(),
Some(sys::amd_comgr_language_t::AMD_COMGR_LANGUAGE_OPENCL_2_0),
)?;
self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_LINK_BC_TO_BC,
&device_linking_output,
isa,
unsafe {
[CStr::from_bytes_with_nul_unchecked(
CODE_OBJECT_VERSION_FLAG_COMGR,
)]
.iter()
.copied()
},
None,
)
}
fn build_relocatable_impl<'this, 'a>(
&'this self,
compilation_mode: CompilationMode,
isa: &'a CStr,
bc_linking_output: &DataSet<'this>,
) -> Result<DataSet<'this>> {
let debug_level = if cfg!(debug_assertions) {
unsafe {
[
CStr::from_bytes_with_nul_unchecked(b"-g\0"),
CStr::from_bytes_with_nul_unchecked(b"\0"),
CStr::from_bytes_with_nul_unchecked(b"\0"),
]
}
} else {
unsafe {
[
CStr::from_bytes_with_nul_unchecked(b"-g0\0"),
// TODO: tweak and measure impact
CStr::from_bytes_with_nul_unchecked(b"-mllvm\0"),
CStr::from_bytes_with_nul_unchecked(b"-inline-threshold=5000\0"),
]
}
};
let compilation_mode = unsafe {
if compilation_mode == CompilationMode::Wave32 {
CStr::from_bytes_with_nul_unchecked(b"-mno-wavefrontsize64\0")
} else {
CStr::from_bytes_with_nul_unchecked(b"-mwavefrontsize64\0")
}
};
let relocatable = self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE,
bc_linking_output,
isa,
unsafe {
[
compilation_mode,
CStr::from_bytes_with_nul_unchecked(CODE_OBJECT_VERSION_FLAG_CLANG),
CStr::from_bytes_with_nul_unchecked(b"-O3\0"),
// TODO: measure more
// Slightly more efficient in Blender
CStr::from_bytes_with_nul_unchecked(b"-mcumode\0"),
CStr::from_bytes_with_nul_unchecked(b"-ffp-contract=off\0"),
CStr::from_bytes_with_nul_unchecked(b"-mllvm\0"),
CStr::from_bytes_with_nul_unchecked(b"-amdgpu-internalize-symbols\0"),
// TODO: This emits scratch_ instead of buffer_ instructions
// for stack spills&fills, measure impact
// CStr::from_bytes_with_nul_unchecked(b"-Xclang\0"),
// CStr::from_bytes_with_nul_unchecked(b"-target-feature\0"),
// CStr::from_bytes_with_nul_unchecked(b"-Xclang\0"),
// CStr::from_bytes_with_nul_unchecked(b"+enable-flat-scratch\0"),
// Useful for debugging miscompilations
// CStr::from_bytes_with_nul_unchecked(b"-mllvm\0"),
// CStr::from_bytes_with_nul_unchecked(b"-opt-bisect-limit=-1\0"),
]
}
.iter()
.copied()
.chain(debug_level.iter().copied()),
None,
)?;
Ok(relocatable)
}
fn link_relocatable_impl<'this, 'a, C: Borrow<Comgr> + 'a>(
&'this self,
isa: &'a CStr,
modules: impl Iterator<Item = &'a Data<C>>,
) -> Result<Vec<u8>> {
let mut input = DataSet::new(self)?;
for module in modules {
input.add(module)?;
}
let executable_set: DataSet = self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE,
&input,
isa,
unsafe {
[
CStr::from_bytes_with_nul_unchecked(b"-Xlinker\0"),
CStr::from_bytes_with_nul_unchecked(b"--no-undefined\0"),
]
}
.iter()
.copied(),
None,
)?;
let executable_data = executable_set.get_data(
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_EXECUTABLE,
0,
)?;
executable_data.get_data()
}
fn assemble_source(&self, isa: &CStr, src: &[u8]) -> Result<Data<&Self>> {
let data = Data::new(
self,
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_SOURCE,
src,
unsafe { CStr::from_bytes_with_nul_unchecked(b"input.s\0") },
)?;
let mut data_set = DataSet::new(self)?;
data_set.add(&data)?;
let assembled = self.do_action(
sys::amd_comgr_action_kind_t::AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE,
&data_set,
isa,
iter::once(unsafe {
CStr::from_bytes_with_nul_unchecked(CODE_OBJECT_VERSION_FLAG_CLANG)
}),
None,
)?;
assembled.get_data(
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
0,
)
}
fn do_action<'a, 'cstr>(
&'a self,
kind: sys::amd_comgr_action_kind_t,
input: &DataSet,
isa: &CStr,
options: impl Iterator<Item = &'cstr CStr>,
language: Option<sys::amd_comgr_language_t>,
) -> Result<DataSet<'a>> {
let output = DataSet::new(self)?;
let action = ActionInfo::new(self, isa)?;
if options.size_hint().1.unwrap() > 0 {
action.set_options(options)?;
}
if let Some(lang) = language {
action.set_language(lang)?;
}
action.execute(kind, &input, &output)?;
Ok(output)
}
}
pub struct Bitcode<'a>(DataSet<'a>);
impl<'a> Bitcode<'a> {
pub fn get_data(&self) -> Result<Vec<u8>> {
self.0
.get_data(sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_BC, 0)?
.get_data()
}
}
pub struct Relocatable(Data<Rc<Comgr>>);
impl Relocatable {
fn from_data(data: Data<Rc<Comgr>>) -> Result<Self> {
let suffix = data.1 .1.fetch_add(1, Ordering::Relaxed);
let new_name = format!("reloc_{}.o\0", suffix);
call!(data
.1
.get()
.amd_comgr_set_data_name(data.0, new_name.as_ptr() as _));
Ok(Self(data))
}
pub fn new(comgr: &Rc<Comgr>, vec: &[u8]) -> Result<Self> {
let suffix = comgr.1.fetch_add(1, Ordering::Relaxed);
let new_name = format!("reloc_{}.o", suffix);
let data = Data::new(
comgr.clone(),
sys::amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_RELOCATABLE,
vec,
&CString::new(new_name).map_err(|_| sys::amd_comgr_status_t::AMD_COMGR_STATUS_ERROR)?,
)?;
Ok(Self(data))
}
pub fn get_data(&self) -> Result<Vec<u8>> {
self.0.get_data()
}
}
struct ActionInfo<'a>(sys::amd_comgr_action_info_t, &'a Comgr);
impl<'a> ActionInfo<'a> {
fn new(comgr: &'a Comgr, isa: &'a CStr) -> Result<Self> {
unsafe {
let mut action_info = mem::zeroed();
call!(comgr.get().amd_comgr_create_action_info(&mut action_info));
call!(comgr
.get()
.amd_comgr_action_info_set_isa_name(action_info, isa.as_ptr() as _));
Ok(ActionInfo(action_info, comgr))
}
}
fn get(&self) -> sys::amd_comgr_action_info_t {
self.0
}
fn set_options<'cstr>(&self, options: impl Iterator<Item = &'cstr CStr>) -> Result<()> {
let mut options_c = options.map(CStr::as_ptr).collect::<Vec<_>>();
call!(self.1.get().amd_comgr_action_info_set_option_list(
self.get(),
options_c.as_mut_ptr(),
options_c.len()
));
Ok(())
}
fn set_language(&self, lang: sys::amd_comgr_language_t) -> Result<()> {
call!(self
.1
.get()
.amd_comgr_action_info_set_language(self.get(), lang));
Ok(())
}
fn execute(
&self,
kind: sys::amd_comgr_action_kind_t,
input: &DataSet<'a>,
output: &DataSet<'a>,
) -> Result<()> {
call!(self
.1
.get()
.amd_comgr_do_action(kind, self.get(), input.get(), output.get()));
Ok(())
}
}
#[allow(unused_must_use)]
impl<'a> Drop for ActionInfo<'a> {
fn drop(&mut self) {
unsafe { self.1.get().amd_comgr_destroy_action_info(self.get()) };
}
}
struct DataSet<'a> {
base: sys::amd_comgr_data_set_t,
comgr: &'a Comgr,
}
impl<'a> DataSet<'a> {
fn new(comgr: &'a Comgr) -> Result<DataSet<'a>> {
unsafe {
let mut base = mem::zeroed();
call!(comgr.get().amd_comgr_create_data_set(&mut base));
Ok(DataSet { base, comgr })
}
}
fn add<C: Borrow<Comgr>>(&mut self, data: &Data<C>) -> Result<()> {
call!(self
.comgr
.get()
.amd_comgr_data_set_add(self.base, data.get()));
Ok(())
}
fn get_data(&self, kind: sys::amd_comgr_data_kind_t, index: usize) -> Result<Data<&'a Comgr>> {
let mut output = unsafe { mem::zeroed() };
call!(self.comgr.get().amd_comgr_action_data_get_data(
self.get(),
kind,
index,
&mut output
));
Ok(Data(output, self.comgr))
}
fn get_data_rc(
&self,
comgr: Rc<Comgr>,
kind: sys::amd_comgr_data_kind_t,
index: usize,
) -> Result<Data<Rc<Comgr>>> {
assert!(std::ptr::eq::<Comgr>(self.comgr as *const _, &*comgr));
let mut output = unsafe { mem::zeroed() };
call!(self.comgr.get().amd_comgr_action_data_get_data(
self.get(),
kind,
index,
&mut output
));
Ok(Data(output, comgr))
}
fn get(&self) -> sys::amd_comgr_data_set_t {
self.base
}
}
#[allow(unused_must_use)]
impl<'a> Drop for DataSet<'a> {
fn drop(&mut self) {
unsafe { self.comgr.get().amd_comgr_destroy_data_set(self.get()) };
}
}
struct Data<C: Borrow<Comgr>>(sys::amd_comgr_data_t, C);
impl<C: Borrow<Comgr>> Data<C> {
fn new(
comgr: C,
kind: sys::amd_comgr_data_kind_t,
data: &[u8],
name: &CStr,
) -> Result<Data<C>> {
let mut comgr_data = unsafe { mem::zeroed() };
call!(comgr
.borrow()
.get()
.amd_comgr_create_data(kind, &mut comgr_data));
call!(comgr
.borrow()
.get()
.amd_comgr_set_data_name(comgr_data, name.as_ptr() as _));
call!(comgr
.borrow()
.get()
.amd_comgr_set_data(comgr_data, data.len(), data.as_ptr() as _));
Ok(Self(comgr_data, comgr))
}
fn get(&self) -> sys::amd_comgr_data_t {
self.0
}
fn get_data(&self) -> Result<Vec<u8>> {
let mut size = 0;
call!(self
.1
.borrow()
.get()
.amd_comgr_get_data(self.get(), &mut size, ptr::null_mut()));
let mut output = vec![0u8; size];
call!(self.1.borrow().get().amd_comgr_get_data(
self.get(),
&mut size,
output.as_mut_ptr() as _
));
Ok(output)
}
}
impl<C: Borrow<Comgr> + Clone> Clone for Data<C> {
fn clone(&self) -> Self {
Self(self.0.clone(), self.1.clone())
}
}
#[allow(unused_must_use)]
impl<C: Borrow<Comgr>> Drop for Data<C> {
fn drop(&mut self) {
unsafe { self.1.borrow().get().amd_comgr_release_data(self.get()) };
}
}
#[cfg(test)]
mod tests {
use crate::Comgr;
#[test]
fn version() {
let comgr = Comgr::find_and_load().unwrap();
let version = comgr.version().unwrap();
assert!(version.contains("Clang"));
assert!(!version.contains("\""));
assert!(!version.contains("\n"));
}
}

4
comgr/src/linux.ll Normal file
View file

@ -0,0 +1,4 @@
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
@__zluda_ptx_impl__IS_WINDOWS = linkonce_odr local_unnamed_addr addrspace(4) constant i1 0

4
comgr/src/wave32.ll Normal file
View file

@ -0,0 +1,4 @@
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
@__zluda_ptx_impl__COMPILATION_MODE = linkonce_odr local_unnamed_addr addrspace(4) constant i8 1, align 1

View file

@ -0,0 +1,4 @@
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
@__zluda_ptx_impl__COMPILATION_MODE = linkonce_odr local_unnamed_addr addrspace(4) constant i8 2, align 1

4
comgr/src/windows.ll Normal file
View file

@ -0,0 +1,4 @@
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn-amd-amdhsa"
@__zluda_ptx_impl__IS_WINDOWS = linkonce_odr local_unnamed_addr addrspace(4) constant i1 1

14
cuda_base/Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "cuda_base"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2018"
[lib]
proc-macro = true
[dependencies]
quote = "1.0"
syn = { version = "1.0.93", features = ["full", "visit", "visit-mut"] }
proc-macro2 = "1.0"
rustc-hash = "1.1"

1
cuda_base/README Normal file
View file

@ -0,0 +1 @@
bindgen build/wrapper.h -o src/cuda.rs --no-partialeq "CUDA_HOST_NODE_PARAMS_st" --no-partialeq "CUDA_HOST_NODE_PARAMS_v2_st" --with-derive-eq --allowlist-function="^cu.*" --allowlist-var="^CU.*" --default-enum-style=newtype --no-layout-tests --no-doc-comments --new-type-alias "^CUdevice_v\d+$|^CUdeviceptr_v\d+$" --must-use-type "cudaError_enum" -- -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include"

View file

@ -0,0 +1,7 @@
#define __CUDA_API_VERSION_INTERNAL
#ifdef _WIN32
#include <Windows.h>
#endif
#include <cuda.h>
#include <cudaGL.h>
#include <cudaProfiler.h>

File diff suppressed because it is too large Load diff

556
cuda_base/src/lib.rs Normal file
View file

@ -0,0 +1,556 @@
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::{format_ident, quote, ToTokens};
use rustc_hash::{FxHashMap, FxHashSet};
use std::collections::hash_map;
use std::iter;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::visit::Visit;
use syn::visit_mut::VisitMut;
use syn::{
bracketed, parse_macro_input, Abi, Fields, File, FnArg, ForeignItem, ForeignItemFn, Ident,
Item, ItemEnum, ItemForeignMod, ItemStruct, ItemUnion, LitStr, PatType, Path, PathArguments,
PathSegment, ReturnType, Signature, Token, Type, TypeArray, TypePath, TypePtr,
};
const CUDA_RS: &'static str = include_str! {"cuda.rs"};
// This macro copies cuda.rs as-is with some changes:
// * All function declarations are filtered out
// * CUdeviceptr_v2 is redefined from `unsigned long long` to `*void`
// * `extern "C"` gets replaced by `extern "system"`
// * CUuuid_st is redefined to use uchar instead of char
// * Every type except anything graph-related is marked as Send and Sync
// TODO: Improve Send/Sync generation. Currently types that are defined as
// pointers (which is 99% of useful types) can't be marked as Send&Sync
// Their definition should be changed to newtype with a null() function
// and all code should be updated accordingly
#[proc_macro]
pub fn cuda_type_declarations(_: TokenStream) -> TokenStream {
let mut cuda_module = syn::parse_str::<File>(CUDA_RS).unwrap();
cuda_module.items = cuda_module
.items
.into_iter()
.filter_map(|item| match item {
Item::ForeignMod(_) => None,
Item::Struct(mut struct_) => {
if "CUdeviceptr_v2" == struct_.ident.to_string() {
match &mut struct_.fields {
Fields::Unnamed(ref mut fields) => {
fields.unnamed[0].ty =
absolute_path_to_mut_ptr(&["std", "os", "raw", "c_void"])
}
_ => unreachable!(),
}
} else if "CUuuid_st" == struct_.ident.to_string() {
match &mut struct_.fields {
Fields::Named(ref mut fields) => match fields.named[0].ty {
Type::Array(TypeArray { ref mut elem, .. }) => {
*elem = Box::new(Type::Path(TypePath {
qself: None,
path: segments_to_path(&["std", "os", "raw", "c_uchar"]),
}))
}
_ => unreachable!(),
},
_ => panic!(),
}
}
Some(Item::Struct(struct_))
}
i => Some(i),
})
.collect::<Vec<_>>();
mark_types_as_send_sync(&mut cuda_module);
syn::visit_mut::visit_file_mut(&mut FixAbi, &mut cuda_module);
cuda_module.into_token_stream().into()
}
fn mark_types_as_send_sync(cuda_module: &mut File) {
let mut types_for_send_sync = CollectTypesForSendSync { types: Vec::new() };
syn::visit::visit_file(&mut types_for_send_sync, &cuda_module);
for type_ in types_for_send_sync.types {
let send: Item = syn::parse_quote! {
unsafe impl Send for #type_ {}
};
cuda_module.items.push(send);
let sync: Item = syn::parse_quote! {
unsafe impl Sync for #type_ {}
};
cuda_module.items.push(sync);
}
}
fn segments_to_path(path: &[&'static str]) -> Path {
let mut segments = Punctuated::new();
for ident in path {
let ident = PathSegment {
ident: Ident::new(ident, Span::call_site()),
arguments: PathArguments::None,
};
segments.push(ident);
}
Path {
leading_colon: Some(Token![::](Span::call_site())),
segments,
}
}
fn absolute_path_to_mut_ptr(path: &[&'static str]) -> Type {
Type::Ptr(TypePtr {
star_token: Token![*](Span::call_site()),
const_token: None,
mutability: Some(Token![mut](Span::call_site())),
elem: Box::new(Type::Path(TypePath {
qself: None,
path: segments_to_path(path),
})),
})
}
struct FixAbi;
impl VisitMut for FixAbi {
fn visit_abi_mut(&mut self, i: &mut Abi) {
if let Some(ref mut name) = i.name {
*name = LitStr::new("system", Span::call_site());
}
}
}
struct CollectTypesForSendSync {
types: Vec<Ident>,
}
impl CollectTypesForSendSync {
fn try_add(&mut self, ident: &Ident) {
let mut name = ident.to_string();
name.make_ascii_lowercase();
if name.contains("graph") {
return;
}
self.types.push(ident.clone());
}
}
impl<'ast> Visit<'ast> for CollectTypesForSendSync {
fn visit_item_struct(&mut self, item_struct: &'ast ItemStruct) {
self.try_add(&item_struct.ident);
}
fn visit_item_union(&mut self, item_struct: &'ast ItemUnion) {
self.try_add(&item_struct.ident);
}
fn visit_item_enum(&mut self, item_struct: &'ast ItemEnum) {
self.try_add(&item_struct.ident);
}
}
// This macro accepts following arguments:
// * `type_path`: path to the module with type definitions (in the module tree)
// * `normal_macro`: ident for a normal macro
// * `override_macro`: ident for an override macro
// * `override_fns`: list of override functions
// Then macro goes through every function in rust.rs, and for every fn `foo`:
// * if `foo` is contained in `override_fns` then pass it into `override_macro`
// * if `foo` is not contained in `override_fns` pass it to `normal_macro`
// Both `override_macro` and `normal_macro` expect semicolon-separated list:
// macro_foo!(
// "system" fn cuCtxDetach(ctx: CUcontext) -> CUresult;
// "system" fn cuCtxDetach(ctx: CUcontext) -> CUresult
// )
// Additionally, it does a fixup of CUDA types so they get prefixed with `type_path`
#[proc_macro]
pub fn cuda_function_declarations(tokens: TokenStream) -> TokenStream {
let input = parse_macro_input!(tokens as FnDeclInput);
let cuda_module = syn::parse_str::<File>(CUDA_RS).unwrap();
let override_fns = input
.override_fns
.iter()
.map(ToString::to_string)
.collect::<FxHashSet<_>>();
let (normal_macro_args, override_macro_args): (Vec<_>, Vec<_>) = cuda_module
.items
.into_iter()
.filter_map(|item| match item {
Item::ForeignMod(ItemForeignMod { mut items, .. }) => match items.pop().unwrap() {
ForeignItem::Fn(ForeignItemFn {
sig:
Signature {
ident,
inputs,
output,
..
},
..
}) => {
let use_normal_macro = !override_fns.contains(&ident.to_string());
let inputs = inputs
.into_iter()
.map(|fn_arg| match fn_arg {
FnArg::Typed(mut pat_type) => {
pat_type.ty =
prepend_cuda_path_to_type(&input.type_path, pat_type.ty);
FnArg::Typed(pat_type)
}
_ => unreachable!(),
})
.collect::<Punctuated<_, Token![,]>>();
let output = match output {
ReturnType::Type(_, type_) => type_,
ReturnType::Default => unreachable!(),
};
let type_path = input.type_path.clone();
Some((
quote! {
"system" fn #ident(#inputs) -> #type_path :: #output
},
use_normal_macro,
))
}
_ => unreachable!(),
},
_ => None,
})
.partition(|(_, use_normal_macro)| *use_normal_macro);
let mut result = proc_macro2::TokenStream::new();
if !normal_macro_args.is_empty() {
let punctuated_normal_macro_args = to_punctuated::<Token![;]>(normal_macro_args);
let macro_ = &input.normal_macro;
result.extend(iter::once(quote! {
#macro_ ! (#punctuated_normal_macro_args);
}));
}
if !override_macro_args.is_empty() {
let punctuated_override_macro_args = to_punctuated::<Token![;]>(override_macro_args);
let macro_ = &input.override_macro;
result.extend(iter::once(quote! {
#macro_ ! (#punctuated_override_macro_args);
}));
}
result.into()
}
fn to_punctuated<P: ToTokens + Default>(
elms: Vec<(proc_macro2::TokenStream, bool)>,
) -> proc_macro2::TokenStream {
let mut collection = Punctuated::<proc_macro2::TokenStream, P>::new();
collection.extend(elms.into_iter().map(|(token_stream, _)| token_stream));
collection.into_token_stream()
}
fn prepend_cuda_path_to_type(base_path: &Path, type_: Box<Type>) -> Box<Type> {
match *type_ {
Type::Path(mut type_path) => {
type_path.path = prepend_cuda_path_to_path(base_path, type_path.path);
Box::new(Type::Path(type_path))
}
Type::Ptr(mut type_ptr) => {
type_ptr.elem = prepend_cuda_path_to_type(base_path, type_ptr.elem);
Box::new(Type::Ptr(type_ptr))
}
_ => unreachable!(),
}
}
fn prepend_cuda_path_to_path(base_path: &Path, path: Path) -> Path {
if path.leading_colon.is_some() {
return path;
}
if path.segments.len() == 1 {
let ident = path.segments[0].ident.to_string();
if ident.starts_with("CU")
|| ident.starts_with("cu")
|| ident.starts_with("GL")
|| ident == "HGPUNV"
{
let mut base_path = base_path.clone();
base_path.segments.extend(path.segments);
return base_path;
}
}
path
}
struct FnDeclInput {
type_path: Path,
normal_macro: Path,
override_macro: Path,
override_fns: Punctuated<Ident, Token![,]>,
}
impl Parse for FnDeclInput {
fn parse(input: ParseStream) -> syn::Result<Self> {
let type_path = input.parse::<Path>()?;
input.parse::<Token![,]>()?;
let normal_macro = input.parse::<Path>()?;
input.parse::<Token![,]>()?;
let override_macro = input.parse::<Path>()?;
input.parse::<Token![,]>()?;
let override_fns_content;
bracketed!(override_fns_content in input);
let override_fns = override_fns_content.parse_terminated(Ident::parse)?;
Ok(Self {
type_path,
normal_macro,
override_macro,
override_fns,
})
}
}
// This trait accepts following parameters:
// * `type_path`: path to the module with type definitions (in the module tree)
// * `trait_`: name of the trait to be derived
// * `ignore_types`: bracketed list of types to ignore
// * `ignore_fns`: bracketed list of fns to ignore
#[proc_macro]
pub fn cuda_derive_display_trait(tokens: TokenStream) -> TokenStream {
let input = parse_macro_input!(tokens as DeriveDisplayInput);
let cuda_module = syn::parse_str::<File>(CUDA_RS).unwrap();
let mut derive_state = DeriveDisplayState::new(input);
cuda_module
.items
.into_iter()
.filter_map(|i| cuda_derive_display_trait_for_item(&mut derive_state, i))
.collect::<proc_macro2::TokenStream>()
.into()
}
fn cuda_derive_display_trait_for_item(
state: &mut DeriveDisplayState,
item: Item,
) -> Option<proc_macro2::TokenStream> {
let path_prefix = &state.type_path;
let path_prefix_iter = iter::repeat(&path_prefix);
let trait_ = &state.trait_;
let trait_iter = iter::repeat(&state.trait_);
match item {
Item::Const(_) => None,
Item::ForeignMod(ItemForeignMod { mut items, .. }) => match items.pop().unwrap() {
ForeignItem::Fn(ForeignItemFn {
sig: Signature { ident, inputs, .. },
..
}) => {
if state.ignore_fns.contains(&ident) {
return None;
}
let inputs = inputs
.into_iter()
.map(|fn_arg| match fn_arg {
FnArg::Typed(mut pat_type) => {
pat_type.ty = prepend_cuda_path_to_type(path_prefix, pat_type.ty);
FnArg::Typed(pat_type)
}
_ => unreachable!(),
})
.collect::<Vec<_>>();
let inputs_iter = inputs.iter();
let mut arg_name_iter = inputs.iter().map(|fn_arg| match fn_arg {
FnArg::Typed(PatType { pat, .. }) => pat,
_ => unreachable!(),
});
let fn_name = format_ident!("write_{}", ident);
let original_fn_name = ident.to_string();
Some(match arg_name_iter.next() {
Some(first_arg_name) => quote! {
pub fn #fn_name(writer: &mut (impl std::io::Write + ?Sized), #(#inputs_iter,)*) -> std::io::Result<()> {
writer.write_all(concat!("(", stringify!(#first_arg_name), ": ").as_bytes())?;
let mut arg_idx = 0usize;
CudaDisplay::write(&#first_arg_name, #original_fn_name, arg_idx, writer)?;
#(
writer.write_all(b", ")?;
writer.write_all(concat!(stringify!(#arg_name_iter), ": ").as_bytes())?;
CudaDisplay::write(&#arg_name_iter, #original_fn_name, arg_idx, writer)?;
arg_idx += 1;
)*
writer.write_all(b")")
}
},
None => quote! {
pub fn #fn_name(writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
writer.write_all(b"()")
}
},
})
}
_ => unreachable!(),
},
Item::Impl(mut item_impl) => {
let enum_ = match *(item_impl.self_ty) {
Type::Path(mut path) => path.path.segments.pop().unwrap().into_value().ident,
_ => unreachable!(),
};
let variant_ = match item_impl.items.pop().unwrap() {
syn::ImplItem::Const(item_const) => item_const.ident,
_ => unreachable!(),
};
state.record_enum_variant(enum_, variant_);
None
}
Item::Struct(item_struct) => {
let item_struct_name = item_struct.ident.to_string();
if state.ignore_types.contains(&item_struct.ident) {
return None;
}
if item_struct_name.ends_with("_enum") {
let enum_ = &item_struct.ident;
let enum_iter = iter::repeat(&item_struct.ident);
let variants = state.enums.get(&item_struct.ident).unwrap().iter();
Some(quote! {
impl #trait_ for #path_prefix :: #enum_ {
fn write(&self, _fn_name: &'static str, _index: usize, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
match self {
#(& #path_prefix_iter :: #enum_iter :: #variants => writer.write_all(stringify!(#variants).as_bytes()),)*
_ => write!(writer, "{}", self.0)
}
}
}
})
} else {
let struct_ = &item_struct.ident;
let (first_field, rest_of_fields) = match item_struct.fields {
Fields::Named(fields) => {
let mut all_idents = fields.named.into_iter().filter_map(|f| {
let f_ident = f.ident.unwrap();
let name = f_ident.to_string();
if name.starts_with("reserved") || name == "_unused" {
None
} else {
Some(f_ident)
}
});
let first = match all_idents.next() {
Some(f) => f,
None => return None,
};
(first, all_idents)
}
_ => return None,
};
Some(quote! {
impl #trait_ for #path_prefix :: #struct_ {
fn write(&self, _fn_name: &'static str, _index: usize, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
writer.write_all(concat!("{ ", stringify!(#first_field), ": ").as_bytes())?;
#trait_::write(&self.#first_field, "", 0, writer)?;
#(
writer.write_all(concat!(", ", stringify!(#rest_of_fields), ": ").as_bytes())?;
#trait_iter::write(&self.#rest_of_fields, "", 0, writer)?;
)*
writer.write_all(b" }")
}
}
})
}
}
Item::Type(item_type) => {
if state.ignore_types.contains(&item_type.ident) {
return None;
};
match *(item_type.ty) {
Type::Ptr(_) => {
let type_ = item_type.ident;
Some(quote! {
impl #trait_ for #path_prefix :: #type_ {
fn write(&self, _fn_name: &'static str, _index: usize, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
write!(writer, "{:p}", *self)
}
}
})
}
Type::Path(type_path) => {
if type_path.path.leading_colon.is_some() {
let option_seg = type_path.path.segments.last().unwrap();
if option_seg.ident == "Option" {
match &option_seg.arguments {
PathArguments::AngleBracketed(generic) => match generic.args[0] {
syn::GenericArgument::Type(Type::BareFn(_)) => {
let type_ = &item_type.ident;
return Some(quote! {
impl #trait_ for #path_prefix :: #type_ {
fn write(&self, _fn_name: &'static str, _index: usize, writer: &mut (impl std::io::Write + ?Sized)) -> std::io::Result<()> {
write!(writer, "{:p}", unsafe { std::mem::transmute::<#path_prefix :: #type_, *mut ::std::ffi::c_void>(*self) })
}
}
});
}
_ => unreachable!(),
},
_ => unreachable!(),
}
}
}
None
}
_ => unreachable!(),
}
}
Item::Union(_) => None,
Item::Use(_) => None,
_ => unreachable!(),
}
}
struct DeriveDisplayState {
type_path: Path,
trait_: Path,
ignore_types: FxHashSet<Ident>,
ignore_fns: FxHashSet<Ident>,
enums: FxHashMap<Ident, Vec<Ident>>,
}
impl DeriveDisplayState {
fn new(input: DeriveDisplayInput) -> Self {
DeriveDisplayState {
type_path: input.type_path,
trait_: input.trait_,
ignore_types: input.ignore_types.into_iter().collect(),
ignore_fns: input.ignore_fns.into_iter().collect(),
enums: Default::default(),
}
}
fn record_enum_variant(&mut self, enum_: Ident, variant: Ident) {
match self.enums.entry(enum_) {
hash_map::Entry::Occupied(mut entry) => {
entry.get_mut().push(variant);
}
hash_map::Entry::Vacant(entry) => {
entry.insert(vec![variant]);
}
}
}
}
struct DeriveDisplayInput {
type_path: Path,
trait_: Path,
ignore_types: Punctuated<Ident, Token![,]>,
ignore_fns: Punctuated<Ident, Token![,]>,
}
impl Parse for DeriveDisplayInput {
fn parse(input: ParseStream) -> syn::Result<Self> {
let type_path = input.parse::<Path>()?;
input.parse::<Token![,]>()?;
let trait_ = input.parse::<Path>()?;
input.parse::<Token![,]>()?;
let ignore_types_buffer;
bracketed!(ignore_types_buffer in input);
let ignore_types = ignore_types_buffer.parse_terminated(Ident::parse)?;
input.parse::<Token![,]>()?;
let ignore_fns_buffer;
bracketed!(ignore_fns_buffer in input);
let ignore_fns = ignore_fns_buffer.parse_terminated(Ident::parse)?;
Ok(Self {
type_path,
trait_,
ignore_types,
ignore_fns,
})
}
}

8
cuda_types/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "cuda_types"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2018"
[dependencies]
cuda_base = { path = "../cuda_base" }

12
cuda_types/src/lib.rs Normal file
View file

@ -0,0 +1,12 @@
use cuda_base::cuda_type_declarations;
cuda_type_declarations!();
impl From<CUresult> for Result<(), CUresult> {
fn from(value: CUresult) -> Self {
match value {
CUresult::CUDA_SUCCESS => Ok(()),
err => Err(err),
}
}
}

File diff suppressed because it is too large Load diff

1
ext/llvm-project vendored Submodule

@ -0,0 +1 @@
Subproject commit 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a

3
ext/llvm-sys.rs/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Generated by Cargo.
/target
Cargo.lock

19
ext/llvm-sys.rs/.gitlab-ci.yml vendored Normal file
View file

@ -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

21
ext/llvm-sys.rs/Cargo.toml vendored Normal file
View file

@ -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 <peter@taricorp.net>",
]
build = "build.rs"
[dependencies]
libc = "0.2"
[build-dependencies]
cmake = "0.1"
convert_case = "0.5"

19
ext/llvm-sys.rs/LICENSE vendored Normal file
View file

@ -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.

188
ext/llvm-sys.rs/README.md vendored Normal file
View file

@ -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.

20
ext/llvm-sys.rs/appveyor.yml vendored Normal file
View file

@ -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

2
ext/llvm-sys.rs/build.cmake vendored Normal file
View file

@ -0,0 +1,2 @@
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

140
ext/llvm-sys.rs/build.rs vendored Normal file
View file

@ -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++");
}
}

View file

@ -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`

View file

@ -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

35
ext/llvm-sys.rs/src/analysis.rs vendored Normal file
View file

@ -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);
}

70
ext/llvm-sys.rs/src/bit_reader.rs vendored Normal file
View file

@ -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;
}

23
ext/llvm-sys.rs/src/bit_writer.rs vendored Normal file
View file

@ -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;
}

66
ext/llvm-sys.rs/src/blake3.rs vendored Normal file
View file

@ -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);
}

34
ext/llvm-sys.rs/src/comdat.rs vendored Normal file
View file

@ -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);
}

2095
ext/llvm-sys.rs/src/core.rs vendored Normal file

File diff suppressed because it is too large Load diff

880
ext/llvm-sys.rs/src/debuginfo.rs vendored Normal file
View file

@ -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;
}

147
ext/llvm-sys.rs/src/disassembler.rs vendored Normal file
View file

@ -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;
}

18
ext/llvm-sys.rs/src/error.rs vendored Normal file
View file

@ -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;
}

17
ext/llvm-sys.rs/src/error_handling.rs vendored Normal file
View file

@ -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();
}

212
ext/llvm-sys.rs/src/execution_engine.rs vendored Normal file
View file

@ -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;
}

19
ext/llvm-sys.rs/src/initialization.rs vendored Normal file
View file

@ -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);
}

16
ext/llvm-sys.rs/src/ir_reader.rs vendored Normal file
View file

@ -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;
}

500
ext/llvm-sys.rs/src/lib.rs vendored Normal file
View file

@ -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"
));

19
ext/llvm-sys.rs/src/linker.rs vendored Normal file
View file

@ -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;
}

442
ext/llvm-sys.rs/src/lto.rs vendored Normal file
View file

@ -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,
);
}

164
ext/llvm-sys.rs/src/object.rs vendored Normal file
View file

@ -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;
}

11
ext/llvm-sys.rs/src/orc2/ee.rs vendored Normal file
View file

@ -0,0 +1,11 @@
use super::*;
extern "C" {
pub fn LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(
ES: LLVMOrcExecutionSessionRef,
) -> LLVMOrcObjectLayerRef;
pub fn LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(
RTDyldObjLinkingLayer: LLVMOrcObjectLayerRef,
Listener: LLVMJITEventListenerRef,
);
}

74
ext/llvm-sys.rs/src/orc2/lljit.rs vendored Normal file
View file

@ -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;
}

539
ext/llvm-sys.rs/src/orc2/mod.rs vendored Normal file
View file

@ -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;
}

134
ext/llvm-sys.rs/src/remarks.rs vendored Normal file
View file

@ -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;
}

22
ext/llvm-sys.rs/src/support.rs vendored Normal file
View file

@ -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);
}

195
ext/llvm-sys.rs/src/target.rs vendored Normal file
View file

@ -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;
}

111
ext/llvm-sys.rs/src/target_machine.rs vendored Normal file
View file

@ -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);
}

8
ext/llvm-sys.rs/src/transforms.rs vendored Normal file
View file

@ -0,0 +1,8 @@
use super::*;
// Util
extern "C" {
pub fn LLVMAddLowerSwitchPass(PM: LLVMPassManagerRef );
pub fn LLVMAddPromoteMemoryToRegisterPass(PM: LLVMPassManagerRef );
}

View file

@ -0,0 +1,5 @@
use prelude::*;
extern "C" {
pub fn LLVMAddAggressiveInstCombinerPass(PM: LLVMPassManagerRef);
}

View file

@ -0,0 +1,5 @@
use super::super::prelude::*;
extern "C" {
pub fn LLVMAddInstructionCombiningPass(PM: LLVMPassManagerRef);
}

25
ext/llvm-sys.rs/src/transforms/ipo.rs vendored Normal file
View file

@ -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);
}

View file

@ -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);
}

View file

@ -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,
);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

48
ext/llvm-sys.rs/wrappers/target.c vendored Normal file
View file

@ -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();
}

10
ext/optix_ext/README.md vendored Normal file
View file

@ -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

View file

@ -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__ */

View file

@ -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__ */

View file

@ -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__ */

Some files were not shown because too many files have changed in this diff Show more