8#ifndef MLIR_DIALECT_LLVMIR_ROCDLTARGETINFO_H_
9#define MLIR_DIALECT_LLVMIR_ROCDLTARGETINFO_H_
13#include "llvm/TargetParser/AMDGPUTargetParser.h"
14#include "llvm/TargetParser/Triple.h"
27 using Feature = ::llvm::AMDGPU::AMDGPUFeature;
53 static FailureOr<TargetInfo>
54 get(StringRef arch,
unsigned waveSize = 0,
61 static std::optional<::llvm::AMDGPU::TargetID>
parseTargetID(StringRef arch);
64 bool has(
Feature feature)
const {
return featureBits.test(feature); }
69 return has(::llvm::AMDGPU::FEAT_OCP_FP8_CONVERSION_INSTS);
75 return has(::llvm::AMDGPU::FEAT_FP8_CONVERSION_INSTS) && !
hasOcpFp8();
134 return sramEccSetting;
155 ::llvm::Triple::SubArchType
getSubArch()
const {
return subArch; }
168 bool isUnknown()
const {
return kind == ::llvm::AMDGPU::GK_NONE; }
175 ::llvm::Triple::SubArchType subArch = ::llvm::Triple::NoSubArch;
176 ::llvm::AMDGPU::GPUKind kind = ::llvm::AMDGPU::GK_NONE;
177 ::llvm::AMDGPU::AMDGPUFeatureBitset featureBits;
178 ::llvm::AMDGPU::TargetIDSetting xnackSetting =
179 ::llvm::AMDGPU::TargetIDSetting::Unsupported;
180 ::llvm::AMDGPU::TargetIDSetting sramEccSetting =
181 ::llvm::AMDGPU::TargetIDSetting::Unsupported;
182 bool dualWavefrontSize =
false;
This class represents a diagnostic that is inflight and set to be reported.
Operation is the basic unit of execution within MLIR.
bool has(Feature feature) const
Returns whether the target has feature.
std::optional< unsigned > getTotalNumSGPRs() const
Returns the total number of SGPRs, or nullopt for an unknown target.
bool hasFnuzFp8() const
Returns whether the target has fp8 conversions that use the FNUZ formats (E4M3FNUZ/E5M2FNUZ).
std::optional< unsigned > getSGPRAllocGranule() const
Returns the SGPR allocation granularity in registers, or nullopt for an unknown target.
std::optional< unsigned > getAddressableNumSGPRs() const
Returns the number of SGPRs addressable by a kernel, or nullopt for an unknown target.
bool isGeneric() const
Returns whether this is a "gfxN-generic" target, which carries only the features common to every GPU ...
::llvm::Triple::SubArchType getSubArch() const
::llvm::AMDGPU::IsaVersion getIsaVersion() const
Returns the ISA version.
bool isGeneration(unsigned major) const
Returns whether the target belongs to gfx generation major (9 for any gfx9xx, 12 for any gfx12xx,...
StringRef getArchName() const
Returns the canonical GPU name ("gfx942", "gfx9-4-generic"), or "" if the target is unknown.
std::optional< unsigned > getBufferResourceNumRecordsWidth() const
Returns the width in bits of the num_records field of the buffer resource (V#), or nullopt for an unk...
::llvm::AMDGPU::AMDGPUFeature Feature
bool isUnknown() const
Returns whether no GPU was identified, in which case every feature query answers false.
std::optional< unsigned > getLDSBankCount() const
Returns the number of LDS banks per compute unit, or nullopt for an unknown target.
::llvm::AMDGPU::TargetIDSetting getXnackSetting() const
Returns whether xnack is on, off, either, or unsupported on this target.
bool hasOcpFp8() const
Returns whether the target's fp8 conversions exist and use the OCP formats (E4M3FN/E5M2) rather than ...
bool supportsBothWavefrontSizes() const
Returns whether the GPU can be configured for 32-lane or 64-lane wavefronts.
::llvm::AMDGPU::TargetIDSetting getSramEccSetting() const
Returns whether sramecc is on, off, either, or unsupported, as for getXnackSetting().
void migrateArchFeaturesToModuleFlags(Operation *op) const
Records the xnack and sramecc settings this target's ID pinned onto the module op,...
std::optional< unsigned > getWavefrontSize() const
Returns the wavefront size, or nullopt for an unknown target.
static FailureOr< TargetInfo > get(StringRef arch, unsigned waveSize=0, function_ref< InFlightDiagnostic()> emitError=nullptr)
Resolves a target description.
::llvm::AMDGPU::GPUKind getGPUKind() const
std::optional< unsigned > getMaxAddressableLocalMemorySize() const
Returns the maximum LDS in bytes a single workgroup can address, or nullopt for an unknown target.
const ::llvm::AMDGPU::AMDGPUFeatureBitset & getFeatures() const
std::optional< unsigned > getMaxWavesPerEU() const
Returns the maximum number of waves per execution unit, ignoring any limits a particular kernel impos...
TargetInfo()=default
Constructs an unknown target: no subarch, and every feature query answers false.
std::optional< unsigned > getVGPRAllocGranule() const
Returns the VGPR allocation granularity in registers, or nullopt for an unknown target.
static std::optional<::llvm::AMDGPU::TargetID > parseTargetID(StringRef arch)
Parses arch into a target ID, accepting the spellings get() documents, or returns nullopt if it names...
StringRef resolveArchOption(StringRef arch, StringRef deprecatedAlias)
Returns the target architecture that a pass should parse, given its arch option and the value of the ...
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::function_ref< Fn > function_ref