diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp index d68f150edc..5cf95878aa 100644 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp +++ b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp @@ -5,7 +5,6 @@ #include "api/v0_8/aclValidation.h" #include "libUtils.h" #include "bif/bifbase.hpp" -#include "utils/target_mappings.h" #include "utils/versions.hpp" #include "utils/options.hpp" #include @@ -461,37 +460,6 @@ const char *getDeviceName(const aclTargetInfo &target) return NULL; } -/*! Function that returns the TargetMapping for - *the specific target device. - */ -static const TargetMapping& getTargetMapping(const aclTargetInfo &target) -{ - switch(target.arch_id) { - default: - assert(!"Passed a device id that is invalid!"); - break; - case aclX64: - return X64TargetMapping[target.chip_id]; - break; - case aclX86: - return X86TargetMapping[target.chip_id]; - break; - case aclHSAIL: - return HSAILTargetMapping[target.chip_id]; - break; - case aclHSAIL64: - return HSAIL64TargetMapping[target.chip_id]; - break; - case aclAMDIL: - return AMDILTargetMapping[target.chip_id]; - break; - case aclAMDIL64: - return AMDIL64TargetMapping[target.chip_id]; - break; - }; - return UnknownTarget; -} - /*! Function that returns the library type from the TargetMapping table for *the specific target device id. */ diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h index 3d288359ea..4c44d5bb5b 100644 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.h +++ b/rocclr/compiler/lib/utils/v0_8/libUtils.h @@ -11,6 +11,7 @@ #include #include #include "library.hpp" +#include "utils/target_mappings.h" #include "utils/bif_section_labels.hpp" #include "utils/options.hpp" using namespace bif; @@ -263,6 +264,34 @@ aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32 } #endif +// Returns the TargetMapping for the specific target device. +inline const TargetMapping& getTargetMapping(const aclTargetInfo &target) +{ + switch (target.arch_id) { + default: + break; + case aclX64: + return X64TargetMapping[target.chip_id]; + break; + case aclX86: + return X86TargetMapping[target.chip_id]; + break; + case aclHSAIL: + return HSAILTargetMapping[target.chip_id]; + break; + case aclHSAIL64: + return HSAIL64TargetMapping[target.chip_id]; + break; + case aclAMDIL: + return AMDILTargetMapping[target.chip_id]; + break; + case aclAMDIL64: + return AMDIL64TargetMapping[target.chip_id]; + break; + }; + return UnknownTarget; +} + inline bool is64BitTarget(const aclTargetInfo& target) { return (target.arch_id == aclX64 || @@ -293,6 +322,23 @@ inline bool isHSAILTarget(const aclTargetInfo& target) const std::string& getLegacyLibName(); +inline bool isValidTarget(const aclTargetInfo& target) +{ + return (target.arch_id && target.chip_id); +} + +inline bool isChipSupported(const aclTargetInfo& target) +{ + if (!isValidTarget(target)) { + return false; + } + const TargetMapping& Mapping = getTargetMapping(target); + if (Mapping.family_enum == FAMILY_UNKNOWN) { + return false; + } + return Mapping.supported; +} + enum scId { SC_AMDIL = 0, SC_HSAIL = 0, diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings.h b/rocclr/compiler/lib/utils/v0_8/target_mappings.h index 3cb3ade577..e6a30d977c 100644 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings.h +++ b/rocclr/compiler/lib/utils/v0_8/target_mappings.h @@ -34,9 +34,9 @@ typedef struct _target_mappings_rec { } TargetMapping; const TargetMapping UnknownTarget = { "UnknownFamily", "UnknownChip", "UnknownCodeGen", - amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN}; + amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false}; const TargetMapping InvalidTarget = { NULL, NULL, NULL, - amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN}; + amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false}; typedef struct _family_map_rec { const TargetMapping* target;