13#ifndef MLIR_DIALECT_TOSA_IR_TARGETENV_H
14#define MLIR_DIALECT_TOSA_IR_TARGETENV_H
18#include "llvm/ADT/SmallSet.h"
63 : majorVersion(major), minorVersion(minor), draft(draft) {}
68 if (this->majorVersion != baseVersion.majorVersion)
70 if (this->minorVersion < baseVersion.minorVersion)
81 if (this->draft && !baseVersion.draft &&
82 this->minorVersion == baseVersion.minorVersion)
87 uint32_t
getMajor()
const {
return majorVersion; }
88 uint32_t
getMinor()
const {
return minorVersion; }
92 uint32_t majorVersion = 0;
93 uint32_t minorVersion = 0;
97 fromVersionEnum(SpecificationVersion version) {
99 case SpecificationVersion::V_1_0:
101 case SpecificationVersion::V_1_1_DRAFT:
104 llvm_unreachable(
"Unknown TOSA version");
121 static FailureOr<TargetEnv>
131 return specificationVersion;
135 if (level == Level::eightK)
137 else if (level == Level::none)
140 llvm_unreachable(
"Unknown TOSA level");
144 bool allows(Profile prof)
const {
return enabledProfiles.count(prof) != 0; }
147 return llvm::any_of(profs, [&](Profile prof) {
return allows(prof); });
151 return llvm::all_of(profs, [&](Profile prof) {
return allows(prof); });
155 bool allows(Extension ext)
const {
return enabledExtensions.count(ext) != 0; }
158 return llvm::any_of(exts, [&](Extension ext) {
return allows(ext); });
162 return llvm::all_of(exts, [&](Extension ext) {
return allows(ext); });
168 explicit TargetEnv(SpecificationVersion specificationVersion, Level level,
171 : specificationVersion(specificationVersion), level(level) {
172 enabledProfiles.insert_range(profiles);
173 enabledExtensions.insert_range(extensions);
176 TosaSpecificationVersion specificationVersion;
178 llvm::SmallSet<Profile, 3> enabledProfiles;
179 llvm::SmallSet<Extension, 13> enabledExtensions;
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
TosaLevel getLevel() const
void addExtension(Extension e)
static FailureOr< TargetEnv > createTargetEnvFromAttr(TargetEnvAttr targetAttr, Location targetEnvAttrLoc)
bool allowsAllOf(ArrayRef< Extension > exts) const
void addProfile(Profile p)
bool allowsAllOf(ArrayRef< Profile > profs) const
bool allows(Profile prof) const
static LogicalResult verifyTargetInformation(TargetEnvAttr targetAttr, Location targetAttrLoc)
bool allows(Extension ext) const
bool allowsAnyOf(ArrayRef< Profile > profs) const
TosaSpecificationVersion getSpecVersion() const
bool allowsAnyOf(ArrayRef< Extension > exts) const
A thin wrapper around the SpecificationVersion enum to represent and provide utilities around the TOS...
bool isBackwardsCompatibleWith(TosaSpecificationVersion baseVersion) const
TosaSpecificationVersion()=default
TosaSpecificationVersion(uint32_t major, uint32_t minor, bool draft=false)
TosaSpecificationVersion(SpecificationVersion version)
uint32_t getMinor() const
uint32_t getMajor() const
llvm::SmallString< 4 > stringifyVersion(TosaSpecificationVersion version)
static constexpr TosaLevel TOSA_LEVEL_EIGHTK
static constexpr TosaLevel TOSA_LEVEL_NONE
TargetEnvAttr getDefaultTargetEnv(MLIRContext *context)
TosaSpecificationVersion getMinVersion(const Profile &profile)
TargetEnvAttr lookupTargetEnv(Operation *op)
TargetEnvAttr lookupTargetEnvOrDefault(Operation *op)
Queries the target environment recursively from enclosing symbol table ops containing the given op or...
Include the generated interface declarations.
int32_t MAX_TENSOR_LIST_SIZE
bool operator==(const TosaLevel &rhs)