From f374b819d95be3424e9a99af282db1fb81328d6e Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 30 Jan 2023 15:34:49 +0000 Subject: [PATCH] Remove `sig` deprecation. This CL removes support for the `sig` member in `frexp`. It is now an error if `sig` is used, the deprecation is removed. `fract` should be used instead. Bug: tint:1766 Change-Id: I991544b675caf31f22c8c9472a60c77811ff4efd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117920 Kokoro: Ben Clayton Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair --- docs/tint/origin-trial-changes.md | 6 +++ src/tint/resolver/builtin_test.cc | 23 -------- src/tint/resolver/resolver.cc | 10 ---- src/tint/transform/renamer_test.cc | 4 +- .../glsl/generator_impl_builtin_test.cc | 21 -------- .../hlsl/generator_impl_builtin_test.cc | 21 -------- .../writer/msl/generator_impl_builtin_test.cc | 18 ------- src/tint/writer/spirv/builder_builtin_test.cc | 54 ------------------- test/tint/bug/tint/1757.wgsl | 7 --- .../tint/bug/tint/1757.wgsl.expected.dxc.hlsl | 15 ------ .../tint/bug/tint/1757.wgsl.expected.fxc.hlsl | 15 ------ test/tint/bug/tint/1757.wgsl.expected.glsl | 23 -------- test/tint/bug/tint/1757.wgsl.expected.msl | 19 ------- test/tint/bug/tint/1757.wgsl.expected.spvasm | 33 ------------ test/tint/bug/tint/1757.wgsl.expected.wgsl | 10 ---- 15 files changed, 8 insertions(+), 271 deletions(-) delete mode 100644 test/tint/bug/tint/1757.wgsl delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.glsl delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.msl delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.spvasm delete mode 100644 test/tint/bug/tint/1757.wgsl.expected.wgsl diff --git a/docs/tint/origin-trial-changes.md b/docs/tint/origin-trial-changes.md index 93a330b8c1..5443735c31 100644 --- a/docs/tint/origin-trial-changes.md +++ b/docs/tint/origin-trial-changes.md @@ -1,5 +1,11 @@ # Tint changes during Origin Trial +## Changes for M112 + +### Breaking changes + +* * The `sig` member of the return type of `frexp()` has been renamed to `fract`. [tint:1766](crbug.com/tint/1766) + ## Changes for M111 ### New features diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index b56caaa9c3..7be6162836 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -1046,29 +1046,6 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) { EXPECT_EQ(ty->SizeNoPadding(), 28u); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(ResolverBuiltinFloatTest, FrexpVector_sig) { - Enable(ast::Extension::kF16); - - auto* call = Call("frexp", vec3()); - auto* expr = MemberAccessor(call, "sig"); - WrapInFunction(expr); - - EXPECT_TRUE(r()->Resolve()) << r()->error(); - - ASSERT_NE(TypeOf(call), nullptr); - auto* ty = TypeOf(call)->As(); - ASSERT_NE(ty, nullptr); - ASSERT_EQ(ty->Members().Length(), 2u); - - auto* sig = ty->Members()[0]; - EXPECT_TYPE(sig->Type(), TypeOf(expr)); - - auto* access = Sem().Get(expr); - ASSERT_NE(access, nullptr); - EXPECT_EQ(access->Member(), sig); -} - TEST_F(ResolverBuiltinFloatTest, Frexp_Error_FirstParamInt) { GlobalVar("v", ty.i32(), type::AddressSpace::kWorkgroup); auto* call = Call("frexp", 1_i, AddressOf("v")); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 1e777a7951..9c592fce55 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -2779,16 +2779,6 @@ sem::Expression* Resolver::MemberAccessor(const ast::MemberAccessorExpression* e } } - // TODO(crbug.com/tint/1757): Remove - if (utils::HasPrefix(builder_->Symbols().NameFor(str->Name()), "__frexp_result")) { - if (builder_->Symbols().NameFor(symbol) == "sig") { - AddWarning( - "use of deprecated language feature: 'sig' has been renamed to 'fract'", - expr->member->source); - member = str->Members()[0]; - } - } - if (member == nullptr) { AddError("struct member " + builder_->Symbols().NameFor(symbol) + " not found", expr->source); diff --git a/src/tint/transform/renamer_test.cc b/src/tint/transform/renamer_test.cc index 969ce2c4f8..71d6cfe94e 100644 --- a/src/tint/transform/renamer_test.cc +++ b/src/tint/transform/renamer_test.cc @@ -160,7 +160,7 @@ TEST_F(RenamerTest, PreserveBuiltinTypes) { fn entry() { var a = modf(1.0).whole; var b = modf(1.0).fract; - var c = frexp(1.0).sig; + var c = frexp(1.0).fract; var d = frexp(1.0).exp; } )"; @@ -170,7 +170,7 @@ fn entry() { fn tint_symbol() { var tint_symbol_1 = modf(1.0).whole; var tint_symbol_2 = modf(1.0).fract; - var tint_symbol_3 = frexp(1.0).sig; + var tint_symbol_3 = frexp(1.0).fract; var tint_symbol_4 = frexp(1.0).exp; } )"; diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc index be9788b34b..33d2fa70b5 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc @@ -920,27 +920,6 @@ void main() { )"); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { - WrapInFunction(MemberAccessor(Call("frexp", 1_f), "sig")); - - GeneratorImpl& gen = SanitizeAndBuild(); - - ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_EQ(gen.result(), R"(#version 310 es - -void test_function() { - float tint_symbol = 0.5f; -} - -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -void main() { - test_function(); - return; -} -)"); -} - TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) { auto* val = Var("val", ty.f32()); auto* call = Call("degrees", val); diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc index fadfbd275c..d5c418825d 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -802,27 +802,6 @@ void test_function() { )"); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { - WrapInFunction(Var("v", Call("frexp", 1_f)), // - MemberAccessor("v", "sig")); - - GeneratorImpl& gen = SanitizeAndBuild(); - - ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_EQ(gen.result(), R"(struct frexp_result_f32 { - float fract; - int exp; -}; -[numthreads(1, 1, 1)] -void test_function() { - frexp_result_f32 v = {0.5f, 1}; - const float tint_symbol = v.fract; - return; -} -)"); -} - TEST_F(HlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) { auto* val = Var("val", ty.f32()); auto* call = Call("degrees", val); diff --git a/src/tint/writer/msl/generator_impl_builtin_test.cc b/src/tint/writer/msl/generator_impl_builtin_test.cc index baaab18200..c0f0ff38d1 100644 --- a/src/tint/writer/msl/generator_impl_builtin_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_test.cc @@ -837,24 +837,6 @@ kernel void test_function() { )"); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(MslGeneratorImplTest, Frexp_Sig_Deprecation) { - WrapInFunction(MemberAccessor(Call("frexp", 1_f), "sig")); - - GeneratorImpl& gen = SanitizeAndBuild(); - - ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_EQ(gen.result(), R"(#include - -using namespace metal; -kernel void test_function() { - float const tint_symbol = 0.5f; - return; -} - -)"); -} - TEST_F(MslGeneratorImplTest, Degrees_Scalar_f32) { auto* val = Var("val", ty.f32()); auto* call = Call("degrees", val); diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index ac1dce37aa..057aa7d56b 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -2045,60 +2045,6 @@ OpFunctionEnd Validate(b); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(BuiltinBuilderTest, Frexp_Sig_Deprecation) { - Func("a_func", utils::Empty, ty.void_(), - utils::Vector{ - Decl(Var("vec", vec2(1_f, 2_f))), - Decl(Let("s", MemberAccessor(Call("frexp", "vec"), "sig"))), - }, - utils::Vector{ - Stage(ast::PipelineStage::kFragment), - }); - - spirv::Builder& b = Build(); - - ASSERT_TRUE(b.Build()) << b.error(); - auto got = DumpBuilder(b); - auto* expect = R"(OpCapability Shader -%17 = OpExtInstImport "GLSL.std.450" -OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %3 "a_func" -OpExecutionMode %3 OriginUpperLeft -OpName %3 "a_func" -OpName %10 "vec" -OpName %14 "__frexp_result_vec2_f32" -OpMemberName %14 0 "fract" -OpMemberName %14 1 "exp" -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %14 1 Offset 8 -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 2 -%7 = OpConstant %6 1 -%8 = OpConstant %6 2 -%9 = OpConstantComposite %5 %7 %8 -%11 = OpTypePointer Function %5 -%12 = OpConstantNull %5 -%16 = OpTypeInt 32 1 -%15 = OpTypeVector %16 2 -%14 = OpTypeStruct %5 %15 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%10 = OpVariable %11 Function %12 -OpStore %10 %9 -%18 = OpLoad %5 %10 -%13 = OpExtInst %14 %17 FrexpStruct %18 -%19 = OpCompositeExtract %5 %13 0 -OpReturn -OpFunctionEnd -)"; - EXPECT_EQ(expect, got); - - Validate(b); -} - TEST_F(BuiltinBuilderTest, Call_QuantizeToF16_Scalar) { GlobalVar("v", Expr(2_f), type::AddressSpace::kPrivate); diff --git a/test/tint/bug/tint/1757.wgsl b/test/tint/bug/tint/1757.wgsl deleted file mode 100644 index 1310e100dd..0000000000 --- a/test/tint/bug/tint/1757.wgsl +++ /dev/null @@ -1,7 +0,0 @@ -// TODO(crbug.com/tint/1757): Remove this test once the deprecation period for `frexp().sig` is over -@compute @workgroup_size(1) -fn main() { - let res = frexp(1.23); - let exp : i32 = res.exp; - let sig : f32 = res.sig; -} diff --git a/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl deleted file mode 100644 index 389529aad2..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -struct frexp_result_f32 { - float fract; - int exp; -}; -[numthreads(1, 1, 1)] -void main() { - const frexp_result_f32 res = {0.61500001f, 1}; - const int exp = res.exp; - const float sig = res.fract; - return; -} diff --git a/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl deleted file mode 100644 index 389529aad2..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -struct frexp_result_f32 { - float fract; - int exp; -}; -[numthreads(1, 1, 1)] -void main() { - const frexp_result_f32 res = {0.61500001f, 1}; - const int exp = res.exp; - const float sig = res.fract; - return; -} diff --git a/test/tint/bug/tint/1757.wgsl.expected.glsl b/test/tint/bug/tint/1757.wgsl.expected.glsl deleted file mode 100644 index 39bb6d34f8..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.glsl +++ /dev/null @@ -1,23 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -#version 310 es - -struct frexp_result_f32 { - float fract; - int exp; -}; - - -void tint_symbol() { - frexp_result_f32 res = frexp_result_f32(0.61500001f, 1); - int tint_symbol_1 = res.exp; - float sig = res.fract; -} - -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -void main() { - tint_symbol(); - return; -} diff --git a/test/tint/bug/tint/1757.wgsl.expected.msl b/test/tint/bug/tint/1757.wgsl.expected.msl deleted file mode 100644 index 815c2a44f5..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.msl +++ /dev/null @@ -1,19 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -#include - -using namespace metal; - -struct frexp_result_f32 { - float fract; - int exp; -}; -kernel void tint_symbol() { - frexp_result_f32 const res = frexp_result_f32{.fract=0.61500001f, .exp=1}; - int const exp = res.exp; - float const sig = res.fract; - return; -} - diff --git a/test/tint/bug/tint/1757.wgsl.expected.spvasm b/test/tint/bug/tint/1757.wgsl.expected.spvasm deleted file mode 100644 index a4bb6cdfee..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.spvasm +++ /dev/null @@ -1,33 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -; SPIR-V -; Version: 1.3 -; Generator: Google Tint Compiler; 0 -; Bound: 13 -; Schema: 0 - OpCapability Shader - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" - OpExecutionMode %main LocalSize 1 1 1 - OpName %main "main" - OpName %__frexp_result_f32 "__frexp_result_f32" - OpMemberName %__frexp_result_f32 0 "fract" - OpMemberName %__frexp_result_f32 1 "exp" - OpMemberDecorate %__frexp_result_f32 0 Offset 0 - OpMemberDecorate %__frexp_result_f32 1 Offset 4 - %void = OpTypeVoid - %1 = OpTypeFunction %void - %float = OpTypeFloat 32 - %int = OpTypeInt 32 1 -%__frexp_result_f32 = OpTypeStruct %float %int -%float_0_61500001 = OpConstant %float 0.61500001 - %int_1 = OpConstant %int 1 - %10 = OpConstantComposite %__frexp_result_f32 %float_0_61500001 %int_1 - %main = OpFunction %void None %1 - %4 = OpLabel - %11 = OpCompositeExtract %int %10 1 - %12 = OpCompositeExtract %float %10 0 - OpReturn - OpFunctionEnd diff --git a/test/tint/bug/tint/1757.wgsl.expected.wgsl b/test/tint/bug/tint/1757.wgsl.expected.wgsl deleted file mode 100644 index fe9d8ab75e..0000000000 --- a/test/tint/bug/tint/1757.wgsl.expected.wgsl +++ /dev/null @@ -1,10 +0,0 @@ -bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has been renamed to 'fract' - let sig : f32 = res.sig; - ^^^ - -@compute @workgroup_size(1) -fn main() { - let res = frexp(1.23); - let exp : i32 = res.exp; - let sig : f32 = res.sig; -}