13#ifndef MLIR_DIALECT_TOSA_IR_TARGETENV_H
14#define MLIR_DIALECT_TOSA_IR_TARGETENV_H
18#include "llvm/ADT/SmallSet.h"
60 : majorVersion(major), minorVersion(minor) {}
65 return this->majorVersion == baseVersion.majorVersion &&
66 this->minorVersion >= baseVersion.minorVersion;
69 uint32_t
getMajor()
const {
return majorVersion; }
70 uint32_t
getMinor()
const {
return minorVersion; }
73 uint32_t majorVersion = 0;
74 uint32_t minorVersion = 0;
77 fromVersionEnum(SpecificationVersion version) {
79 case SpecificationVersion::V_1_0:
81 case SpecificationVersion::V_1_1_DRAFT:
84 llvm_unreachable(
"Unknown TOSA version");
101 static FailureOr<TargetEnv>
111 return specificationVersion;
115 if (level == Level::eightK)
117 else if (level == Level::none)
120 llvm_unreachable(
"Unknown TOSA level");
124 bool allows(Profile prof)
const {
return enabledProfiles.count(prof) != 0; }
127 return llvm::any_of(profs, [&](Profile prof) {
return allows(prof); });
131 return llvm::all_of(profs, [&](Profile prof) {
return allows(prof); });
135 bool allows(Extension ext)
const {
return enabledExtensions.count(ext) != 0; }
138 return llvm::any_of(exts, [&](Extension ext) {
return allows(ext); });
142 return llvm::all_of(exts, [&](Extension ext) {
return allows(ext); });
148 explicit TargetEnv(SpecificationVersion specificationVersion, Level level,
151 : specificationVersion(specificationVersion), level(level) {
152 enabledProfiles.insert_range(profiles);
153 enabledExtensions.insert_range(extensions);
156 TosaSpecificationVersion specificationVersion;
158 llvm::SmallSet<Profile, 3> enabledProfiles;
159 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(SpecificationVersion version)
uint32_t getMinor() const
uint32_t getMajor() const
TosaSpecificationVersion(uint32_t major, uint32_t minor)
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)