summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-16 18:19:56 -0400
committerGitHub <noreply@github.com>2022-08-16 18:19:56 -0400
commite68fab2bda5d979f8d991fc41122bb9aa71849a6 (patch)
tree0d07c5d3b957a23065fc61d8a4ad6c2c1726652d /source/slang/slang-compiler.cpp
parenta10a94dcb86e51d74d7c545d99d98110f88e3081 (diff)
IDownstreamCompiler interface (#2361)
* WIP with hierarchical enums. * Some small fixes and improvements around artifact desc related types. * Improvements around hierarchical enum. * Fixes to get Artifact types refactor to be able to execute tests. * Attempt to better categorize PTX. * Work around for potentially unused function warning. * Typo fix. * Simplify Artifact header. * Small improvements around Artifact kind/payload/style. * Added IDestroyable/ICastable * Add IArtifactList. * First impl of IArtifactUtil. * Use the ICastable interface for IArtifactRepresentation. * Added IArtifactRepresentation & IArtifactAssociated. * Add SLANG_OVERRIDE to avoid gcc/clang warning. * Fix calling convention issue on win32. * Fix missing SLANG_OVERRIDE. * First attempt at file abstraction around Artifact. * Added creation of lock file. * Move functionality for determining file paths to the IArtifactUtil. Add casting to ICastable. * Added some casting/finding mechanisms. * Simplify IArtifact interface, and use Items for file reps. * Fix problem with libraries on DXIL. * Split out ArtifactRepresentation. * Move ArtifactDesc functionality to ArtifactDescUtil. ArtifactInfoUtil becomes ArtifactDescUtil. * Split implementations from the interfaces for Artifact. * Use TypeTextUtil for target name outputting. * Add artifact impls. * Add ICastableList * Added UnknownCastableAdapter * Make ISlangSharedLibrary derive from ICastable, and remain backwards compatible with slang-llvm. * Refactor Representation on Artifact. * Make our ISlangBlobs also derive from ICastable. Make ISlangBlob atomic ref counted. * Split out CastableList and related types, and placed in core. * Small fixes around IArtifact. Improve IArtifact docs. First impl of getChildren for IArtifact. * Documentation improvements for Artifact related types. * Fix typo. * Special case adding a ICastableList to a LazyCastableList. * Small simplification of LazyCastableList, by adding State member. * Removed the ILockFile interface because IFileArtifactRepresentation can be used. * Implement DiagnosticsArtifactRepresentation. * Added PostEmitMetadataArtifactRepresentation * Add searching by predicate. Added handling of accessing Artifact as ISharedLibrary * Fix typo. * Add find to IArtifacgtList. Fix some missing SLANG_NO_THROW. * Small improvements around ArtifactDesc types. * Another small change around ArtifactKind. * Some more shuffling of ArtifactDesc. * Make IArtifact castable Remove IArtifactList Made IArtifactContainer derive from IArtifact Made ModuleLibrary atomic ref counted/given IModuleLibrary interface. * Must call _requireChildren before any children access. * Fix missing SLANG_MCALL on castAs. * Fix missing SLANG_OVERRIDE. * Added IArtifactHandler * Use ICastable for basis of scope/lookup. * WIP first attempt to remove CompileResult. * Fix support for for downstream compiler shared library adapter. * Fix issues found when replacing CompileResult. * Fix typo. * Fix getting items form 'significant' member of an Artifact. * Split out ArtifactUtil & ArtifactHandler. * Work around for problem on Visual studio. * Improve searching. * Add missing files. * Split out Artifact associated types. Don't produce a container by default - use associated for 'metadata'. * Remove no longer used ArtifactPayload type. * Generalized converting representations. Small improvements to artifacts. * Fix intermediate dumping issue. * Removed #if 0 out CompileResult. Remove DownstreamCompileResult maybeDumpIntermediate. * Pull out functionality for dumping artifact output into ArtifactOutputUtil Fixed a bug in naming files based on ArtifactDesc. * std::atomic issue. * Pull out types from DownstreamCompile to simplify moving to an interface. * Fix typo. * Use IDownstreamCompiler interface. Split out DownstreamCompilerUtil and DownstreamCompilerSet. * Update projects. * Fix missing SLANG_MCALL. * Fix calling convention of IDownstreamCompiler impls. * Split out binary work arounds into a dep1.cpp/h * Small reorganising around DownstreamCompilerInfo. * Remove Desc library functionality to DownstreamCompilerUtil. * Expand IDiagnostics interface. Rename associated impls with Impl suffix. * Fix outputting as text bug. Some small improvements. * Add fix around prefix for dumping. Improved how handling for extensions work form ArtifactDesc. * Dump assembly if available. * Simplify some of Dep1 definitions.
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 02d312b61..d175277c8 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -828,7 +828,7 @@ namespace Slang
/// and generally there will not be a match with emitted source.
///
/// This test is only used for pass through mode.
- static bool _useEmittedSource(DownstreamCompiler* compiler, TranslationUnitRequest* translationUnit)
+ static bool _useEmittedSource(IDownstreamCompiler* compiler, TranslationUnitRequest* translationUnit)
{
// We only bother if it's a file based compiler.
if (compiler->isFileBased())
@@ -952,7 +952,7 @@ namespace Slang
SLANG_ASSERT(compilerType != PassThroughMode::None);
// Get the required downstream compiler
- DownstreamCompiler* compiler = session->getOrLoadDownstreamCompiler(compilerType, sink);
+ IDownstreamCompiler* compiler = session->getOrLoadDownstreamCompiler(compilerType, sink);
if (!compiler)
{
auto compilerName = TypeTextUtil::getPassThroughAsHumanText((SlangPassThrough)compilerType);
@@ -963,7 +963,7 @@ namespace Slang
Dictionary<String, String> preprocessorDefinitions;
List<String> includePaths;
- typedef DownstreamCompiler::CompileOptions CompileOptions;
+ typedef DownstreamCompileOptions CompileOptions;
CompileOptions options;
// Set compiler specific args
@@ -1115,8 +1115,8 @@ namespace Slang
if (cudaTracker->m_smVersion.isSet())
{
- DownstreamCompiler::CapabilityVersion version;
- version.kind = DownstreamCompiler::CapabilityVersion::Kind::CUDASM;
+ DownstreamCompileOptions::CapabilityVersion version;
+ version.kind = DownstreamCompileOptions::CapabilityVersion::Kind::CUDASM;
version.version = cudaTracker->m_smVersion;
options.requiredCapabilityVersions.add(version);
@@ -1129,8 +1129,8 @@ namespace Slang
}
else if (GLSLExtensionTracker* glslTracker = as<GLSLExtensionTracker>(extensionTracker))
{
- DownstreamCompiler::CapabilityVersion version;
- version.kind = DownstreamCompiler::CapabilityVersion::Kind::SPIRV;
+ DownstreamCompileOptions::CapabilityVersion version;
+ version.kind = DownstreamCompileOptions::CapabilityVersion::Kind::SPIRV;
version.version = glslTracker->getSPIRVVersion();
options.requiredCapabilityVersions.add(version);
@@ -1260,28 +1260,28 @@ namespace Slang
switch (linkage->optimizationLevel)
{
- case OptimizationLevel::None: options.optimizationLevel = DownstreamCompiler::OptimizationLevel::None; break;
- case OptimizationLevel::Default: options.optimizationLevel = DownstreamCompiler::OptimizationLevel::Default; break;
- case OptimizationLevel::High: options.optimizationLevel = DownstreamCompiler::OptimizationLevel::High; break;
- case OptimizationLevel::Maximal: options.optimizationLevel = DownstreamCompiler::OptimizationLevel::Maximal; break;
+ case OptimizationLevel::None: options.optimizationLevel = DownstreamCompileOptions::OptimizationLevel::None; break;
+ case OptimizationLevel::Default: options.optimizationLevel = DownstreamCompileOptions::OptimizationLevel::Default; break;
+ case OptimizationLevel::High: options.optimizationLevel = DownstreamCompileOptions::OptimizationLevel::High; break;
+ case OptimizationLevel::Maximal: options.optimizationLevel = DownstreamCompileOptions::OptimizationLevel::Maximal; break;
default: SLANG_ASSERT(!"Unhandled optimization level"); break;
}
switch (linkage->debugInfoLevel)
{
- case DebugInfoLevel::None: options.debugInfoType = DownstreamCompiler::DebugInfoType::None; break;
- case DebugInfoLevel::Minimal: options.debugInfoType = DownstreamCompiler::DebugInfoType::Minimal; break;
+ case DebugInfoLevel::None: options.debugInfoType = DownstreamCompileOptions::DebugInfoType::None; break;
+ case DebugInfoLevel::Minimal: options.debugInfoType = DownstreamCompileOptions::DebugInfoType::Minimal; break;
- case DebugInfoLevel::Standard: options.debugInfoType = DownstreamCompiler::DebugInfoType::Standard; break;
- case DebugInfoLevel::Maximal: options.debugInfoType = DownstreamCompiler::DebugInfoType::Maximal; break;
+ case DebugInfoLevel::Standard: options.debugInfoType = DownstreamCompileOptions::DebugInfoType::Standard; break;
+ case DebugInfoLevel::Maximal: options.debugInfoType = DownstreamCompileOptions::DebugInfoType::Maximal; break;
default: SLANG_ASSERT(!"Unhandled debug level"); break;
}
switch( getTargetReq()->getFloatingPointMode())
{
- case FloatingPointMode::Default: options.floatingPointMode = DownstreamCompiler::FloatingPointMode::Default; break;
- case FloatingPointMode::Precise: options.floatingPointMode = DownstreamCompiler::FloatingPointMode::Precise; break;
- case FloatingPointMode::Fast: options.floatingPointMode = DownstreamCompiler::FloatingPointMode::Fast; break;
+ case FloatingPointMode::Default: options.floatingPointMode = DownstreamCompileOptions::FloatingPointMode::Default; break;
+ case FloatingPointMode::Precise: options.floatingPointMode = DownstreamCompileOptions::FloatingPointMode::Precise; break;
+ case FloatingPointMode::Fast: options.floatingPointMode = DownstreamCompileOptions::FloatingPointMode::Fast; break;
default: SLANG_ASSERT(!"Unhandled floating point mode");
}
@@ -1311,7 +1311,7 @@ namespace Slang
break;
case Stage::Compute:
- options.pipelineType = DownstreamCompiler::PipelineType::Compute;
+ options.pipelineType = DownstreamCompileOptions::PipelineType::Compute;
break;
case Stage::Vertex:
@@ -1319,7 +1319,7 @@ namespace Slang
case Stage::Domain:
case Stage::Geometry:
case Stage::Fragment:
- options.pipelineType = DownstreamCompiler::PipelineType::Rasterization;
+ options.pipelineType = DownstreamCompileOptions::PipelineType::Rasterization;
break;
case Stage::RayGeneration:
@@ -1328,7 +1328,7 @@ namespace Slang
case Stage::ClosestHit:
case Stage::Miss:
case Stage::Callable:
- options.pipelineType = DownstreamCompiler::PipelineType::RayTracing;
+ options.pipelineType = DownstreamCompileOptions::PipelineType::RayTracing;
break;
}
}
@@ -1341,7 +1341,7 @@ namespace Slang
{
for(auto& def : preprocessorDefinitions)
{
- DownstreamCompiler::Define define;
+ DownstreamCompileOptions::Define define;
define.nameWithSig = def.Key;
define.value = def.Value;
@@ -1366,7 +1366,7 @@ namespace Slang
if (diagnostics.diagnostics.getCount())
{
StringBuilder compilerText;
- compiler->getDesc().appendAsText(compilerText);
+ DownstreamCompilerUtil::appendAsText(compiler->getDesc(), compilerText);
StringBuilder builder;