llvm-project/mlir/lib/Interfaces/ShapedOpInterfaces.cpp
Matthias Springer 598f5275c1 [mlir][interfaces] Add ShapedDimOpInterface
This interface is implemented by memref.dim and tensor.dim. This change makes it possible to remove a build dependency of the Affine dialect on the Tensor dialect (and maybe also the MemRef dialect in the future).

Differential Revision: https://reviews.llvm.org/D133595
2022-10-03 13:58:52 +09:00

27 lines
1010 B
C++

//===- ShapedOpInterfaces.cpp - Interfaces for Shaped Ops -----------------===//
//
// 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/Interfaces/ShapedOpInterfaces.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
// ShapedDimOpInterface
//===----------------------------------------------------------------------===//
LogicalResult mlir::detail::verifyShapedDimOpInterface(Operation *op) {
if (op->getNumResults() != 1)
return op->emitError("expected single op result");
if (!op->getResult(0).getType().isIndex())
return op->emitError("expect index result type");
return success();
}
/// Include the definitions of the interface.
#include "mlir/Interfaces/ShapedOpInterfaces.cpp.inc"