Remove Clone() from sem::Types

These should always be generated by the resolver, not manually constructed by transforms.

This also fixes duplicate intrinsic output from DecomposeStorageAccess.

Bug: tint:724
Change-Id: I979d55f7b141f38c0504dc72cc3c63e8353ac14f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49881
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-05-05 16:55:22 +00:00
committed by Commit Bot service account
parent 8c6808fa13
commit 8e1d177590
39 changed files with 169 additions and 399 deletions

View File

@@ -66,11 +66,5 @@ std::string AccessControl::FriendlyName(const SymbolTable& symbols) const {
return out.str();
}
AccessControl* AccessControl::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<AccessControl>(access_, ty);
}
} // namespace sem
} // namespace tint

View File

@@ -54,11 +54,6 @@ class AccessControl : public Castable<AccessControl, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
AccessControl* Clone(CloneContext* ctx) const override;
private:
ast::AccessControl::Access const access_;
const Type* const subtype_;

View File

@@ -40,12 +40,5 @@ std::string Alias::FriendlyName(const SymbolTable& symbols) const {
return symbols.NameFor(symbol_);
}
Alias* Alias::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto sym = ctx->Clone(symbol());
auto* ty = ctx->Clone(type());
return ctx->dst->create<Alias>(sym, ty);
}
} // namespace sem
} // namespace tint

View File

@@ -18,6 +18,7 @@
#include <string>
#include "src/sem/type.h"
#include "src/symbol.h"
namespace tint {
namespace sem {
@@ -47,11 +48,6 @@ class Alias : public Castable<Alias, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Alias* Clone(CloneContext* ctx) const override;
private:
Symbol const symbol_;
Type const* const subtype_;

View File

@@ -63,12 +63,5 @@ std::string ArrayType::FriendlyName(const SymbolTable& symbols) const {
return out.str();
}
ArrayType* ArrayType::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
auto decos = ctx->Clone(decorations());
return ctx->dst->create<ArrayType>(ty, size_, decos);
}
} // namespace sem
} // namespace tint

View File

@@ -58,11 +58,6 @@ class ArrayType : public Castable<ArrayType, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
ArrayType* Clone(CloneContext* ctx) const override;
private:
Type* const subtype_;
uint32_t const size_;

View File

@@ -35,9 +35,5 @@ std::string Bool::FriendlyName(const SymbolTable&) const {
return "bool";
}
Bool* Bool::Clone(CloneContext* ctx) const {
return ctx->dst->create<Bool>();
}
} // namespace sem
} // namespace tint

View File

@@ -44,11 +44,6 @@ class Bool : public Castable<Bool, Type> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Bool* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -51,9 +51,5 @@ std::string DepthTexture::FriendlyName(const SymbolTable&) const {
return out.str();
}
DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
return ctx->dst->create<DepthTexture>(dim());
}
} // namespace sem
} // namespace tint

View File

@@ -39,11 +39,6 @@ class DepthTexture : public Castable<DepthTexture, Texture> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
DepthTexture* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -35,9 +35,5 @@ std::string ExternalTexture::FriendlyName(const SymbolTable&) const {
return "texture_external";
}
ExternalTexture* ExternalTexture::Clone(CloneContext* ctx) const {
return ctx->dst->create<ExternalTexture>();
}
} // namespace sem
} // namespace tint

View File

@@ -39,11 +39,6 @@ class ExternalTexture : public Castable<ExternalTexture, Texture> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
ExternalTexture* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -35,9 +35,5 @@ std::string F32::FriendlyName(const SymbolTable&) const {
return "f32";
}
F32* F32::Clone(CloneContext* ctx) const {
return ctx->dst->create<F32>();
}
} // namespace sem
} // namespace tint

View File

@@ -38,11 +38,6 @@ class F32 : public Castable<F32, Type> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
F32* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -35,9 +35,5 @@ std::string I32::FriendlyName(const SymbolTable&) const {
return "i32";
}
I32* I32::Clone(CloneContext* ctx) const {
return ctx->dst->create<I32>();
}
} // namespace sem
} // namespace tint

View File

@@ -38,11 +38,6 @@ class I32 : public Castable<I32, Type> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
I32* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -49,11 +49,5 @@ std::string Matrix::FriendlyName(const SymbolTable& symbols) const {
return out.str();
}
Matrix* Matrix::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* column_type = ctx->Clone(ColumnType());
return ctx->dst->create<Matrix>(column_type, columns_);
}
} // namespace sem
} // namespace tint

View File

@@ -54,11 +54,6 @@ class Matrix : public Castable<Matrix, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Matrix* Clone(CloneContext* ctx) const override;
private:
Type* const subtype_;
Vector* const column_type_;

View File

@@ -45,11 +45,5 @@ std::string MultisampledTexture::FriendlyName(
return out.str();
}
MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<MultisampledTexture>(dim(), ty);
}
} // namespace sem
} // namespace tint

