Migrate from using ast::Module to Program

Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`.

As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object.

As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module.
These const_casts are temporary, and will be fixed in the next set of changes.

Depends on https://dawn-review.googlesource.com/c/dawn/+/38522

Bug: tint:390
Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2021-01-26 16:57:10 +00:00
parent be610ba987
commit c40f627bea
252 changed files with 1978 additions and 2017 deletions

View File

@@ -16,8 +16,8 @@
#include <assert.h>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl);

View File

@@ -16,8 +16,8 @@
#include <assert.h>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Alias);

View File

@@ -17,9 +17,9 @@
#include <cmath>
#include <memory>
#include "src/ast/module.h"
#include "src/ast/stride_decoration.h"
#include "src/clone_context.h"
#include "src/program.h"
#include "src/type/vector_type.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Array);

View File

@@ -14,8 +14,8 @@
#include "src/type/bool_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Bool);

View File

@@ -17,8 +17,8 @@
#include <cassert>
#include <sstream>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture);

View File

@@ -14,8 +14,8 @@
#include "src/type/f32_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::F32);

View File

@@ -14,8 +14,8 @@
#include "src/type/i32_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::I32);

View File

@@ -16,8 +16,8 @@
#include <assert.h>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
#include "src/type/array_type.h"
#include "src/type/vector_type.h"

View File

@@ -17,8 +17,8 @@
#include <cassert>
#include <sstream>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::MultisampledTexture);

View File

@@ -14,8 +14,8 @@
#include "src/type/pointer_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Pointer);

View File

@@ -17,8 +17,8 @@
#include <cassert>
#include <sstream>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::SampledTexture);

View File

@@ -14,8 +14,8 @@
#include "src/type/sampler_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Sampler);

View File

@@ -17,8 +17,8 @@
#include <cassert>
#include <sstream>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::StorageTexture);

View File

@@ -17,8 +17,8 @@
#include <cmath>
#include <utility>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
#include "src/type/alias_type.h"
#include "src/type/array_type.h"
#include "src/type/matrix_type.h"

View File

@@ -21,15 +21,15 @@
#include "gtest/gtest.h"
#include "src/ast/builder.h"
#include "src/ast/module.h"
#include "src/demangler.h"
#include "src/program.h"
namespace tint {
namespace type {
/// Helper class for testing
template <typename BASE>
class TestHelperBase : public BASE, public ast::BuilderWithModule {
class TestHelperBase : public BASE, public ast::BuilderWithProgram {
public:
/// Demangles the given string
/// @param s the string to demangle

View File

@@ -23,9 +23,7 @@ namespace tint {
// Forward declarations
class CloneContext;
namespace ast {
class Module;
} // namespace ast
class Program;
namespace type {
@@ -103,12 +101,12 @@ class Type : public Castable<Type> {
/// A helper method for cloning the `Type` `t` if it is not null.
/// If `t` is null, then `Clone()` returns null.
/// @param m the module to clone `n` into
/// @param p the program to clone `n` into
/// @param t the `Type` to clone (if not null)
/// @return the cloned type
template <typename T>
static T* Clone(ast::Module* m, const T* t) {
return (t != nullptr) ? static_cast<T*>(t->Clone(m)) : nullptr;
static T* Clone(Program* p, const T* t) {
return (t != nullptr) ? static_cast<T*>(t->Clone(p)) : nullptr;
}
};

View File

@@ -14,8 +14,8 @@
#include "src/type/u32_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::U32);

View File

@@ -17,8 +17,8 @@
#include <assert.h>
#include <cmath>
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Vector);

View File

@@ -14,8 +14,8 @@
#include "src/type/void_type.h"
#include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/program.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Void);