summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-09 11:23:40 -0400
committerGitHub <noreply@github.com>2022-08-09 11:23:40 -0400
commit9df7fcb023bd5a22f35ecd609b7a50cc6634976c (patch)
tree69692c36e664eafa2a37b5fa13ca7142f62b1844 /source/slang/slang-compiler.cpp
parentc0733be56dc24ef0eb67b26fe0c49d3419e75773 (diff)
Artifact split interface and implementation (#2349)
* #include an absolute path didn't work - because paths were taken to always be relative. * 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.
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp48
1 files changed, 18 insertions, 30 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 8205bcf36..361f92525 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -13,7 +13,11 @@
#include "slang-compiler.h"
#include "../compiler-core/slang-lexer.h"
-#include "../compiler-core/slang-artifact.h"
+
+// Artifact
+#include "../compiler-core/slang-artifact-desc-util.h"
+#include "../compiler-core/slang-artifact-representation-impl.h"
+#include "../compiler-core/slang-artifact-impl.h"
#include "slang-lower-to-ir.h"
#include "slang-mangle.h"
@@ -28,7 +32,6 @@
#include "slang-serialize-container.h"
//
-
// Includes to allow us to control console
// output when writing assembly dumps.
#include <fcntl.h>
@@ -53,32 +56,18 @@
namespace Slang
{
- // !!!!!!!!!!!!!!!!!!!!!! free functions for DiagnosicSink !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// !!!!!!!!!!!!!!!!!!!!!! free functions for DiagnosicSink !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-bool isHeterogeneousTarget(CodeGenTarget target)
-{
- return ArtifactDesc::makeFromCompileTarget(asExternal(target)).style == ArtifactStyle::Host;
-}
-
-void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
+ bool isHeterogeneousTarget(CodeGenTarget target)
{
- switch (val)
- {
- default:
- sb << "<unknown>";
- break;
+ return ArtifactDescUtil::makeDescFromCompileTarget(asExternal(target)).style == ArtifactStyle::Host;
+ }
- #define CASE(TAG, STR) case CodeGenTarget::TAG: sb << STR; break
- CASE(GLSL, "glsl");
- CASE(HLSL, "hlsl");
- CASE(SPIRV, "spirv");
- CASE(SPIRVAssembly, "spriv-assembly");
- CASE(DXBytecode, "dxbc");
- CASE(DXBytecodeAssembly, "dxbc-assembly");
- CASE(DXIL, "dxil");
- CASE(DXILAssembly, "dxil-assembly");
- #undef CASE
- }
+ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
+ {
+ UnownedStringSlice name = TypeTextUtil::getCompileTargetName(asExternal(val));
+ name = name.getLength() ? name : toSlice("<unknown>");
+ sb << name;
}
void printDiagnosticArg(StringBuilder& sb, PassThroughMode val)
@@ -86,7 +75,6 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
sb << TypeTextUtil::getPassThroughName(SlangPassThrough(val));
}
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!! CompileResult !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SlangResult CompileResult::getSharedLibrary(ComPtr<ISlangSharedLibrary>& outSharedLibrary)
@@ -997,7 +985,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
static bool _isCPUHostTarget(CodeGenTarget target)
{
- auto desc = ArtifactDesc::makeFromCompileTarget(asExternal(target));
+ auto desc = ArtifactDescUtil::makeDescFromCompileTarget(asExternal(target));
return desc.style == ArtifactStyle::Host;
}
@@ -1303,7 +1291,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
// If we aren't using LLVM 'host callable', we want downstream compile to produce a shared library
if (compilerType != PassThroughMode::LLVM &&
- ArtifactDesc::makeFromCompileTarget(asExternal(target)).kind == ArtifactKind::HostCallable)
+ ArtifactDescUtil::makeDescFromCompileTarget(asExternal(target)).kind == ArtifactKind::HostCallable)
{
target = CodeGenTarget::ShaderSharedLibrary;
}
@@ -1804,7 +1792,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
ComPtr<ISlangBlob> blob;
if (SLANG_FAILED(result.getBlob(blob)))
{
- if (ArtifactDesc::makeFromCompileTarget(asExternal(targetReq->getTarget())).kind == ArtifactKind::HostCallable)
+ if (ArtifactDescUtil::makeDescFromCompileTarget(asExternal(targetReq->getTarget())).kind == ArtifactKind::HostCallable)
{
// Some HostCallable are not directly representable as a 'binary'.
// So here, we just ignore if that appears the case, and don't output an unexpected error.
@@ -2448,7 +2436,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
return;
auto target = getTargetFormat();
- const auto desc = ArtifactDesc::makeFromCompileTarget(asExternal(target));
+ const auto desc = ArtifactDescUtil::makeDescFromCompileTarget(asExternal(target));
if (desc.kind == ArtifactKind::Text)
{