Remove MSL override generation
This CL removes the override emission from the MSL backend. The override should be removed by the substitute_override transform before making it to the backend. Bug: tint:1155 Change-Id: I9d3852a7e20b258a2f0af200bff6268037eaa0b5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101662 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
e214a130dd
commit
5432767a04
|
@ -271,9 +271,11 @@ bool GeneratorImpl::Generate() {
|
|||
[&](const ast::Const*) {
|
||||
return true; // Constants are embedded at their use
|
||||
},
|
||||
[&](const ast::Override* override) {
|
||||
TINT_DEFER(line());
|
||||
return EmitOverride(override);
|
||||
[&](const ast::Override*) {
|
||||
// Override is removed with SubstituteOverride
|
||||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "Override should have been removed by the substitute_override transform.";
|
||||
return false;
|
||||
},
|
||||
[&](const ast::Function* func) {
|
||||
TINT_DEFER(line());
|
||||
|
@ -3038,22 +3040,6 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitOverride(const ast::Override* override) {
|
||||
auto* global = program_->Sem().Get<sem::GlobalVariable>(override);
|
||||
auto* type = global->Type();
|
||||
|
||||
auto out = line();
|
||||
out << "constant ";
|
||||
if (!EmitType(out, type, program_->Symbols().NameFor(override->symbol))) {
|
||||
return false;
|
||||
}
|
||||
out << " " << program_->Symbols().NameFor(override->symbol);
|
||||
|
||||
out << " [[function_constant(" << global->OverrideId().value << ")]];";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const sem::Type* ty) {
|
||||
return Switch(
|
||||
ty,
|
||||
|
|
|
@ -356,10 +356,6 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param let the variable to generate
|
||||
/// @returns true if the variable was emitted
|
||||
bool EmitLet(const ast::Let* let);
|
||||
/// Handles generating a module-scope 'override' declaration
|
||||
/// @param override the 'override' to emit
|
||||
/// @returns true if the variable was emitted
|
||||
bool EmitOverride(const ast::Override* override);
|
||||
/// Emits the zero value for the given type
|
||||
/// @param out the output of the expression stream
|
||||
/// @param type the type to emit the value for
|
||||
|
|
|
@ -328,27 +328,5 @@ void f() {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Override) {
|
||||
auto* var = Override("pos", ty.f32(), Expr(3_f), Id(23_a));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitOverride(var)) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "constant float pos [[function_constant(23)]];\n");
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Override_NoId) {
|
||||
auto* var_a = Override("a", ty.f32(), Id(0_a));
|
||||
auto* var_b = Override("b", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitOverride(var_a)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitOverride(var_b)) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(constant float a [[function_constant(0)]];
|
||||
constant float b [[function_constant(1)]];
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::msl
|
||||
|
|
Loading…
Reference in New Issue