[llvm] [Offload] Add Offload API Sphinx documentation (PR #147323)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 08:26:26 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Kenneth Benzie (Benie) (kbenzie)
<details>
<summary>Changes</summary>
* 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.
* Copy Sphinx llvm-theme from llvm/docs
* Add spec generation to offload-tblgen tool
This patch adds generation of Sphinx compatible reStructuedText utilizing the C domain to document the Offload API directly from the spec definition `.td` files.
---
Patch is 27.60 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/147323.diff
19 Files Affected:
- (modified) offload/CMakeLists.txt (+3)
- (added) offload/docs/.gitignore (+1)
- (added) offload/docs/CMakeLists.txt (+25)
- (added) offload/docs/_static/llvm.css (+112)
- (added) offload/docs/_themes/llvm-theme/layout.html (+23)
- (added) offload/docs/_themes/llvm-theme/static/contents.png ()
- (added) offload/docs/_themes/llvm-theme/static/llvm-theme.css (+374)
- (added) offload/docs/_themes/llvm-theme/static/logo.png ()
- (added) offload/docs/_themes/llvm-theme/static/navigation.png ()
- (added) offload/docs/_themes/llvm-theme/theme.conf (+4)
- (added) offload/docs/conf.py (+31)
- (added) offload/docs/index.rst (+21)
- (modified) offload/liboffload/API/Common.td (-15)
- (modified) offload/tools/offload-tblgen/APIGen.cpp (+1-1)
- (modified) offload/tools/offload-tblgen/CMakeLists.txt (+1)
- (modified) offload/tools/offload-tblgen/GenCommon.hpp (+5)
- (modified) offload/tools/offload-tblgen/Generators.hpp (+1)
- (added) offload/tools/offload-tblgen/SpecGen.cpp (+192)
- (modified) offload/tools/offload-tblgen/offload-tblgen.cpp (+6)
``````````diff
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 0a441c3bc5782..8e44f5e0034f7 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -23,6 +23,8 @@ elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
return()
endif()
+set(OFFLOAD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
if(OPENMP_STANDALONE_BUILD)
set(OFFLOAD_LIBDIR_SUFFIX "" CACHE STRING
"Suffix of lib installation directory, e.g. 64 => lib64")
@@ -371,6 +373,7 @@ add_subdirectory(tools/offload-tblgen)
add_subdirectory(plugins-nextgen)
add_subdirectory(DeviceRTL)
add_subdirectory(tools)
+add_subdirectory(docs)
# Build target agnostic offloading library.
add_subdirectory(libomptarget)
diff --git a/offload/docs/.gitignore b/offload/docs/.gitignore
new file mode 100644
index 0000000000000..a17658c751ec0
--- /dev/null
+++ b/offload/docs/.gitignore
@@ -0,0 +1 @@
+offload-api.rst
diff --git a/offload/docs/CMakeLists.txt b/offload/docs/CMakeLists.txt
new file mode 100644
index 0000000000000..0fdef0bdc22cc
--- /dev/null
+++ b/offload/docs/CMakeLists.txt
@@ -0,0 +1,25 @@
+if(LLVM_ENABLE_SPHINX)
+ include(AddSphinxTarget)
+ if(SPHINX_FOUND AND SPHINX_OUTPUT_HTML)
+ # Generate offload-api.rst from OffloadAPI.td
+ set(LLVM_TARGET_DEFINITIONS
+ ${OFFLOAD_SOURCE_DIR}/liboffload/API/OffloadAPI.td)
+ tablegen(OFFLOAD source/offload-api.rst -gen-spec
+ EXTRA_INCLUDES ${OFFLOAD_SOURCE_DIR}/liboffload/API)
+ add_public_tablegen_target(OffloadDocsGenerate)
+
+ # Due to Sphinx only allowing a single source direcotry and the fact we
+ # only generate a single file, copy offload-api.rst to the source directory
+ # to be included in the generated documentation. A .gitignore file ensures
+ # offload-api.rst will not be added to the repository.
+ add_custom_target(OffloadDocsCopy
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_BINARY_DIR}/source/offload-api.rst
+ ${CMAKE_CURRENT_SOURCE_DIR}/offload-api.rst)
+
+ # Generate the HTML documentation, invoked wt the docs-offload-html target.
+ add_sphinx_target(html offload
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ add_dependencies(docs-offload-html OffloadDocsGenerate OffloadDocsCopy)
+ endif()
+endif()
diff --git a/offload/docs/_static/llvm.css b/offload/docs/_static/llvm.css
new file mode 100644
index 0000000000000..53eeed95c6c0a
--- /dev/null
+++ b/offload/docs/_static/llvm.css
@@ -0,0 +1,112 @@
+/*
+ * LLVM documentation style sheet
+ */
+
+/* Common styles */
+.body { color: black; background: white; margin: 0 0 0 0 }
+
+/* No borders on image links */
+a:link img, a:visited img { border-style: none }
+
+address img { float: right; width: 88px; height: 31px; }
+address { clear: right; }
+
+table { text-align: center; border: 2px solid black;
+ border-collapse: collapse; margin-top: 1em; margin-left: 1em;
+ margin-right: 1em; margin-bottom: 1em; }
+tr, td { border: 2px solid gray; padding: 4pt 4pt 2pt 2pt; }
+th { border: 2px solid gray; font-weight: bold; font-size: 105%;
+ background: url("lines.gif");
+ font-family: "Georgia,Palatino,Times,Roman,SanSerif";
+ text-align: center; vertical-align: middle; }
+/*
+ * Documentation
+ */
+/* Common for title and header */
+.doc_title, .doc_section, .doc_subsection, h1, h2, h3 {
+ color: black; background: url("lines.gif");
+ font-family: "Georgia,Palatino,Times,Roman,SanSerif"; font-weight: bold;
+ border-width: 1px;
+ border-style: solid none solid none;
+ text-align: center;
+ vertical-align: middle;
+ padding-left: 8pt;
+ padding-top: 1px;
+ padding-bottom: 2px
+}
+
+h1, .doc_title, .title { text-align: left; font-size: 25pt }
+
+h2, .doc_section { text-align: center; font-size: 22pt;
+ margin: 20pt 0pt 5pt 0pt; }
+
+h3, .doc_subsection { width: 75%;
+ text-align: left; font-size: 12pt;
+ padding: 4pt 4pt 4pt 4pt;
+ margin: 1.5em 0.5em 0.5em 0.5em }
+
+h4, .doc_subsubsection { margin: 2.0em 0.5em 0.5em 0.5em;
+ font-weight: bold; font-style: oblique;
+ border-bottom: 1px solid #999999; font-size: 12pt;
+ width: 75%; }
+
+.doc_author { text-align: left; font-weight: bold; padding-left: 20pt }
+.doc_text { text-align: left; padding-left: 20pt; padding-right: 10pt }
+
+.doc_footer { text-align: left; padding: 0 0 0 0 }
+
+.doc_hilite { color: blue; font-weight: bold; }
+
+.doc_table { text-align: center; width: 90%;
+ padding: 1px 1px 1px 1px; border: 1px; }
+
+.doc_warning { color: red; font-weight: bold }
+
+/* <div class="doc_code"> would use this class, and <div> adds more padding */
+.doc_code, .literal-block
+ { border: solid 1px gray; background: #eeeeee;
+ margin: 0 1em 0 1em;
+ padding: 0 1em 0 1em;
+ display: table;
+ }
+
+blockquote pre {
+ padding: 1em 2em 1em 1em;
+ border: solid 1px gray;
+ background: #eeeeee;
+ margin: 0 1em 0 1em;
+ display: table;
+}
+
+h2+div, h2+p {text-align: left; padding-left: 20pt; padding-right: 10pt;}
+h3+div, h3+p {text-align: left; padding-left: 20pt; padding-right: 10pt;}
+h4+div, h4+p {text-align: left; padding-left: 20pt; padding-right: 10pt;}
+
+/* It is preferable to use <pre class="doc_code"> everywhere instead of the
+ * <div class="doc_code"><pre>...</ptr></div> construct.
+ *
+ * Once all docs use <pre> for code regions, this style can be merged with the
+ * one above, and we can drop the [pre] qualifier.
+ */
+pre.doc_code, .literal-block { padding: 1em 2em 1em 1em }
+
+.doc_notes { background: #fafafa; border: 1px solid #cecece;
+ display: table; padding: 0 1em 0 .1em }
+
+table.layout { text-align: left; border: none; border-collapse: collapse;
+ padding: 4px 4px 4px 4px; }
+tr.layout, td.layout, td.left, td.right
+ { border: none; padding: 4pt 4pt 2pt 2pt; vertical-align: top; }
+td.left { text-align: left }
+td.right { text-align: right }
+th.layout { border: none; font-weight: bold; font-size: 105%;
+ text-align: center; vertical-align: middle; }
+
+/* Left align table cell */
+.td_left { border: 2px solid gray; text-align: left; }
+
+/* ReST-specific */
+.title { margin-top: 0 }
+.topic-title{ display: none }
+div.contents ul { list-style-type: decimal }
+.toc-backref { color: black; text-decoration: none; }
diff --git a/offload/docs/_themes/llvm-theme/layout.html b/offload/docs/_themes/llvm-theme/layout.html
new file mode 100644
index 0000000000000..746c2f56c82ae
--- /dev/null
+++ b/offload/docs/_themes/llvm-theme/layout.html
@@ -0,0 +1,23 @@
+{#
+ sphinxdoc/layout.html
+ ~~~~~~~~~~~~~~~~~~~~~
+
+ Sphinx layout template for the sphinxdoc theme.
+
+ :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+#}
+{% extends "basic/layout.html" %}
+
+{% block relbar1 %}
+<div class="logo">
+ <a href="{{ pathto('index') }}">
+ <img src="{{pathto("_static/logo.png", 1) }}"
+ alt="LLVM Logo" width="250" height="88"/></a>
+</div>
+{{ super() }}
+{% endblock %}
+
+{# put the sidebar before the body #}
+{% block sidebar1 %}{{ sidebar() }}{% endblock %}
+{% block sidebar2 %}{% endblock %}
diff --git a/offload/docs/_themes/llvm-theme/static/contents.png b/offload/docs/_themes/llvm-theme/static/contents.png
new file mode 100644
index 0000000000000..7fb82154a1748
Binary files /dev/null and b/offload/docs/_themes/llvm-theme/static/contents.png differ
diff --git a/offload/docs/_themes/llvm-theme/static/llvm-theme.css b/offload/docs/_themes/llvm-theme/static/llvm-theme.css
new file mode 100644
index 0000000000000..0fc5b261dbd05
--- /dev/null
+++ b/offload/docs/_themes/llvm-theme/static/llvm-theme.css
@@ -0,0 +1,374 @@
+/*
+ * sphinxdoc.css_t
+ * ~~~~~~~~~~~~~~~
+ *
+ * Sphinx stylesheet -- sphinxdoc theme. Originally created by
+ * Armin Ronacher for Werkzeug.
+ *
+ * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ * :license: BSD, see LICENSE for details.
+ *
+ */
+
+ at import url("basic.css");
+
+/* -- page layout ----------------------------------------------------------- */
+
+body {
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
+ 'Verdana', sans-serif;
+ font-size: 14px;
+ line-height: 150%;
+ text-align: center;
+ background-color: #BFD1D4;
+ color: black;
+ padding: 0;
+ border: 1px solid #aaa;
+ margin: 0px 80px 0px 80px;
+ min-width: 740px;
+ position: relative;
+}
+
+div.logo {
+ background-color: white;
+ text-align: left;
+ padding: 10px 10px 15px 15px;
+}
+
+div.document {
+ background-color: white;
+ text-align: left;
+ background-image: url(contents.png);
+ background-repeat: repeat-x;
+}
+
+div.bodywrapper {
+ margin: 0 240px 0 0;
+ border-right: 1px solid #ccc;
+}
+
+div.body {
+ margin: 0;
+ padding: 0.5em 20px 20px 20px;
+ max-width: 1000px;
+}
+
+div.related {
+ font-size: 1em;
+}
+
+div.related ul {
+ background-image: url(navigation.png);
+ height: 2em;
+ border-top: 1px solid #ddd;
+ border-bottom: 1px solid #ddd;
+}
+
+div.related ul li {
+ margin: 0;
+ padding: 0;
+ height: 2em;
+ float: left;
+}
+
+div.related ul li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+div.related ul li a {
+ margin: 0;
+ padding: 0 5px 0 5px;
+ line-height: 1.75em;
+ color: #EE9816;
+}
+
+div.related ul li a:hover {
+ color: #3CA8E7;
+}
+
+div.sphinxsidebarwrapper {
+ padding: 0;
+}
+
+div.sphinxsidebar {
+ margin: 0;
+ padding: 0.5em 15px 15px 0;
+ width: 210px;
+ font-size: 1em;
+ text-align: left;
+ float: none;
+ position: absolute;
+ right: 0;
+}
+
+div.sphinxsidebar h3, div.sphinxsidebar h4 {
+ margin: 1em 0 0.5em 0;
+ font-size: 1em;
+ padding: 0.1em 0 0.1em 0.5em;
+ color: white;
+ border: 1px solid #86989B;
+ background-color: #AFC1C4;
+}
+
+div.sphinxsidebar h3 a {
+ color: white;
+}
+
+div.sphinxsidebar ul {
+ padding-left: 1.5em;
+ margin-top: 7px;
+ padding: 0;
+ line-height: 130%;
+}
+
+div.sphinxsidebar ul ul {
+ margin-left: 20px;
+}
+
+div.footer {
+ background-color: #E3EFF1;
+ color: #86989B;
+ padding: 3px 8px 3px 0;
+ clear: both;
+ font-size: 0.8em;
+ text-align: right;
+}
+
+div.footer a {
+ color: #86989B;
+ text-decoration: underline;
+}
+
+/* -- body styles ----------------------------------------------------------- */
+
+p {
+ margin: 0.8em 0 0.5em 0;
+}
+
+a {
+ color: #CA7900;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #2491CF;
+}
+
+div.body p a{
+ text-decoration: underline;
+}
+
+h1 {
+ margin: 0;
+ padding: 0.7em 0 0.3em 0;
+ font-size: 1.5em;
+ color: #11557C;
+}
+
+h2 {
+ margin: 1.3em 0 0.2em 0;
+ font-size: 1.35em;
+ padding: 0;
+}
+
+h3 {
+ margin: 1em 0 -0.3em 0;
+ font-size: 1.2em;
+}
+
+h3 a:hover {
+ text-decoration: underline;
+}
+
+div.body h1 a, div.body h2 a, div.body h3 a, div.body h4 a, div.body h5 a, div.body h6 a {
+ color: black!important;
+}
+
+div.body h1,
+div.body h2,
+div.body h3,
+div.body h4,
+div.body h5,
+div.body h6 {
+ background-color: #f2f2f2;
+ font-weight: normal;
+ color: #20435c;
+ border-bottom: 1px solid #ccc;
+ margin: 20px -20px 10px -20px;
+ padding: 3px 0 3px 10px;
+}
+
+div.body h1 { margin-top: 0; font-size: 200%; }
+div.body h2 { font-size: 160%; }
+div.body h3 { font-size: 140%; }
+div.body h4 { font-size: 120%; }
+div.body h5 { font-size: 110%; }
+div.body h6 { font-size: 100%; }
+
+h1 a.anchor, h2 a.anchor, h3 a.anchor, h4 a.anchor, h5 a.anchor, h6 a.anchor {
+ display: none;
+ margin: 0 0 0 0.3em;
+ padding: 0 0.2em 0 0.2em;
+ color: #aaa!important;
+}
+
+h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor,
+h5:hover a.anchor, h6:hover a.anchor {
+ display: inline;
+}
+
+h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover,
+h5 a.anchor:hover, h6 a.anchor:hover {
+ color: #777;
+ background-color: #eee;
+}
+
+a.headerlink {
+ color: #c60f0f!important;
+ font-size: 1em;
+ margin-left: 6px;
+ padding: 0 4px 0 4px;
+ text-decoration: none!important;
+}
+
+a.headerlink:hover {
+ background-color: #ccc;
+ color: white!important;
+}
+
+cite, code, tt {
+ font-family: 'Consolas', 'Deja Vu Sans Mono',
+ 'Bitstream Vera Sans Mono', monospace;
+ font-size: 0.95em;
+}
+
+:not(a.reference) > tt {
+ background-color: #f2f2f2;
+ border-bottom: 1px solid #ddd;
+ color: #333;
+}
+
+tt.descname, tt.descclassname, tt.xref {
+ border: 0;
+}
+
+hr {
+ border: 1px solid #abc;
+ margin: 2em;
+}
+
+p a tt {
+ border: 0;
+ color: #CA7900;
+}
+
+p a tt:hover {
+ color: #2491CF;
+}
+
+a tt {
+ border: none;
+}
+
+pre {
+ font-family: 'Consolas', 'Deja Vu Sans Mono',
+ 'Bitstream Vera Sans Mono', monospace;
+ font-size: 0.95em;
+ line-height: 120%;
+ padding: 0.5em;
+ border: 1px solid #ccc;
+ background-color: #f8f8f8;
+}
+
+pre a {
+ color: inherit;
+ text-decoration: underline;
+}
+
+td.linenos pre {
+ padding: 0.5em 0;
+}
+
+div.quotebar {
+ background-color: #f8f8f8;
+ max-width: 250px;
+ float: right;
+ padding: 2px 7px;
+ border: 1px solid #ccc;
+}
+
+div.topic {
+ background-color: #f8f8f8;
+}
+
+table {
+ border-collapse: collapse;
+ margin: 0 -0.5em 0 -0.5em;
+}
+
+table td, table th {
+ padding: 0.2em 0.5em 0.2em 0.5em;
+}
+
+div.admonition, div.warning {
+ font-size: 0.9em;
+ margin: 1em 0 1em 0;
+ border: 1px solid #86989B;
+ background-color: #f7f7f7;
+ padding: 0;
+}
+
+div.admonition p, div.warning p {
+ margin: 0.5em 1em 0.5em 1em;
+ padding: 0;
+}
+
+div.admonition pre, div.warning pre {
+ margin: 0.4em 1em 0.4em 1em;
+}
+
+div.admonition p.admonition-title,
+div.warning p.admonition-title {
+ margin: 0;
+ padding: 0.1em 0 0.1em 0.5em;
+ color: white;
+ border-bottom: 1px solid #86989B;
+ font-weight: bold;
+ background-color: #AFC1C4;
+}
+
+div.warning {
+ border: 1px solid #940000;
+}
+
+div.warning p.admonition-title {
+ background-color: #CF0000;
+ border-bottom-color: #940000;
+}
+
+div.admonition ul, div.admonition ol,
+div.warning ul, div.warning ol {
+ margin: 0.1em 0.5em 0.5em 3em;
+ padding: 0;
+}
+
+div.versioninfo {
+ margin: 1em 0 0 0;
+ border: 1px solid #ccc;
+ background-color: #DDEAF0;
+ padding: 8px;
+ line-height: 1.3em;
+ font-size: 0.9em;
+}
+
+.viewcode-back {
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
+ 'Verdana', sans-serif;
+}
+
+div.viewcode-block:target {
+ background-color: #f4debf;
+ border-top: 1px solid #ac9;
+ border-bottom: 1px solid #ac9;
+}
diff --git a/offload/docs/_themes/llvm-theme/static/logo.png b/offload/docs/_themes/llvm-theme/static/logo.png
new file mode 100644
index 0000000000000..18d424c53c09a
Binary files /dev/null and b/offload/docs/_themes/llvm-theme/static/logo.png differ
diff --git a/offload/docs/_themes/llvm-theme/static/navigation.png b/offload/docs/_themes/llvm-theme/static/navigation.png
new file mode 100644
index 0000000000000..1081dc1439fb9
Binary files /dev/null and b/offload/docs/_themes/llvm-theme/static/navigation.png differ
diff --git a/offload/docs/_themes/llvm-theme/theme.conf b/offload/docs/_themes/llvm-theme/theme.conf
new file mode 100644
index 0000000000000..573fd78aba990
--- /dev/null
+++ b/offload/docs/_themes/llvm-theme/theme.conf
@@ -0,0 +1,4 @@
+[theme]
+inherit = basic
+stylesheet = llvm-theme.css
+pygments_style = friendly
diff --git a/offload/docs/conf.py b/offload/docs/conf.py
new file mode 100644
index 0000000000000..b90505b45e759
--- /dev/null
+++ b/offload/docs/conf.py
@@ -0,0 +1,31 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# For the full list of built-in configuration values, see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
+project = 'Offload'
+copyright = '2025, LLVM project'
+author = 'LLVM project'
+
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
+
+extensions = []
+
+templates_path = ['_templates']
+exclude_patterns = []
+
+# -- C domain configuration --------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#c-config
+
+c_maximum_signature_line_length = 60
+
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
+
+html_theme = "llvm-theme"
+html_theme_path = ["_themes"]
+html_static_path = ['_static']
diff --git a/offload/docs/index.rst b/offload/docs/index.rst
new file mode 100644
index 0000000000000..481d1f7ddd8b8
--- /dev/null
+++ b/offload/docs/index.rst
@@ -0,0 +1,21 @@
+.. Offload documentation master file, created by
+ sphinx-quickstart on Fri Jul 4 14:59:13 2025.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Offload's documentation!
+===================================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ offload-api
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/offload/liboffload/API/Common.td b/offload/liboffload/API/Common.td
index 850a01d06759e..a621de081a0c6 100644
--- a/offload/liboffload/API/Common.td
+++ b/offload/liboffload/API/Common.td
@@ -44,21 +44,6 @@ def : Macro {
let alt_value = "";
}
-def : Macro {
- let name = "OL_DLLEXPORT";
- let desc = "Microsoft-specific dllexport storage-class attribute";
- let condition = "defined(_WIN32)";
- let value = "__declspec(dllexport)";
-}
-
-def : Macro {
- let name = "OL_DLLEXPORT";
- let desc = "GCC-specific dllexport storage-class attribute";
- let condition = "__GNUC__ >= 4";
- let value = "__attribute__ ((visibility (\"default\")))";
- let alt_value = "";
-}
-
def : Handle {
let name = "ol_platform_handle_t";
let desc = "Handle of a platform instance";
diff --git a/offload/tools/offload-tblgen/APIGen.cpp b/offload/tools/offload-tblgen/APIGen.cpp
index 35b080e3c8011..db92e4019e666 100644
--- a/offload/tools/offload-tblgen/APIGen.cpp
+++ b/offload/tools/offload-tblgen/APIGen.cpp
@@ -48,7 +48,7 @@ static void ProcessHandle(const HandleRec &H, raw_ostream &OS) {
exit(1);
}
- auto ImplName = H.getName().substr(0, H.getName().size() - 9) + "_impl_t";
+ auto ImplName = getHandleImplName(H);
OS << CommentsHeader;
OS << formatv("/// @brief {0}\n", H.getDesc());
OS << formatv("typedef struct {0} *{1};\n", ImplName, H.getName());
diff --git a/offload/tools/offload-tblgen/CMakeLists.txt b/offload/tools/offload-tblgen/CMakeLists.txt
index 613b166d62b4d..01ef87941e733 100644
--- a/offload/tools/offload-tblgen/CMakeLists.txt
+++ b/offload/tools/offload-tblgen/CMakeLists.txt
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS Support)
add_tablegen(offload-tblgen OFFLOAD
EXPORT OFFLOAD
APIGen.cpp
+ SpecGen.cpp
EntryPointGen.cpp
MiscGen.cpp
GenCommon.hpp
diff --git a/offload/tools/offload-tblgen/GenCommon.hpp b/offload/tools/offload-tblgen/GenCommon.hpp
index db432e9958b5d..b57f96ad0c456 100644
--- a/offload/tools/offload-tblgen/GenCommon.hpp
+++ b/offload/tools/offload-tblgen/GenCommon.hpp
@@ -65,3 +65,8 @@ MakeParamComment(const llvm::offload::tblgen::ParamRec &Param) {
(Param.isOut() ? "[out]" : ""),
(Param.isOpt() ? "[optional]" : ""), Param.getDesc());
}
+
+inline std::string
+getHandleImplName(const llvm::offload::tblgen::HandleRec &H) {
+ return (H.getName().substr(0, H.getName().size() - 9) + "_impl_t").str();
+}
diff --git a/offload/tools/offload-tbl...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/147323
More information about the llvm-commits
mailing list