Skip to content

Commit

Permalink
Replace all use of StandardModules with CoreModules
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwak-work committed Oct 25, 2024
1 parent 0b512eb commit 2bef62f
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 99 deletions.
32 changes: 16 additions & 16 deletions include/slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,10 @@ extern "C"
CompileCoreModule,
Doc,
IrCompression,
LoadStandardModules,
LoadCoreModule,
ReferenceModule,
SaveStandardModules,
SaveStandardModulesBinSource,
SaveCoreModule,
SaveCoreModuleBinSource,
TrackLiveness,
LoopInversion, // bool, enable loop inversion optimization

Expand Down Expand Up @@ -3307,10 +3307,10 @@ namespace slang

};

typedef uint32_t CompileStandardModulesFlags;
struct CompileStandardModulesFlag
typedef uint32_t CompileCoreModuleFlags;
struct CompileCoreModuleFlag
{
enum Enum : CompileStandardModulesFlags
enum Enum : CompileCoreModuleFlags
{
WriteDocumentation = 0x1,
};
Expand Down Expand Up @@ -3487,22 +3487,22 @@ namespace slang
NOTE! API is experimental and not ready for production code
@param flags to control compilation
*/
virtual SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(CompileStandardModulesFlags flags) = 0;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(CompileCoreModuleFlags flags) = 0;

/** Load the standard modules. Currently loads modules from the file system.
@param standardModules Start address of the serialized standard modules
@param standardModulesSizeInBytes The size in bytes of the serialized standard modules
/** Load the core module. Currently loads modules from the file system.
@param coreModule Start address of the serialized core module
@param coreModuleSizeInBytes The size in bytes of the serialized core module
NOTE! API is experimental and not ready for production code
*/
virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadStandardModules(const void* standardModules, size_t standardModulesSizeInBytes) = 0;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) = 0;

/** Save the standard modules to the file system
@param archiveType The type of archive used to hold the standard modules
@param outBlob The serialized blob containing the standard modules
/** Save the core module to the file system
@param archiveType The type of archive used to hold the core module
@param outBlob The serialized blob containing the core module
NOTE! API is experimental and not ready for production code */
virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveStandardModules(SlangArchiveType archiveType, ISlangBlob** outBlob) = 0;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) = 0;

