summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-12-12 14:53:44 -0500
committerGitHub <noreply@github.com>2019-12-12 14:53:44 -0500
commit15335549340c54fd7b89b28104ddc907e9c64638 (patch)
tree02c4705fc7784c3003d14fc661894b5f88c05875 /source/slang/slang-compiler.cpp
parent6e6a876a6b5ad3d2ef402757d2e20641f5a2b49b (diff)
Use DownstreamCompiler for all downstream compilers (#1152)
* CPPCompiler -> DownstreamCompiler * Added DownstreamCompileResult to start abstraction such that we don't need files. * * Split out slang-blob.cpp * Made CompileResult hold a DownstreamCompileResult - for access to binary or ISlangSharedLibrary * Keep temporary files in scope. * Add a hash to the hex dump stream. * Move all file tracking into DownstreamCompiler. * WIP support for nvrtc. * WIP: Adding support for nvrtc compiler. Adding enum types, wiring up the nvrtc into slang. * Fix remaining CPPCompiler references. * Fix order issue on target string matching. * Use ISlangSharedLibrary for nvrtc. * Use DownstreamCompiler for nvrtc. * WIP first pass at compilation win nvrtc. * Added testing if file is on file system into CommandLineDownstreamCompiler. Added sourceContentsPath. * Make test cuda-compile.cu work by just compiling not comparing output. * Genearlize DownstreamCompiler usage. * Fix warning on clang. * Remove CompilerType from DownstreamCompiler. * Use DownstreamCompiler interface for all compilers. NOTE for FXC, DXC and GLSLANG this doesn't mean using 'compile' - it's still extracting functions from shared library. * Fix compiling on gcc/clang for DownstreamCompiler. * Fix problem on non-vc builds with not having return on locateCompilers for VS. * Change so no warning for code not reachable on locateCompilers for vs.
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp76
1 files changed, 15 insertions, 61 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index cba25d7df..16d9a5546 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -427,6 +427,7 @@ namespace Slang
{ "glsl", SourceLanguage::GLSL },
{ "c", SourceLanguage::C },
{ "cxx", SourceLanguage::CPP },
+ { "cuda", SourceLanguage::CUDA },
};
SourceLanguage findSourceLanguageByName(String const& name)
@@ -444,6 +445,7 @@ namespace Slang
SlangResult checkExternalCompilerSupport(Session* session, PassThroughMode passThrough)
{
+ // Check if the type is supported on this compile
switch (passThrough)
{
case PassThroughMode::None:
@@ -451,54 +453,20 @@ namespace Slang
// If no pass through -> that will always work!
return SLANG_OK;
}
- case PassThroughMode::Dxc:
- {
-#if SLANG_ENABLE_DXIL_SUPPORT
- // Must have dxc
- return session->getOrLoadSharedLibrary(SharedLibraryType::Dxc, nullptr) ? SLANG_OK : SLANG_E_NOT_FOUND;
+#if !SLANG_ENABLE_DXIL_SUPPORT
+ case PassThroughMode::Dxc: return SLANG_E_NOT_IMPLEMENTED;
#endif
- break;
- }
- case PassThroughMode::Fxc:
- {
-#if SLANG_ENABLE_DXBC_SUPPORT
- // Must have fxc
- return session->getOrLoadSharedLibrary(SharedLibraryType::Fxc, nullptr) ? SLANG_OK : SLANG_E_NOT_FOUND;
+#if !SLANG_ENABLE_DXBC_SUPPORT
+ case PassThroughMode::Fxc: return SLANG_E_NOT_IMPLEMENTED;
#endif
- break;
- }
- case PassThroughMode::Glslang:
- {
-#if SLANG_ENABLE_GLSLANG_SUPPORT
- return session->getOrLoadSharedLibrary(Slang::SharedLibraryType::Glslang, nullptr) ? SLANG_OK : SLANG_E_NOT_FOUND;
+#if !SLANG_ENABLE_GLSLANG_SUPPORT
+ case PassThroughMode::Glslang: return SLANG_E_NOT_IMPLEMENTED;
#endif
- break;
- }
- case PassThroughMode::Clang:
- {
- return session->requireDownstreamCompilerSet()->hasCompiler(DownstreamCompiler::CompilerType::Clang) ? SLANG_OK: SLANG_E_NOT_FOUND;
- }
- case PassThroughMode::VisualStudio:
- {
- return session->requireDownstreamCompilerSet()->hasCompiler(DownstreamCompiler::CompilerType::VisualStudio) ? SLANG_OK: SLANG_E_NOT_FOUND;
- }
- case PassThroughMode::Gcc:
- {
- return session->requireDownstreamCompilerSet()->hasCompiler(DownstreamCompiler::CompilerType::GCC) ? SLANG_OK: SLANG_E_NOT_FOUND;
- }
- case PassThroughMode::GenericCCpp:
- {
- List<DownstreamCompiler::Desc> descs;
- session->requireDownstreamCompilerSet()->getCompilerDescs(descs);
- return descs.getCount() ? SLANG_OK: SLANG_E_NOT_FOUND;
- }
- case PassThroughMode::NVRTC:
- {
- return session->requireDownstreamCompilerSet()->hasCompiler(DownstreamCompiler::CompilerType::NVRTC) ? SLANG_OK: SLANG_E_NOT_FOUND;
- }
+ default: break;
}
- return SLANG_E_NOT_IMPLEMENTED;
+
+ return session->getOrLoadDownstreamCompiler(passThrough, nullptr) ? SLANG_OK: SLANG_E_NOT_FOUND;
}
PassThroughMode getDownstreamCompilerRequiredForTarget(CodeGenTarget target)
@@ -561,20 +529,6 @@ namespace Slang
return PassThroughMode::None;
}
- PassThroughMode getPassThroughModeForDownstreamCompiler(DownstreamCompiler::CompilerType type)
- {
- typedef DownstreamCompiler::CompilerType CompilerType;
-
- switch (type)
- {
- case CompilerType::VisualStudio: return PassThroughMode::VisualStudio;
- case CompilerType::GCC: return PassThroughMode::Gcc;
- case CompilerType::Clang: return PassThroughMode::Clang;
- case CompilerType::NVRTC: return PassThroughMode::NVRTC;
- default: return PassThroughMode::None;
- }
- }
-
SlangResult checkCompileTargetSupport(Session* session, CodeGenTarget target)
{
const PassThroughMode mode = getDownstreamCompilerRequiredForTarget(target);
@@ -1290,7 +1244,7 @@ SlangResult dissassembleDXILUsingDXC(
return SLANG_OK;
}
- SlangResult emitDownstreamForEntryPoint(
+ SlangResult emitWithDownstreamForEntryPoint(
BackEndCompileRequest* slangRequest,
Int entryPointIndex,
TargetRequest* targetReq,
@@ -1330,8 +1284,8 @@ SlangResult dissassembleDXILUsingDXC(
}
}
- // Get the required downstream CPP compiler
- DownstreamCompiler* compiler = session->getDownstreamCompiler(downstreamCompiler);
+ // Get the required downstream compiler
+ DownstreamCompiler* compiler = session->getOrLoadDownstreamCompiler(downstreamCompiler, sink);
if (!compiler)
{
@@ -1714,7 +1668,7 @@ SlangResult dissassembleDXILUsingDXC(
{
RefPtr<DownstreamCompileResult> downstreamResult;
- if (SLANG_SUCCEEDED(emitDownstreamForEntryPoint(
+ if (SLANG_SUCCEEDED(emitWithDownstreamForEntryPoint(
compileRequest,
entryPointIndex,
targetReq,