summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
authorTheresa Foley <10618364+tangent-vector@users.noreply.github.com>2022-04-11 12:01:31 -0700
committerGitHub <noreply@github.com>2022-04-11 12:01:31 -0700
commit1409a5379d38ac153eabb4c19c7f4463a8b030ca (patch)
tree0b5abbc64dbb46521b52453c9bee09469f032a2c /source/slang/slang-emit.cpp
parent2aac3700741f47caa6e8d674872979e2cdc251ab (diff)
Refactor: eliminate BackEndCompileRequest (#2178)
An earlier refactoring pass over the compiler codebase split the type that had been called `CompileRequest` into three distinct pieces: * `FrontEndCompileRequest` which was supposed to own state and options related to running the compiler front end and producing IR + reflection (e.g., what translation units and source files/strings are included). * `BackEndCompileRequest` which was supposed to own state and options related to running the compiler back end to translate the IR for a `ComponentType` (program) into output code. (Note that the `BackEndCompileRequest` was conceived of as orthogonal to the `TargetRequest`s, which store per-target and target-specific options.) * `EndToEndCompileRequest` which was an umbrella object that owns separate front-end and back-end requests, plus any state that is only relevant when doing a true end-to-end compile (such as the kinds of compiles initiated with `slangc`). As originally conceived, the only state that this type was supposed to own was stuff related to "pass-through" compilation, as well as state related to writing of generated code to output files. That refactoring work was very useful at the time, because it allowed us to "scrub" the back end compilation steps to remove all dependencies on front-end and AST state (this was important for our goals of enabling linking and codegen from serialized Slang IR). At this point, however, it is clear that the hierarchy that was built up serves very little purpose: * The `BackEndCompileRequest` type is only used in two places: * As part of an `EndToEndCompileRequest`, where the settings on the `BackEndCompileRequest` can be configured, but only through the `EndToEndCompileRequest` * As part of on-demand code generation through the `IComponentType` APIs. In this case, the settings stored on the `BackEndCompileRequest` are not accessible to the application at all, and will always use their default values, so that instantiating a "request" object doesn't really make any sense. * The `FrontEndCompileRequest` type has a similar situation: * Front-end compilation as part of an `EndToEndCompileRequest` supports user configuration of `FrontEndCompileRequest` settings, but only through the `EndToEndCompileRequest` * Front-end compilation triggered by an `import` or a `loadModule()` call does not support user configuration of settings at all. It will always derive all relevant settings from thsoe on the session ("linkage"). In addition, subsequent changes have been made to the compiler that show a bit of a "code smell" and/or forward-looking worries for this decomposition: * In some cases we've had to add the same setting to multiple types in the breakdown (front-end, back-end, end-to-end, linkage, target, etc.) which makes it harder for us to validate that all the possible mixtures of state work correctly. * Related to the above, in some cases we have manual logic that copies state from one of the objects in the breakdown to another, in order to ensure that the user's intention is actually followed. * As a forward-looking concern, it seems that developers have sometimes added new configuration options and state to places that don't really make sense according to the rationale of the original decomposition (e.g., we probably don't want to have a lot of state that is only available via end-to-end requests, given that the API structure is meant to push users *away* from end-to-end compiles). As a result of all of the above, I've been planning a large refactor with the following big-picture goals: * Eliminate `BackEndCompileRequest` * Move all relevant state/options from the back-end request to the end-to-end request, since that is the only place they could be set anyway. * Introduce a transient "context" type to be used for the duration of code generation that serves the main functions that back-end requests really served in the codebase * Make `EndToEndCompileRequest` be a subclass of `FrontEndCompileRequest` * Consider addding a transient "context" type for front-end compiles that can be used in `import`-like cases rather than needing a full front-end request object. If this works, then eliminate `FrontEndCompileRequest` and be back to world with just a single `CompileRequest` type * Move *all* compiler configuration options to a distinct type (named something like `CompilerConfig` or `CompilerOptions` or whatever) which stores setting as key-value pairs, and has a notion of "inheritance" such that one configuration can extend or build on top of another. Make all the relevant types use this catch-all structure instead of redundantly storing flags in many places. This change deals with the first of those bullets: removeal of `BackEndCompileRequest`. The addition of the `CodeGenContext` type is perhaps an unncessary additional step, but making that change helps clean up a bunch of the code related to per-target code generation, so I think it is the right choice. Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp199
1 files changed, 85 insertions, 114 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 23f06e8e9..067d0a99a 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -1,5 +1,4 @@
// slang-emit.cpp
-#include "slang-emit.h"
#include "../core/slang-writer.h"
#include "../core/slang-type-text-util.h"
@@ -139,17 +138,17 @@ StructTypeLayout* getGlobalStructLayout(
}
static void dumpIRIfEnabled(
- BackEndCompileRequest* compileRequest,
+ CodeGenContext* codeGenContext,
IRModule* irModule,
char const* label = nullptr)
{
- if(compileRequest->shouldDumpIR)
+ if(codeGenContext->shouldDumpIR())
{
- DiagnosticSinkWriter writer(compileRequest->getSink());
+ DiagnosticSinkWriter writer(codeGenContext->getSink());
//FILE* f = nullptr;
//fopen_s(&f, (String("dump-") + label + ".txt").getBuffer(), "wt");
//FileWriter writer(f, 0);
- dumpIR(irModule, compileRequest->m_irDumpOptions, label, compileRequest->getSourceManager(), &writer);
+ dumpIR(irModule, codeGenContext->getIRDumpOptions(), label, codeGenContext->getSourceManager(), &writer);
//fclose(f);
}
}
@@ -161,18 +160,15 @@ struct LinkingAndOptimizationOptions
};
Result linkAndOptimizeIR(
- BackEndCompileRequest* compileRequest,
- const List<Int>& entryPointIndices,
- CodeGenTarget target,
- TargetRequest* targetRequest,
+ CodeGenContext* codeGenContext,
LinkingAndOptimizationOptions const& options,
LinkedIR& outLinkedIR)
{
- auto sink = compileRequest->getSink();
- auto program = compileRequest->getProgram();
- auto targetProgram = program->getTargetProgram(targetRequest);
+ auto session = codeGenContext->getSession();
+ auto sink = codeGenContext->getSink();
+ auto target = codeGenContext->getTargetFormat();
+ auto targetRequest = codeGenContext->getTargetReq();
- auto session = targetRequest->getSession();
// We start out by performing "linking" at the level of the IR.
// This step will create a fresh IR module to be used for
@@ -182,32 +178,28 @@ Result linkAndOptimizeIR(
// modules, and also select between the definitions of
// any "profile-overloaded" symbols.
//
- outLinkedIR = linkIR(
- compileRequest,
- entryPointIndices,
- target,
- targetProgram);
+ outLinkedIR = linkIR(codeGenContext);
auto irModule = outLinkedIR.module;
auto irEntryPoints = outLinkedIR.entryPoints;
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "LINKED");
+ dumpIRIfEnabled(codeGenContext, irModule, "LINKED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// If the user specified the flag that they want us to dump
// IR, then do it here, for the target-specific, but
// un-specialized IR.
- dumpIRIfEnabled(compileRequest, irModule);
+ dumpIRIfEnabled(codeGenContext, irModule);
// Replace any global constants with their values.
//
replaceGlobalConstants(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "GLOBAL CONSTANTS REPLACED");
+ dumpIRIfEnabled(codeGenContext, irModule, "GLOBAL CONSTANTS REPLACED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// When there are top-level existential-type parameters
@@ -219,9 +211,9 @@ Result linkAndOptimizeIR(
//
bindExistentialSlots(irModule, sink);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "EXISTENTIALS BOUND");
+ dumpIRIfEnabled(codeGenContext, irModule, "EXISTENTIALS BOUND");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Now that we've linked the IR code, any layout/binding
// information has been attached to shader parameters
@@ -243,9 +235,9 @@ Result linkAndOptimizeIR(
//
collectGlobalUniformParameters(irModule, outLinkedIR.globalScopeVarLayout);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "GLOBAL UNIFORMS COLLECTED");
+ dumpIRIfEnabled(codeGenContext, irModule, "GLOBAL UNIFORMS COLLECTED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Another transformation that needed to wait until we
// had layout information on parameters is to take uniform
@@ -264,9 +256,9 @@ Result linkAndOptimizeIR(
case CodeGenTarget::CUDASource:
collectOptiXEntryPointUniformParams(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "OPTIX ENTRY POINT UNIFORMS COLLECTED");
+ dumpIRIfEnabled(codeGenContext, irModule, "OPTIX ENTRY POINT UNIFORMS COLLECTED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
break;
case CodeGenTarget::CPPSource:
@@ -274,9 +266,9 @@ Result linkAndOptimizeIR(
default:
collectEntryPointUniformParams(irModule, passOptions);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "ENTRY POINT UNIFORMS COLLECTED");
+ dumpIRIfEnabled(codeGenContext, irModule, "ENTRY POINT UNIFORMS COLLECTED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
break;
}
}
@@ -286,9 +278,9 @@ Result linkAndOptimizeIR(
default:
moveEntryPointUniformParamsToGlobalScope(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "ENTRY POINT UNIFORMS MOVED");
+ dumpIRIfEnabled(codeGenContext, irModule, "ENTRY POINT UNIFORMS MOVED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
break;
case CodeGenTarget::HostCPPSource:
case CodeGenTarget::CPPSource:
@@ -302,9 +294,9 @@ Result linkAndOptimizeIR(
//
desugarUnionTypes(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "UNIONS DESUGARED");
+ dumpIRIfEnabled(codeGenContext, irModule, "UNIONS DESUGARED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Next, we need to ensure that the code we emit for
// the target doesn't contain any operations that would
@@ -325,24 +317,24 @@ Result linkAndOptimizeIR(
// perform specialization of functions based on parameter
// values that need to be compile-time constants.
//
- dumpIRIfEnabled(compileRequest, irModule, "BEFORE-SPECIALIZE");
- if (!compileRequest->disableSpecialization)
+ dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-SPECIALIZE");
+ if (!codeGenContext->isSpecializationDisabled())
specializeModule(irModule);
- dumpIRIfEnabled(compileRequest, irModule, "AFTER-SPECIALIZE");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER-SPECIALIZE");
applySparseConditionalConstantPropagation(irModule);
eliminateDeadCode(irModule);
lowerReinterpret(targetRequest, irModule, sink);
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// For targets that supports dynamic dispatch, we need to lower the
// generics / interface types to ordinary functions and types using
// function pointers.
- dumpIRIfEnabled(compileRequest, irModule, "BEFORE-LOWER-GENERICS");
+ dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-LOWER-GENERICS");
lowerGenerics(targetRequest, irModule, sink);
- dumpIRIfEnabled(compileRequest, irModule, "AFTER-LOWER-GENERICS");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER-LOWER-GENERICS");
if (sink->getErrorCount() != 0)
return SLANG_FAIL;
@@ -355,9 +347,9 @@ Result linkAndOptimizeIR(
// so that they don't just throw out any non-entry point code
// Debugging code for IR transformations...
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "SPECIALIZED");
+ dumpIRIfEnabled(codeGenContext, irModule, "SPECIALIZED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Inline calls to any functions marked with [__unsafeInlineEarly] again,
// since we may be missing out cases prevented by the generic constructs
@@ -370,9 +362,9 @@ Result linkAndOptimizeIR(
//
simplifyIR(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER DCE");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER DCE");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// We don't need the legalize pass for C/C++ based types
if(options.shouldLegalizeExistentialAndResourceTypes )
@@ -409,9 +401,9 @@ Result linkAndOptimizeIR(
eliminateDeadCode(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "EXISTENTIALS LEGALIZED");
+ dumpIRIfEnabled(codeGenContext, irModule, "EXISTENTIALS LEGALIZED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Many of our target languages and/or downstream compilers
// don't support `struct` types that have resource-type fields.
@@ -431,9 +423,9 @@ Result linkAndOptimizeIR(
// Debugging output of legalization
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "LEGALIZED");
+ dumpIRIfEnabled(codeGenContext, irModule, "LEGALIZED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
}
// Once specialization and type legalization have been performed,
@@ -444,9 +436,9 @@ Result linkAndOptimizeIR(
simplifyIR(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER SSA");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER SSA");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// After type legalization and subsequent SSA cleanup we expect
// that any resource types passed to functions are exposed
@@ -457,8 +449,8 @@ Result linkAndOptimizeIR(
// resource types can be used, so that having them as
// function parameters, reults, etc. is invalid.
// We clean up the usages of resource values here.
- specializeResourceUsage(compileRequest, targetRequest, irModule);
- specializeFuncsForBufferLoadArgs(compileRequest, targetRequest, irModule);
+ specializeResourceUsage(codeGenContext, irModule);
+ specializeFuncsForBufferLoadArgs(codeGenContext, irModule);
//
simplifyIR(irModule);
@@ -468,15 +460,15 @@ Result linkAndOptimizeIR(
// those platforms.
if (isKhronosTarget(targetRequest))
{
- specializeArrayParameters(compileRequest, targetRequest, irModule);
+ specializeArrayParameters(codeGenContext, irModule);
simplifyIR(irModule);
}
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER RESOURCE SPECIALIZATION");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER RESOURCE SPECIALIZATION");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// For HLSL (and fxc/dxc) only, we need to "wrap" any
// structured buffers defined over matrix types so
@@ -491,9 +483,9 @@ Result linkAndOptimizeIR(
{
wrapStructuredBuffersOfMatrices(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "STRUCTURED BUFFERS WRAPPED");
+ dumpIRIfEnabled(codeGenContext, irModule, "STRUCTURED BUFFERS WRAPPED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
}
break;
@@ -600,12 +592,12 @@ Result linkAndOptimizeIR(
{
synthesizeActiveMask(
irModule,
- compileRequest->getSink());
+ codeGenContext->getSink());
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER synthesizeActiveMask");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER synthesizeActiveMask");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
}
break;
@@ -631,26 +623,26 @@ Result linkAndOptimizeIR(
session,
irModule,
irEntryPoints,
- compileRequest->getSink(),
+ codeGenContext->getSink(),
glslExtensionTracker);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "GLSL LEGALIZED");
+ dumpIRIfEnabled(codeGenContext, irModule, "GLSL LEGALIZED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
}
break;
case CodeGenTarget::CSource:
case CodeGenTarget::CPPSource:
{
- legalizeEntryPointVaryingParamsForCPU(irModule, compileRequest->getSink());
+ legalizeEntryPointVaryingParamsForCPU(irModule, codeGenContext->getSink());
}
break;
case CodeGenTarget::CUDASource:
{
- legalizeEntryPointVaryingParamsForCUDA(irModule, compileRequest->getSink());
+ legalizeEntryPointVaryingParamsForCUDA(irModule, codeGenContext->getSink());
}
break;
@@ -684,9 +676,9 @@ Result linkAndOptimizeIR(
convertEntryPointPtrParamsToRawPtrs(irModule);
}
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "EXPLICIT GLOBAL CONTEXT INTRODUCED");
+ dumpIRIfEnabled(codeGenContext, irModule, "EXPLICIT GLOBAL CONTEXT INTRODUCED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
break;
}
@@ -696,9 +688,9 @@ Result linkAndOptimizeIR(
stripWitnessTables(irModule);
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER STRIP WITNESS TABLES");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER STRIP WITNESS TABLES");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// The resource-based specialization pass above
// may create specialized versions of functions, but
@@ -717,9 +709,9 @@ Result linkAndOptimizeIR(
performGLSLResourceReturnFunctionInlining(irModule);
}
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "AFTER DCE");
+ dumpIRIfEnabled(codeGenContext, irModule, "AFTER DCE");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
// Lower all bit_cast operations on complex types into leaf-level
// bit_cast on basic types.
@@ -731,9 +723,9 @@ Result linkAndOptimizeIR(
// reflect the IR that code is generated from as closely as possible.
//
#if 0
- dumpIRIfEnabled(compileRequest, irModule, "OPTIMIZED");
+ dumpIRIfEnabled(codeGenContext, irModule, "OPTIMIZED");
#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
return SLANG_OK;
}
@@ -742,18 +734,17 @@ void trackGLSLTargetCaps(
GLSLExtensionTracker* extensionTracker,
CapabilitySet const& caps);
-SlangResult emitEntryPointsSourceFromIR(
- BackEndCompileRequest* compileRequest,
- const List<Int>& entryPointIndices,
- CodeGenTarget target,
- TargetRequest* targetRequest,
- ExtensionTracker* extensionTracker,
+SlangResult CodeGenContext::emitEntryPointsSourceFromIR(
String& outSource)
{
outSource = String();
- auto sink = compileRequest->getSink();
- auto program = compileRequest->getProgram();
+ auto extensionTracker = getExtensionTracker();
+ auto session = getSession();
+ auto sink = getSink();
+ auto sourceManager = getSourceManager();
+ auto target = getTargetFormat();
+ auto targetRequest = getTargetReq();
auto lineDirectiveMode = targetRequest->getLineDirectiveMode();
// To try to make the default behavior reasonable, we will
@@ -767,17 +758,15 @@ SlangResult emitEntryPointsSourceFromIR(
lineDirectiveMode = LineDirectiveMode::GLSL;
}
- SourceWriter sourceWriter(compileRequest->getSourceManager(), lineDirectiveMode );
+ SourceWriter sourceWriter(sourceManager, lineDirectiveMode );
CLikeSourceEmitter::Desc desc;
- desc.compileRequest = compileRequest;
- desc.targetRequest = targetRequest;
- desc.target = target;
- // TODO(DG): Can't assume a single entry point stage for multiple entry points
- if (entryPointIndices.getCount() == 1)
+ desc.codeGenContext = this;
+
+ if (getEntryPointCount() == 1)
{
- auto entryPoint = program->getEntryPoint(entryPointIndices[0]);
+ auto entryPoint = getEntryPoint(getSingleEntryPointIndex());
desc.entryPointStage = entryPoint->getStage();
desc.effectiveProfile = getEffectiveProfile(entryPoint, targetRequest);
}
@@ -786,9 +775,7 @@ SlangResult emitEntryPointsSourceFromIR(
desc.entryPointStage = Stage::Unknown;
desc.effectiveProfile = targetRequest->getTargetProfile();
}
- desc.targetCaps = targetRequest->getTargetCaps();
desc.sourceWriter = &sourceWriter;
- desc.extensionTracker = extensionTracker;
// Define here, because must be in scope longer than the sourceEmitter, as sourceEmitter might reference
// items in the linkedIR module
@@ -848,10 +835,7 @@ SlangResult emitEntryPointsSourceFromIR(
}
SLANG_RETURN_ON_FAIL(linkAndOptimizeIR(
- compileRequest,
- entryPointIndices,
- target,
- targetRequest,
+ this,
linkingAndOptimizationOptions,
linkedIR));
@@ -884,7 +868,7 @@ SlangResult emitEntryPointsSourceFromIR(
else
{
// If there is a prelude emit it
- const auto& prelude = compileRequest->getSession()->getPreludeForLanguage(sourceLanguage);
+ const auto& prelude = session->getPreludeForLanguage(sourceLanguage);
if (prelude.getLength() > 0)
{
sourceWriter.emit(prelude.getUnownedSlice());
@@ -924,40 +908,27 @@ SlangResult emitEntryPointsSourceFromIR(
}
SlangResult emitSPIRVFromIR(
- BackEndCompileRequest* compileRequest,
- TargetRequest* targetRequest,
+ CodeGenContext* codeGenContext,
IRModule* irModule,
const List<IRFunc*>& irEntryPoints,
List<uint8_t>& spirvOut);
SlangResult emitSPIRVForEntryPointsDirectly(
- BackEndCompileRequest* compileRequest,
- const List<Int>& entryPointIndices,
- TargetRequest* targetRequest,
- List<uint8_t>& spirvOut)
+ CodeGenContext* codeGenContext,
+ List<uint8_t>& spirvOut)
{
- auto sink = compileRequest->getSink();
- auto program = compileRequest->getProgram();
- auto targetProgram = program->getTargetProgram(targetRequest);
- auto programLayout = targetProgram->getOrCreateLayout(sink);
-
- 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;
SLANG_RETURN_ON_FAIL(linkAndOptimizeIR(
- compileRequest,
- entryPointIndices,
- targetRequest->getTarget(),
- targetRequest,
+ codeGenContext,
linkingAndOptimizationOptions,
linkedIR));
auto irModule = linkedIR.module;
auto irEntryPoints = linkedIR.entryPoints;
- emitSPIRVFromIR(compileRequest, targetRequest, irModule, irEntryPoints, spirvOut);
+ emitSPIRVFromIR(codeGenContext, irModule, irEntryPoints, spirvOut);
return SLANG_OK;
}