mirror-llvm-project/mlir/lib/Dialect/Utils/VerificationUtils.cpp
Nick Kreeger e289b2e765
[mlir][Utils] Add VerificationUtils (NFC) (#174336)
Introduces `VerificationUtils` to consolidate common operation
verification patterns in MLIR. This initial implementation provides
`verifyDynamicDimensionCount()` to reduce code duplication across
dialect verifiers.

This is an NFC (No Functional Change) refactoring that improves code
maintainability by extracting reusable verification logic into a shared
utility.
2026-01-12 16:52:44 +00:00

22 lines
891 B
C++

//===- VerificationUtils.cpp - Common verification utilities --------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Utils/VerificationUtils.h"
using namespace mlir;
LogicalResult mlir::verifyDynamicDimensionCount(Operation *op, ShapedType type,
ValueRange dynamicSizes) {
int64_t expectedCount = type.getNumDynamicDims();
int64_t actualCount = dynamicSizes.size();
if (expectedCount != actualCount) {
return op->emitOpError("incorrect number of dynamic sizes, has ")
<< actualCount << ", expected " << expectedCount;
}
return success();
}