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) {}
68 return this->majorVersion == baseVersion.majorVersion &&
69 this->minorVersion >= baseVersion.minorVersion;
72 uint32_t
getMajor()
const {
return majorVersion; }
73 uint32_t
getMinor()
const {
return minorVersion; }
76 uint32_t majorVersion = 0;
77 uint32_t minorVersion = 0;
80 fromVersionEnum(SpecificationVersion version) {
82 case SpecificationVersion::V_1_0:
84 case SpecificationVersion::V_1_1_DRAFT:
87 llvm_unreachable(
"Unknown TOSA version");
104 static FailureOr<TargetEnv>
114 return specificationVersion;
118 if (level == Level::eightK)
120 else if (level == Level::none)
123 llvm_unreachable(
"Unknown TOSA level");
127 bool allows(Profile prof)
const {
return enabledProfiles.count(prof) != 0; }
130 return llvm::any_of(profs, [&](Profile prof) {
return allows(prof); });
134 return llvm::all_of(profs, [&](Profile prof) {
return allows(prof); });
138 bool allows(Extension ext)
const {
return enabledExtensions.count(ext) != 0; }
141 return llvm::any_of(exts, [&](Extension ext) {
return allows(ext); });
145 return llvm::all_of(exts, [&](Extension ext) {
return allows(ext); });
151 explicit TargetEnv(SpecificationVersion specificationVersion, Level level,
154 : specificationVersion(specificationVersion), level(level) {
155 enabledProfiles.insert_range(profiles);
156 enabledExtensions.insert_range(extensions);
159 TosaSpecificationVersion specificationVersion;
161 llvm::SmallSet<Profile, 3> enabledProfiles;
162 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)