================
@@ -257,6 +258,42 @@ cir::CIRDialect::verifyOperationAttribute(mlir::Operation
*op,
if (isOpenCLVersionAttrName(attrName))
return verifyOpenCLVersionAttr(op, attr);
+ if (attrName == getCXXABIAttrName()) {
+ if (!mlir::isa<mlir::ModuleOp>(op))
+ return op->emitOpError() << "expects '" << getCXXABIAttrName()
+ << "' attribute to be attached to '"
+ << mlir::ModuleOp::getOperationName() << "'";
+ auto abi = mlir::dyn_cast<mlir::StringAttr>(attr.getValue());
+ if (!abi)
+ return op->emitOpError()
+ << "expects '" << getCXXABIAttrName() << "' to be a string";
+
+ StringRef abival = abi.getValue();
+ if (!clang::TargetCXXABI::isABI(abival))
+ return op->emitOpError() << "unknown C++ ABI '" << abi.getValue() << "'";
+
+ clang::TargetCXXABI::Kind kind =
+ clang::TargetCXXABI::getKind(abival);
+ if (auto triple = op->getAttrOfType<mlir::StringAttr>(getTripleAttrName()))
+ if (!clang::TargetCXXABI::isSupportedCXXABI(
+ llvm::Triple(triple.getValue()), kind))
+ return op->emitOpError()
+ << "C++ ABI '" << abi.getValue()
+ << "' is not supported on target '" << triple.getValue() << "'";
+
+ switch (kind) {
----------------
Fznamznon wrote:
I agree that we should not duplicate the logic. @koparasy , do you? Since you
requested this in
https://github.com/llvm/llvm-project/pull/229494#discussion_r4199624028 .
https://github.com/llvm/llvm-project/pull/229494
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits