[Mlir-commits] [mlir] [mlir][emitc] Add a `declare_func` operation (PR #80297)
Simon Camphausen
llvmlistbot at llvm.org
Mon Feb 5 02:45:02 PST 2024
================
@@ -393,6 +393,36 @@ FunctionType CallOp::getCalleeType() {
return FunctionType::get(getContext(), getOperandTypes(), getResultTypes());
}
+//===----------------------------------------------------------------------===//
+// DeclareFuncOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult
+DeclareFuncOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
+ // Check that the sym_name attribute was specified.
+ auto fnAttr = getSymNameAttr();
+ if (!fnAttr)
+ return emitOpError("requires a 'sym_name' symbol reference attribute");
+ FuncOp fn = symbolTable.lookupNearestSymbolFrom<FuncOp>(*this, fnAttr);
+ if (!fn)
+ return emitOpError() << "'" << fnAttr.getValue()
+ << "' does not reference a valid function";
+
+ return success();
+}
+
+LogicalResult DeclareFuncOp::verify() {
+ auto fnAttr = (*this)->getAttrOfType<FlatSymbolRefAttr>("sym_name");
+ auto funcOp =
+ SymbolTable::lookupNearestSymbolFrom<emitc::FuncOp>((*this), fnAttr);
+
+ if (!isa<ModuleOp>((*this)->getParentOp()) && funcOp.isPrivate())
----------------
simon-camp wrote:
We shouldn't be using `isPrivate` here. The symbol visibility is not neccessarily in sync with the specifiers.
https://github.com/llvm/llvm-project/pull/80297
More information about the Mlir-commits
mailing list