summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-04-27 13:51:30 -0400
committerGitHub <noreply@github.com>2022-04-27 10:51:30 -0700
commit50d5a1021623a89df035a1ef78557e0f1152648d (patch)
tree46b859c764dbc6d27a679b32c025f23ee0baaa74 /source
parentf9432467cac85eae6f7120cd94208f3a3dd9aa19 (diff)
Split out Artifact info (#2193)
* #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments. * Fix multiple adding of PublicDecoration. Make public output export for DXIL/lib. Add checking for simpleDecorations such that only added once. * Use 'whole program' to identify library build. * Move slang-artifact into compiler-core. * Split out Keep free functions. * Artifact::Keep -> ArtifactKeep. * Handle libraries as artifacts. * Add -target dxil so test infrastructure knows it needs DXC. * Linking working in DXC. * Improve handling around emit for 'export'. * Add comment around Artifact name. * Render test working with linking. * Improvements around Artifact handling. * Add ArtifactPayloadInfo. * Small tidy up around artifact. * Split out code to get info about Artifacts into artifact-info.cpp/.h * Re-add slang-artifact.cpp * Readd artifact.cpp.
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-artifact-info.cpp248
-rw-r--r--source/compiler-core/slang-artifact-info.h96
-rw-r--r--source/compiler-core/slang-artifact.cpp220
-rw-r--r--source/compiler-core/slang-artifact.h38
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp4
-rw-r--r--source/compiler-core/slang-visual-studio-compiler-util.cpp3
-rw-r--r--source/slang/slang-options.cpp7
7 files changed, 361 insertions, 255 deletions
diff --git a/source/compiler-core/slang-artifact-info.cpp b/source/compiler-core/slang-artifact-info.cpp
new file mode 100644
index 000000000..6aaf1552c
--- /dev/null
+++ b/source/compiler-core/slang-artifact-info.cpp
@@ -0,0 +1,248 @@
+// slang-artifact-info.cpp
+#include "slang-artifact-info.h"
+
+#include "../core/slang-type-text-util.h"
+#include "../core/slang-io.h"
+
+namespace Slang {
+
+static ArtifactPayloadInfo::Lookup _makePayloadInfoLookup()
+{
+ ArtifactPayloadInfo::Lookup values;
+ memset(&values, 0, sizeof(values));
+
+
+ typedef ArtifactPayload Payload;
+ typedef ArtifactPayloadInfo::Flag Flag;
+ typedef ArtifactPayloadInfo::Flags Flags;
+ typedef ArtifactPayloadInfo::Flavor Flavor;
+
+ struct Info
+ {
+ Payload payload;
+ Flavor flavor;
+ Flags flags;
+ };
+
+ const Info infos[] =
+ {
+ {Payload::None, Flavor::None, 0},
+ {Payload::Unknown, Flavor::Unknown, 0},
+
+ // It seems as if DXBC is potentially linkable from
+ // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-keywords#export
+
+ // We can't *actually* link PTX or SPIR-V currently but it is in principal possible
+ // so let's say we accept for now
+
+ {Payload::DXIL, Flavor::Binary, Flag::IsGpuNative | Flag::IsLinkable},
+ {Payload::DXBC, Flavor::Binary, Flag::IsGpuNative | Flag::IsLinkable},
+ {Payload::SPIRV, Flavor::Binary, Flag::IsGpuNative | Flag::IsLinkable },
+ {Payload::PTX, Flavor::Binary, Flag::IsGpuNative | Flag::IsLinkable },
+
+ {Payload::DXILAssembly, Flavor::Assembly, 0},
+ {Payload::DXBCAssembly, Flavor::Assembly, 0},
+ {Payload::SPIRVAssembly, Flavor::Assembly, 0},
+ {Payload::PTXAssembly, Flavor::Assembly, 0},
+
+ {Payload::HostCPU, Flavor::Binary, Flag::IsCpuNative | Flag::IsLinkable},
+
+ // Do we want some other Flavor for these?
+ {Payload::SlangIR, Flavor::Binary, Flag::IsLinkable},
+ {Payload::LLVMIR, Flavor::Binary, 0},
+ {Payload::SlangAST, Flavor::Binary, 0},
+
+ {Payload::X86, Flavor::Binary, Flag::IsCpuNative | Flag::IsLinkable},
+ {Payload::X86_64, Flavor::Binary, Flag::IsCpuNative | Flag::IsLinkable},
+ {Payload::AARCH, Flavor::Binary, Flag::IsCpuNative | Flag::IsLinkable},
+ {Payload::AARCH64, Flavor::Binary, Flag::IsCpuNative | Flag::IsLinkable},
+
+ {Payload::HLSL, Flavor::Source, 0},
+ {Payload::GLSL, Flavor::Source, 0},
+ {Payload::CPP, Flavor::Source, 0},
+ {Payload::C, Flavor::Source, 0},
+ {Payload::CUDA, Flavor::Source, 0},
+ {Payload::Slang, Flavor::Source, 0},
+
+ {Payload::DebugInfo, Flavor::Unknown, 0},
+
+ {Payload::Zip, Flavor::Container, 0},
+ };
+
+ for (auto info : infos)
+ {
+ auto& v = values.values[Index(info.payload)];
+ v.flavor = info.flavor;
+ v.flags = info.flags;
+ }
+
+ return values;
+}
+
+/* static */const ArtifactPayloadInfo::Lookup ArtifactPayloadInfo::Lookup::g_values = _makePayloadInfoLookup();
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!! ArtifactInfoUtil !!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+
+namespace { // anonymous
+struct KindExtension
+{
+ ArtifactKind kind;
+ UnownedStringSlice ext;
+};
+} // anonymous
+
+#define SLANG_KIND_EXTENSION(kind, ext) \
+ { ArtifactKind::kind, UnownedStringSlice::fromLiteral(ext) },
+
+static const KindExtension g_cpuKindExts[] =
+{
+#if SLANG_WINDOWS_FAMILY
+ SLANG_KIND_EXTENSION(Library, "lib")
+ SLANG_KIND_EXTENSION(ObjectCode, "obj")
+ SLANG_KIND_EXTENSION(Executable, "exe")
+ SLANG_KIND_EXTENSION(SharedLibrary, "dll")
+#else
+ SLANG_KIND_EXTENSION(Library, "a")
+ SLANG_KIND_EXTENSION(ObjectCode, "o")
+ SLANG_KIND_EXTENSION(Executable, "")
+
+#if __CYGWIN__
+ SLANG_KIND_EXTENSION(SharedLibrary, "dll")
+#elif SLANG_APPLE_FAMILY
+ SLANG_KIND_EXTENSION(SharedLibrary, "dylib")
+#else
+ SLANG_KIND_EXTENSION(SharedLibrary, "so")
+#endif
+
+#endif
+};
+
+/* static */bool ArtifactInfoUtil::isKindBinaryLinkable(Kind kind)
+{
+ switch (kind)
+ {
+ case Kind::Library:
+ case Kind::ObjectCode:
+ {
+ return true;
+ }
+ default: break;
+ }
+ return false;
+}
+
+/* static */bool ArtifactInfoUtil::isBinaryLinkable(const ArtifactDesc& desc)
+{
+ return isKindBinaryLinkable(desc.kind) &&
+ getInfo(desc.payload).isSet(ArtifactPayloadInfo::Flag::IsLinkable);
+}
+
+/* static */bool ArtifactInfoUtil::isPayloadCpuBinary(Payload payload)
+{
+ auto info = getInfo(payload);
+ return info.isSet(ArtifactPayloadInfo::Flag::IsCpuNative) && info.flavor == ArtifactPayloadInfo::Flavor::Binary;
+}
+
+/* static */bool ArtifactInfoUtil::isPayloadGpuBinary(Payload payload)
+{
+ auto info = getInfo(payload);
+ return info.isSet(ArtifactPayloadInfo::Flag::IsGpuNative) && info.flavor == ArtifactPayloadInfo::Flavor::Binary;
+}
+
+/* static */UnownedStringSlice ArtifactInfoUtil::getDefaultExtensionForPayload(Payload payload)
+{
+ switch (payload)
+ {
+ case Payload::None: return UnownedStringSlice();
+ case Payload::Unknown: return UnownedStringSlice::fromLiteral("unknown");
+
+ case Payload::DXIL: return UnownedStringSlice::fromLiteral("dxil");
+ case Payload::DXBC: return UnownedStringSlice::fromLiteral("dxbc");
+ case Payload::SPIRV: return UnownedStringSlice::fromLiteral("spirv");
+
+ case Payload::PTX: return UnownedStringSlice::fromLiteral("ptx");
+
+ case Payload::X86:
+ case Payload::X86_64:
+ case Payload::AARCH:
+ case Payload::AARCH64:
+ case Payload::HostCPU:
+ {
+ return UnownedStringSlice();
+ }
+
+ case Payload::SlangIR: return UnownedStringSlice::fromLiteral("slang-ir");
+ case Payload::LLVMIR: return UnownedStringSlice::fromLiteral("llvm-ir");
+
+ case Payload::HLSL: return UnownedStringSlice::fromLiteral("hlsl");
+ case Payload::GLSL: return UnownedStringSlice::fromLiteral("glsl");
+
+ case Payload::CPP: return UnownedStringSlice::fromLiteral("cpp");
+ case Payload::C: return UnownedStringSlice::fromLiteral("c");
+
+ case Payload::CUDA: return UnownedStringSlice::fromLiteral("cu");
+
+ case Payload::Slang: return UnownedStringSlice::fromLiteral("slang");
+
+ case Payload::Zip: return UnownedStringSlice::fromLiteral("zip");
+
+ default: break;
+ }
+
+ SLANG_UNEXPECTED("Unknown content type");
+}
+
+/* static */ArtifactDesc ArtifactInfoUtil::getDescFromExtension(const UnownedStringSlice& slice)
+{
+ if (slice == "slang-module" ||
+ slice == "slang-lib")
+ {
+ return ArtifactDesc::make(ArtifactKind::Library, ArtifactPayload::SlangIR);
+ }
+
+ for (const auto& kindExt : g_cpuKindExts)
+ {
+ if (slice == kindExt.ext)
+ {
+ // We'll assume it's for the host CPU for now..
+ return ArtifactDesc::make(kindExt.kind, Payload::HostCPU);
+ }
+ }
+
+ const auto target = TypeTextUtil::findCompileTargetFromExtension(slice);
+
+ return ArtifactDesc::makeFromCompileTarget(target);
+}
+
+/* static */ArtifactDesc ArtifactInfoUtil::getDescFromPath(const UnownedStringSlice& slice)
+{
+ auto extension = Path::getPathExt(slice);
+ return getDescFromExtension(extension);
+}
+
+/* static*/ UnownedStringSlice ArtifactInfoUtil::getCpuExtensionForKind(Kind kind)
+{
+ for (const auto& kindExt : g_cpuKindExts)
+ {
+ if (kind == kindExt.kind)
+ {
+ return kindExt.ext;
+ }
+ }
+ return UnownedStringSlice();
+}
+
+UnownedStringSlice ArtifactInfoUtil::getDefaultExtension(const ArtifactDesc& desc)
+{
+ if (ArtifactInfoUtil::isPayloadCpuBinary(desc.payload))
+ {
+ return getCpuExtensionForKind(desc.kind);
+ }
+ else
+ {
+ return getDefaultExtensionForPayload(desc.payload);
+ }
+}
+
+} // namespace Slang
diff --git a/source/compiler-core/slang-artifact-info.h b/source/compiler-core/slang-artifact-info.h
new file mode 100644
index 000000000..95de38cf6
--- /dev/null
+++ b/source/compiler-core/slang-artifact-info.h
@@ -0,0 +1,96 @@
+// slang-artifact.h
+#ifndef SLANG_ARTIFACT_INFO_H
+#define SLANG_ARTIFACT_INFO_H
+
+#include "slang-artifact.h"
+
+namespace Slang
+{
+
+/* We want to centralize information about artifact descs and related types, such that when new types are added they only need
+to be added/altered in one place */
+struct ArtifactPayloadInfo
+{
+ typedef ArtifactPayloadInfo This;
+ enum class Flavor : uint8_t
+ {
+ Unknown,
+ None,
+ Assembly,
+ Source,
+ Container,
+ Binary,
+ CountOf,
+ };
+
+ typedef uint8_t Flags;
+ struct Flag
+ {
+ enum Enum : Flags
+ {
+ IsCpuNative = 0x01, ///< True if is a CPU native type
+ IsGpuNative = 0x02, ///< True if is a GPU native type
+ IsLinkable = 0x04, ///< True if in principal is linkable
+ };
+ };
+
+ bool isSet(Flag::Enum flag) const { return (flags & Flags(flag)) != 0; }
+ bool isReset(Flag::Enum flag) const { return (flags & Flags(flag)) == 0; }
+
+ struct Lookup;
+
+ Flags flags;
+ Flavor flavor;
+};
+
+struct ArtifactPayloadInfo::Lookup
+{
+ void setFlag(ArtifactPayload payload, Flag::Enum flag) { values[Index(payload)].flags |= Flags(flag); }
+ void setFlags(ArtifactPayload payload, Flags flags) { values[Index(payload)].flags |= flags; }
+
+ This values[Index(ArtifactPayload::CountOf)];
+ static const Lookup g_values;
+};
+
+SLANG_FORCE_INLINE ArtifactPayloadInfo getInfo(ArtifactPayload payload) { return ArtifactPayloadInfo::Lookup::g_values.values[Index(payload)]; }
+
+struct ArtifactInfoUtil
+{
+ typedef ArtifactPayload Payload;
+ typedef ArtifactKind Kind;
+
+ /// Returns true if the kind is binary linkable
+ static bool isKindBinaryLinkable(Kind kind);
+
+ /// Returns true if the payload type is CPU
+ static bool isPayloadCpuBinary(Payload payload);
+ /// Returns true if the payload type is applicable to the GPU
+ static bool isPayloadGpuBinary(Payload payload);
+
+ /// True if is a CPU binary
+ static bool isCpuBinary(const ArtifactDesc& desc) { return isPayloadCpuBinary(desc.payload); }
+ /// True if is a GPU binary
+ static bool isGpuBinary(const ArtifactDesc& desc) { return isPayloadGpuBinary(desc.payload); }
+
+ /// True if artifact appears to be binary linkable
+ static bool isBinaryLinkable(const ArtifactDesc& desc);
+
+ /// Get the default extension type for a payload type
+ static UnownedStringSlice getDefaultExtensionForPayload(Payload payload);
+
+ /// Try to determine the desc from just a file extension (passed without .)
+ static ArtifactDesc getDescFromExtension(const UnownedStringSlice& slice);
+
+ /// Try to determine the desc from a path
+ static ArtifactDesc getDescFromPath(const UnownedStringSlice& slice);
+
+ /// Gets the default file extension for the artifact type. Returns empty slice if not known
+ static UnownedStringSlice getDefaultExtension(const ArtifactDesc& desc);
+
+ /// Get the extension for CPU/Host for a kind
+ static UnownedStringSlice getCpuExtensionForKind(Kind kind);
+};
+
+} // namespace Slang
+
+#endif
diff --git a/source/compiler-core/slang-artifact.cpp b/source/compiler-core/slang-artifact.cpp
index 1f11c31df..862e7bb37 100644
--- a/source/compiler-core/slang-artifact.cpp
+++ b/source/compiler-core/slang-artifact.cpp
@@ -1,73 +1,13 @@
// slang-artifact.cpp
#include "slang-artifact.h"
+#include "slang-artifact-info.h"
+
#include "../core/slang-type-text-util.h"
#include "../core/slang-io.h"
namespace Slang {
-namespace { // anonymous
-struct KindExtension
-{
- ArtifactKind kind;
- UnownedStringSlice ext;
-};
-} // anonymous
-
-#define SLANG_KIND_EXTENSION(kind, ext) \
- { ArtifactKind::kind, UnownedStringSlice::fromLiteral(ext) },
-
-static const KindExtension g_cpuKindExts[] =
-{
-#if SLANG_WINDOWS_FAMILY
- SLANG_KIND_EXTENSION(Library, "lib")
- SLANG_KIND_EXTENSION(ObjectCode, "obj")
- SLANG_KIND_EXTENSION(Executable, "exe")
- SLANG_KIND_EXTENSION(SharedLibrary, "dll")
-#else
- SLANG_KIND_EXTENSION(Library, "a")
- SLANG_KIND_EXTENSION(ObjectCode, "o")
- SLANG_KIND_EXTENSION(Executable, "")
-
-#if __CYGWIN__
- SLANG_KIND_EXTENSION(SharedLibrary, "dll")
-#elif SLANG_APPLE_FAMILY
- SLANG_KIND_EXTENSION(SharedLibrary, "dylib")
-#else
- SLANG_KIND_EXTENSION(SharedLibrary, "so")
-#endif
-
-#endif
-};
-
-/* static */ArtifactDesc ArtifactDesc::fromPath(const UnownedStringSlice& slice)
-{
- auto extension = Path::getPathExt(slice);
- return fromExtension(extension);
-}
-
-/* static */ ArtifactDesc ArtifactDesc::fromExtension(const UnownedStringSlice& slice)
-{
- if (slice == "slang-module" ||
- slice == "slang-lib")
- {
- return make(ArtifactKind::Library, ArtifactPayload::SlangIR, ArtifactStyle::Unknown);
- }
-
- for (const auto& kindExt : g_cpuKindExts)
- {
- if (slice == kindExt.ext)
- {
- // We'll assume it's for the host CPU for now..
- return make(kindExt.kind, Payload::HostCPU, Style::Unknown);
- }
- }
-
- const auto target = TypeTextUtil::findCompileTargetFromExtension(slice);
-
- return makeFromCompileTarget(target);
-}
-
/* static */ArtifactDesc ArtifactDesc::makeFromCompileTarget(SlangCompileTarget target)
{
switch (target)
@@ -104,154 +44,6 @@ static const KindExtension g_cpuKindExts[] =
SLANG_UNEXPECTED("Unhandled type");
}
-/* static */bool ArtifactDesc::isPayloadGpuBinary(Payload payloadType)
-{
- switch (payloadType)
- {
- case Payload::DXIL:
- case Payload::DXBC:
- case Payload::SPIRV:
- case Payload::PTX:
- {
- return true;
- }
- default: break;
- }
- return false;
-}
-
-/* static */bool ArtifactDesc::isPayloadCpuBinary(Payload payloadType)
-{
- switch (payloadType)
- {
- case Payload::X86:
- case Payload::X86_64:
- case Payload::AARCH:
- case Payload::AARCH64:
- case Payload::HostCPU:
- {
- return true;
- }
- default: break;
- }
- return false;
-}
-
-/* static */bool ArtifactDesc::isPayloadGpuBinaryLinkable(Payload payload)
-{
- switch (payload)
- {
- case Payload::DXBC:
- {
- // It seems as if DXBC is potentially linkable from
- // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-keywords#export
- return true;
- }
-
- case Payload::DXIL:
- case Payload::PTX:
- case Payload::SPIRV:
- {
- // We can't *actually* link PTX or SPIR-V currently but it is in principal possible
- // so let's say we accept for now
- return true;
- }
- default: break;
- }
- return false;
-}
-
-bool ArtifactDesc::isBinaryLinkable() const
-{
- if (isKindBinaryLinkable(kind))
- {
- return isPayloadCpuBinary(payload) || isPayloadGpuBinaryLinkable(payload) || payload == ArtifactPayload::SlangIR;
- }
-
- return false;
-}
-
-/* static */bool ArtifactDesc::isKindBinaryLinkable(Kind kind)
-{
- switch (kind)
- {
- case Kind::Library:
- case Kind::ObjectCode:
- {
- return true;
- }
- default: break;
- }
- return false;
-}
-
-/* static*/ UnownedStringSlice ArtifactDesc::getCpuExtensionForKind(Kind kind)
-{
- for (const auto& kindExt : g_cpuKindExts)
- {
- if (kind == kindExt.kind)
- {
- return kindExt.ext;
- }
- }
- return UnownedStringSlice();
-}
-
-UnownedStringSlice ArtifactDesc::getDefaultExtension()
-{
- if (isPayloadCpuBinary(payload))
- {
- return getCpuExtensionForKind(kind);
- }
- else
- {
- return getDefaultExtensionForPayload(payload);
- }
-}
-
-/* static */UnownedStringSlice ArtifactDesc::getDefaultExtensionForPayload(Payload payload)
-{
- switch (payload)
- {
- case Payload::None: return UnownedStringSlice();
- case Payload::Unknown: return UnownedStringSlice::fromLiteral("unknown");
-
- case Payload::DXIL: return UnownedStringSlice::fromLiteral("dxil");
- case Payload::DXBC: return UnownedStringSlice::fromLiteral("dxbc");
- case Payload::SPIRV: return UnownedStringSlice::fromLiteral("spirv");
-
- case Payload::PTX: return UnownedStringSlice::fromLiteral("ptx");
-
- case Payload::X86:
- case Payload::X86_64:
- case Payload::AARCH:
- case Payload::AARCH64:
- case Payload::HostCPU:
- {
- return UnownedStringSlice();
- }
-
- case Payload::SlangIR: return UnownedStringSlice::fromLiteral("slang-ir");
- case Payload::LLVMIR: return UnownedStringSlice::fromLiteral("llvm-ir");
-
- case Payload::HLSL: return UnownedStringSlice::fromLiteral("hlsl");
- case Payload::GLSL: return UnownedStringSlice::fromLiteral("glsl");
-
- case Payload::CPP: return UnownedStringSlice::fromLiteral("cpp");
- case Payload::C: return UnownedStringSlice::fromLiteral("c");
-
- case Payload::CUDA: return UnownedStringSlice::fromLiteral("cu");
-
- case Payload::Slang: return UnownedStringSlice::fromLiteral("slang");
-
- case Payload::Zip: return UnownedStringSlice::fromLiteral("zip");
-
- default: break;
- }
-
- SLANG_UNEXPECTED("Unknown content type");
-}
-
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Artifact !!!!!!!!!!!!!!!!!!!!!!!!!!! */
Artifact::~Artifact()
@@ -372,7 +164,7 @@ ISlangUnknown* Artifact::findInterfaceInstance(const Guid& guid)
if (isSharedLibraryPrefixPlatform)
{
// Strip lib prefix
- if (desc.isCpuBinary() &&
+ if (ArtifactInfoUtil::isCpuBinary(desc) &&
(desc.kind == ArtifactKind::Library ||
desc.kind == ArtifactKind::SharedLibrary))
{
@@ -387,7 +179,7 @@ ISlangUnknown* Artifact::findInterfaceInstance(const Guid& guid)
// Strip any extension
{
- auto descExt = desc.getDefaultExtension();
+ auto descExt = ArtifactInfoUtil::getDefaultExtension(desc);
// Strip the extension if it's a match
if (descExt.getLength() &&
Path::getPathExt(name) == descExt)
@@ -473,7 +265,7 @@ SlangResult Artifact::requireFile(Keep keep)
String path;
SLANG_RETURN_ON_FAIL(File::generateTemporary(nameBase, path));
- if (m_desc.isCpuBinary() &&
+ if (ArtifactInfoUtil::isCpuBinary(m_desc) &&
(m_desc.kind == ArtifactKind::SharedLibrary ||
m_desc.kind == ArtifactKind::Library))
{
@@ -500,7 +292,7 @@ SlangResult Artifact::requireFile(Keep keep)
// If there is an extension append it
- const UnownedStringSlice ext = m_desc.getDefaultExtension();
+ const UnownedStringSlice ext = ArtifactInfoUtil::getDefaultExtension(m_desc);
if (ext.getLength())
{
diff --git a/source/compiler-core/slang-artifact.h b/source/compiler-core/slang-artifact.h
index 651e0ad3b..1395c1b7c 100644
--- a/source/compiler-core/slang-artifact.h
+++ b/source/compiler-core/slang-artifact.h
@@ -99,7 +99,6 @@ enum class ArtifactKeep
All, ///< Keep the final item and any intermediataries
};
-
/**
A value type to describe aspects of the contents of an Artifact.
**/
@@ -119,37 +118,6 @@ public:
/// Get in packed format
inline Packed getPacked() const;
- /// True if the container appears to be binary linkable
- bool isBinaryLinkable() const;
- /// True if is a CPU binary
- bool isCpuBinary() const { return isPayloadCpuBinary(payload); }
- /// True if is a GPU binary
- bool isGpuBinary() const { return isPayloadGpuBinary(payload); }
-
- /// Gets the default file extension for the artifact type. Returns empty slice if not known
- UnownedStringSlice getDefaultExtension();
-
- static UnownedStringSlice getDefaultExtensionForPayload(Payload payload);
-
- /// Get the extension for CPU/Host for a kind
- static UnownedStringSlice getCpuExtensionForKind(Kind kind);
-
- /// Returns true if the kind is binary linkable
- static bool isKindBinaryLinkable(Kind kind);
-
- /// Returns true if the payload type is CPU
- static bool isPayloadCpuBinary(Payload payload);
- /// Returns true if the payload type is applicable to the GPU
- static bool isPayloadGpuBinary(Payload payload);
-
- /// True if the payload type is in principal binary linkable
- static bool isPayloadGpuBinaryLinkable(Payload payload);
-
- /// Try to determine the desc from a path
- static This fromPath(const UnownedStringSlice& slice);
- /// Try to determine the desc from just a file extension (passed without .)
- static This fromExtension(const UnownedStringSlice& slice);
-
bool operator==(const This& rhs) const { return kind == rhs.kind && payload == rhs.payload && style == rhs.style && flags == rhs.flags; }
bool operator!=(const This& rhs) const { return !(*this == rhs); }
@@ -157,10 +125,8 @@ public:
static This makeFromCompileTarget(SlangCompileTarget target);
/// Construct from the elements
- static This make(Kind inKind, Payload inPayload, Style inStyle = Style::Unknown, Flags flags = 0)
- {
- return This{ inKind, inPayload, inStyle, flags };
- }
+ static This make(Kind inKind, Payload inPayload, Style inStyle = Style::Unknown, Flags flags = 0) { return This{ inKind, inPayload, inStyle, flags }; }
+
/// Construct from the packed format
inline static This make(Packed inPacked);
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index 2d1ad2555..554322198 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -10,6 +10,8 @@
#include "../core/slang-char-util.h"
#include "../core/slang-string-slice-pool.h"
+#include "slang-artifact-info.h"
+
namespace Slang
{
@@ -633,7 +635,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
{
const auto desc = artifact->getDesc();
// If it's a library for CPU types, try and use it
- if (desc.isCpuBinary() && desc.kind == ArtifactKind::Library)
+ if (ArtifactInfoUtil::isCpuBinary(desc) && desc.kind == ArtifactKind::Library)
{
// Get the name and path (can be empty) to the library
SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No));
diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp
index 0552657f8..d70f7ca84 100644
--- a/source/compiler-core/slang-visual-studio-compiler-util.cpp
+++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp
@@ -12,6 +12,7 @@
#endif
#include "../core/slang-io.h"
+#include "slang-artifact-info.h"
namespace Slang
{
@@ -263,7 +264,7 @@ namespace Slang
{
auto desc = artifact->getDesc();
- if (desc.isCpuBinary() && desc.kind == ArtifactKind::Library)
+ if (ArtifactInfoUtil::isCpuBinary(desc) && desc.kind == ArtifactKind::Library)
{
// Get the libray name and path
SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No));
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index b02c25549..10980f216 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -20,6 +20,7 @@
#include "../core/slang-hex-dump-util.h"
#include "../compiler-core/slang-command-line-args.h"
+#include "../compiler-core/slang-artifact-info.h"
#include <assert.h>
@@ -1402,7 +1403,7 @@ struct OptionsParser
auto path = referenceModuleName.value;
- auto desc = ArtifactDesc::fromPath(path.getUnownedSlice());
+ auto desc = ArtifactInfoUtil::getDescFromPath(path.getUnownedSlice());
if (desc.kind == ArtifactKind::Unknown)
{
@@ -1411,12 +1412,12 @@ struct OptionsParser
}
// If it's a GPU binary, then we'll assume it's a library
- if (desc.isGpuBinary())
+ if (ArtifactInfoUtil::isGpuBinary(desc))
{
desc.kind = ArtifactKind::Library;
}
- if (!desc.isBinaryLinkable())
+ if (!ArtifactInfoUtil::isBinaryLinkable(desc))
{
sink->diagnose(referenceModuleName.loc, Diagnostics::kindNotLinkable, Path::getPathExt(path));
return SLANG_FAIL;