================
@@ -2683,15 +2691,55 @@ static constexpr std::array
kExplicitLLVMFuncOpAttributes{
StringLiteral("willreturn"),
};
+// List of LLVM IR attributes that are handled by prefix to map onto an MLIR
+// LLVMFuncOp.
+static constexpr std::array kExplicitLLVMFuncOpAttributePrefixes{
+ StringLiteral("no-builtin-"),
+};
+
+template <typename OpTy>
+static void convertNoBuiltinAttrs(MLIRContext *ctx,
+ const llvm::AttributeSet &attrs,
+ OpTy target) {
+ // 'no-builtins' is the complete collection, and overrides all the rest.
+ if (attrs.hasAttribute("no-builtins")) {
+ target.setNobuiltinsAttr(mlir::ArrayAttr::get(ctx, {}));
+ return;
+ }
+
+ llvm::SmallVector<mlir::Attribute> nbAttrs;
+ for (llvm::Attribute attr : attrs) {
+ // Attributes that are part of llvm directly (that is, have an
AttributeKind
+ // in the enum) shouldn't be checked.
+ if (attr.hasKindAsEnum())
+ continue;
+
+ StringRef val = attr.getKindAsString();
+
+ if (val.starts_with("no-builtin-")) {
+ StringRef str = val.drop_front(sizeof("no-builtin-") - 1);
+
+ if (nbAttrs.end() == llvm::find_if(nbAttrs, [str](Attribute a) {
----------------
gysit wrote:
Let's maybe use a SetVector for `nbAttrs`? That should allow us to just create
the attribute and insert it.
https://github.com/llvm/llvm-project/pull/178899
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits