1515 */
1616
1717//
18- // TranslateEHOldToNew translates the old Phase 3 EH instructions, which include
18+ // TranslateToNewEH translates the old Phase 3 EH instructions, which include
1919// try, catch, catch_all, delegate, and rethrow, into the new EH instructions,
2020// which include try_table (with catch / catch_ref / catch_all / catch_all_ref)
2121// and throw_ref, passed at the Oct 2023 CG meeting. This translator can be used
2424// end of the Binaryen pipeline to produce binaries for the new spec while the
2525// end-to-end toolchain implementation for the new spec is in progress.
2626//
27- // TODO
28- // TranslateEHNewToOld translates the new EH instructions to the old ones. This
29- // can be used as a stopgap tool while Binaryen implementation for the whole
30- // optimization pipeline is not complete but we need to test our LLVM
31- // implementation for the new spec. This has not been implemented yet.
32- //
3327
3428#include < ir/drop.h>
3529#include < ir/find_all.h>
@@ -45,8 +39,7 @@ namespace {
4539// Translates the old EH instructions (try / catch / catch_all / delegate /
4640// rethrow) into the new ones (try_table (+ catch / catch_ref / catch_all /
4741// catch_all_ref) / throw_ref).
48- struct TranslateEHOldToNew
49- : public WalkerPass<PostWalker<TranslateEHOldToNew>> {
42+ struct TranslateToNewEH : public WalkerPass <PostWalker<TranslateToNewEH>> {
5043 bool isFunctionParallel () override { return true ; }
5144
5245 // Scans and records which try labels are targeted by delegates and rethrows.
@@ -201,10 +194,8 @@ struct TranslateEHOldToNew
201194 // exnref) tuples for a short time.
202195 std::unordered_map<Type, Index> typeToScratchLocal;
203196
204- bool refinalize = false ;
205-
206197 std::unique_ptr<Pass> create () override {
207- return std::make_unique<TranslateEHOldToNew >();
198+ return std::make_unique<TranslateToNewEH >();
208199 }
209200
210201 // Get a scratch local for a given type. These locals are used to contain
@@ -680,7 +671,6 @@ struct TranslateEHOldToNew
680671 }
681672
682673 void visitTry (Try* curr) {
683- refinalize = true ;
684674 Builder builder (*getModule ());
685675 Block* outerBlock = nullptr ;
686676 auto it = delegateTargetToBrTarget.find (curr->name );
@@ -807,15 +797,8 @@ struct TranslateEHOldToNew
807797 }
808798};
809799
810- struct TranslateEHNewToOld
811- : public WalkerPass<PostWalker<TranslateEHNewToOld>> {
812- // TODO
813- };
814-
815800} // namespace
816801
817- Pass* createTranslateEHOldToNewPass () { return new TranslateEHOldToNew (); }
818-
819- Pass* createTranslateEHNewToOldPass () { return new TranslateEHNewToOld (); }
802+ Pass* createTranslateToNewEHPass () { return new TranslateToNewEH (); }
820803
821804} // namespace wasm
0 commit comments