[Mlir-commits] [mlir] [mlir][llvm] Add llvm.target_features features attribute (PR #71510)
Cullen Rhodes
llvmlistbot at llvm.org
Thu Nov 30 06:52:15 PST 2023
================
@@ -871,4 +871,67 @@ def LLVM_VScaleRangeAttr : LLVM_Attr<"VScaleRange", "vscale_range"> {
"IntegerAttr":$maxRange);
let assemblyFormat = "`<` struct(params) `>`";
}
+
+//===----------------------------------------------------------------------===//
+// TargetFeaturesAttr
+//===----------------------------------------------------------------------===//
+
+def LLVM_TargetFeaturesAttr : LLVM_Attr<"TargetFeatures", "target_features">
+{
+ let summary = "LLVM target features attribute";
+
+ let description = [{
+ Represents the LLVM target features as a list that can be checked within
+ passes/rewrites.
+
+ Example:
+ ```mlir
+ #llvm.target_features<["+sme", "+sve", "+sme-f64f64"]>
+ ```
+
+ Then within a pass or rewrite the features active at an op can be queried:
+
+ ```c++
+ auto targetFeatures = LLVM::TargetFeaturesAttr::featuresAt(op);
+
+ if (!targetFeatures.contains("+sme-f64f64"))
+ return failure();
+ ```
+ }];
+
+ let parameters = (ins OptionalArrayRefParameter<"StringAttr">:$features);
+
+ let builders = [
+ TypeBuilder<(ins "::llvm::StringRef":$features)>,
+ TypeBuilder<(ins "::llvm::ArrayRef<::llvm::StringRef>":$features)>
+ ];
+
+ let extraClassDeclaration = [{
+ /// Checks if a feature is contained within the features list.
+ /// Note: Using a StringAttr allows doing pointer-comparisons.
+ bool contains(::mlir::StringAttr feature) const;
+ bool contains(::llvm::StringRef feature) const;
+
+ bool nullOrEmpty() const {
+ // Checks if this attribute is fasly, or the features are empty.
----------------
c-rhodes wrote:
nit: spelling
```suggestion
// Checks if this attribute is false, or the features are empty.
```
https://github.com/llvm/llvm-project/pull/71510
More information about the Mlir-commits
mailing list