Skip to content

Commit

Permalink
[tint] Remove remappings output from Renamer
Browse files Browse the repository at this point in the history
This is no longer used anywhere.

Fixed: 375192379
Change-Id: I1ea420cb1aca97d3d4a9ab7e5143eed2a139bd0b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218143
Reviewed-by: dan sinclair <[email protected]>
Commit-Queue: James Price <[email protected]>
  • Loading branch information
jrprice authored and Dawn LUCI CQ committed Dec 5, 2024
1 parent 0f8ddaf commit 38268c8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 132 deletions.
17 changes: 1 addition & 16 deletions src/tint/lang/wgsl/ast/transform/renamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "src/tint/utils/text/unicode.h"

TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Renamer);
TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Renamer::Data);
TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Renamer::Config);

namespace tint::ast::transform {
Expand Down Expand Up @@ -1262,12 +1261,6 @@ const char* const kReservedKeywordsMSL[] = {

} // namespace

Renamer::Data::Data(Remappings&& r) : remappings(std::move(r)) {}

Renamer::Data::Data(const Data&) = default;

Renamer::Data::~Data() = default;

Renamer::Config::Config() = default;

Renamer::Config::Config(Target t) : target(t) {}
Expand All @@ -1282,9 +1275,7 @@ Renamer::Config::~Config() = default;
Renamer::Renamer() = default;
Renamer::~Renamer() = default;

Transform::ApplyResult Renamer::Apply(const Program& src,
const DataMap& inputs,
DataMap& outputs) const {
Transform::ApplyResult Renamer::Apply(const Program& src, const DataMap& inputs, DataMap&) const {
Hashset<Symbol, 16> global_decls;
for (auto* decl : src.AST().TypeDecls()) {
global_decls.Add(decl->name->symbol);
Expand Down Expand Up @@ -1430,12 +1421,6 @@ Transform::ApplyResult Renamer::Apply(const Program& src,

ctx.Clone();

Remappings out;
for (auto& it : remappings) {
out[it.key->Name()] = it.value.Name();
}
outputs.Add<Data>(std::move(out));

return resolver::Resolve(b);
}

Expand Down
17 changes: 0 additions & 17 deletions src/tint/lang/wgsl/ast/transform/renamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@ class Renamer final : public Castable<Renamer, Transform> {
/// Remappings is a map of old symbol name to new symbol name
using Remappings = std::unordered_map<std::string, std::string>;

/// Data is outputted by the Renamer transform.
/// Data holds information about shader usage and constant buffer offsets.
struct Data final : public Castable<Data, transform::Data> {
/// Constructor
/// @param remappings the symbol remappings
explicit Data(Remappings&& remappings);

/// Copy constructor
Data(const Data&);

/// Destructor
~Data() override;

/// A map of old symbol name to new symbol name
const Remappings remappings;
};

/// Target is an enumerator of rename targets that can be used
enum class Target {
/// Rename every symbol.
Expand Down
99 changes: 0 additions & 99 deletions src/tint/lang/wgsl/ast/transform/renamer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ TEST_F(RenamerTest, EmptyModule) {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_EQ(data->remappings.size(), 0u);
}

TEST_F(RenamerTest, BasicModuleVertexIndex) {
Expand Down Expand Up @@ -91,16 +87,6 @@ fn tint_symbol_2(@builtin(vertex_index) tint_symbol_1 : u32) -> @builtin(positio
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"vert_idx", "tint_symbol_1"},
{"test", "tint_symbol"},
{"entry", "tint_symbol_2"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, RequestedNamesWithRenameAll) {
Expand Down Expand Up @@ -158,16 +144,6 @@ fn tint_symbol_2(@builtin(vertex_index) tint_symbol_3 : u32) -> tint_symbol {
auto got = Run<Renamer>(src, inputs);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"pos", "tint_symbol_1"}, {"vert_idx", "tint_symbol_3"}, {"ShaderIO", "tint_symbol"},
{"shaderIO", "tint_symbol_4"}, {"main", "tint_symbol_2"}, {"var1", "user_var1"},
{"var3", "user_var3"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

using RenamerTestRequestedNamesWithoutRenameAll = TransformTestWithParam<Renamer::Target>;
Expand Down Expand Up @@ -227,15 +203,6 @@ fn entry_point(@builtin(vertex_index) vert_idx : u32) -> ShaderIO {
auto got = Run<Renamer>(src, inputs);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"var1", "user_var1"},
{"var3", "user_var3"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

INSTANTIATE_TEST_SUITE_P(RenamerTestRequestedNamesWithoutRenameAll,
Expand Down Expand Up @@ -270,15 +237,6 @@ fn tint_symbol() -> @builtin(position) vec4<f32> {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"}, {"v", "tint_symbol_1"}, {"rgba", "tint_symbol_2"},
{"xyzw", "tint_symbol_3"}, {"z", "tint_symbol_4"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveSwizzles_ThroughMaterialize) {
Expand All @@ -296,15 +254,6 @@ const tint_symbol_1 = (tint_symbol.x * 2u);
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"v", "tint_symbol"},
{"x", "tint_symbol_1"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveBuiltins) {
Expand All @@ -327,15 +276,6 @@ fn tint_symbol() -> @builtin(position) vec4<f32> {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"},
{"blah", "tint_symbol_1"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveBuiltinTypes) {
Expand All @@ -362,15 +302,6 @@ fn tint_symbol() {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"}, {"a", "tint_symbol_1"}, {"b", "tint_symbol_2"},
{"c", "tint_symbol_3"}, {"d", "tint_symbol_4"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveBuiltinTypes_ViaPointerDot) {
Expand Down Expand Up @@ -406,16 +337,6 @@ fn tint_symbol() {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"}, {"m", "tint_symbol_1"}, {"p1", "tint_symbol_2"},
{"f", "tint_symbol_3"}, {"p2", "tint_symbol_4"}, {"a", "tint_symbol_5"},
{"b", "tint_symbol_6"}, {"c", "tint_symbol_7"}, {"d", "tint_symbol_8"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveCoreDiagnosticRuleName) {
Expand Down Expand Up @@ -449,15 +370,6 @@ fn tint_symbol(@location(0) tint_symbol_1 : f32) -> @location(0) f32 {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"},
{"value", "tint_symbol_1"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, AttemptSymbolCollision) {
Expand All @@ -484,17 +396,6 @@ fn tint_symbol() -> @builtin(position) vec4<f32> {
auto got = Run<Renamer>(src);

EXPECT_EQ(expect, str(got));

auto* data = got.data.Get<Renamer::Data>();

ASSERT_NE(data, nullptr);
Renamer::Remappings expected_remappings = {
{"entry", "tint_symbol"},
{"tint_symbol", "tint_symbol_1"},
{"tint_symbol_2", "tint_symbol_2"},
{"tint_symbol_4", "tint_symbol_3"},
};
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
}

TEST_F(RenamerTest, PreserveTexelFormatAndAccess) {
Expand Down

0 comments on commit 38268c8

Please sign in to comment.