summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-10-25 10:14:22 -0700
committerGitHub <noreply@github.com>2024-10-25 10:14:22 -0700
commit4bad669bbc5ec3ff77321f083c59cde87eb10229 (patch)
treebf0abc916692cf34e804469bba400f2b04172472 /source/slang
parentef40d3044cf75ec3d7b24a43257fa744b45274f9 (diff)
Replace stdlib on Slang API with CoreModule (#5405)
This is a breaking change in a way that the Slang API function names are changed. All of them are commented as "experimental" and we wouldn't provide a back-ward compatibility for them. Following functions are renamed: compileStdLib() -> compileCoreModule() loadStdLib() -> loadCoreModule() saveStdLib() -> saveCoreModule() slang_createGlobalSessionWithoutStdLib() -> slang_createGlobalSessionWithoutCoreModule() slang_getEmbeddedStdLib() -> slang_getEmbeddedCoreModule() hasDeferredStdLib() -> hasDeferredCoreModule() Following command-line arguments are renamed: "-load-stdlib" -> "-load-core-module" "-save-stdlib" -> "-save-core-module" "-save-stdlib-bin-source" -> "-save-core-module-bin-source" "-compile-stdlib" -> "-compile-core-module"
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-api.cpp14
-rwxr-xr-xsource/slang/slang-compiler.h6
-rw-r--r--source/slang/slang-options.cpp32
-rw-r--r--source/slang/slang.cpp10
4 files changed, 31 insertions, 31 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp
index ccecc74e1..feaca559e 100644
--- a/source/slang/slang-api.cpp
+++ b/source/slang/slang-api.cpp
@@ -51,7 +51,7 @@ SlangResult tryLoadStdLibFromCache(
auto cacheTimestamp = *(uint64_t*)(cacheData.getData());
if (cacheTimestamp != currentLibTimestamp)
return SLANG_FAIL;
- SLANG_RETURN_ON_FAIL(globalSession->loadStdLib(
+ SLANG_RETURN_ON_FAIL(globalSession->loadCoreModule(
(uint8_t*)cacheData.getData() + sizeof(uint64_t),
cacheData.getSizeInBytes() - sizeof(uint64_t)));
return SLANG_OK;
@@ -66,7 +66,7 @@ SlangResult trySaveStdLibToCache(
{
Slang::ComPtr<ISlangBlob> stdLibBlobPtr;
SLANG_RETURN_ON_FAIL(
- globalSession->saveStdLib(SLANG_ARCHIVE_TYPE_RIFF_LZ4, stdLibBlobPtr.writeRef()));
+ globalSession->saveCoreModule(SLANG_ARCHIVE_TYPE_RIFF_LZ4, stdLibBlobPtr.writeRef()));
Slang::FileStream fileStream;
SLANG_RETURN_ON_FAIL(fileStream.init(cacheFilename, Slang::FileMode::Create));
@@ -89,13 +89,13 @@ SLANG_API SlangResult slang_createGlobalSession(
Slang::_debugGetIRAllocCounter() = 0x80000000;
#endif
- SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(apiVersion, globalSession.writeRef()));
+ SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(apiVersion, globalSession.writeRef()));
// If we have the embedded stdlib, load from that, else compile it
- ISlangBlob* stdLibBlob = slang_getEmbeddedStdLib();
+ ISlangBlob* stdLibBlob = slang_getEmbeddedCoreModule();
if (stdLibBlob)
{
- SLANG_RETURN_ON_FAIL(globalSession->loadStdLib(stdLibBlob->getBufferPointer(), stdLibBlob->getBufferSize()));
+ SLANG_RETURN_ON_FAIL(globalSession->loadCoreModule(stdLibBlob->getBufferPointer(), stdLibBlob->getBufferSize()));
}
else
{
@@ -109,7 +109,7 @@ SLANG_API SlangResult slang_createGlobalSession(
#endif
{
// Compile std lib from embeded source.
- SLANG_RETURN_ON_FAIL(globalSession->compileStdLib(0));
+ SLANG_RETURN_ON_FAIL(globalSession->compileCoreModule(0));
#if SLANG_PROFILE_STDLIB_COMPILE
auto timeElapsed = std::chrono::high_resolution_clock::now() - startTime;
printf("stdlib compilation time: %.1fms\n", timeElapsed.count() / 1000000.0);
@@ -148,7 +148,7 @@ SLANG_API void slang_shutdown()
Slang::freeCapabilityDefs();
}
-SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib(
+SLANG_API SlangResult slang_createGlobalSessionWithoutCoreModule(
SlangInt apiVersion,
slang::IGlobalSession** outGlobalSession)
{
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index c1251488b..71c751ff2 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -3275,9 +3275,9 @@ namespace Slang
SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override;
void writeStdlibDoc(String config);
- SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(slang::CompileStdLibFlags flags) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) override;
+ SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(slang::CompileCoreModuleFlags flags) override;
+ SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) override;
+ SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) override;
SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability(char const* name) override;
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 43f98872d..4875627f5 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -543,18 +543,18 @@ void initCommandOptions(CommandOptions& options)
const Option internalOpts[] =
{
- { OptionKind::ArchiveType, "-archive-type", "-archive-type <archive-type>", "Set the archive type for -save-stdlib. Default is zip." },
- { OptionKind::CompileStdLib, "-compile-stdlib", nullptr,
+ { OptionKind::ArchiveType, "-archive-type", "-archive-type <archive-type>", "Set the archive type for -save-core-module. Default is zip." },
+ { OptionKind::CompileCoreModule, "-compile-core-module", nullptr,
"Compile the StdLib from embedded sources. "
"Will return a failure if there is already a StdLib available."},
- { OptionKind::Doc, "-doc", nullptr, "Write documentation for -compile-stdlib" },
+ { OptionKind::Doc, "-doc", nullptr, "Write documentation for -compile-core-module" },
{ OptionKind::IrCompression,"-ir-compression", "-ir-compression <type>",
"Set compression for IR and AST outputs.\n"
"Accepted compression types: none, lite"},
- { OptionKind::LoadStdLib, "-load-stdlib", "-load-stdlib <filename>", "Load the StdLib from file." },
+ { OptionKind::LoadCoreModule, "-load-core-module", "-load-core-module <filename>", "Load the core module from file." },
{ OptionKind::ReferenceModule, "-r", "-r <name>", "reference module <name>" },
- { OptionKind::SaveStdLib, "-save-stdlib", "-save-stdlib <filename>", "Save the StdLib modules to an archive file." },
- { OptionKind::SaveStdLibBinSource, "-save-stdlib-bin-source","-save-stdlib-bin-source <filename>", "Same as -save-stdlib but output "
+ { OptionKind::SaveCoreModule, "-save-core-module", "-save-core-module <filename>", "Save the core module to an archive file." },
+ { OptionKind::SaveCoreModuleBinSource, "-save-core-module-bin-source","-save-core-module-bin-source <filename>", "Same as -save-core-module but output "
"the data as a C array.\n"},
{ OptionKind::TrackLiveness, "-track-liveness", nullptr, "Enable liveness tracking. Places SLANG_LIVE_START, and SLANG_LIVE_END in output source to indicate value liveness." },
{ OptionKind::LoopInversion, "-loop-inversion", nullptr, "Enable loop inversion in the code-gen optimization. Default is off" },
@@ -798,7 +798,7 @@ struct OptionsParser
bool m_hasLoadedRepro = false;
bool m_compileStdLib = false;
- slang::CompileStdLibFlags m_compileStdLibFlags;
+ slang::CompileCoreModuleFlags m_compileStdLibFlags;
SlangArchiveType m_archiveType = SLANG_ARCHIVE_TYPE_RIFF_LZ4;
@@ -1747,7 +1747,7 @@ SlangResult OptionsParser::_parse(
case OptionKind::NoCodeGen:
linkage->m_optionSet.set(OptionKind::SkipCodeGen, true); break;
break;
- case OptionKind::LoadStdLib:
+ case OptionKind::LoadCoreModule:
{
CommandLineArg fileName;
SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName));
@@ -1755,38 +1755,38 @@ SlangResult OptionsParser::_parse(
// Load the file
ScopedAllocation contents;
SLANG_RETURN_ON_FAIL(File::readAllBytes(fileName.value, contents));
- SLANG_RETURN_ON_FAIL(m_session->loadStdLib(contents.getData(), contents.getSizeInBytes()));
+ SLANG_RETURN_ON_FAIL(m_session->loadCoreModule(contents.getData(), contents.getSizeInBytes()));
// Ensure that the linkage's AST builder is up-to-date.
linkage->getASTBuilder()->m_cachedNodes = asInternal(m_session)->getGlobalASTBuilder()->m_cachedNodes;
break;
}
- case OptionKind::CompileStdLib: m_compileStdLib = true; break;
+ case OptionKind::CompileCoreModule: m_compileStdLib = true; break;
case OptionKind::ArchiveType:
{
SLANG_RETURN_ON_FAIL(_expectValue(m_archiveType));
break;
}
- case OptionKind::SaveStdLib:
+ case OptionKind::SaveCoreModule:
{
CommandLineArg fileName;
SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName));
ComPtr<ISlangBlob> blob;
- SLANG_RETURN_ON_FAIL(m_session->saveStdLib(m_archiveType, blob.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_session->saveCoreModule(m_archiveType, blob.writeRef()));
SLANG_RETURN_ON_FAIL(File::writeAllBytes(fileName.value, blob->getBufferPointer(), blob->getBufferSize()));
break;
}
- case OptionKind::SaveStdLibBinSource:
+ case OptionKind::SaveCoreModuleBinSource:
{
CommandLineArg fileName;
SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName));
ComPtr<ISlangBlob> blob;
- SLANG_RETURN_ON_FAIL(m_session->saveStdLib(m_archiveType, blob.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_session->saveCoreModule(m_archiveType, blob.writeRef()));
StringBuilder builder;
StringWriter writer(&builder, 0);
@@ -1811,7 +1811,7 @@ SlangResult OptionsParser::_parse(
case OptionKind::Doc:
{
// If compiling stdlib is enabled, will write out documentation
- m_compileStdLibFlags |= slang::CompileStdLibFlag::WriteDocumentation;
+ m_compileStdLibFlags |= slang::CompileCoreModuleFlag::WriteDocumentation;
// Enable writing out documentation on the req
linkage->m_optionSet.set(CompilerOptionName::Doc, true);
@@ -2380,7 +2380,7 @@ SlangResult OptionsParser::_parse(
if (m_compileStdLib)
{
- SLANG_RETURN_ON_FAIL(m_session->compileStdLib(m_compileStdLibFlags));
+ SLANG_RETURN_ON_FAIL(m_session->compileCoreModule(m_compileStdLibFlags));
}
// TODO(JS): This is a restriction because of how setting of state works for load repro
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 93fb2c203..b77a3efc8 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -342,7 +342,7 @@ void Session::writeStdlibDoc(String config)
}
}
-SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags)
+SlangResult Session::compileCoreModule(slang::CompileCoreModuleFlags compileFlags)
{
SLANG_AST_BUILDER_RAII(m_builtinLinkage->getASTBuilder());
@@ -369,7 +369,7 @@ SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags)
auto stdLibSrcBlob = StringBlob::moveCreate(stdLibSrcBuilder.produceString());
addBuiltinSource(coreLanguageScope, "core", stdLibSrcBlob);
- if (compileFlags & slang::CompileStdLibFlag::WriteDocumentation)
+ if (compileFlags & slang::CompileCoreModuleFlag::WriteDocumentation)
{
// Load config file first.
String configText;
@@ -393,7 +393,7 @@ SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags)
return SLANG_OK;
}
-SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes)
+SlangResult Session::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes)
{
SLANG_PROFILE;
@@ -407,7 +407,7 @@ SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes)
// Make a file system to read it from
ComPtr<ISlangFileSystemExt> fileSystem;
- SLANG_RETURN_ON_FAIL(loadArchiveFileSystem(stdLib, stdLibSizeInBytes, fileSystem));
+ SLANG_RETURN_ON_FAIL(loadArchiveFileSystem(coreModule, coreModuleSizeInBytes, fileSystem));
// Let's try loading serialized modules and adding them
SLANG_RETURN_ON_FAIL(_readBuiltinModule(fileSystem, coreLanguageScope, "core"));
@@ -416,7 +416,7 @@ SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes)
return SLANG_OK;
}
-SlangResult Session::saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob)
+SlangResult Session::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob)
{
if (m_builtinLinkage->mapNameToLoadedModules.getCount() == 0)
{