[llvm] [Coroutines] ABI Objects to improve code separation between different ABIs, users and utilities. (PR #109338)
Chuanqi Xu via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 20:31:00 PDT 2024
================
@@ -2207,8 +2196,53 @@ static void addPrepareFunction(const Module &M,
Fns.push_back(PrepareFn);
}
+static coro::BaseABI *CreateNewABI(Function &F, coro::Shape &S) {
+ switch (S.ABI) {
+ case coro::ABI::Switch:
+ return new coro::SwitchABI(F, S);
+ case coro::ABI::Async:
+ return new coro::AsyncABI(F, S);
+ case coro::ABI::Retcon:
+ return new coro::AnyRetconABI(F, S);
+ case coro::ABI::RetconOnce:
+ return new coro::AnyRetconABI(F, S);
+ }
+ llvm_unreachable("Unknown ABI");
+}
+
CoroSplitPass::CoroSplitPass(bool OptimizeFrame)
- : MaterializableCallback(coro::defaultMaterializable),
+ : CreateAndInitABI([](Function &F, coro::Shape &S) {
+ coro::BaseABI *ABI = CreateNewABI(F, S);
+ ABI->init();
+ return ABI;
+ }),
+ OptimizeFrame(OptimizeFrame) {}
+
+static coro::BaseABI *
+CreateNewABIIsMat(Function &F, coro::Shape &S,
----------------
ChuanqiXu9 wrote:
```suggestion
CreateNewABI(Function &F, coro::Shape &S,
```
or make `IsMatCallback` a default argument
https://github.com/llvm/llvm-project/pull/109338
More information about the llvm-commits
mailing list