File indexing completed on 2026-05-10 08:44:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
0016 #define LLVM_TRANSFORMS_COROUTINES_ABI_H
0017
0018 #include "llvm/Analysis/TargetTransformInfo.h"
0019 #include "llvm/Transforms/Coroutines/CoroShape.h"
0020 #include "llvm/Transforms/Coroutines/MaterializationUtils.h"
0021 #include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
0022
0023 namespace llvm {
0024
0025 class Function;
0026
0027 namespace coro {
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 class BaseABI {
0041 public:
0042 BaseABI(Function &F, coro::Shape &S,
0043 std::function<bool(Instruction &)> IsMaterializable)
0044 : F(F), Shape(S), IsMaterializable(std::move(IsMaterializable)) {}
0045 virtual ~BaseABI() = default;
0046
0047
0048 virtual void init() = 0;
0049
0050
0051 virtual void buildCoroutineFrame(bool OptimizeFrame);
0052
0053
0054 virtual void splitCoroutine(Function &F, coro::Shape &Shape,
0055 SmallVectorImpl<Function *> &Clones,
0056 TargetTransformInfo &TTI) = 0;
0057
0058 Function &F;
0059 coro::Shape &Shape;
0060
0061
0062
0063 std::function<bool(Instruction &I)> IsMaterializable;
0064 };
0065
0066 class SwitchABI : public BaseABI {
0067 public:
0068 SwitchABI(Function &F, coro::Shape &S,
0069 std::function<bool(Instruction &)> IsMaterializable)
0070 : BaseABI(F, S, std::move(IsMaterializable)) {}
0071
0072 void init() override;
0073
0074 void splitCoroutine(Function &F, coro::Shape &Shape,
0075 SmallVectorImpl<Function *> &Clones,
0076 TargetTransformInfo &TTI) override;
0077 };
0078
0079 class AsyncABI : public BaseABI {
0080 public:
0081 AsyncABI(Function &F, coro::Shape &S,
0082 std::function<bool(Instruction &)> IsMaterializable)
0083 : BaseABI(F, S, std::move(IsMaterializable)) {}
0084
0085 void init() override;
0086
0087 void splitCoroutine(Function &F, coro::Shape &Shape,
0088 SmallVectorImpl<Function *> &Clones,
0089 TargetTransformInfo &TTI) override;
0090 };
0091
0092 class AnyRetconABI : public BaseABI {
0093 public:
0094 AnyRetconABI(Function &F, coro::Shape &S,
0095 std::function<bool(Instruction &)> IsMaterializable)
0096 : BaseABI(F, S, std::move(IsMaterializable)) {}
0097
0098 void init() override;
0099
0100 void splitCoroutine(Function &F, coro::Shape &Shape,
0101 SmallVectorImpl<Function *> &Clones,
0102 TargetTransformInfo &TTI) override;
0103 };
0104
0105 }
0106
0107 }
0108
0109 #endif