1//===-- SROA.h - Scalar Replacement Of Aggregates ---------------*- 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_SROA_H
10#define MLIR_TRANSFORMS_SROA_H
11
12#include "mlir/Interfaces/MemorySlotInterfaces.h"
13#include "mlir/Support/LogicalResult.h"
14#include "llvm/ADT/Statistic.h"
15
16namespace mlir {
17
18/// Statistics collected while applying SROA.
19struct SROAStatistics {
20 /// Total amount of memory slots destructured.
21 llvm::Statistic *destructuredAmount = nullptr;
22 /// Total amount of memory slots in which the destructured size was smaller
23 /// than the total size after eliminating unused fields.
24 llvm::Statistic *slotsWithMemoryBenefit = nullptr;
25 /// Maximal number of sub-elements a successfully destructured slot initially
26 /// had.
27 llvm::Statistic *maxSubelementAmount = nullptr;
28};
29
30/// Attempts to destructure the slots of destructurable allocators. Returns
31/// failure if no slot was destructured.
32LogicalResult tryToDestructureMemorySlots(
33 ArrayRef<DestructurableAllocationOpInterface> allocators,
34 RewriterBase &rewriter, const DataLayout &dataLayout,
35 SROAStatistics statistics = {});
36
37} // namespace mlir
38
39#endif // MLIR_TRANSFORMS_SROA_H
40

source code of mlir/include/mlir/Transforms/SROA.h