[Mlir-commits] [mlir] [mlir][llvmir] implement missing attrs `getChecked` (PR #121248)
Maksim Levental
llvmlistbot at llvm.org
Sat Dec 28 13:30:04 PST 2024
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/121248
>From d4a9e5613edb8950f944490271918e1c24eb3f15 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Fri, 27 Dec 2024 22:46:21 -0600
Subject: [PATCH 1/5] [mlir][llvmir] implement missing attrs `getChecked`
---
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index c7ddc1b36f4d4f..6823bf05d1e2d8 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -288,6 +288,15 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
}));
}
+TargetFeaturesAttr TargetFeaturesAttr::getChecked(
+ llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
+ MLIRContext *context, llvm::ArrayRef<StringRef> features) {
+ return Base::getChecked(emitError, context,
+ llvm::map_to_vector(features, [&](StringRef feature) {
+ return StringAttr::get(context, feature);
+ }));
+}
+
TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
StringRef targetFeatures) {
SmallVector<StringRef> features;
@@ -296,6 +305,20 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
return get(context, features);
}
+TargetFeaturesAttr TargetFeaturesAttr::getChecked(
+ llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
+ MLIRContext *context, StringRef targetFeatures) {
+ SmallVector<StringRef> features;
+ targetFeatures.split(features, ',', /*MaxSplit=*/-1,
+ /*KeepEmpty=*/false);
+ SmallVector<StringAttr> featuresAttrs;
+ featuresAttrs.reserve(features.size());
+ for (StringRef feature : features) {
+ featuresAttrs.push_back(StringAttr::get(context, feature));
+ }
+ return getChecked(emitError, context, featuresAttrs);
+}
+
LogicalResult
TargetFeaturesAttr::verify(function_ref<InFlightDiagnostic()> emitError,
llvm::ArrayRef<StringAttr> features) {
>From 0a8fdd25c6a2601df9c8fafc69663febf00c7f89 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Sat, 28 Dec 2024 13:43:00 -0500
Subject: [PATCH 2/5] Update mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
Co-authored-by: Tobias Gysi <tobias.gysi at nextsilicon.com>
---
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index 6823bf05d1e2d8..2156d081a381df 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -289,7 +289,7 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
}
TargetFeaturesAttr TargetFeaturesAttr::getChecked(
- llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
+ function_ref<InFlightDiagnostic()> emitError,
MLIRContext *context, llvm::ArrayRef<StringRef> features) {
return Base::getChecked(emitError, context,
llvm::map_to_vector(features, [&](StringRef feature) {
>From 896d5154b91223aabb740ff16ef3bf1ca9afdf29 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Sat, 28 Dec 2024 13:44:31 -0500
Subject: [PATCH 3/5] Update mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
Co-authored-by: Tobias Gysi <tobias.gysi at nextsilicon.com>
---
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index 2156d081a381df..2e66e6cf911c9b 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -306,7 +306,7 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
}
TargetFeaturesAttr TargetFeaturesAttr::getChecked(
- llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
+ function_ref<InFlightDiagnostic()> emitError,
MLIRContext *context, StringRef targetFeatures) {
SmallVector<StringRef> features;
targetFeatures.split(features, ',', /*MaxSplit=*/-1,
>From d2515df82577237f969a1dd94bd26ab83500060b Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Sat, 28 Dec 2024 13:46:22 -0500
Subject: [PATCH 4/5] Update mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
Co-authored-by: Tobias Gysi <tobias.gysi at nextsilicon.com>
---
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index 2e66e6cf911c9b..fe2adf361ede52 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -311,12 +311,7 @@ TargetFeaturesAttr TargetFeaturesAttr::getChecked(
SmallVector<StringRef> features;
targetFeatures.split(features, ',', /*MaxSplit=*/-1,
/*KeepEmpty=*/false);
- SmallVector<StringAttr> featuresAttrs;
- featuresAttrs.reserve(features.size());
- for (StringRef feature : features) {
- featuresAttrs.push_back(StringAttr::get(context, feature));
- }
- return getChecked(emitError, context, featuresAttrs);
+ return getChecked(emitError, context, features);
}
LogicalResult
>From 6ba64b1cf9ed0c7ecc467387442c4b40a07d28bb Mon Sep 17 00:00:00 2001
From: max <maksim.levental at gmail.com>
Date: Sat, 28 Dec 2024 16:29:49 -0500
Subject: [PATCH 5/5] use TargetFeaturesAttr::getChecked
---
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index fe2adf361ede52..3461deadcb870b 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -48,6 +48,7 @@ void LLVMDialect::registerAttributes() {
addAttributes<
#define GET_ATTRDEF_LIST
#include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc"
+
>();
}
@@ -288,9 +289,10 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
}));
}
-TargetFeaturesAttr TargetFeaturesAttr::getChecked(
- function_ref<InFlightDiagnostic()> emitError,
- MLIRContext *context, llvm::ArrayRef<StringRef> features) {
+TargetFeaturesAttr
+TargetFeaturesAttr::getChecked(function_ref<InFlightDiagnostic()> emitError,
+ MLIRContext *context,
+ llvm::ArrayRef<StringRef> features) {
return Base::getChecked(emitError, context,
llvm::map_to_vector(features, [&](StringRef feature) {
return StringAttr::get(context, feature);
@@ -305,13 +307,13 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
return get(context, features);
}
-TargetFeaturesAttr TargetFeaturesAttr::getChecked(
- function_ref<InFlightDiagnostic()> emitError,
- MLIRContext *context, StringRef targetFeatures) {
+TargetFeaturesAttr
+TargetFeaturesAttr::getChecked(function_ref<InFlightDiagnostic()> emitError,
+ MLIRContext *context, StringRef targetFeatures) {
SmallVector<StringRef> features;
targetFeatures.split(features, ',', /*MaxSplit=*/-1,
/*KeepEmpty=*/false);
- return getChecked(emitError, context, features);
+ return TargetFeaturesAttr::getChecked(emitError, context, features);
}
LogicalResult
More information about the Mlir-commits
mailing list