View File

@@ -44,11 +44,6 @@ class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
MultisampledTexture* Clone(CloneContext* ctx) const override;
private:
const Type* const type_;
};

View File

@@ -44,11 +44,5 @@ Pointer::Pointer(Pointer&&) = default;
Pointer::~Pointer() = default;
Pointer* Pointer::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<Pointer>(ty, storage_class_);
}
} // namespace sem
} // namespace tint

View File

@@ -47,11 +47,6 @@ class Pointer : public Castable<Pointer, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Pointer* Clone(CloneContext* ctx) const override;
private:
Type* const subtype_;
ast::StorageClass const storage_class_;

View File

@@ -42,11 +42,5 @@ std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const {
return out.str();
}
SampledTexture* SampledTexture::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<SampledTexture>(dim(), ty);
}
} // namespace sem
} // namespace tint

View File

@@ -44,11 +44,6 @@ class SampledTexture : public Castable<SampledTexture, Texture> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
SampledTexture* Clone(CloneContext* ctx) const override;
private:
const Type* const type_;
};

View File

@@ -36,9 +36,5 @@ std::string Sampler::FriendlyName(const SymbolTable&) const {
return kind_ == ast::SamplerKind::kSampler ? "sampler" : "sampler_comparison";
}
Sampler* Sampler::Clone(CloneContext* ctx) const {
return ctx->dst->create<Sampler>(kind_);
}
} // namespace sem
} // namespace tint

View File

@@ -49,11 +49,6 @@ class Sampler : public Castable<Sampler, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Sampler* Clone(CloneContext* ctx) const override;
private:
ast::SamplerKind const kind_;
};

View File

@@ -42,12 +42,6 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
return out.str();
}
StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<StorageTexture>(dim(), image_format_, ty);
}
sem::Type* StorageTexture::SubtypeFor(ast::ImageFormat format,
sem::Manager& type_mgr) {
switch (format) {

View File

@@ -54,11 +54,6 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
StorageTexture* Clone(CloneContext* ctx) const override;
/// @param format the storage texture image format
/// @param type_mgr the sem::Manager used to build the returned type
/// @returns the storage texture subtype for the given ImageFormat

View File

@@ -37,11 +37,5 @@ std::string StructType::FriendlyName(const SymbolTable& symbols) const {
return impl()->FriendlyName(symbols);
}
StructType* StructType::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* str = ctx->Clone(impl());
return ctx->dst->create<StructType>(str);
}
} // namespace sem
} // namespace tint

View File

@@ -47,11 +47,6 @@ class StructType : public Castable<StructType, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
StructType* Clone(CloneContext* ctx) const override;
private:
ast::Struct* const struct_;

View File

@@ -17,7 +17,7 @@
#include <string>
#include "src/clone_context.h"
#include "src/castable.h"
namespace tint {
@@ -31,7 +31,7 @@ namespace sem {
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
/// Base class for a type in the system
class Type : public Castable<Type, ShareableCloneable> {
class Type : public Castable<Type> {
public:
/// Move constructor
Type(Type&&);
@@ -132,13 +132,6 @@ class Type : public Castable<Type, ShareableCloneable> {
Type();
};
/// @returns the ProgramID of the given type.
inline ProgramID ProgramIDOf(const Type*) {
/// TODO(crbug.com/tint/724): Actually implement this once we split the `type`
/// namespace into ast::Type and sem::Type.
return ProgramID();
}
} // namespace sem
} // namespace tint

View File

@@ -35,9 +35,5 @@ std::string U32::FriendlyName(const SymbolTable&) const {
return "u32";
}
U32* U32::Clone(CloneContext* ctx) const {
return ctx->dst->create<U32>();
}
} // namespace sem
} // namespace tint

View File

@@ -38,11 +38,6 @@ class U32 : public Castable<U32, Type> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
U32* Clone(CloneContext* ctx) const override;
};
} // namespace sem

View File

@@ -41,11 +41,5 @@ std::string Vector::FriendlyName(const SymbolTable& symbols) const {
return out.str();
}
Vector* Vector::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
return ctx->dst->create<Vector>(ty, size_);
}
} // namespace sem
} // namespace tint

View File

@@ -46,11 +46,6 @@ class Vector : public Castable<Vector, Type> {
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Vector* Clone(CloneContext* ctx) const override;
private:
Type const* const subtype_;
uint32_t const size_;

View File

@@ -35,9 +35,5 @@ std::string Void::FriendlyName(const SymbolTable&) const {
return "void";
}
Void* Void::Clone(CloneContext* ctx) const {
return ctx->dst->create<Void>();
}
} // namespace sem
} // namespace tint

View File

@@ -38,11 +38,6 @@ class Void : public Castable<Void, Type> {
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
Void* Clone(CloneContext* ctx) const override;
};
} // namespace sem