diff options
| author | Yong He <yonghe@outlook.com> | 2024-05-29 11:14:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-29 11:14:22 -0700 |
| commit | 83f176ba8a3bae5533470aed6a90663653f894b8 (patch) | |
| tree | 3e39a674cb4662c946598526f633302f139e14ab /source/core | |
| parent | c1e34c5a29d99d8a70b4e78313bfd3d539d9206e (diff) | |
Add options to speedup compilation. (#4240)
* Add options to speedup compilation.
* Fix.
* Plumb options to DCE pass.
* Revert debug change.
* Fix regressions.
* More optimizations.
* more cleanup and fixes.
* remove comment.
* Fixes.
* Another fix.
* Fix errors.
* Fix errors.
* Add comments.
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-common.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/core/slang-common.h b/source/core/slang-common.h index 9e73b50a9..7d455546a 100644 --- a/source/core/slang-common.h +++ b/source/core/slang-common.h @@ -84,6 +84,26 @@ namespace Slang } } +// SLANG_DEFER +template<typename F> +class SlangDeferImpl +{ + F f; +public: + SlangDeferImpl(F&& f) + : f(Slang::_Move(f)) + {} + ~SlangDeferImpl() + { + f(); + } +}; + +#ifndef SLANG_DEFER_LAMBDA +#define SLANG_DEFER_LAMBDA(x) auto SLANG_CONCAT(slang_defer_, __LINE__) = SlangDeferImpl(x) +#define SLANG_DEFER(x) auto SLANG_CONCAT(slang_defer_,__LINE__) = SlangDeferImpl([&](){x;}) +#endif + // // Some macros for avoiding boilerplate // TODO: could probably deduce the size with templates, and move the whole |
