summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorjarcherNV <jarcher@nvidia.com>2025-08-15 13:16:09 -0700
committerGitHub <noreply@github.com>2025-08-15 20:16:09 +0000
commitaf27de01532904508e6a630c213249e93fdd1c66 (patch)
tree771a04869c4539653ce2c9f44476ea0d14bd81fb /include
parentdcda42e7dcdb5e260013757763bf5dbf67d69568 (diff)
Add static functions to create blobs from data (#8179)
Add helper functions to create ISlangBlob and load module data from source. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'include')
-rw-r--r--include/slang.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/slang.h b/include/slang.h
index a32cbfd3b..02f6bdce6 100644
--- a/include/slang.h
+++ b/include/slang.h
@@ -4687,6 +4687,66 @@ struct SlangGlobalSessionDesc
uint32_t reserved[16] = {};
};
+/* Create a blob from binary data.
+ *
+ * @param data Pointer to the binary data to store in the blob. Must not be null.
+ * @param size Size of the data in bytes. Must be greater than 0.
+ * @return The created blob on success, or nullptr on failure.
+ */
+SLANG_EXTERN_C SLANG_API ISlangBlob* slang_createBlob(const void* data, size_t size);
+
+/* Load a module from source code with size specification.
+ *
+ * @param session The session to load the module into.
+ * @param moduleName The name of the module.
+ * @param path The path for the module.
+ * @param source Pointer to the source code data.
+ * @param sourceSize Size of the source code data in bytes.
+ * @param outDiagnostics (out, optional) Diagnostics output.
+ * @return The loaded module on success, or nullptr on failure.
+ */
+SLANG_EXTERN_C SLANG_API slang::IModule* slang_loadModuleFromSource(
+ slang::ISession* session,
+ const char* moduleName,
+ const char* path,
+ const char* source,
+ size_t sourceSize,
+ ISlangBlob** outDiagnostics = nullptr);
+
+/** Load a module from IR data.
+ * @param session The session to load the module into.
+ * @param moduleName Name of the module to load.
+ * @param path Path for the module (used for diagnostics).
+ * @param source IR data containing the module.
+ * @param sourceSize Size of the IR data in bytes.
+ * @param outDiagnostics (out, optional) Diagnostics output.
+ * @return The loaded module on success, or nullptr on failure.
+ */
+SLANG_EXTERN_C SLANG_API slang::IModule* slang_loadModuleFromIRBlob(
+ slang::ISession* session,
+ const char* moduleName,
+ const char* path,
+ const void* source,
+ size_t sourceSize,
+ ISlangBlob** outDiagnostics = nullptr);
+
+/** Read module info (name and version) from IR data.
+ * @param session The session to use for loading module info.
+ * @param source IR data containing the module.
+ * @param sourceSize Size of the IR data in bytes.
+ * @param outModuleVersion (out) Module version number.
+ * @param outModuleCompilerVersion (out) Compiler version that created the module.
+ * @param outModuleName (out) Name of the module.
+ * @return SLANG_OK on success, or an error code on failure.
+ */
+SLANG_EXTERN_C SLANG_API SlangResult slang_loadModuleInfoFromIRBlob(
+ slang::ISession* session,
+ const void* source,
+ size_t sourceSize,
+ SlangInt& outModuleVersion,
+ const char*& outModuleCompilerVersion,
+ const char*& outModuleName);
+
/* Create a global session, with the built-in core module.
@param apiVersion Pass in SLANG_API_VERSION