Skip to content

Commit d4a9e56

Browse files
authored
[mlir][llvmir] implement missing attrs getChecked
1 parent 092966a commit d4a9e56

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
288288
}));
289289
}
290290

291+
TargetFeaturesAttr TargetFeaturesAttr::getChecked(
292+
llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
293+
MLIRContext *context, llvm::ArrayRef<StringRef> features) {
294+
return Base::getChecked(emitError, context,
295+
llvm::map_to_vector(features, [&](StringRef feature) {
296+
return StringAttr::get(context, feature);
297+
}));
298+
}
299+
291300
TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
292301
StringRef targetFeatures) {
293302
SmallVector<StringRef> features;
@@ -296,6 +305,20 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
296305
return get(context, features);
297306
}
298307

308+
TargetFeaturesAttr TargetFeaturesAttr::getChecked(
309+
llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
310+
MLIRContext *context, StringRef targetFeatures) {
311+
SmallVector<StringRef> features;
312+
targetFeatures.split(features, ',', /*MaxSplit=*/-1,
313+
/*KeepEmpty=*/false);
314+
SmallVector<StringAttr> featuresAttrs;
315+
featuresAttrs.reserve(features.size());
316+
for (StringRef feature : features) {
317+
featuresAttrs.push_back(StringAttr::get(context, feature));
318+
}
319+
return getChecked(emitError, context, featuresAttrs);
320+
}
321+
299322
LogicalResult
300323
TargetFeaturesAttr::verify(function_ref<InFlightDiagnostic()> emitError,
301324
llvm::ArrayRef<StringAttr> features) {

0 commit comments

Comments
 (0)