[llvm-branch-commits] [clang] [llvm] [HLSL][RootSignature] Implement Parsing of Descriptor Tables (PR #122982)
Justin Bogner via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 13 00:05:40 PST 2025
================
@@ -162,5 +219,371 @@ std::optional<RootSignatureToken> RootSignatureLexer::PeekNextToken() {
return Result;
}
+// Parser Definitions
+
+RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
+ RootSignatureLexer &Lexer,
+ DiagnosticsEngine &Diags)
+ : Elements(Elements), Lexer(Lexer), Diags(Diags) {}
+
+bool RootSignatureParser::Parse() {
+ // Handle edge-case of empty RootSignature()
+ if (Lexer.EndOfBuffer())
+ return false;
+
+ // Iterate as many RootElements as possible
+ while (!ParseRootElement()) {
+ if (Lexer.EndOfBuffer())
+ return false;
+ if (ConsumeExpectedToken(TokenKind::pu_comma))
+ return true;
+ }
+
+ return true;
+}
+
+bool RootSignatureParser::ParseRootElement() {
+ if (ConsumeExpectedToken(TokenKind::kw_DescriptorTable))
+ return true;
+
+ // Dispatch onto the correct parse method
+ switch (CurToken.Kind) {
+ case TokenKind::kw_DescriptorTable:
+ return ParseDescriptorTable();
+ default:
+ llvm_unreachable("Switch for an expected token was not provided");
----------------
bogner wrote:
An `llvm_unreachable` under a `default:` label always makes me nervous. Ideally, we could have a fully covered switch here, which would mean that if we add anything to `TokenKind` we would get warnings if we forget to update this. Is this something we could do here?
https://github.com/llvm/llvm-project/pull/122982
More information about the llvm-branch-commits
mailing list