tint/reader/spirv: Generate 'i' suffixed literals
For all i32 literal values.
Reduces risk of the SPIR-V reader producing WGSL that behaves
differently, when abstract-integers are fully implemented.
Bug: tint:1504
Change-Id: Ieaf8afec5b09c7978c75a38c6ed144633ddc017e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88843
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc
index ef3d7f0..f2fa3a4 100644
--- a/src/tint/reader/spirv/function.cc
+++ b/src/tint/reader/spirv/function.cc
@@ -2989,9 +2989,9 @@
selectors.emplace_back(create<ast::IntLiteralExpression>(
Source{}, value32, ast::IntLiteralExpression::Suffix::kU));
} else {
- selectors.emplace_back(create<ast::IntLiteralExpression>(
- Source{}, static_cast<int32_t>(value32),
- ast::IntLiteralExpression::Suffix::kNone));
+ selectors.emplace_back(
+ create<ast::IntLiteralExpression>(Source{}, static_cast<int32_t>(value32),
+ ast::IntLiteralExpression::Suffix::kI));
}
}
}
diff --git a/src/tint/reader/spirv/function_arithmetic_test.cc b/src/tint/reader/spirv/function_arithmetic_test.cc
index c82e19f..9db49d9 100644
--- a/src/tint/reader/spirv/function_arithmetic_test.cc
+++ b/src/tint/reader/spirv/function_arithmetic_test.cc
@@ -81,16 +81,16 @@
return "vec2<u32>(20u, 10u)";
}
if (assembly == "v2int_30_40") {
- return "vec2<i32>(30, 40)";
+ return "vec2<i32>(30i, 40i)";
}
if (assembly == "v2int_40_30") {
- return "vec2<i32>(40, 30)";
+ return "vec2<i32>(40i, 30i)";
}
if (assembly == "cast_int_v2uint_10_20") {
return "bitcast<vec2<i32>>(vec2<u32>(10u, 20u))";
}
if (assembly == "cast_uint_v2int_40_30") {
- return "bitcast<vec2<u32>>(vec2<i32>(40, 30))";
+ return "bitcast<vec2<u32>>(vec2<i32>(40i, 30i))";
}
if (assembly == "v2float_50_60") {
return "vec2<f32>(50.0, 60.0)";
@@ -116,7 +116,7 @@
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
- EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : i32 = -(30);"));
+ EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : i32 = -(30i);"));
}
TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
@@ -150,7 +150,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : u32 = bitcast<u32>(-(30));"));
+ HasSubstr("let x_1 : u32 = bitcast<u32>(-(30i));"));
}
TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
@@ -184,7 +184,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : vec2<i32> = -(vec2<i32>(30, 40));"));
+ HasSubstr("let x_1 : vec2<i32> = -(vec2<i32>(30i, 40i));"));
}
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
@@ -218,7 +218,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : vec2<u32> = bitcast<vec2<u32>>(-(vec2<i32>(30, 40)));"));
+ HasSubstr("let x_1 : vec2<u32> = bitcast<vec2<u32>>(-(vec2<i32>(30i, 40i)));"));
}
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
@@ -359,7 +359,7 @@
::testing::Values(
// Both uint
BinaryData{"uint", "uint_10", "OpIAdd", "uint_20", "u32", "10u", "+", "20u"}, // Both int
- BinaryData{"int", "int_30", "OpIAdd", "int_40", "i32", "30", "+", "40"}, // Both v2uint
+ BinaryData{"int", "int_30", "OpIAdd", "int_40", "i32", "30i", "+", "40i"}, // Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpIAdd", "v2uint_20_10", "vec2<u32>",
AstFor("v2uint_10_20"), "+", AstFor("v2uint_20_10")},
// Both v2int
@@ -372,22 +372,23 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpIAdd", "uint_10", "u32",
- "bitcast<u32>((30 + bitcast<i32>(10u)))"},
+ "bitcast<u32>((30i + bitcast<i32>(10u)))"},
// Mixed, int <- int uint
- BinaryDataGeneral{"int", "int_30", "OpIAdd", "uint_10", "i32", "(30 + bitcast<i32>(10u))"},
+ BinaryDataGeneral{"int", "int_30", "OpIAdd", "uint_10", "i32", "(30i + bitcast<i32>(10u))"},
// Mixed, uint <- uint int
- BinaryDataGeneral{"uint", "uint_10", "OpIAdd", "int_30", "u32", "(10u + bitcast<u32>(30))"},
+ BinaryDataGeneral{"uint", "uint_10", "OpIAdd", "int_30", "u32",
+ "(10u + bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpIAdd", "uint_10", "i32",
"bitcast<i32>((20u + 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpIAdd", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) + bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) + bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpIAdd", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) + bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) + bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FAdd,
SpvBinaryArithTest,
@@ -405,7 +406,7 @@
::testing::Values(
// Both uint
BinaryData{"uint", "uint_10", "OpISub", "uint_20", "u32", "10u", "-", "20u"}, // Both int
- BinaryData{"int", "int_30", "OpISub", "int_40", "i32", "30", "-", "40"}, // Both v2uint
+ BinaryData{"int", "int_30", "OpISub", "int_40", "i32", "30i", "-", "40i"}, // Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpISub", "v2uint_20_10", "vec2<u32>",
AstFor("v2uint_10_20"), "-", AstFor("v2uint_20_10")},
// Both v2int
@@ -418,22 +419,23 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpISub", "uint_10", "u32",
- R"(bitcast<u32>((30 - bitcast<i32>(10u))))"},
+ R"(bitcast<u32>((30i - bitcast<i32>(10u))))"},
// Mixed, int <- int uint
- BinaryDataGeneral{"int", "int_30", "OpISub", "uint_10", "i32", "(30 - bitcast<i32>(10u))"},
+ BinaryDataGeneral{"int", "int_30", "OpISub", "uint_10", "i32", "(30i - bitcast<i32>(10u))"},
// Mixed, uint <- uint int
- BinaryDataGeneral{"uint", "uint_10", "OpISub", "int_30", "u32", "(10u - bitcast<u32>(30))"},
+ BinaryDataGeneral{"uint", "uint_10", "OpISub", "int_30", "u32",
+ "(10u - bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpISub", "uint_10", "i32",
"bitcast<i32>((20u - 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpISub", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) - bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) - bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpISub", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) - bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) - bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FSub,
SpvBinaryArithTest,
@@ -451,7 +453,7 @@
::testing::Values(
// Both uint
BinaryData{"uint", "uint_10", "OpIMul", "uint_20", "u32", "10u", "*", "20u"}, // Both int
- BinaryData{"int", "int_30", "OpIMul", "int_40", "i32", "30", "*", "40"}, // Both v2uint
+ BinaryData{"int", "int_30", "OpIMul", "int_40", "i32", "30i", "*", "40i"}, // Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpIMul", "v2uint_20_10", "vec2<u32>",
AstFor("v2uint_10_20"), "*", AstFor("v2uint_20_10")},
// Both v2int
@@ -464,22 +466,23 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpIMul", "uint_10", "u32",
- "bitcast<u32>((30 * bitcast<i32>(10u)))"},
+ "bitcast<u32>((30i * bitcast<i32>(10u)))"},
// Mixed, int <- int uint
- BinaryDataGeneral{"int", "int_30", "OpIMul", "uint_10", "i32", "(30 * bitcast<i32>(10u))"},
+ BinaryDataGeneral{"int", "int_30", "OpIMul", "uint_10", "i32", "(30i * bitcast<i32>(10u))"},
// Mixed, uint <- uint int
- BinaryDataGeneral{"uint", "uint_10", "OpIMul", "int_30", "u32", "(10u * bitcast<u32>(30))"},
+ BinaryDataGeneral{"uint", "uint_10", "OpIMul", "int_30", "u32",
+ "(10u * bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpIMul", "uint_10", "i32",
"bitcast<i32>((20u * 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpIMul", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) * bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) * bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpIMul", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) * bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) * bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FMul,
SpvBinaryArithTest,
@@ -506,7 +509,7 @@
SpvBinaryArithTest,
::testing::Values(
// Both int
- BinaryData{"int", "int_30", "OpSDiv", "int_40", "i32", "30", "/", "40"}, // Both v2int
+ BinaryData{"int", "int_30", "OpSDiv", "int_40", "i32", "30i", "/", "40i"}, // Both v2int
BinaryData{"v2int", "v2int_30_40", "OpSDiv", "v2int_40_30", "vec2<i32>",
AstFor("v2int_30_40"), "/", AstFor("v2int_40_30")}));
@@ -515,10 +518,10 @@
SpvBinaryArithTest,
::testing::Values(
// Mixed, returning int, second arg uint
- BinaryData{"int", "int_30", "OpSDiv", "uint_10", "i32", "30", "/", "bitcast<i32>(10u)"},
+ BinaryData{"int", "int_30", "OpSDiv", "uint_10", "i32", "30i", "/", "bitcast<i32>(10u)"},
// Mixed, returning int, first arg uint
BinaryData{"int", "uint_10", "OpSDiv", "int_30", "i32", "bitcast<i32>(10u)", "/",
- "30"}, // Mixed, returning v2int, first arg v2uint
+ "30i"}, // Mixed, returning v2int, first arg v2uint
BinaryData{"v2int", "v2uint_10_20", "OpSDiv", "v2int_30_40", "vec2<i32>",
AstFor("cast_int_v2uint_10_20"), "/", AstFor("v2int_30_40")},
// Mixed, returning v2int, second arg v2uint
@@ -543,7 +546,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : u32 = bitcast<u32>((30 / 40));"));
+ HasSubstr("let x_1 : u32 = bitcast<u32>((30i / 40i));"));
}
TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
@@ -566,7 +569,7 @@
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr(
- R"(let x_1 : vec2<u32> = bitcast<vec2<u32>>((vec2<i32>(30, 40) / vec2<i32>(40, 30)));)"));
+ R"(let x_1 : vec2<u32> = bitcast<vec2<u32>>((vec2<i32>(30i, 40i) / vec2<i32>(40i, 30i)));)"));
}
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FDiv,
@@ -597,7 +600,7 @@
SpvBinaryArithTest,
::testing::Values(
// Both int
- BinaryData{"int", "int_30", "OpSMod", "int_40", "i32", "30", "%", "40"}, // Both v2int
+ BinaryData{"int", "int_30", "OpSMod", "int_40", "i32", "30i", "%", "40i"}, // Both v2int
BinaryData{"v2int", "v2int_30_40", "OpSMod", "v2int_40_30", "vec2<i32>",
AstFor("v2int_30_40"), "%", AstFor("v2int_40_30")}));
@@ -606,10 +609,10 @@
SpvBinaryArithTest,
::testing::Values(
// Mixed, returning int, second arg uint
- BinaryData{"int", "int_30", "OpSMod", "uint_10", "i32", "30", "%", "bitcast<i32>(10u)"},
+ BinaryData{"int", "int_30", "OpSMod", "uint_10", "i32", "30i", "%", "bitcast<i32>(10u)"},
// Mixed, returning int, first arg uint
BinaryData{"int", "uint_10", "OpSMod", "int_30", "i32", "bitcast<i32>(10u)", "%",
- "30"}, // Mixed, returning v2int, first arg v2uint
+ "30i"}, // Mixed, returning v2int, first arg v2uint
BinaryData{"v2int", "v2uint_10_20", "OpSMod", "v2int_30_40", "vec2<i32>",
AstFor("cast_int_v2uint_10_20"), "%", AstFor("v2int_30_40")},
// Mixed, returning v2int, second arg v2uint
@@ -634,7 +637,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : u32 = bitcast<u32>((30 % 40));"));
+ HasSubstr("let x_1 : u32 = bitcast<u32>((30i % 40i));"));
}
TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
@@ -657,7 +660,7 @@
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr(
- R"(let x_1 : vec2<u32> = bitcast<vec2<u32>>((vec2<i32>(30, 40) % vec2<i32>(40, 30)));)"));
+ R"(let x_1 : vec2<u32> = bitcast<vec2<u32>>((vec2<i32>(30i, 40i) % vec2<i32>(40i, 30i)));)"));
}
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FRem,
diff --git a/src/tint/reader/spirv/function_bit_test.cc b/src/tint/reader/spirv/function_bit_test.cc
index 7f63cb0..a8e97b3 100644
--- a/src/tint/reader/spirv/function_bit_test.cc
+++ b/src/tint/reader/spirv/function_bit_test.cc
@@ -72,10 +72,10 @@
return "vec2<u32>(20u, 10u)";
}
if (assembly == "v2int_30_40") {
- return "vec2<i32>(30, 40)";
+ return "vec2<i32>(30i, 40i)";
}
if (assembly == "v2int_40_30") {
- return "vec2<i32>(40, 30)";
+ return "vec2<i32>(40i, 30i)";
}
if (assembly == "cast_int_v2uint_10_20") {
return "bitcast<vec2<i32>(vec2<u32>(10u, 20u))";
@@ -177,7 +177,7 @@
// uint uint -> uint
BinaryData{"uint", "uint_10", "OpShiftLeftLogical", "uint_20", "u32", "10u", "<<", "20u"},
// int, uint -> int
- BinaryData{"int", "int_30", "OpShiftLeftLogical", "uint_20", "i32", "30", "<<", "20u"},
+ BinaryData{"int", "int_30", "OpShiftLeftLogical", "uint_20", "i32", "30i", "<<", "20u"},
// v2uint v2uint -> v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpShiftLeftLogical", "v2uint_20_10", "vec2<u32>",
AstFor("v2uint_10_20"), "<<", AstFor("v2uint_20_10")},
@@ -192,16 +192,16 @@
::testing::Values(
// int, int -> int
BinaryDataGeneral{"int", "int_30", "OpShiftLeftLogical", "int_40", "i32",
- "(30 << bitcast<u32>(40))"},
+ "(30i << bitcast<u32>(40i))"},
// uint, int -> uint
BinaryDataGeneral{"uint", "uint_10", "OpShiftLeftLogical", "int_40", "u32",
- "(10u << bitcast<u32>(40))"},
+ "(10u << bitcast<u32>(40i))"},
// v2uint, v2int -> v2uint
BinaryDataGeneral{"v2uint", "v2uint_10_20", "OpShiftLeftLogical", "v2uint_20_10",
"vec2<u32>", "(vec2<u32>(10u, 20u) << vec2<u32>(20u, 10u))"},
// v2int, v2int -> v2int
BinaryDataGeneral{"v2int", "v2int_30_40", "OpShiftLeftLogical", "v2int_40_30", "vec2<i32>",
- "(vec2<i32>(30, 40) << bitcast<vec2<u32>>(vec2<i32>(40, 30)))"}));
+ "(vec2<i32>(30i, 40i) << bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftLeftLogical_BitcastResult,
@@ -209,11 +209,11 @@
::testing::Values(
// int, int -> uint
BinaryDataGeneral{"uint", "int_30", "OpShiftLeftLogical", "uint_10", "u32",
- "bitcast<u32>((30 << 10u))"},
+ "bitcast<u32>((30i << 10u))"},
// v2uint, v2int -> v2uint
BinaryDataGeneral{"v2uint", "v2int_30_40", "OpShiftLeftLogical", "v2uint_20_10",
"vec2<u32>",
- "bitcast<vec2<u32>>((vec2<i32>(30, 40) << vec2<u32>(20u, 10u)))"}));
+ "bitcast<vec2<u32>>((vec2<i32>(30i, 40i) << vec2<u32>(20u, 10u)))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftRightLogical_Arg2Unsigned,
@@ -224,14 +224,14 @@
"(10u >> 20u)"},
// int, uint -> int
BinaryDataGeneral{"int", "int_30", "OpShiftRightLogical", "uint_20", "i32",
- "bitcast<i32>((bitcast<u32>(30) >> 20u))"},
+ "bitcast<i32>((bitcast<u32>(30i) >> 20u))"},
// v2uint, v2uint -> v2uint
BinaryDataGeneral{"v2uint", "v2uint_10_20", "OpShiftRightLogical", "v2uint_20_10",
"vec2<u32>", "(vec2<u32>(10u, 20u) >> vec2<u32>(20u, 10u))"},
// v2int, v2uint -> v2int
BinaryDataGeneral{
"v2int", "v2int_30_40", "OpShiftRightLogical", "v2uint_10_20", "vec2<i32>",
- R"(bitcast<vec2<i32>>((bitcast<vec2<u32>>(vec2<i32>(30, 40)) >> vec2<u32>(10u, 20u))))"}));
+ R"(bitcast<vec2<i32>>((bitcast<vec2<u32>>(vec2<i32>(30i, 40i)) >> vec2<u32>(10u, 20u))))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftRightLogical_Arg2Signed,
@@ -239,18 +239,18 @@
::testing::Values(
// uint, int -> uint
BinaryDataGeneral{"uint", "uint_10", "OpShiftRightLogical", "int_30", "u32",
- "(10u >> bitcast<u32>(30))"},
+ "(10u >> bitcast<u32>(30i))"},
// int, int -> int
BinaryDataGeneral{"int", "int_30", "OpShiftRightLogical", "int_40", "i32",
- "bitcast<i32>((bitcast<u32>(30) >> bitcast<u32>(40)))"},
+ "bitcast<i32>((bitcast<u32>(30i) >> bitcast<u32>(40i)))"},
// v2uint, v2int -> v2uint
BinaryDataGeneral{"v2uint", "v2uint_10_20", "OpShiftRightLogical", "v2int_30_40",
"vec2<u32>",
- "(vec2<u32>(10u, 20u) >> bitcast<vec2<u32>>(vec2<i32>(30, 40)))"},
+ "(vec2<u32>(10u, 20u) >> bitcast<vec2<u32>>(vec2<i32>(30i, 40i)))"},
// v2int, v2int -> v2int
BinaryDataGeneral{
"v2int", "v2int_40_30", "OpShiftRightLogical", "v2int_30_40", "vec2<i32>",
- R"(bitcast<vec2<i32>>((bitcast<vec2<u32>>(vec2<i32>(40, 30)) >> bitcast<vec2<u32>>(vec2<i32>(30, 40)))))"}));
+ R"(bitcast<vec2<i32>>((bitcast<vec2<u32>>(vec2<i32>(40i, 30i)) >> bitcast<vec2<u32>>(vec2<i32>(30i, 40i)))))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftRightLogical_BitcastResult,
@@ -273,14 +273,14 @@
"bitcast<u32>((bitcast<i32>(10u) >> 20u))"},
// int, uint -> int
BinaryDataGeneral{"int", "int_30", "OpShiftRightArithmetic", "uint_10", "i32",
- "(30 >> 10u)"},
+ "(30i >> 10u)"},
// v2uint, v2uint -> v2uint
BinaryDataGeneral{
"v2uint", "v2uint_10_20", "OpShiftRightArithmetic", "v2uint_20_10", "vec2<u32>",
R"(bitcast<vec2<u32>>((bitcast<vec2<i32>>(vec2<u32>(10u, 20u)) >> vec2<u32>(20u, 10u))))"},
// v2int, v2uint -> v2int
BinaryDataGeneral{"v2int", "v2int_40_30", "OpShiftRightArithmetic", "v2uint_20_10",
- "vec2<i32>", "(vec2<i32>(40, 30) >> vec2<u32>(20u, 10u))"}));
+ "vec2<i32>", "(vec2<i32>(40i, 30i) >> vec2<u32>(20u, 10u))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftRightArithmetic_Arg2Signed,
@@ -288,18 +288,18 @@
::testing::Values(
// uint, int -> uint
BinaryDataGeneral{"uint", "uint_10", "OpShiftRightArithmetic", "int_30", "u32",
- "bitcast<u32>((bitcast<i32>(10u) >> bitcast<u32>(30)))"},
+ "bitcast<u32>((bitcast<i32>(10u) >> bitcast<u32>(30i)))"},
// int, int -> int
BinaryDataGeneral{"int", "int_30", "OpShiftRightArithmetic", "int_40", "i32",
- "(30 >> bitcast<u32>(40))"},
+ "(30i >> bitcast<u32>(40i))"},
// v2uint, v2int -> v2uint
BinaryDataGeneral{
"v2uint", "v2uint_10_20", "OpShiftRightArithmetic", "v2int_30_40", "vec2<u32>",
- R"(bitcast<vec2<u32>>((bitcast<vec2<i32>>(vec2<u32>(10u, 20u)) >> bitcast<vec2<u32>>(vec2<i32>(30, 40)))))"},
+ R"(bitcast<vec2<u32>>((bitcast<vec2<i32>>(vec2<u32>(10u, 20u)) >> bitcast<vec2<u32>>(vec2<i32>(30i, 40i)))))"},
// v2int, v2int -> v2int
BinaryDataGeneral{"v2int", "v2int_40_30", "OpShiftRightArithmetic", "v2int_30_40",
"vec2<i32>",
- "(vec2<i32>(40, 30) >> bitcast<vec2<u32>>(vec2<i32>(30, 40)))"}));
+ "(vec2<i32>(40i, 30i) >> bitcast<vec2<u32>>(vec2<i32>(30i, 40i)))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftRightArithmetic_BitcastResult,
@@ -307,11 +307,11 @@
::testing::Values(
// int, uint -> uint
BinaryDataGeneral{"uint", "int_30", "OpShiftRightArithmetic", "uint_10", "u32",
- "bitcast<u32>((30 >> 10u))"},
+ "bitcast<u32>((30i >> 10u))"},
// v2int, v2uint -> v2uint
BinaryDataGeneral{"v2uint", "v2int_30_40", "OpShiftRightArithmetic", "v2uint_20_10",
"vec2<u32>",
- "bitcast<vec2<u32>>((vec2<i32>(30, 40) >> vec2<u32>(20u, 10u)))"}));
+ "bitcast<vec2<u32>>((vec2<i32>(30i, 40i) >> vec2<u32>(20u, 10u)))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_BitwiseAnd,
@@ -320,7 +320,7 @@
// Both uint
BinaryData{"uint", "uint_10", "OpBitwiseAnd", "uint_20", "u32", "10u", "&", "20u"},
// Both int
- BinaryData{"int", "int_30", "OpBitwiseAnd", "int_40", "i32", "30", "&", "40"},
+ BinaryData{"int", "int_30", "OpBitwiseAnd", "int_40", "i32", "30i", "&", "40i"},
// TODO(crbug.com/tint/678): Resolver fails on vector bitwise operations
// Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpBitwiseAnd", "v2uint_20_10", "vec2<u32>",
@@ -335,24 +335,24 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpBitwiseAnd", "uint_10", "u32",
- "bitcast<u32>((30 & bitcast<i32>(10u)))"},
+ "bitcast<u32>((30i & bitcast<i32>(10u)))"},
// Mixed, int <- int uint
BinaryDataGeneral{"int", "int_30", "OpBitwiseAnd", "uint_10", "i32",
- "(30 & bitcast<i32>(10u))"},
+ "(30i & bitcast<i32>(10u))"},
// Mixed, uint <- uint int
BinaryDataGeneral{"uint", "uint_10", "OpBitwiseAnd", "int_30", "u32",
- "(10u & bitcast<u32>(30))"},
+ "(10u & bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpBitwiseAnd", "uint_10", "i32",
"bitcast<i32>((20u & 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpBitwiseAnd", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) & bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) & bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpBitwiseAnd", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) & bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) & bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_BitwiseOr,
@@ -361,7 +361,7 @@
// Both uint
BinaryData{"uint", "uint_10", "OpBitwiseOr", "uint_20", "u32", "10u", "|", "20u"},
// Both int
- BinaryData{"int", "int_30", "OpBitwiseOr", "int_40", "i32", "30", "|", "40"},
+ BinaryData{"int", "int_30", "OpBitwiseOr", "int_40", "i32", "30i", "|", "40i"},
// TODO(crbug.com/tint/678): Resolver fails on vector bitwise operations
// Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpBitwiseOr", "v2uint_20_10", "vec2<u32>",
@@ -376,24 +376,24 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpBitwiseOr", "uint_10", "u32",
- "bitcast<u32>((30 | bitcast<i32>(10u)))"},
+ "bitcast<u32>((30i | bitcast<i32>(10u)))"},
// Mixed, int <- int uint
BinaryDataGeneral{"int", "int_30", "OpBitwiseOr", "uint_10", "i32",
- "(30 | bitcast<i32>(10u))"},
+ "(30i | bitcast<i32>(10u))"},
// Mixed, uint <- uint int
BinaryDataGeneral{"uint", "uint_10", "OpBitwiseOr", "int_30", "u32",
- "(10u | bitcast<u32>(30))"},
+ "(10u | bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpBitwiseOr", "uint_10", "i32",
"bitcast<i32>((20u | 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpBitwiseOr", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) | bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) | bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpBitwiseOr", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) | bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) | bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_BitwiseXor,
@@ -402,7 +402,7 @@
// Both uint
BinaryData{"uint", "uint_10", "OpBitwiseXor", "uint_20", "u32", "10u", "^", "20u"},
// Both int
- BinaryData{"int", "int_30", "OpBitwiseXor", "int_40", "i32", "30", "^", "40"},
+ BinaryData{"int", "int_30", "OpBitwiseXor", "int_40", "i32", "30i", "^", "40i"},
// TODO(crbug.com/tint/678): Resolver fails on vector bitwise operations
// Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpBitwiseXor", "v2uint_20_10", "vec2<u32>",
@@ -417,24 +417,24 @@
::testing::Values(
// Mixed, uint <- int uint
BinaryDataGeneral{"uint", "int_30", "OpBitwiseXor", "uint_10", "u32",
- "bitcast<u32>((30 ^ bitcast<i32>(10u)))"},
+ "bitcast<u32>((30i ^ bitcast<i32>(10u)))"},
// Mixed, int <- int uint
BinaryDataGeneral{"int", "int_30", "OpBitwiseXor", "uint_10", "i32",
- "(30 ^ bitcast<i32>(10u))"},
+ "(30i ^ bitcast<i32>(10u))"},
// Mixed, uint <- uint int
BinaryDataGeneral{"uint", "uint_10", "OpBitwiseXor", "int_30", "u32",
- "(10u ^ bitcast<u32>(30))"},
+ "(10u ^ bitcast<u32>(30i))"},
// Mixed, int <- uint uint
BinaryDataGeneral{"int", "uint_20", "OpBitwiseXor", "uint_10", "i32",
"bitcast<i32>((20u ^ 10u))"},
// Mixed, returning v2uint
BinaryDataGeneral{
"v2uint", "v2int_30_40", "OpBitwiseXor", "v2uint_10_20", "vec2<u32>",
- R"(bitcast<vec2<u32>>((vec2<i32>(30, 40) ^ bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
+ R"(bitcast<vec2<u32>>((vec2<i32>(30i, 40i) ^ bitcast<vec2<i32>>(vec2<u32>(10u, 20u)))))"},
// Mixed, returning v2int
BinaryDataGeneral{
"v2int", "v2uint_10_20", "OpBitwiseXor", "v2int_40_30", "vec2<i32>",
- R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) ^ bitcast<vec2<u32>>(vec2<i32>(40, 30)))))"}));
+ R"(bitcast<vec2<i32>>((vec2<u32>(10u, 20u) ^ bitcast<vec2<u32>>(vec2<i32>(40i, 30i)))))"}));
TEST_F(SpvUnaryBitTest, Not_Int_Int) {
const auto assembly = SimplePreamble() + R"(
@@ -450,7 +450,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : i32 = ~(30);"));
+ EXPECT_THAT(body, HasSubstr("let x_1 : i32 = ~(30i);"));
}
TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
@@ -484,7 +484,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : u32 = bitcast<u32>(~(30));"));
+ EXPECT_THAT(body, HasSubstr("let x_1 : u32 = bitcast<u32>(~(30i));"));
}
TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
@@ -518,7 +518,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = ~(vec2<i32>(30, 40));"));
+ EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = ~(vec2<i32>(30i, 40i));"));
}
TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
@@ -553,7 +553,8 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : vec2<u32> = bitcast<vec2<u32>>(~(vec2<i32>(30, 40)));"));
+ EXPECT_THAT(body,
+ HasSubstr("let x_1 : vec2<u32> = bitcast<vec2<u32>>(~(vec2<i32>(30i, 40i)));"));
}
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
const auto assembly = SimplePreamble() + R"(
@@ -840,7 +841,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = insertBits(30, 40, 10u, 20u);")) << body;
+ EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = insertBits(30i, 40i, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_IntVector) {
@@ -858,7 +859,7 @@
EXPECT_THAT(
body,
HasSubstr(
- R"(let x_1 : vec2<i32> = insertBits(vec2<i32>(30, 40), vec2<i32>(40, 30), 10u, 20u);)"))
+ R"(let x_1 : vec2<i32> = insertBits(vec2<i32>(30i, 40i), vec2<i32>(40i, 30i), 10u, 20u);)"))
<< body;
}
@@ -908,7 +909,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = extractBits(30, 10u, 20u);")) << body;
+ EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = extractBits(30i, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_IntVector) {
@@ -923,7 +924,8 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
- EXPECT_THAT(body, HasSubstr("let x_1 : vec2<i32> = extractBits(vec2<i32>(30, 40), 10u, 20u);"))
+ EXPECT_THAT(body,
+ HasSubstr("let x_1 : vec2<i32> = extractBits(vec2<i32>(30i, 40i), 10u, 20u);"))
<< body;
}
diff --git a/src/tint/reader/spirv/function_cfg_test.cc b/src/tint/reader/spirv/function_cfg_test.cc
index 6526667..edeea55 100644
--- a/src/tint/reader/spirv/function_cfg_test.cc
+++ b/src/tint/reader/spirv/function_cfg_test.cc
@@ -9392,14 +9392,14 @@
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var_1 = 1u;
-switch(42) {
- case -294967296: {
+switch(42i) {
+ case -294967296i: {
var_1 = 40u;
}
- case 2000000000: {
+ case 2000000000i: {
var_1 = 30u;
}
- case 20: {
+ case 20i: {
var_1 = 20u;
}
default: {
diff --git a/src/tint/reader/spirv/function_composite_test.cc b/src/tint/reader/spirv/function_composite_test.cc
index 9383c00..2e15743 100644
--- a/src/tint/reader/spirv/function_composite_test.cc
+++ b/src/tint/reader/spirv/function_composite_test.cc
@@ -97,7 +97,7 @@
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : vec2<u32> = vec2<u32>(10u, 20u);
-let x_2 : vec2<i32> = vec2<i32>(30, 40);
+let x_2 : vec2<i32> = vec2<i32>(30i, 40i);
let x_3 : vec2<f32> = vec2<f32>(50.0, 60.0);
)"));
}
@@ -153,7 +153,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_1 : S = S(vec2<f32>(50.0, 60.0), 5u, 30);"));
+ HasSubstr("let x_1 : S = S(vec2<f32>(50.0, 60.0), 5u, 30i);"));
}
TEST_F(SpvParserTest_Composite_Construct, ConstantComposite_Struct_NoDeduplication) {
@@ -608,7 +608,7 @@
EXPECT_THAT(body_str, HasSubstr(R"(var x_36 : S;
let x_1 : S = x_36;
var x_2_1 : S = x_1;
-x_2_1.field2 = 30;
+x_2_1.field2 = 30i;
let x_2 : S = x_2_1;
)")) << body_str;
}
diff --git a/src/tint/reader/spirv/function_logical_test.cc b/src/tint/reader/spirv/function_logical_test.cc
index a6d0f2c..ba73d5d 100644
--- a/src/tint/reader/spirv/function_logical_test.cc
+++ b/src/tint/reader/spirv/function_logical_test.cc
@@ -94,22 +94,22 @@
return "bitcast<vec2<i32>>(vec2<u32>(20u, 10u))";
}
if (assembly == "cast_int_30") {
- return "bitcast<u32>(30)";
+ return "bitcast<u32>(30i)";
}
if (assembly == "cast_int_40") {
- return "bitcast<u32>(40)";
+ return "bitcast<u32>(40i)";
}
if (assembly == "v2int_30_40") {
- return "vec2<i32>(30, 40)";
+ return "vec2<i32>(30i, 40i)";
}
if (assembly == "cast_v2int_30_40") {
- return "bitcast<vec2<u32>>(vec2<i32>(30, 40))";
+ return "bitcast<vec2<u32>>(vec2<i32>(30i, 40i))";
}
if (assembly == "v2int_40_30") {
- return "vec2<i32>(40, 30)";
+ return "vec2<i32>(40i, 30i)";
}
if (assembly == "cast_v2int_40_30") {
- return "bitcast<vec2<u32>>(vec2<i32>(40, 30))";
+ return "bitcast<vec2<u32>>(vec2<i32>(40i, 30i))";
}
if (assembly == "v2float_50_60") {
return "vec2<f32>(50.0, 60.0)";
@@ -202,12 +202,12 @@
// uint uint
BinaryData{"bool", "uint_10", "OpIEqual", "uint_20", "bool", "10u", "==", "20u"},
// int int
- BinaryData{"bool", "int_30", "OpIEqual", "int_40", "bool", "30", "==", "40"},
+ BinaryData{"bool", "int_30", "OpIEqual", "int_40", "bool", "30i", "==", "40i"},
// uint int
BinaryData{"bool", "uint_10", "OpIEqual", "int_40", "bool", "10u",
- "==", "bitcast<u32>(40)"},
+ "==", "bitcast<u32>(40i)"},
// int uint
- BinaryData{"bool", "int_40", "OpIEqual", "uint_10", "bool", "40",
+ BinaryData{"bool", "int_40", "OpIEqual", "uint_10", "bool", "40i",
"==", "bitcast<i32>(10u)"},
// v2uint v2uint
BinaryData{"v2bool", "v2uint_10_20", "OpIEqual", "v2uint_20_10", "vec2<bool>",
@@ -232,12 +232,12 @@
// Both uint
BinaryData{"bool", "uint_10", "OpINotEqual", "uint_20", "bool", "10u", "!=", "20u"},
// Both int
- BinaryData{"bool", "int_30", "OpINotEqual", "int_40", "bool", "30", "!=", "40"},
+ BinaryData{"bool", "int_30", "OpINotEqual", "int_40", "bool", "30i", "!=", "40i"},
// uint int
BinaryData{"bool", "uint_10", "OpINotEqual", "int_40", "bool", "10u",
- "!=", "bitcast<u32>(40)"},
+ "!=", "bitcast<u32>(40i)"},
// int uint
- BinaryData{"bool", "int_40", "OpINotEqual", "uint_10", "bool", "40",
+ BinaryData{"bool", "int_40", "OpINotEqual", "uint_10", "bool", "40i",
"!=", "bitcast<i32>(10u)"},
// Both v2uint
BinaryData{"v2bool", "v2uint_10_20", "OpINotEqual", "v2uint_20_10", "vec2<bool>",
@@ -416,12 +416,12 @@
SpvBinaryLogicalTest,
::testing::Values(
// Both signed
- BinaryData{"bool", "int_30", "OpSGreaterThan", "int_40", "bool", "30", ">", "40"},
+ BinaryData{"bool", "int_30", "OpSGreaterThan", "int_40", "bool", "30i", ">", "40i"},
// First arg unsigned
BinaryData{"bool", "uint_10", "OpSGreaterThan", "int_40", "bool", AstFor("cast_uint_10"),
- ">", "40"},
+ ">", "40i"},
// Second arg unsigned
- BinaryData{"bool", "int_30", "OpSGreaterThan", "uint_20", "bool", "30", ">",
+ BinaryData{"bool", "int_30", "OpSGreaterThan", "uint_20", "bool", "30i", ">",
AstFor("cast_uint_20")},
// Vector, both signed
BinaryData{"v2bool", "v2int_30_40", "OpSGreaterThan", "v2int_40_30", "vec2<bool>",
@@ -438,12 +438,12 @@
SpvBinaryLogicalTest,
::testing::Values(
// Both signed
- BinaryData{"bool", "int_30", "OpSGreaterThanEqual", "int_40", "bool", "30", ">=", "40"},
+ BinaryData{"bool", "int_30", "OpSGreaterThanEqual", "int_40", "bool", "30i", ">=", "40i"},
// First arg unsigned
BinaryData{"bool", "uint_10", "OpSGreaterThanEqual", "int_40", "bool",
- AstFor("cast_uint_10"), ">=", "40"},
+ AstFor("cast_uint_10"), ">=", "40i"},
// Second arg unsigned
- BinaryData{"bool", "int_30", "OpSGreaterThanEqual", "uint_20", "bool", "30",
+ BinaryData{"bool", "int_30", "OpSGreaterThanEqual", "uint_20", "bool", "30i",
">=", AstFor("cast_uint_20")},
// Vector, both signed
BinaryData{"v2bool", "v2int_30_40", "OpSGreaterThanEqual", "v2int_40_30", "vec2<bool>",
@@ -460,12 +460,12 @@
SpvBinaryLogicalTest,
::testing::Values(
// Both signed
- BinaryData{"bool", "int_30", "OpSLessThan", "int_40", "bool", "30", "<", "40"},
+ BinaryData{"bool", "int_30", "OpSLessThan", "int_40", "bool", "30i", "<", "40i"},
// First arg unsigned
BinaryData{"bool", "uint_10", "OpSLessThan", "int_40", "bool", AstFor("cast_uint_10"), "<",
- "40"},
+ "40i"},
// Second arg unsigned
- BinaryData{"bool", "int_30", "OpSLessThan", "uint_20", "bool", "30", "<",
+ BinaryData{"bool", "int_30", "OpSLessThan", "uint_20", "bool", "30i", "<",
AstFor("cast_uint_20")},
// Vector, both signed
BinaryData{"v2bool", "v2int_30_40", "OpSLessThan", "v2int_40_30", "vec2<bool>",
@@ -482,12 +482,12 @@
SpvBinaryLogicalTest,
::testing::Values(
// Both signed
- BinaryData{"bool", "int_30", "OpSLessThanEqual", "int_40", "bool", "30", "<=", "40"},
+ BinaryData{"bool", "int_30", "OpSLessThanEqual", "int_40", "bool", "30i", "<=", "40i"},
// First arg unsigned
BinaryData{"bool", "uint_10", "OpSLessThanEqual", "int_40", "bool", AstFor("cast_uint_10"),
- "<=", "40"},
+ "<=", "40i"},
// Second arg unsigned
- BinaryData{"bool", "int_30", "OpSLessThanEqual", "uint_20", "bool", "30",
+ BinaryData{"bool", "int_30", "OpSLessThanEqual", "uint_20", "bool", "30i",
"<=", AstFor("cast_uint_20")},
// Vector, both signed
BinaryData{"v2bool", "v2int_30_40", "OpSLessThanEqual", "v2int_40_30", "vec2<bool>",
diff --git a/src/tint/reader/spirv/function_memory_test.cc b/src/tint/reader/spirv/function_memory_test.cc
index ea57e25..58cceda 100644
--- a/src/tint/reader/spirv/function_memory_test.cc
+++ b/src/tint/reader/spirv/function_memory_test.cc
@@ -107,8 +107,9 @@
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody());
auto ast_body = fe.ast_body();
- EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(x_1 = 42;
-x_1 = 0;
+ EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(x_1 = 42i;
+x_1 = 0i;
+return;
)"));
}
diff --git a/src/tint/reader/spirv/function_misc_test.cc b/src/tint/reader/spirv/function_misc_test.cc
index 3d37325..9d40ffc 100644
--- a/src/tint/reader/spirv/function_misc_test.cc
+++ b/src/tint/reader/spirv/function_misc_test.cc
@@ -74,7 +74,7 @@
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 : bool = false;
let x_12 : u32 = 0u;
-let x_13 : i32 = 0;
+let x_13 : i32 = 0i;
let x_14 : f32 = 0.0;
)"));
}
@@ -132,7 +132,7 @@
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 : bool = false;
let x_12 : u32 = 0u;
-let x_13 : i32 = 0;
+let x_13 : i32 = 0i;
let x_14 : f32 = 0.0;
)"));
}
@@ -224,7 +224,7 @@
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
- HasSubstr("let x_11 : S = S(false, 0u, 0, 0.0);"));
+ HasSubstr("let x_11 : S = S(false, 0u, 0i, 0.0);"));
}
TEST_F(SpvParserTestMiscInstruction, OpNop) {
diff --git a/src/tint/reader/spirv/function_var_test.cc b/src/tint/reader/spirv/function_var_test.cc
index 39436d2..c986af8 100644
--- a/src/tint/reader/spirv/function_var_test.cc
+++ b/src/tint/reader/spirv/function_var_test.cc
@@ -182,7 +182,7 @@
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a : bool = true;
var b : bool = false;
-var c : i32 = -1;
+var c : i32 = -1i;
var d : u32 = 1u;
var e : f32 = 1.5;
)"));
@@ -210,7 +210,7 @@
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a : bool = false;
-var b : i32 = 0;
+var b : i32 = 0i;
var c : u32 = 0u;
var d : f32 = 0.0;
)"));
@@ -1506,7 +1506,7 @@
const auto* expected = R"(var x_200 : vec2<i32>;
if (true) {
x_200 = vec2<i32>();
- x_200.x = 0;
+ x_200.x = 0i;
} else {
return;
}
@@ -1549,7 +1549,7 @@
const auto* expected = R"(var x_200 : vec2<i32>;
if (true) {
x_200 = vec2<i32>();
- x_200[1] = 3;
+ x_200[1i] = 3i;
} else {
return;
}
@@ -1597,7 +1597,7 @@
const auto got = test::ToString(p->program(), ast_body);
const auto* expected = R"(var x_200 : i32;
if (true) {
- x_200 = 1;
+ x_200 = 1i;
} else {
return;
}
diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc
index ffcdd5b..28dc856 100644
--- a/src/tint/reader/spirv/parser_impl.cc
+++ b/src/tint/reader/spirv/parser_impl.cc
@@ -1332,7 +1332,7 @@
[&](const I32*) {
return create<ast::IntLiteralExpression>(
Source{}, static_cast<int64_t>(literal_value),
- ast::IntLiteralExpression::Suffix::kNone);
+ ast::IntLiteralExpression::Suffix::kI);
},
[&](const U32*) {
return create<ast::IntLiteralExpression>(
@@ -1907,7 +1907,7 @@
[&](const I32*) {
return TypedExpression{ty_.I32(), create<ast::IntLiteralExpression>(
source, spirv_const->GetS32(),
- ast::IntLiteralExpression::Suffix::kNone)};
+ ast::IntLiteralExpression::Suffix::kI)};
},
[&](const U32*) {
return TypedExpression{ty_.U32(), create<ast::IntLiteralExpression>(
@@ -1947,7 +1947,7 @@
type, //
[&](const I32*) {
return create<ast::IntLiteralExpression>(Source{}, 0,
- ast::IntLiteralExpression::Suffix::kNone);
+ ast::IntLiteralExpression::Suffix::kI);
},
[&](const U32*) {
return create<ast::IntLiteralExpression>(Source{}, 0,
diff --git a/src/tint/reader/spirv/parser_impl_handle_test.cc b/src/tint/reader/spirv/parser_impl_handle_test.cc
index aa1b8c2..0af3cc5 100644
--- a/src/tint/reader/spirv/parser_impl_handle_test.cc
+++ b/src/tint/reader/spirv/parser_impl_handle_test.cc
@@ -1499,7 +1499,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- "textureGather(1, x_20, x_10, coords12)"},
+ "textureGather(1i, x_20, x_10, coords12)"},
// OpImageGather 2D ConstOffset signed
ImageAccessCase{"%float 2D 0 0 0 1 Unknown",
"%result = OpImageGather "
@@ -1507,7 +1507,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- "textureGather(1, x_20, x_10, coords12, vec2<i32>(3, 4))"},
+ "textureGather(1i, x_20, x_10, coords12, vec2<i32>(3i, 4i))"},
// OpImageGather 2D ConstOffset unsigned
ImageAccessCase{"%float 2D 0 0 0 1 Unknown",
"%result = OpImageGather "
@@ -1516,7 +1516,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- "textureGather(1, x_20, x_10, coords12, "
+ "textureGather(1i, x_20, x_10, coords12, "
"vec2<i32>(vec2<u32>(3u, 4u)))"},
// OpImageGather 2D Array
ImageAccessCase{"%float 2D 0 1 0 1 Unknown",
@@ -1525,7 +1525,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- "textureGather(1, x_20, x_10, coords123.xy, "
+ "textureGather(1i, x_20, x_10, coords123.xy, "
"i32(round(coords123.z)))"},
// OpImageGather 2D Array ConstOffset signed
ImageAccessCase{"%float 2D 0 1 0 1 Unknown",
@@ -1534,8 +1534,8 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- "textureGather(1, x_20, x_10, coords123.xy, "
- "i32(round(coords123.z)), vec2<i32>(3, 4))"},
+ "textureGather(1i, x_20, x_10, coords123.xy, "
+ "i32(round(coords123.z)), vec2<i32>(3i, 4i))"},
// OpImageGather 2D Array ConstOffset unsigned
ImageAccessCase{"%float 2D 0 1 0 1 Unknown",
"%result = OpImageGather "
@@ -1544,7 +1544,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- "textureGather(1, x_20, x_10, coords123.xy, "
+ "textureGather(1i, x_20, x_10, coords123.xy, "
"i32(round(coords123.z)), "
"vec2<i32>(vec2<u32>(3u, 4u)))"},
// OpImageGather Cube
@@ -1554,7 +1554,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_cube<f32>;)",
- "textureGather(1, x_20, x_10, coords123)"},
+ "textureGather(1i, x_20, x_10, coords123)"},
// OpImageGather Cube Array
ImageAccessCase{"%float Cube 0 1 0 1 Unknown",
"%result = OpImageGather "
@@ -1562,7 +1562,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_cube_array<f32>;)",
- "textureGather(1, x_20, x_10, coords1234.xyz, "
+ "textureGather(1i, x_20, x_10, coords1234.xyz, "
"i32(round(coords1234.w)))"},
// OpImageGather 2DDepth
ImageAccessCase{"%float 2D 1 0 0 1 Unknown",
@@ -1579,7 +1579,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_depth_2d;)",
- "textureGather(x_20, x_10, coords12, vec2<i32>(3, 4))"},
+ "textureGather(x_20, x_10, coords12, vec2<i32>(3i, 4i))"},
// OpImageGather 2DDepth ConstOffset unsigned
ImageAccessCase{"%float 2D 1 0 0 1 Unknown",
"%result = OpImageGather "
@@ -1607,7 +1607,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
"textureGather(x_20, x_10, coords123.xy, "
- "i32(round(coords123.z)), vec2<i32>(3, 4))"},
+ "i32(round(coords123.z)), vec2<i32>(3i, 4i))"},
// OpImageGather 2DDepth Array ConstOffset unsigned
ImageAccessCase{"%float 2D 1 1 0 1 Unknown",
"%result = OpImageGather "
@@ -1657,7 +1657,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d;)",
"textureGatherCompare(x_20, x_10, coords12, 0.200000003, "
- "vec2<i32>(3, 4))"},
+ "vec2<i32>(3i, 4i))"},
// OpImageDrefGather 2DDepth ConstOffset unsigned
ImageAccessCase{"%float 2D 1 0 0 1 Unknown",
"%result = OpImageDrefGather "
@@ -1685,7 +1685,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
"textureGatherCompare(x_20, x_10, coords123.xy, "
- "i32(round(coords123.z)), 0.200000003, vec2<i32>(3, 4))"},
+ "i32(round(coords123.z)), 0.200000003, vec2<i32>(3i, 4i))"},
// OpImageDrefGather 2DDepth Array ConstOffset unsigned
ImageAccessCase{"%float 2D 1 1 0 1 Unknown",
"%result = OpImageDrefGather "
@@ -1745,7 +1745,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- "textureSample(x_20, x_10, coords12, vec2<i32>(3, 4))"},
+ "textureSample(x_20, x_10, coords12, vec2<i32>(3i, 4i))"},
// OpImageSampleImplicitLod arrayed with ConstOffset
ImageAccessCase{
@@ -1755,7 +1755,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- R"(textureSample(x_20, x_10, coords123.xy, i32(round(coords123.z)), vec2<i32>(3, 4)))"},
+ R"(textureSample(x_20, x_10, coords123.xy, i32(round(coords123.z)), vec2<i32>(3i, 4i)))"},
// OpImageSampleImplicitLod with Bias
ImageAccessCase{"%float 2D 0 0 0 1 Unknown",
@@ -1784,7 +1784,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleBias(x_20, x_10, coords12, 7.0, vec2<i32>(3, 4))"},
+ R"(textureSampleBias(x_20, x_10, coords12, 7.0, vec2<i32>(3i, 4i))"},
// OpImageSampleImplicitLod with Bias and unsigned ConstOffset
// Convert ConstOffset to signed
@@ -1806,7 +1806,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- R"(textureSampleBias(x_20, x_10, coords123.xy, i32(round(coords123.z)), 7.0, vec2<i32>(3, 4))"}));
+ R"(textureSampleBias(x_20, x_10, coords123.xy, i32(round(coords123.z)), 7.0, vec2<i32>(3i, 4i))"}));
INSTANTIATE_TEST_SUITE_P(
// This test shows the use of a sampled image used with both regular
@@ -1866,7 +1866,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d;
)",
- R"(textureSampleCompare(x_20, x_10, coords12, 0.200000003, vec2<i32>(3, 4)))"},
+ R"(textureSampleCompare(x_20, x_10, coords12, 0.200000003, vec2<i32>(3i, 4i)))"},
// ImageSampleDrefImplicitLod arrayed with ConstOffset
ImageAccessCase{
"%float 2D 0 1 0 1 Unknown",
@@ -1875,7 +1875,7 @@
R"(@group(0) @binding(0) var x_10 : sampler_comparison;
@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
- R"(textureSampleCompare(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.200000003, vec2<i32>(3, 4)))"}));
+ R"(textureSampleCompare(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.200000003, vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
ImageSampleDrefExplicitLod,
@@ -1911,7 +1911,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d;
)",
- R"(textureSampleCompareLevel(x_20, x_10, coords12, 0.200000003, vec2<i32>(3, 4)))"},
+ R"(textureSampleCompareLevel(x_20, x_10, coords12, 0.200000003, vec2<i32>(3i, 4i)))"},
// 2D array, ConstOffset
ImageAccessCase{
"%float 2D 1 1 0 1 Unknown",
@@ -1921,7 +1921,7 @@
R"(@group(0) @binding(0) var x_10 : sampler_comparison;
@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
- R"(textureSampleCompareLevel(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.200000003, vec2<i32>(3, 4)))"},
+ R"(textureSampleCompareLevel(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.200000003, vec2<i32>(3i, 4i)))"},
// Cube
ImageAccessCase{"%float Cube 1 0 0 1 Unknown",
"%result = OpImageSampleDrefExplicitLod "
@@ -1972,7 +1972,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleLevel(x_20, x_10, coords12, 0.0, vec2<i32>(3, 4)))"},
+ R"(textureSampleLevel(x_20, x_10, coords12, 0.0, vec2<i32>(3i, 4i)))"},
// OpImageSampleExplicitLod - using Lod and unsigned ConstOffset
// Convert the ConstOffset operand to signed
@@ -1995,7 +1995,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- R"(textureSampleLevel(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.0, vec2<i32>(3, 4)))"}));
+ R"(textureSampleLevel(x_20, x_10, coords123.xy, i32(round(coords123.z)), 0.0, vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
ImageSampleExplicitLod_UsingGrad,
@@ -2022,14 +2022,15 @@
R"(textureSampleGrad(x_20, x_10, coords123.xy, i32(round(coords123.z)), vf12, vf21))"},
// OpImageSampleExplicitLod - using Grad and ConstOffset
- ImageAccessCase{"%float 2D 0 0 0 1 Unknown",
- "%result = OpImageSampleExplicitLod "
- "%v4float %sampled_image %coords12 Grad|ConstOffset "
- "%vf12 %vf21 %offsets2d",
- R"(@group(0) @binding(0) var x_10 : sampler;
+ ImageAccessCase{
+ "%float 2D 0 0 0 1 Unknown",
+ "%result = OpImageSampleExplicitLod "
+ "%v4float %sampled_image %coords12 Grad|ConstOffset "
+ "%vf12 %vf21 %offsets2d",
+ R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleGrad(x_20, x_10, coords12, vf12, vf21, vec2<i32>(3, 4)))"},
+ R"(textureSampleGrad(x_20, x_10, coords12, vf12, vf21, vec2<i32>(3i, 4i)))"},
// OpImageSampleExplicitLod - using Grad and unsigned ConstOffset
ImageAccessCase{
@@ -2051,7 +2052,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
- R"(textureSampleGrad(x_20, x_10, coords123.xy, i32(round(coords123.z)), vf12, vf21, vec2<i32>(3, 4)))"},
+ R"(textureSampleGrad(x_20, x_10, coords123.xy, i32(round(coords123.z)), vf12, vf21, vec2<i32>(3i, 4i)))"},
// OpImageSampleExplicitLod arrayed - using Grad and unsigned
// ConstOffset
@@ -2160,7 +2161,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSample(x_20, x_10, (coords123.xy / coords123.z), vec2<i32>(3, 4)))"}));
+ R"(textureSample(x_20, x_10, (coords123.xy / coords123.z), vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
ImageSampleProjImplicitLod_Bias,
@@ -2186,7 +2187,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleBias(x_20, x_10, (coords123.xy / coords123.z), 7.0, vec2<i32>(3, 4)))"},
+ R"(textureSampleBias(x_20, x_10, (coords123.xy / coords123.z), 7.0, vec2<i32>(3i, 4i)))"},
// OpImageSampleProjImplicitLod with Bias and unsigned ConstOffset
// Convert ConstOffset to signed
@@ -2221,7 +2222,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleLevel(x_20, x_10, (coords123.xy / coords123.z), f1, vec2<i32>(3, 4)))"}));
+ R"(textureSampleLevel(x_20, x_10, (coords123.xy / coords123.z), f1, vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
ImageSampleProjExplicitLod_Grad,
@@ -2246,7 +2247,7 @@
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(textureSampleGrad(x_20, x_10, (coords123.xy / coords123.z), vf12, vf21, vec2<i32>(3, 4)))"}));
+ R"(textureSampleGrad(x_20, x_10, (coords123.xy / coords123.z), vf12, vf21, vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
// Ordinary (non-comparison) sampling on a depth texture.
@@ -2291,7 +2292,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d;
)",
- R"(textureSampleCompare(x_20, x_10, (coords123.xy / coords123.z), f1, vec2<i32>(3, 4)))"}));
+ R"(textureSampleCompare(x_20, x_10, (coords123.xy / coords123.z), f1, vec2<i32>(3i, 4i)))"}));
INSTANTIATE_TEST_SUITE_P(
DISABLED_ImageSampleProjDrefExplicitLod_Lod,
@@ -2322,7 +2323,7 @@
@group(2) @binding(1) var x_20 : texture_depth_2d;
)",
- R"(textureSampleCompareLevel(x_20, x_10, (coords123.xy / coords123.z), 0.200000003, 0.0, vec2<i32>(3, 4)))"}));
+ R"(textureSampleCompareLevel(x_20, x_10, (coords123.xy / coords123.z), 0.200000003, 0.0, vec2<i32>(3i, 4i)))"}));
/////
// End projection sampling
@@ -2563,7 +2564,7 @@
// Source signed, dest signed
{"%int 2D 0 0 0 2 R32i", "OpImageWrite %im %vi12 %vi12",
R"(@group(2) @binding(1) var x_20 : texture_storage_2d<r32sint, write>;)",
- R"(textureStore(x_20, vi12, vec4<i32>(vi12, 0, 0)))"}}));
+ R"(textureStore(x_20, vi12, vec4<i32>(vi12, 0i, 0i)))"}}));
INSTANTIATE_TEST_SUITE_P(
ImageFetch_OptionalParams,
@@ -2573,20 +2574,20 @@
// Level of detail is injected for sampled texture
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch with explicit level, on sampled texture
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 3);)"},
+ R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 3i);)"},
// OpImageFetch with no extra params, on depth texture
// Level of detail is injected for depth texture
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
- R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 0), 0.0, 0.0, 0.0);)"},
+ R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 0i), 0.0, 0.0, 0.0);)"},
// OpImageFetch with extra params, on depth texture
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
- R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 3), 0.0, 0.0, 0.0);)"}}));
+ R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 3i), 0.0, 0.0, 0.0);)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageFetch_Depth,
@@ -2599,7 +2600,7 @@
// ImageFetch on depth image.
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 ",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
- R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 0), 0.0, 0.0, 0.0);)"}}));
+ R"(let x_99 : vec4<f32> = vec4<f32>(textureLoad(x_20, vi12, 0i), 0.0, 0.0, 0.0);)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageFetch_DepthMultisampled,
@@ -2657,11 +2658,11 @@
// OpImageFetch requires no conversion, float -> v4float
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires no conversion, uint -> v4uint
{"%uint 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4uint %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<u32>;)",
- R"(let x_99 : vec4<u32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<u32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires conversion, uint -> v4int
// is invalid SPIR-V:
// "Expected Image 'Sampled Type' to be the same as Result Type
@@ -2670,7 +2671,7 @@
// OpImageFetch requires no conversion, int -> v4int
{"%int 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4int %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<i32>;)",
- R"(let x_99 : vec4<i32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<i32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires conversion, int -> v4uint
// is invalid SPIR-V:
// "Expected Image 'Sampled Type' to be the same as Result Type
@@ -2683,11 +2684,11 @@
// OpImageRead requires no conversion, float -> v4float
{"%float 2D 0 0 0 2 Rgba32f", "%99 = OpImageRead %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
- R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<f32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires no conversion, uint -> v4uint
{"%uint 2D 0 0 0 2 Rgba32ui", "%99 = OpImageRead %v4uint %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<u32>;)",
- R"(let x_99 : vec4<u32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<u32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires conversion, uint -> v4int
// is invalid SPIR-V:
@@ -2697,7 +2698,7 @@
// OpImageRead requires no conversion, int -> v4int
{"%int 2D 0 0 0 2 Rgba32i", "%99 = OpImageRead %v4int %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<i32>;)",
- R"(let x_99 : vec4<i32> = textureLoad(x_20, vi12, 0);)"},
+ R"(let x_99 : vec4<i32> = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires conversion, int -> v4uint
// is invalid SPIR-V:
diff --git a/src/tint/reader/spirv/parser_impl_module_var_test.cc b/src/tint/reader/spirv/parser_impl_module_var_test.cc
index 4f8aa0d..5066659 100644
--- a/src/tint/reader/spirv/parser_impl_module_var_test.cc
+++ b/src/tint/reader/spirv/parser_impl_module_var_test.cc
@@ -885,7 +885,7 @@
var<private> x_2 : bool = false;
-var<private> x_3 : i32 = -1;
+var<private> x_3 : i32 = -1i;
var<private> x_4 : u32 = 1u;
@@ -910,7 +910,7 @@
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 : bool = false;
-var<private> x_2 : i32 = 0;
+var<private> x_2 : i32 = 0i;
var<private> x_3 : u32 = 0u;
@@ -935,7 +935,7 @@
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 : bool = false;
-var<private> x_2 : i32 = 0;
+var<private> x_2 : i32 = 0i;
var<private> x_3 : u32 = 0u;
@@ -1550,7 +1550,7 @@
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
- EXPECT_THAT(module_str, HasSubstr("@id(12) override myconst : i32 = 42;")) << module_str;
+ EXPECT_THAT(module_str, HasSubstr("@id(12) override myconst : i32 = 42i;")) << module_str;
}
TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_DeclareConst_F32) {
@@ -1985,7 +1985,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- let x_3 : u32 = x_1[0];
+ let x_3 : u32 = x_1[0i];
return;
}
@@ -2017,7 +2017,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- let x_4 : u32 = x_1[0];
+ let x_4 : u32 = x_1[0i];
return;
}
@@ -2049,7 +2049,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- let x_4 : u32 = x_1[0];
+ let x_4 : u32 = x_1[0i];
return;
}
@@ -2080,7 +2080,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- let x_3 : i32 = x_1[0];
+ let x_3 : i32 = x_1[0i];
return;
}
@@ -2112,7 +2112,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- let x_4 : i32 = x_1[0];
+ let x_4 : i32 = x_1[0i];
return;
}
@@ -2144,7 +2144,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- let x_4 : i32 = x_1[0];
+ let x_4 : i32 = x_1[0i];
return;
}
@@ -2193,7 +2193,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- x_1[0] = 0u;
+ x_1[0i] = 0u;
return;
}
@@ -2230,7 +2230,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- x_1[0] = 0u;
+ x_1[0i] = 0u;
return;
}
@@ -2267,7 +2267,7 @@
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
- x_1[0] = 0u;
+ x_1[0i] = 0u;
return;
}
@@ -2303,7 +2303,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- x_1[0] = 12;
+ x_1[0i] = 12i;
return;
}
@@ -2340,7 +2340,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- x_1[0] = 12;
+ x_1[0i] = 12i;
return;
}
@@ -2377,7 +2377,7 @@
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
- x_1[0] = 12;
+ x_1[0i] = 12i;
return;
}
@@ -2421,7 +2421,7 @@
var<private> x_1 : Arr;
fn main_1() {
- let x_3 : u32 = x_1[0];
+ let x_3 : u32 = x_1[0i];
return;
}
@@ -2460,7 +2460,7 @@
var<private> x_1 : Arr;
fn main_1() {
- x_1[0] = 0u;
+ x_1[0i] = 0u;
return;
}
@@ -3467,7 +3467,7 @@
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
- const std::string expected = "var<private> x_1 : array<i32, 1u> = array<i32, 1u>(14);";
+ const std::string expected = "var<private> x_1 : array<i32, 1u> = array<i32, 1u>(14i);";
EXPECT_THAT(got, HasSubstr(expected)) << got;
}