1 | //===- CoroSplit.h - Converts a coroutine into a state machine -*- 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 | // \file |
10 | // This file declares the pass that builds the coroutine frame and outlines |
11 | // the resume and destroy parts of the coroutine into separate functions. |
12 | // |
13 | //===----------------------------------------------------------------------===// |
14 | |
15 | #ifndef LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H |
16 | #define LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H |
17 | |
18 | #include "llvm/Analysis/CGSCCPassManager.h" |
19 | #include "llvm/Analysis/LazyCallGraph.h" |
20 | #include "llvm/IR/PassManager.h" |
21 | |
22 | namespace llvm { |
23 | |
24 | struct CoroSplitPass : PassInfoMixin<CoroSplitPass> { |
25 | const std::function<bool(Instruction &)> MaterializableCallback; |
26 | |
27 | CoroSplitPass(bool OptimizeFrame = false); |
28 | CoroSplitPass(std::function<bool(Instruction &)> MaterializableCallback, |
29 | bool OptimizeFrame = false) |
30 | : MaterializableCallback(MaterializableCallback), |
31 | OptimizeFrame(OptimizeFrame) {} |
32 | |
33 | PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, |
34 | LazyCallGraph &CG, CGSCCUpdateResult &UR); |
35 | static bool isRequired() { return true; } |
36 | |
37 | // Would be true if the Optimization level isn't O0. |
38 | bool OptimizeFrame; |
39 | }; |
40 | } // end namespace llvm |
41 | |
42 | #endif // LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H |
43 |