Skip to content

Commit

Permalink
⚗️ Add experimental custom device intrinsics
Browse files Browse the repository at this point in the history
This allows extending clang with additional builtin headers for device
compilation.
  • Loading branch information
aaronmondal committed May 6, 2024
1 parent c1d2682 commit 6531e10
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/styles/config/vocabularies/eomii/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ buildable
bundler
eomii
hermeticity
intrinsics
lockfile
multithreading
namespace
Expand Down
21 changes: 12 additions & 9 deletions docs/reference/defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ load("@rules_ll//ll:defs.bzl", "ll_binary")
## `ll_binary`

<pre><code>ll_binary(<a href="#ll_binary-name">name</a>, <a href="#ll_binary-deps">deps</a>, <a href="#ll_binary-srcs">srcs</a>, <a href="#ll_binary-data">data</a>, <a href="#ll_binary-hdrs">hdrs</a>, <a href="#ll_binary-angled_includes">angled_includes</a>, <a href="#ll_binary-compilation_mode">compilation_mode</a>, <a href="#ll_binary-compile_flags">compile_flags</a>, <a href="#ll_binary-defines">defines</a>,
<a href="#ll_binary-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_binary-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_binary-exposed_defines">exposed_defines</a>, <a href="#ll_binary-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_binary-exposed_includes">exposed_includes</a>,
<a href="#ll_binary-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_binary-includes">includes</a>, <a href="#ll_binary-interfaces">interfaces</a>, <a href="#ll_binary-libraries">libraries</a>, <a href="#ll_binary-link_flags">link_flags</a>, <a href="#ll_binary-sanitize">sanitize</a>,
<a href="#ll_binary-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_binary-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_binary-experimental_device_intrinsics">experimental_device_intrinsics</a>, <a href="#ll_binary-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_binary-exposed_defines">exposed_defines</a>,
<a href="#ll_binary-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_binary-exposed_includes">exposed_includes</a>, <a href="#ll_binary-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_binary-includes">includes</a>, <a href="#ll_binary-interfaces">interfaces</a>, <a href="#ll_binary-libraries">libraries</a>,
<a href="#ll_binary-link_flags">link_flags</a>, <a href="#ll_binary-sanitize">sanitize</a>, <a href="#ll_binary-toolchain_configuration">toolchain_configuration</a>)</code></pre>
Creates an executable.

