mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Rename builtin constant_id to override
There are no downstream usages, so we can skip deprecation. Allowing the ID to be omitted will be done in a separate patch. Fixed: tint:754 Change-Id: I3bd6de4d0f426fc3c66708bfd5b411a4051b375b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49581 Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
083b591783
commit
e87ded8567
@@ -28,32 +28,32 @@ namespace {
|
||||
|
||||
const char* kWGSLReservedWords[] = {
|
||||
// Please keep this list sorted
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "constant_id", "continue",
|
||||
"default", "discard", "do",
|
||||
"else", "elseif", "entry_point",
|
||||
"enum", "f16", "f32",
|
||||
"fallthrough", "false", "fn",
|
||||
"for", "fragment", "i16",
|
||||
"i32", "i64", "i8",
|
||||
"if", "image", "import",
|
||||
"in", "let", "location",
|
||||
"loop", "mat2x2", "mat2x3",
|
||||
"mat2x4", "mat3x2", "mat3x3",
|
||||
"mat3x4", "mat4x2", "mat4x3",
|
||||
"mat4x4", "offset", "out",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "continue", "default",
|
||||
"discard", "do", "else",
|
||||
"elseif", "entry_point", "enum",
|
||||
"f16", "f32", "fallthrough",
|
||||
"false", "fn", "for",
|
||||
"fragment", "i16", "i32",
|
||||
"i64", "i8", "if",
|
||||
"image", "import", "in",
|
||||
"let", "location", "loop",
|
||||
"mat2x2", "mat2x3", "mat2x4",
|
||||
"mat3x2", "mat3x3", "mat3x4",
|
||||
"mat4x2", "mat4x3", "mat4x4",
|
||||
"offset", "out", "override",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"workgroup",
|
||||
};
|
||||
|
||||
|
||||
@@ -372,32 +372,32 @@ INSTANTIATE_TEST_SUITE_P(SpvParserTest_ReservedWords,
|
||||
SpvNamerReservedWordTest,
|
||||
::testing::ValuesIn(std::vector<std::string>{
|
||||
// Please keep this list sorted.
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "constant_id", "continue",
|
||||
"default", "discard", "do",
|
||||
"else", "elseif", "entry_point",
|
||||
"enum", "f16", "f32",
|
||||
"fallthrough", "false", "fn",
|
||||
"for", "fragment", "i16",
|
||||
"i32", "i64", "i8",
|
||||
"if", "image", "import",
|
||||
"in", "let", "location",
|
||||
"loop", "mat2x2", "mat2x3",
|
||||
"mat2x4", "mat3x2", "mat3x3",
|
||||
"mat3x4", "mat4x2", "mat4x3",
|
||||
"mat4x4", "offset", "out",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "continue", "default",
|
||||
"discard", "do", "else",
|
||||
"elseif", "entry_point", "enum",
|
||||
"f16", "f32", "fallthrough",
|
||||
"false", "fn", "for",
|
||||
"fragment", "i16", "i32",
|
||||
"i64", "i8", "if",
|
||||
"image", "import", "in",
|
||||
"let", "location", "loop",
|
||||
"mat2x2", "mat2x3", "mat2x4",
|
||||
"mat3x2", "mat3x3", "mat3x4",
|
||||
"mat4x2", "mat4x3", "mat4x4",
|
||||
"offset", "out", "override",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"workgroup",
|
||||
}));
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "source/opt/build_module.h"
|
||||
#include "src/ast/bitcast_expression.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/struct_block_decoration.h"
|
||||
#include "src/reader/spirv/function.h"
|
||||
#include "src/sem/access_control_type.h"
|
||||
@@ -1157,7 +1157,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||
ast::DecorationList spec_id_decos;
|
||||
for (const auto& deco : GetDecorationsFor(inst.result_id())) {
|
||||
if ((deco.size() == 2) && (deco[0] == SpvDecorationSpecId)) {
|
||||
auto* cid = create<ast::ConstantIdDecoration>(Source{}, deco[1]);
|
||||
auto* cid = create<ast::OverrideDecoration>(Source{}, deco[1]);
|
||||
spec_id_decos.push_back(cid);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1851,7 +1851,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_True) {
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
VariableConst{
|
||||
Decorations{
|
||||
ConstantIdDecoration{12}
|
||||
OverrideDecoration{12}
|
||||
}
|
||||
myconst
|
||||
none
|
||||
@@ -1876,7 +1876,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_False) {
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
VariableConst{
|
||||
Decorations{
|
||||
ConstantIdDecoration{12}
|
||||
OverrideDecoration{12}
|
||||
}
|
||||
myconst
|
||||
none
|
||||
@@ -1901,7 +1901,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_U32) {
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
VariableConst{
|
||||
Decorations{
|
||||
ConstantIdDecoration{12}
|
||||
OverrideDecoration{12}
|
||||
}
|
||||
myconst
|
||||
none
|
||||
@@ -1926,7 +1926,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_I32) {
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
VariableConst{
|
||||
Decorations{
|
||||
ConstantIdDecoration{12}
|
||||
OverrideDecoration{12}
|
||||
}
|
||||
myconst
|
||||
none
|
||||
@@ -1951,7 +1951,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_F32) {
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
VariableConst{
|
||||
Decorations{
|
||||
ConstantIdDecoration{12}
|
||||
OverrideDecoration{12}
|
||||
}
|
||||
myconst
|
||||
none
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#include "src/ast/bitcast_expression.h"
|
||||
#include "src/ast/break_statement.h"
|
||||
#include "src/ast/call_statement.h"
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/continue_statement.h"
|
||||
#include "src/ast/discard_statement.h"
|
||||
#include "src/ast/external_texture.h"
|
||||
#include "src/ast/fallthrough_statement.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/loop_statement.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
#include "src/ast/stage_decoration.h"
|
||||
#include "src/ast/struct_block_decoration.h"
|
||||
@@ -121,9 +121,9 @@ const char kAccessDecoration[] = "access";
|
||||
const char kBindingDecoration[] = "binding";
|
||||
const char kBlockDecoration[] = "block";
|
||||
const char kBuiltinDecoration[] = "builtin";
|
||||
const char kConstantIdDecoration[] = "constant_id";
|
||||
const char kGroupDecoration[] = "group";
|
||||
const char kLocationDecoration[] = "location";
|
||||
const char kOverrideDecoration[] = "override";
|
||||
const char kOffsetDecoration[] = "offset"; // DEPRECATED
|
||||
const char kSizeDecoration[] = "size";
|
||||
const char kAlignDecoration[] = "align";
|
||||
@@ -139,8 +139,8 @@ bool is_decoration(Token t) {
|
||||
auto s = t.to_str();
|
||||
return s == kAccessDecoration || s == kAlignDecoration ||
|
||||
s == kBindingDecoration || s == kBlockDecoration ||
|
||||
s == kBuiltinDecoration || s == kConstantIdDecoration ||
|
||||
s == kGroupDecoration || s == kLocationDecoration ||
|
||||
s == kBuiltinDecoration || s == kGroupDecoration ||
|
||||
s == kLocationDecoration || s == kOverrideDecoration ||
|
||||
s == kOffsetDecoration || s == kSetDecoration ||
|
||||
s == kSizeDecoration || s == kStageDecoration ||
|
||||
s == kStrideDecoration || s == kWorkgroupSizeDecoration;
|
||||
@@ -3102,14 +3102,14 @@ Maybe<ast::Decoration*> ParserImpl::decoration() {
|
||||
});
|
||||
}
|
||||
|
||||
if (s == kConstantIdDecoration) {
|
||||
const char* use = "constant_id decoration";
|
||||
if (s == kOverrideDecoration) {
|
||||
const char* use = "override decoration";
|
||||
return expect_paren_block(use, [&]() -> Result {
|
||||
auto val = expect_positive_sint(use);
|
||||
if (val.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return create<ast::ConstantIdDecoration>(t.source(), val.value);
|
||||
return create<ast::OverrideDecoration>(t.source(), val.value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/ast/constant_id_decoration.h"
|
||||
#include "src/ast/override_decoration.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -45,7 +45,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
||||
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
||||
|
||||
EXPECT_FALSE(
|
||||
ast::HasDecoration<ast::ConstantIdDecoration>(e.value->decorations()));
|
||||
ast::HasDecoration<ast::OverrideDecoration>(e.value->decorations()));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
||||
@@ -100,8 +100,8 @@ TEST_F(ParserImplTest, GlobalConstantDecl_MissingExpression) {
|
||||
EXPECT_EQ(p->error(), "1:14: unable to parse constant literal");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) {
|
||||
auto p = parser("[[constant_id(7)]] let a : f32 = 1.");
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_WithId) {
|
||||
auto p = parser("[[override(7)]] let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
@@ -118,20 +118,20 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) {
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 24u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 21u);
|
||||
EXPECT_EQ(e->source().range.end.line, 1u);
|
||||
EXPECT_EQ(e->source().range.end.column, 25u);
|
||||
EXPECT_EQ(e->source().range.end.column, 22u);
|
||||
|
||||
ASSERT_NE(e->constructor(), nullptr);
|
||||
EXPECT_TRUE(e->constructor()->Is<ast::ConstructorExpression>());
|
||||
|
||||
EXPECT_TRUE(
|
||||
ast::HasDecoration<ast::ConstantIdDecoration>(e.value->decorations()));
|
||||
ast::HasDecoration<ast::OverrideDecoration>(e.value->decorations()));
|
||||
EXPECT_EQ(e.value->constant_id(), 7u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Missing) {
|
||||
auto p = parser("[[constant_id()]] let a : f32 = 1.");
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_MissingId) {
|
||||
auto p = parser("[[override()]] let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
@@ -143,11 +143,11 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Missing) {
|
||||
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:15: expected signed integer literal for constant_id decoration");
|
||||
"1:12: expected signed integer literal for override decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Invalid) {
|
||||
auto p = parser("[[constant_id(-7)]] let a : f32 = 1.");
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_InvalidId) {
|
||||
auto p = parser("[[override(-7)]] let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
@@ -158,10 +158,10 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Invalid) {
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:15: constant_id decoration must be positive");
|
||||
EXPECT_EQ(p->error(), "1:12: override decoration must be positive");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_ConstantId_Const) {
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Const) {
|
||||
auto p = parser("const a : i32 = 1");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
||||
Reference in New Issue
Block a user