diff options
| author | Dietrich Geisler <dgeisler50@gmail.com> | 2020-06-29 17:42:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-29 14:42:12 -0700 |
| commit | 47b43f8b15ef35c520b9b287fd17ff25e36bfe95 (patch) | |
| tree | fed30013e307f9ee17700ab7e8839bee56f104e1 /source/slang/slang-emit.cpp | |
| parent | 3e8bdb60afb5b0c0a53ce06d1dbbc429988f5885 (diff) | |
Backend for Multiple Entry Points (#1411)
* Backend for Multiple Entry Points
Introduces the basic backend on the compiler for zero or more entry
points. Entry points have been extended to lists for several functions,
with loopFunctions have been extended to take in entry points and
indices as appropriate, to allow for multiple entry points once the
frontend is expanded. Several functions are currently being assumed to
have a single entry point for simplicity and provide a work in progress
commit.
* Progress on debugging fixes
* Tests passing
* Refactored emitEntryPoints
* Updated lists to be by constant reference
* Fixes to formatting
* Refactoring updates for the compiler
* Fix for compilation errors
* Reformatting
* More reformatting
* Moved struct around to help with compilation
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 59b059e91..e59cfae37 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -160,9 +160,10 @@ struct LinkingAndOptimizationOptions CLikeSourceEmitter* sourceEmitter = nullptr; }; +// TODO(DG): A bit tricky; this needs to be generalized to multiple entry points Result linkAndOptimizeIR( BackEndCompileRequest* compileRequest, - Int entryPointIndex, + List<Int> entryPointIndices, CodeGenTarget target, TargetRequest* targetRequest, LinkingAndOptimizationOptions const& options, @@ -184,7 +185,7 @@ Result linkAndOptimizeIR( // outLinkedIR = linkIR( compileRequest, - entryPointIndex, + entryPointIndices, target, targetProgram); auto irModule = outLinkedIR.module; @@ -287,6 +288,9 @@ Result linkAndOptimizeIR( break; } + // TODO(DG): There are multiple DCE steps here, which need to be changed + // CHECK: how to these modules work? + // so that they don't just throw out any non-entry point code // Debugging code for IR transformations... #if 0 dumpIRIfEnabled(compileRequest, irModule, "SPECIALIZED"); @@ -605,19 +609,23 @@ Result linkAndOptimizeIR( return SLANG_OK; } +// TODO(DG): This probably needs to be generalized to a list SlangResult emitEntryPointSourceFromIR( BackEndCompileRequest* compileRequest, - Int entryPointIndex, + List<Int> entryPointIndices, CodeGenTarget target, TargetRequest* targetRequest, SourceResult& outSource) { + // Temporary assertion for checkpoint + SLANG_ASSERT(entryPointIndices.getCount() == 1); outSource.reset(); auto sink = compileRequest->getSink(); auto program = compileRequest->getProgram(); - auto entryPoint = program->getEntryPoint(entryPointIndex); + // TODO(DG): Update from assertion + auto entryPoint = program->getEntryPoint(entryPointIndices[0]); auto lineDirectiveMode = compileRequest->getLineDirectiveMode(); // To try to make the default behavior reasonable, we will @@ -637,6 +645,7 @@ SlangResult emitEntryPointSourceFromIR( desc.compileRequest = compileRequest; desc.target = target; + // TODO(DG): Can't assume a single entry point stage for multiple entry points desc.entryPointStage = entryPoint->getStage(); desc.effectiveProfile = getEffectiveProfile(entryPoint, targetRequest); desc.sourceWriter = &sourceWriter; @@ -700,7 +709,7 @@ SlangResult emitEntryPointSourceFromIR( linkAndOptimizeIR( compileRequest, - entryPointIndex, + entryPointIndices, target, targetRequest, linkingAndOptimizationOptions, @@ -769,25 +778,27 @@ SlangResult emitSPIRVFromIR( IRFunc* irEntryPoint, List<uint8_t>& spirvOut); -SlangResult emitSPIRVForEntryPointDirectly( +SlangResult emitSPIRVForEntryPointsDirectly( BackEndCompileRequest* compileRequest, - Int entryPointIndex, + List<Int> entryPointIndices, TargetRequest* targetRequest, List<uint8_t>& spirvOut) { + // TODO(DG): Temporary assertion for checkpoint + SLANG_ASSERT(entryPointIndices.getCount() == 1); auto sink = compileRequest->getSink(); auto program = compileRequest->getProgram(); auto targetProgram = program->getTargetProgram(targetRequest); auto programLayout = targetProgram->getOrCreateLayout(sink); - RefPtr<EntryPointLayout> entryPointLayout = programLayout->entryPoints[entryPointIndex]; + RefPtr<EntryPointLayout> entryPointLayout = programLayout->entryPoints[entryPointIndices[0]]; // Outside because we want to keep IR in scope whilst we are processing emits LinkedIR linkedIR; LinkingAndOptimizationOptions linkingAndOptimizationOptions; linkAndOptimizeIR( compileRequest, - entryPointIndex, + entryPointIndices, targetRequest->getTarget(), targetRequest, linkingAndOptimizationOptions, |
