diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-08-29 06:05:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-28 15:05:26 -0700 |
| commit | 508dc3a95de50de4a4d07d0a72a18e40d55b0e2e (patch) | |
| tree | 7487232f5c0db0dd607e2a91b539f6a592789b06 /source/core/slang-common.h | |
| parent | 06f7ef354cdde4cf8e8797d8853ed2d9c3208b5b (diff) | |
Allow bitwise or expressions and numeric literals in spirv_asm blocks (#3157)
* Add -spirv-core-grammar option to load alternate spirv defs
Also embed a version to use by default
* Use perfect hash for spv op lookup
* Neaten perfect hash embedding
* Refactor spirv grammar lookup in preperation for more kinds of lookups
* Load spirv capability list from spec
* Add all SPIR-V enums to lookup table
* regenerate vs projects
* appease msvc
* Use string slices for spir-v core grammar lookups
* wiggle
* comment
* Add OpInfo for spv ops
* regenerate vs projects
* Embed op names
* Add min/max operand counts and enum categories to spirv info
* neaten
* Operand kinds for spirv ops
* Store and embed all information relating to spirv enums and qualifiers
* Use SPIR-V spec to position instructions in spirv_asm blocks
* Neaten spir-v info embedding
* Neaten perfect hash embedding
* Add assignment syntax to spirv_asm snippets
* Better errors for spirv_asm parser
* Add warning for too many operands in spirv asm
* squash warnings
* neaten
* test wiggle
* Lookup enums for spirv
* Put OpCapability and OpExtension in the correct place for spirv_asm blocks
* Tests for OpCapability and OpExtension
* ci wiggle
* Add expected failure
* Allow raising immediate values to constant ids where necessary in spirv_asm blocks
* Allow bitwise or expressions and numeric literals in spirv_asm blocks
* test numeric literals
* Fix memory issues.
* fix.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core/slang-common.h')
| -rw-r--r-- | source/core/slang-common.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source/core/slang-common.h b/source/core/slang-common.h index 62c73df08..9e73b50a9 100644 --- a/source/core/slang-common.h +++ b/source/core/slang-common.h @@ -84,6 +84,53 @@ namespace Slang } } +// +// Some macros for avoiding boilerplate +// TODO: could probably deduce the size with templates, and move the whole +// thing into a template +// +#if __cplusplus >= 202002L +#define SLANG_COMPONENTWISE_EQUALITY_1(type) bool operator==(const type& other) const = default; +#define SLANG_COMPONENTWISE_EQUALITY_2(type) bool operator==(const type& other) const = default; +#define SLANG_COMPONENTWISE_EQUALITY_3(type) bool operator==(const type& other) const = default; +#else +#define SLANG_COMPONENTWISE_EQUALITY_1(type) \ + bool operator==(const type& other) const \ + { \ + const auto& [m1] = *this; \ + const auto& [o1] = other; \ + return m1 == o1; \ + } \ + bool operator!=(const type& other) const \ + { \ + return !(*this == other); \ + } + +#define SLANG_COMPONENTWISE_EQUALITY_2(type) \ + bool operator==(const type& other) const \ + { \ + const auto& [m1, m2] = *this; \ + const auto& [o1, o2] = other; \ + return m1 == o1 && m2 == o2; \ + } \ + bool operator!=(const type& other) const \ + { \ + return !(*this == other); \ + } + +#define SLANG_COMPONENTWISE_EQUALITY_3(type) \ + bool operator==(const type& other) const \ + { \ + const auto& [m1, m2, m3] = *this; \ + const auto& [o1, o2, o3] = other; \ + return m1 == o1 && m2 == o2 && m3 == o3; \ + } \ + bool operator!=(const type& other) const \ + { \ + return !(*this == other); \ + } +#endif + // TODO: Shouldn't these be SLANG_ prefixed? #ifdef _MSC_VER #define UNREACHABLE_RETURN(x) |