/** Look up the internal ID of a capability by its `name`.
Expand Down Expand Up @@ -4242,7 +4242,7 @@ SLANG_EXTERN_C SLANG_API SlangResult slang_createGlobalSession(
slang::IGlobalSession** outGlobalSession);

/* Create a global session, but do not set up the core module. The core module can
then be loaded via loadStandardModules or compileCoreModule
then be loaded via loadCoreModule or compileCoreModule
@param apiVersion Pass in SLANG_API_VERSION
@param outGlobalSession (out)The created global session that doesn't have a core module setup.
Expand Down
2 changes: 1 addition & 1 deletion source/core/slang-test-tool-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Slang
for (Index i = 0; i < argc; ++i)
{
UnownedStringSlice option(argv[i]);
if (option == "-load-standard-modules" || option == "-compile-core-module")
if (option == "-load-core-module" || option == "-compile-core-module")
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion source/core/slang-test-tool-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ 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 core module should not be initialized immediately (eg when doing a -load-standard-modules).
/// 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);
Expand Down
16 changes: 8 additions & 8 deletions source/slang-record-replay/record/slang-global-session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace SlangRecord
return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileCoreModule(slang::CompileStandardModulesFlags flags)
SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags)
{
slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

Expand All @@ -321,33 +321,33 @@ namespace SlangRecord
return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadStandardModules(const void* standardModules, size_t standardModulesSizeInBytes)
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_loadStandardModules, m_globalSessionHandle);
recorder->recordPointer(standardModules, false, standardModulesSizeInBytes);
recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadCoreModule, m_globalSessionHandle);
recorder->recordPointer(coreModule, false, coreModuleSizeInBytes);
m_recordManager->endMethodRecord();
}

SlangResult res = m_actualGlobalSession->loadStandardModules(standardModules, standardModulesSizeInBytes);
SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes);
return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveStandardModules(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_saveStandardModules, m_globalSessionHandle);
recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveCoreModule, m_globalSessionHandle);
recorder->recordEnumValue(archiveType);
recorder = m_recordManager->endMethodRecord();
}

SlangResult res = m_actualGlobalSession->saveStandardModules(archiveType, outBlob);
SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob);

{
recorder->recordAddress(*outBlob);
Expand Down
6 changes: 3 additions & 3 deletions source/slang-record-replay/record/slang-global-session.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 compileCoreModule(slang::CompileStandardModulesFlags flags) override;
SLANG_NO_THROW SlangResult SLANG_MCALL loadStandardModules(const void* standardModules, size_t standardModulesSizeInBytes) override;
SLANG_NO_THROW SlangResult SLANG_MCALL saveStandardModules(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;

Expand Down
6 changes: 3 additions & 3 deletions source/slang-record-replay/replay/decoder-consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_compileCoreModule(ObjectID objectId, slang::CompileStandardModulesFlags flags) = 0;
virtual void IGlobalSession_loadStandardModules(ObjectID objectId, const void* standardModules, size_t standardModulesSizeInBytes) = 0;
virtual void IGlobalSession_saveStandardModules(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;
Expand Down
18 changes: 9 additions & 9 deletions source/slang-record-replay/replay/json-consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ namespace SlangRecord
}


void JsonConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileStandardModulesFlags flags)
void JsonConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags)
{
SANITY_CHECK();
Slang::StringBuilder builder;
Expand All @@ -797,7 +797,7 @@ namespace SlangRecord
ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileCoreModule");
{
_writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId));
_writePairNoComma(builder, indent, "flags", CompileStandardModulesFlagsToString(flags));
_writePairNoComma(builder, indent, "flags", CompileCoreModuleFlagsToString(flags));
}
}

Expand All @@ -806,34 +806,34 @@ namespace SlangRecord
}


void JsonConsumer::IGlobalSession_loadStandardModules(ObjectID objectId, const void* standardModules, size_t standardModulesSizeInBytes)
void JsonConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes)
{
SANITY_CHECK();
Slang::StringBuilder builder;
int indent = 0;
_writeString(builder, indent, "IGlobalSession::loadStandardModules: {\n");
_writeString(builder, indent, "IGlobalSession::loadCoreModule: {\n");

{
ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadStandardModules");
ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadCoreModule");
{
_writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId));
_writePair(builder, indent, "standardModules-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId));
_writePairNoComma(builder, indent, "standardModulesSizeInBytes", (uint32_t)standardModulesSizeInBytes);
_writePair(builder, indent, "coreModule-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId));
_writePairNoComma(builder, indent, "coreModuleSizeInBytes", (uint32_t)coreModuleSizeInBytes);
}
}

m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength());
m_fileStream.flush();
}

void JsonConsumer::IGlobalSession_saveStandardModules(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::saveStandardModules");
ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveCoreModule");
{
_writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId));
_writePair(builder, indent, "archiveType", SlangArchiveTypeToString(archiveType));
Expand Down
6 changes: 3 additions & 3 deletions source/slang-record-replay/replay/json-consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_compileCoreModule(ObjectID objectId, slang::CompileStandardModulesFlags flags);
virtual void IGlobalSession_loadStandardModules(ObjectID objectId, const void* standardModules, size_t standardModulesSizeInBytes);
virtual void IGlobalSession_saveStandardModules(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);
Expand Down
14 changes: 7 additions & 7 deletions source/slang-record-replay/replay/replay-consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ namespace SlangRecord
}


void ReplayConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileStandardModulesFlags flags)
void ReplayConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags)
{
InputObjectSanityCheck(objectId);

Expand All @@ -480,36 +480,36 @@ namespace SlangRecord
}


void ReplayConsumer::IGlobalSession_loadStandardModules(ObjectID objectId, const void* standardModules, size_t standardModulesSizeInBytes)
void ReplayConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes)
{
InputObjectSanityCheck(objectId);

slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId);
SlangResult res = globalSession->loadStandardModules(standardModules, standardModulesSizeInBytes);
SlangResult res = globalSession->loadCoreModule(coreModule, coreModuleSizeInBytes);

if (SLANG_FAILED(res))
{
slangRecordLog(LogLevel::Error, "IGlobalSession::loadStandardModules 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_saveStandardModules(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId)
void ReplayConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId)
{
InputObjectSanityCheck(objectId);
OutputObjectSanityCheck(outBlobId);

slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId);
ISlangBlob* outBlob {};
SlangResult res = globalSession->saveStandardModules(archiveType, &outBlob);
SlangResult res = globalSession->saveCoreModule(archiveType, &outBlob);

if (outBlob && SLANG_SUCCEEDED(res))
{
m_objectMap.add(outBlobId, outBlob);
}
else
{
slangRecordLog(LogLevel::Error, "IGlobalSession::saveStandardModules 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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/slang-record-replay/replay/replay-consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_compileCoreModule(ObjectID objectId, slang::CompileStandardModulesFlags flags) override;
virtual void IGlobalSession_loadStandardModules(ObjectID objectId, const void* standardModules, size_t standardModulesSizeInBytes) override;
virtual void IGlobalSession_saveStandardModules(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;
Expand Down
Loading

0 comments on commit 2bef62f

Please sign in to comment.