diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-18 15:06:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 15:06:14 -0700 |
| commit | 515d8eb0cd719ae31db2f6e03751011a123bc0ba (patch) | |
| tree | 3e78893a74af856fb29158078bed7099a567f5dd /source/slang/slang-emit.cpp | |
| parent | e2d21026d115dc61296b47dcc990534f1844bc7f (diff) | |
| parent | aa6aca498cd1f7fbbdb143e72dd48b1d714c8fbb (diff) | |
Merge branch 'master' into feature/prelude-fix
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 63 |
1 files changed, 13 insertions, 50 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 4af7b5989..f2552f95d 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -308,7 +308,7 @@ Result linkAndOptimizeIR( // We don't need the legalize pass for C/C++ based types if(options.shouldLegalizeExistentialAndResourceTypes ) -// if (!(sourceStyle == SourceStyle::CPP || sourceStyle == SourceStyle::C)) +// if (!(sourceLanguage == SourceLanguage::CPP || sourceStyle == SourceLanguage::C)) { // The Slang language allows interfaces to be used like // ordinary types (including placing them in constant @@ -495,7 +495,7 @@ Result linkAndOptimizeIR( auto profile = targetRequest->targetProfile; if( profile.getFamily() == ProfileFamily::DX ) { - if(profile.GetVersion() <= ProfileVersion::DX_5_0) + if(profile.getVersion() <= ProfileVersion::DX_5_0) { // Fxc and earlier dxc versions do not support // a templates `.Load<T>` operation on byte-address @@ -646,27 +646,25 @@ SlangResult emitEntryPointSourceFromIR( RefPtr<CLikeSourceEmitter> sourceEmitter; - typedef CLikeSourceEmitter::SourceStyle SourceStyle; - - SourceStyle sourceStyle = CLikeSourceEmitter::getSourceStyle(target); - switch (sourceStyle) + SourceLanguage sourceLanguage = CLikeSourceEmitter::getSourceLanguage(target); + switch (sourceLanguage) { - case SourceStyle::CPP: + case SourceLanguage::CPP: { sourceEmitter = new CPPSourceEmitter(desc); break; } - case SourceStyle::GLSL: + case SourceLanguage::GLSL: { sourceEmitter = new GLSLSourceEmitter(desc); break; } - case SourceStyle::HLSL: + case SourceLanguage::HLSL: { sourceEmitter = new HLSLSourceEmitter(desc); break; } - case SourceStyle::CUDA: + case SourceLanguage::CUDA: { sourceEmitter = new CUDASourceEmitter(desc); break; @@ -687,14 +685,14 @@ SlangResult emitEntryPointSourceFromIR( linkingAndOptimizationOptions.sourceEmitter = sourceEmitter; - switch( sourceStyle ) + switch( sourceLanguage ) { default: break; - case SourceStyle::CPP: - case SourceStyle::C: - case SourceStyle::CUDA: + case SourceLanguage::CPP: + case SourceLanguage::C: + case SourceLanguage::CUDA: linkingAndOptimizationOptions.shouldLegalizeExistentialAndResourceTypes = false; break; } @@ -728,43 +726,8 @@ SlangResult emitEntryPointSourceFromIR( // it is time to stitch together the final output. { - Session* session = compileRequest->getSession(); - - // Get the downstream compiler needed for final target - PassThroughMode passThru = getDownstreamCompilerRequiredForTarget(session, targetRequest->target); - - // If nothing was *needed*, we still need some idea of which downstream compiler is going to be used for the - // prelude (the prelude is associated with each specific downstream compiler) - if (passThru == PassThroughMode::None) - { - // TODO(JS): - // NOTE! This makes the *assumption* that if we are outputting source, we don't want the - // prelude for a specific compiler, we are happy to just use the GenericCCpp - // If we didn't do this, we would have to do the work out what's available etc. - // - // This is all a bit unfortunate. The decision to associate preludes on compilers seemed like a good idea, but was perhaps a mistake. - // That it would be simpler if prelude was based on output source type. - passThru = getPreludeDownstreamCompilerForTarget(session, targetRequest->target); - } - else - { - // If a compiler was required that means a downstream compiler *will* be used - // so lookup which specific compiler is used, and use it's prelude - // Currently this distinction is only applicable to C++ - if (passThru == PassThroughMode::GenericCCpp) - { - const SourceLanguage sourceLanguage = (sourceStyle == SourceStyle::C) ? SourceLanguage::C : SourceLanguage::CPP; - // Get the compiler used for the language - DownstreamCompiler* compiler = session->getDefaultDownstreamCompiler(sourceLanguage); - if (compiler) - { - passThru = PassThroughMode(compiler->getDesc().type); - } - } - } - // If there is a prelude emit it - const auto& prelude = compileRequest->getSession()->getDownstreamCompilerPrelude(passThru); + const auto& prelude = compileRequest->getSession()->getPreludeForLanguage(sourceLanguage); if (prelude.getLength() > 0) { sourceWriter.emit(prelude.getUnownedSlice()); |
