Skip to content

Commit 182d1af

Browse files
committed
review: rename RootParam to RootDescriptor
1 parent fc2fc60 commit 182d1af

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class RootSignatureParser {
7373
/// Root Element parse methods:
7474
std::optional<llvm::hlsl::rootsig::RootFlags> parseRootFlags();
7575
std::optional<llvm::hlsl::rootsig::RootConstants> parseRootConstants();
76-
std::optional<llvm::hlsl::rootsig::RootParam> parseRootParam();
76+
std::optional<llvm::hlsl::rootsig::RootDescriptor> parseRootDescriptor();
7777
std::optional<llvm::hlsl::rootsig::DescriptorTable> parseDescriptorTable();
7878
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>
7979
parseDescriptorTableClause();

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ bool RootSignatureParser::parse() {
5050

5151
if (tryConsumeExpectedToken(
5252
{TokenKind::kw_CBV, TokenKind::kw_SRV, TokenKind::kw_UAV})) {
53-
auto RootParam = parseRootParam();
54-
if (!RootParam.has_value())
53+
auto Descriptor = parseRootDescriptor();
54+
if (!Descriptor.has_value())
5555
return true;
56-
Elements.push_back(*RootParam);
56+
Elements.push_back(*Descriptor);
5757
}
5858
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
5959

@@ -163,30 +163,30 @@ std::optional<RootConstants> RootSignatureParser::parseRootConstants() {
163163
return Constants;
164164
}
165165

166-
std::optional<RootParam> RootSignatureParser::parseRootParam() {
166+
std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
167167
assert((CurToken.TokKind == TokenKind::kw_CBV ||
168168
CurToken.TokKind == TokenKind::kw_SRV ||
169169
CurToken.TokKind == TokenKind::kw_UAV) &&
170170
"Expects to only be invoked starting at given keyword");
171171

172-
TokenKind ParamKind = CurToken.TokKind;
172+
TokenKind DescriptorKind = CurToken.TokKind;
173173

174174
if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
175175
CurToken.TokKind))
176176
return std::nullopt;
177177

178-
RootParam Param;
179-
switch (ParamKind) {
178+
RootDescriptor Descriptor;
179+
switch (DescriptorKind) {
180180
default:
181181
llvm_unreachable("Switch for consumed token was not provided");
182182
case TokenKind::kw_CBV:
183-
Param.Type = ParamType::CBuffer;
183+
Descriptor.Type = DescriptorType::CBuffer;
184184
break;
185185
case TokenKind::kw_SRV:
186-
Param.Type = ParamType::SRV;
186+
Descriptor.Type = DescriptorType::SRV;
187187
break;
188188
case TokenKind::kw_UAV:
189-
Param.Type = ParamType::UAV;
189+
Descriptor.Type = DescriptorType::UAV;
190190
break;
191191
}
192192

@@ -195,7 +195,7 @@ std::optional<RootParam> RootSignatureParser::parseRootParam() {
195195
/*param of=*/TokenKind::kw_RootConstants))
196196
return std::nullopt;
197197

198-
return Param;
198+
return Descriptor;
199199
}
200200

201201
std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
344344
ASSERT_TRUE(Consumer->isSatisfied());
345345
}
346346

347-
TEST_F(ParseHLSLRootSignatureTest, ValidParseRootParamsTest) {
347+
TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
348348
const llvm::StringLiteral Source = R"cc(
349349
CBV(),
350350
SRV(),
@@ -367,16 +367,16 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootParamsTest) {
367367
ASSERT_EQ(Elements.size(), 3u);
368368

369369
RootElement Elem = Elements[0];
370-
ASSERT_TRUE(std::holds_alternative<RootParam>(Elem));
371-
ASSERT_EQ(std::get<RootParam>(Elem).Type, ParamType::CBuffer);
370+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
371+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, ParamType::CBuffer);
372372

373373
Elem = Elements[1];
374-
ASSERT_TRUE(std::holds_alternative<RootParam>(Elem));
375-
ASSERT_EQ(std::get<RootParam>(Elem).Type, ParamType::SRV);
374+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
375+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, ParamType::SRV);
376376

377377
Elem = Elements[2];
378-
ASSERT_TRUE(std::holds_alternative<RootParam>(Elem));
379-
ASSERT_EQ(std::get<RootParam>(Elem).Type, ParamType::UAV);
378+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
379+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, ParamType::UAV);
380380

381381
ASSERT_TRUE(Consumer->isSatisfied());
382382
}

llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ struct RootConstants {
8585
ShaderVisibility Visibility = ShaderVisibility::All;
8686
};
8787

88-
using ParamType = llvm::dxil::ResourceClass;
89-
struct RootParam {
90-
ParamType Type;
88+
using DescriptorType = llvm::dxil::ResourceClass;
89+
// Models RootDescriptor : CBV | SRV | UAV, by collecting like parameters
90+
struct RootDescriptor {
91+
DescriptorType Type;
9192
};
9293

9394
// Models the end of a descriptor table and stores its visibility
@@ -130,7 +131,7 @@ struct DescriptorTableClause {
130131
void dump(raw_ostream &OS) const;
131132
};
132133

133-
/// Models RootElement : RootFlags | RootConstants | RootParam
134+
/// Models RootElement : RootFlags | RootConstants | RootDescriptor
134135
/// | DescriptorTable | DescriptorTableClause
135136
///
136137
/// A Root Signature is modeled in-memory by an array of RootElements. These
@@ -145,8 +146,9 @@ struct DescriptorTableClause {
145146
/// The DescriptorTable is modelled by having its Clauses as the previous
146147
/// RootElements in the array, and it holds a data member for the Visibility
147148
/// parameter.
148-
using RootElement = std::variant<RootFlags, RootConstants, RootParam,
149+
using RootElement = std::variant<RootFlags, RootConstants, RootDescriptor,
149150
DescriptorTable, DescriptorTableClause>;
151+
150152
void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements);
151153

152154
class MetadataBuilder {

0 commit comments

Comments
 (0)