Files
clang-p2996/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp
River Riddle 755dc07d69 [mlir:Analysis] Move the LoopAnalysis library to Dialect/Affine/Analysis
The current state of the top level Analysis/ directory is that it contains two libraries;
a generic Analysis library (free from dialect dependencies), and a LoopAnalysis library
that contains various analysis utilities that originated from Affine loop transformations.
This commit moves the LoopAnalysis to the more appropriate home of `Dialect/Affine/Analysis/`,
given the use and intention of the majority of the code within it. After the move, if there
are generic utilities that would fit better in the top-level Analysis/ directory, we can move
them.

Differential Revision: https://reviews.llvm.org/D117351
2022-01-18 10:28:22 -08:00

56 lines
1.7 KiB
C++

//===- TestMemRefBoundCheck.cpp - Test out of bound access checks ---------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements a pass to check memref accesses for out of bound
// accesses.
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/Analysis/Utils.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#define DEBUG_TYPE "memref-bound-check"
using namespace mlir;
namespace {
/// Checks for out of bound memref access subscripts..
struct TestMemRefBoundCheck
: public PassWrapper<TestMemRefBoundCheck, FunctionPass> {
StringRef getArgument() const final { return "test-memref-bound-check"; }
StringRef getDescription() const final {
return "Check memref access bounds in a Function";
}
void runOnFunction() override;
};
} // namespace
void TestMemRefBoundCheck::runOnFunction() {
getFunction().walk([](Operation *opInst) {
TypeSwitch<Operation *>(opInst)
.Case<AffineReadOpInterface, AffineWriteOpInterface>(
[](auto op) { (void)boundCheckLoadOrStoreOp(op); });
// TODO: do this for DMA ops as well.
});
}
namespace mlir {
namespace test {
void registerMemRefBoundCheck() { PassRegistration<TestMemRefBoundCheck>(); }
} // namespace test
} // namespace mlir