[tint] Remove writer::IRTextGenerator

This is trivially inlineable.

Bug: tint:1988
Change-Id: I5d080feeb56fb6a68fb643435c7f1c634eae3605
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/143002
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index d2e27c1..07f598c 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -1000,15 +1000,6 @@
     ":libtint_type_src",
     ":libtint_utils_src",
   ]
-
-  if (tint_build_ir) {
-    sources += [
-      "writer/ir_text_generator.cc",
-      "writer/ir_text_generator.h",
-    ]
-
-    deps += [ ":libtint_ir_src" ]
-  }
 }
 
 libtint_source_set("libtint_spv_writer_src") {
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 23c0112..f702c55 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -577,8 +577,6 @@
   writer/binding_remapper_options.h
   writer/external_texture_options.cc
   writer/external_texture_options.h
-  writer/ir_text_generator.cc
-  writer/ir_text_generator.h
 )
 
 tint_generated(lang/core/builtin/access BENCH TEST)
diff --git a/src/tint/lang/msl/writer/generator_impl_ir.cc b/src/tint/lang/msl/writer/generator_impl_ir.cc
index 6231f5d..528c64d 100644
--- a/src/tint/lang/msl/writer/generator_impl_ir.cc
+++ b/src/tint/lang/msl/writer/generator_impl_ir.cc
@@ -52,7 +52,7 @@
     TINT_UNIMPLEMENTED(Writer, diagnostics_) \
         << "unhandled case in Switch(): " << (object_ptr ? object_ptr->TypeInfo().name : "<null>")
 
-GeneratorImplIr::GeneratorImplIr(ir::Module* module) : IRTextGenerator(module) {}
+GeneratorImplIr::GeneratorImplIr(ir::Module* module) : ir_(module) {}
 
 GeneratorImplIr::~GeneratorImplIr() = default;
 
@@ -90,6 +90,12 @@
     return true;
 }
 
+std::string GeneratorImplIr::Result() const {
+    utils::StringStream ss;
+    ss << preamble_buffer_.String() << std::endl << main_buffer_.String();
+    return ss.str();
+}
+
 void GeneratorImplIr::EmitFunction(ir::Function* func) {
     {
         auto out = Line();
@@ -506,4 +512,8 @@
         [&](Default) { UNHANDLED_CASE(c->Type()); });
 }
 
+std::string GeneratorImplIr::UniqueIdentifier(const std::string& prefix /* = "" */) {
+    return ir_->symbols.New(prefix).Name();
+}
+
 }  // namespace tint::writer::msl
diff --git a/src/tint/lang/msl/writer/generator_impl_ir.h b/src/tint/lang/msl/writer/generator_impl_ir.h
index 4ef5245..cda54a4 100644
--- a/src/tint/lang/msl/writer/generator_impl_ir.h
+++ b/src/tint/lang/msl/writer/generator_impl_ir.h
@@ -22,12 +22,12 @@
 #include "src/tint/lang/core/type/texture.h"
 #include "src/tint/utils/diagnostic/diagnostic.h"
 #include "src/tint/utils/text/string_stream.h"
