Skip to content

Commit

Permalink
[mlir][llvmir] implement missing attrs getChecked (#121248)
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental authored Dec 28, 2024
1 parent 8e32959 commit cb1ad98
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void LLVMDialect::registerAttributes() {
addAttributes<
#define GET_ATTRDEF_LIST
#include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc"

>();
}

Expand Down Expand Up @@ -288,6 +289,16 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
}));
}

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);
}));
}

TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
StringRef targetFeatures) {
SmallVector<StringRef> features;
Expand All @@ -296,6 +307,16 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
return get(context, features);
}

TargetFeaturesAttr
TargetFeaturesAttr::getChecked(function_ref<InFlightDiagnostic()> emitError,
MLIRContext *context, StringRef targetFeatures) {
SmallVector<StringRef> features;
targetFeatures.split(features, ',', /*MaxSplit=*/-1,
/*KeepEmpty=*/false);
ArrayRef featuresRef(features);
return getChecked(emitError, context, featuresRef);
}

LogicalResult
TargetFeaturesAttr::verify(function_ref<InFlightDiagnostic()> emitError,
llvm::ArrayRef<StringAttr> features) {
Expand Down

0 comments on commit cb1ad98

Please sign in to comment.