#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Transforms/FoldUtils.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
usingnamespacemlir;
usingnamespacemlir::linalg;
usingnamespacemlir::scf;
MapVector;
#define DEBUG_TYPE …
static Value allocBuffer(ImplicitLocOpBuilder &b,
const LinalgPromotionOptions &options,
Type elementType, Value allocSize, DataLayout &layout,
std::optional<unsigned> alignment = std::nullopt) { … }
static std::optional<Value> defaultAllocBufferCallBack(
const LinalgPromotionOptions &options, OpBuilder &builder,
memref::SubViewOp subView, ArrayRef<Value> boundingSubViewSize,
std::optional<unsigned> alignment, DataLayout &layout) { … }
static LogicalResult
defaultDeallocBufferCallBack(const LinalgPromotionOptions &options,
OpBuilder &b, Value fullLocalView) { … }
namespace {
struct LinalgOpInstancePromotionOptions { … };
}
LinalgOpInstancePromotionOptions::LinalgOpInstancePromotionOptions(
LinalgOp linalgOp, const LinalgPromotionOptions &options)
: … { … }
FailureOr<PromotionInfo> mlir::linalg::promoteSubviewAsNewBuffer(
OpBuilder &b, Location loc, memref::SubViewOp subView,
const AllocBufferCallbackFn &allocationFn, DataLayout &layout) { … }
static FailureOr<MapVector<int64_t, PromotionInfo>>
promoteSubViews(ImplicitLocOpBuilder &b,
LinalgOpInstancePromotionOptions options, DataLayout &layout) { … }
static FailureOr<LinalgOp>
promoteSubViews(ImplicitLocOpBuilder &b, LinalgOp op,
LinalgOpInstancePromotionOptions options, DataLayout &layout) { … }
LogicalResult
mlir::linalg::promoteSubviewsPrecondition(Operation *op,
LinalgPromotionOptions options) { … }
FailureOr<LinalgOp>
mlir::linalg::promoteSubViews(OpBuilder &builder, LinalgOp linalgOp,
const LinalgPromotionOptions &options) { … }
static std::optional<Value> allocateSubviewGPUMemoryInAddressSpace(
OpBuilder &builder, memref::SubViewOp subview, ArrayRef<Value> sizeBounds,
gpu::AddressSpace addressSpace) { … }
std::optional<Value> mlir::linalg::allocateWorkgroupMemory(
OpBuilder &builder, memref::SubViewOp subview, ArrayRef<Value> sizeBounds,
DataLayout &) { … }
LogicalResult mlir::linalg::deallocateWorkgroupMemory(OpBuilder &,
Value ) { … }
LogicalResult mlir::linalg::copyToWorkgroupMemory(OpBuilder &b, Value src,
Value dst) { … }
std::optional<Value> mlir::linalg::allocateGPUPrivateMemory(
OpBuilder &builder, memref::SubViewOp subview, ArrayRef<Value> sizeBounds,
DataLayout &) { … }
LogicalResult mlir::linalg::copyToGPUPrivateMemory(OpBuilder &b, Value src,
Value dst) { … }
LogicalResult mlir::linalg::deallocateGPUPrivateMemory(OpBuilder &,
Value ) { … }