[tint] Move HLSL AST transforms to lang/hlsl/writer/ast_raise
These transforms are exclusively used by the HLSL AST writer.
Reduces build times when building Tint without `tint_build_hlsl_writer`
Change-Id: I9d50f59a945d0b39a60eb6e20d1b71614fb40669
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/150140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/cmd/test/BUILD.cmake b/src/tint/cmd/test/BUILD.cmake
index 7f9126e..526ca2e 100644
--- a/src/tint/cmd/test/BUILD.cmake
+++ b/src/tint/cmd/test/BUILD.cmake
@@ -80,6 +80,7 @@
if(TINT_BUILD_HLSL_WRITER)
tint_target_add_dependencies(tint_cmd_test_test_cmd test_cmd
tint_lang_hlsl_writer_ast_printer_test
+ tint_lang_hlsl_writer_ast_raise_test
)
endif(TINT_BUILD_HLSL_WRITER)
diff --git a/src/tint/cmd/test/BUILD.gn b/src/tint/cmd/test/BUILD.gn
index 4b932d6..313aafb 100644
--- a/src/tint/cmd/test/BUILD.gn
+++ b/src/tint/cmd/test/BUILD.gn
@@ -76,7 +76,10 @@
}
if (tint_build_hlsl_writer) {
- deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_printer:unittests" ]
+ deps += [
+ "${tint_src_dir}/lang/hlsl/writer/ast_printer:unittests",
+ "${tint_src_dir}/lang/hlsl/writer/ast_raise:unittests",
+ ]
}
if (tint_build_ir) {
diff --git a/src/tint/lang/glsl/writer/ast_printer/BUILD.cmake b/src/tint/lang/glsl/writer/ast_printer/BUILD.cmake
index f8f380e..6822d6d 100644
--- a/src/tint/lang/glsl/writer/ast_printer/BUILD.cmake
+++ b/src/tint/lang/glsl/writer/ast_printer/BUILD.cmake
@@ -66,6 +66,12 @@
)
endif(TINT_BUILD_GLSL_WRITER)
+if(TINT_BUILD_HLSL_WRITER)
+ tint_target_add_dependencies(tint_lang_glsl_writer_ast_printer lib
+ tint_lang_hlsl_writer_ast_raise
+ )
+endif(TINT_BUILD_HLSL_WRITER)
+
endif(TINT_BUILD_GLSL_WRITER)
if(TINT_BUILD_GLSL_WRITER)
################################################################################
diff --git a/src/tint/lang/glsl/writer/ast_printer/BUILD.gn b/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
index f07d9ca..3c59f7c 100644
--- a/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
@@ -65,6 +65,10 @@
if (tint_build_glsl_writer) {
deps += [ "${tint_src_dir}/lang/glsl/writer/common" ]
}
+
+ if (tint_build_hlsl_writer) {
+ deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_raise" ]
+ }
}
}
if (tint_build_unittests) {
diff --git a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
index 7436941..7c974ec 100644
--- a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
@@ -34,6 +34,7 @@
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/glsl/writer/common/options.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/internal_attribute.h"
@@ -44,7 +45,6 @@
#include "src/tint/lang/wgsl/ast/transform/builtin_polyfill.h"
#include "src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.h"
#include "src/tint/lang/wgsl/ast/transform/combine_samplers.h"
-#include "src/tint/lang/wgsl/ast/transform/decompose_memory_access.h"
#include "src/tint/lang/wgsl/ast/transform/demote_to_helper.h"
#include "src/tint/lang/wgsl/ast/transform/direct_variable_access.h"
#include "src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis.h"
diff --git a/src/tint/lang/hlsl/writer/BUILD.cmake b/src/tint/lang/hlsl/writer/BUILD.cmake
index f82c2ea..df4dc70 100644
--- a/src/tint/lang/hlsl/writer/BUILD.cmake
+++ b/src/tint/lang/hlsl/writer/BUILD.cmake
@@ -22,6 +22,7 @@
################################################################################
include(lang/hlsl/writer/ast_printer/BUILD.cmake)
+include(lang/hlsl/writer/ast_raise/BUILD.cmake)
include(lang/hlsl/writer/common/BUILD.cmake)
if(TINT_BUILD_HLSL_WRITER)
@@ -67,6 +68,7 @@
if(TINT_BUILD_HLSL_WRITER)
tint_target_add_dependencies(tint_lang_hlsl_writer lib
tint_lang_hlsl_writer_ast_printer
+ tint_lang_hlsl_writer_ast_raise
)
endif(TINT_BUILD_HLSL_WRITER)
diff --git a/src/tint/lang/hlsl/writer/BUILD.gn b/src/tint/lang/hlsl/writer/BUILD.gn
index c0435f6..62cf889 100644
--- a/src/tint/lang/hlsl/writer/BUILD.gn
+++ b/src/tint/lang/hlsl/writer/BUILD.gn
@@ -60,7 +60,10 @@
]
if (tint_build_hlsl_writer) {
- deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_printer" ]
+ deps += [
+ "${tint_src_dir}/lang/hlsl/writer/ast_printer",
+ "${tint_src_dir}/lang/hlsl/writer/ast_raise",
+ ]
}
}
}
diff --git a/src/tint/lang/hlsl/writer/ast_printer/BUILD.cmake b/src/tint/lang/hlsl/writer/ast_printer/BUILD.cmake
index 8a43885..5c13dec 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/BUILD.cmake
+++ b/src/tint/lang/hlsl/writer/ast_printer/BUILD.cmake
@@ -61,6 +61,12 @@
tint_utils_traits
)
+if(TINT_BUILD_HLSL_WRITER)
+ tint_target_add_dependencies(tint_lang_hlsl_writer_ast_printer lib
+ tint_lang_hlsl_writer_ast_raise
+ )
+endif(TINT_BUILD_HLSL_WRITER)
+
endif(TINT_BUILD_HLSL_WRITER)
if(TINT_BUILD_HLSL_WRITER)
################################################################################
@@ -139,6 +145,7 @@
tint_target_add_dependencies(tint_lang_hlsl_writer_ast_printer_test test
tint_lang_hlsl_writer
tint_lang_hlsl_writer_ast_printer
+ tint_lang_hlsl_writer_ast_raise
)
endif(TINT_BUILD_HLSL_WRITER)
diff --git a/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn b/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
index 88e7e42..de41c15 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
@@ -62,6 +62,10 @@
"${tint_src_dir}/utils/text",
"${tint_src_dir}/utils/traits",
]
+
+ if (tint_build_hlsl_writer) {
+ deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_raise" ]
+ }
}
}
if (tint_build_unittests) {
@@ -135,6 +139,7 @@
deps += [
"${tint_src_dir}/lang/hlsl/writer",
"${tint_src_dir}/lang/hlsl/writer/ast_printer",
+ "${tint_src_dir}/lang/hlsl/writer/ast_raise",
]
}
}
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
index 61f8422..1c077b1 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
@@ -33,6 +33,12 @@
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/internal_attribute.h"
@@ -41,24 +47,18 @@
#include "src/tint/lang/wgsl/ast/transform/array_length_from_uniform.h"
#include "src/tint/lang/wgsl/ast/transform/binding_remapper.h"
#include "src/tint/lang/wgsl/ast/transform/builtin_polyfill.h"
-#include "src/tint/lang/wgsl/ast/transform/calculate_array_length.h"
#include "src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.h"
-#include "src/tint/lang/wgsl/ast/transform/decompose_memory_access.h"
#include "src/tint/lang/wgsl/ast/transform/demote_to_helper.h"
#include "src/tint/lang/wgsl/ast/transform/direct_variable_access.h"
#include "src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis.h"
#include "src/tint/lang/wgsl/ast/transform/expand_compound_assignment.h"
-#include "src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h"
#include "src/tint/lang/wgsl/ast/transform/manager.h"
#include "src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.h"
-#include "src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h"
#include "src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h"
#include "src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h"
-#include "src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h"
#include "src/tint/lang/wgsl/ast/transform/remove_phonies.h"
#include "src/tint/lang/wgsl/ast/transform/robustness.h"
#include "src/tint/lang/wgsl/ast/transform/simplify_pointers.h"
-#include "src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h"
#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
#include "src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers.h"
#include "src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.h"
@@ -186,7 +186,7 @@
// SimplifyPointers transform. Can't do it right now because
// LocalizeStructArrayAssignment introduces pointers.
manager.Add<ast::transform::SimplifyPointers>();
- manager.Add<ast::transform::LocalizeStructArrayAssignment>();
+ manager.Add<LocalizeStructArrayAssignment>();
manager.Add<ast::transform::PromoteSideEffectsToDecl>();
@@ -267,18 +267,17 @@
// with the current stage output.
// Build the config for internal TruncateInterstageVariables transform.
- ast::transform::TruncateInterstageVariables::Config truncate_interstage_variables_cfg;
+ TruncateInterstageVariables::Config truncate_interstage_variables_cfg;
truncate_interstage_variables_cfg.interstage_locations =
std::move(options.interstage_locations);
- manager.Add<ast::transform::TruncateInterstageVariables>();
- data.Add<ast::transform::TruncateInterstageVariables::Config>(
- std::move(truncate_interstage_variables_cfg));
+ manager.Add<TruncateInterstageVariables>();
+ data.Add<TruncateInterstageVariables::Config>(std::move(truncate_interstage_variables_cfg));
}
// NumWorkgroupsFromUniform must come after CanonicalizeEntryPointIO, as it
// assumes that num_workgroups builtins only appear as struct members and are
// only accessed directly via member accessors.
- manager.Add<ast::transform::NumWorkgroupsFromUniform>();
+ manager.Add<NumWorkgroupsFromUniform>();
manager.Add<ast::transform::VectorizeScalarMatrixInitializers>();
manager.Add<ast::transform::SimplifyPointers>();
manager.Add<ast::transform::RemovePhonies>();
@@ -306,20 +305,20 @@
// of `*(&(intrinsic_load()))` expressions.
// * RemovePhonies, as phonies can be assigned a pointer to a
// non-constructible buffer, or dynamic array, which DMA cannot cope with.
- manager.Add<ast::transform::DecomposeMemoryAccess>();
+ manager.Add<DecomposeMemoryAccess>();
// CalculateArrayLength must come after DecomposeMemoryAccess, as
// DecomposeMemoryAccess special-cases the arrayLength() intrinsic, which
// will be transformed by CalculateArrayLength
- manager.Add<ast::transform::CalculateArrayLength>();
+ manager.Add<CalculateArrayLength>();
manager.Add<ast::transform::PromoteInitializersToLet>();
- manager.Add<ast::transform::RemoveContinueInSwitch>();
+ manager.Add<RemoveContinueInSwitch>();
manager.Add<ast::transform::AddEmptyEntryPoint>();
data.Add<ast::transform::CanonicalizeEntryPointIO::Config>(
ast::transform::CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
- data.Add<ast::transform::NumWorkgroupsFromUniform::Config>(options.root_constant_binding_point);
+ data.Add<NumWorkgroupsFromUniform::Config>(options.root_constant_binding_point);
SanitizedResult result;
ast::transform::DataMap outputs;
@@ -1102,7 +1101,7 @@
const sem::Function* func) {
auto* expr = call->Declaration();
- if (ast::HasAttribute<ast::transform::CalculateArrayLength::BufferSizeIntrinsic>(
+ if (ast::HasAttribute<CalculateArrayLength::BufferSizeIntrinsic>(
func->Declaration()->attributes)) {
// Special function generated by the CalculateArrayLength transform for
// calling X.GetDimensions(Y)
@@ -1117,8 +1116,8 @@
return true;
}
- if (auto* intrinsic = ast::GetAttribute<ast::transform::DecomposeMemoryAccess::Intrinsic>(
- func->Declaration()->attributes)) {
+ if (auto* intrinsic =
+ ast::GetAttribute<DecomposeMemoryAccess::Intrinsic>(func->Declaration()->attributes)) {
switch (intrinsic->address_space) {
case core::AddressSpace::kUniform:
return EmitUniformBufferAccess(out, expr, intrinsic);
@@ -1335,10 +1334,9 @@
return true;
}
-bool ASTPrinter::EmitUniformBufferAccess(
- StringStream& out,
- const ast::CallExpression* expr,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
+bool ASTPrinter::EmitUniformBufferAccess(StringStream& out,
+ const ast::CallExpression* expr,
+ const DecomposeMemoryAccess::Intrinsic* intrinsic) {
auto const buffer = intrinsic->Buffer()->identifier->symbol.Name();
auto* const offset = expr->args[0];
@@ -1367,7 +1365,7 @@
// scalar_offset_index or scalar_offset_index_unified_expr. Currently only loading f16 scalar
// require using offset in bytes.
const bool need_offset_in_bytes =
- intrinsic->type == ast::transform::DecomposeMemoryAccess::Intrinsic::DataType::kF16;
+ intrinsic->type == DecomposeMemoryAccess::Intrinsic::DataType::kF16;
if (!scalar_offset_constant) {
// UBO offset not compile-time known.
@@ -1398,8 +1396,8 @@
const char swizzle[] = {'x', 'y', 'z', 'w'};
- using Op = ast::transform::DecomposeMemoryAccess::Intrinsic::Op;
- using DataType = ast::transform::DecomposeMemoryAccess::Intrinsic::DataType;
+ using Op = DecomposeMemoryAccess::Intrinsic::Op;
+ using DataType = DecomposeMemoryAccess::Intrinsic::DataType;
switch (intrinsic->op) {
case Op::kLoad: {
auto cast = [&](const char* to, auto&& load) {
@@ -1622,16 +1620,15 @@
return false;
}
-bool ASTPrinter::EmitStorageBufferAccess(
- StringStream& out,
- const ast::CallExpression* expr,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
+bool ASTPrinter::EmitStorageBufferAccess(StringStream& out,
+ const ast::CallExpression* expr,
+ const DecomposeMemoryAccess::Intrinsic* intrinsic) {
auto const buffer = intrinsic->Buffer()->identifier->symbol.Name();
auto* const offset = expr->args[0];
auto* const value = expr->args.Length() > 1 ? expr->args[1] : nullptr;
- using Op = ast::transform::DecomposeMemoryAccess::Intrinsic::Op;
- using DataType = ast::transform::DecomposeMemoryAccess::Intrinsic::DataType;
+ using Op = DecomposeMemoryAccess::Intrinsic::Op;
+ using DataType = DecomposeMemoryAccess::Intrinsic::DataType;
switch (intrinsic->op) {
case Op::kLoad: {
auto load = [&](const char* cast, int n) {
@@ -1782,10 +1779,9 @@
return false;
}
-bool ASTPrinter::EmitStorageAtomicIntrinsic(
- const ast::Function* func,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
- using Op = ast::transform::DecomposeMemoryAccess::Intrinsic::Op;
+bool ASTPrinter::EmitStorageAtomicIntrinsic(const ast::Function* func,
+ const DecomposeMemoryAccess::Intrinsic* intrinsic) {
+ using Op = DecomposeMemoryAccess::Intrinsic::Op;
const sem::Function* sem_func = builder_.Sem().Get(func);
auto* result_ty = sem_func->ReturnType();
@@ -3125,8 +3121,7 @@
auto* sem = builder_.Sem().Get(func);
// Emit storage atomic helpers
- if (auto* intrinsic =
- ast::GetAttribute<ast::transform::DecomposeMemoryAccess::Intrinsic>(func->attributes)) {
+ if (auto* intrinsic = ast::GetAttribute<DecomposeMemoryAccess::Intrinsic>(func->attributes)) {
if (intrinsic->address_space == core::AddressSpace::kStorage && intrinsic->IsAtomic()) {
if (!EmitStorageAtomicIntrinsic(func, intrinsic)) {
return false;
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.h b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.h
index 5061c45..7b7966b 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.h
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.h
@@ -24,8 +24,8 @@
#include "src/tint/api/common/binding_point.h"
#include "src/tint/api/options/array_length_from_uniform.h"
#include "src/tint/lang/core/builtin_value.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h"
#include "src/tint/lang/hlsl/writer/common/options.h"
-#include "src/tint/lang/wgsl/ast/transform/decompose_memory_access.h"
#include "src/tint/lang/wgsl/program/program_builder.h"
#include "src/tint/utils/containers/scope_stack.h"
#include "src/tint/utils/generator/text_generator.h"
@@ -147,23 +147,23 @@
const sem::Call* call,
const sem::ValueConstructor* ctor);
/// Handles generating a call expression to a
- /// ast::transform::DecomposeMemoryAccess::Intrinsic for a uniform buffer
+ /// DecomposeMemoryAccess::Intrinsic for a uniform buffer
/// @param out the output stream
/// @param expr the call expression
- /// @param intrinsic the ast::transform::DecomposeMemoryAccess::Intrinsic
+ /// @param intrinsic the DecomposeMemoryAccess::Intrinsic
/// @returns true if the call expression is emitted
bool EmitUniformBufferAccess(StringStream& out,
const ast::CallExpression* expr,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic);
+ const DecomposeMemoryAccess::Intrinsic* intrinsic);
/// Handles generating a call expression to a
- /// ast::transform::DecomposeMemoryAccess::Intrinsic for a storage buffer
+ /// DecomposeMemoryAccess::Intrinsic for a storage buffer
/// @param out the output stream
/// @param expr the call expression
- /// @param intrinsic the ast::transform::DecomposeMemoryAccess::Intrinsic
+ /// @param intrinsic the DecomposeMemoryAccess::Intrinsic
/// @returns true if the call expression is emitted
bool EmitStorageBufferAccess(StringStream& out,
const ast::CallExpression* expr,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic);
+ const DecomposeMemoryAccess::Intrinsic* intrinsic);
/// Handles generating a barrier intrinsic call
/// @param out the output stream
/// @param builtin the semantic information for the barrier builtin
@@ -176,14 +176,13 @@
/// @returns true if the call expression is emitted
bool EmitStorageAtomicCall(StringStream& out,
const ast::CallExpression* expr,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic);
+ const DecomposeMemoryAccess::Intrinsic* intrinsic);
/// Handles generating the helper function for the atomic intrinsic function
/// @param func the function
/// @param intrinsic the atomic intrinsic
/// @returns true if the function is emitted
- bool EmitStorageAtomicIntrinsic(
- const ast::Function* func,
- const ast::transform::DecomposeMemoryAccess::Intrinsic* intrinsic);
+ bool EmitStorageAtomicIntrinsic(const ast::Function* func,
+ const DecomposeMemoryAccess::Intrinsic* intrinsic);
/// Handles generating an atomic intrinsic call for a workgroup variable
/// @param out the output stream
/// @param expr the call expression
@@ -530,8 +529,8 @@
};
struct DMAIntrinsic {
- ast::transform::DecomposeMemoryAccess::Intrinsic::Op op;
- ast::transform::DecomposeMemoryAccess::Intrinsic::DataType type;
+ DecomposeMemoryAccess::Intrinsic::Op op;
+ DecomposeMemoryAccess::Intrinsic::DataType type;
bool operator==(const DMAIntrinsic& rhs) const { return op == rhs.op && type == rhs.type; }
/// Hasher is a std::hash function for DMAIntrinsic
struct Hasher {
diff --git a/src/tint/lang/hlsl/writer/ast_raise/BUILD.cfg b/src/tint/lang/hlsl/writer/ast_raise/BUILD.cfg
new file mode 100644
index 0000000..31b4636
--- /dev/null
+++ b/src/tint/lang/hlsl/writer/ast_raise/BUILD.cfg
@@ -0,0 +1,3 @@
+{
+ "condition": "tint_build_hlsl_writer"
+}
diff --git a/src/tint/lang/hlsl/writer/ast_raise/BUILD.cmake b/src/tint/lang/hlsl/writer/ast_raise/BUILD.cmake
new file mode 100644
index 0000000..6e3e1f0
--- /dev/null
+++ b/src/tint/lang/hlsl/writer/ast_raise/BUILD.cmake
@@ -0,0 +1,123 @@
+# Copyright 2023 The Tint Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+# tools/src/cmd/gen/build/BUILD.cmake.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+# Do not modify this file directly
+################################################################################
+
+if(TINT_BUILD_HLSL_WRITER)
+################################################################################
+# Target: tint_lang_hlsl_writer_ast_raise
+# Kind: lib
+# Condition: TINT_BUILD_HLSL_WRITER
+################################################################################
+tint_add_target(tint_lang_hlsl_writer_ast_raise lib
+ lang/hlsl/writer/ast_raise/calculate_array_length.cc
+ lang/hlsl/writer/ast_raise/calculate_array_length.h
+ lang/hlsl/writer/ast_raise/decompose_memory_access.cc
+ lang/hlsl/writer/ast_raise/decompose_memory_access.h
+ lang/hlsl/writer/ast_raise/localize_struct_array_assignment.cc
+ lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h
+ lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
+ lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h
+ lang/hlsl/writer/ast_raise/remove_continue_in_switch.cc
+ lang/hlsl/writer/ast_raise/remove_continue_in_switch.h
+ lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
+ lang/hlsl/writer/ast_raise/truncate_interstage_variables.h
+)
+
+tint_target_add_dependencies(tint_lang_hlsl_writer_ast_raise lib
+ tint_api_common
+ tint_lang_core
+ tint_lang_core_constant
+ tint_lang_core_type
+ tint_lang_wgsl_ast
+ tint_lang_wgsl_ast_transform
+ tint_lang_wgsl_program
+ tint_lang_wgsl_resolver
+ tint_lang_wgsl_sem
+ tint_utils_containers
+ tint_utils_diagnostic
+ tint_utils_ice
+ tint_utils_id
+ tint_utils_macros
+ tint_utils_math
+ tint_utils_memory
+ tint_utils_reflection
+ tint_utils_result
+ tint_utils_rtti
+ tint_utils_symbol
+ tint_utils_text
+ tint_utils_traits
+)
+
+endif(TINT_BUILD_HLSL_WRITER)
+if(TINT_BUILD_HLSL_WRITER)
+################################################################################
+# Target: tint_lang_hlsl_writer_ast_raise_test
+# Kind: test
+# Condition: TINT_BUILD_HLSL_WRITER
+################################################################################
+tint_add_target(tint_lang_hlsl_writer_ast_raise_test test
+ lang/hlsl/writer/ast_raise/calculate_array_length_test.cc
+ lang/hlsl/writer/ast_raise/decompose_memory_access_test.cc
+ lang/hlsl/writer/ast_raise/localize_struct_array_assignment_test.cc
+ lang/hlsl/writer/ast_raise/num_workgroups_from_uniform_test.cc
+ lang/hlsl/writer/ast_raise/remove_continue_in_switch_test.cc
+ lang/hlsl/writer/ast_raise/truncate_interstage_variables_test.cc
+)
+
+tint_target_add_dependencies(tint_lang_hlsl_writer_ast_raise_test test
+ tint_api_common
+ tint_lang_core
+ tint_lang_core_constant
+ tint_lang_core_type
+ tint_lang_wgsl_ast
+ tint_lang_wgsl_ast_transform
+ tint_lang_wgsl_ast_transform_test
+ tint_lang_wgsl_program
+ tint_lang_wgsl_reader
+ tint_lang_wgsl_sem
+ tint_lang_wgsl_writer
+ tint_utils_containers
+ tint_utils_diagnostic
+ tint_utils_ice
+ tint_utils_id
+ tint_utils_macros
+ tint_utils_math
+ tint_utils_memory
+ tint_utils_reflection
+ tint_utils_result
+ tint_utils_rtti
+ tint_utils_symbol
+ tint_utils_text
+ tint_utils_traits
+)
+
+tint_target_add_external_dependencies(tint_lang_hlsl_writer_ast_raise_test test
+ "gtest"
+)
+
+if(TINT_BUILD_HLSL_WRITER)
+ tint_target_add_dependencies(tint_lang_hlsl_writer_ast_raise_test test
+ tint_lang_hlsl_writer_ast_raise
+ )
+endif(TINT_BUILD_HLSL_WRITER)
+
+endif(TINT_BUILD_HLSL_WRITER)
\ No newline at end of file
diff --git a/src/tint/lang/hlsl/writer/ast_raise/BUILD.gn b/src/tint/lang/hlsl/writer/ast_raise/BUILD.gn
new file mode 100644
index 0000000..89f2e4b
--- /dev/null
+++ b/src/tint/lang/hlsl/writer/ast_raise/BUILD.gn
@@ -0,0 +1,118 @@
+# Copyright 2023 The Tint Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+# tools/src/cmd/gen/build/BUILD.gn.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+# Do not modify this file directly
+################################################################################
+
+import("../../../../../../scripts/tint_overrides_with_defaults.gni")
+
+import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+ import("//testing/test.gni")
+}
+if (tint_build_hlsl_writer) {
+ libtint_source_set("ast_raise") {
+ sources = [
+ "calculate_array_length.cc",
+ "calculate_array_length.h",
+ "decompose_memory_access.cc",
+ "decompose_memory_access.h",
+ "localize_struct_array_assignment.cc",
+ "localize_struct_array_assignment.h",
+ "num_workgroups_from_uniform.cc",
+ "num_workgroups_from_uniform.h",
+ "remove_continue_in_switch.cc",
+ "remove_continue_in_switch.h",
+ "truncate_interstage_variables.cc",
+ "truncate_interstage_variables.h",
+ ]
+ deps = [
+ "${tint_src_dir}/api/common",
+ "${tint_src_dir}/lang/core",
+ "${tint_src_dir}/lang/core/constant",
+ "${tint_src_dir}/lang/core/type",
+ "${tint_src_dir}/lang/wgsl/ast",
+ "${tint_src_dir}/lang/wgsl/ast/transform",
+ "${tint_src_dir}/lang/wgsl/program",
+ "${tint_src_dir}/lang/wgsl/resolver",
+ "${tint_src_dir}/lang/wgsl/sem",
+ "${tint_src_dir}/utils/containers",
+ "${tint_src_dir}/utils/diagnostic",
+ "${tint_src_dir}/utils/ice",
+ "${tint_src_dir}/utils/id",
+ "${tint_src_dir}/utils/macros",
+ "${tint_src_dir}/utils/math",
+ "${tint_src_dir}/utils/memory",
+ "${tint_src_dir}/utils/reflection",
+ "${tint_src_dir}/utils/result",
+ "${tint_src_dir}/utils/rtti",
+ "${tint_src_dir}/utils/symbol",
+ "${tint_src_dir}/utils/text",
+ "${tint_src_dir}/utils/traits",
+ ]
+ }
+}
+if (tint_build_unittests) {
+ if (tint_build_hlsl_writer) {
+ tint_unittests_source_set("unittests") {
+ testonly = true
+ sources = [
+ "calculate_array_length_test.cc",
+ "decompose_memory_access_test.cc",
+ "localize_struct_array_assignment_test.cc",
+ "num_workgroups_from_uniform_test.cc",
+ "remove_continue_in_switch_test.cc",
+ "truncate_interstage_variables_test.cc",
+ ]
+ deps = [
+ "${tint_src_dir}:gmock_and_gtest",
+ "${tint_src_dir}/api/common",
+ "${tint_src_dir}/lang/core",
+ "${tint_src_dir}/lang/core/constant",
+ "${tint_src_dir}/lang/core/type",
+ "${tint_src_dir}/lang/wgsl/ast",
+ "${tint_src_dir}/lang/wgsl/ast/transform",
+ "${tint_src_dir}/lang/wgsl/ast/transform:unittests",
+ "${tint_src_dir}/lang/wgsl/program",
+ "${tint_src_dir}/lang/wgsl/reader",
+ "${tint_src_dir}/lang/wgsl/sem",
+ "${tint_src_dir}/lang/wgsl/writer",
+ "${tint_src_dir}/utils/containers",
+ "${tint_src_dir}/utils/diagnostic",
+ "${tint_src_dir}/utils/ice",
+ "${tint_src_dir}/utils/id",
+ "${tint_src_dir}/utils/macros",
+ "${tint_src_dir}/utils/math",
+ "${tint_src_dir}/utils/memory",
+ "${tint_src_dir}/utils/reflection",
+ "${tint_src_dir}/utils/result",
+ "${tint_src_dir}/utils/rtti",
+ "${tint_src_dir}/utils/symbol",
+ "${tint_src_dir}/utils/text",
+ "${tint_src_dir}/utils/traits",
+ ]
+
+ if (tint_build_hlsl_writer) {
+ deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_raise" ]
+ }
+ }
+ }
+}
diff --git a/src/tint/lang/wgsl/ast/transform/calculate_array_length.cc b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.cc
similarity index 89%
rename from src/tint/lang/wgsl/ast/transform/calculate_array_length.cc
rename to src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.cc
index b36c275..604700f 100644
--- a/src/tint/lang/wgsl/ast/transform/calculate_array_length.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/calculate_array_length.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h"
#include <unordered_map>
#include <utility>
@@ -34,10 +34,10 @@
#include "src/tint/utils/math/hash.h"
#include "src/tint/utils/rtti/switch.h"
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::CalculateArrayLength);
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::CalculateArrayLength::BufferSizeIntrinsic);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::CalculateArrayLength);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::CalculateArrayLength::BufferSizeIntrinsic);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
using namespace tint::core::fluent_types; // NOLINT
@@ -59,7 +59,7 @@
/// ArrayUsage describes a runtime array usage.
/// It is used as a key by the array_length_by_usage map.
struct ArrayUsage {
- BlockStatement const* const block;
+ ast::BlockStatement const* const block;
sem::Variable const* const buffer;
bool operator==(const ArrayUsage& rhs) const {
return block == rhs.block && buffer == rhs.buffer;
@@ -71,7 +71,7 @@
} // namespace
-CalculateArrayLength::BufferSizeIntrinsic::BufferSizeIntrinsic(GenerationID pid, NodeID nid)
+CalculateArrayLength::BufferSizeIntrinsic::BufferSizeIntrinsic(GenerationID pid, ast::NodeID nid)
: Base(pid, nid, tint::Empty) {}
CalculateArrayLength::BufferSizeIntrinsic::~BufferSizeIntrinsic() = default;
std::string CalculateArrayLength::BufferSizeIntrinsic::InternalName() const {
@@ -87,9 +87,9 @@
CalculateArrayLength::CalculateArrayLength() = default;
CalculateArrayLength::~CalculateArrayLength() = default;
-Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
- const DataMap&,
- DataMap&) const {
+ast::transform::Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
+ const ast::transform::DataMap&,
+ ast::transform::DataMap&) const {
if (!ShouldRun(src)) {
return SkipTransform;
}
@@ -106,16 +106,16 @@
return tint::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] {
auto name = b.Sym();
auto type = CreateASTTypeFor(ctx, buffer_type);
- auto* disable_validation = b.Disable(DisabledValidation::kFunctionParameter);
+ auto* disable_validation = b.Disable(ast::DisabledValidation::kFunctionParameter);
b.Func(name,
- tint::Vector{
+ Vector{
b.Param("buffer",
b.ty.ptr(buffer_type->AddressSpace(), type, buffer_type->Access()),
- tint::Vector{disable_validation}),
+ Vector{disable_validation}),
b.Param("result", b.ty.ptr<function, u32>()),
},
b.ty.void_(), nullptr,
- tint::Vector{
+ Vector{
b.ASTNodes().Create<BufferSizeIntrinsic>(b.ID(), b.AllocateNodeID()),
});
@@ -127,13 +127,13 @@
// Find all the arrayLength() calls...
for (auto* node : src->ASTNodes().Objects()) {
- if (auto* call_expr = node->As<CallExpression>()) {
+ if (auto* call_expr = node->As<ast::CallExpression>()) {
auto* call = sem.Get(call_expr)->UnwrapMaterialize()->As<sem::Call>();
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
if (builtin->Type() == core::Function::kArrayLength) {
// We're dealing with an arrayLength() call
- if (auto* call_stmt = call->Stmt()->Declaration()->As<CallStatement>()) {
+ if (auto* call_stmt = call->Stmt()->Declaration()->As<ast::CallStatement>()) {
if (call_stmt->expr == call_expr) {
// arrayLength() is used as a statement.
// The argument expression must be side-effect free, so just drop the
@@ -150,13 +150,13 @@
// arrayLength(&struct_var.array_member)
// arrayLength(&array_var)
auto* arg = call_expr->args[0];
- auto* address_of = arg->As<UnaryOpExpression>();
+ auto* address_of = arg->As<ast::UnaryOpExpression>();
if (TINT_UNLIKELY(!address_of || address_of->op != core::UnaryOp::kAddressOf)) {
TINT_ICE()
<< "arrayLength() expected address-of, got " << arg->TypeInfo().name;
}
auto* storage_buffer_expr = address_of->expr;
- if (auto* accessor = storage_buffer_expr->As<MemberAccessorExpression>()) {
+ if (auto* accessor = storage_buffer_expr->As<ast::MemberAccessorExpression>()) {
storage_buffer_expr = accessor->object;
}
auto* storage_buffer_sem = sem.Get<sem::VariableUser>(storage_buffer_expr);
@@ -198,7 +198,8 @@
// array_length = ----------------------------------------
// array_stride
auto name = b.Sym();
- const Expression* total_size = b.Expr(buffer_size_result->variable);
+ const ast::Expression* total_size =
+ b.Expr(buffer_size_result->variable);
const core::type::Array* array_type = Switch(
storage_buffer_type->StoreType(),
@@ -242,4 +243,4 @@
return resolver::Resolve(b);
}
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/calculate_array_length.h b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h
similarity index 71%
rename from src/tint/lang/wgsl/ast/transform/calculate_array_length.h
rename to src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h
index f492e90..e798a77 100644
--- a/src/tint/lang/wgsl/ast/transform/calculate_array_length.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h
@@ -12,31 +12,32 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_CALCULATE_ARRAY_LENGTH_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_CALCULATE_ARRAY_LENGTH_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_CALCULATE_ARRAY_LENGTH_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_CALCULATE_ARRAY_LENGTH_H_
#include <string>
#include "src/tint/lang/wgsl/ast/internal_attribute.h"
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// CalculateArrayLength is a transform used to replace calls to arrayLength()
/// with a value calculated from the size of the storage buffer.
///
/// @note Depends on the following transforms to have been run first:
/// * SimplifyPointers
-class CalculateArrayLength final : public Castable<CalculateArrayLength, Transform> {
+class CalculateArrayLength final
+ : public Castable<CalculateArrayLength, ast::transform::Transform> {
public:
/// BufferSizeIntrinsic is an InternalAttribute that's applied to intrinsic
/// functions used to obtain the runtime size of a storage buffer.
- class BufferSizeIntrinsic final : public Castable<BufferSizeIntrinsic, InternalAttribute> {
+ class BufferSizeIntrinsic final : public Castable<BufferSizeIntrinsic, ast::InternalAttribute> {
public:
/// Constructor
/// @param generation_id the identifier of the program that owns this node
/// @param nid the unique node identifier
- BufferSizeIntrinsic(GenerationID generation_id, NodeID nid);
+ BufferSizeIntrinsic(GenerationID generation_id, ast::NodeID nid);
/// Destructor
~BufferSizeIntrinsic() override;
@@ -46,7 +47,7 @@
/// Performs a deep clone of this object using the program::CloneContext `ctx`.
/// @param ctx the clone context
/// @return the newly cloned object
- const BufferSizeIntrinsic* Clone(CloneContext& ctx) const override;
+ const BufferSizeIntrinsic* Clone(ast::CloneContext& ctx) const override;
};
/// Constructor
@@ -54,12 +55,12 @@
/// Destructor
~CalculateArrayLength() override;
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_CALCULATE_ARRAY_LENGTH_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_CALCULATE_ARRAY_LENGTH_H_
diff --git a/src/tint/lang/wgsl/ast/transform/calculate_array_length_test.cc b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length_test.cc
similarity index 97%
rename from src/tint/lang/wgsl/ast/transform/calculate_array_length_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/calculate_array_length_test.cc
index 41f99cf..11ae0fc 100644
--- a/src/tint/lang/wgsl/ast/transform/calculate_array_length_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/calculate_array_length_test.cc
@@ -12,16 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/calculate_array_length.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/calculate_array_length.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
#include "src/tint/lang/wgsl/ast/transform/simplify_pointers.h"
#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
-using CalculateArrayLengthTest = TransformTest;
+using CalculateArrayLengthTest = ast::transform::TransformTest;
+using Unshadow = ast::transform::Unshadow;
+using SimplifyPointers = ast::transform::SimplifyPointers;
TEST_F(CalculateArrayLengthTest, ShouldRunEmptyModule) {
auto* src = R"()";
@@ -548,4 +550,4 @@
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc
similarity index 91%
rename from src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc
rename to src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc
index b60adb1..9cff4ce 100644
--- a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/decompose_memory_access.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h"
#include <memory>
#include <string>
@@ -45,10 +45,10 @@
using namespace tint::core::number_suffixes; // NOLINT
using namespace tint::core::fluent_types; // NOLINT
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::DecomposeMemoryAccess);
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::DecomposeMemoryAccess::Intrinsic);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::DecomposeMemoryAccess);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::DecomposeMemoryAccess::Intrinsic);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
@@ -68,17 +68,17 @@
/// offsets for storage and uniform buffer accesses.
struct Offset : Castable<Offset> {
/// @returns builds and returns the Expression in `ctx.dst`
- virtual const Expression* Build(program::CloneContext& ctx) const = 0;
+ virtual const ast::Expression* Build(program::CloneContext& ctx) const = 0;
};
/// OffsetExpr is an implementation of Offset that clones and casts the given
/// expression to `u32`.
struct OffsetExpr : Offset {
- const Expression* const expr = nullptr;
+ const ast::Expression* const expr = nullptr;
- explicit OffsetExpr(const Expression* e) : expr(e) {}
+ explicit OffsetExpr(const ast::Expression* e) : expr(e) {}
- const Expression* Build(program::CloneContext& ctx) const override {
+ const ast::Expression* Build(program::CloneContext& ctx) const override {
auto* type = ctx.src->Sem().GetVal(expr)->Type()->UnwrapRef();
auto* res = ctx.Clone(expr);
if (!type->Is<core::type::U32>()) {
@@ -95,7 +95,7 @@
explicit OffsetLiteral(uint32_t lit) : literal(lit) {}
- const Expression* Build(program::CloneContext& ctx) const override {
+ const ast::Expression* Build(program::CloneContext& ctx) const override {
return ctx.dst->Expr(u32(literal));
}
};
@@ -107,8 +107,8 @@
Offset const* lhs = nullptr;
Offset const* rhs = nullptr;
- const Expression* Build(program::CloneContext& ctx) const override {
- return ctx.dst->create<BinaryExpression>(op, lhs->Build(ctx), rhs->Build(ctx));
+ const ast::Expression* Build(program::CloneContext& ctx) const override {
+ return ctx.dst->create<ast::BinaryExpression>(op, lhs->Build(ctx), rhs->Build(ctx));
}
};
@@ -317,8 +317,8 @@
/// Store describes a single storage or uniform buffer write
struct Store {
- const AssignmentStatement* assignment; // The AST assignment statement
- BufferAccess target; // The target for the write
+ const ast::AssignmentStatement* assignment; // The AST assignment statement
+ BufferAccess target; // The target for the write
};
} // namespace
@@ -334,9 +334,9 @@
/// expressions chain the access.
/// Subset of #expression_order, as expressions are not removed from
/// #expression_order.
- std::unordered_map<const Expression*, BufferAccess> accesses;
+ std::unordered_map<const ast::Expression*, BufferAccess> accesses;
/// The visited order of AST expressions (superset of #accesses)
- std::vector<const Expression*> expression_order;
+ std::vector<const ast::Expression*> expression_order;
/// [buffer-type, element-type] -> load function name
std::unordered_map<LoadStoreKey, Symbol, LoadStoreKey::Hasher> load_funcs;
/// [buffer-type, element-type] -> store function name
@@ -358,8 +358,8 @@
/// @param expr the expression to convert to an Offset
/// @returns an Offset for the given Expression
- const Offset* ToOffset(const Expression* expr) {
- if (auto* lit = expr->As<IntLiteralExpression>()) {
+ const Offset* ToOffset(const ast::Expression* expr) {
+ if (auto* lit = expr->As<ast::IntLiteralExpression>()) {
if (lit->value >= 0) {
return offsets_.Create<OffsetLiteral>(static_cast<uint32_t>(lit->value));
}
@@ -436,7 +436,7 @@
/// to #expression_order.
/// @param expr the expression that performs the access
/// @param access the access
- void AddAccess(const Expression* expr, const BufferAccess& access) {
+ void AddAccess(const ast::Expression* expr, const BufferAccess& access) {
TINT_ASSERT(access.type);
accesses.emplace(expr, access);
expression_order.emplace_back(expr);
@@ -447,7 +447,7 @@
/// `node`, an invalid BufferAccess is returned.
/// @param node the expression that performed an access
/// @return the BufferAccess for the given expression
- BufferAccess TakeAccess(const Expression* node) {
+ BufferAccess TakeAccess(const ast::Expression* node) {
auto lhs_it = accesses.find(node);
if (lhs_it == accesses.end()) {
return {};
@@ -470,16 +470,16 @@
core::AddressSpace address_space,
const Symbol& buffer) {
return tint::GetOrCreate(load_funcs, LoadStoreKey{el_ty, buffer}, [&] {
- tint::Vector params{b.Param("offset", b.ty.u32())};
+ Vector params{b.Param("offset", b.ty.u32())};
auto name = b.Symbols().New(buffer.Name() + "_load");
if (auto* intrinsic = IntrinsicLoadFor(ctx.dst, el_ty, address_space, buffer)) {
auto el_ast_ty = CreateASTTypeFor(ctx, el_ty);
b.Func(name, params, el_ast_ty, nullptr,
- tint::Vector{
+ Vector{
intrinsic,
- b.Disable(DisabledValidation::kFunctionHasNoBody),
+ b.Disable(ast::DisabledValidation::kFunctionHasNoBody),
});
} else if (auto* arr_ty = el_ty->As<core::type::Array>()) {
// fn load_func(buffer : buf_ty, offset : u32) -> array<T, N> {
@@ -502,8 +502,8 @@
TINT_ICE() << "unexpected non-constant array count";
arr_cnt = 1;
}
- auto* for_cond = b.create<BinaryExpression>(core::BinaryOp::kLessThan, b.Expr(i),
- b.Expr(u32(arr_cnt.value())));
+ auto* for_cond = b.create<ast::BinaryExpression>(
+ core::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_cnt.value())));
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
auto* arr_el = b.IndexAccessor(arr, i);
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, u32(arr_ty->Stride())));
@@ -512,13 +512,13 @@
b.For(for_init, for_cond, for_cont, b.Block(b.Assign(arr_el, el_val)));
b.Func(name, params, CreateASTTypeFor(ctx, arr_ty),
- tint::Vector{
+ Vector{
b.Decl(arr),
for_loop,
b.Return(arr),
});
} else {
- tint::Vector<const Expression*, 8> values;
+ Vector<const ast::Expression*, 8> values;
if (auto* mat_ty = el_ty->As<core::type::Matrix>()) {
auto* vec_ty = mat_ty->ColumnType();
Symbol load = LoadFunc(vec_ty, address_space, buffer);
@@ -534,7 +534,7 @@
}
}
b.Func(name, params, CreateASTTypeFor(ctx, el_ty),
- tint::Vector{
+ Vector{
b.Return(b.Call(CreateASTTypeFor(ctx, el_ty), values)),
});
}
@@ -550,7 +550,7 @@
/// @return the name of the function that performs the store
Symbol StoreFunc(const core::type::Type* el_ty, const Symbol& buffer) {
return tint::GetOrCreate(store_funcs, LoadStoreKey{el_ty, buffer}, [&] {
- tint::Vector params{
+ Vector params{
b.Param("offset", b.ty.u32()),
b.Param("value", CreateASTTypeFor(ctx, el_ty)),
};
@@ -559,12 +559,12 @@
if (auto* intrinsic = IntrinsicStoreFor(ctx.dst, el_ty, buffer)) {
b.Func(name, params, b.ty.void_(), nullptr,
- tint::Vector{
+ Vector{
intrinsic,
- b.Disable(DisabledValidation::kFunctionHasNoBody),
+ b.Disable(ast::DisabledValidation::kFunctionHasNoBody),
});
} else {
- auto body = Switch<tint::Vector<const Statement*, 8>>(
+ auto body = Switch<Vector<const ast::Statement*, 8>>(
el_ty, //
[&](const core::type::Array* arr_ty) {
// fn store_func(buffer : buf_ty, offset : u32, value : el_ty) {
@@ -588,7 +588,7 @@
TINT_ICE() << "unexpected non-constant array count";
arr_cnt = 1;
}
- auto* for_cond = b.create<BinaryExpression>(
+ auto* for_cond = b.create<ast::BinaryExpression>(
core::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_cnt.value())));
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
auto* arr_el = b.IndexAccessor(array, i);
@@ -596,12 +596,12 @@
auto* store_stmt = b.CallStmt(b.Call(store, el_offset, arr_el));
auto* for_loop = b.For(for_init, for_cond, for_cont, b.Block(store_stmt));
- return tint::Vector{b.Decl(array), for_loop};
+ return Vector{b.Decl(array), for_loop};
},
[&](const core::type::Matrix* mat_ty) {
auto* vec_ty = mat_ty->ColumnType();
Symbol store = StoreFunc(vec_ty, buffer);
- tint::Vector<const Statement*, 4> stmts;
+ Vector<const ast::Statement*, 4> stmts;
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
auto* offset = b.Add("offset", u32(i * mat_ty->ColumnStride()));
auto* element = b.IndexAccessor("value", u32(i));
@@ -611,7 +611,7 @@
return stmts;
},
[&](const core::type::Struct* str) {
- tint::Vector<const Statement*, 8> stmts;
+ Vector<const ast::Statement*, 8> stmts;
for (auto* member : str->Members()) {
auto* offset = b.Add("offset", u32(member->Offset()));
auto* element = b.MemberAccessor("value", ctx.Clone(member->Name()));
@@ -643,7 +643,7 @@
return tint::GetOrCreate(atomic_funcs, AtomicKey{el_ty, op, buffer}, [&] {
// The first parameter to all WGSL atomics is the expression to the
// atomic. This is replaced with two parameters: the buffer and offset.
- tint::Vector params{b.Param("offset", b.ty.u32())};
+ Vector params{b.Param("offset", b.ty.u32())};
// Other parameters are copied as-is:
for (size_t i = 1; i < intrinsic->Parameters().Length(); i++) {
@@ -658,13 +658,13 @@
<< el_ty->TypeInfo().name;
}
- Type ret_ty = CreateASTTypeFor(ctx, intrinsic->ReturnType());
+ ast::Type ret_ty = CreateASTTypeFor(ctx, intrinsic->ReturnType());
auto name = b.Symbols().New(buffer.Name() + intrinsic->str());
b.Func(name, std::move(params), ret_ty, nullptr,
- tint::Vector{
+ Vector{
atomic,
- b.Disable(DisabledValidation::kFunctionHasNoBody),
+ b.Disable(ast::DisabledValidation::kFunctionHasNoBody),
});
return name;
});
@@ -672,12 +672,12 @@
};
DecomposeMemoryAccess::Intrinsic::Intrinsic(GenerationID pid,
- NodeID nid,
+ ast::NodeID nid,
Op o,
DataType ty,
core::AddressSpace as,
- const IdentifierExpression* buf)
- : Base(pid, nid, tint::Vector{buf}), op(o), type(ty), address_space(as) {}
+ const ast::IdentifierExpression* buf)
+ : Base(pid, nid, Vector{buf}), op(o), type(ty), address_space(as) {}
DecomposeMemoryAccess::Intrinsic::~Intrinsic() = default;
std::string DecomposeMemoryAccess::Intrinsic::InternalName() const {
StringStream ss;
@@ -787,16 +787,17 @@
return op != Op::kLoad && op != Op::kStore;
}
-const IdentifierExpression* DecomposeMemoryAccess::Intrinsic::Buffer() const {
+const ast::IdentifierExpression* DecomposeMemoryAccess::Intrinsic::Buffer() const {
return dependencies[0];
}
DecomposeMemoryAccess::DecomposeMemoryAccess() = default;
DecomposeMemoryAccess::~DecomposeMemoryAccess() = default;
-Transform::ApplyResult DecomposeMemoryAccess::Apply(const Program* src,
- const DataMap&,
- DataMap&) const {
+ast::transform::Transform::ApplyResult DecomposeMemoryAccess::Apply(
+ const Program* src,
+ const ast::transform::DataMap&,
+ ast::transform::DataMap&) const {
if (!ShouldRun(src)) {
return SkipTransform;
}
@@ -815,7 +816,7 @@
// nodes are fully immutable and require their children to be constructed
// first so their pointer can be passed to the parent's initializer.
for (auto* node : src->ASTNodes().Objects()) {
- if (auto* ident = node->As<IdentifierExpression>()) {
+ if (auto* ident = node->As<ast::IdentifierExpression>()) {
// X
if (auto* sem_ident = sem.GetVal(ident)) {
if (auto* user = sem_ident->UnwrapLoad()->As<sem::VariableUser>()) {
@@ -835,7 +836,7 @@
continue;
}
- if (auto* accessor = node->As<MemberAccessorExpression>()) {
+ if (auto* accessor = node->As<ast::MemberAccessorExpression>()) {
// X.Y
auto* accessor_sem = sem.Get(accessor)->UnwrapLoad();
if (auto* swizzle = accessor_sem->As<sem::Swizzle>()) {
@@ -865,7 +866,7 @@
continue;
}
- if (auto* accessor = node->As<IndexAccessorExpression>()) {
+ if (auto* accessor = node->As<ast::IndexAccessorExpression>()) {
if (auto access = state.TakeAccess(accessor->object)) {
// X[Y]
if (auto* arr = access.type->As<core::type::Array>()) {
@@ -898,7 +899,7 @@
}
}
- if (auto* op = node->As<UnaryOpExpression>()) {
+ if (auto* op = node->As<ast::UnaryOpExpression>()) {
if (op->op == core::UnaryOp::kAddressOf) {
// &X
if (auto access = state.TakeAccess(op->expr)) {
@@ -910,7 +911,7 @@
}
}
- if (auto* assign = node->As<AssignmentStatement>()) {
+ if (auto* assign = node->As<ast::AssignmentStatement>()) {
// X = Y
// Move the LHS access to a store.
if (auto lhs = state.TakeAccess(assign->lhs)) {
@@ -918,7 +919,7 @@
}
}
- if (auto* call_expr = node->As<CallExpression>()) {
+ if (auto* call_expr = node->As<ast::CallExpression>()) {
auto* call = sem.Get(call_expr)->UnwrapMaterialize()->As<sem::Call>();
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
if (builtin->Type() == core::Function::kArrayLength) {
@@ -937,7 +938,7 @@
auto buffer = ctx.Clone(access.var->Declaration()->name->symbol);
Symbol func = state.AtomicFunc(el_ty, builtin, buffer);
- tint::Vector<const Expression*, 8> args{offset};
+ Vector<const ast::Expression*, 8> args{offset};
for (size_t i = 1; i < call_expr->args.Length(); i++) {
auto* arg = call_expr->args[i];
args.Push(ctx.Clone(arg));
@@ -985,7 +986,7 @@
return resolver::Resolve(b);
}
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Offset);
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::OffsetLiteral);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::Offset);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::OffsetLiteral);
diff --git a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.h b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h
similarity index 79%
rename from src/tint/lang/wgsl/ast/transform/decompose_memory_access.h
rename to src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h
index 120bb26..cea9dd9 100644
--- a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h
@@ -12,25 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_DECOMPOSE_MEMORY_ACCESS_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_DECOMPOSE_MEMORY_ACCESS_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_DECOMPOSE_MEMORY_ACCESS_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_DECOMPOSE_MEMORY_ACCESS_H_
#include <string>
#include "src/tint/lang/wgsl/ast/internal_attribute.h"
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// DecomposeMemoryAccess is a transform used to replace storage and uniform buffer accesses with a
/// combination of load, store or atomic functions on primitive types.
-class DecomposeMemoryAccess final : public Castable<DecomposeMemoryAccess, Transform> {
+class DecomposeMemoryAccess final
+ : public Castable<DecomposeMemoryAccess, ast::transform::Transform> {
public:
/// Intrinsic is an InternalAttribute that's used to decorate a stub function so that the HLSL
/// transforms this into calls to
/// `[RW]ByteAddressBuffer.Load[N]()` or `[RW]ByteAddressBuffer.Store[N]()`,
/// with a possible cast.
- class Intrinsic final : public Castable<Intrinsic, InternalAttribute> {
+ class Intrinsic final : public Castable<Intrinsic, ast::InternalAttribute> {
public:
/// Intrinsic op
enum class Op {
@@ -77,11 +78,11 @@
/// @param address_space the address space of the buffer
/// @param buffer the storage or uniform buffer identifier
Intrinsic(GenerationID pid,
- NodeID nid,
+ ast::NodeID nid,
Op o,
DataType type,
core::AddressSpace address_space,
- const IdentifierExpression* buffer);
+ const ast::IdentifierExpression* buffer);
/// Destructor
~Intrinsic() override;
@@ -92,13 +93,13 @@
/// Performs a deep clone of this object using the program::CloneContext `ctx`.
/// @param ctx the clone context
/// @return the newly cloned object
- const Intrinsic* Clone(CloneContext& ctx) const override;
+ const Intrinsic* Clone(ast::CloneContext& ctx) const override;
/// @return true if op is atomic
bool IsAtomic() const;
/// @return the buffer that this intrinsic operates on
- const IdentifierExpression* Buffer() const;
+ const ast::IdentifierExpression* Buffer() const;
/// The op of the intrinsic
const Op op;
@@ -115,15 +116,15 @@
/// Destructor
~DecomposeMemoryAccess() override;
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
private:
struct State;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_DECOMPOSE_MEMORY_ACCESS_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_DECOMPOSE_MEMORY_ACCESS_H_
diff --git a/src/tint/lang/wgsl/ast/transform/decompose_memory_access_test.cc b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access_test.cc
similarity index 99%
rename from src/tint/lang/wgsl/ast/transform/decompose_memory_access_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access_test.cc
index 9d07277..e2b900d 100644
--- a/src/tint/lang/wgsl/ast/transform/decompose_memory_access_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access_test.cc
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/decompose_memory_access.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
-using DecomposeMemoryAccessTest = TransformTest;
+using DecomposeMemoryAccessTest = ast::transform::TransformTest;
TEST_F(DecomposeMemoryAccessTest, ShouldRunEmptyModule) {
auto* src = R"()";
@@ -3942,4 +3942,4 @@
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.cc b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.cc
similarity index 65%
rename from src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.cc
rename to src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.cc
index e4c1bb4..883c911 100644
--- a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h"
#include <unordered_map>
#include <utility>
@@ -30,9 +30,9 @@
#include "src/tint/lang/wgsl/sem/variable.h"
#include "src/tint/utils/macros/scoped_assignment.h"
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::LocalizeStructArrayAssignment);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::LocalizeStructArrayAssignment);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// PIMPL state for the transform
struct LocalizeStructArrayAssignment::State {
@@ -45,14 +45,14 @@
ApplyResult Run() {
struct Shared {
bool process_nested_nodes = false;
- tint::Vector<const Statement*, 4> insert_before_stmts;
- tint::Vector<const Statement*, 4> insert_after_stmts;
+ Vector<const ast::Statement*, 4> insert_before_stmts;
+ Vector<const ast::Statement*, 4> insert_after_stmts;
} s;
bool made_changes = false;
for (auto* node : ctx.src->ASTNodes().Objects()) {
- if (auto* assign_stmt = node->As<AssignmentStatement>()) {
+ if (auto* assign_stmt = node->As<ast::AssignmentStatement>()) {
// Process if it's an assignment statement to a dynamically indexed array
// within a struct on a function or private storage variable. This
// specific use-case is what FXC fails to compile with:
@@ -72,7 +72,7 @@
// Reset shared state for this assignment statement
s = Shared{};
- const Expression* new_lhs = nullptr;
+ const ast::Expression* new_lhs = nullptr;
{
TINT_SCOPED_ASSIGNMENT(s.process_nested_nodes, true);
new_lhs = ctx.Clone(assign_stmt->lhs);
@@ -100,52 +100,53 @@
return SkipTransform;
}
- ctx.ReplaceAll([&](const IndexAccessorExpression* index_access) -> const Expression* {
- if (!s.process_nested_nodes) {
- return nullptr;
- }
-
- // Indexing a member access expr?
- auto* mem_access = index_access->object->As<MemberAccessorExpression>();
- if (!mem_access) {
- return nullptr;
- }
-
- // Process any nested IndexAccessorExpressions
- mem_access = ctx.Clone(mem_access);
-
- // Store the address of the member access into a let as we need to read
- // the value twice e.g. let tint_symbol = &(s.a1);
- auto mem_access_ptr = b.Sym();
- s.insert_before_stmts.Push(b.Decl(b.Let(mem_access_ptr, b.AddressOf(mem_access))));
-
- // Disable further transforms when cloning
- TINT_SCOPED_ASSIGNMENT(s.process_nested_nodes, false);
-
- // Copy entire array out of struct into local temp var
- // e.g. var tint_symbol_1 = *(tint_symbol);
- auto tmp_var = b.Sym();
- s.insert_before_stmts.Push(b.Decl(b.Var(tmp_var, b.Deref(mem_access_ptr))));
-
- // Replace input index_access with a clone of itself, but with its
- // .object replaced by the new temp var. This is returned from this
- // function to modify the original assignment statement. e.g.
- // tint_symbol_1[uniforms.i]
- auto* new_index_access = b.IndexAccessor(tmp_var, ctx.Clone(index_access->index));
-
- // Assign temp var back to array
- // e.g. *(tint_symbol) = tint_symbol_1;
- auto* assign_rhs_to_temp = b.Assign(b.Deref(mem_access_ptr), tmp_var);
- {
- tint::Vector<const Statement*, 8> stmts{assign_rhs_to_temp};
- for (auto* stmt : s.insert_after_stmts) {
- stmts.Push(stmt);
+ ctx.ReplaceAll(
+ [&](const ast::IndexAccessorExpression* index_access) -> const ast::Expression* {
+ if (!s.process_nested_nodes) {
+ return nullptr;
}
- s.insert_after_stmts = std::move(stmts);
- }
- return new_index_access;
- });
+ // Indexing a member access expr?
+ auto* mem_access = index_access->object->As<ast::MemberAccessorExpression>();
+ if (!mem_access) {
+ return nullptr;
+ }
+
+ // Process any nested IndexAccessorExpressions
+ mem_access = ctx.Clone(mem_access);
+
+ // Store the address of the member access into a let as we need to read
+ // the value twice e.g. let tint_symbol = &(s.a1);
+ auto mem_access_ptr = b.Sym();
+ s.insert_before_stmts.Push(b.Decl(b.Let(mem_access_ptr, b.AddressOf(mem_access))));
+
+ // Disable further transforms when cloning
+ TINT_SCOPED_ASSIGNMENT(s.process_nested_nodes, false);
+
+ // Copy entire array out of struct into local temp var
+ // e.g. var tint_symbol_1 = *(tint_symbol);
+ auto tmp_var = b.Sym();
+ s.insert_before_stmts.Push(b.Decl(b.Var(tmp_var, b.Deref(mem_access_ptr))));
+
+ // Replace input index_access with a clone of itself, but with its
+ // .object replaced by the new temp var. This is returned from this
+ // function to modify the original assignment statement. e.g.
+ // tint_symbol_1[uniforms.i]
+ auto* new_index_access = b.IndexAccessor(tmp_var, ctx.Clone(index_access->index));
+
+ // Assign temp var back to array
+ // e.g. *(tint_symbol) = tint_symbol_1;
+ auto* assign_rhs_to_temp = b.Assign(b.Deref(mem_access_ptr), tmp_var);
+ {
+ Vector<const ast::Statement*, 8> stmts{assign_rhs_to_temp};
+ for (auto* stmt : s.insert_after_stmts) {
+ stmts.Push(stmt);
+ }
+ s.insert_after_stmts = std::move(stmts);
+ }
+
+ return new_index_access;
+ });
ctx.Clone();
return resolver::Resolve(b);
@@ -161,22 +162,22 @@
/// Returns true if `expr` contains an index accessor expression to a
/// structure member of array type.
- bool ContainsStructArrayIndex(const Expression* expr) {
+ bool ContainsStructArrayIndex(const ast::Expression* expr) {
bool result = false;
- TraverseExpressions(expr, [&](const IndexAccessorExpression* ia) {
+ TraverseExpressions(expr, [&](const ast::IndexAccessorExpression* ia) {
// Indexing using a runtime value?
auto* idx_sem = src->Sem().GetVal(ia->index);
if (!idx_sem->ConstantValue()) {
// Indexing a member access expr?
- if (auto* ma = ia->object->As<MemberAccessorExpression>()) {
+ if (auto* ma = ia->object->As<ast::MemberAccessorExpression>()) {
// That accesses an array?
if (src->TypeOf(ma)->UnwrapRef()->Is<core::type::Array>()) {
result = true;
- return TraverseAction::Stop;
+ return ast::TraverseAction::Stop;
}
}
}
- return TraverseAction::Descend;
+ return ast::TraverseAction::Descend;
});
return result;
@@ -186,7 +187,7 @@
// of the assignment statement.
// See https://www.w3.org/TR/WGSL/#originating-variable-section
std::pair<const core::type::Type*, core::AddressSpace> GetOriginatingTypeAndAddressSpace(
- const AssignmentStatement* assign_stmt) {
+ const ast::AssignmentStatement* assign_stmt) {
auto* root_ident = src->Sem().GetVal(assign_stmt->lhs)->RootIdentifier();
if (TINT_UNLIKELY(!root_ident)) {
TINT_ICE() << "Unable to determine originating variable for lhs of assignment "
@@ -214,10 +215,11 @@
LocalizeStructArrayAssignment::~LocalizeStructArrayAssignment() = default;
-Transform::ApplyResult LocalizeStructArrayAssignment::Apply(const Program* src,
- const DataMap&,
- DataMap&) const {
+ast::transform::Transform::ApplyResult LocalizeStructArrayAssignment::Apply(
+ const Program* src,
+ const ast::transform::DataMap&,
+ ast::transform::DataMap&) const {
return State{src}.Run();
}
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h
similarity index 70%
rename from src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h
rename to src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h
index 32cf93e..d70e04e 100644
--- a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h
@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// This transforms replaces assignment to dynamically-indexed fixed-size arrays
/// in structs on shader-local variables with code that copies the arrays to a
@@ -28,7 +28,7 @@
/// @note Depends on the following transforms to have been run first:
/// * SimplifyPointers
class LocalizeStructArrayAssignment final
- : public Castable<LocalizeStructArrayAssignment, Transform> {
+ : public Castable<LocalizeStructArrayAssignment, ast::transform::Transform> {
public:
/// Constructor
LocalizeStructArrayAssignment();
@@ -36,15 +36,15 @@
/// Destructor
~LocalizeStructArrayAssignment() override;
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
private:
struct State;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
diff --git a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment_test.cc b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment_test.cc
similarity index 97%
rename from src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment_test.cc
index 1ca28d1..f6441f8 100644
--- a/src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment_test.cc
@@ -12,16 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/localize_struct_array_assignment.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/localize_struct_array_assignment.h"
#include "src/tint/lang/wgsl/ast/transform/simplify_pointers.h"
#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
-using LocalizeStructArrayAssignmentTest = TransformTest;
+using LocalizeStructArrayAssignmentTest = ast::transform::TransformTest;
+using Unshadow = ast::transform::Unshadow;
+using SimplifyPointers = ast::transform::SimplifyPointers;
TEST_F(LocalizeStructArrayAssignmentTest, EmptyModule) {
auto* src = R"()";
@@ -844,4 +846,4 @@
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.cc b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
similarity index 88%
rename from src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.cc
rename to src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
index d337198..3bb5a40 100644
--- a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h"
#include <memory>
#include <string>
@@ -30,15 +30,15 @@
using namespace tint::core::fluent_types; // NOLINT
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::NumWorkgroupsFromUniform);
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::NumWorkgroupsFromUniform::Config);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::NumWorkgroupsFromUniform);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::NumWorkgroupsFromUniform::Config);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
bool ShouldRun(const Program* program) {
for (auto* node : program->ASTNodes().Objects()) {
- if (auto* attr = node->As<BuiltinAttribute>()) {
+ if (auto* attr = node->As<ast::BuiltinAttribute>()) {
if (program->Sem().Get(attr)->Value() == core::BuiltinValue::kNumWorkgroups) {
return true;
}
@@ -68,9 +68,10 @@
NumWorkgroupsFromUniform::NumWorkgroupsFromUniform() = default;
NumWorkgroupsFromUniform::~NumWorkgroupsFromUniform() = default;
-Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src,
- const DataMap& inputs,
- DataMap&) const {
+ast::transform::Transform::ApplyResult NumWorkgroupsFromUniform::Apply(
+ const Program* src,
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap&) const {
ProgramBuilder b;
program::CloneContext ctx{&b, src, /* auto_clone_symbols */ true};
@@ -91,7 +92,7 @@
std::unordered_set<Accessor, Accessor::Hasher> to_replace;
for (auto* func : src->AST().Functions()) {
// num_workgroups is only valid for compute stages.
- if (func->PipelineStage() != PipelineStage::kCompute) {
+ if (func->PipelineStage() != ast::PipelineStage::kCompute) {
continue;
}
@@ -131,7 +132,7 @@
// Get (or create, on first call) the uniform buffer that will receive the
// number of workgroups.
- const Variable* num_workgroups_ubo = nullptr;
+ const ast::Variable* num_workgroups_ubo = nullptr;
auto get_ubo = [&] {
if (!num_workgroups_ubo) {
auto* num_workgroups_struct =
@@ -171,11 +172,11 @@
// Now replace all the places where the builtins are accessed with the value
// loaded from the uniform buffer.
for (auto* node : src->ASTNodes().Objects()) {
- auto* accessor = node->As<MemberAccessorExpression>();
+ auto* accessor = node->As<ast::MemberAccessorExpression>();
if (!accessor) {
continue;
}
- auto* ident = accessor->object->As<IdentifierExpression>();
+ auto* ident = accessor->object->As<ast::IdentifierExpression>();
if (!ident) {
continue;
}
@@ -195,4 +196,4 @@
NumWorkgroupsFromUniform::Config::Config(const Config&) = default;
NumWorkgroupsFromUniform::Config::~Config() = default;
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h
similarity index 78%
rename from src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h
rename to src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h
index 50407e4..4b26e33 100644
--- a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_NUM_WORKGROUPS_FROM_UNIFORM_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_NUM_WORKGROUPS_FROM_UNIFORM_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_NUM_WORKGROUPS_FROM_UNIFORM_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_NUM_WORKGROUPS_FROM_UNIFORM_H_
#include <optional>
#include "src/tint/api/common/binding_point.h"
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// NumWorkgroupsFromUniform is a transform that implements the `num_workgroups`
/// builtin by loading it from a uniform buffer.
@@ -39,7 +39,8 @@
///
/// @note Depends on the following transforms to have been run first:
/// * CanonicalizeEntryPointIO
-class NumWorkgroupsFromUniform final : public Castable<NumWorkgroupsFromUniform, Transform> {
+class NumWorkgroupsFromUniform final
+ : public Castable<NumWorkgroupsFromUniform, ast::transform::Transform> {
public:
/// Constructor
NumWorkgroupsFromUniform();
@@ -47,7 +48,7 @@
~NumWorkgroupsFromUniform() override;
/// Configuration options for the NumWorkgroupsFromUniform transform.
- struct Config final : public Castable<Config, Data> {
+ struct Config final : public Castable<Config, ast::transform::Data> {
/// Constructor
/// @param ubo_bp the binding point to use for the generated uniform buffer. If ubo_bp
/// contains no value, a free binding point will be used to ensure the generated program is
@@ -67,12 +68,12 @@
std::optional<BindingPoint> ubo_binding;
};
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_NUM_WORKGROUPS_FROM_UNIFORM_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_NUM_WORKGROUPS_FROM_UNIFORM_H_
diff --git a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform_test.cc b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform_test.cc
similarity index 94%
rename from src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform_test.cc
index a9651e0..e29ec8c 100644
--- a/src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/num_workgroups_from_uniform.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.h"
#include <utility>
@@ -20,15 +20,17 @@
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
-using NumWorkgroupsFromUniformTest = TransformTest;
+using NumWorkgroupsFromUniformTest = ast::transform::TransformTest;
+using CanonicalizeEntryPointIO = ast::transform::CanonicalizeEntryPointIO;
+using Unshadow = ast::transform::Unshadow;
TEST_F(NumWorkgroupsFromUniformTest, ShouldRunEmptyModule) {
auto* src = R"()";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
EXPECT_FALSE(ShouldRun<NumWorkgroupsFromUniform>(src, data));
}
@@ -40,7 +42,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
EXPECT_TRUE(ShouldRun<NumWorkgroupsFromUniform>(src, data));
}
@@ -52,10 +54,9 @@
}
)";
- auto* expect =
- "error: missing transform data for tint::ast::transform::NumWorkgroupsFromUniform";
+ auto* expect = "error: missing transform data for tint::hlsl::writer::NumWorkgroupsFromUniform";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
EXPECT_EQ(expect, str(got));
@@ -90,7 +91,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -134,7 +135,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -178,7 +179,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -233,7 +234,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -289,7 +290,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -388,7 +389,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -429,7 +430,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@@ -530,7 +531,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
// Make binding point unspecified.
data.Add<NumWorkgroupsFromUniform::Config>(std::nullopt);
@@ -684,7 +685,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
// Make binding point unspecified.
data.Add<NumWorkgroupsFromUniform::Config>(std::nullopt);
@@ -693,4 +694,4 @@
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.cc b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.cc
similarity index 82%
rename from src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.cc
rename to src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.cc
index c55eb98..b091b91 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h"
#include <string>
#include <unordered_map>
@@ -31,9 +31,9 @@
#include "src/tint/lang/wgsl/sem/while_statement.h"
#include "src/tint/utils/containers/map.h"
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::RemoveContinueInSwitch);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::RemoveContinueInSwitch);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// PIMPL state for the transform
struct RemoveContinueInSwitch::State {
@@ -47,7 +47,7 @@
bool made_changes = false;
for (auto* node : src->ASTNodes().Objects()) {
- auto* cont = node->As<ContinueStatement>();
+ auto* cont = node->As<ast::ContinueStatement>();
if (!cont) {
continue;
}
@@ -65,7 +65,7 @@
// switch.
auto var_name = b.Symbols().New("tint_continue");
auto* decl = b.Decl(b.Var(var_name, b.ty.bool_(), b.Expr(false)));
- auto ip = utils::GetInsertionPoint(ctx, switch_stmt);
+ auto ip = ast::transform::utils::GetInsertionPoint(ctx, switch_stmt);
ctx.InsertBefore(ip.first->Declaration()->statements, ip.second, decl);
// Create and insert 'if (tint_continue) { continue; }' after
@@ -104,12 +104,12 @@
const sem::Info& sem = src->Sem();
// Map of switch statement to 'tint_continue' variable.
- std::unordered_map<const SwitchStatement*, Symbol> switch_to_cont_var_name;
+ std::unordered_map<const ast::SwitchStatement*, Symbol> switch_to_cont_var_name;
// If `cont` is within a switch statement within a loop, returns a pointer to
// that switch statement.
- static const SwitchStatement* GetParentSwitchInLoop(const sem::Info& sem,
- const ContinueStatement* cont) {
+ static const ast::SwitchStatement* GetParentSwitchInLoop(const sem::Info& sem,
+ const ast::ContinueStatement* cont) {
// Find whether first parent is a switch or a loop
auto* sem_stmt = sem.Get(cont);
auto* sem_parent = sem_stmt->FindFirstParent<sem::SwitchStatement, sem::LoopBlockStatement,
@@ -117,18 +117,19 @@
if (!sem_parent) {
return nullptr;
}
- return sem_parent->Declaration()->As<SwitchStatement>();
+ return sem_parent->Declaration()->As<ast::SwitchStatement>();
}
};
RemoveContinueInSwitch::RemoveContinueInSwitch() = default;
RemoveContinueInSwitch::~RemoveContinueInSwitch() = default;
-Transform::ApplyResult RemoveContinueInSwitch::Apply(const Program* src,
- const DataMap&,
- DataMap&) const {
+ast::transform::Transform::ApplyResult RemoveContinueInSwitch::Apply(
+ const Program* src,
+ const ast::transform::DataMap&,
+ ast::transform::DataMap&) const {
State state(src);
return state.Run();
}
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h
similarity index 66%
rename from src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h
rename to src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h
index 8775c63..4ad747e 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h
@@ -12,18 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_REMOVE_CONTINUE_IN_SWITCH_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_REMOVE_CONTINUE_IN_SWITCH_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_REMOVE_CONTINUE_IN_SWITCH_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_REMOVE_CONTINUE_IN_SWITCH_H_
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// This transform replaces continue statements in switch cases with setting a
/// bool variable, and checking if the variable is set after the switch to
/// continue. It is necessary to work around FXC "error X3708: continue cannot
/// be used in a switch". See crbug.com/tint/1080.
-class RemoveContinueInSwitch final : public Castable<RemoveContinueInSwitch, Transform> {
+class RemoveContinueInSwitch final
+ : public Castable<RemoveContinueInSwitch, ast::transform::Transform> {
public:
/// Constructor
RemoveContinueInSwitch();
@@ -31,15 +32,15 @@
/// Destructor
~RemoveContinueInSwitch() override;
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
private:
struct State;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_REMOVE_CONTINUE_IN_SWITCH_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_REMOVE_CONTINUE_IN_SWITCH_H_
diff --git a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_test.cc b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch_test.cc
similarity index 94%
rename from src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch_test.cc
index ea82a6c..60153b1 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch_test.cc
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/remove_continue_in_switch.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
-using RemoveContinueInSwitchTest = TransformTest;
+using RemoveContinueInSwitchTest = ast::transform::TransformTest;
TEST_F(RemoveContinueInSwitchTest, ShouldRun_True) {
auto* src = R"(
@@ -101,7 +101,7 @@
auto* src = "";
auto* expect = src;
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -163,7 +163,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -247,7 +247,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -332,7 +332,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -423,7 +423,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -501,7 +501,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -553,7 +553,7 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@@ -607,11 +607,11 @@
}
)";
- DataMap data;
+ ast::transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.cc b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
similarity index 78%
rename from src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.cc
rename to src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
index 7b9bcf6..240da0a 100644
--- a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h"
#include <memory>
#include <string>
@@ -28,10 +28,10 @@
#include "src/tint/lang/wgsl/sem/variable.h"
#include "src/tint/utils/text/unicode.h"
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::TruncateInterstageVariables);
-TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::TruncateInterstageVariables::Config);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::TruncateInterstageVariables);
+TINT_INSTANTIATE_TYPEINFO(tint::hlsl::writer::TruncateInterstageVariables::Config);
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
@@ -48,9 +48,10 @@
TruncateInterstageVariables::TruncateInterstageVariables() = default;
TruncateInterstageVariables::~TruncateInterstageVariables() = default;
-Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src,
- const DataMap& config,
- DataMap&) const {
+ast::transform::Transform::ApplyResult TruncateInterstageVariables::Apply(
+ const Program* src,
+ const ast::transform::DataMap& config,
+ ast::transform::DataMap&) const {
ProgramBuilder b;
program::CloneContext ctx{&b, src, /* auto_clone_symbols */ true};
@@ -76,7 +77,7 @@
continue;
}
- if (func_ast->PipelineStage() != PipelineStage::kVertex) {
+ if (func_ast->PipelineStage() != ast::PipelineStage::kVertex) {
// Currently only vertex stage could have interstage output variables that need
// truncated.
continue;
@@ -119,8 +120,8 @@
old_shader_io_structs_to_new_struct_and_truncate_functions.GetOrCreate(str, [&] {
auto new_struct_sym = b.Symbols().New();
- tint::Vector<const StructMember*, 20> truncated_members;
- tint::Vector<const Expression*, 20> initializer_exprs;
+ Vector<const ast::StructMember*, 20> truncated_members;
+ Vector<const ast::Expression*, 20> initializer_exprs;
for (auto* member : str->Members()) {
if (omit_members.Contains(member)) {
@@ -136,10 +137,9 @@
// Create the mapping function to truncate the shader io.
auto mapping_fn_sym = b.Symbols().New("truncate_shader_output");
- b.Func(mapping_fn_sym,
- tint::Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
+ b.Func(mapping_fn_sym, Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
b.ty(new_struct_sym),
- tint::Vector{
+ Vector{
b.Return(b.Call(new_struct_sym, std::move(initializer_exprs))),
});
return TruncatedStructAndConverter{new_struct_sym, mapping_fn_sym};
@@ -155,24 +155,25 @@
}
// Replace return statements with new truncated shader IO struct
- ctx.ReplaceAll([&](const ReturnStatement* return_statement) -> const ReturnStatement* {
- auto* return_sem = sem.Get(return_statement);
- if (auto mapping_fn_sym =
- entry_point_functions_to_truncate_functions.Find(return_sem->Function())) {
- return b.Return(return_statement->source,
- b.Call(*mapping_fn_sym, ctx.Clone(return_statement->value)));
- }
- return nullptr;
- });
+ ctx.ReplaceAll(
+ [&](const ast::ReturnStatement* return_statement) -> const ast::ReturnStatement* {
+ auto* return_sem = sem.Get(return_statement);
+ if (auto mapping_fn_sym =
+ entry_point_functions_to_truncate_functions.Find(return_sem->Function())) {
+ return b.Return(return_statement->source,
+ b.Call(*mapping_fn_sym, ctx.Clone(return_statement->value)));
+ }
+ return nullptr;
+ });
// Remove IO attributes from old shader IO struct which is not used as entry point output
// anymore.
for (auto it : old_shader_io_structs_to_new_struct_and_truncate_functions) {
- const Struct* struct_ty = it.key->Declaration();
+ const ast::Struct* struct_ty = it.key->Declaration();
for (auto* member : struct_ty->members) {
for (auto* attr : member->attributes) {
- if (attr->IsAnyOf<BuiltinAttribute, LocationAttribute, InterpolateAttribute,
- InvariantAttribute>()) {
+ if (attr->IsAnyOf<ast::BuiltinAttribute, ast::LocationAttribute,
+ ast::InterpolateAttribute, ast::InvariantAttribute>()) {
ctx.Remove(member->attributes, attr);
}
}
@@ -192,4 +193,4 @@
TruncateInterstageVariables::Config& TruncateInterstageVariables::Config::operator=(const Config&) =
default;
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h
similarity index 84%
rename from src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h
rename to src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h
index 7c45cd9..8fe3250 100644
--- a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h
+++ b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_TRUNCATE_INTERSTAGE_VARIABLES_H_
-#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_TRUNCATE_INTERSTAGE_VARIABLES_H_
+#ifndef SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_TRUNCATE_INTERSTAGE_VARIABLES_H_
+#define SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_TRUNCATE_INTERSTAGE_VARIABLES_H_
#include <bitset>
#include "src/tint/api/common/binding_point.h"
#include "src/tint/lang/wgsl/ast/transform/transform.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
/// TruncateInterstageVariables is a transform that truncate interstage variables.
/// It must be run after CanonicalizeEntryPointIO which guarantees all interstage variables of
@@ -88,10 +88,11 @@
/// }
/// ```
///
-class TruncateInterstageVariables final : public Castable<TruncateInterstageVariables, Transform> {
+class TruncateInterstageVariables final
+ : public Castable<TruncateInterstageVariables, ast::transform::Transform> {
public:
/// Configuration options for the transform
- struct Config final : public Castable<Config, Data> {
+ struct Config final : public Castable<Config, ast::transform::Data> {
/// Constructor
Config();
@@ -119,12 +120,12 @@
/// Destructor
~TruncateInterstageVariables() override;
- /// @copydoc Transform::Apply
+ /// @copydoc ast::transform::Transform::Apply
ApplyResult Apply(const Program* program,
- const DataMap& inputs,
- DataMap& outputs) const override;
+ const ast::transform::DataMap& inputs,
+ ast::transform::DataMap& outputs) const override;
};
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
-#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_TRUNCATE_INTERSTAGE_VARIABLES_H_
+#endif // SRC_TINT_LANG_HLSL_WRITER_AST_RAISE_TRUNCATE_INTERSTAGE_VARIABLES_H_
diff --git a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables_test.cc b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables_test.cc
similarity index 92%
rename from src/tint/lang/wgsl/ast/transform/truncate_interstage_variables_test.cc
rename to src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables_test.cc
index 8884792..b0b0dee 100644
--- a/src/tint/lang/wgsl/ast/transform/truncate_interstage_variables_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables_test.cc
@@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/wgsl/ast/transform/truncate_interstage_variables.h"
+#include "src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.h"
#include "src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.h"
#include "gmock/gmock.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
-namespace tint::ast::transform {
+namespace tint::hlsl::writer {
namespace {
using ::testing::ContainerEq;
-using TruncateInterstageVariablesTest = TransformTest;
+using TruncateInterstageVariablesTest = ast::transform::TransformTest;
TEST_F(TruncateInterstageVariablesTest, ShouldRunVertex) {
auto* src = R"(
@@ -43,7 +43,7 @@
{
auto* expect =
- "error: missing transform data for tint::ast::transform::TruncateInterstageVariables";
+ "error: missing transform data for tint::hlsl::writer::TruncateInterstageVariables";
auto got = Run<TruncateInterstageVariables>(src);
EXPECT_EQ(expect, str(got));
}
@@ -51,7 +51,7 @@
{
// Empty interstage_locations: truncate all interstage variables, should run
TruncateInterstageVariables::Config cfg;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
EXPECT_TRUE(ShouldRun<TruncateInterstageVariables>(src, data));
}
@@ -61,7 +61,7 @@
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[0] = true;
cfg.interstage_locations[2] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
EXPECT_FALSE(ShouldRun<TruncateInterstageVariables>(src, data));
}
@@ -70,7 +70,7 @@
// Partial interstage_locations are marked: should run
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[2] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
EXPECT_TRUE(ShouldRun<TruncateInterstageVariables>(src, data));
}
@@ -91,7 +91,7 @@
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[2] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
EXPECT_FALSE(ShouldRun<TruncateInterstageVariables>(src, data));
@@ -109,11 +109,12 @@
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[0] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
- data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
- auto got = Run<CanonicalizeEntryPointIO>(src, data);
+ data.Add<ast::transform::CanonicalizeEntryPointIO::Config>(
+ ast::transform::CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
+ auto got = Run<ast::transform::CanonicalizeEntryPointIO>(src, data);
// Inevitably entry point can write only one variable if not using struct
// So the truncate won't run.
@@ -169,7 +170,7 @@
// fragment has input at @location(1)
cfg.interstage_locations[1] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -226,7 +227,7 @@
// fragment has input at @location(3)
cfg.interstage_locations[3] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -279,7 +280,7 @@
)";
TruncateInterstageVariables::Config cfg;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -349,7 +350,7 @@
cfg.interstage_locations[3] = true;
cfg.interstage_locations[5] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -426,7 +427,7 @@
// fragment has input at @location(3)
cfg.interstage_locations[3] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -521,7 +522,7 @@
// fragment has input at @location(3)
cfg.interstage_locations[3] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -586,7 +587,7 @@
// fragment has input at @location(3)
cfg.interstage_locations[3] = true;
- DataMap data;
+ ast::transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@@ -595,4 +596,4 @@
}
} // namespace
-} // namespace tint::ast::transform
+} // namespace tint::hlsl::writer
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.cmake b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
index 21e7fa3..07c97f8 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.cmake
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
@@ -36,8 +36,6 @@
lang/wgsl/ast/transform/binding_remapper.h
lang/wgsl/ast/transform/builtin_polyfill.cc
lang/wgsl/ast/transform/builtin_polyfill.h
- lang/wgsl/ast/transform/calculate_array_length.cc
- lang/wgsl/ast/transform/calculate_array_length.h
lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
lang/wgsl/ast/transform/canonicalize_entry_point_io.h
lang/wgsl/ast/transform/clamp_frag_depth.cc
@@ -46,8 +44,6 @@
lang/wgsl/ast/transform/combine_samplers.h
lang/wgsl/ast/transform/data.cc
lang/wgsl/ast/transform/data.h
- lang/wgsl/ast/transform/decompose_memory_access.cc
- lang/wgsl/ast/transform/decompose_memory_access.h
lang/wgsl/ast/transform/decompose_strided_array.cc
lang/wgsl/ast/transform/decompose_strided_array.h
lang/wgsl/ast/transform/decompose_strided_matrix.cc
@@ -70,8 +66,6 @@
lang/wgsl/ast/transform/get_insertion_point.h
lang/wgsl/ast/transform/hoist_to_decl_before.cc
lang/wgsl/ast/transform/hoist_to_decl_before.h
- lang/wgsl/ast/transform/localize_struct_array_assignment.cc
- lang/wgsl/ast/transform/localize_struct_array_assignment.h
lang/wgsl/ast/transform/manager.cc
lang/wgsl/ast/transform/manager.h
lang/wgsl/ast/transform/merge_return.cc
@@ -82,8 +76,6 @@
lang/wgsl/ast/transform/msl_subgroup_ballot.h
lang/wgsl/ast/transform/multiplanar_external_texture.cc
lang/wgsl/ast/transform/multiplanar_external_texture.h
- lang/wgsl/ast/transform/num_workgroups_from_uniform.cc
- lang/wgsl/ast/transform/num_workgroups_from_uniform.h
lang/wgsl/ast/transform/packed_vec3.cc
lang/wgsl/ast/transform/packed_vec3.h
lang/wgsl/ast/transform/pad_structs.cc
@@ -94,8 +86,6 @@
lang/wgsl/ast/transform/promote_initializers_to_let.h
lang/wgsl/ast/transform/promote_side_effects_to_decl.cc
lang/wgsl/ast/transform/promote_side_effects_to_decl.h
- lang/wgsl/ast/transform/remove_continue_in_switch.cc
- lang/wgsl/ast/transform/remove_continue_in_switch.h
lang/wgsl/ast/transform/remove_phonies.cc
lang/wgsl/ast/transform/remove_phonies.h
lang/wgsl/ast/transform/remove_unreachable_statements.cc
@@ -120,8 +110,6 @@
lang/wgsl/ast/transform/texture_builtins_from_uniform.h
lang/wgsl/ast/transform/transform.cc
lang/wgsl/ast/transform/transform.h
- lang/wgsl/ast/transform/truncate_interstage_variables.cc
- lang/wgsl/ast/transform/truncate_interstage_variables.h
lang/wgsl/ast/transform/unshadow.cc
lang/wgsl/ast/transform/unshadow.h
lang/wgsl/ast/transform/var_for_dynamic_index.cc
@@ -173,11 +161,9 @@
lang/wgsl/ast/transform/array_length_from_uniform_test.cc
lang/wgsl/ast/transform/binding_remapper_test.cc
lang/wgsl/ast/transform/builtin_polyfill_test.cc
- lang/wgsl/ast/transform/calculate_array_length_test.cc
lang/wgsl/ast/transform/canonicalize_entry_point_io_test.cc
lang/wgsl/ast/transform/clamp_frag_depth_test.cc
lang/wgsl/ast/transform/combine_samplers_test.cc
- lang/wgsl/ast/transform/decompose_memory_access_test.cc
lang/wgsl/ast/transform/decompose_strided_array_test.cc
lang/wgsl/ast/transform/decompose_strided_matrix_test.cc
lang/wgsl/ast/transform/demote_to_helper_test.cc
@@ -190,19 +176,16 @@
lang/wgsl/ast/transform/get_insertion_point_test.cc
lang/wgsl/ast/transform/helper_test.h
lang/wgsl/ast/transform/hoist_to_decl_before_test.cc
- lang/wgsl/ast/transform/localize_struct_array_assignment_test.cc
lang/wgsl/ast/transform/manager_test.cc
lang/wgsl/ast/transform/merge_return_test.cc
lang/wgsl/ast/transform/module_scope_var_to_entry_point_param_test.cc
lang/wgsl/ast/transform/msl_subgroup_ballot_test.cc
lang/wgsl/ast/transform/multiplanar_external_texture_test.cc
- lang/wgsl/ast/transform/num_workgroups_from_uniform_test.cc
lang/wgsl/ast/transform/packed_vec3_test.cc
lang/wgsl/ast/transform/pad_structs_test.cc
lang/wgsl/ast/transform/preserve_padding_test.cc
lang/wgsl/ast/transform/promote_initializers_to_let_test.cc
lang/wgsl/ast/transform/promote_side_effects_to_decl_test.cc
- lang/wgsl/ast/transform/remove_continue_in_switch_test.cc
lang/wgsl/ast/transform/remove_phonies_test.cc
lang/wgsl/ast/transform/remove_unreachable_statements_test.cc
lang/wgsl/ast/transform/renamer_test.cc
@@ -218,7 +201,6 @@
lang/wgsl/ast/transform/texture_1d_to_2d_test.cc
lang/wgsl/ast/transform/texture_builtins_from_uniform_test.cc
lang/wgsl/ast/transform/transform_test.cc
- lang/wgsl/ast/transform/truncate_interstage_variables_test.cc
lang/wgsl/ast/transform/unshadow_test.cc
lang/wgsl/ast/transform/var_for_dynamic_index_test.cc
lang/wgsl/ast/transform/vectorize_matrix_conversions_test.cc
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.gn b/src/tint/lang/wgsl/ast/transform/BUILD.gn
index 3f325ce..63aaa0f 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.gn
@@ -41,8 +41,6 @@
"binding_remapper.h",
"builtin_polyfill.cc",
"builtin_polyfill.h",
- "calculate_array_length.cc",
- "calculate_array_length.h",
"canonicalize_entry_point_io.cc",
"canonicalize_entry_point_io.h",
"clamp_frag_depth.cc",
@@ -51,8 +49,6 @@
"combine_samplers.h",
"data.cc",
"data.h",
- "decompose_memory_access.cc",
- "decompose_memory_access.h",
"decompose_strided_array.cc",
"decompose_strided_array.h",
"decompose_strided_matrix.cc",
@@ -75,8 +71,6 @@
"get_insertion_point.h",
"hoist_to_decl_before.cc",
"hoist_to_decl_before.h",
- "localize_struct_array_assignment.cc",
- "localize_struct_array_assignment.h",
"manager.cc",
"manager.h",
"merge_return.cc",
@@ -87,8 +81,6 @@
"msl_subgroup_ballot.h",
"multiplanar_external_texture.cc",
"multiplanar_external_texture.h",
- "num_workgroups_from_uniform.cc",
- "num_workgroups_from_uniform.h",
"packed_vec3.cc",
"packed_vec3.h",
"pad_structs.cc",
@@ -99,8 +91,6 @@
"promote_initializers_to_let.h",
"promote_side_effects_to_decl.cc",
"promote_side_effects_to_decl.h",
- "remove_continue_in_switch.cc",
- "remove_continue_in_switch.h",
"remove_phonies.cc",
"remove_phonies.h",
"remove_unreachable_statements.cc",
@@ -125,8 +115,6 @@
"texture_builtins_from_uniform.h",
"transform.cc",
"transform.h",
- "truncate_interstage_variables.cc",
- "truncate_interstage_variables.h",
"unshadow.cc",
"unshadow.h",
"var_for_dynamic_index.cc",
@@ -176,11 +164,9 @@
"array_length_from_uniform_test.cc",
"binding_remapper_test.cc",
"builtin_polyfill_test.cc",
- "calculate_array_length_test.cc",
"canonicalize_entry_point_io_test.cc",
"clamp_frag_depth_test.cc",
"combine_samplers_test.cc",
- "decompose_memory_access_test.cc",
"decompose_strided_array_test.cc",
"decompose_strided_matrix_test.cc",
"demote_to_helper_test.cc",
@@ -193,19 +179,16 @@
"get_insertion_point_test.cc",
"helper_test.h",
"hoist_to_decl_before_test.cc",
- "localize_struct_array_assignment_test.cc",
"manager_test.cc",
"merge_return_test.cc",
"module_scope_var_to_entry_point_param_test.cc",
"msl_subgroup_ballot_test.cc",
"multiplanar_external_texture_test.cc",
- "num_workgroups_from_uniform_test.cc",
"packed_vec3_test.cc",
"pad_structs_test.cc",
"preserve_padding_test.cc",
"promote_initializers_to_let_test.cc",
"promote_side_effects_to_decl_test.cc",
- "remove_continue_in_switch_test.cc",
"remove_phonies_test.cc",
"remove_unreachable_statements_test.cc",
"renamer_test.cc",
@@ -221,7 +204,6 @@
"texture_1d_to_2d_test.cc",
"texture_builtins_from_uniform_test.cc",
"transform_test.cc",
- "truncate_interstage_variables_test.cc",
"unshadow_test.cc",
"var_for_dynamic_index_test.cc",
"vectorize_matrix_conversions_test.cc",