diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-08-31 13:02:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-31 13:02:55 -0400 |
| commit | 69025ad82238a7402b18d9c566fac1574faef684 (patch) | |
| tree | ab01e4248071f9f597aa04f15742852a7662ed23 /source/slang/slang-compiler.cpp | |
| parent | baa789e0c9109bcb1e717ce4a9953709e7345e55 (diff) | |
AST Serialization in Modules (#1524)
* First pass at filter for AST serial writing.
* Serialization of AST for modules.
* Removed some commented out source.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-compiler.cpp')
| -rwxr-xr-x | source/slang/slang-compiler.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index d0b15c683..53e529cc7 100755 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -23,6 +23,8 @@ #include "slang-glsl-extension-tracker.h" #include "slang-emit-cuda.h" +#include "slang-ast-serialize.h" + #include "slang-ir-serialize.h" // Enable calling through to `fxc` or `dxc` to @@ -2331,7 +2333,7 @@ SlangResult dissassembleDXILUsingDXC( { // Module list - RiffContainer::ScopeChunk listScope(&container, RiffContainer::Chunk::Kind::List, IRSerialBinary::kSlangModuleListFourCc); + RiffContainer::ScopeChunk listScope(&container, RiffContainer::Chunk::Kind::List, SerialBinary::kSlangModuleListFourCc); auto linkage = getLinkage(); auto sink = getSink(); @@ -2344,9 +2346,11 @@ SlangResult dissassembleDXILUsingDXC( optionFlags |= IRSerialWriter::OptionFlag::DebugInfo; } + RefPtr<ASTSerialClasses> astClasses = new ASTSerialClasses; + SourceManager* sourceManager = frontEndReq->getSourceManager(); - for (auto translationUnit : frontEndReq->translationUnits) + for (TranslationUnitRequest* translationUnit : frontEndReq->translationUnits) { auto module = translationUnit->module; auto irModule = module->getIRModule(); @@ -2354,10 +2358,27 @@ SlangResult dissassembleDXILUsingDXC( // Okay, we need to serialize this module to our container file. // We currently don't serialize it's name..., but support for that could be added. - IRSerialData serialData; - IRSerialWriter writer; - SLANG_RETURN_ON_FAIL(writer.write(irModule, sourceManager, optionFlags, &serialData)); - SLANG_RETURN_ON_FAIL(IRSerialWriter::writeContainer(serialData, compressionType, &container)); + // Write the IR information + { + IRSerialData serialData; + IRSerialWriter writer; + SLANG_RETURN_ON_FAIL(writer.write(irModule, sourceManager, optionFlags, &serialData)); + SLANG_RETURN_ON_FAIL(IRSerialWriter::writeContainer(serialData, compressionType, &container)); + } + + // Write the AST information + { + ModuleDecl* moduleDecl = translationUnit->getModuleDecl(); + + ModuleASTSerialFilter filter(moduleDecl); + ASTSerialWriter writer(astClasses, &filter); + + // Add the module and everything that isn't filtered out in the filter. + writer.addPointer(moduleDecl); + + // We can now serialize it into the riff container. + SLANG_RETURN_ON_FAIL(writer.writeIntoContainer(&container)); + } } auto program = getSpecializedGlobalAndEntryPointsComponentType(); @@ -2383,7 +2404,7 @@ SlangResult dissassembleDXILUsingDXC( auto entryPoint = program->getEntryPoint(ii); auto entryPointMangledName = program->getEntryPointMangledName(ii); - RiffContainer::ScopeChunk entryPointScope(&container, RiffContainer::Chunk::Kind::Data, IRSerialBinary::kEntryPointFourCc); + RiffContainer::ScopeChunk entryPointScope(&container, RiffContainer::Chunk::Kind::Data, SerialBinary::kEntryPointFourCc); auto writeString = [&](String const& str) { @@ -2529,7 +2550,8 @@ SlangResult dissassembleDXILUsingDXC( compileRequest, targetReq); } - else { + else + { for (Index ee = 0; ee < entryPointCount; ++ee) { writeEntryPointResult( |
