Skip to content

Commit 2645289

Browse files
committed
[Offload] Add Sphinx HTML documentation target
Introduces the `docs-offload-html` target when CMake is configured with `LLVM_ENABLE_SPHINX=ON` and `SPHINX_OUTPUT_HTML=ON`. Utilized `offload-tblgen -gen-spen` to generate Offload API specification docs.
1 parent 4c02465 commit 2645289

File tree

6 files changed

+96
-15
lines changed

6 files changed

+96
-15
lines changed

offload/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
2323
return()
2424
endif()
2525

26+
set(OFFLOAD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
27+
2628
if(OPENMP_STANDALONE_BUILD)
2729
set(OFFLOAD_LIBDIR_SUFFIX "" CACHE STRING
2830
"Suffix of lib installation directory, e.g. 64 => lib64")
@@ -371,6 +373,7 @@ add_subdirectory(tools/offload-tblgen)
371373
add_subdirectory(plugins-nextgen)
372374
add_subdirectory(DeviceRTL)
373375
add_subdirectory(tools)
376+
add_subdirectory(docs)
374377

375378
# Build target agnostic offloading library.
376379
add_subdirectory(libomptarget)

offload/docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_static/
2+
_themes/
3+
offload-api.rst

offload/docs/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
if(LLVM_ENABLE_SPHINX)
2+
include(AddSphinxTarget)
3+
if(SPHINX_FOUND AND SPHINX_OUTPUT_HTML)
4+
# Generate offload-api.rst from OffloadAPI.td
5+
set(LLVM_TARGET_DEFINITIONS
6+
${OFFLOAD_SOURCE_DIR}/liboffload/API/OffloadAPI.td)
7+
tablegen(OFFLOAD source/offload-api.rst -gen-spec
8+
EXTRA_INCLUDES ${OFFLOAD_SOURCE_DIR}/liboffload/API)
9+
add_public_tablegen_target(OffloadDocsGenerate)
10+
11+
# Due to Sphinx only allowing a single source direcotry and the fact we
12+
# only generate a single file, copy offload-api.rst to the source directory
13+
# to be included in the generated documentation.
14+
# Additionally, copy the llvm-theme into the Sphinx source directory.
15+
# A .gitignore file ensures the copied files will not be added to the
16+
# repository.
17+
add_custom_target(OffloadDocsCopy
18+
COMMAND ${CMAKE_COMMAND} -E copy
19+
${CMAKE_CURRENT_BINARY_DIR}/source/offload-api.rst
20+
${CMAKE_CURRENT_SOURCE_DIR}/offload-api.rst
21+
COMMAND ${CMAKE_COMMAND} -E copy
22+
${OFFLOAD_SOURCE_DIR}/../clang/www/favicon.ico
23+
${CMAKE_CURRENT_SOURCE_DIR}/_static/favicon.ico
24+
COMMAND ${CMAKE_COMMAND} -E copy
25+
${OFFLOAD_SOURCE_DIR}/../llvm/docs/_static/llvm.css
26+
${CMAKE_CURRENT_SOURCE_DIR}/_static/llvm.css
27+
COMMAND ${CMAKE_COMMAND} -E copy_directory
28+
${OFFLOAD_SOURCE_DIR}/../llvm/docs/_themes
29+
${CMAKE_CURRENT_SOURCE_DIR}/_themes
30+
)
31+
add_dependencies(OffloadDocsCopy OffloadDocsGenerate)
32+
33+
# Generate the HTML documentation, the docs-offload-html target.
34+
add_sphinx_target(html offload)
35+
add_dependencies(docs-offload-html OffloadDocsCopy)
36+
endif()
37+
endif()

offload/docs/conf.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = "Offload"
10+
copyright = "2025, LLVM project"
11+
author = "LLVM project"
12+
13+
# -- General configuration ---------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
15+
16+
extensions = []
17+
18+
templates_path = ["_templates"]
19+
exclude_patterns = []
20+
21+
# -- C domain configuration --------------------------------------------------
22+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#c-config
23+
24+
c_maximum_signature_line_length = 60
25+
26+
# -- Options for HTML output -------------------------------------------------
27+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
28+
29+
html_theme = "llvm-theme"
30+
html_theme_path = ["_themes"]
31+
html_static_path = ["_static"]
32+
html_favicon = "_static/favicon.ico"

offload/docs/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Offload documentation master file, created by
2+
sphinx-quickstart on Fri Jul 4 14:59:13 2025.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to Offload's documentation!
7+
===================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
offload-api
14+
15+
16+
Indices and tables
17+
==================
18+
19+
* :ref:`genindex`
20+
* :ref:`modindex`
21+
* :ref:`search`

offload/liboffload/API/Common.td

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,6 @@ def : Macro {
4444
let alt_value = "";
4545
}
4646

47-
def : Macro {
48-
let name = "OL_DLLEXPORT";
49-
let desc = "Microsoft-specific dllexport storage-class attribute";
50-
let condition = "defined(_WIN32)";
51-
let value = "__declspec(dllexport)";
52-
}
53-
54-
def : Macro {
55-
let name = "OL_DLLEXPORT";
56-
let desc = "GCC-specific dllexport storage-class attribute";
57-
let condition = "__GNUC__ >= 4";
58-
let value = "__attribute__ ((visibility (\"default\")))";
59-
let alt_value = "";
60-
}
61-
6247
def : Handle {
6348
let name = "ol_platform_handle_t";
6449
let desc = "Handle of a platform instance";

0 commit comments

Comments
 (0)