From 4bad669bbc5ec3ff77321f083c59cde87eb10229 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:14:22 -0700 Subject: 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" --- source/core/slang-test-tool-util.cpp | 4 +-- source/core/slang-test-tool-util.h | 4 +-- .../record/slang-global-session.cpp | 20 +++++++------- .../record/slang-global-session.h | 6 ++-- .../slang-record-replay/replay/decoder-consumer.h | 6 ++-- .../slang-record-replay/replay/json-consumer.cpp | 20 +++++++------- source/slang-record-replay/replay/json-consumer.h | 6 ++-- .../slang-record-replay/replay/replay-consumer.cpp | 18 ++++++------ .../slang-record-replay/replay/replay-consumer.h | 6 ++-- .../slang-record-replay/replay/slang-decoder.cpp | 30 ++++++++++---------- source/slang-record-replay/replay/slang-decoder.h | 6 ++-- source/slang-record-replay/util/emum-to-string.h | 14 +++++----- source/slang-record-replay/util/record-format.h | 6 ++-- source/slang-stdlib/CMakeLists.txt | 2 +- source/slang-stdlib/slang-embedded-stdlib.cpp | 10 +++---- source/slang/slang-api.cpp | 14 +++++----- source/slang/slang-compiler.h | 6 ++-- source/slang/slang-options.cpp | 32 +++++++++++----------- source/slang/slang.cpp | 10 +++---- source/slangc/main.cpp | 10 +++---- 20 files changed, 115 insertions(+), 115 deletions(-) (limited to 'source') diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index 9a0ebe4f1..d362d7043 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -37,12 +37,12 @@ namespace Slang } } -/* static */bool TestToolUtil::hasDeferredStdLib(Index argc, const char*const* argv) +/* static */bool TestToolUtil::hasDeferredCoreModule(Index argc, const char*const* argv) { for (Index i = 0; i < argc; ++i) { UnownedStringSlice option(argv[i]); - if (option == "-load-stdlib" || option == "-compile-stdlib") + if (option == "-load-core-module" || option == "-compile-core-module") { return true; } diff --git a/source/core/slang-test-tool-util.h b/source/core/slang-test-tool-util.h index 03f3b768e..967dc0fa8 100644 --- a/source/core/slang-test-tool-util.h +++ b/source/core/slang-test-tool-util.h @@ -64,8 +64,8 @@ struct TestToolUtil /// Sets the default preludes on the session based on the executable path static SlangResult setSessionDefaultPreludeFromExePath(const char* exePath, slang::IGlobalSession* session); - /// Returns true if the StdLib should not be initialized immediately (eg when doing a -load-stdlib). - static bool hasDeferredStdLib(Index numArgs, const char*const* args); + /// Returns true if the core module should not be initialized immediately (eg when doing a -load-core-module). + static bool hasDeferredCoreModule(Index numArgs, const char*const* args); static SlangResult getDllDirectoryPath(const char* exePath, String& outDllDirectoryPath); }; diff --git a/source/slang-record-replay/record/slang-global-session.cpp b/source/slang-record-replay/record/slang-global-session.cpp index 012900f5c..06bbed553 100644 --- a/source/slang-record-replay/record/slang-global-session.cpp +++ b/source/slang-record-replay/record/slang-global-session.cpp @@ -306,48 +306,48 @@ namespace SlangRecord return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileStdLib(slang::CompileStdLibFlags flags) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_compileStdLib, m_globalSessionHandle); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_compileCoreModule, m_globalSessionHandle); recorder->recordEnumValue(flags); m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->compileStdLib(flags); + SlangResult res = m_actualGlobalSession->compileCoreModule(flags); return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadStdLib, m_globalSessionHandle); - recorder->recordPointer(stdLib, false, stdLibSizeInBytes); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadCoreModule, m_globalSessionHandle); + recorder->recordPointer(coreModule, false, coreModuleSizeInBytes); m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->loadStdLib(stdLib, stdLibSizeInBytes); + SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveStdLib, m_globalSessionHandle); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveCoreModule, m_globalSessionHandle); recorder->recordEnumValue(archiveType); recorder = m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->saveStdLib(archiveType, outBlob); + SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob); { recorder->recordAddress(*outBlob); diff --git a/source/slang-record-replay/record/slang-global-session.h b/source/slang-record-replay/record/slang-global-session.h index 25504ff02..284185cb4 100644 --- a/source/slang-record-replay/record/slang-global-session.h +++ b/source/slang-record-replay/record/slang-global-session.h @@ -42,9 +42,9 @@ namespace SlangRecord SLANG_NO_THROW SlangResult SLANG_MCALL checkCompileTargetSupport(SlangCompileTarget target) override; SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override; - 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-record-replay/replay/decoder-consumer.h b/source/slang-record-replay/replay/decoder-consumer.h index aa3883cc0..d1039d867 100644 --- a/source/slang-record-replay/replay/decoder-consumer.h +++ b/source/slang-record-replay/replay/decoder-consumer.h @@ -30,9 +30,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) = 0; virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) = 0; virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) = 0; - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) = 0; - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) = 0; - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) = 0; + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) = 0; + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) = 0; + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) = 0; virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) = 0; virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) = 0; virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) = 0; diff --git a/source/slang-record-replay/replay/json-consumer.cpp b/source/slang-record-replay/replay/json-consumer.cpp index 27b2830d6..21fd45807 100644 --- a/source/slang-record-replay/replay/json-consumer.cpp +++ b/source/slang-record-replay/replay/json-consumer.cpp @@ -787,17 +787,17 @@ namespace SlangRecord } - void JsonConsumer::IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) + void JsonConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "flags", CompileStdLibFlagsToString(flags)); + _writePairNoComma(builder, indent, "flags", CompileCoreModuleFlagsToString(flags)); } } @@ -806,19 +806,19 @@ namespace SlangRecord } - void JsonConsumer::IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) + void JsonConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; - _writeString(builder, indent, "IGlobalSession::loadStdLib: {\n"); + _writeString(builder, indent, "IGlobalSession::loadCoreModule: {\n"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "stdLib-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "stdLibSizeInBytes", (uint32_t)stdLibSizeInBytes); + _writePair(builder, indent, "coreModule-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma(builder, indent, "coreModuleSizeInBytes", (uint32_t)coreModuleSizeInBytes); } } @@ -826,14 +826,14 @@ namespace SlangRecord m_fileStream.flush(); } - void JsonConsumer::IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) + void JsonConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); _writePair(builder, indent, "archiveType", SlangArchiveTypeToString(archiveType)); diff --git a/source/slang-record-replay/replay/json-consumer.h b/source/slang-record-replay/replay/json-consumer.h index d0529aab4..a7eaf1ec2 100644 --- a/source/slang-record-replay/replay/json-consumer.h +++ b/source/slang-record-replay/replay/json-consumer.h @@ -77,9 +77,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId); virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target); virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough); - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags); - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes); - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId); + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags); + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes); + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId); virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name); virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler); virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target); diff --git a/source/slang-record-replay/replay/replay-consumer.cpp b/source/slang-record-replay/replay/replay-consumer.cpp index dd457c5d0..3ef2ae97d 100644 --- a/source/slang-record-replay/replay/replay-consumer.cpp +++ b/source/slang-record-replay/replay/replay-consumer.cpp @@ -466,42 +466,42 @@ namespace SlangRecord } - void ReplayConsumer::IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) + void ReplayConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) { InputObjectSanityCheck(objectId); slang::IGlobalSession* globalSession = getObjectPointer(objectId); - SlangResult res = globalSession->compileStdLib(flags); + SlangResult res = globalSession->compileCoreModule(flags); if (SLANG_FAILED(res)) { - slangRecordLog(LogLevel::Error, "IGlobalSession::compileStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::compileCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } - void ReplayConsumer::IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) + void ReplayConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) { InputObjectSanityCheck(objectId); slang::IGlobalSession* globalSession = getObjectPointer(objectId); - SlangResult res = globalSession->loadStdLib(stdLib, stdLibSizeInBytes); + SlangResult res = globalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); if (SLANG_FAILED(res)) { - slangRecordLog(LogLevel::Error, "IGlobalSession::loadStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::loadCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } - void ReplayConsumer::IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) + void ReplayConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) { InputObjectSanityCheck(objectId); OutputObjectSanityCheck(outBlobId); slang::IGlobalSession* globalSession = getObjectPointer(objectId); ISlangBlob* outBlob {}; - SlangResult res = globalSession->saveStdLib(archiveType, &outBlob); + SlangResult res = globalSession->saveCoreModule(archiveType, &outBlob); if (outBlob && SLANG_SUCCEEDED(res)) { @@ -509,7 +509,7 @@ namespace SlangRecord } else { - slangRecordLog(LogLevel::Error, "IGlobalSession::saveStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::saveCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } diff --git a/source/slang-record-replay/replay/replay-consumer.h b/source/slang-record-replay/replay/replay-consumer.h index b7620af0d..8a0260c82 100644 --- a/source/slang-record-replay/replay/replay-consumer.h +++ b/source/slang-record-replay/replay/replay-consumer.h @@ -76,9 +76,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) override; virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) override; virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) override; - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) override; - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) override; - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) override; + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) override; + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) override; + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) override; virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) override; virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override; virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) override; diff --git a/source/slang-record-replay/replay/slang-decoder.cpp b/source/slang-record-replay/replay/slang-decoder.cpp index 30d182729..6eb4ac8f5 100644 --- a/source/slang-record-replay/replay/slang-decoder.cpp +++ b/source/slang-record-replay/replay/slang-decoder.cpp @@ -91,14 +91,14 @@ namespace SlangRecord case ApiCallId::IGlobalSession_checkPassThroughSupport: IGlobalSession_checkPassThroughSupport(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_compileStdLib: - IGlobalSession_compileStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_compileCoreModule: + IGlobalSession_compileCoreModule(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_loadStdLib: - IGlobalSession_loadStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_loadCoreModule: + IGlobalSession_loadCoreModule(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_saveStdLib: - IGlobalSession_saveStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_saveCoreModule: + IGlobalSession_saveCoreModule(objectId, parameterBlock); break; case ApiCallId::IGlobalSession_findCapability: IGlobalSession_findCapability(objectId, parameterBlock); @@ -619,29 +619,29 @@ namespace SlangRecord slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); } - void SlangDecoder::IGlobalSession_compileStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { - slang::CompileStdLibFlags flags {}; + slang::CompileCoreModuleFlags flags {}; ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, flags); for (auto consumer: m_consumers) { - consumer->IGlobalSession_compileStdLib(objectId, flags); + consumer->IGlobalSession_compileCoreModule(objectId, flags); } } - void SlangDecoder::IGlobalSession_loadStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { - PointerDecoder stdLib; - ParameterDecoder::decodePointer(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, stdLib); + PointerDecoder coreModule; + ParameterDecoder::decodePointer(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, coreModule); for (auto consumer: m_consumers) { - consumer->IGlobalSession_loadStdLib(objectId, stdLib.getPointer(), stdLib.getDataSize()); + consumer->IGlobalSession_loadCoreModule(objectId, coreModule.getPointer(), coreModule.getDataSize()); } } - void SlangDecoder::IGlobalSession_saveStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { SlangArchiveType archiveType {}; ObjectID outBlobId = 0; @@ -650,7 +650,7 @@ namespace SlangRecord for (auto consumer: m_consumers) { - consumer->IGlobalSession_saveStdLib(objectId, archiveType, outBlobId); + consumer->IGlobalSession_saveCoreModule(objectId, archiveType, outBlobId); } } diff --git a/source/slang-record-replay/replay/slang-decoder.h b/source/slang-record-replay/replay/slang-decoder.h index 78c3128ba..03af6d842 100644 --- a/source/slang-record-replay/replay/slang-decoder.h +++ b/source/slang-record-replay/replay/slang-decoder.h @@ -57,9 +57,9 @@ namespace SlangRecord void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_checkPassThroughSupport(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_compileStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_loadStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_saveStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_findCapability(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); diff --git a/source/slang-record-replay/util/emum-to-string.h b/source/slang-record-replay/util/emum-to-string.h index 8c140cf3d..3b275399c 100644 --- a/source/slang-record-replay/util/emum-to-string.h +++ b/source/slang-record-replay/util/emum-to-string.h @@ -215,13 +215,13 @@ namespace SlangRecord CASE(ValidateUniformity); CASE(AllowGLSL); CASE(ArchiveType); - CASE(CompileStdLib); + CASE(CompileCoreModule); CASE(Doc); CASE(IrCompression); - CASE(LoadStdLib); + CASE(LoadCoreModule); CASE(ReferenceModule); - CASE(SaveStdLib); - CASE(SaveStdLibBinSource); + CASE(SaveCoreModule); + CASE(SaveCoreModuleBinSource); CASE(TrackLiveness); CASE(LoopInversion); CASE(CountOfParsableOptions); @@ -332,15 +332,15 @@ namespace SlangRecord } } - static Slang::String CompileStdLibFlagsToString(const slang::CompileStdLibFlags flags) + static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModuleFlags flags) { using namespace slang; switch(flags) { - case CompileStdLibFlag::WriteDocumentation: return "WriteDocumentation"; + case CompileCoreModuleFlag::WriteDocumentation: return "WriteDocumentation"; default: Slang::StringBuilder str; - str << "Unknown CompileStdLibFlags: " << static_cast(flags); + str << "Unknown CompileCoreModuleFlags: " << static_cast(flags); return str.toString(); } } diff --git a/source/slang-record-replay/util/record-format.h b/source/slang-record-replay/util/record-format.h index 1a32dbbd6..7c53044d6 100644 --- a/source/slang-record-replay/util/record-format.h +++ b/source/slang-record-replay/util/record-format.h @@ -78,9 +78,9 @@ namespace SlangRecord IGlobalSession_getSharedLibraryLoader = makeApiCallId(Class_IGlobalSession, 0x000E), IGlobalSession_checkCompileTargetSupport = makeApiCallId(Class_IGlobalSession, 0x000F), IGlobalSession_checkPassThroughSupport = makeApiCallId(Class_IGlobalSession, 0x0010), - IGlobalSession_compileStdLib = makeApiCallId(Class_IGlobalSession, 0x0011), - IGlobalSession_loadStdLib = makeApiCallId(Class_IGlobalSession, 0x0012), - IGlobalSession_saveStdLib = makeApiCallId(Class_IGlobalSession, 0x0013), + IGlobalSession_compileCoreModule = makeApiCallId(Class_IGlobalSession, 0x0011), + IGlobalSession_loadCoreModule = makeApiCallId(Class_IGlobalSession, 0x0012), + IGlobalSession_saveCoreModule = makeApiCallId(Class_IGlobalSession, 0x0013), IGlobalSession_findCapability = makeApiCallId(Class_IGlobalSession, 0x0014), IGlobalSession_setDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0015), IGlobalSession_getDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0016), diff --git a/source/slang-stdlib/CMakeLists.txt b/source/slang-stdlib/CMakeLists.txt index a6d646cf3..e7fed354a 100644 --- a/source/slang-stdlib/CMakeLists.txt +++ b/source/slang-stdlib/CMakeLists.txt @@ -19,7 +19,7 @@ set(stdlib_generated_header add_custom_command( OUTPUT ${stdlib_generated_header} COMMAND - slang-bootstrap -archive-type riff-lz4 -save-stdlib-bin-source + slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source ${stdlib_generated_header} DEPENDS slang-bootstrap VERBATIM diff --git a/source/slang-stdlib/slang-embedded-stdlib.cpp b/source/slang-stdlib/slang-embedded-stdlib.cpp index 87107fa50..83e4a8c70 100644 --- a/source/slang-stdlib/slang-embedded-stdlib.cpp +++ b/source/slang-stdlib/slang-embedded-stdlib.cpp @@ -4,21 +4,21 @@ #ifdef SLANG_EMBED_STDLIB -static const uint8_t g_stdLib[] = +static const uint8_t g_coreModule[] = { # include "slang-stdlib-generated.h" }; -static Slang::StaticBlob g_stdLibBlob((const void*)g_stdLib, sizeof(g_stdLib)); +static Slang::StaticBlob g_coreModuleBlob((const void*)g_coreModule, sizeof(g_coreModule)); -SLANG_API ISlangBlob* slang_getEmbeddedStdLib() +SLANG_API ISlangBlob* slang_getEmbeddedCoreModule() { - return &g_stdLibBlob; + return &g_coreModuleBlob; } #else -SLANG_API ISlangBlob* slang_getEmbeddedStdLib() +SLANG_API ISlangBlob* slang_getEmbeddedCoreModule() { return nullptr; } 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 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 ", "Set the archive type for -save-stdlib. Default is zip." }, - { OptionKind::CompileStdLib, "-compile-stdlib", nullptr, + { OptionKind::ArchiveType, "-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 ", "Set compression for IR and AST outputs.\n" "Accepted compression types: none, lite"}, - { OptionKind::LoadStdLib, "-load-stdlib", "-load-stdlib ", "Load the StdLib from file." }, + { OptionKind::LoadCoreModule, "-load-core-module", "-load-core-module ", "Load the core module from file." }, { OptionKind::ReferenceModule, "-r", "-r ", "reference module " }, - { OptionKind::SaveStdLib, "-save-stdlib", "-save-stdlib ", "Save the StdLib modules to an archive file." }, - { OptionKind::SaveStdLibBinSource, "-save-stdlib-bin-source","-save-stdlib-bin-source ", "Same as -save-stdlib but output " + { OptionKind::SaveCoreModule, "-save-core-module", "-save-core-module ", "Save the core module to an archive file." }, + { OptionKind::SaveCoreModuleBinSource, "-save-core-module-bin-source","-save-core-module-bin-source ", "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 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 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 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) { diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp index c7cca428b..75e68ce58 100644 --- a/source/slangc/main.cpp +++ b/source/slangc/main.cpp @@ -83,12 +83,12 @@ SLANG_TEST_TOOL_API SlangResult innerMain(StdWriters* stdWriters, slang::IGlobal // Assume we will used the shared session ComPtr session(sharedSession); - // The sharedSession always has a pre-loaded stdlib, is sharedSession is not nullptr. - // This differed test checks if the command line has an option to setup the stdlib. - // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation. - if (TestToolUtil::hasDeferredStdLib(Index(argc - 1), argv + 1)) + // The sharedSession always has a pre-loaded core module, is sharedSession is not nullptr. + // This differed test checks if the command line has an option to setup the core module. + // If so we *don't* use the sharedSession, and create a new session without the core module just for this compilation. + if (TestToolUtil::hasDeferredCoreModule(Index(argc - 1), argv + 1)) { - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(SLANG_API_VERSION, session.writeRef())); } else if (!session) { -- cgit v1.2.3