#pragma once #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Operation.h" #include "mlir/Support/LogicalResult.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include namespace onnx_mlir::pim { /// Emits a consistent diagnostic for target paths that require static shapes. mlir::InFlightDiagnostic emitUnsupportedStaticShapeDiagnostic(mlir::Operation* op, llvm::StringRef valueDescription); /// Emits a consistent diagnostic for unsupported ranks while listing the ranks /// accepted by the current lowering/codegen path. mlir::InFlightDiagnostic emitUnsupportedRankDiagnostic(mlir::Operation* op, llvm::StringRef valueDescription, int64_t actualRank, llvm::ArrayRef supportedRanks); /// Emits a consistent diagnostic for missing symbol/global references. mlir::InFlightDiagnostic emitMissingSymbolDiagnostic(mlir::Operation* op, llvm::StringRef symbolKind, llvm::StringRef symbolName); /// Converts a filesystem error into an MLIR failure diagnostic anchored at /// the relevant IR location. mlir::LogicalResult emitFileSystemError(mlir::Location loc, llvm::StringRef action, llvm::StringRef path, const std::error_code& errorCode); template mlir::LogicalResult failureOrToLogicalResult(const llvm::FailureOr& value) { return mlir::success(succeeded(value)); } } // namespace onnx_mlir::pim