Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes:
* They don't derive from ast::Node
* They're deduplicated by the type manager
* None of the types have an Source - they have no lexical declaration point
* The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type.
* We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree.
Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory.
The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module.
Bug: tint:390
Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h
index ccee67e..d1376f2 100644
--- a/src/ast/bitcast_expression.h
+++ b/src/ast/bitcast_expression.h
@@ -20,7 +20,7 @@
#include "src/ast/expression.h"
#include "src/ast/literal.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc
index dcbd774..186e4b7 100644
--- a/src/ast/bitcast_expression_test.cc
+++ b/src/ast/bitcast_expression_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc
index 97a9d5d..e07e66e 100644
--- a/src/ast/bool_literal_test.cc
+++ b/src/ast/bool_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/builder.h b/src/ast/builder.h
index 1ebe604..35a49e1 100644
--- a/src/ast/builder.h
+++ b/src/ast/builder.h
@@ -33,20 +33,20 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc
index ce858df..ae60ba1 100644
--- a/src/ast/case_statement_test.cc
+++ b/src/ast/case_statement_test.cc
@@ -18,9 +18,9 @@
#include "src/ast/if_statement.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc
index 0d3403d..0855fec 100644
--- a/src/ast/else_statement_test.cc
+++ b/src/ast/else_statement_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/if_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/expression.h b/src/ast/expression.h
index 12e038c..853a57c 100644
--- a/src/ast/expression.h
+++ b/src/ast/expression.h
@@ -20,7 +20,7 @@
#include <vector>
#include "src/ast/node.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc
index b48409d..c6887e3 100644
--- a/src/ast/expression_test.cc
+++ b/src/ast/expression_test.cc
@@ -15,8 +15,8 @@
#include "src/ast/expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc
index 1cd4cfe..41be541 100644
--- a/src/ast/float_literal_test.cc
+++ b/src/ast/float_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/function.cc b/src/ast/function.cc
index 822d8cb..47863ca 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -19,11 +19,11 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
#include "src/ast/stage_decoration.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/texture_type.h"
#include "src/ast/variable.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/texture_type.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::Function);
diff --git a/src/ast/function.h b/src/ast/function.h
index 19fb034..248dd55 100644
--- a/src/ast/function.h
+++ b/src/ast/function.h
@@ -32,10 +32,10 @@
#include "src/ast/node.h"
#include "src/ast/pipeline_stage.h"
#include "src/ast/statement.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/type.h"
#include "src/ast/variable.h"
#include "src/symbol.h"
+#include "src/type/sampler_type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc
index dfeb534..e207f83 100644
--- a/src/ast/int_literal_test.cc
+++ b/src/ast/int_literal_test.cc
@@ -19,9 +19,9 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/intrinsic_texture_helper_test.cc b/src/ast/intrinsic_texture_helper_test.cc
index 256de22..b1a16c3 100644
--- a/src/ast/intrinsic_texture_helper_test.cc
+++ b/src/ast/intrinsic_texture_helper_test.cc
@@ -15,12 +15,12 @@
#include "src/ast/intrinsic_texture_helper_test.h"
#include "src/ast/builder.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/access_control_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
namespace tint {
namespace ast {
@@ -135,7 +135,7 @@
return out;
}
-ast::type::Type* TextureOverloadCase::resultVectorComponentType(
+type::Type* TextureOverloadCase::resultVectorComponentType(
ast::Builder* b) const {
switch (texture_data_type) {
case ast::intrinsic::test::TextureDataType::kF32:
@@ -162,26 +162,26 @@
case ast::intrinsic::test::TextureKind::kRegular:
return b->Var(
"texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::SampledTexture>(texture_dimension, datatype),
- nullptr, decos);
+ b->create<type::SampledTexture>(texture_dimension, datatype), nullptr,
+ decos);
case ast::intrinsic::test::TextureKind::kDepth:
return b->Var("texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::DepthTexture>(texture_dimension),
- nullptr, decos);
+ b->create<type::DepthTexture>(texture_dimension), nullptr,
+ decos);
case ast::intrinsic::test::TextureKind::kMultisampled:
- return b->Var("texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::MultisampledTexture>(texture_dimension,
- datatype),
- nullptr, decos);
+ return b->Var(
+ "texture", ast::StorageClass::kUniformConstant,
+ b->create<type::MultisampledTexture>(texture_dimension, datatype),
+ nullptr, decos);
case ast::intrinsic::test::TextureKind::kStorage: {
auto* st =
- b->create<ast::type::StorageTexture>(texture_dimension, image_format);
+ b->create<type::StorageTexture>(texture_dimension, image_format);
st->set_type(datatype);
- auto* ac = b->create<ast::type::AccessControl>(access_control, st);
+ auto* ac = b->create<type::AccessControl>(access_control, st);
return b->Var("texture", ast::StorageClass::kUniformConstant, ac, nullptr,
decos);
}
@@ -198,7 +198,7 @@
b->create<ast::BindingDecoration>(1),
};
return b->Var("sampler", ast::StorageClass::kUniformConstant,
- b->create<ast::type::Sampler>(sampler_kind), nullptr, decos);
+ b->create<type::Sampler>(sampler_kind), nullptr, decos);
}
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
@@ -437,7 +437,7 @@
ValidTextureOverload::kDimensionsStorageRO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
@@ -448,7 +448,7 @@
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
"i32",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -459,7 +459,7 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
@@ -470,7 +470,7 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -481,7 +481,7 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
@@ -491,7 +491,7 @@
ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
@@ -502,7 +502,7 @@
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
"i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -513,7 +513,7 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
@@ -524,7 +524,7 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -535,7 +535,7 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
@@ -605,7 +605,7 @@
ValidTextureOverload::kNumLayersStorageWO1dArray,
"textureNumLayers(t : texture_storage_1d_array<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureNumLayers",
@@ -615,7 +615,7 @@
ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
@@ -2240,7 +2240,7 @@
"textureLoad(t : texture_storage_1d<rgba32float>,\n"
" coords : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureLoad",
@@ -2256,7 +2256,7 @@
" coords : i32,\n"
" array_index : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureLoad",
@@ -2271,7 +2271,7 @@
"textureLoad(t : texture_storage_2d<rgba8unorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Unorm,
+ type::ImageFormat::kRgba8Unorm,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2285,7 +2285,7 @@
"textureLoad(t : texture_storage_2d<rgba8snorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Snorm,
+ type::ImageFormat::kRgba8Snorm,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2299,7 +2299,7 @@
"textureLoad(t : texture_storage_2d<rgba8uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Uint,
+ type::ImageFormat::kRgba8Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2313,7 +2313,7 @@
"textureLoad(t : texture_storage_2d<rgba8sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Sint,
+ type::ImageFormat::kRgba8Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2327,7 +2327,7 @@
"textureLoad(t : texture_storage_2d<rgba16uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Uint,
+ type::ImageFormat::kRgba16Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2341,7 +2341,7 @@
"textureLoad(t : texture_storage_2d<rgba16sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Sint,
+ type::ImageFormat::kRgba16Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2355,7 +2355,7 @@
"textureLoad(t : texture_storage_2d<rgba16float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Float,
+ type::ImageFormat::kRgba16Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2369,7 +2369,7 @@
"textureLoad(t : texture_storage_2d<r32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Uint,
+ type::ImageFormat::kR32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2383,7 +2383,7 @@
"textureLoad(t : texture_storage_2d<r32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Sint,
+ type::ImageFormat::kR32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2397,7 +2397,7 @@
"textureLoad(t : texture_storage_2d<r32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Float,
+ type::ImageFormat::kR32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2411,7 +2411,7 @@
"textureLoad(t : texture_storage_2d<rg32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Uint,
+ type::ImageFormat::kRg32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2425,7 +2425,7 @@
"textureLoad(t : texture_storage_2d<rg32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Sint,
+ type::ImageFormat::kRg32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2439,7 +2439,7 @@
"textureLoad(t : texture_storage_2d<rg32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Float,
+ type::ImageFormat::kRg32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2453,7 +2453,7 @@
"textureLoad(t : texture_storage_2d<rgba32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Uint,
+ type::ImageFormat::kRgba32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2467,7 +2467,7 @@
"textureLoad(t : texture_storage_2d<rgba32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Sint,
+ type::ImageFormat::kRgba32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2481,7 +2481,7 @@
"textureLoad(t : texture_storage_2d<rgba32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2497,7 +2497,7 @@
" coords : vec2<i32>,\n"
" array_index : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
@@ -2512,7 +2512,7 @@
"textureLoad(t : texture_storage_3d<rgba32float>,\n"
" coords : vec3<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureLoad",
@@ -2527,7 +2527,7 @@
" coords : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureStore",
@@ -2544,7 +2544,7 @@
" array_index : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureStore",
@@ -2561,7 +2561,7 @@
" coords : vec2<i32>,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureStore",
@@ -2578,7 +2578,7 @@
" array_index : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureStore",
@@ -2595,7 +2595,7 @@
" coords : vec3<i32>,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureStore",
diff --git a/src/ast/intrinsic_texture_helper_test.h b/src/ast/intrinsic_texture_helper_test.h
index bd67b9f..f8a4b53 100644
--- a/src/ast/intrinsic_texture_helper_test.h
+++ b/src/ast/intrinsic_texture_helper_test.h
@@ -20,9 +20,9 @@
#include "src/ast/access_control.h"
#include "src/ast/builder.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
namespace ast {
@@ -240,7 +240,7 @@
/// @param builder the AST builder used for the test
/// @returns the vector component type of the texture function return value
- ast::type::Type* resultVectorComponentType(ast::Builder* builder) const;
+ type::Type* resultVectorComponentType(ast::Builder* builder) const;
/// @param builder the AST builder used for the test
/// @returns a Variable holding the test texture
ast::Variable* buildTextureVariable(ast::Builder* builder) const;
diff --git a/src/ast/literal.h b/src/ast/literal.h
index f5127ef..2b08eea 100644
--- a/src/ast/literal.h
+++ b/src/ast/literal.h
@@ -18,7 +18,7 @@
#include <string>
#include "src/ast/node.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/module.cc b/src/ast/module.cc
index ac337d0..3561263 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -17,7 +17,7 @@
#include <sstream>
#include "src/ast/clone_context.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/module.h b/src/ast/module.h
index 63fd9c7..76ed92e 100644
--- a/src/ast/module.h
+++ b/src/ast/module.h
@@ -25,11 +25,11 @@
#include "src/ast/function.h"
#include "src/ast/traits.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type_manager.h"
#include "src/ast/variable.h"
#include "src/block_allocator.h"
#include "src/symbol_table.h"
+#include "src/type/alias_type.h"
+#include "src/type/type_manager.h"
namespace tint {
namespace ast {
@@ -181,7 +181,7 @@
std::vector<type::Type*> constructed_types_;
FunctionList functions_;
BlockAllocator<Node> ast_nodes_;
- TypeManager type_mgr_;
+ type::Manager type_mgr_;
};
} // namespace ast
diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc
index 1c7fd7b..e5007b0 100644
--- a/src/ast/module_clone_test.cc
+++ b/src/ast/module_clone_test.cc
@@ -126,7 +126,7 @@
for (auto* src_node : src.nodes()) {
src_nodes.emplace(src_node);
}
- std::unordered_set<ast::type::Type*> src_types;
+ std::unordered_set<type::Type*> src_types;
for (auto& src_type : src.types()) {
src_types.emplace(src_type.second.get());
}
diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc
index d195f32..605bdb8 100644
--- a/src/ast/module_test.cc
+++ b/src/ast/module_test.cc
@@ -20,10 +20,10 @@
#include "gmock/gmock.h"
#include "src/ast/function.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/ast/variable.h"
+#include "src/type/alias_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/node.h b/src/ast/node.h
index b3d5cde..87e2ee9 100644
--- a/src/ast/node.h
+++ b/src/ast/node.h
@@ -23,15 +23,14 @@
#include "src/source.h"
namespace tint {
+namespace type {
+class Type;
+}
namespace ast {
class Module;
class CloneContext;
-namespace type {
-class Type;
-}
-
/// AST base class node
class Node : public Castable<Node> {
public:
diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc
index 025e02c..93b6d44 100644
--- a/src/ast/null_literal_test.cc
+++ b/src/ast/null_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc
index 25fdbd2..563a086 100644
--- a/src/ast/scalar_constructor_expression_test.cc
+++ b/src/ast/scalar_constructor_expression_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/bool_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc
index e4a32d2..3cdb7bb 100644
--- a/src/ast/sint_literal_test.cc
+++ b/src/ast/sint_literal_test.cc
@@ -18,9 +18,9 @@
#include "src/ast/float_literal.h"
#include "src/ast/null_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h
index 52204f8..9f06562 100644
--- a/src/ast/struct_member.h
+++ b/src/ast/struct_member.h
@@ -22,8 +22,8 @@
#include "src/ast/node.h"
#include "src/ast/struct_member_decoration.h"
-#include "src/ast/type/type.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc
index df6758a..2591a64 100644
--- a/src/ast/struct_member_test.cc
+++ b/src/ast/struct_member_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc
index a0af738..a34a2a6 100644
--- a/src/ast/struct_test.cc
+++ b/src/ast/struct_test.cc
@@ -21,7 +21,7 @@
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc
index 1753658..5f05e6a 100644
--- a/src/ast/switch_statement_test.cc
+++ b/src/ast/switch_statement_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/type/access_control_type.cc b/src/ast/type/access_control_type.cc
deleted file mode 100644
index 44e7cbe..0000000
--- a/src/ast/type/access_control_type.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2020 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/ast/type/access_control_type.h"
-
-#include <assert.h>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::AccessControl);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
- : access_(access), subtype_(subtype) {
- assert(subtype_);
- assert(!subtype_->Is<AccessControl>());
-}
-
-AccessControl::AccessControl(AccessControl&&) = default;
-
-AccessControl::~AccessControl() = default;
-
-std::string AccessControl::type_name() const {
- std::string name = "__access_control_";
- switch (access_) {
- case ast::AccessControl::kReadOnly:
- name += "read_only";
- break;
- case ast::AccessControl::kWriteOnly:
- name += "write_only";
- break;
- case ast::AccessControl::kReadWrite:
- name += "read_write";
- break;
- }
- return name + subtype_->type_name();
-}
-
-uint64_t AccessControl::MinBufferBindingSize(MemoryLayout mem_layout) const {
- return subtype_->MinBufferBindingSize(mem_layout);
-}
-
-uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) const {
- return subtype_->BaseAlignment(mem_layout);
-}
-
-AccessControl* AccessControl::Clone(CloneContext* ctx) const {
- return ctx->mod->create<AccessControl>(access_, ctx->Clone(subtype_));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/access_control_type.h b/src/ast/type/access_control_type.h
deleted file mode 100644
index e018b95..0000000
--- a/src/ast/type/access_control_type.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2020 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_AST_TYPE_ACCESS_CONTROL_TYPE_H_
-#define SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
-
-#include <string>
-
-#include "src/ast/access_control.h"
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// An access control type. Holds an access setting and pointer to another type.
-class AccessControl : public Castable<AccessControl, Type> {
- public:
- /// Constructor
- /// @param access the access control setting
- /// @param subtype the access controlled type
- AccessControl(ast::AccessControl access, Type* subtype);
- /// Move constructor
- AccessControl(AccessControl&&);
- ~AccessControl() override;
-
- /// @returns true if the access control is read only
- bool IsReadOnly() const { return access_ == ast::AccessControl::kReadOnly; }
- /// @returns true if the access control is write only
- bool IsWriteOnly() const { return access_ == ast::AccessControl::kWriteOnly; }
- /// @returns true if the access control is read/write
- bool IsReadWrite() const { return access_ == ast::AccessControl::kReadWrite; }
-
- /// @returns the access control value
- ast::AccessControl access_control() const { return access_; }
- /// @returns the subtype type
- Type* type() const { return subtype_; }
-
- /// @returns the name for this type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 const access_;
- Type* const subtype_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc
deleted file mode 100644
index 882f144..0000000
--- a/src/ast/type/access_control_type_test.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2020 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/ast/type/access_control_type.h"
-
-#include <memory>
-#include <utility>
-
-#include "src/ast/storage_class.h"
-#include "src/ast/stride_decoration.h"
-#include "src/ast/struct_member.h"
-#include "src/ast/struct_member_decoration.h"
-#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using AccessControlTest = TestHelper;
-
-TEST_F(AccessControlTest, Create) {
- U32 u32;
- AccessControl a{ast::AccessControl::kReadWrite, &u32};
- EXPECT_TRUE(a.IsReadWrite());
- EXPECT_EQ(a.type(), &u32);
-}
-
-TEST_F(AccessControlTest, Is) {
- I32 i32;
-
- AccessControl at{ast::AccessControl::kReadOnly, &i32};
- Type* ty = &at;
- EXPECT_TRUE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(AccessControlTest, AccessRead) {
- I32 i32;
- AccessControl at{ast::AccessControl::kReadOnly, &i32};
- EXPECT_TRUE(at.IsReadOnly());
- EXPECT_FALSE(at.IsWriteOnly());
- EXPECT_FALSE(at.IsReadWrite());
-
- EXPECT_EQ(at.type_name(), "__access_control_read_only__i32");
-}
-
-TEST_F(AccessControlTest, AccessWrite) {
- I32 i32;
- AccessControl at{ast::AccessControl::kWriteOnly, &i32};
- EXPECT_FALSE(at.IsReadOnly());
- EXPECT_TRUE(at.IsWriteOnly());
- EXPECT_FALSE(at.IsReadWrite());
-
- EXPECT_EQ(at.type_name(), "__access_control_write_only__i32");
-}
-
-TEST_F(AccessControlTest, AccessReadWrite) {
- I32 i32;
- AccessControl at{ast::AccessControl::kReadWrite, &i32};
- EXPECT_FALSE(at.IsReadOnly());
- EXPECT_FALSE(at.IsWriteOnly());
- EXPECT_TRUE(at.IsReadWrite());
-
- EXPECT_EQ(at.type_name(), "__access_control_read_write__i32");
-}
-
-TEST_F(AccessControlTest, MinBufferBindingSizeU32) {
- U32 u32;
- AccessControl at{ast::AccessControl::kReadOnly, &u32};
- EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
- U32 u32;
- Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- AccessControl at{ast::AccessControl::kReadOnly, &array};
- EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
- U32 u32;
- Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- AccessControl at{ast::AccessControl::kReadOnly, &array};
- EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
-
- auto* struct_type = ty.struct_("struct_type", str);
- AccessControl at{ast::AccessControl::kReadOnly, struct_type};
- EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(AccessControlTest, BaseAlignmentU32) {
- U32 u32;
- AccessControl at{ast::AccessControl::kReadOnly, &u32};
- EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, BaseAlignmentArray) {
- U32 u32;
- Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- AccessControl at{ast::AccessControl::kReadOnly, &array};
- EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
- U32 u32;
- Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- AccessControl at{ast::AccessControl::kReadOnly, &array};
- EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AccessControlTest, BaseAlignmentStruct) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
- auto* struct_type = ty.struct_("struct_type", str);
-
- AccessControl at{ast::AccessControl::kReadOnly, struct_type};
- EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/alias_type.cc b/src/ast/type/alias_type.cc
deleted file mode 100644
index b8632de..0000000
--- a/src/ast/type/alias_type.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2020 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/ast/type/alias_type.h"
-
-#include <assert.h>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Alias);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Alias::Alias(const Symbol& sym, Type* subtype)
- : symbol_(sym), subtype_(subtype) {
- assert(subtype_);
-}
-
-Alias::Alias(Alias&&) = default;
-
-Alias::~Alias() = default;
-
-std::string Alias::type_name() const {
- return "__alias_" + symbol_.to_str() + subtype_->type_name();
-}
-
-uint64_t Alias::MinBufferBindingSize(MemoryLayout mem_layout) const {
- return subtype_->MinBufferBindingSize(mem_layout);
-}
-
-uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) const {
- return subtype_->BaseAlignment(mem_layout);
-}
-
-Alias* Alias::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Alias>(ctx->Clone(symbol()), ctx->Clone(subtype_));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/alias_type.h b/src/ast/type/alias_type.h
deleted file mode 100644
index 7bc3bc2..0000000
--- a/src/ast/type/alias_type.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2020 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_AST_TYPE_ALIAS_TYPE_H_
-#define SRC_AST_TYPE_ALIAS_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-#include "src/symbol.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A type alias type. Holds a name and pointer to another type.
-class Alias : public Castable<Alias, Type> {
- public:
- /// Constructor
- /// @param sym the symbol for the alias
- /// @param subtype the alias'd type
- Alias(const Symbol& sym, Type* subtype);
- /// Move constructor
- Alias(Alias&&);
- /// Destructor
- ~Alias() override;
-
- /// @returns the alias symbol
- Symbol symbol() const { return symbol_; }
- /// @returns the alias type
- Type* type() const { return subtype_; }
-
- /// @returns the type_name for this type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 subtype_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_ALIAS_TYPE_H_
diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc
deleted file mode 100644
index c1c59a4..0000000
--- a/src/ast/type/alias_type_test.cc
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright 2020 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/ast/type/alias_type.h"
-
-#include <memory>
-#include <utility>
-
-#include "src/ast/storage_class.h"
-#include "src/ast/stride_decoration.h"
-#include "src/ast/struct_member.h"
-#include "src/ast/struct_member_decoration.h"
-#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using AliasTest = TestHelper;
-
-TEST_F(AliasTest, Create) {
- auto* a = ty.alias("a_type", ty.u32);
- EXPECT_EQ(a->symbol(), Symbol(1));
- EXPECT_EQ(a->type(), ty.u32);
-}
-
-TEST_F(AliasTest, Is) {
- auto* at = ty.alias("a", ty.i32);
- type::Type* ty = at;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_TRUE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(AliasTest, TypeName) {
- auto* at = ty.alias("Particle", ty.i32);
- EXPECT_EQ(at->type_name(), "__alias_tint_symbol_1__i32");
-}
-
-TEST_F(AliasTest, UnwrapIfNeeded_Alias) {
- auto* a = ty.alias("a_type", ty.u32);
- EXPECT_EQ(a->symbol(), Symbol(1));
- EXPECT_EQ(a->type(), ty.u32);
- EXPECT_EQ(a->UnwrapIfNeeded(), ty.u32);
- EXPECT_EQ(ty.u32->UnwrapIfNeeded(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapIfNeeded_AccessControl) {
- AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
- EXPECT_EQ(a.type(), ty.u32);
- EXPECT_EQ(a.UnwrapIfNeeded(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel) {
- auto* a = ty.alias("a_type", ty.u32);
- auto* aa = ty.alias("aa_type", a);
-
- EXPECT_EQ(aa->symbol(), Symbol(2));
- EXPECT_EQ(aa->type(), a);
- EXPECT_EQ(aa->UnwrapIfNeeded(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) {
- auto* a = ty.alias("a_type", ty.u32);
-
- AccessControl aa{ast::AccessControl::kReadWrite, a};
- EXPECT_EQ(aa.type(), a);
- EXPECT_EQ(aa.UnwrapIfNeeded(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
- auto* a = ty.alias("a_type", ty.u32);
- auto* aa = ty.alias("aa_type", a);
- Pointer paa{aa, StorageClass::kUniform};
- auto* apaa = ty.alias("paa_type", &paa);
- auto* aapaa = ty.alias("aapaa_type", apaa);
-
- EXPECT_EQ(aapaa->symbol(), Symbol(4));
- EXPECT_EQ(aapaa->type(), apaa);
- EXPECT_EQ(aapaa->UnwrapAll(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
- auto* a = ty.alias("a_type", ty.u32);
- auto* aa = ty.alias("aa_type", a);
-
- Pointer paa{aa, StorageClass::kUniform};
- Pointer ppaa{&paa, StorageClass::kUniform};
- auto* appaa = ty.alias("appaa_type", &ppaa);
- EXPECT_EQ(appaa->UnwrapAll(), &paa);
-}
-
-TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
- auto* a = ty.alias("a_type", ty.u32);
- auto* aa = ty.alias("aa_type", a);
- Pointer paa{aa, StorageClass::kUniform};
-
- auto* apaa = ty.alias("apaa_type", &paa);
- auto* aapaa = ty.alias("aapaa_type", apaa);
- Pointer paapaa{aapaa, StorageClass::kUniform};
- auto* apaapaa = ty.alias("apaapaa_type", &paapaa);
-
- EXPECT_EQ(apaapaa->UnwrapAll(), &paa);
-}
-
-TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
- AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
- Pointer pa{&a, StorageClass::kUniform};
- EXPECT_EQ(pa.type(), &a);
- EXPECT_EQ(pa.UnwrapAll(), ty.u32);
-}
-
-TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
- Pointer p{ty.u32, StorageClass::kUniform};
- AccessControl a{ast::AccessControl::kReadOnly, &p};
-
- EXPECT_EQ(a.type(), &p);
- EXPECT_EQ(a.UnwrapAll(), ty.u32);
-}
-
-TEST_F(AliasTest, MinBufferBindingSizeU32) {
- auto* alias = ty.alias("alias", ty.u32);
- EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, MinBufferBindingSizeArray) {
- Array array(ty.u32, 4,
- ArrayDecorationList{
- create<StrideDecoration>(4),
- });
- auto* alias = ty.alias("alias", &array);
- EXPECT_EQ(16u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
- Array array(ty.u32, 0,
- ArrayDecorationList{
- create<StrideDecoration>(4),
- });
- auto* alias = ty.alias("alias", &array);
- EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, MinBufferBindingSizeStruct) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
- auto* struct_type = ty.struct_("struct_type", str);
- auto* alias = ty.alias("alias", struct_type);
-
- EXPECT_EQ(16u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, alias->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(AliasTest, BaseAlignmentU32) {
- auto* alias = ty.alias("alias", ty.u32);
- EXPECT_EQ(4u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, BaseAlignmentArray) {
- Array array(ty.u32, 4,
- ArrayDecorationList{
- create<StrideDecoration>(4),
- });
- auto* alias = ty.alias("alias", &array);
- EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
- Array array(ty.u32, 0,
- ArrayDecorationList{
- create<StrideDecoration>(4),
- });
- auto* alias = ty.alias("alias", &array);
- EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(AliasTest, BaseAlignmentStruct) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
- auto* struct_type = ty.struct_("struct_type", str);
- auto* alias = ty.alias("alias", struct_type);
-
- EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, alias->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/array_type.cc b/src/ast/type/array_type.cc
deleted file mode 100644
index be71ad7..0000000
--- a/src/ast/type/array_type.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2020 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/ast/type/array_type.h"
-
-#include <cmath>
-#include <memory>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-#include "src/ast/stride_decoration.h"
-#include "src/ast/type/vector_type.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Array);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Array::Array(Type* subtype, uint32_t size, ArrayDecorationList decorations)
- : subtype_(subtype), size_(size), decos_(decorations) {}
-
-Array::Array(Array&&) = default;
-
-Array::~Array() = default;
-
-uint64_t Array::MinBufferBindingSize(MemoryLayout mem_layout) const {
- if (!has_array_stride()) {
- // Arrays in buffers are required to have a stride.
- return 0;
- }
-
- if (IsRuntimeArray()) {
- // WebGPU spec 10.1.2:
- // If the last field of the corresponding structure defined in the shader
- // has an unbounded array type, then the value of minBufferBindingSize must
- // be greater than or equal to the byte offset of that field plus the stride
- // of the unbounded array
- return array_stride();
- } else {
- // Not including the padding for the last element
- return (size_ - 1) * array_stride() +
- subtype_->MinBufferBindingSize(mem_layout);
- }
-}
-
-uint64_t Array::BaseAlignment(MemoryLayout mem_layout) const {
- if (mem_layout == MemoryLayout::kUniformBuffer) {
- float aligment = 16; // for a vec4
- float unaligned = static_cast<float>(subtype_->BaseAlignment(mem_layout));
- return static_cast<uint64_t>(aligment * std::ceil(unaligned / aligment));
- } else if (mem_layout == MemoryLayout::kStorageBuffer) {
- return subtype_->BaseAlignment(mem_layout);
- }
- return 0;
-}
-
-uint32_t Array::array_stride() const {
- for (auto* deco : decos_) {
- if (auto* stride = deco->As<StrideDecoration>()) {
- return stride->stride();
- }
- }
- return 0;
-}
-
-bool Array::has_array_stride() const {
- for (auto* deco : decos_) {
- if (deco->Is<StrideDecoration>()) {
- return true;
- }
- }
- return false;
-}
-
-std::string Array::type_name() const {
- assert(subtype_);
-
- std::string type_name = "__array" + subtype_->type_name();
- if (!IsRuntimeArray())
- type_name += "_" + std::to_string(size_);
- if (has_array_stride())
- type_name += "_stride_" + std::to_string(array_stride());
-
- return type_name;
-}
-
-Array* Array::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Array>(ctx->Clone(subtype_), size_,
- ctx->Clone(decorations()));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/array_type.h b/src/ast/type/array_type.h
deleted file mode 100644
index eafb204..0000000
--- a/src/ast/type/array_type.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2020 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_AST_TYPE_ARRAY_TYPE_H_
-#define SRC_AST_TYPE_ARRAY_TYPE_H_
-
-#include <assert.h>
-
-#include <string>
-#include <utility>
-
-#include "src/ast/array_decoration.h"
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// An array type. If size is zero then it is a runtime array.
-class Array : public Castable<Array, Type> {
- public:
- /// Constructor
- /// @param subtype the type of the array elements
- /// @param size the number of elements in the array. `0` represents a
- /// runtime-sized array.
- /// @param decorations the array decorations
- Array(Type* subtype, uint32_t size, ArrayDecorationList decorations);
- /// Move constructor
- Array(Array&&);
- ~Array() override;
-
- /// @returns true if this is a runtime array.
- /// i.e. the size is determined at runtime
- bool IsRuntimeArray() const { return size_ == 0; }
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
-
- /// @returns the array decorations
- const ArrayDecorationList& decorations() const { return decos_; }
-
- /// @returns the array stride or 0 if none set.
- uint32_t array_stride() const;
- /// @returns true if the array has a stride set
- bool has_array_stride() const;
-
- /// @returns the array type
- Type* type() const { return subtype_; }
- /// @returns the array size. Size is 0 for a runtime array
- uint32_t size() const { return size_; }
-
- /// @returns the name for the type
- std::string type_name() const override;
-
- /// Clones this type and all transitive types using the `CloneContext` `ctx`.
- /// @param ctx the clone context
- /// @return the newly cloned type
- Array* Clone(CloneContext* ctx) const override;
-
- private:
- Type* const subtype_;
- uint32_t const size_;
- ArrayDecorationList const decos_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_ARRAY_TYPE_H_
diff --git a/src/ast/type/array_type_test.cc b/src/ast/type/array_type_test.cc
deleted file mode 100644
index 8d61e27..0000000
--- a/src/ast/type/array_type_test.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright 2020 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/ast/type/array_type.h"
-
-#include <memory>
-#include <utility>
-
-#include "src/ast/stride_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using ArrayTest = TestHelper;
-
-TEST_F(ArrayTest, CreateSizedArray) {
- U32 u32;
- Array arr{&u32, 3, ArrayDecorationList{}};
- EXPECT_EQ(arr.type(), &u32);
- EXPECT_EQ(arr.size(), 3u);
- EXPECT_TRUE(arr.Is<Array>());
- EXPECT_FALSE(arr.IsRuntimeArray());
-}
-
-TEST_F(ArrayTest, CreateRuntimeArray) {
- U32 u32;
- Array arr{&u32, 0, ArrayDecorationList{}};
- EXPECT_EQ(arr.type(), &u32);
- EXPECT_EQ(arr.size(), 0u);
- EXPECT_TRUE(arr.Is<Array>());
- EXPECT_TRUE(arr.IsRuntimeArray());
-}
-
-TEST_F(ArrayTest, Is) {
- I32 i32;
-
- Array arr{&i32, 3, ArrayDecorationList{}};
- Type* ty = &arr;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_TRUE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(ArrayTest, TypeName) {
- I32 i32;
- Array arr{&i32, 0, ArrayDecorationList{}};
- EXPECT_EQ(arr.type_name(), "__array__i32");
-}
-
-TEST_F(ArrayTest, TypeName_RuntimeArray) {
- I32 i32;
- Array arr{&i32, 3, ArrayDecorationList{}};
- EXPECT_EQ(arr.type_name(), "__array__i32_3");
-}
-
-TEST_F(ArrayTest, TypeName_WithStride) {
- I32 i32;
- Array arr{&i32, 3, ArrayDecorationList{create<StrideDecoration>(16)}};
- EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
-}
-
-TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
- U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{});
- EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(ArrayTest, MinBufferBindingSizeArray) {
- U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
- U32 u32;
- Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(ArrayTest, BaseAlignmentArray) {
- U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
- U32 u32;
- Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/bool_type.cc b/src/ast/type/bool_type.cc
deleted file mode 100644
index 7c26c86..0000000
--- a/src/ast/type/bool_type.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2020 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/ast/type/bool_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Bool);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Bool::Bool() = default;
-
-Bool::Bool(Bool&&) = default;
-
-Bool::~Bool() = default;
-
-std::string Bool::type_name() const {
- return "__bool";
-}
-
-Bool* Bool::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Bool>();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/bool_type.h b/src/ast/type/bool_type.h
deleted file mode 100644
index 11f5338..0000000
--- a/src/ast/type/bool_type.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2020 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_AST_TYPE_BOOL_TYPE_H_
-#define SRC_AST_TYPE_BOOL_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A boolean type
-class Bool : public Castable<Bool, Type> {
- public:
- /// Constructor
- Bool();
- /// Move constructor
- Bool(Bool&&);
- ~Bool() override;
-
- /// @returns the name for this type
- std::string type_name() 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_BOOL_TYPE_H_
diff --git a/src/ast/type/bool_type_test.cc b/src/ast/type/bool_type_test.cc
deleted file mode 100644
index d6c6f25..0000000
--- a/src/ast/type/bool_type_test.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2020 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/ast/type/bool_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using BoolTest = TestHelper;
-
-TEST_F(BoolTest, Is) {
- Bool b;
- Type* ty = &b;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_TRUE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(BoolTest, TypeName) {
- Bool b;
- EXPECT_EQ(b.type_name(), "__bool");
-}
-
-TEST_F(BoolTest, MinBufferBindingSize) {
- Bool b;
- EXPECT_EQ(0u, b.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/depth_texture_type.cc b/src/ast/type/depth_texture_type.cc
deleted file mode 100644
index 95b55aa..0000000
--- a/src/ast/type/depth_texture_type.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2020 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/ast/type/depth_texture_type.h"
-
-#include <cassert>
-#include <sstream>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::DepthTexture);
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-#ifndef NDEBUG
-
-bool IsValidDepthDimension(TextureDimension dim) {
- return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
- dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
-}
-
-#endif // NDEBUG
-
-} // namespace
-
-DepthTexture::DepthTexture(TextureDimension dim) : Base(dim) {
- assert(IsValidDepthDimension(dim));
-}
-
-DepthTexture::DepthTexture(DepthTexture&&) = default;
-
-DepthTexture::~DepthTexture() = default;
-
-std::string DepthTexture::type_name() const {
- std::ostringstream out;
- out << "__depth_texture_" << dim();
- return out.str();
-}
-
-DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
- return ctx->mod->create<DepthTexture>(dim());
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/depth_texture_type.h b/src/ast/type/depth_texture_type.h
deleted file mode 100644
index 02f07d3..0000000
--- a/src/ast/type/depth_texture_type.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2020 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_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/texture_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A depth texture type.
-class DepthTexture : public Castable<DepthTexture, Texture> {
- public:
- /// Constructor
- /// @param dim the dimensionality of the texture
- explicit DepthTexture(TextureDimension dim);
- /// Move constructor
- DepthTexture(DepthTexture&&);
- ~DepthTexture() override;
-
- /// @returns the name for this type
- std::string type_name() 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
diff --git a/src/ast/type/depth_texture_type_test.cc b/src/ast/type/depth_texture_type_test.cc
deleted file mode 100644
index b956f89..0000000
--- a/src/ast/type/depth_texture_type_test.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2020 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/ast/type/depth_texture_type.h"
-
-#include "src/ast/test_helper.h"
-
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using DepthTextureTest = TestHelper;
-
-TEST_F(DepthTextureTest, Is) {
- DepthTexture d(TextureDimension::kCube);
- Type* ty = &d;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_TRUE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(DepthTextureTest, IsTexture) {
- DepthTexture d(TextureDimension::kCube);
- Texture* ty = &d;
- EXPECT_TRUE(ty->Is<DepthTexture>());
- EXPECT_FALSE(ty->Is<SampledTexture>());
- EXPECT_FALSE(ty->Is<StorageTexture>());
-}
-
-TEST_F(DepthTextureTest, Dim) {
- DepthTexture d(TextureDimension::kCube);
- EXPECT_EQ(d.dim(), TextureDimension::kCube);
-}
-
-TEST_F(DepthTextureTest, TypeName) {
- DepthTexture d(TextureDimension::kCube);
- EXPECT_EQ(d.type_name(), "__depth_texture_cube");
-}
-
-TEST_F(DepthTextureTest, MinBufferBindingSize) {
- DepthTexture d(TextureDimension::kCube);
- EXPECT_EQ(0u, d.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/f32_type.cc b/src/ast/type/f32_type.cc
deleted file mode 100644
index bfcdc69..0000000
--- a/src/ast/type/f32_type.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2020 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/ast/type/f32_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::F32);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-F32::F32() = default;
-
-F32::F32(F32&&) = default;
-
-F32::~F32() = default;
-
-std::string F32::type_name() const {
- return "__f32";
-}
-
-uint64_t F32::MinBufferBindingSize(MemoryLayout) const {
- return 4;
-}
-
-uint64_t F32::BaseAlignment(MemoryLayout) const {
- return 4;
-}
-
-F32* F32::Clone(CloneContext* ctx) const {
- return ctx->mod->create<F32>();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/f32_type.h b/src/ast/type/f32_type.h
deleted file mode 100644
index 86187f3..0000000
--- a/src/ast/type/f32_type.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2020 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_AST_TYPE_F32_TYPE_H_
-#define SRC_AST_TYPE_F32_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A float 32 type
-class F32 : public Castable<F32, Type> {
- public:
- /// Constructor
- F32();
- /// Move constructor
- F32(F32&&);
- ~F32() override;
-
- /// @returns the name for this type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_F32_TYPE_H_
diff --git a/src/ast/type/f32_type_test.cc b/src/ast/type/f32_type_test.cc
deleted file mode 100644
index 0570b7e..0000000
--- a/src/ast/type/f32_type_test.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2020 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/ast/type/f32_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using F32Test = TestHelper;
-
-TEST_F(F32Test, Is) {
- F32 f;
- Type* ty = &f;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_TRUE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(F32Test, TypeName) {
- F32 f;
- EXPECT_EQ(f.type_name(), "__f32");
-}
-
-TEST_F(F32Test, MinBufferBindingSize) {
- F32 f;
- EXPECT_EQ(4u, f.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(F32Test, BaseAlignment) {
- F32 f;
- EXPECT_EQ(4u, f.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/i32_type.cc b/src/ast/type/i32_type.cc
deleted file mode 100644
index 6b47eb3..0000000
--- a/src/ast/type/i32_type.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2020 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/ast/type/i32_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::I32);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-I32::I32() = default;
-
-I32::I32(I32&&) = default;
-
-I32::~I32() = default;
-
-std::string I32::type_name() const {
- return "__i32";
-}
-
-uint64_t I32::MinBufferBindingSize(MemoryLayout) const {
- return 4;
-}
-
-uint64_t I32::BaseAlignment(MemoryLayout) const {
- return 4;
-}
-
-I32* I32::Clone(CloneContext* ctx) const {
- return ctx->mod->create<I32>();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/i32_type.h b/src/ast/type/i32_type.h
deleted file mode 100644
index 104d593..0000000
--- a/src/ast/type/i32_type.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2020 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_AST_TYPE_I32_TYPE_H_
-#define SRC_AST_TYPE_I32_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A signed int 32 type.
-class I32 : public Castable<I32, Type> {
- public:
- /// Constructor
- I32();
- /// Move constructor
- I32(I32&&);
- ~I32() override;
-
- /// @returns the name for this type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_I32_TYPE_H_
diff --git a/src/ast/type/i32_type_test.cc b/src/ast/type/i32_type_test.cc
deleted file mode 100644
index 0333d01..0000000
--- a/src/ast/type/i32_type_test.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2020 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/ast/type/i32_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using I32Test = TestHelper;
-
-TEST_F(I32Test, Is) {
- I32 i;
- Type* ty = &i;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_TRUE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(I32Test, TypeName) {
- I32 i;
- EXPECT_EQ(i.type_name(), "__i32");
-}
-
-TEST_F(I32Test, MinBufferBindingSize) {
- I32 i;
- EXPECT_EQ(4u, i.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(I32Test, BaseAlignment) {
- I32 i;
- EXPECT_EQ(4u, i.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/matrix_type.cc b/src/ast/type/matrix_type.cc
deleted file mode 100644
index 12eea45..0000000
--- a/src/ast/type/matrix_type.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2020 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/ast/type/matrix_type.h"
-
-#include <assert.h>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/vector_type.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Matrix);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Matrix::Matrix(Type* subtype, uint32_t rows, uint32_t columns)
- : subtype_(subtype), rows_(rows), columns_(columns) {
- assert(rows > 1);
- assert(rows < 5);
- assert(columns > 1);
- assert(columns < 5);
-}
-
-Matrix::Matrix(Matrix&&) = default;
-
-Matrix::~Matrix() = default;
-
-std::string Matrix::type_name() const {
- return "__mat_" + std::to_string(rows_) + "_" + std::to_string(columns_) +
- subtype_->type_name();
-}
-
-uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const {
- Vector vec(subtype_, rows_);
- return (columns_ - 1) * vec.BaseAlignment(mem_layout) +
- vec.MinBufferBindingSize(mem_layout);
-}
-
-uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
- Vector vec(subtype_, rows_);
- Array arr(&vec, columns_, ArrayDecorationList{});
- return arr.BaseAlignment(mem_layout);
-}
-
-Matrix* Matrix::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Matrix>(ctx->Clone(subtype_), rows_, columns_);
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/matrix_type.h b/src/ast/type/matrix_type.h
deleted file mode 100644
index 500f43e..0000000
--- a/src/ast/type/matrix_type.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2020 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_AST_TYPE_MATRIX_TYPE_H_
-#define SRC_AST_TYPE_MATRIX_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A matrix type
-class Matrix : public Castable<Matrix, Type> {
- public:
- /// Constructor
- /// @param subtype type matrix type
- /// @param rows the number of rows in the matrix
- /// @param columns the number of columns in the matrix
- Matrix(Type* subtype, uint32_t rows, uint32_t columns);
- /// Move constructor
- Matrix(Matrix&&);
- ~Matrix() override;
-
- /// @returns the type of the matrix
- Type* type() const { return subtype_; }
- /// @returns the number of rows in the matrix
- uint32_t rows() const { return rows_; }
- /// @returns the number of columns in the matrix
- uint32_t columns() const { return columns_; }
-
- /// @returns the name for this type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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_;
- uint32_t const rows_;
- uint32_t const columns_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_MATRIX_TYPE_H_
diff --git a/src/ast/type/matrix_type_test.cc b/src/ast/type/matrix_type_test.cc
deleted file mode 100644
index fb4c1a7..0000000
--- a/src/ast/type/matrix_type_test.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2020 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/ast/type/matrix_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using MatrixTest = TestHelper;
-
-TEST_F(MatrixTest, Creation) {
- I32 i32;
- Matrix m{&i32, 2, 4};
- EXPECT_EQ(m.type(), &i32);
- EXPECT_EQ(m.rows(), 2u);
- EXPECT_EQ(m.columns(), 4u);
-}
-
-TEST_F(MatrixTest, Is) {
- I32 i32;
- Matrix m{&i32, 2, 3};
- Type* ty = &m;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_TRUE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(MatrixTest, TypeName) {
- I32 i32;
- Matrix m{&i32, 2, 3};
- EXPECT_EQ(m.type_name(), "__mat_2_3__i32");
-}
-
-TEST_F(MatrixTest, MinBufferBindingSize4x2) {
- I32 i32;
- Matrix m{&i32, 4, 2};
- EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, MinBufferBindingSize3x2) {
- I32 i32;
- Matrix m{&i32, 3, 2};
- EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, MinBufferBindingSize2x3) {
- I32 i32;
- Matrix m{&i32, 2, 3};
- EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, MinBufferBindingSize2x2) {
- I32 i32;
- Matrix m{&i32, 2, 2};
- EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, BaseAlignment4x2) {
- I32 i32;
- Matrix m{&i32, 4, 2};
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, BaseAlignment3x2) {
- I32 i32;
- Matrix m{&i32, 3, 2};
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, BaseAlignment2x3) {
- I32 i32;
- Matrix m{&i32, 2, 3};
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(MatrixTest, BaseAlignment2x2) {
- I32 i32;
- Matrix m{&i32, 2, 2};
- EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/multisampled_texture_type.cc b/src/ast/type/multisampled_texture_type.cc
deleted file mode 100644
index 2ec4320..0000000
--- a/src/ast/type/multisampled_texture_type.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2020 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/ast/type/multisampled_texture_type.h"
-
-#include <cassert>
-#include <sstream>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::MultisampledTexture);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
- : Base(dim), type_(type) {
- assert(type_);
-}
-
-MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default;
-
-MultisampledTexture::~MultisampledTexture() = default;
-
-std::string MultisampledTexture::type_name() const {
- std::ostringstream out;
- out << "__multisampled_texture_" << dim() << type_->type_name();
- return out.str();
-}
-
-MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const {
- return ctx->mod->create<MultisampledTexture>(dim(), ctx->Clone(type_));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/multisampled_texture_type.h b/src/ast/type/multisampled_texture_type.h
deleted file mode 100644
index 4fb45e2..0000000
--- a/src/ast/type/multisampled_texture_type.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2020 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_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/texture_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A multisampled texture type.
-class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
- public:
- /// Constructor
- /// @param dim the dimensionality of the texture
- /// @param type the data type of the multisampled texture
- MultisampledTexture(TextureDimension dim, Type* type);
- /// Move constructor
- MultisampledTexture(MultisampledTexture&&);
- ~MultisampledTexture() override;
-
- /// @returns the subtype of the sampled texture
- Type* type() const { return type_; }
-
- /// @returns the name for this type
- std::string type_name() 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:
- Type* const type_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
diff --git a/src/ast/type/multisampled_texture_type_test.cc b/src/ast/type/multisampled_texture_type_test.cc
deleted file mode 100644
index 99bb0e5..0000000
--- a/src/ast/type/multisampled_texture_type_test.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2020 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/ast/type/multisampled_texture_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using MultisampledTextureTest = TestHelper;
-
-TEST_F(MultisampledTextureTest, Is) {
- F32 f32;
- MultisampledTexture s(TextureDimension::kCube, &f32);
- Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_TRUE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(MultisampledTextureTest, IsTexture) {
- F32 f32;
- MultisampledTexture s(TextureDimension::kCube, &f32);
- Texture* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTexture>());
- EXPECT_TRUE(ty->Is<MultisampledTexture>());
- EXPECT_FALSE(ty->Is<SampledTexture>());
- EXPECT_FALSE(ty->Is<StorageTexture>());
-}
-
-TEST_F(MultisampledTextureTest, Dim) {
- F32 f32;
- MultisampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.dim(), TextureDimension::k3d);
-}
-
-TEST_F(MultisampledTextureTest, Type) {
- F32 f32;
- MultisampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.type(), &f32);
-}
-
-TEST_F(MultisampledTextureTest, TypeName) {
- F32 f32;
- MultisampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32");
-}
-
-TEST_F(MultisampledTextureTest, MinBufferBindingSize) {
- F32 f32;
- MultisampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/pointer_type.cc b/src/ast/type/pointer_type.cc
deleted file mode 100644
index 67c0cfa..0000000
--- a/src/ast/type/pointer_type.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2020 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/ast/type/pointer_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Pointer);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Pointer::Pointer(Type* subtype, StorageClass storage_class)
- : subtype_(subtype), storage_class_(storage_class) {}
-
-std::string Pointer::type_name() const {
- std::ostringstream out;
- out << "__ptr_" << storage_class_ << subtype_->type_name();
- return out.str();
-}
-
-Pointer::Pointer(Pointer&&) = default;
-
-Pointer::~Pointer() = default;
-
-Pointer* Pointer::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Pointer>(ctx->Clone(subtype_), storage_class_);
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/pointer_type.h b/src/ast/type/pointer_type.h
deleted file mode 100644
index 7a9a61b..0000000
--- a/src/ast/type/pointer_type.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2020 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_AST_TYPE_POINTER_TYPE_H_
-#define SRC_AST_TYPE_POINTER_TYPE_H_
-
-#include <sstream>
-#include <string>
-
-#include "src/ast/storage_class.h"
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A pointer type.
-class Pointer : public Castable<Pointer, Type> {
- public:
- /// Construtor
- /// @param subtype the pointee type
- /// @param storage_class the storage class of the pointer
- explicit Pointer(Type* subtype, StorageClass storage_class);
- /// Move constructor
- Pointer(Pointer&&);
- ~Pointer() override;
-
- /// @returns the pointee type
- Type* type() const { return subtype_; }
- /// @returns the storage class of the pointer
- StorageClass storage_class() const { return storage_class_; }
-
- /// @returns the name for this type
- std::string type_name() 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_;
- StorageClass const storage_class_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_POINTER_TYPE_H_
diff --git a/src/ast/type/pointer_type_test.cc b/src/ast/type/pointer_type_test.cc
deleted file mode 100644
index 95a4c87..0000000
--- a/src/ast/type/pointer_type_test.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2020 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/ast/type/pointer_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using PointerTest = TestHelper;
-
-TEST_F(PointerTest, Creation) {
- I32 i32;
- Pointer p{&i32, StorageClass::kStorage};
- EXPECT_EQ(p.type(), &i32);
- EXPECT_EQ(p.storage_class(), StorageClass::kStorage);
-}
-
-TEST_F(PointerTest, Is) {
- I32 i32;
- Pointer p{&i32, StorageClass::kFunction};
- Type* ty = &p;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_TRUE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(PointerTest, TypeName) {
- I32 i32;
- Pointer p{&i32, StorageClass::kWorkgroup};
- EXPECT_EQ(p.type_name(), "__ptr_workgroup__i32");
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/sampled_texture_type.cc b/src/ast/type/sampled_texture_type.cc
deleted file mode 100644
index 9a95c12..0000000
--- a/src/ast/type/sampled_texture_type.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2020 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/ast/type/sampled_texture_type.h"
-
-#include <cassert>
-#include <sstream>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::SampledTexture);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-SampledTexture::SampledTexture(TextureDimension dim, Type* type)
- : Base(dim), type_(type) {
- assert(type_);
-}
-
-SampledTexture::SampledTexture(SampledTexture&&) = default;
-
-SampledTexture::~SampledTexture() = default;
-
-std::string SampledTexture::type_name() const {
- std::ostringstream out;
- out << "__sampled_texture_" << dim() << type_->type_name();
- return out.str();
-}
-
-SampledTexture* SampledTexture::Clone(CloneContext* ctx) const {
- return ctx->mod->create<SampledTexture>(dim(), ctx->Clone(type_));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/sampled_texture_type.h b/src/ast/type/sampled_texture_type.h
deleted file mode 100644
index cdc93fa..0000000
--- a/src/ast/type/sampled_texture_type.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2020 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_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/texture_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A sampled texture type.
-class SampledTexture : public Castable<SampledTexture, Texture> {
- public:
- /// Constructor
- /// @param dim the dimensionality of the texture
- /// @param type the data type of the sampled texture
- SampledTexture(TextureDimension dim, Type* type);
- /// Move constructor
- SampledTexture(SampledTexture&&);
- ~SampledTexture() override;
-
- /// @returns the subtype of the sampled texture
- Type* type() const { return type_; }
-
- /// @returns the name for this type
- std::string type_name() 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:
- Type* const type_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
diff --git a/src/ast/type/sampled_texture_type_test.cc b/src/ast/type/sampled_texture_type_test.cc
deleted file mode 100644
index 5c6bcb4..0000000
--- a/src/ast/type/sampled_texture_type_test.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2020 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/ast/type/sampled_texture_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using SampledTextureTest = TestHelper;
-
-TEST_F(SampledTextureTest, Is) {
- F32 f32;
- SampledTexture s(TextureDimension::kCube, &f32);
- Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_TRUE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(SampledTextureTest, IsTexture) {
- F32 f32;
- SampledTexture s(TextureDimension::kCube, &f32);
- Texture* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTexture>());
- EXPECT_TRUE(ty->Is<SampledTexture>());
- EXPECT_FALSE(ty->Is<StorageTexture>());
-}
-
-TEST_F(SampledTextureTest, Dim) {
- F32 f32;
- SampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.dim(), TextureDimension::k3d);
-}
-
-TEST_F(SampledTextureTest, Type) {
- F32 f32;
- SampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.type(), &f32);
-}
-
-TEST_F(SampledTextureTest, TypeName) {
- F32 f32;
- SampledTexture s(TextureDimension::k3d, &f32);
- EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32");
-}
-
-TEST_F(SampledTextureTest, MinBufferBindingSize) {
- F32 f32;
- SampledTexture s(TextureDimension::kCube, &f32);
- EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/sampler_type.cc b/src/ast/type/sampler_type.cc
deleted file mode 100644
index f1070d4..0000000
--- a/src/ast/type/sampler_type.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2020 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/ast/type/sampler_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Sampler);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-std::ostream& operator<<(std::ostream& out, SamplerKind kind) {
- switch (kind) {
- case SamplerKind::kSampler:
- out << "sampler";
- break;
- case SamplerKind::kComparisonSampler:
- out << "comparison_sampler";
- break;
- }
- return out;
-}
-
-Sampler::Sampler(SamplerKind kind) : kind_(kind) {}
-
-Sampler::Sampler(Sampler&&) = default;
-
-Sampler::~Sampler() = default;
-
-std::string Sampler::type_name() const {
- return std::string("__sampler_") +
- (kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
-}
-
-Sampler* Sampler::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Sampler>(kind_);
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/sampler_type.h b/src/ast/type/sampler_type.h
deleted file mode 100644
index 28a60e8..0000000
--- a/src/ast/type/sampler_type.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2020 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_AST_TYPE_SAMPLER_TYPE_H_
-#define SRC_AST_TYPE_SAMPLER_TYPE_H_
-
-#include <ostream>
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// The different kinds of samplers
-enum class SamplerKind {
- /// A regular sampler
- kSampler,
- /// A comparison sampler
- kComparisonSampler
-};
-std::ostream& operator<<(std::ostream& out, SamplerKind kind);
-
-/// A sampler type.
-class Sampler : public Castable<Sampler, Type> {
- public:
- /// Constructor
- /// @param kind the kind of sampler
- explicit Sampler(SamplerKind kind);
- /// Move constructor
- Sampler(Sampler&&);
- ~Sampler() override;
-
- /// @returns the sampler type
- SamplerKind kind() const { return kind_; }
-
- /// @returns true if this is a comparison sampler
- bool IsComparison() const { return kind_ == SamplerKind::kComparisonSampler; }
-
- /// @returns the name for this type
- std::string type_name() 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:
- SamplerKind const kind_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_SAMPLER_TYPE_H_
diff --git a/src/ast/type/sampler_type_test.cc b/src/ast/type/sampler_type_test.cc
deleted file mode 100644
index 9641aec..0000000
--- a/src/ast/type/sampler_type_test.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2020 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/ast/type/sampler_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using SamplerTest = TestHelper;
-
-TEST_F(SamplerTest, Creation) {
- Sampler s{SamplerKind::kSampler};
- EXPECT_EQ(s.kind(), SamplerKind::kSampler);
-}
-
-TEST_F(SamplerTest, Creation_ComparisonSampler) {
- Sampler s{SamplerKind::kComparisonSampler};
- EXPECT_EQ(s.kind(), SamplerKind::kComparisonSampler);
- EXPECT_TRUE(s.IsComparison());
-}
-
-TEST_F(SamplerTest, Is) {
- Sampler s{SamplerKind::kSampler};
- Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_TRUE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(SamplerTest, TypeName_Sampler) {
- Sampler s{SamplerKind::kSampler};
- EXPECT_EQ(s.type_name(), "__sampler_sampler");
-}
-
-TEST_F(SamplerTest, TypeName_Comparison) {
- Sampler s{SamplerKind::kComparisonSampler};
- EXPECT_EQ(s.type_name(), "__sampler_comparison");
-}
-
-TEST_F(SamplerTest, MinBufferBindingSize) {
- Sampler s{SamplerKind::kSampler};
- EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/storage_texture_type.cc b/src/ast/type/storage_texture_type.cc
deleted file mode 100644
index 3dc432c..0000000
--- a/src/ast/type/storage_texture_type.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright 2020 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/ast/type/storage_texture_type.h"
-
-#include <cassert>
-#include <sstream>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::StorageTexture);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-// Note, these names match the names in the WGSL spec. This behaviour is used
-// in the WGSL writer to emit the texture format names.
-std::ostream& operator<<(std::ostream& out, ImageFormat format) {
- switch (format) {
- case ImageFormat::kNone:
- out << "none";
- break;
- case ImageFormat::kR8Unorm:
- out << "r8unorm";
- break;
- case ImageFormat::kR8Snorm:
- out << "r8snorm";
- break;
- case ImageFormat::kR8Uint:
- out << "r8uint";
- break;
- case ImageFormat::kR8Sint:
- out << "r8sint";
- break;
- case ImageFormat::kR16Uint:
- out << "r16uint";
- break;
- case ImageFormat::kR16Sint:
- out << "r16sint";
- break;
- case ImageFormat::kR16Float:
- out << "r16float";
- break;
- case ImageFormat::kRg8Unorm:
- out << "rg8unorm";
- break;
- case ImageFormat::kRg8Snorm:
- out << "rg8snorm";
- break;
- case ImageFormat::kRg8Uint:
- out << "rg8uint";
- break;
- case ImageFormat::kRg8Sint:
- out << "rg8sint";
- break;
- case ImageFormat::kR32Uint:
- out << "r32uint";
- break;
- case ImageFormat::kR32Sint:
- out << "r32sint";
- break;
- case ImageFormat::kR32Float:
- out << "r32float";
- break;
- case ImageFormat::kRg16Uint:
- out << "rg16uint";
- break;
- case ImageFormat::kRg16Sint:
- out << "rg16sint";
- break;
- case ImageFormat::kRg16Float:
- out << "rg16float";
- break;
- case ImageFormat::kRgba8Unorm:
- out << "rgba8unorm";
- break;
- case ImageFormat::kRgba8UnormSrgb:
- out << "rgba8unorm_srgb";
- break;
- case ImageFormat::kRgba8Snorm:
- out << "rgba8snorm";
- break;
- case ImageFormat::kRgba8Uint:
- out << "rgba8uint";
- break;
- case ImageFormat::kRgba8Sint:
- out << "rgba8sint";
- break;
- case ImageFormat::kBgra8Unorm:
- out << "bgra8unorm";
- break;
- case ImageFormat::kBgra8UnormSrgb:
- out << "bgra8unorm_srgb";
- break;
- case ImageFormat::kRgb10A2Unorm:
- out << "rgb10a2unorm";
- break;
- case ImageFormat::kRg11B10Float:
- out << "rg11b10float";
- break;
- case ImageFormat::kRg32Uint:
- out << "rg32uint";
- break;
- case ImageFormat::kRg32Sint:
- out << "rg32sint";
- break;
- case ImageFormat::kRg32Float:
- out << "rg32float";
- break;
- case ImageFormat::kRgba16Uint:
- out << "rgba16uint";
- break;
- case ImageFormat::kRgba16Sint:
- out << "rgba16sint";
- break;
- case ImageFormat::kRgba16Float:
- out << "rgba16float";
- break;
- case ImageFormat::kRgba32Uint:
- out << "rgba32uint";
- break;
- case ImageFormat::kRgba32Sint:
- out << "rgba32sint";
- break;
- case ImageFormat::kRgba32Float:
- out << "rgba32float";
- break;
- }
- return out;
-}
-
-StorageTexture::StorageTexture(TextureDimension dim, ImageFormat format)
- : Base(dim), image_format_(format) {}
-
-void StorageTexture::set_type(Type* const type) {
- type_ = type;
-}
-
-Type* StorageTexture::type() const {
- return type_;
-}
-
-StorageTexture::StorageTexture(StorageTexture&&) = default;
-
-StorageTexture::~StorageTexture() = default;
-
-std::string StorageTexture::type_name() const {
- std::ostringstream out;
- out << "__storage_texture_" << dim() << "_" << image_format_;
- return out.str();
-}
-
-StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
- return ctx->mod->create<StorageTexture>(dim(), image_format_);
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/storage_texture_type.h b/src/ast/type/storage_texture_type.h
deleted file mode 100644
index 2723a0f..0000000
--- a/src/ast/type/storage_texture_type.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2020 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_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/texture_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// The image format in the storage texture
-enum class ImageFormat {
- kNone = -1,
- kR8Unorm,
- kR8Snorm,
- kR8Uint,
- kR8Sint,
- kR16Uint,
- kR16Sint,
- kR16Float,
- kRg8Unorm,
- kRg8Snorm,
- kRg8Uint,
- kRg8Sint,
- kR32Uint,
- kR32Sint,
- kR32Float,
- kRg16Uint,
- kRg16Sint,
- kRg16Float,
- kRgba8Unorm,
- kRgba8UnormSrgb,
- kRgba8Snorm,
- kRgba8Uint,
- kRgba8Sint,
- kBgra8Unorm,
- kBgra8UnormSrgb,
- kRgb10A2Unorm,
- kRg11B10Float,
- kRg32Uint,
- kRg32Sint,
- kRg32Float,
- kRgba16Uint,
- kRgba16Sint,
- kRgba16Float,
- kRgba32Uint,
- kRgba32Sint,
- kRgba32Float,
-};
-std::ostream& operator<<(std::ostream& out, ImageFormat dim);
-
-/// A storage texture type.
-class StorageTexture : public Castable<StorageTexture, Texture> {
- public:
- /// Constructor
- /// @param dim the dimensionality of the texture
- /// @param format the image format of the texture
- StorageTexture(TextureDimension dim,
- ImageFormat format);
-
- /// Move constructor
- StorageTexture(StorageTexture&&);
- ~StorageTexture() override;
-
- /// @param type the subtype of the storage texture
- void set_type(Type* const type);
-
- /// @returns the subtype of the storage texture set with set_type
- Type* type() const;
-
- /// @returns the image format
- ImageFormat image_format() const { return image_format_; }
-
- /// @returns the name for this type
- std::string type_name() 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;
-
- private:
- ImageFormat const image_format_;
-
- Type* type_ = nullptr; // Semantic info
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
diff --git a/src/ast/type/storage_texture_type_test.cc b/src/ast/type/storage_texture_type_test.cc
deleted file mode 100644
index d05d53d..0000000
--- a/src/ast/type/storage_texture_type_test.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2020 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/ast/type/storage_texture_type.h"
-
-#include <memory>
-
-#include "src/ast/identifier_expression.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/type_determiner.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using StorageTextureTest = TestHelper;
-
-TEST_F(StorageTextureTest, Is) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
- Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_TRUE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(StorageTextureTest, IsTexture) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
- Texture* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTexture>());
- EXPECT_FALSE(ty->Is<SampledTexture>());
- EXPECT_TRUE(ty->Is<StorageTexture>());
-}
-
-TEST_F(StorageTextureTest, Dim) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
- EXPECT_EQ(s.dim(), TextureDimension::k2dArray);
-}
-
-TEST_F(StorageTextureTest, Format) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
- EXPECT_EQ(s.image_format(), ImageFormat::kRgba32Float);
-}
-
-TEST_F(StorageTextureTest, TypeName) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
- EXPECT_EQ(s.type_name(), "__storage_texture_2d_array_rgba32float");
-}
-
-TEST_F(StorageTextureTest, F32) {
- Type* s = mod->create<StorageTexture>(TextureDimension::k2dArray,
- ImageFormat::kRgba32Float);
- TypeDeterminer td(mod);
-
- ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<Texture>());
- ASSERT_TRUE(s->Is<StorageTexture>());
- EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<F32>());
-}
-
-TEST_F(StorageTextureTest, U32) {
- Type* s = mod->create<StorageTexture>(TextureDimension::k2dArray,
- ImageFormat::kRg32Uint);
- TypeDeterminer td(mod);
-
- ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<Texture>());
- ASSERT_TRUE(s->Is<StorageTexture>());
- EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<U32>());
-}
-
-TEST_F(StorageTextureTest, I32) {
- Type* s = mod->create<StorageTexture>(TextureDimension::k2dArray,
- ImageFormat::kRgba32Sint);
- TypeDeterminer td(mod);
-
- ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<Texture>());
- ASSERT_TRUE(s->Is<StorageTexture>());
- EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<I32>());
-}
-
-TEST_F(StorageTextureTest, MinBufferBindingSize) {
- StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Sint);
- EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc
deleted file mode 100644
index 24f5640..0000000
--- a/src/ast/type/struct_type.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2020 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/ast/type/struct_type.h"
-
-#include <cmath>
-#include <utility>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/vector_type.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Struct);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Struct::Struct(const Symbol& sym, ast::Struct* impl)
- : symbol_(sym), struct_(impl) {}
-
-Struct::Struct(Struct&&) = default;
-
-Struct::~Struct() = default;
-
-std::string Struct::type_name() const {
- return "__struct_" + symbol_.to_str();
-}
-
-uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const {
- if (!struct_->members().size()) {
- return 0;
- }
-
- auto* last_member = struct_->members().back();
-
- // If there is no offset, then this is not a host-shareable struct, returning
- // 0 indicates this to the caller.
- if (!last_member->has_offset_decoration()) {
- return 0;
- }
-
- uint64_t size = last_member->type()->MinBufferBindingSize(mem_layout);
- if (!size) {
- return 0;
- }
-
- float unaligned = static_cast<float>(last_member->offset() + size);
- float alignment = static_cast<float>(BaseAlignment(mem_layout));
-
- return static_cast<uint64_t>(alignment * std::ceil(unaligned / alignment));
-}
-
-uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const {
- uint64_t max = 0;
- for (auto* member : struct_->members()) {
- if (member->type()->BaseAlignment(mem_layout) > max) {
- max = member->type()->BaseAlignment(mem_layout);
- }
- }
-
- if (mem_layout == MemoryLayout::kUniformBuffer) {
- // Round up to a vec4.
- return static_cast<uint64_t>(16 *
- std::ceil(static_cast<float>(max) / 16.0f));
- } else if (mem_layout == MemoryLayout::kStorageBuffer) {
- return max;
- }
- return 0;
-}
-
-Struct* Struct::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Struct>(ctx->Clone(symbol()), ctx->Clone(struct_));
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h
deleted file mode 100644
index e340f4bb..0000000
--- a/src/ast/type/struct_type.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2020 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_AST_TYPE_STRUCT_TYPE_H_
-#define SRC_AST_TYPE_STRUCT_TYPE_H_
-
-#include <memory>
-#include <string>
-
-#include "src/ast/struct.h"
-#include "src/ast/type/type.h"
-#include "src/symbol.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A structure type
-class Struct : public Castable<Struct, Type> {
- public:
- /// Constructor
- /// @param sym the symbol representing the struct
- /// @param impl the struct data
- Struct(const Symbol& sym, ast::Struct* impl);
- /// Move constructor
- Struct(Struct&&);
- ~Struct() override;
-
- /// @returns the struct symbol
- const Symbol& symbol() const { return symbol_; }
-
- /// @returns true if the struct has a block decoration
- bool IsBlockDecorated() const { return struct_->IsBlockDecorated(); }
-
- /// @returns the struct
- ast::Struct* impl() const { return struct_; }
-
- /// @returns the name for the type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
-
- /// Clones this type and all transitive types using the `CloneContext` `ctx`.
- /// @param ctx the clone context
- /// @return the newly cloned type
- Struct* Clone(CloneContext* ctx) const override;
-
- private:
- Symbol const symbol_;
- ast::Struct* const struct_;
-
- uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_STRUCT_TYPE_H_
diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc
deleted file mode 100644
index ca5be28..0000000
--- a/src/ast/type/struct_type_test.cc
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright 2020 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/ast/type/struct_type.h"
-
-#include <utility>
-
-#include "src/ast/stride_decoration.h"
-#include "src/ast/struct_member.h"
-#include "src/ast/struct_member_decoration.h"
-#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using StructTest = TestHelper;
-
-TEST_F(StructTest, Creation) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* ptr = impl;
- auto* s = ty.struct_("S", impl);
- EXPECT_EQ(s->impl(), ptr);
-}
-
-TEST_F(StructTest, Is) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* s = ty.struct_("S", impl);
- type::Type* ty = s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_TRUE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(StructTest, TypeName) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* s = ty.struct_("my_struct", impl);
- EXPECT_EQ(s->type_name(), "__struct_tint_symbol_1");
-}
-
-TEST_F(StructTest, MinBufferBindingSize) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeArray) {
- Array arr(ty.u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
-
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", &arr, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(32u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(24u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
- Array arr(ty.u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
-
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(12u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec2) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec3) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec4) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignment) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentArray) {
- Array arr(ty.u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", &arr, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentRuntimeArray) {
- Array arr(ty.u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec2) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec3) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec4) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/texture_type.cc b/src/ast/type/texture_type.cc
deleted file mode 100644
index 58a0d47..0000000
--- a/src/ast/type/texture_type.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2020 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/ast/type/texture_type.h"
-
-#include <cassert>
-#include <ostream>
-
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Texture);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
- switch (dim) {
- case TextureDimension::kNone:
- out << "None";
- break;
- case TextureDimension::k1d:
- out << "1d";
- break;
- case TextureDimension::k1dArray:
- out << "1d_array";
- break;
- case TextureDimension::k2d:
- out << "2d";
- break;
- case TextureDimension::k2dArray:
- out << "2d_array";
- break;
- case TextureDimension::k3d:
- out << "3d";
- break;
- case TextureDimension::kCube:
- out << "cube";
- break;
- case TextureDimension::kCubeArray:
- out << "cube_array";
- break;
- }
- return out;
-}
-
-bool IsTextureArray(TextureDimension dim) {
- switch (dim) {
- case TextureDimension::k1dArray:
- case TextureDimension::k2dArray:
- case TextureDimension::kCubeArray:
- return true;
- case TextureDimension::k2d:
- case TextureDimension::kNone:
- case TextureDimension::k1d:
- case TextureDimension::k3d:
- case TextureDimension::kCube:
- return false;
- }
- return false;
-}
-
-int NumCoordinateAxes(TextureDimension dim) {
- switch (dim) {
- case TextureDimension::kNone:
- return 0;
- case TextureDimension::k1d:
- case TextureDimension::k1dArray:
- return 1;
- case TextureDimension::k2d:
- case TextureDimension::k2dArray:
- return 2;
- case TextureDimension::k3d:
- case TextureDimension::kCube:
- case TextureDimension::kCubeArray:
- return 3;
- }
- return 0;
-}
-
-Texture::Texture(TextureDimension dim) : dim_(dim) {}
-
-Texture::Texture(Texture&&) = default;
-
-Texture::~Texture() = default;
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/texture_type.h b/src/ast/type/texture_type.h
deleted file mode 100644
index 495afd9..0000000
--- a/src/ast/type/texture_type.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2020 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_AST_TYPE_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_TEXTURE_TYPE_H_
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// The dimensionality of the texture
-enum class TextureDimension {
- /// Invalid texture
- kNone = -1,
- /// 1 dimensional texture
- k1d,
- /// 1 dimenstional array texture
- k1dArray,
- /// 2 dimensional texture
- k2d,
- /// 2 dimensional array texture
- k2dArray,
- /// 3 dimensional texture
- k3d,
- /// cube texture
- kCube,
- /// cube array texture
- kCubeArray,
-};
-std::ostream& operator<<(std::ostream& out, TextureDimension dim);
-
-/// @param dim the TextureDimension to query
-/// @return true if the given TextureDimension is an array texture
-bool IsTextureArray(TextureDimension dim);
-
-/// Returns the number of axes in the coordinate for a dimensionality.
-/// None -> 0
-/// 1D, 1DArray -> 1
-/// 2D, 2DArray -> 2
-/// 3D, Cube, CubeArray -> 3
-/// @param dim the TextureDimension to query
-/// @return number of dimensions in a coordinate for the dimensionality
-int NumCoordinateAxes(TextureDimension dim);
-
-/// A texture type.
-class Texture : public Castable<Texture, Type> {
- public:
- /// Constructor
- /// @param dim the dimensionality of the texture
- explicit Texture(TextureDimension dim);
- /// Move constructor
- Texture(Texture&&);
- ~Texture() override;
-
- /// @returns the texture dimension
- TextureDimension dim() const { return dim_; }
-
- private:
- TextureDimension const dim_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_TEXTURE_TYPE_H_
diff --git a/src/ast/type/texture_type_test.cc b/src/ast/type/texture_type_test.cc
deleted file mode 100644
index 3ed1921..0000000
--- a/src/ast/type/texture_type_test.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2021 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/ast/type/texture_type.h"
-
-#include "src/ast/test_helper.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using TextureTypeTest = TestHelper;
-
-TEST_F(TextureTypeTest, IsTextureArray) {
- EXPECT_EQ(false, IsTextureArray(TextureDimension::kNone));
- EXPECT_EQ(false, IsTextureArray(TextureDimension::k1d));
- EXPECT_EQ(true, IsTextureArray(TextureDimension::k1dArray));
- EXPECT_EQ(false, IsTextureArray(TextureDimension::k2d));
- EXPECT_EQ(true, IsTextureArray(TextureDimension::k2dArray));
- EXPECT_EQ(false, IsTextureArray(TextureDimension::k3d));
- EXPECT_EQ(false, IsTextureArray(TextureDimension::kCube));
- EXPECT_EQ(true, IsTextureArray(TextureDimension::kCubeArray));
-}
-
-TEST_F(TextureTypeTest, NumCoordinateAxes) {
- EXPECT_EQ(0, NumCoordinateAxes(TextureDimension::kNone));
- EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1d));
- EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1dArray));
- EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2d));
- EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2dArray));
- EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::k3d));
- EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCube));
- EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCubeArray));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/type.cc b/src/ast/type/type.cc
deleted file mode 100644
index 329812f..0000000
--- a/src/ast/type/type.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2020 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/ast/type/type.h"
-
-#include <assert.h>
-
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Type);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Type::Type() = default;
-
-Type::Type(Type&&) = default;
-
-Type::~Type() = default;
-
-Type* Type::UnwrapPtrIfNeeded() {
- if (auto* ptr = As<type::Pointer>()) {
- return ptr->type();
- }
- return this;
-}
-
-Type* Type::UnwrapIfNeeded() {
- auto* where = this;
- while (true) {
- if (auto* alias = where->As<type::Alias>()) {
- where = alias->type();
- } else if (auto* access = where->As<type::AccessControl>()) {
- where = access->type();
- } else {
- break;
- }
- }
- return where;
-}
-
-Type* Type::UnwrapAll() {
- return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
-}
-
-uint64_t Type::MinBufferBindingSize(MemoryLayout) const {
- return 0;
-}
-
-uint64_t Type::BaseAlignment(MemoryLayout) const {
- return 0;
-}
-
-bool Type::is_scalar() {
- return is_float_scalar() || is_integer_scalar() || Is<Bool>();
-}
-
-bool Type::is_float_scalar() {
- return Is<F32>();
-}
-
-bool Type::is_float_matrix() {
- return Is<Matrix>() && As<Matrix>()->type()->is_float_scalar();
-}
-
-bool Type::is_float_vector() {
- return Is<Vector>() && As<Vector>()->type()->is_float_scalar();
-}
-
-bool Type::is_float_scalar_or_vector() {
- return is_float_scalar() || is_float_vector();
-}
-
-bool Type::is_integer_scalar() {
- return Is<U32>() || Is<I32>();
-}
-
-bool Type::is_unsigned_integer_vector() {
- return Is<Vector>() && As<Vector>()->type()->Is<U32>();
-}
-
-bool Type::is_signed_integer_vector() {
- return Is<Vector>() && As<Vector>()->type()->Is<I32>();
-}
-
-bool Type::is_unsigned_scalar_or_vector() {
- return Is<U32>() || (Is<Vector>() && As<Vector>()->type()->Is<U32>());
-}
-
-bool Type::is_signed_scalar_or_vector() {
- return Is<I32>() || (Is<Vector>() && As<Vector>()->type()->Is<I32>());
-}
-
-bool Type::is_integer_scalar_or_vector() {
- return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/type.h b/src/ast/type/type.h
deleted file mode 100644
index 536ddd1..0000000
--- a/src/ast/type/type.h
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2020 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_AST_TYPE_TYPE_H_
-#define SRC_AST_TYPE_TYPE_H_
-
-#include <string>
-
-#include "src/castable.h"
-
-namespace tint {
-namespace ast {
-
-class Module;
-class CloneContext;
-
-namespace type {
-
-/// Supported memory layouts for calculating sizes
-enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
-
-/// Base class for a type in the system
-class Type : public Castable<Type> {
- public:
- /// Move constructor
- Type(Type&&);
- ~Type() override;
-
- /// Clones this type and all transitive types using the `CloneContext` `ctx`.
- /// @param ctx the clone context
- /// @return the newly cloned type
- virtual Type* Clone(CloneContext* ctx) const = 0;
-
- /// @returns the name for this type. The type name is unique over all types.
- virtual std::string type_name() const = 0;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- virtual uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- virtual uint64_t BaseAlignment(MemoryLayout mem_layout) const;
-
- /// @returns the pointee type if this is a pointer, `this` otherwise
- Type* UnwrapPtrIfNeeded();
-
- /// Removes all levels of aliasing and access control.
- /// This is just enough to assist with WGSL translation
- /// in that you want see through one level of pointer to get from an
- /// identifier-like expression as an l-value to its corresponding r-value,
- /// plus see through the wrappers on either side.
- /// @returns the completely unaliased type.
- Type* UnwrapIfNeeded();
-
- /// Returns the type found after:
- /// - removing all layers of aliasing and access control if they exist, then
- /// - removing the pointer, if it exists, then
- /// - removing all further layers of aliasing or access control, if they exist
- /// @returns the unwrapped type
- Type* UnwrapAll();
-
- /// @returns true if this type is a scalar
- bool is_scalar();
- /// @returns true if this type is a float scalar
- bool is_float_scalar();
- /// @returns true if this type is a float matrix
- bool is_float_matrix();
- /// @returns true if this type is a float vector
- bool is_float_vector();
- /// @returns true if this type is a float scalar or vector
- bool is_float_scalar_or_vector();
- /// @returns ture if this type is an integer scalar
- bool is_integer_scalar();
- /// @returns true if this type is a signed integer vector
- bool is_signed_integer_vector();
- /// @returns true if this type is an unsigned vector
- bool is_unsigned_integer_vector();
- /// @returns true if this type is an unsigned scalar or vector
- bool is_unsigned_scalar_or_vector();
- /// @returns true if this type is a signed scalar or vector
- bool is_signed_scalar_or_vector();
- /// @returns true if this type is an integer scalar or vector
- bool is_integer_scalar_or_vector();
-
- protected:
- 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 t the `Type` to clone (if not null)
- /// @return the cloned type
- template <typename T>
- static T* Clone(Module* m, const T* t) {
- return (t != nullptr) ? static_cast<T*>(t->Clone(m)) : nullptr;
- }
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_TYPE_H_
diff --git a/src/ast/type/u32_type.cc b/src/ast/type/u32_type.cc
deleted file mode 100644
index 37364d7..0000000
--- a/src/ast/type/u32_type.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2020 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/ast/type/u32_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::U32);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-U32::U32() = default;
-
-U32::~U32() = default;
-
-U32::U32(U32&&) = default;
-
-std::string U32::type_name() const {
- return "__u32";
-}
-
-uint64_t U32::MinBufferBindingSize(MemoryLayout) const {
- return 4;
-}
-
-uint64_t U32::BaseAlignment(MemoryLayout) const {
- return 4;
-}
-
-U32* U32::Clone(CloneContext* ctx) const {
- return ctx->mod->create<U32>();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/u32_type.h b/src/ast/type/u32_type.h
deleted file mode 100644
index 9e04155..0000000
--- a/src/ast/type/u32_type.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2020 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_AST_TYPE_U32_TYPE_H_
-#define SRC_AST_TYPE_U32_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A unsigned int 32 type.
-class U32 : public Castable<U32, Type> {
- public:
- /// Constructor
- U32();
- /// Move constructor
- U32(U32&&);
- ~U32() override;
-
- /// @returns the name for th type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_U32_TYPE_H_
diff --git a/src/ast/type/u32_type_test.cc b/src/ast/type/u32_type_test.cc
deleted file mode 100644
index bf3a56b..0000000
--- a/src/ast/type/u32_type_test.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2020 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/ast/type/u32_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using U32Test = TestHelper;
-
-TEST_F(U32Test, Is) {
- U32 u;
- Type* ty = &u;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_TRUE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(U32Test, TypeName) {
- U32 u;
- EXPECT_EQ(u.type_name(), "__u32");
-}
-
-TEST_F(U32Test, MinBufferBindingSize) {
- U32 u;
- EXPECT_EQ(4u, u.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(U32Test, BaseAlignment) {
- U32 u;
- EXPECT_EQ(4u, u.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/vector_type.cc b/src/ast/type/vector_type.cc
deleted file mode 100644
index 3697e4e..0000000
--- a/src/ast/type/vector_type.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2020 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/ast/type/vector_type.h"
-
-#include <assert.h>
-#include <cmath>
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Vector);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Vector::Vector(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {
- assert(size_ > 1);
- assert(size_ < 5);
-}
-
-Vector::Vector(Vector&&) = default;
-
-Vector::~Vector() = default;
-
-std::string Vector::type_name() const {
- return "__vec_" + std::to_string(size_) + subtype_->type_name();
-}
-
-uint64_t Vector::MinBufferBindingSize(MemoryLayout mem_layout) const {
- return size_ * subtype_->MinBufferBindingSize(mem_layout);
-}
-
-uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) const {
- if (size_ == 2) {
- return 2 * subtype_->BaseAlignment(mem_layout);
- } else if (size_ == 3 || size_ == 4) {
- return 4 * subtype_->BaseAlignment(mem_layout);
- }
-
- return 0; // vectors are only supposed to have 2, 3, or 4 elements.
-}
-
-Vector* Vector::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Vector>(ctx->Clone(subtype_), size_);
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/vector_type.h b/src/ast/type/vector_type.h
deleted file mode 100644
index 4228c59..0000000
--- a/src/ast/type/vector_type.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2020 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_AST_TYPE_VECTOR_TYPE_H_
-#define SRC_AST_TYPE_VECTOR_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A vector type.
-class Vector : public Castable<Vector, Type> {
- public:
- /// Constructor
- /// @param subtype the vector element type
- /// @param size the number of elements in the vector
- Vector(Type* subtype, uint32_t size);
- /// Move constructor
- Vector(Vector&&);
- ~Vector() override;
-
- /// @returns the type of the vector elements
- Type* type() const { return subtype_; }
- /// @returns the size of the vector
- uint32_t size() const { return size_; }
-
- /// @returns the name for th type
- std::string type_name() const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns minimum size required for this type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t MinBufferBindingSize(MemoryLayout mem_layout) const override;
-
- /// @param mem_layout type of memory layout to use in calculation.
- /// @returns base alignment for the type, in bytes.
- /// 0 for non-host shareable types.
- uint64_t BaseAlignment(MemoryLayout mem_layout) 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 subtype_;
- uint32_t const size_;
-};
-
-} // namespace type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_VECTOR_TYPE_H_
diff --git a/src/ast/type/vector_type_test.cc b/src/ast/type/vector_type_test.cc
deleted file mode 100644
index 9b885ae..0000000
--- a/src/ast/type/vector_type_test.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2020 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/ast/type/vector_type.h"
-
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using VectorTest = TestHelper;
-
-TEST_F(VectorTest, Creation) {
- I32 i32;
- Vector v{&i32, 2};
- EXPECT_EQ(v.type(), &i32);
- EXPECT_EQ(v.size(), 2u);
-}
-
-TEST_F(VectorTest, Is) {
- I32 i32;
- Vector v{&i32, 4};
- Type* ty = &v;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_TRUE(ty->Is<Vector>());
-}
-
-TEST_F(VectorTest, TypeName) {
- I32 i32;
- Vector v{&i32, 3};
- EXPECT_EQ(v.type_name(), "__vec_3__i32");
-}
-
-TEST_F(VectorTest, MinBufferBindingSizeVec2) {
- I32 i32;
- Vector v{&i32, 2};
- EXPECT_EQ(8u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(VectorTest, MinBufferBindingSizeVec3) {
- I32 i32;
- Vector v{&i32, 3};
- EXPECT_EQ(12u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(VectorTest, MinBufferBindingSizeVec4) {
- I32 i32;
- Vector v{&i32, 4};
- EXPECT_EQ(16u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(VectorTest, BaseAlignmentVec2) {
- I32 i32;
- Vector v{&i32, 2};
- EXPECT_EQ(8u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(VectorTest, BaseAlignmentVec3) {
- I32 i32;
- Vector v{&i32, 3};
- EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-TEST_F(VectorTest, BaseAlignmentVec4) {
- I32 i32;
- Vector v{&i32, 4};
- EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/void_type.cc b/src/ast/type/void_type.cc
deleted file mode 100644
index 62ce402..0000000
--- a/src/ast/type/void_type.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2020 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/ast/type/void_type.h"
-
-#include "src/ast/clone_context.h"
-#include "src/ast/module.h"
-
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Void);
-
-namespace tint {
-namespace ast {
-namespace type {
-
-Void::Void() = default;
-
-Void::Void(Void&&) = default;
-
-Void::~Void() = default;
-
-std::string Void::type_name() const {
- return "__void";
-}
-
-Void* Void::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Void>();
-}
-
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type/void_type.h b/src/ast/type/void_type.h
deleted file mode 100644
index 8631188..0000000
--- a/src/ast/type/void_type.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2020 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_AST_TYPE_VOID_TYPE_H_
-#define SRC_AST_TYPE_VOID_TYPE_H_
-
-#include <string>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-
-/// A void type
-class Void : public Castable<Void, Type> {
- public:
- /// Constructor
- Void();
- /// Move constructor
- Void(Void&&);
- ~Void() override;
-
- /// @returns the name for this type
- std::string type_name() 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 type
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_VOID_TYPE_H_
diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h
index 66f45b1..1fdbeec 100644
--- a/src/ast/type_constructor_expression.h
+++ b/src/ast/type_constructor_expression.h
@@ -19,7 +19,7 @@
#include <utility>
#include "src/ast/constructor_expression.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc
index 9b51d8e..b7bbfb0 100644
--- a/src/ast/type_constructor_expression_test.cc
+++ b/src/ast/type_constructor_expression_test.cc
@@ -20,8 +20,8 @@
#include "src/ast/constructor_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/type_manager.cc b/src/ast/type_manager.cc
deleted file mode 100644
index 39f4e07..0000000
--- a/src/ast/type_manager.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2020 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/ast/type_manager.h"
-
-#include <utility>
-
-namespace tint {
-namespace ast {
-
-TypeManager::TypeManager() = default;
-TypeManager::TypeManager(TypeManager&&) = default;
-TypeManager& TypeManager::operator=(TypeManager&& rhs) = default;
-TypeManager::~TypeManager() = default;
-
-void TypeManager::Reset() {
- types_.clear();
-}
-
-type::Type* TypeManager::Get(std::unique_ptr<type::Type> type) {
- auto name = type->type_name();
-
- if (types_.find(name) == types_.end()) {
- types_[name] = std::move(type);
- }
- return types_.find(name)->second.get();
-}
-
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type_manager.h b/src/ast/type_manager.h
deleted file mode 100644
index f428ac9..0000000
--- a/src/ast/type_manager.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2020 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_AST_TYPE_MANAGER_H_
-#define SRC_AST_TYPE_MANAGER_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-#include <utility>
-
-#include "src/ast/type/type.h"
-
-namespace tint {
-namespace ast {
-
-/// The type manager holds all the pointers to the known types.
-class TypeManager {
- public:
- /// Constructor
- TypeManager();
-
- /// Move constructor
- TypeManager(TypeManager&&);
-
- /// Move assignment operator
- /// @param rhs the TypeManager to move
- /// @return this TypeManager
- TypeManager& operator=(TypeManager&& rhs);
-
- /// Destructor
- ~TypeManager();
-
- /// Clears all registered types.
- void Reset();
-
- /// Get the given type from the type manager
- /// @param type The type to register
- /// @return the pointer to the registered type
- type::Type* Get(std::unique_ptr<type::Type> type);
-
- /// Get the given type `T` from the type manager
- /// @param args the arguments to pass to the type constructor
- /// @return the pointer to the registered type
- template <typename T, typename... ARGS>
- T* Get(ARGS&&... args) {
- auto ty = Get(std::make_unique<T>(std::forward<ARGS>(args)...));
- return static_cast<T*>(ty);
- }
-
- /// Returns the type map
- /// @returns the mapping from name string to type.
- const std::unordered_map<std::string, std::unique_ptr<type::Type>>& types() {
- return types_;
- }
-
- private:
- std::unordered_map<std::string, std::unique_ptr<type::Type>> types_;
-};
-
-} // namespace ast
-} // namespace tint
-
-#endif // SRC_AST_TYPE_MANAGER_H_
diff --git a/src/ast/type_manager_test.cc b/src/ast/type_manager_test.cc
deleted file mode 100644
index f78a61f..0000000
--- a/src/ast/type_manager_test.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2020 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/ast/type_manager.h"
-
-#include "gtest/gtest.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
-
-namespace tint {
-namespace ast {
-namespace {
-
-using TypeManagerTest = testing::Test;
-
-TEST_F(TypeManagerTest, GetUnregistered) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
- ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
-}
-
-TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
- ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
-
- auto* t2 = tm.Get(std::make_unique<type::I32>());
- EXPECT_EQ(t, t2);
-}
-
-TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
- ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
-
- auto* t2 = tm.Get(std::make_unique<type::U32>());
- ASSERT_NE(t2, nullptr);
- EXPECT_NE(t, t2);
- EXPECT_TRUE(t2->Is<type::U32>());
-}
-
-TEST_F(TypeManagerTest, ResetClearsPreviousData) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
- ASSERT_NE(t, nullptr);
-
- EXPECT_FALSE(tm.types().empty());
- tm.Reset();
- EXPECT_TRUE(tm.types().empty());
-
- auto* t2 = tm.Get(std::make_unique<type::I32>());
- ASSERT_NE(t2, nullptr);
-}
-
-} // namespace
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc
index 1197ba7..db3e1bb 100644
--- a/src/ast/uint_literal_test.cc
+++ b/src/ast/uint_literal_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable.h b/src/ast/variable.h
index 88257b2..e721ad0 100644
--- a/src/ast/variable.h
+++ b/src/ast/variable.h
@@ -23,9 +23,9 @@
#include "src/ast/expression.h"
#include "src/ast/node.h"
#include "src/ast/storage_class.h"
-#include "src/ast/type/type.h"
#include "src/ast/variable_decoration.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc
index a432804..60b878b 100644
--- a/src/ast/variable_decl_statement_test.cc
+++ b/src/ast/variable_decl_statement_test.cc
@@ -15,8 +15,8 @@
#include "src/ast/variable_decl_statement.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc
index 7f19618..331d17f 100644
--- a/src/ast/variable_test.cc
+++ b/src/ast/variable_test.cc
@@ -17,8 +17,8 @@
#include "src/ast/constant_id_decoration.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {