Skip to content

Commit 0bf120a

Browse files
Théo Degioannigysit
Théo Degioanni
authored andcommitted
[mlir] [sroa] Add support for MemRef.
This patch implements SROA interfaces for MemRef, up to a given fixed size. Reviewed By: gysit, Dinistro Differential Revision: https://reviews.llvm.org/D151102
1 parent 7420413 commit 0bf120a

File tree

7 files changed

+515
-123
lines changed

7 files changed

+515
-123
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===- MemRefMemorySlot.h - Implementation of Memory Slot Interfaces ------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_DIALECT_MEMREF_IR_MEMREFMEMORYSLOT_H
10+
#define MLIR_DIALECT_MEMREF_IR_MEMREFMEMORYSLOT_H
11+
12+
namespace mlir {
13+
class DialectRegistry;
14+
15+
namespace memref {
16+
void registerMemorySlotExternalModels(DialectRegistry &registry);
17+
} // namespace memref
18+
} // namespace mlir
19+
20+
#endif // MLIR_DIALECT_MEMREF_IR_MEMREFMEMORYSLOT_H

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ def MemRef_ReallocOp : MemRef_Op<"realloc"> {
311311

312312
def MemRef_AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource,[
313313
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
314-
DeclareOpInterfaceMethods<PromotableAllocationOpInterface>]> {
314+
DeclareOpInterfaceMethods<PromotableAllocationOpInterface>,
315+
DeclareOpInterfaceMethods<DestructurableAllocationOpInterface>]> {
315316
let summary = "stack memory allocation operation";
316317
let description = [{
317318
The `alloca` operation allocates memory on the stack, to be automatically
@@ -1162,7 +1163,8 @@ def LoadOp : MemRef_Op<"load",
11621163
"memref", "result",
11631164
"::llvm::cast<MemRefType>($_self).getElementType()">,
11641165
MemRefsNormalizable,
1165-
DeclareOpInterfaceMethods<PromotableMemOpInterface>]> {
1166+
DeclareOpInterfaceMethods<PromotableMemOpInterface>,
1167+
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>]> {
11661168
let summary = "load operation";
11671169
let description = [{
11681170
The `load` op reads an element from a memref specified by an index list. The
@@ -1752,7 +1754,8 @@ def MemRef_StoreOp : MemRef_Op<"store",
17521754
"memref", "value",
17531755
"::llvm::cast<MemRefType>($_self).getElementType()">,
17541756
MemRefsNormalizable,
1755-
DeclareOpInterfaceMethods<PromotableMemOpInterface>]> {
1757+
DeclareOpInterfaceMethods<PromotableMemOpInterface>,
1758+
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>]> {
17561759
let summary = "store operation";
17571760
let description = [{
17581761
Store a value to a memref location given by indices. The value stored should

mlir/include/mlir/InitAllDialects.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "mlir/Dialect/MLProgram/IR/MLProgram.h"
4949
#include "mlir/Dialect/Math/IR/Math.h"
5050
#include "mlir/Dialect/MemRef/IR/MemRef.h"
51+
#include "mlir/Dialect/MemRef/IR/MemRefMemorySlot.h"
5152
#include "mlir/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.h"
5253
#include "mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.h"
5354
#include "mlir/Dialect/MemRef/Transforms/BufferizableOpInterfaceImpl.h"
@@ -148,6 +149,7 @@ inline void registerAllDialects(DialectRegistry &registry) {
148149
memref::registerBufferizableOpInterfaceExternalModels(registry);
149150
memref::registerRuntimeVerifiableOpInterfaceExternalModels(registry);
150151
memref::registerValueBoundsOpInterfaceExternalModels(registry);
152+
memref::registerMemorySlotExternalModels(registry);
151153
scf::registerBufferizableOpInterfaceExternalModels(registry);
152154
scf::registerValueBoundsOpInterfaceExternalModels(registry);
153155
shape::registerBufferizableOpInterfaceExternalModels(registry);

mlir/lib/Dialect/MemRef/IR/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_mlir_dialect_library(MLIRMemRefDialect
22
MemRefDialect.cpp
3-
MemRefMem2Reg.cpp
3+
MemRefMemorySlot.cpp
44
MemRefOps.cpp
55
ValueBoundsOpInterfaceImpl.cpp
66

@@ -21,6 +21,7 @@ add_mlir_dialect_library(MLIRMemRefDialect
2121
MLIRDialectUtils
2222
MLIRInferTypeOpInterface
2323
MLIRIR
24+
MLIRMemorySlotInterfaces
2425
MLIRShapedOpInterfaces
2526
MLIRSideEffectInterfaces
2627
MLIRValueBoundsOpInterface

mlir/lib/Dialect/MemRef/IR/MemRefMem2Reg.cpp

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)