From 4aed3150b58807721ad4b5aa69d7b834173b5c0d Mon Sep 17 00:00:00 2001 From: James Price Date: Wed, 14 Jul 2021 13:23:45 +0000 Subject: [PATCH] writer: Remove legacy generator API Make the sanitizer transforms internal, as the new generator API automatically runs them. Change-Id: Ia2674762328b5d91d8370b8c18c31693936e8566 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57102 Kokoro: Kokoro Reviewed-by: Ben Clayton --- include/tint/tint.h | 3 --- src/writer/hlsl/generator.cc | 21 --------------------- src/writer/hlsl/generator.h | 25 ------------------------- src/writer/msl/generator.cc | 21 --------------------- src/writer/msl/generator.h | 28 ---------------------------- src/writer/spirv/generator.cc | 21 --------------------- src/writer/spirv/generator.h | 23 ----------------------- src/writer/wgsl/generator.cc | 21 --------------------- src/writer/wgsl/generator.h | 28 ---------------------------- 9 files changed, 191 deletions(-) diff --git a/include/tint/tint.h b/include/tint/tint.h index d989f92aa5..ac1c8b3563 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -44,7 +44,6 @@ #if TINT_BUILD_SPV_WRITER #include "spirv-tools/libspirv.hpp" -#include "src/transform/spirv.h" #include "src/writer/spirv/generator.h" #endif // TINT_BUILD_SPV_WRITER @@ -53,12 +52,10 @@ #endif // TINT_BUILD_WGSL_WRITER #if TINT_BUILD_MSL_WRITER -#include "src/transform/msl.h" #include "src/writer/msl/generator.h" #endif // TINT_BUILD_MSL_WRITER #if TINT_BUILD_HLSL_WRITER -#include "src/transform/hlsl.h" #include "src/writer/hlsl/generator.h" #endif // TINT_BUILD_HLSL_WRITER diff --git a/src/writer/hlsl/generator.cc b/src/writer/hlsl/generator.cc index d6815a3fd7..5dc8693b31 100644 --- a/src/writer/hlsl/generator.cc +++ b/src/writer/hlsl/generator.cc @@ -54,27 +54,6 @@ Result Generate(const Program* program, const Options&) { return result; } -Generator::Generator(const Program* program) - : impl_(std::make_unique(program)) {} - -Generator::~Generator() = default; - -bool Generator::Generate() { - auto ret = impl_->Generate(); - if (!ret) { - error_ = impl_->error(); - } - return ret; -} - -std::string Generator::result() const { - return impl_->result(); -} - -std::string Generator::error() const { - return impl_->error(); -} - } // namespace hlsl } // namespace writer } // namespace tint diff --git a/src/writer/hlsl/generator.h b/src/writer/hlsl/generator.h index 75d47d80f4..f4673481f9 100644 --- a/src/writer/hlsl/generator.h +++ b/src/writer/hlsl/generator.h @@ -69,31 +69,6 @@ struct Result { /// @returns the resulting HLSL and supplementary information Result Generate(const Program* program, const Options& options); -// TODO(jrprice): Remove this once Dawn is using the new interface. -/// Class to generate HLSL source -class Generator : public Text { - public: - /// Constructor - /// @param program the program to convert - explicit Generator(const Program* program); - - /// Destructor - ~Generator() override; - - /// Generates the result data - /// @returns true on successful generation; false otherwise - bool Generate() override; - - /// @returns the result data - std::string result() const override; - - /// @returns the error - std::string error() const; - - private: - std::unique_ptr impl_; -}; - } // namespace hlsl } // namespace writer } // namespace tint diff --git a/src/writer/msl/generator.cc b/src/writer/msl/generator.cc index 215d6503cb..e73541e112 100644 --- a/src/writer/msl/generator.cc +++ b/src/writer/msl/generator.cc @@ -53,27 +53,6 @@ Result Generate(const Program* program, const Options& options) { return result; } -Generator::Generator(const Program* program) - : impl_(std::make_unique(program)) {} - -Generator::~Generator() = default; - -bool Generator::Generate() { - auto ret = impl_->Generate(); - if (!ret) { - error_ = impl_->error(); - } - return ret; -} - -std::string Generator::result() const { - return impl_->result(); -} - -std::string Generator::error() const { - return impl_->error(); -} - } // namespace msl } // namespace writer } // namespace tint diff --git a/src/writer/msl/generator.h b/src/writer/msl/generator.h index 50284587d7..9a182d3b45 100644 --- a/src/writer/msl/generator.h +++ b/src/writer/msl/generator.h @@ -76,34 +76,6 @@ struct Result { /// @returns the resulting MSL and supplementary information Result Generate(const Program* program, const Options& options); -// TODO(jrprice): Remove this once Dawn is using the new interface. -/// Class to generate MSL source -class Generator : public Text { - public: - /// Constructor - /// @param program the program to convert - explicit Generator(const Program* program); - - /// Destructor - ~Generator() override; - - /// Generates the result data - /// @returns true on successful generation; false otherwise - bool Generate() override; - - /// @returns the result data - std::string result() const override; - - /// @returns the error - std::string error() const; - - private: - Generator(const Generator&) = delete; - Generator& operator=(const Generator&) = delete; - - std::unique_ptr impl_; -}; - } // namespace msl } // namespace writer } // namespace tint diff --git a/src/writer/spirv/generator.cc b/src/writer/spirv/generator.cc index 8fae66c860..6270e503fd 100644 --- a/src/writer/spirv/generator.cc +++ b/src/writer/spirv/generator.cc @@ -57,27 +57,6 @@ Result Generate(const Program* program, const Options& options) { return result; } -Generator::Generator(const Program* program) - : builder_(std::make_unique(program)), - writer_(std::make_unique()) {} - -Generator::~Generator() = default; - -bool Generator::Generate() { - if (!builder_->Build()) { - set_error(builder_->error()); - return false; - } - - writer_->WriteHeader(builder_->id_bound()); - writer_->WriteBuilder(builder_.get()); - return true; -} - -const std::vector& Generator::result() const { - return writer_->result(); -} - } // namespace spirv } // namespace writer } // namespace tint diff --git a/src/writer/spirv/generator.h b/src/writer/spirv/generator.h index 122f12bc3d..2b06032696 100644 --- a/src/writer/spirv/generator.h +++ b/src/writer/spirv/generator.h @@ -69,29 +69,6 @@ struct Result { /// @returns the resulting SPIR-V and supplementary information Result Generate(const Program* program, const Options& options); -// TODO(jrprice): Remove this once Dawn is using the new interface. -/// Class to generate SPIR-V from a Tint program -class Generator : public writer::Writer { - public: - /// Constructor - /// @param program the program to convert - explicit Generator(const Program* program); - - /// Destructor - ~Generator() override; - - /// Generates the result data - /// @returns true on successful generation; false otherwise - bool Generate() override; - - /// @returns the result data - const std::vector& result() const; - - private: - std::unique_ptr builder_; - std::unique_ptr writer_; -}; - } // namespace spirv } // namespace writer } // namespace tint diff --git a/src/writer/wgsl/generator.cc b/src/writer/wgsl/generator.cc index 48e1cebcd5..b7c3566d6c 100644 --- a/src/writer/wgsl/generator.cc +++ b/src/writer/wgsl/generator.cc @@ -35,27 +35,6 @@ Result Generate(const Program* program, const Options&) { return result; } -Generator::Generator(const Program* program) - : impl_(std::make_unique(program)) {} - -Generator::~Generator() = default; - -bool Generator::Generate() { - auto ret = impl_->Generate(); - if (!ret) { - error_ = impl_->error(); - } - return ret; -} - -std::string Generator::result() const { - return impl_->result(); -} - -std::string Generator::error() const { - return impl_->error(); -} - } // namespace wgsl } // namespace writer } // namespace tint diff --git a/src/writer/wgsl/generator.h b/src/writer/wgsl/generator.h index 35f194fbe3..9e93c765e4 100644 --- a/src/writer/wgsl/generator.h +++ b/src/writer/wgsl/generator.h @@ -62,34 +62,6 @@ struct Result { /// @returns the resulting WGSL and supplementary information Result Generate(const Program* program, const Options& options); -// TODO(jrprice): Remove this once Dawn is using the new interface. -/// Class to generate WGSL source -class Generator : public Text { - public: - /// Constructor - /// @param program the program to convert - explicit Generator(const Program* program); - - /// Destructor - ~Generator() override; - - /// Generates the result data - /// @returns true on successful generation; false otherwise - bool Generate() override; - - /// @returns the result data - std::string result() const override; - - /// @returns the error - std::string error() const; - - private: - Generator(const Generator&) = delete; - Generator& operator=(const Generator&) = delete; - - std::unique_ptr impl_; -}; - } // namespace wgsl } // namespace writer } // namespace tint