summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-expr.h
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-08-29 06:05:26 +0800
committerGitHub <noreply@github.com>2023-08-28 15:05:26 -0700
commit508dc3a95de50de4a4d07d0a72a18e40d55b0e2e (patch)
tree7487232f5c0db0dd607e2a91b539f6a592789b06 /source/slang/slang-ast-expr.h
parent06f7ef354cdde4cf8e8797d8853ed2d9c3208b5b (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/slang/slang-ast-expr.h')
-rw-r--r--source/slang/slang-ast-expr.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/source/slang/slang-ast-expr.h b/source/slang/slang-ast-expr.h
index 36d304a1a..7b09c3334 100644
--- a/source/slang/slang-ast-expr.h
+++ b/source/slang/slang-ast-expr.h
@@ -6,6 +6,8 @@
namespace Slang {
+using SpvWord = uint32_t;
+
// Syntax class definitions for expressions.
//
// A placeholder for where an Expr is expected but is missing from source.
@@ -640,14 +642,38 @@ public:
{
Literal, // No prefix
Id, // Prefixed with %
- NamedValue, // An identifier
+ ResultMarker, // "result" (without quotes)
+ NamedValue, // Any other identifier
SlangValue,
SlangValueAddr,
SlangType,
};
+
+ // The flavour and token describes how this was parsed
Flavor flavor;
+ // The single token this came from
Token token;
+
+ // If this was a SlangValue or SlangValueAddr or SlangType, then we also
+ // store the expression, which should be a single VarExpr because we only
+ // parse single idents at the moment
Expr* expr = nullptr;
+
+ // If this is part of a bitwise or expression, this will point to the
+ // remaining operands values in such an expression must be of flavour
+ // Literal or NamedValue
+ List<SPIRVAsmOperand> bitwiseOrWith = List<SPIRVAsmOperand>();
+
+ // If this is a named value then we calculate the value here during
+ // checking. If this is an opcode, then the parser will populate this too
+ // (or set it to 0xffffffff);
+ SpvWord knownValue = 0xffffffff;
+ // Although this might be a constant in the source we should actually pass
+ // it as an id created with OpConstant
+ bool wrapInId = false;
+
+ // Once we've checked things, the SlangType flavour operands will have this
+ // type populated.
TypeExp type = TypeExp();
};