diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp index c7ddc1b36f4d4..28e8b81a05576 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,6 +289,16 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context, })); } +TargetFeaturesAttr +TargetFeaturesAttr::getChecked(function_ref emitError, + MLIRContext *context, + llvm::ArrayRef 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 features; @@ -296,6 +307,16 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context, return get(context, features); } +TargetFeaturesAttr +TargetFeaturesAttr::getChecked(function_ref emitError, + MLIRContext *context, StringRef targetFeatures) { + SmallVector features; + targetFeatures.split(features, ',', /*MaxSplit=*/-1, + /*KeepEmpty=*/false); + ArrayRef featuresRef(features); + return getChecked(emitError, context, featuresRef); +} + LogicalResult TargetFeaturesAttr::verify(function_ref emitError, llvm::ArrayRef features) {