summaryrefslogtreecommitdiff
path: root/source/slang-record-replay
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2025-03-20 11:38:46 -0400
committerGitHub <noreply@github.com>2025-03-20 23:38:46 +0800
commitde6cc94e3b7fa5d1b8eeb53993dbf3ca2cec1cc1 (patch)
tree0913d39d83c4beff06a854b6503bd05d395077b4 /source/slang-record-replay
parent96de7f6a9dccabd1801dcbf1eb76e0967d7f5fe8 (diff)
Add -dump-module command to slangc (#6638)
* Add -dump-module command to slangc The new -dump-module command to slangc will load and disassemble a slang module, similar to what would be seen by the -dump-ir command, except that -dump-ir tells slangc to print IR as it performs some compilation command. That is, -dump-ir requires some larger compilation task. -dump-module on the otherhand requires no additional goal and will simply load a module and print its IR to stdout independently from other compilation steps. Its intended purpose is to inspect .slang-module files on disk. It can also be used on .slang files which will be parsed and lowered if slang does not find an associated ".slang-module" version of the module on disk. The compilation API is extended with a new IModule::disassemble() method which retrieves the string representation of the dumped IR. Closes #6599 * format code * Use FileStream not FILE * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang-record-replay')
-rw-r--r--source/slang-record-replay/record/slang-module.cpp8
-rw-r--r--source/slang-record-replay/record/slang-module.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/source/slang-record-replay/record/slang-module.cpp b/source/slang-record-replay/record/slang-module.cpp
index 2071a8491..628a29c90 100644
--- a/source/slang-record-replay/record/slang-module.cpp
+++ b/source/slang-record-replay/record/slang-module.cpp
@@ -244,4 +244,12 @@ IEntryPointRecorder* ModuleRecorder::getEntryPointRecorder(slang::IEntryPoint* e
return result.detach();
}
}
+
+SlangResult ModuleRecorder::disassemble(ISlangBlob** outBlob)
+{
+ // No need to record this call as it is just a query.
+ slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
+ auto res = m_actualModule->disassemble(outBlob);
+ return res;
+}
} // namespace SlangRecord
diff --git a/source/slang-record-replay/record/slang-module.h b/source/slang-record-replay/record/slang-module.h
index 7608ac52d..d9c83576d 100644
--- a/source/slang-record-replay/record/slang-module.h
+++ b/source/slang-record-replay/record/slang-module.h
@@ -56,6 +56,8 @@ public:
ISlangBlob** outDiagnostics) override;
virtual SLANG_NO_THROW SlangInt32 SLANG_MCALL getDependencyFileCount() override;
virtual SLANG_NO_THROW char const* SLANG_MCALL getDependencyFilePath(SlangInt32 index) override;
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL
+ disassemble(slang::IBlob** outDisassembly) override;
// Interfaces for `IComponentType`
virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override