[Mlir-commits] [mlir] [mlir][llvmir] implement missing attrs `getChecked` (PR #121248)
Maksim Levental
llvmlistbot at llvm.org
Sat Dec 28 10:44:40 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/3] [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/3] 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/3] 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,
More information about the Mlir-commits
mailing list