-#include "src/tint/writer/ir_text_generator.h"
+#include "src/tint/utils/text/text_generator.h"
 
 namespace tint::writer::msl {
 
 /// Implementation class for the MSL generator
-class GeneratorImplIr : public IRTextGenerator {
+class GeneratorImplIr : public utils::TextGenerator {
   public:
     /// Constructor
     /// @param module the Tint IR module to generate
@@ -37,6 +37,9 @@
     /// @returns true on successful generation; false otherwise
     bool Generate();
 
+    /// @copydoc utils::TextGenerator::Result
+    std::string Result() const override;
+
     /// Emit the function
     /// @param func the function to emit
     void EmitFunction(ir::Function* func);
@@ -97,6 +100,14 @@
     std::string array_template_name_;
 
   private:
+    /// @copydoc utils::TextWrtiter::UniqueIdentifier
+    std::string UniqueIdentifier(const std::string& prefix = "") override;
+
+    ir::Module* const ir_;
+
+    /// The buffer holding preamble text
+    TextBuffer preamble_buffer_;
+
     /// Unique name of the 'TINT_INVARIANT' preprocessor define.
     /// Non-empty only if an invariant attribute has been generated.
     std::string invariant_define_name_;
diff --git a/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.cc b/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.cc
index ef27e67..848616c 100644
--- a/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.cc
+++ b/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.cc
@@ -16,21 +16,55 @@
 
 #include <algorithm>
 
+#include "src/tint/lang/core/builtin/texel_format.h"
+#include "src/tint/lang/wgsl/ast/accessor_expression.h"
 #include "src/tint/lang/wgsl/ast/alias.h"
+#include "src/tint/lang/wgsl/ast/assignment_statement.h"
+#include "src/tint/lang/wgsl/ast/binary_expression.h"
+#include "src/tint/lang/wgsl/ast/bitcast_expression.h"
 #include "src/tint/lang/wgsl/ast/bool_literal_expression.h"
+#include "src/tint/lang/wgsl/ast/break_if_statement.h"
+#include "src/tint/lang/wgsl/ast/break_statement.h"
+#include "src/tint/lang/wgsl/ast/call_expression.h"
 #include "src/tint/lang/wgsl/ast/call_statement.h"
+#include "src/tint/lang/wgsl/ast/compound_assignment_statement.h"
+#include "src/tint/lang/wgsl/ast/const.h"
+#include "src/tint/lang/wgsl/ast/continue_statement.h"
+#include "src/tint/lang/wgsl/ast/diagnostic_attribute.h"
+#include "src/tint/lang/wgsl/ast/diagnostic_rule_name.h"
+#include "src/tint/lang/wgsl/ast/discard_statement.h"
 #include "src/tint/lang/wgsl/ast/float_literal_expression.h"
+#include "src/tint/lang/wgsl/ast/for_loop_statement.h"
 #include "src/tint/lang/wgsl/ast/id_attribute.h"
+#include "src/tint/lang/wgsl/ast/identifier.h"
+#include "src/tint/lang/wgsl/ast/identifier_expression.h"
+#include "src/tint/lang/wgsl/ast/if_statement.h"
+#include "src/tint/lang/wgsl/ast/increment_decrement_statement.h"
+#include "src/tint/lang/wgsl/ast/index_accessor_expression.h"
+#include "src/tint/lang/wgsl/ast/index_attribute.h"
+#include "src/tint/lang/wgsl/ast/int_literal_expression.h"
 #include "src/tint/lang/wgsl/ast/internal_attribute.h"
 #include "src/tint/lang/wgsl/ast/interpolate_attribute.h"
 #include "src/tint/lang/wgsl/ast/invariant_attribute.h"
+#include "src/tint/lang/wgsl/ast/let.h"
+#include "src/tint/lang/wgsl/ast/loop_statement.h"
+#include "src/tint/lang/wgsl/ast/member_accessor_expression.h"
 #include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/must_use_attribute.h"
+#include "src/tint/lang/wgsl/ast/override.h"
+#include "src/tint/lang/wgsl/ast/phony_expression.h"
+#include "src/tint/lang/wgsl/ast/return_statement.h"
 #include "src/tint/lang/wgsl/ast/stage_attribute.h"
 #include "src/tint/lang/wgsl/ast/stride_attribute.h"
 #include "src/tint/lang/wgsl/ast/struct_member_align_attribute.h"
 #include "src/tint/lang/wgsl/ast/struct_member_offset_attribute.h"
 #include "src/tint/lang/wgsl/ast/struct_member_size_attribute.h"
+#include "src/tint/lang/wgsl/ast/switch_statement.h"
+#include "src/tint/lang/wgsl/ast/templated_identifier.h"
+#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
+#include "src/tint/lang/wgsl/ast/var.h"
 #include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
+#include "src/tint/lang/wgsl/ast/while_statement.h"
 #include "src/tint/lang/wgsl/ast/workgroup_attribute.h"
 #include "src/tint/lang/wgsl/sem/struct.h"
 #include "src/tint/lang/wgsl/sem/switch_statement.h"
@@ -38,6 +72,7 @@
 #include "src/tint/utils/math/math.h"
 #include "src/tint/utils/rtti/switch.h"
 #include "src/tint/utils/text/float_to_string.h"
+#include "src/tint/utils/text/string.h"
 
 namespace tint::writer::syntax_tree {
 
diff --git a/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.h b/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.h
index 60e35d3..48aa801 100644
--- a/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.h
+++ b/src/tint/lang/wgsl/syntax_tree_writer/generator_impl.h
@@ -38,6 +38,51 @@
 #include "src/tint/utils/text/string_stream.h"
 #include "src/tint/utils/text/text_generator.h"
 
+// Forward declarations
+namespace tint::ast {
+class AssignmentStatement;
+class Attribute;
+class BinaryExpression;
+enum class BinaryOp;
+class BitcastExpression;
+class BlockStatement;
+class BlockStatement;
+class BreakIfStatement;
+class BreakStatement;
+class CallExpression;
+class CaseStatement;
+class CompoundAssignmentStatement;
+class ConstAssert;
+class ContinueStatement;
+struct DiagnosticControl;
+class DiscardStatement;
+class Enable;
+class Expression;
+class ForLoopStatement;
+class Function;
+class Identifier;
+class IdentifierExpression;
+class IfStatement;
+class IncrementDecrementStatement;
+class IndexAccessorExpression;
+class LiteralExpression;
+class LoopStatement;
+class MemberAccessorExpression;
+class ReturnStatement;
+class Statement;
+class Statement;
+class Statement;
+class Struct;
+class SwitchStatement;
+class TypeDecl;
+class UnaryOpExpression;
+class Variable;
+class WhileStatement;
+}  // namespace tint::ast
+namespace tint::builtin {
+enum class TexelFormat;
+}  // namespace tint::builtin
+
 namespace tint::writer::syntax_tree {
 
 /// Implementation class for AST generator
diff --git a/src/tint/writer/ir_text_generator.cc b/src/tint/writer/ir_text_generator.cc
deleted file mode 100644
index ac071c7..0000000
--- a/src/tint/writer/ir_text_generator.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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.
-
-#include "src/tint/writer/ir_text_generator.h"
-
-#include "src/tint/utils/containers/map.h"
-
-namespace tint::writer {
-
-IRTextGenerator::IRTextGenerator(ir::Module* mod) : ir_(mod) {}
-
-IRTextGenerator::~IRTextGenerator() = default;
-
-std::string IRTextGenerator::UniqueIdentifier(const std::string& prefix) {
-    return ir_->symbols.New(prefix).Name();
-}
-
-}  // namespace tint::writer
diff --git a/src/tint/writer/ir_text_generator.h b/src/tint/writer/ir_text_generator.h
deleted file mode 100644
index 9f37c27..0000000
--- a/src/tint/writer/ir_text_generator.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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.
-
-#ifndef SRC_TINT_WRITER_IR_TEXT_GENERATOR_H_
-#define SRC_TINT_WRITER_IR_TEXT_GENERATOR_H_
-
-#include <string>
-
-#include "src/tint/lang/core/ir/module.h"
-#include "src/tint/utils/text/text_generator.h"
-
-namespace tint::writer {
-
-/// Helper methods for generators which are creating text output
-class IRTextGenerator : public utils::TextGenerator {
-  public:
-    /// Constructor
-    /// @param mod the IR module used by the generator
-    explicit IRTextGenerator(ir::Module* mod);
-    ~IRTextGenerator() override;
-
-    /// @return a new, unique identifier with the given prefix.
-    /// @param prefix optional prefix to apply to the generated identifier. If
-    /// empty "tint_symbol" will be used.
-    std::string UniqueIdentifier(const std::string& prefix = "") override;
-
-    /// @returns the generated shader string
-    std::string Result() const override {
-        utils::StringStream ss;
-        ss << preamble_buffer_.String() << std::endl << main_buffer_.String();
-        return ss.str();
-    }
-
-  protected:
-    /// The IR module
-    ir::Module* ir_ = nullptr;
-
-    /// The buffer holding preamble text
-    TextBuffer preamble_buffer_;
-};
-
-}  // namespace tint::writer
-
-#endif  // SRC_TINT_WRITER_IR_TEXT_GENERATOR_H_