summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-artifact-info.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-03 17:10:46 -0400
committerGitHub <noreply@github.com>2022-08-03 17:10:46 -0400
commite43ef82e288afe486f45ef2736d378e88f40cc90 (patch)
tree356841a992263d6a5d03e9d6704868c2cc12190c /source/compiler-core/slang-artifact-info.h
parente81a5fe56f3177fc3c7040e2320ae083e3746eb7 (diff)
Improvements around Artifact (#2346)
* #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.
Diffstat (limited to 'source/compiler-core/slang-artifact-info.h')
-rw-r--r--source/compiler-core/slang-artifact-info.h76
1 files changed, 12 insertions, 64 deletions
diff --git a/source/compiler-core/slang-artifact-info.h b/source/compiler-core/slang-artifact-info.h
index e63349937..393771a6f 100644
--- a/source/compiler-core/slang-artifact-info.h
+++ b/source/compiler-core/slang-artifact-info.h
@@ -7,53 +7,6 @@
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;
@@ -62,27 +15,22 @@ struct ArtifactInfoUtil
/// 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 target
- static bool isPayloadCpuTarget(Payload payload);
-
/// True if is a CPU target - either
- static bool isCpuTarget(const ArtifactDesc& desc) { return isPayloadCpuTarget(desc.payload); }
-
+ static bool isCpuLikeTarget(const ArtifactDesc& desc);
+
/// 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); }
+ static bool isCpuBinary(const ArtifactDesc& desc);
+ /// True if is a GPU usable (can be passed to a driver/API and be used
+ static bool isGpuUsable(const ArtifactDesc& desc);
+
+ /// True if the desc holds textual information
+ static bool isText(const ArtifactDesc& desc);
- /// True if artifact appears to be binary linkable
- static bool isBinaryLinkable(const ArtifactDesc& desc);
+ /// Given an assembly type returns it's extension from the payload type
+ static UnownedStringSlice getAssemblyExtensionForPayload(ArtifactPayload payload);
- /// Get the default extension type for a payload type
- static UnownedStringSlice getDefaultExtensionForPayload(Payload payload);
+ /// True if artifact appears to be linkable
+ static bool isLinkable(const ArtifactDesc& desc);
/// Try to determine the desc from just a file extension (passed without .)
static ArtifactDesc getDescFromExtension(const UnownedStringSlice& slice);