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/// \file
9/// This file provides the interface for LLVM's Scalar Replacement of
10/// Aggregates pass. This pass provides both aggregate splitting and the
11/// primary SSA formation used in the compiler.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_SCALAR_SROA_H
16#define LLVM_TRANSFORMS_SCALAR_SROA_H
17
18#include "llvm/IR/PassManager.h"
19
20namespace llvm {
21
22class Function;
23
24struct SROAOptions {
25 enum CFGOption { ModifyCFG, PreserveCFG };
26
27 CFGOption CFG;
28 bool AggregateToVector;
29
30 SROAOptions(CFGOption CFG = PreserveCFG, bool AggregateToVector = false)
31 : CFG(CFG), AggregateToVector(AggregateToVector) {}
32};
33
34class SROAPass : public OptionalPassInfoMixin<SROAPass> {
35 const SROAOptions Options;
36
37public:
38 /// If \p PreserveCFG is set, then the pass is not allowed to modify CFG
39 /// in any way, even if it would update CFG analyses.
40 /// If \p AggregateToVector is set, then the pass will try to convert
41 /// allocas of homogeneous structs into vector allocas.
42 LLVM_ABI SROAPass(SROAOptions Options);
43
44 /// Run the pass over the function.
45 LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
46
47 LLVM_ABI void
48 printPipeline(raw_ostream &OS,
49 function_ref<StringRef(StringRef)> MapClassName2PassName);
50};
51
52} // end namespace llvm
53
54#endif // LLVM_TRANSFORMS_SCALAR_SROA_H
55