From e43ef82e288afe486f45ef2736d378e88f40cc90 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 3 Aug 2022 17:10:46 -0400 Subject: 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. --- source/compiler-core/slang-artifact-info.h | 76 +++++------------------------- 1 file changed, 12 insertions(+), 64 deletions(-) (limited to 'source/compiler-core/slang-artifact-info.h') 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); -- cgit v1.2.3