13 #ifndef MLIR_DIALECT_TOSA_IR_TARGETENV_H
14 #define MLIR_DIALECT_TOSA_IR_TARGETENV_H
18 #include "llvm/ADT/SmallSet.h"
58 : majorVersion(major), minorVersion(minor) {}
63 return this->majorVersion == baseVersion.majorVersion &&
64 this->minorVersion >= baseVersion.minorVersion;
67 uint32_t
getMajor()
const {
return majorVersion; }
68 uint32_t
getMinor()
const {
return minorVersion; }
71 uint32_t majorVersion = 0;
72 uint32_t minorVersion = 0;
75 fromVersionEnum(SpecificationVersion version) {
77 case SpecificationVersion::V_1_0:
79 case SpecificationVersion::V_1_1_DRAFT:
82 llvm_unreachable(
"Unknown TOSA version");
94 explicit TargetEnv(SpecificationVersion specificationVersion, Level level,
97 : specificationVersion(specificationVersion), level(level) {
98 enabledProfiles.insert_range(profiles);
99 enabledExtensions.insert_range(extensions);
104 targetAttr.getProfiles(), targetAttr.getExtensions()) {}
112 if (level == Level::eightK)
114 else if (level == Level::none)
117 llvm_unreachable(
"Unknown TOSA level");
121 bool allows(Profile prof)
const {
return enabledProfiles.count(prof) != 0; }
124 return llvm::any_of(profs, [&](Profile prof) {
return allows(prof); });
128 return llvm::all_of(profs, [&](Profile prof) {
return allows(prof); });
132 bool allows(Extension ext)
const {
return enabledExtensions.count(ext) != 0; }
135 return llvm::any_of(exts, [&](Extension ext) {
return allows(ext); });
139 return llvm::all_of(exts, [&](Extension ext) {
return allows(ext); });
143 SpecificationVersion specificationVersion;
145 llvm::SmallSet<Profile, 3> enabledProfiles;
146 llvm::SmallSet<Extension, 13> enabledExtensions;
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
This class represents the capability enabled in the target implementation such as profile,...
TosaLevel getLevel() const
void addExtension(Extension e)
TargetEnv(SpecificationVersion specificationVersion, Level level, const ArrayRef< Profile > &profiles, const ArrayRef< Extension > &extensions)
SpecificationVersion getSpecVersion() const
bool allowsAllOf(ArrayRef< Extension > exts) const
void addProfile(Profile p)
bool allowsAllOf(ArrayRef< Profile > profs) const
bool allows(Profile prof) const
bool allows(Extension ext) const
bool allowsAnyOf(ArrayRef< Profile > profs) const
TargetEnv(TargetEnvAttr targetAttr)
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(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)
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)