Example:
Expand All @@ -39,6 +39,7 @@ Example:
| <a id="ll_binary-compile_flags"></a>`compile_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler.<br><br>Pass a list of strings here. For instance `["-O3", "-std=c++20"]`.<br><br>Split flag pairs `-Xclang -somearg` into separate flags `["-Xclang", "-somearg"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_binary-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_binary-depends_on_llvm"></a>`depends_on_llvm` | <code>Boolean</code>, optional, defaults to <code>False</code>.<br><br> Whether this target directly depends on targets from the `llvm-project-overlay`.<br><br>Setting this to `True` makes the `cc_library` targets from the LLVM project overlay available to this target. |
| <a id="ll_binary-experimental_device_intrinsics"></a>`experimental_device_intrinsics` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Custom intrinsics for device compilation.<br><br>Adds `-Xarch_device -include<thefile>` to the compile commands for this target. |
| <a id="ll_binary-exposed_angled_includes"></a>`exposed_angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed angled include paths, relative to the original target workspace.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_binary-exposed_defines"></a>`exposed_defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed defines for this target.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_binary-exposed_hdrs"></a>`exposed_hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Exposed headers for this target.<br><br>Direct dependents can see exposed headers. Put the public API headers for libraries here. |
Expand Down Expand Up @@ -93,9 +94,9 @@ TODO
## `ll_library`

<pre><code>ll_library(<a href="#ll_library-name">name</a>, <a href="#ll_library-deps">deps</a>, <a href="#ll_library-srcs">srcs</a>, <a href="#ll_library-data">data</a>, <a href="#ll_library-hdrs">hdrs</a>, <a href="#ll_library-angled_includes">angled_includes</a>, <a href="#ll_library-compilation_mode">compilation_mode</a>, <a href="#ll_library-compile_flags">compile_flags</a>, <a href="#ll_library-defines">defines</a>,
<a href="#ll_library-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_library-emit">emit</a>, <a href="#ll_library-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_library-exposed_defines">exposed_defines</a>, <a href="#ll_library-exposed_hdrs">exposed_hdrs</a>,
<a href="#ll_library-exposed_includes">exposed_includes</a>, <a href="#ll_library-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_library-includes">includes</a>, <a href="#ll_library-interfaces">interfaces</a>, <a href="#ll_library-sanitize">sanitize</a>,
<a href="#ll_library-shared_object_link_flags">shared_object_link_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_library-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_library-emit">emit</a>, <a href="#ll_library-experimental_device_intrinsics">experimental_device_intrinsics</a>, <a href="#ll_library-exposed_angled_includes">exposed_angled_includes</a>,
<a href="#ll_library-exposed_defines">exposed_defines</a>, <a href="#ll_library-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_library-exposed_includes">exposed_includes</a>, <a href="#ll_library-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_library-includes">includes</a>, <a href="#ll_library-interfaces">interfaces</a>,
<a href="#ll_library-sanitize">sanitize</a>, <a href="#ll_library-shared_object_link_flags">shared_object_link_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>)</code></pre>
Creates a static archive.

Example:
Expand All @@ -120,6 +121,7 @@ Example:
| <a id="ll_library-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_library-depends_on_llvm"></a>`depends_on_llvm` | <code>Boolean</code>, optional, defaults to <code>False</code>.<br><br> Whether this target directly depends on targets from the `llvm-project-overlay`.<br><br>Setting this to `True` makes the `cc_library` targets from the LLVM project overlay available to this target. |
| <a id="ll_library-emit"></a>`emit` | <code>List of strings</code>, optional, defaults to <code>["archive"]</code>.<br><br> Sets the output mode.<br><br>You can enable several output types at the same time.<br><br>`"archive"` invokes the archiver and adds an archive with a `.a` extension to the outputs.<br><br>`"shared_object"` invokes the linker and adds a shared object with a `.so` extension to the outputs.<br><br>`"objects"` adds loose object files to the outputs. |
| <a id="ll_library-experimental_device_intrinsics"></a>`experimental_device_intrinsics` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Custom intrinsics for device compilation.<br><br>Adds `-Xarch_device -include<thefile>` to the compile commands for this target. |
| <a id="ll_library-exposed_angled_includes"></a>`exposed_angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed angled include paths, relative to the original target workspace.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_library-exposed_defines"></a>`exposed_defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed defines for this target.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_library-exposed_hdrs"></a>`exposed_hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Exposed headers for this target.<br><br>Direct dependents can see exposed headers. Put the public API headers for libraries here. |
Expand All @@ -137,9 +139,9 @@ Example:
## `ll_test`

<pre><code>ll_test(<a href="#ll_test-name">name</a>, <a href="#ll_test-deps">deps</a>, <a href="#ll_test-srcs">srcs</a>, <a href="#ll_test-data">data</a>, <a href="#ll_test-hdrs">hdrs</a>, <a href="#ll_test-angled_includes">angled_includes</a>, <a href="#ll_test-compilation_mode">compilation_mode</a>, <a href="#ll_test-compile_flags">compile_flags</a>, <a href="#ll_test-defines">defines</a>,
<a href="#ll_test-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_test-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_test-exposed_defines">exposed_defines</a>, <a href="#ll_test-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_test-exposed_includes">exposed_includes</a>,
<a href="#ll_test-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_test-includes">includes</a>, <a href="#ll_test-interfaces">interfaces</a>, <a href="#ll_test-libraries">libraries</a>, <a href="#ll_test-link_flags">link_flags</a>, <a href="#ll_test-sanitize">sanitize</a>,
<a href="#ll_test-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_test-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_test-experimental_device_intrinsics">experimental_device_intrinsics</a>, <a href="#ll_test-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_test-exposed_defines">exposed_defines</a>,
<a href="#ll_test-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_test-exposed_includes">exposed_includes</a>, <a href="#ll_test-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_test-includes">includes</a>, <a href="#ll_test-interfaces">interfaces</a>, <a href="#ll_test-libraries">libraries</a>,
<a href="#ll_test-link_flags">link_flags</a>, <a href="#ll_test-sanitize">sanitize</a>, <a href="#ll_test-toolchain_configuration">toolchain_configuration</a>)</code></pre>
Testable wrapper around `ll_binary`.

Consider using this rule over skylib's `native_test` targets to propagate shared
Expand Down Expand Up @@ -172,6 +174,7 @@ Example:
| <a id="ll_test-compile_flags"></a>`compile_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the compiler.<br><br>Pass a list of strings here. For instance `["-O3", "-std=c++20"]`.<br><br>Split flag pairs `-Xclang -somearg` into separate flags `["-Xclang", "-somearg"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_test-defines"></a>`defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Defines for this target.<br><br>Pass a list of strings here. For instance `["MYDEFINE_1", "MYDEFINE_2"]`.<br><br>Unavailable to downstream targets. |
| <a id="ll_test-depends_on_llvm"></a>`depends_on_llvm` | <code>Boolean</code>, optional, defaults to <code>False</code>.<br><br> Whether this target directly depends on targets from the `llvm-project-overlay`.<br><br>Setting this to `True` makes the `cc_library` targets from the LLVM project overlay available to this target. |
| <a id="ll_test-experimental_device_intrinsics"></a>`experimental_device_intrinsics` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Custom intrinsics for device compilation.<br><br>Adds `-Xarch_device -include<thefile>` to the compile commands for this target. |
| <a id="ll_test-exposed_angled_includes"></a>`exposed_angled_includes` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed angled include paths, relative to the original target workspace.<br><br>Expands paths starting with `$(GENERATED)` to the workspace location in the `GENDIR` path.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_test-exposed_defines"></a>`exposed_defines` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Exposed defines for this target.<br><br>Added to the compile command line arguments of direct dependents. |
| <a id="ll_test-exposed_hdrs"></a>`exposed_hdrs` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Exposed headers for this target.<br><br>Direct dependents can see exposed headers. Put the public API headers for libraries here. |
Expand Down
Loading

0 comments on commit 6531e10

Please sign in to comment.