blob: c190c8006b14d27d33f7efd595f1f49a126ccade [file] [log] [blame]
//===- DataLayoutAnalysis.h - API for Querying Nested Data Layout -*- C++ -*-=//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMap.h"
#include <memory>
namespace mlir {
class Operation;
class DataLayout;
/// Stores data layout objects for each operation that specifies the data layout
/// above and below the given operation.
class DataLayoutAnalysis {
/// Constructs the data layouts.
explicit DataLayoutAnalysis(Operation *root);
/// Returns the data layout active active at the given operation, that is the
/// data layout specified by the closest ancestor that can specify one, or the
/// default layout if there is no such ancestor.
const DataLayout &getAbove(Operation *operation) const;
/// Returns the data layout specified by the given operation or its closest
/// ancestor that can specify one.
const DataLayout &getAtOrAbove(Operation *operation) const;
/// Storage for individual data layouts.
DenseMap<Operation *, std::unique_ptr<DataLayout>> layouts;
/// Default data layout in case no operations specify one.
std::unique_ptr<DataLayout> defaultLayout;
} // namespace mlir