1 | //===-- Mem2Reg.h - Mem2Reg definitions -------------------------*- C++ -*-===// |
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_TRANSFORMS_MEM2REG_H |
10 | #define MLIR_TRANSFORMS_MEM2REG_H |
11 | |
12 | #include "mlir/IR/PatternMatch.h" |
13 | #include "mlir/Interfaces/MemorySlotInterfaces.h" |
14 | #include "llvm/ADT/Statistic.h" |
15 | |
16 | namespace mlir { |
17 | |
18 | /// Statistics collected while applying mem2reg. |
19 | struct Mem2RegStatistics { |
20 | /// Total amount of memory slots promoted. |
21 | llvm::Statistic *promotedAmount = nullptr; |
22 | /// Total amount of new block arguments inserted in blocks. |
23 | llvm::Statistic *newBlockArgumentAmount = nullptr; |
24 | }; |
25 | |
26 | /// Attempts to promote the memory slots of the provided allocators. Succeeds if |
27 | /// at least one memory slot was promoted. |
28 | LogicalResult |
29 | tryToPromoteMemorySlots(ArrayRef<PromotableAllocationOpInterface> allocators, |
30 | RewriterBase &rewriter, const DataLayout &dataLayout, |
31 | Mem2RegStatistics statistics = {}); |
32 | |
33 | } // namespace mlir |
34 | |
35 | #endif // MLIR_TRANSFORMS_MEM2REG_H |
36 | |