Move all classes from namespace `type` to namespace `sem`
Bug: tint:724
Change-Id: I4eeabab9b00b6b28f61645bd95d326fb48609bf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48362
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/ast/bitcast_expression.cc b/src/ast/bitcast_expression.cc
index 6b78366..a39870b 100644
--- a/src/ast/bitcast_expression.cc
+++ b/src/ast/bitcast_expression.cc
@@ -23,7 +23,7 @@
BitcastExpression::BitcastExpression(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
Expression* expr)
: Base(program_id, source), type_(type), expr_(expr) {
TINT_ASSERT(type_);
diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h
index 9c87ba5..6b6cc2b 100644
--- a/src/ast/bitcast_expression.h
+++ b/src/ast/bitcast_expression.h
@@ -30,14 +30,14 @@
/// @param expr the expr
BitcastExpression(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
Expression* expr);
/// Move constructor
BitcastExpression(BitcastExpression&&);
~BitcastExpression() override;
/// @returns the left side expression
- type::Type* type() const { return type_; }
+ sem::Type* type() const { return type_; }
/// @returns the expression
Expression* expr() const { return expr_; }
@@ -58,7 +58,7 @@
private:
BitcastExpression(const BitcastExpression&) = delete;
- type::Type* const type_;
+ sem::Type* const type_;
Expression* const expr_;
};
diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc
index 5e4cf86..b264c4a 100644
--- a/src/ast/bool_literal.cc
+++ b/src/ast/bool_literal.cc
@@ -23,7 +23,7 @@
BoolLiteral::BoolLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
bool value)
: Base(program_id, source, type), value_(value) {}
diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h
index b95adc0..4f2fce1 100644
--- a/src/ast/bool_literal.h
+++ b/src/ast/bool_literal.h
@@ -32,7 +32,7 @@
/// @param value the bool literals value
BoolLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
bool value);
~BoolLiteral() override;
diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc
index de3a358..f7a8005 100644
--- a/src/ast/bool_literal_test.cc
+++ b/src/ast/bool_literal_test.cc
@@ -21,7 +21,7 @@
using BoolLiteralTest = TestHelper;
TEST_F(BoolLiteralTest, True) {
- type::Bool bool_type;
+ sem::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, true);
ASSERT_TRUE(b->Is<BoolLiteral>());
ASSERT_TRUE(b->IsTrue());
@@ -29,7 +29,7 @@
}
TEST_F(BoolLiteralTest, False) {
- type::Bool bool_type;
+ sem::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, false);
ASSERT_TRUE(b->Is<BoolLiteral>());
ASSERT_FALSE(b->IsTrue());
@@ -37,7 +37,7 @@
}
TEST_F(BoolLiteralTest, Is) {
- type::Bool bool_type;
+ sem::Bool bool_type;
ast::Literal* l = create<BoolLiteral>(&bool_type, false);
EXPECT_TRUE(l->Is<BoolLiteral>());
EXPECT_FALSE(l->Is<SintLiteral>());
@@ -47,7 +47,7 @@
}
TEST_F(BoolLiteralTest, ToStr) {
- type::Bool bool_type;
+ sem::Bool bool_type;
auto* t = create<BoolLiteral>(&bool_type, true);
auto* f = create<BoolLiteral>(&bool_type, false);
diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc
index 1c301b7..b23742c 100644
--- a/src/ast/float_literal.cc
+++ b/src/ast/float_literal.cc
@@ -25,7 +25,7 @@
FloatLiteral::FloatLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
float value)
: Base(program_id, source, type), value_(value) {}
diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h
index 82e37ba..9d03093 100644
--- a/src/ast/float_literal.h
+++ b/src/ast/float_literal.h
@@ -32,7 +32,7 @@
/// @param value the float literals value
FloatLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
float value);
~FloatLiteral() override;
diff --git a/src/ast/function.cc b/src/ast/function.cc
index df83626..a14d3cb 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -27,7 +27,7 @@
const Source& source,
Symbol symbol,
VariableList params,
- type::Type* return_type,
+ sem::Type* return_type,
BlockStatement* body,
DecorationList decorations,
DecorationList return_type_decorations)
diff --git a/src/ast/function.h b/src/ast/function.h
index 62f3bd7..bb43b2f 100644
--- a/src/ast/function.h
+++ b/src/ast/function.h
@@ -48,7 +48,7 @@
const Source& source,
Symbol symbol,
VariableList params,
- type::Type* return_type,
+ sem::Type* return_type,
BlockStatement* body,
DecorationList decorations,
DecorationList return_type_decorations);
@@ -76,7 +76,7 @@
bool IsEntryPoint() const { return pipeline_stage() != PipelineStage::kNone; }
/// @returns the function return type.
- type::Type* return_type() const { return return_type_; }
+ sem::Type* return_type() const { return return_type_; }
/// @returns the decorations attached to the function return type.
const DecorationList& return_type_decorations() const {
@@ -114,7 +114,7 @@
Symbol const symbol_;
VariableList const params_;
- type::Type* const return_type_;
+ sem::Type* const return_type_;
BlockStatement* const body_;
DecorationList const decorations_;
DecorationList const return_type_decorations_;
diff --git a/src/ast/int_literal.cc b/src/ast/int_literal.cc
index 0b3db78..b959e0a 100644
--- a/src/ast/int_literal.cc
+++ b/src/ast/int_literal.cc
@@ -21,7 +21,7 @@
IntLiteral::IntLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
uint32_t value)
: Base(program_id, source, type), value_(value) {}
diff --git a/src/ast/int_literal.h b/src/ast/int_literal.h
index 2c2afeb..5aca29e 100644
--- a/src/ast/int_literal.h
+++ b/src/ast/int_literal.h
@@ -36,7 +36,7 @@
/// @param value value of the literal
IntLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
uint32_t value);
private:
diff --git a/src/ast/intrinsic_texture_helper_test.cc b/src/ast/intrinsic_texture_helper_test.cc
index 0d9632e..f9be5ba 100644
--- a/src/ast/intrinsic_texture_helper_test.cc
+++ b/src/ast/intrinsic_texture_helper_test.cc
@@ -32,8 +32,8 @@
ValidTextureOverload o,
const char* desc,
TextureKind tk,
- type::SamplerKind sk,
- type::TextureDimension dims,
+ sem::SamplerKind sk,
+ sem::TextureDimension dims,
TextureDataType datatype,
const char* f,
std::function<ExpressionList(ProgramBuilder*)> a)
@@ -49,7 +49,7 @@
ValidTextureOverload o,
const char* desc,
TextureKind tk,
- type::TextureDimension dims,
+ sem::TextureDimension dims,
TextureDataType datatype,
const char* f,
std::function<ExpressionList(ProgramBuilder*)> a)
@@ -64,8 +64,8 @@
ValidTextureOverload o,
const char* d,
AccessControl access,
- type::ImageFormat i,
- type::TextureDimension dims,
+ sem::ImageFormat i,
+ sem::TextureDimension dims,
TextureDataType datatype,
const char* f,
std::function<ExpressionList(ProgramBuilder*)> a)
@@ -132,7 +132,7 @@
return out;
}
-type::Type* TextureOverloadCase::resultVectorComponentType(
+sem::Type* TextureOverloadCase::resultVectorComponentType(
ProgramBuilder* b) const {
switch (texture_data_type) {
case ast::intrinsic::test::TextureDataType::kF32:
@@ -159,25 +159,25 @@
case ast::intrinsic::test::TextureKind::kRegular:
return b->Global(
"texture",
- b->create<type::SampledTexture>(texture_dimension, datatype),
+ b->create<sem::SampledTexture>(texture_dimension, datatype),
ast::StorageClass::kUniformConstant, nullptr, decos);
case ast::intrinsic::test::TextureKind::kDepth:
return b->Global("texture",
- b->create<type::DepthTexture>(texture_dimension),
+ b->create<sem::DepthTexture>(texture_dimension),
ast::StorageClass::kUniformConstant, nullptr, decos);
case ast::intrinsic::test::TextureKind::kMultisampled:
return b->Global(
"texture",
- b->create<type::MultisampledTexture>(texture_dimension, datatype),
+ b->create<sem::MultisampledTexture>(texture_dimension, datatype),
ast::StorageClass::kUniformConstant, nullptr, decos);
case ast::intrinsic::test::TextureKind::kStorage: {
- auto* st = b->create<type::StorageTexture>(texture_dimension,
- image_format, datatype);
+ auto* st = b->create<sem::StorageTexture>(texture_dimension, image_format,
+ datatype);
- auto* ac = b->create<type::AccessControl>(access_control, st);
+ auto* ac = b->create<sem::AccessControl>(access_control, st);
return b->Global("texture", ac, ast::StorageClass::kUniformConstant,
nullptr, decos);
}
@@ -193,7 +193,7 @@
b->create<ast::GroupDecoration>(0),
b->create<ast::BindingDecoration>(1),
};
- return b->Global("sampler", b->create<type::Sampler>(sampler_kind),
+ return b->Global("sampler", b->create<sem::Sampler>(sampler_kind),
ast::StorageClass::kUniformConstant, nullptr, decos);
}
@@ -203,8 +203,8 @@
ValidTextureOverload::kDimensions1d,
"textureDimensions(t : texture_1d<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k1d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -213,8 +213,8 @@
ValidTextureOverload::kDimensions2d,
"textureDimensions(t : texture_2d<f32>) -> vec2<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -224,8 +224,8 @@
"textureDimensions(t : texture_2d<f32>,\n"
" level : i32) -> vec2<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -234,8 +234,8 @@
ValidTextureOverload::kDimensions2dArray,
"textureDimensions(t : texture_2d_array<f32>) -> vec2<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -245,8 +245,8 @@
"textureDimensions(t : texture_2d_array<f32>,\n"
" level : i32) -> vec2<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -255,8 +255,8 @@
ValidTextureOverload::kDimensions3d,
"textureDimensions(t : texture_3d<f32>) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -266,8 +266,8 @@
"textureDimensions(t : texture_3d<f32>,\n"
" level : i32) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -276,8 +276,8 @@
ValidTextureOverload::kDimensionsCube,
"textureDimensions(t : texture_cube<f32>) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -287,8 +287,8 @@
"textureDimensions(t : texture_cube<f32>,\n"
" level : i32) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -297,8 +297,8 @@
ValidTextureOverload::kDimensionsCubeArray,
"textureDimensions(t : texture_cube_array<f32>) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -308,8 +308,8 @@
"textureDimensions(t : texture_cube_array<f32>,\n"
" level : i32) -> vec3<i32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -318,8 +318,8 @@
ValidTextureOverload::kDimensionsMultisampled2d,
"textureDimensions(t : texture_multisampled_2d<f32>)-> vec2<i32>",
TextureKind::kMultisampled,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -329,8 +329,8 @@
"textureDimensions(t : texture_multisampled_2d_array<f32>)-> "
"vec2<i32>",
TextureKind::kMultisampled,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -339,8 +339,8 @@
ValidTextureOverload::kDimensionsDepth2d,
"textureDimensions(t : texture_depth_2d) -> vec2<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -350,8 +350,8 @@
"textureDimensions(t : texture_depth_2d,\n"
" level : i32) -> vec2<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -360,8 +360,8 @@
ValidTextureOverload::kDimensionsDepth2dArray,
"textureDimensions(t : texture_depth_2d_array) -> vec2<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -371,8 +371,8 @@
"textureDimensions(t : texture_depth_2d_array,\n"
" level : i32) -> vec2<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -381,8 +381,8 @@
ValidTextureOverload::kDimensionsDepthCube,
"textureDimensions(t : texture_depth_cube) -> vec3<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -392,8 +392,8 @@
"textureDimensions(t : texture_depth_cube,\n"
" level : i32) -> vec3<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -402,8 +402,8 @@
ValidTextureOverload::kDimensionsDepthCubeArray,
"textureDimensions(t : texture_depth_cube_array) -> vec3<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -413,8 +413,8 @@
"textureDimensions(t : texture_depth_cube_array,\n"
" level : i32) -> vec3<i32>",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture", 1); },
@@ -423,8 +423,8 @@
ValidTextureOverload::kDimensionsStorageRO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k1d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -434,8 +434,8 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -445,8 +445,8 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2dArray,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -456,8 +456,8 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k3d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -466,8 +466,8 @@
ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k1d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -477,8 +477,8 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -488,8 +488,8 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2dArray,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -499,8 +499,8 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k3d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -509,8 +509,8 @@
ValidTextureOverload::kNumLayers2dArray,
"textureNumLayers(t : texture_2d_array<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -519,8 +519,8 @@
ValidTextureOverload::kNumLayersCubeArray,
"textureNumLayers(t : texture_cube_array<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -529,8 +529,8 @@
ValidTextureOverload::kNumLayersMultisampled2dArray,
"textureNumLayers(t : texture_multisampled_2d_array<f32>) -> i32",
TextureKind::kMultisampled,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -539,8 +539,8 @@
ValidTextureOverload::kNumLayersDepth2dArray,
"textureNumLayers(t : texture_depth_2d_array) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -549,8 +549,8 @@
ValidTextureOverload::kNumLayersDepthCubeArray,
"textureNumLayers(t : texture_depth_cube_array) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -559,8 +559,8 @@
ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2dArray,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -569,8 +569,8 @@
ValidTextureOverload::kNumLevels2d,
"textureNumLevels(t : texture_2d<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -579,8 +579,8 @@
ValidTextureOverload::kNumLevels2dArray,
"textureNumLevels(t : texture_2d_array<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -589,8 +589,8 @@
ValidTextureOverload::kNumLevels3d,
"textureNumLevels(t : texture_3d<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -599,8 +599,8 @@
ValidTextureOverload::kNumLevelsCube,
"textureNumLevels(t : texture_cube<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -609,8 +609,8 @@
ValidTextureOverload::kNumLevelsCubeArray,
"textureNumLevels(t : texture_cube_array<f32>) -> i32",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -619,8 +619,8 @@
ValidTextureOverload::kNumLevelsDepth2d,
"textureNumLevels(t : texture_depth_2d) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -629,8 +629,8 @@
ValidTextureOverload::kNumLevelsDepth2dArray,
"textureNumLevels(t : texture_depth_2d_array) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -639,8 +639,8 @@
ValidTextureOverload::kNumLevelsDepthCube,
"textureNumLevels(t : texture_depth_cube) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -649,8 +649,8 @@
ValidTextureOverload::kNumLevelsDepthCubeArray,
"textureNumLevels(t : texture_depth_cube_array) -> i32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLevels",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -659,8 +659,8 @@
ValidTextureOverload::kNumSamplesMultisampled2d,
"textureNumSamples(t : texture_multisampled_2d<f32>) -> i32",
TextureKind::kMultisampled,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureNumSamples",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -669,8 +669,8 @@
ValidTextureOverload::kNumSamplesMultisampled2dArray,
"textureNumSamples(t : texture_multisampled_2d_array<f32>) -> i32",
TextureKind::kMultisampled,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumSamples",
[](ProgramBuilder* b) { return b->ExprList("texture"); },
@@ -681,8 +681,8 @@
" s : sampler,\n"
" coords : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k1d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -697,8 +697,8 @@
" s : sampler,\n"
" coords : vec2<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -714,8 +714,8 @@
" coords : vec2<f32>\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -732,8 +732,8 @@
" coords : vec2<f32>,\n"
" array_index : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -751,8 +751,8 @@
" array_index : i32\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -769,8 +769,8 @@
" s : sampler,\n"
" coords : vec3<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -786,8 +786,8 @@
" coords : vec3<f32>\n"
" offset : vec3<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -803,8 +803,8 @@
" s : sampler,\n"
" coords : vec3<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -820,8 +820,8 @@
" coords : vec3<f32>,\n"
" array_index : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -837,8 +837,8 @@
" s : sampler,\n"
" coords : vec2<f32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -854,8 +854,8 @@
" coords : vec2<f32>\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -872,8 +872,8 @@
" coords : vec2<f32>,\n"
" array_index : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -891,8 +891,8 @@
" array_index : i32\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -909,8 +909,8 @@
" s : sampler,\n"
" coords : vec3<f32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -926,8 +926,8 @@
" coords : vec3<f32>,\n"
" array_index : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSample",
[](ProgramBuilder* b) {
@@ -944,8 +944,8 @@
" coords : vec2<f32>,\n"
" bias : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -963,8 +963,8 @@
" bias : f32,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -983,8 +983,8 @@
" array_index : i32,\n"
" bias : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1004,8 +1004,8 @@
" bias : f32,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1024,8 +1024,8 @@
" coords : vec3<f32>,\n"
" bias : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1043,8 +1043,8 @@
" bias : f32,\n"
" offset : vec3<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1062,8 +1062,8 @@
" coords : vec3<f32>,\n"
" bias : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1081,8 +1081,8 @@
" array_index : i32,\n"
" bias : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSampleBias",
[](ProgramBuilder* b) {
@@ -1100,8 +1100,8 @@
" coords : vec2<f32>,\n"
" level : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1119,8 +1119,8 @@
" level : f32,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1139,8 +1139,8 @@
" array_index : i32,\n"
" level : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1160,8 +1160,8 @@
" level : f32,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1180,8 +1180,8 @@
" coords : vec3<f32>,\n"
" level : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1199,8 +1199,8 @@
" level : f32,\n"
" offset : vec3<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1218,8 +1218,8 @@
" coords : vec3<f32>,\n"
" level : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1237,8 +1237,8 @@
" array_index : i32,\n"
" level : f32) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1256,8 +1256,8 @@
" coords : vec2<f32>,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1275,8 +1275,8 @@
" level : i32,\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1295,8 +1295,8 @@
" array_index : i32,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1316,8 +1316,8 @@
" level : i32,\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1336,8 +1336,8 @@
" coords : vec3<f32>,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1355,8 +1355,8 @@
" array_index : i32,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSampleLevel",
[](ProgramBuilder* b) {
@@ -1375,8 +1375,8 @@
" ddx : vec2<f32>,\n"
" ddy : vec2<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1396,8 +1396,8 @@
" ddy : vec2<f32>,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1418,8 +1418,8 @@
" ddx : vec2<f32>,\n"
" ddy : vec2<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1441,8 +1441,8 @@
" ddy : vec2<f32>,\n"
" offset : vec2<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1463,8 +1463,8 @@
" ddx : vec3<f32>,\n"
" ddy : vec3<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1484,8 +1484,8 @@
" ddy : vec3<f32>,\n"
" offset : vec3<i32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::k3d,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1505,8 +1505,8 @@
" ddx : vec3<f32>,\n"
" ddy : vec3<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1526,8 +1526,8 @@
" ddx : vec3<f32>,\n"
" ddy : vec3<f32>) -> vec4<f32>",
TextureKind::kRegular,
- type::SamplerKind::kSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
@@ -1546,8 +1546,8 @@
" coords : vec2<f32>,\n"
" depth_ref : f32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1565,8 +1565,8 @@
" depth_ref : f32,\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::k2d,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1585,8 +1585,8 @@
" array_index : i32,\n"
" depth_ref : f32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1606,8 +1606,8 @@
" depth_ref : f32,\n"
" offset : vec2<i32>) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::k2dArray,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1626,8 +1626,8 @@
" coords : vec3<f32>,\n"
" depth_ref : f32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::kCube,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::kCube,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1645,8 +1645,8 @@
" array_index : i32,\n"
" depth_ref : f32) -> f32",
TextureKind::kDepth,
- type::SamplerKind::kComparisonSampler,
- type::TextureDimension::kCubeArray,
+ sem::SamplerKind::kComparisonSampler,
+ sem::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureSampleCompare",
[](ProgramBuilder* b) {
@@ -1663,7 +1663,7 @@
" coords : i32,\n"
" level : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1678,7 +1678,7 @@
" coords : i32,\n"
" level : i32) -> vec4<u32>",
TextureKind::kRegular,
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1693,7 +1693,7 @@
" coords : i32,\n"
" level : i32) -> vec4<i32>",
TextureKind::kRegular,
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1708,7 +1708,7 @@
" coords : vec2<i32>,\n"
" level : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1723,7 +1723,7 @@
" coords : vec2<i32>,\n"
" level : i32) -> vec4<u32>",
TextureKind::kRegular,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1738,7 +1738,7 @@
" coords : vec2<i32>,\n"
" level : i32) -> vec4<i32>",
TextureKind::kRegular,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1754,7 +1754,7 @@
" array_index : i32,\n"
" level : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1771,7 +1771,7 @@
" array_index : i32,\n"
" level : i32) -> vec4<u32>",
TextureKind::kRegular,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1788,7 +1788,7 @@
" array_index : i32,\n"
" level : i32) -> vec4<i32>",
TextureKind::kRegular,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1804,7 +1804,7 @@
" coords : vec3<i32>,\n"
" level : i32) -> vec4<f32>",
TextureKind::kRegular,
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1819,7 +1819,7 @@
" coords : vec3<i32>,\n"
" level : i32) -> vec4<u32>",
TextureKind::kRegular,
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1834,7 +1834,7 @@
" coords : vec3<i32>,\n"
" level : i32) -> vec4<i32>",
TextureKind::kRegular,
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1849,7 +1849,7 @@
" coords : vec2<i32>,\n"
" sample_index : i32) -> vec4<f32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1864,7 +1864,7 @@
" coords : vec2<i32>,\n"
" sample_index : i32) -> vec4<u32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1879,7 +1879,7 @@
" coords : vec2<i32>,\n"
" sample_index : i32) -> vec4<i32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1895,7 +1895,7 @@
" array_index : i32,\n"
" sample_index : i32) -> vec4<f32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1912,7 +1912,7 @@
" array_index : i32,\n"
" sample_index : i32) -> vec4<u32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1929,7 +1929,7 @@
" array_index : i32,\n"
" sample_index : i32) -> vec4<i32>",
TextureKind::kMultisampled,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1945,7 +1945,7 @@
" coords : vec2<i32>,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1961,7 +1961,7 @@
" array_index : i32,\n"
" level : i32) -> f32",
TextureKind::kDepth,
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1976,8 +1976,8 @@
"textureLoad(t : texture_storage_1d<rgba32float>,\n"
" coords : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k1d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -1990,8 +1990,8 @@
"textureLoad(t : texture_storage_2d<rgba8unorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba8Unorm,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba8Unorm,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2004,8 +2004,8 @@
"textureLoad(t : texture_storage_2d<rgba8snorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba8Snorm,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba8Snorm,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2018,8 +2018,8 @@
"textureLoad(t : texture_storage_2d<rgba8uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba8Uint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba8Uint,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2032,8 +2032,8 @@
"textureLoad(t : texture_storage_2d<rgba8sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba8Sint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba8Sint,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2046,8 +2046,8 @@
"textureLoad(t : texture_storage_2d<rgba16uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba16Uint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba16Uint,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2060,8 +2060,8 @@
"textureLoad(t : texture_storage_2d<rgba16sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba16Sint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba16Sint,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2074,8 +2074,8 @@
"textureLoad(t : texture_storage_2d<rgba16float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba16Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba16Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2088,8 +2088,8 @@
"textureLoad(t : texture_storage_2d<r32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kR32Uint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kR32Uint,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2102,8 +2102,8 @@
"textureLoad(t : texture_storage_2d<r32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kR32Sint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kR32Sint,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2116,8 +2116,8 @@
"textureLoad(t : texture_storage_2d<r32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kR32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kR32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2130,8 +2130,8 @@
"textureLoad(t : texture_storage_2d<rg32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRg32Uint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRg32Uint,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2144,8 +2144,8 @@
"textureLoad(t : texture_storage_2d<rg32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRg32Sint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRg32Sint,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2158,8 +2158,8 @@
"textureLoad(t : texture_storage_2d<rg32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRg32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRg32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2172,8 +2172,8 @@
"textureLoad(t : texture_storage_2d<rgba32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Uint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Uint,
+ sem::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2186,8 +2186,8 @@
"textureLoad(t : texture_storage_2d<rgba32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Sint,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Sint,
+ sem::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2200,8 +2200,8 @@
"textureLoad(t : texture_storage_2d<rgba32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2216,8 +2216,8 @@
" coords : vec2<i32>,\n"
" array_index : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2dArray,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2231,8 +2231,8 @@
"textureLoad(t : texture_storage_3d<rgba32float>,\n"
" coords : vec3<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k3d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureLoad",
[](ProgramBuilder* b) {
@@ -2246,8 +2246,8 @@
" coords : i32,\n"
" value : vec4<T>)",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k1d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k1d,
TextureDataType::kF32,
"textureStore",
[](ProgramBuilder* b) {
@@ -2262,8 +2262,8 @@
" coords : vec2<i32>,\n"
" value : vec4<T>)",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2d,
TextureDataType::kF32,
"textureStore",
[](ProgramBuilder* b) {
@@ -2279,8 +2279,8 @@
" array_index : i32,\n"
" value : vec4<T>)",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k2dArray,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureStore",
[](ProgramBuilder* b) {
@@ -2296,8 +2296,8 @@
" coords : vec3<i32>,\n"
" value : vec4<T>)",
ast::AccessControl::kWriteOnly,
- type::ImageFormat::kRgba32Float,
- type::TextureDimension::k3d,
+ sem::ImageFormat::kRgba32Float,
+ sem::TextureDimension::k3d,
TextureDataType::kF32,
"textureStore",
[](ProgramBuilder* b) {
diff --git a/src/ast/intrinsic_texture_helper_test.h b/src/ast/intrinsic_texture_helper_test.h
index 521d2c9..4ff154e 100644
--- a/src/ast/intrinsic_texture_helper_test.h
+++ b/src/ast/intrinsic_texture_helper_test.h
@@ -182,8 +182,8 @@
TextureOverloadCase(ValidTextureOverload,
const char*,
TextureKind,
- type::SamplerKind,
- type::TextureDimension,
+ sem::SamplerKind,
+ sem::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@@ -191,7 +191,7 @@
TextureOverloadCase(ValidTextureOverload,
const char*,
TextureKind,
- type::TextureDimension,
+ sem::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@@ -199,8 +199,8 @@
TextureOverloadCase(ValidTextureOverload,
const char*,
AccessControl,
- type::ImageFormat,
- type::TextureDimension,
+ sem::ImageFormat,
+ sem::TextureDimension,
TextureDataType,
const char*,
std::function<ExpressionList(ProgramBuilder*)>);
@@ -215,7 +215,7 @@
/// @param builder the AST builder used for the test
/// @returns the vector component type of the texture function return value
- type::Type* resultVectorComponentType(ProgramBuilder* builder) const;
+ sem::Type* resultVectorComponentType(ProgramBuilder* builder) const;
/// @param builder the AST builder used for the test
/// @returns a variable holding the test texture, automatically registered as
/// a global variable.
@@ -233,15 +233,15 @@
TextureKind const texture_kind;
/// The sampler kind for the sampler parameter
/// Used only when texture_kind is not kStorage
- type::SamplerKind const sampler_kind = type::SamplerKind::kSampler;
+ sem::SamplerKind const sampler_kind = sem::SamplerKind::kSampler;
/// The access control for the storage texture
/// Used only when texture_kind is kStorage
AccessControl const access_control = AccessControl::kReadWrite;
/// The image format for the storage texture
/// Used only when texture_kind is kStorage
- type::ImageFormat const image_format = type::ImageFormat::kNone;
+ sem::ImageFormat const image_format = sem::ImageFormat::kNone;
/// The dimensions of the texture parameter
- type::TextureDimension const texture_dimension;
+ sem::TextureDimension const texture_dimension;
/// The data type of the texture parameter
TextureDataType const texture_data_type;
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc
diff --git a/src/ast/literal.cc b/src/ast/literal.cc
index 457ca6b..bea8d6c 100644
--- a/src/ast/literal.cc
+++ b/src/ast/literal.cc
@@ -19,7 +19,7 @@
namespace tint {
namespace ast {
-Literal::Literal(ProgramID program_id, const Source& source, type::Type* type)
+Literal::Literal(ProgramID program_id, const Source& source, sem::Type* type)
: Base(program_id, source), type_(type) {}
Literal::~Literal() = default;
diff --git a/src/ast/literal.h b/src/ast/literal.h
index 39b826c..6ea656b 100644
--- a/src/ast/literal.h
+++ b/src/ast/literal.h
@@ -28,7 +28,7 @@
~Literal() override;
/// @returns the type of the literal
- type::Type* type() const { return type_; }
+ sem::Type* type() const { return type_; }
/// Writes a representation of the node to the output stream
/// @param sem the semantic info for the program
@@ -50,12 +50,10 @@
/// @param program_id the identifier of the program that owns this node
/// @param source the input source
/// @param type the type of the literal
- explicit Literal(ProgramID program_id,
- const Source& source,
- type::Type* type);
+ explicit Literal(ProgramID program_id, const Source& source, sem::Type* type);
private:
- type::Type* const type_;
+ sem::Type* const type_;
};
} // namespace ast
diff --git a/src/ast/module.cc b/src/ast/module.cc
index c26e6ed..31ac2f3 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -35,7 +35,7 @@
continue;
}
- if (auto* ty = decl->As<type::Type>()) {
+ if (auto* ty = decl->As<sem::Type>()) {
constructed_types_.push_back(ty);
} else if (auto* func = decl->As<Function>()) {
functions_.push_back(func);
@@ -62,7 +62,7 @@
TINT_ICE(ctx->dst->Diagnostics()) << "src global declaration was nullptr";
continue;
}
- if (auto* ty = decl->As<type::Type>()) {
+ if (auto* ty = decl->As<sem::Type>()) {
AddConstructedType(ty);
} else if (auto* func = decl->As<Function>()) {
AddFunction(func);
@@ -82,13 +82,13 @@
indent += 2;
for (auto* const ty : constructed_types_) {
make_indent(out, indent);
- if (auto* alias = ty->As<type::Alias>()) {
+ if (auto* alias = ty->As<sem::Alias>()) {
out << alias->symbol().to_str() << " -> " << alias->type()->type_name()
<< std::endl;
- if (auto* str = alias->type()->As<type::StructType>()) {
+ if (auto* str = alias->type()->As<sem::StructType>()) {
str->impl()->to_str(sem, out, indent);
}
- } else if (auto* str = ty->As<type::StructType>()) {
+ } else if (auto* str = ty->As<sem::StructType>()) {
out << str->symbol().to_str() << " ";
str->impl()->to_str(sem, out, indent);
}
diff --git a/src/ast/module.h b/src/ast/module.h
index b2b7673..fe319bc 100644
--- a/src/ast/module.h
+++ b/src/ast/module.h
@@ -67,14 +67,14 @@
/// Adds a constructed type to the Builder.
/// The type must be an alias or a struct.
/// @param type the constructed type to add
- void AddConstructedType(type::Type* type) {
+ void AddConstructedType(sem::Type* type) {
TINT_ASSERT(type);
constructed_types_.push_back(type);
global_declarations_.push_back(type);
}
/// @returns the constructed types in the translation unit
- const std::vector<type::Type*>& ConstructedTypes() const {
+ const std::vector<sem::Type*>& ConstructedTypes() const {
return constructed_types_;
}
@@ -115,7 +115,7 @@
private:
std::vector<Cloneable*> global_declarations_;
- std::vector<type::Type*> constructed_types_;
+ std::vector<sem::Type*> constructed_types_;
FunctionList functions_;
VariableList global_variables_;
};
diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc
index d89f9d9..6f39c42 100644
--- a/src/ast/module_clone_test.cc
+++ b/src/ast/module_clone_test.cc
@@ -128,7 +128,7 @@
for (auto* src_node : src.ASTNodes().Objects()) {
src_nodes.emplace(src_node);
}
- std::unordered_set<type::Type*> src_types;
+ std::unordered_set<sem::Type*> src_types;
for (auto* src_type : src.Types()) {
src_types.emplace(src_type);
}
diff --git a/src/ast/node.h b/src/ast/node.h
index 18eee89..24320bb 100644
--- a/src/ast/node.h
+++ b/src/ast/node.h
@@ -24,7 +24,7 @@
// Forward declarations
class CloneContext;
-namespace type {
+namespace sem {
class Type;
}
namespace sem {
diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc
index 8fc435f..7d3c151 100644
--- a/src/ast/sint_literal.cc
+++ b/src/ast/sint_literal.cc
@@ -23,7 +23,7 @@
SintLiteral::SintLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
int32_t value)
: Base(program_id, source, type, static_cast<uint32_t>(value)) {}
diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h
index ddc2ac8..e215382 100644
--- a/src/ast/sint_literal.h
+++ b/src/ast/sint_literal.h
@@ -32,7 +32,7 @@
/// @param value the signed int literals value
SintLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
int32_t value);
~SintLiteral() override;
diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc
index cfd7ec6..da4121b 100644
--- a/src/ast/sint_literal_test.cc
+++ b/src/ast/sint_literal_test.cc
@@ -45,7 +45,7 @@
}
TEST_F(SintLiteralTest, Name_U32) {
- type::U32 u32;
+ sem::U32 u32;
auto* i = create<SintLiteral>(&u32, 2);
EXPECT_EQ("__sint__u32_2", i->name());
}
diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc
index 68c9340..d9b895c 100644
--- a/src/ast/struct_member.cc
+++ b/src/ast/struct_member.cc
@@ -24,7 +24,7 @@
StructMember::StructMember(ProgramID program_id,
const Source& source,
const Symbol& sym,
- type::Type* type,
+ sem::Type* type,
DecorationList decorations)
: Base(program_id, source),
symbol_(sym),
diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h
index afb0e6b..246aa2f 100644
--- a/src/ast/struct_member.h
+++ b/src/ast/struct_member.h
@@ -35,7 +35,7 @@
StructMember(ProgramID program_id,
const Source& source,
const Symbol& sym,
- type::Type* type,
+ sem::Type* type,
DecorationList decorations);
/// Move constructor
StructMember(StructMember&&);
@@ -45,7 +45,7 @@
/// @returns the symbol
const Symbol& symbol() const { return symbol_; }
/// @returns the type
- type::Type* type() const { return type_; }
+ sem::Type* type() const { return type_; }
/// @returns the decorations
const DecorationList& decorations() const { return decorations_; }
@@ -73,7 +73,7 @@
StructMember(const StructMember&) = delete;
Symbol const symbol_;
- type::Type* const type_;
+ sem::Type* const type_;
DecorationList const decorations_;
};
diff --git a/src/ast/type_constructor_expression.cc b/src/ast/type_constructor_expression.cc
index 2b4a940..1b2c3d1 100644
--- a/src/ast/type_constructor_expression.cc
+++ b/src/ast/type_constructor_expression.cc
@@ -23,7 +23,7 @@
TypeConstructorExpression::TypeConstructorExpression(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
ExpressionList values)
: Base(program_id, source), type_(type), values_(std::move(values)) {
TINT_ASSERT(type_);
diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h
index 8052121..8270865 100644
--- a/src/ast/type_constructor_expression.h
+++ b/src/ast/type_constructor_expression.h
@@ -33,14 +33,14 @@
/// @param values the constructor values
TypeConstructorExpression(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
ExpressionList values);
/// Move constructor
TypeConstructorExpression(TypeConstructorExpression&&);
~TypeConstructorExpression() override;
/// @returns the type
- type::Type* type() const { return type_; }
+ sem::Type* type() const { return type_; }
/// @returns the values
const ExpressionList& values() const { return values_; }
@@ -61,7 +61,7 @@
private:
TypeConstructorExpression(const TypeConstructorExpression&) = delete;
- type::Type* const type_;
+ sem::Type* const type_;
ExpressionList const values_;
};
diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc
index 335385f..e9e8ace 100644
--- a/src/ast/type_constructor_expression_test.cc
+++ b/src/ast/type_constructor_expression_test.cc
@@ -81,7 +81,7 @@
}
TEST_F(TypeConstructorExpressionTest, ToStr) {
- type::Vector vec(ty.f32(), 3);
+ sem::Vector vec(ty.f32(), 3);
ExpressionList expr;
expr.push_back(Expr("expr_1"));
expr.push_back(Expr("expr_2"));
diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc
index 1616c50..a65a36b 100644
--- a/src/ast/uint_literal.cc
+++ b/src/ast/uint_literal.cc
@@ -23,7 +23,7 @@
UintLiteral::UintLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
uint32_t value)
: Base(program_id, source, type, value) {}
diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h
index 557be53..0b12775 100644
--- a/src/ast/uint_literal.h
+++ b/src/ast/uint_literal.h
@@ -32,7 +32,7 @@
/// @param value the uint literals value
UintLiteral(ProgramID program_id,
const Source& source,
- type::Type* type,
+ sem::Type* type,
uint32_t value);
~UintLiteral() override;
diff --git a/src/ast/variable.cc b/src/ast/variable.cc
index 3e5f7f8..1371ce4 100644
--- a/src/ast/variable.cc
+++ b/src/ast/variable.cc
@@ -27,7 +27,7 @@
const Source& source,
const Symbol& sym,
StorageClass declared_storage_class,
- type::Type* declared_type,
+ sem::Type* declared_type,
bool is_const,
Expression* constructor,
DecorationList decorations)
diff --git a/src/ast/variable.h b/src/ast/variable.h
index ab88e3a..9094f9e 100644
--- a/src/ast/variable.h
+++ b/src/ast/variable.h
@@ -103,7 +103,7 @@
const Source& source,
const Symbol& sym,
StorageClass declared_storage_class,
- type::Type* declared_type,
+ sem::Type* declared_type,
bool is_const,
Expression* constructor,
DecorationList decorations);
@@ -116,7 +116,7 @@
const Symbol& symbol() const { return symbol_; }
/// @returns the declared type
- type::Type* declared_type() const { return declared_type_; }
+ sem::Type* declared_type() const { return declared_type_; }
/// @returns the declared storage class
StorageClass declared_storage_class() const {
@@ -175,7 +175,7 @@
Symbol const symbol_;
// The value type if a const or formal paramter, and the store type if a var
- type::Type* const declared_type_;
+ sem::Type* const declared_type_;
bool const is_const_;
Expression* const constructor_;
DecorationList const decorations_;
diff --git a/src/clone_context.h b/src/clone_context.h
index 16f8fa1..ec562f3 100644
--- a/src/clone_context.h
+++ b/src/clone_context.h
@@ -84,7 +84,7 @@
/// Destructor
~CloneContext();
- /// Clones the Node or type::Type `a` into the ProgramBuilder #dst if `a` is
+ /// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is
/// not null. If `a` is null, then Clone() returns null. If `a` has been
/// cloned already by this CloneContext then the same cloned pointer is
/// returned.
@@ -92,9 +92,9 @@
/// Clone() may use a function registered with ReplaceAll() to create a
/// transformed version of the object. See ReplaceAll() for more information.
///
- /// The Node or type::Type `a` must be owned by the Program #src.
+ /// The Node or sem::Type `a` must be owned by the Program #src.
///
- /// @param a the `Node` or `type::Type` to clone
+ /// @param a the `Node` or `sem::Type` to clone
/// @return the cloned node
template <typename T>
T* Clone(T* a) {
@@ -144,7 +144,7 @@
return out;
}
- /// Clones the Node or type::Type `a` into the ProgramBuilder #dst if `a` is
+ /// Clones the Node or sem::Type `a` into the ProgramBuilder #dst if `a` is
/// not null. If `a` is null, then Clone() returns null. If `a` has been
/// cloned already by this CloneContext then the same cloned pointer is
/// returned.
@@ -152,9 +152,9 @@
/// Unlike Clone(), this method does not invoke or use any transformations
/// registered by ReplaceAll().
///
- /// The Node or type::Type `a` must be owned by the Program #src.
+ /// The Node or sem::Type `a` must be owned by the Program #src.
///
- /// @param a the `Node` or `type::Type` to clone
+ /// @param a the `Node` or `sem::Type` to clone
/// @return the cloned node
template <typename T>
T* CloneWithoutTransform(T* a) {
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index c9ca62d..34983cd 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -57,44 +57,44 @@
ResourceBinding::TextureDimension
TypeTextureDimensionToResourceBindingTextureDimension(
- const type::TextureDimension& type_dim) {
+ const sem::TextureDimension& type_dim) {
switch (type_dim) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
return ResourceBinding::TextureDimension::k1d;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
return ResourceBinding::TextureDimension::k2d;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
return ResourceBinding::TextureDimension::k2dArray;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
return ResourceBinding::TextureDimension::k3d;
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
return ResourceBinding::TextureDimension::kCube;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
return ResourceBinding::TextureDimension::kCubeArray;
- case type::TextureDimension::kNone:
+ case sem::TextureDimension::kNone:
return ResourceBinding::TextureDimension::kNone;
}
return ResourceBinding::TextureDimension::kNone;
}
-ResourceBinding::SampledKind BaseTypeToSampledKind(type::Type* base_type) {
+ResourceBinding::SampledKind BaseTypeToSampledKind(sem::Type* base_type) {
if (!base_type) {
return ResourceBinding::SampledKind::kUnknown;
}
- if (auto* at = base_type->As<type::ArrayType>()) {
+ if (auto* at = base_type->As<sem::ArrayType>()) {
base_type = at->type();
- } else if (auto* mt = base_type->As<type::Matrix>()) {
+ } else if (auto* mt = base_type->As<sem::Matrix>()) {
base_type = mt->type();
- } else if (auto* vt = base_type->As<type::Vector>()) {
+ } else if (auto* vt = base_type->As<sem::Vector>()) {
base_type = vt->type();
}
- if (base_type->Is<type::F32>()) {
+ if (base_type->Is<sem::F32>()) {
return ResourceBinding::SampledKind::kFloat;
- } else if (base_type->Is<type::U32>()) {
+ } else if (base_type->Is<sem::U32>()) {
return ResourceBinding::SampledKind::kUInt;
- } else if (base_type->Is<type::I32>()) {
+ } else if (base_type->Is<sem::I32>()) {
return ResourceBinding::SampledKind::kSInt;
} else {
return ResourceBinding::SampledKind::kUnknown;
@@ -102,79 +102,79 @@
}
ResourceBinding::ImageFormat TypeImageFormatToResourceBindingImageFormat(
- const type::ImageFormat& image_format) {
+ const sem::ImageFormat& image_format) {
switch (image_format) {
- case type::ImageFormat::kR8Unorm:
+ case sem::ImageFormat::kR8Unorm:
return ResourceBinding::ImageFormat::kR8Unorm;
- case type::ImageFormat::kR8Snorm:
+ case sem::ImageFormat::kR8Snorm:
return ResourceBinding::ImageFormat::kR8Snorm;
- case type::ImageFormat::kR8Uint:
+ case sem::ImageFormat::kR8Uint:
return ResourceBinding::ImageFormat::kR8Uint;
- case type::ImageFormat::kR8Sint:
+ case sem::ImageFormat::kR8Sint:
return ResourceBinding::ImageFormat::kR8Sint;
- case type::ImageFormat::kR16Uint:
+ case sem::ImageFormat::kR16Uint:
return ResourceBinding::ImageFormat::kR16Uint;
- case type::ImageFormat::kR16Sint:
+ case sem::ImageFormat::kR16Sint:
return ResourceBinding::ImageFormat::kR16Sint;
- case type::ImageFormat::kR16Float:
+ case sem::ImageFormat::kR16Float:
return ResourceBinding::ImageFormat::kR16Float;
- case type::ImageFormat::kRg8Unorm:
+ case sem::ImageFormat::kRg8Unorm:
return ResourceBinding::ImageFormat::kRg8Unorm;
- case type::ImageFormat::kRg8Snorm:
+ case sem::ImageFormat::kRg8Snorm:
return ResourceBinding::ImageFormat::kRg8Snorm;
- case type::ImageFormat::kRg8Uint:
+ case sem::ImageFormat::kRg8Uint:
return ResourceBinding::ImageFormat::kRg8Uint;
- case type::ImageFormat::kRg8Sint:
+ case sem::ImageFormat::kRg8Sint:
return ResourceBinding::ImageFormat::kRg8Sint;
- case type::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kR32Uint:
return ResourceBinding::ImageFormat::kR32Uint;
- case type::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kR32Sint:
return ResourceBinding::ImageFormat::kR32Sint;
- case type::ImageFormat::kR32Float:
+ case sem::ImageFormat::kR32Float:
return ResourceBinding::ImageFormat::kR32Float;
- case type::ImageFormat::kRg16Uint:
+ case sem::ImageFormat::kRg16Uint:
return ResourceBinding::ImageFormat::kRg16Uint;
- case type::ImageFormat::kRg16Sint:
+ case sem::ImageFormat::kRg16Sint:
return ResourceBinding::ImageFormat::kRg16Sint;
- case type::ImageFormat::kRg16Float:
+ case sem::ImageFormat::kRg16Float:
return ResourceBinding::ImageFormat::kRg16Float;
- case type::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8Unorm:
return ResourceBinding::ImageFormat::kRgba8Unorm;
- case type::ImageFormat::kRgba8UnormSrgb:
+ case sem::ImageFormat::kRgba8UnormSrgb:
return ResourceBinding::ImageFormat::kRgba8UnormSrgb;
- case type::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kRgba8Snorm:
return ResourceBinding::ImageFormat::kRgba8Snorm;
- case type::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRgba8Uint:
return ResourceBinding::ImageFormat::kRgba8Uint;
- case type::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRgba8Sint:
return ResourceBinding::ImageFormat::kRgba8Sint;
- case type::ImageFormat::kBgra8Unorm:
+ case sem::ImageFormat::kBgra8Unorm:
return ResourceBinding::ImageFormat::kBgra8Unorm;
- case type::ImageFormat::kBgra8UnormSrgb:
+ case sem::ImageFormat::kBgra8UnormSrgb:
return ResourceBinding::ImageFormat::kBgra8UnormSrgb;
- case type::ImageFormat::kRgb10A2Unorm:
+ case sem::ImageFormat::kRgb10A2Unorm:
return ResourceBinding::ImageFormat::kRgb10A2Unorm;
- case type::ImageFormat::kRg11B10Float:
+ case sem::ImageFormat::kRg11B10Float:
return ResourceBinding::ImageFormat::kRg11B10Float;
- case type::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRg32Uint:
return ResourceBinding::ImageFormat::kRg32Uint;
- case type::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRg32Sint:
return ResourceBinding::ImageFormat::kRg32Sint;
- case type::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRg32Float:
return ResourceBinding::ImageFormat::kRg32Float;
- case type::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kRgba16Uint:
return ResourceBinding::ImageFormat::kRgba16Uint;
- case type::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kRgba16Sint:
return ResourceBinding::ImageFormat::kRgba16Sint;
- case type::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kRgba16Float:
return ResourceBinding::ImageFormat::kRgba16Float;
- case type::ImageFormat::kRgba32Uint:
+ case sem::ImageFormat::kRgba32Uint:
return ResourceBinding::ImageFormat::kRgba32Uint;
- case type::ImageFormat::kRgba32Sint:
+ case sem::ImageFormat::kRgba32Sint:
return ResourceBinding::ImageFormat::kRgba32Sint;
- case type::ImageFormat::kRgba32Float:
+ case sem::ImageFormat::kRgba32Float:
return ResourceBinding::ImageFormat::kRgba32Float;
- case type::ImageFormat::kNone:
+ case sem::ImageFormat::kNone:
return ResourceBinding::ImageFormat::kNone;
}
return ResourceBinding::ImageFormat::kNone;
@@ -207,7 +207,7 @@
entry_point.input_variables);
}
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
AddEntryPointInOutVariables("<retval>", func->return_type(),
func->return_type_decorations(),
entry_point.output_variables);
@@ -386,7 +386,7 @@
auto binding_info = ruv.second;
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
- auto* str = unwrapped_type->As<type::StructType>();
+ auto* str = unwrapped_type->As<sem::StructType>();
if (str == nullptr) {
continue;
}
@@ -514,7 +514,7 @@
entry.bind_group = binding_info.group->value();
entry.binding = binding_info.binding->value();
- auto* texture_type = var->Type()->UnwrapIfNeeded()->As<type::Texture>();
+ auto* texture_type = var->Type()->UnwrapIfNeeded()->As<sem::Texture>();
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
texture_type->dim());
@@ -541,7 +541,7 @@
void Inspector::AddEntryPointInOutVariables(
std::string name,
- type::Type* type,
+ sem::Type* type,
const ast::DecorationList& decorations,
std::vector<StageVariable>& variables) const {
// Skip builtins.
@@ -551,7 +551,7 @@
auto* unwrapped_type = type->UnwrapAll();
- if (auto* struct_ty = unwrapped_type->As<type::StructType>()) {
+ if (auto* struct_ty = unwrapped_type->As<sem::StructType>()) {
// Recurse into members.
for (auto* member : struct_ty->impl()->members()) {
AddEntryPointInOutVariables(
@@ -597,7 +597,7 @@
auto* var = rsv.first;
auto binding_info = rsv.second;
- auto* ac_type = var->Type()->As<type::AccessControl>();
+ auto* ac_type = var->Type()->As<sem::AccessControl>();
if (ac_type == nullptr) {
continue;
}
@@ -606,7 +606,7 @@
continue;
}
- auto* str = var->Type()->UnwrapIfNeeded()->As<type::StructType>();
+ auto* str = var->Type()->UnwrapIfNeeded()->As<sem::StructType>();
if (!str) {
continue;
}
@@ -657,18 +657,18 @@
entry.bind_group = binding_info.group->value();
entry.binding = binding_info.binding->value();
- auto* texture_type = var->Type()->UnwrapIfNeeded()->As<type::Texture>();
+ auto* texture_type = var->Type()->UnwrapIfNeeded()->As<sem::Texture>();
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
texture_type->dim());
- type::Type* base_type = nullptr;
+ sem::Type* base_type = nullptr;
if (multisampled_only) {
- base_type = texture_type->As<type::MultisampledTexture>()
+ base_type = texture_type->As<sem::MultisampledTexture>()
->type()
->UnwrapIfNeeded();
} else {
base_type =
- texture_type->As<type::SampledTexture>()->type()->UnwrapIfNeeded();
+ texture_type->As<sem::SampledTexture>()->type()->UnwrapIfNeeded();
}
entry.sampled_kind = BaseTypeToSampledKind(base_type);
@@ -692,7 +692,7 @@
auto* var = ref.first;
auto binding_info = ref.second;
- auto* ac_type = var->Type()->As<type::AccessControl>();
+ auto* ac_type = var->Type()->As<sem::AccessControl>();
if (ac_type == nullptr) {
continue;
}
@@ -709,11 +709,11 @@
entry.binding = binding_info.binding->value();
auto* texture_type =
- var->Type()->UnwrapIfNeeded()->As<type::StorageTexture>();
+ var->Type()->UnwrapIfNeeded()->As<sem::StorageTexture>();
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
texture_type->dim());
- type::Type* base_type = texture_type->type()->UnwrapIfNeeded();
+ sem::Type* base_type = texture_type->type()->UnwrapIfNeeded();
entry.sampled_kind = BaseTypeToSampledKind(base_type);
entry.image_format = TypeImageFormatToResourceBindingImageFormat(
texture_type->image_format());
diff --git a/src/inspector/inspector.h b/src/inspector/inspector.h
index 7258b7b..34723dd 100644
--- a/src/inspector/inspector.h
+++ b/src/inspector/inspector.h
@@ -223,7 +223,7 @@
/// @param decorations the variable decorations
/// @param variables the list to add the variables to
void AddEntryPointInOutVariables(std::string name,
- type::Type* type,
+ sem::Type* type,
const ast::DecorationList& decorations,
std::vector<StageVariable>& variables) const;
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index f3ea311..54c5838 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -30,8 +30,8 @@
class InspectorHelper : public ProgramBuilder {
public:
InspectorHelper()
- : sampler_type_(type::SamplerKind::kSampler),
- comparison_sampler_type_(type::SamplerKind::kComparisonSampler) {}
+ : sampler_type_(sem::SamplerKind::kSampler),
+ comparison_sampler_type_(sem::SamplerKind::kComparisonSampler) {}
/// Generates an empty function
/// @param name name of the function created
@@ -62,7 +62,7 @@
/// Generates a struct that contains user-defined IO members
/// @param name the name of the generated struct
/// @param inout_vars tuples of {name, loc} that will be the struct members
- type::StructType* MakeInOutStruct(
+ sem::StructType* MakeInOutStruct(
std::string name,
std::vector<std::tuple<std::string, uint32_t>> inout_vars) {
ast::StructMemberList members;
@@ -146,7 +146,7 @@
/// @param val value to initialize the variable with, if NULL no initializer
/// will be added.
template <class T>
- void AddConstantID(std::string name, uint32_t id, type::Type* type, T* val) {
+ void AddConstantID(std::string name, uint32_t id, sem::Type* type, T* val) {
ast::Expression* constructor = nullptr;
if (val) {
constructor =
@@ -161,28 +161,28 @@
/// @param type AST type of the literal, must resolve to BoolLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(type::Type* type, bool* val) {
+ ast::Literal* MakeLiteral(sem::Type* type, bool* val) {
return create<ast::BoolLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to UIntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(type::Type* type, uint32_t* val) {
+ ast::Literal* MakeLiteral(sem::Type* type, uint32_t* val) {
return create<ast::UintLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to IntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(type::Type* type, int32_t* val) {
+ ast::Literal* MakeLiteral(sem::Type* type, int32_t* val) {
return create<ast::SintLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to FloattLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(type::Type* type, float* val) {
+ ast::Literal* MakeLiteral(sem::Type* type, float* val) {
return create<ast::FloatLiteral>(type, *val);
}
@@ -203,7 +203,7 @@
/// @param idx index of member
/// @param type type of member
/// @returns a string for the member
- std::string StructMemberName(size_t idx, type::Type* type) {
+ std::string StructMemberName(size_t idx, sem::Type* type) {
return std::to_string(idx) + type->type_name();
}
@@ -212,9 +212,9 @@
/// @param member_types a vector of member types
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type
- type::StructType* MakeStructType(const std::string& name,
- std::vector<type::Type*> member_types,
- bool is_block) {
+ sem::StructType* MakeStructType(const std::string& name,
+ std::vector<sem::Type*> member_types,
+ bool is_block) {
ast::StructMemberList members;
for (auto* type : member_types) {
members.push_back(Member(StructMemberName(members.size(), type), type));
@@ -235,9 +235,8 @@
/// @param name name for the type
/// @param member_types a vector of member types
/// @returns a struct type that has the layout for an uniform buffer.
- type::StructType* MakeUniformBufferType(
- const std::string& name,
- std::vector<type::Type*> member_types) {
+ sem::StructType* MakeUniformBufferType(const std::string& name,
+ std::vector<sem::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
return struct_type;
}
@@ -248,12 +247,12 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a storage buffer, and the control type wraps the
/// struct.
- std::tuple<type::StructType*, type::AccessControl*> MakeStorageBufferTypes(
+ std::tuple<sem::StructType*, sem::AccessControl*> MakeStorageBufferTypes(
const std::string& name,
- std::vector<type::Type*> member_types) {
+ std::vector<sem::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
- auto* access_type = create<type::AccessControl>(
- ast::AccessControl::kReadWrite, struct_type);
+ auto* access_type =
+ create<sem::AccessControl>(ast::AccessControl::kReadWrite, struct_type);
return {struct_type, std::move(access_type)};
}
@@ -263,12 +262,12 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a read-only storage buffer, and the control type
/// wraps the struct.
- std::tuple<type::StructType*, type::AccessControl*>
+ std::tuple<sem::StructType*, sem::AccessControl*>
MakeReadOnlyStorageBufferTypes(const std::string& name,
- std::vector<type::Type*> member_types) {
+ std::vector<sem::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
auto* access_type =
- create<type::AccessControl>(ast::AccessControl::kReadOnly, struct_type);
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, struct_type);
return {struct_type, std::move(access_type)};
}
@@ -279,7 +278,7 @@
/// @param group the binding and group to use for the uniform buffer
/// @param binding the binding number to use for the uniform buffer
void AddBinding(const std::string& name,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage_class,
uint32_t group,
uint32_t binding) {
@@ -296,7 +295,7 @@
/// @param group the binding/group/ to use for the uniform buffer
/// @param binding the binding number to use for the uniform buffer
void AddUniformBuffer(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
@@ -308,7 +307,7 @@
/// @param group the binding/group to use for the storage buffer
/// @param binding the binding number to use for the storage buffer
void AddStorageBuffer(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kStorage, group, binding);
@@ -321,11 +320,11 @@
void MakeStructVariableReferenceBodyFunction(
std::string func_name,
std::string struct_name,
- std::vector<std::tuple<size_t, type::Type*>> members) {
+ std::vector<std::tuple<size_t, sem::Type*>> members) {
ast::StatementList stmts;
for (auto member : members) {
size_t member_idx;
- type::Type* member_type;
+ sem::Type* member_type;
std::tie(member_idx, member_type) = member;
std::string member_name = StructMemberName(member_idx, member_type);
@@ -335,7 +334,7 @@
for (auto member : members) {
size_t member_idx;
- type::Type* member_type;
+ sem::Type* member_type;
std::tie(member_idx, member_type) = member;
std::string member_name = StructMemberName(member_idx, member_type);
@@ -374,26 +373,26 @@
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- type::SampledTexture* MakeSampledTextureType(type::TextureDimension dim,
- type::Type* type) {
- return create<type::SampledTexture>(dim, type);
+ sem::SampledTexture* MakeSampledTextureType(sem::TextureDimension dim,
+ sem::Type* type) {
+ return create<sem::SampledTexture>(dim, type);
}
/// Generates a DepthTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @returns the generated DepthTexture
- type::DepthTexture* MakeDepthTextureType(type::TextureDimension dim) {
- return create<type::DepthTexture>(dim);
+ sem::DepthTexture* MakeDepthTextureType(sem::TextureDimension dim) {
+ return create<sem::DepthTexture>(dim);
}
/// Generates a MultisampledTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- type::MultisampledTexture* MakeMultisampledTextureType(
- type::TextureDimension dim,
- type::Type* type) {
- return create<type::MultisampledTexture>(dim, type);
+ sem::MultisampledTexture* MakeMultisampledTextureType(
+ sem::TextureDimension dim,
+ sem::Type* type) {
+ return create<sem::MultisampledTexture>(dim, type);
}
/// Adds a sampled texture variable to the program
@@ -402,7 +401,7 @@
/// @param group the binding/group to use for the sampled texture
/// @param binding the binding number to use for the sampled texture
void AddSampledTexture(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
@@ -414,13 +413,13 @@
/// @param group the binding/group to use for the multi-sampled texture
/// @param binding the binding number to use for the multi-sampled texture
void AddMultisampledTexture(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
}
- void AddGlobalVariable(const std::string& name, type::Type* type) {
+ void AddGlobalVariable(const std::string& name, sem::Type* type) {
Global(name, type, ast::StorageClass::kUniformConstant);
}
@@ -430,7 +429,7 @@
/// @param group the binding/group to use for the depth texture
/// @param binding the binding number to use for the depth texture
void AddDepthTexture(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
@@ -449,7 +448,7 @@
const std::string& texture_name,
const std::string& sampler_name,
const std::string& coords_name,
- type::Type* base_type,
+ sem::Type* base_type,
ast::DecorationList decorations) {
std::string result_name = "sampler_result";
@@ -481,7 +480,7 @@
const std::string& sampler_name,
const std::string& coords_name,
const std::string& array_index,
- type::Type* base_type,
+ sem::Type* base_type,
ast::DecorationList decorations) {
std::string result_name = "sampler_result";
@@ -515,7 +514,7 @@
const std::string& sampler_name,
const std::string& coords_name,
const std::string& depth_name,
- type::Type* base_type,
+ sem::Type* base_type,
ast::DecorationList decorations) {
std::string result_name = "sampler_result";
@@ -534,7 +533,7 @@
/// Gets an appropriate type for the data in a given texture type.
/// @param sampled_kind type of in the texture
/// @returns a pointer to a type appropriate for the coord param
- type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
+ sem::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
switch (sampled_kind) {
case ResourceBinding::SampledKind::kFloat:
return ty.f32();
@@ -552,17 +551,17 @@
/// @param dim dimensionality of the texture being sampled
/// @param scalar the scalar type
/// @returns a pointer to a type appropriate for the coord param
- type::Type* GetCoordsType(type::TextureDimension dim, type::Type* scalar) {
+ sem::Type* GetCoordsType(sem::TextureDimension dim, sem::Type* scalar) {
switch (dim) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
return scalar;
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
- return create<type::Vector>(scalar, 2);
- case type::TextureDimension::k3d:
- case type::TextureDimension::kCube:
- case type::TextureDimension::kCubeArray:
- return create<type::Vector>(scalar, 3);
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
+ return create<sem::Vector>(scalar, 2);
+ case sem::TextureDimension::k3d:
+ case sem::TextureDimension::kCube:
+ case sem::TextureDimension::kCubeArray:
+ return create<sem::Vector>(scalar, 3);
default:
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
}
@@ -573,11 +572,11 @@
/// @param dim the texture dimension of the storage texture
/// @param format the image format of the storage texture
/// @returns the storage texture type and subtype
- std::tuple<type::StorageTexture*, type::Type*> MakeStorageTextureTypes(
- type::TextureDimension dim,
- type::ImageFormat format) {
- type::Type* subtype = type::StorageTexture::SubtypeFor(format, Types());
- return {create<type::StorageTexture>(dim, format, subtype), subtype};
+ std::tuple<sem::StorageTexture*, sem::Type*> MakeStorageTextureTypes(
+ sem::TextureDimension dim,
+ sem::ImageFormat format) {
+ sem::Type* subtype = sem::StorageTexture::SubtypeFor(format, Types());
+ return {create<sem::StorageTexture>(dim, format, subtype), subtype};
}
/// Generates appropriate types for a Read-Only StorageTexture
@@ -585,17 +584,17 @@
/// @param format the image format of the storage texture
/// @param read_only should the access type be read only, otherwise write only
/// @returns the storage texture type, subtype & access control type
- std::tuple<type::StorageTexture*, type::Type*, type::AccessControl*>
- MakeStorageTextureTypes(type::TextureDimension dim,
- type::ImageFormat format,
+ std::tuple<sem::StorageTexture*, sem::Type*, sem::AccessControl*>
+ MakeStorageTextureTypes(sem::TextureDimension dim,
+ sem::ImageFormat format,
bool read_only) {
- type::StorageTexture* texture_type;
- type::Type* subtype;
+ sem::StorageTexture* texture_type;
+ sem::Type* subtype;
std::tie(texture_type, subtype) = MakeStorageTextureTypes(dim, format);
auto* access_control =
- create<type::AccessControl>(read_only ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- texture_type);
+ create<sem::AccessControl>(read_only ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ texture_type);
return {texture_type, subtype, access_control};
}
@@ -605,7 +604,7 @@
/// @param group the binding/group to use for the sampled texture
/// @param binding the binding number to use for the sampled texture
void AddStorageTexture(const std::string& name,
- type::Type* type,
+ sem::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
@@ -620,7 +619,7 @@
ast::Function* MakeStorageTextureBodyFunction(
const std::string& func_name,
const std::string& st_name,
- type::Type* dim_type,
+ sem::Type* dim_type,
ast::DecorationList decorations) {
ast::StatementList stmts;
@@ -646,34 +645,34 @@
return *inspector_;
}
- type::ArrayType* u32_array_type(uint32_t count) {
+ sem::ArrayType* u32_array_type(uint32_t count) {
if (array_type_memo_.find(count) == array_type_memo_.end()) {
array_type_memo_[count] =
- create<type::ArrayType>(ty.u32(), count,
- ast::DecorationList{
- create<ast::StrideDecoration>(4),
- });
+ create<sem::ArrayType>(ty.u32(), count,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(4),
+ });
}
return array_type_memo_[count];
}
- type::Vector* vec_type(type::Type* type, uint32_t count) {
+ sem::Vector* vec_type(sem::Type* type, uint32_t count) {
if (vector_type_memo_.find(std::tie(type, count)) ==
vector_type_memo_.end()) {
vector_type_memo_[std::tie(type, count)] =
- create<type::Vector>(type, count);
+ create<sem::Vector>(type, count);
}
return vector_type_memo_[std::tie(type, count)];
}
- type::Sampler* sampler_type() { return &sampler_type_; }
- type::Sampler* comparison_sampler_type() { return &comparison_sampler_type_; }
+ sem::Sampler* sampler_type() { return &sampler_type_; }
+ sem::Sampler* comparison_sampler_type() { return &comparison_sampler_type_; }
private:
std::unique_ptr<Program> program_;
std::unique_ptr<Inspector> inspector_;
- type::Sampler sampler_type_;
- type::Sampler comparison_sampler_type_;
- std::map<uint32_t, type::ArrayType*> array_type_memo_;
- std::map<std::tuple<type::Type*, uint32_t>, type::Vector*> vector_type_memo_;
+ sem::Sampler sampler_type_;
+ sem::Sampler comparison_sampler_type_;
+ std::map<uint32_t, sem::ArrayType*> array_type_memo_;
+ std::map<std::tuple<sem::Type*, uint32_t>, sem::Vector*> vector_type_memo_;
};
class InspectorGetEntryPointTest : public InspectorHelper,
@@ -705,7 +704,7 @@
: public InspectorHelper,
public testing::Test {};
struct GetSampledTextureTestParams {
- type::TextureDimension type_dim;
+ sem::TextureDimension type_dim;
inspector::ResourceBinding::TextureDimension inspector_dim;
inspector::ResourceBinding::SampledKind sampled_kind;
};
@@ -731,16 +730,16 @@
class InspectorGetStorageTextureResourceBindingsTest : public InspectorHelper,
public testing::Test {};
struct GetDepthTextureTestParams {
- type::TextureDimension type_dim;
+ sem::TextureDimension type_dim;
inspector::ResourceBinding::TextureDimension inspector_dim;
};
class InspectorGetDepthTextureResourceBindingsTestWithParam
: public InspectorHelper,
public testing::TestWithParam<GetDepthTextureTestParams> {};
-typedef std::tuple<type::TextureDimension, ResourceBinding::TextureDimension>
+typedef std::tuple<sem::TextureDimension, ResourceBinding::TextureDimension>
DimensionParams;
-typedef std::tuple<type::ImageFormat,
+typedef std::tuple<sem::ImageFormat,
ResourceBinding::ImageFormat,
ResourceBinding::SampledKind>
ImageFormatParams;
@@ -905,7 +904,7 @@
TEST_P(InspectorGetEntryPointTestWithComponentTypeParam, InOutVariables) {
ComponentType inspector_type = GetParam();
- type::Type* tint_type = nullptr;
+ sem::Type* tint_type = nullptr;
switch (inspector_type) {
case ComponentType::kFloat:
tint_type = ty.f32();
@@ -1681,20 +1680,20 @@
}
TEST_F(InspectorGetResourceBindingsTest, Simple) {
- type::StructType* ub_struct_type =
+ sem::StructType* ub_struct_type =
MakeUniformBufferType("ub_type", {ty.i32()});
AddUniformBuffer("ub_var", ub_struct_type, 0, 0);
MakeStructVariableReferenceBodyFunction("ub_func", "ub_var", {{0, ty.i32()}});
- type::StructType* sb_struct_type;
- type::AccessControl* sb_control_type;
+ sem::StructType* sb_struct_type;
+ sem::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeStorageBufferTypes("sb_type", {ty.i32()});
AddStorageBuffer("sb_var", sb_control_type, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", {{0, ty.i32()}});
- type::StructType* rosb_struct_type;
- type::AccessControl* rosb_control_type;
+ sem::StructType* rosb_struct_type;
+ sem::AccessControl* rosb_control_type;
std::tie(rosb_struct_type, rosb_control_type) =
MakeReadOnlyStorageBufferTypes("rosb_type", {ty.i32()});
AddStorageBuffer("rosb_var", rosb_control_type, 1, 1);
@@ -1702,7 +1701,7 @@
{{0, ty.i32()}});
auto* s_texture_type =
- MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
+ MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
AddSampledTexture("s_texture", s_texture_type, 2, 0);
AddSampler("s_var", 3, 0);
AddGlobalVariable("s_coords", ty.f32());
@@ -1710,7 +1709,7 @@
ty.f32(), {});
auto* cs_depth_texture_type =
- MakeDepthTextureType(type::TextureDimension::k2d);
+ MakeDepthTextureType(sem::TextureDimension::k2d);
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
AddComparisonSampler("cs_var", 3, 2);
AddGlobalVariable("cs_coords", ty.vec2<f32>());
@@ -1718,19 +1717,19 @@
MakeComparisonSamplerReferenceBodyFunction(
"cs_func", "cs_texture", "cs_var", "cs_coords", "cs_depth", ty.f32(), {});
- type::StorageTexture* st_type;
- type::Type* st_subtype;
- type::AccessControl* st_ac;
+ sem::StorageTexture* st_type;
+ sem::Type* st_subtype;
+ sem::AccessControl* st_ac;
std::tie(st_type, st_subtype, st_ac) = MakeStorageTextureTypes(
- type::TextureDimension::k2d, type::ImageFormat::kR8Uint, false);
+ sem::TextureDimension::k2d, sem::ImageFormat::kR8Uint, false);
AddStorageTexture("st_var", st_ac, 4, 0);
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<i32>(), {});
- type::StorageTexture* rost_type;
- type::Type* rost_subtype;
- type::AccessControl* rost_ac;
+ sem::StorageTexture* rost_type;
+ sem::Type* rost_subtype;
+ sem::AccessControl* rost_ac;
std::tie(rost_type, rost_subtype, rost_ac) = MakeStorageTextureTypes(
- type::TextureDimension::k2d, type::ImageFormat::kR8Uint, true);
+ sem::TextureDimension::k2d, sem::ImageFormat::kR8Uint, true);
AddStorageTexture("rost_var", rost_ac, 4, 1);
MakeStorageTextureBodyFunction("rost_func", "rost_var", ty.vec2<i32>(), {});
@@ -1803,7 +1802,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
- type::StructType* foo_struct_type =
+ sem::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1847,7 +1846,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
- type::StructType* foo_struct_type =
+ sem::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1874,7 +1873,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
- type::StructType* foo_struct_type =
+ sem::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32(), ty.u32(), ty.f32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1902,7 +1901,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) {
- type::StructType* foo_struct_type =
+ sem::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.vec3<f32>()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1930,7 +1929,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
- type::StructType* ub_struct_type =
+ sem::StructType* ub_struct_type =
MakeUniformBufferType("ub_type", {ty.i32(), ty.u32(), ty.f32()});
AddUniformBuffer("ub_foo", ub_struct_type, 0, 0);
AddUniformBuffer("ub_bar", ub_struct_type, 0, 1);
@@ -1989,7 +1988,7 @@
// TODO(bclayton) - This is not a legal structure layout for uniform buffer
// usage. Once crbug.com/tint/628 is implemented, this will fail validation
// and will need to be fixed.
- type::StructType* foo_struct_type =
+ sem::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32(), u32_array_type(4)});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -2016,8 +2015,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2045,8 +2044,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), ty.u32(), ty.f32()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2075,8 +2074,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
- type::StructType* sb_struct_type;
- type::AccessControl* sb_control_type;
+ sem::StructType* sb_struct_type;
+ sem::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()});
AddStorageBuffer("sb_foo", sb_control_type, 0, 0);
@@ -2136,8 +2135,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2165,8 +2164,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2194,8 +2193,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.vec3<f32>()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2224,8 +2223,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2246,8 +2245,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2276,8 +2275,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
MultipleStorageBuffers) {
- type::StructType* sb_struct_type;
- type::AccessControl* sb_control_type;
+ sem::StructType* sb_struct_type;
+ sem::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeReadOnlyStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()});
AddStorageBuffer("sb_foo", sb_control_type, 0, 0);
@@ -2337,8 +2336,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2367,8 +2366,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
ContainingRuntimeArray) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2396,8 +2395,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
- type::StructType* foo_struct_type;
- type::AccessControl* foo_control_type;
+ sem::StructType* foo_struct_type;
+ sem::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32()});
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
@@ -2419,7 +2418,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
auto* sampled_texture_type =
- MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
+ MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@@ -2457,7 +2456,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
auto* sampled_texture_type =
- MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
+ MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@@ -2484,7 +2483,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
auto* sampled_texture_type =
- MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
+ MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@@ -2502,7 +2501,7 @@
}
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
- auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
+ auto* depth_texture_type = MakeDepthTextureType(sem::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.vec2<f32>());
@@ -2523,7 +2522,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
- auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
+ auto* depth_texture_type = MakeDepthTextureType(sem::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.vec2<f32>());
@@ -2562,7 +2561,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
- auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
+ auto* depth_texture_type = MakeDepthTextureType(sem::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.vec2<f32>());
@@ -2591,7 +2590,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
- auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
+ auto* depth_texture_type = MakeDepthTextureType(sem::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.vec2<f32>());
@@ -2611,7 +2610,7 @@
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
auto* sampled_texture_type =
- MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
+ MakeSampledTextureType(sem::TextureDimension::k1d, ty.f32());
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32());
@@ -2685,19 +2684,19 @@
InspectorGetSampledTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
inspector::ResourceBinding::TextureDimension::k3d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- type::TextureDimension::kCube,
+ sem::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube,
inspector::ResourceBinding::SampledKind::kFloat}));
@@ -2737,11 +2736,11 @@
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray,
inspector::ResourceBinding::SampledKind::kFloat}));
@@ -2789,15 +2788,15 @@
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kUInt}));
@@ -2851,15 +2850,15 @@
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kUInt}));
@@ -2886,32 +2885,32 @@
ImageFormatParams format_params;
std::tie(read_only, dim_params, format_params) = GetParam();
- type::TextureDimension dim;
+ sem::TextureDimension dim;
ResourceBinding::TextureDimension expected_dim;
std::tie(dim, expected_dim) = dim_params;
- type::ImageFormat format;
+ sem::ImageFormat format;
ResourceBinding::ImageFormat expected_format;
ResourceBinding::SampledKind expected_kind;
std::tie(format, expected_format, expected_kind) = format_params;
- type::StorageTexture* st_type;
- type::Type* st_subtype;
- type::AccessControl* ac;
+ sem::StorageTexture* st_type;
+ sem::Type* st_subtype;
+ sem::AccessControl* ac;
std::tie(st_type, st_subtype, ac) =
MakeStorageTextureTypes(dim, format, read_only);
AddStorageTexture("st_var", ac, 0, 0);
- type::Type* dim_type = nullptr;
+ sem::Type* dim_type = nullptr;
switch (dim) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
dim_type = ty.i32();
break;
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
dim_type = ty.vec2<i32>();
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
dim_type = ty.vec3<i32>();
break;
default:
@@ -2955,118 +2954,118 @@
testing::Combine(
testing::Bool(),
testing::Values(
- std::make_tuple(type::TextureDimension::k1d,
+ std::make_tuple(sem::TextureDimension::k1d,
ResourceBinding::TextureDimension::k1d),
- std::make_tuple(type::TextureDimension::k2d,
+ std::make_tuple(sem::TextureDimension::k2d,
ResourceBinding::TextureDimension::k2d),
- std::make_tuple(type::TextureDimension::k2dArray,
+ std::make_tuple(sem::TextureDimension::k2dArray,
ResourceBinding::TextureDimension::k2dArray),
- std::make_tuple(type::TextureDimension::k3d,
+ std::make_tuple(sem::TextureDimension::k3d,
ResourceBinding::TextureDimension::k3d)),
testing::Values(
- std::make_tuple(type::ImageFormat::kR8Uint,
+ std::make_tuple(sem::ImageFormat::kR8Uint,
ResourceBinding::ImageFormat::kR8Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kR16Uint,
+ std::make_tuple(sem::ImageFormat::kR16Uint,
ResourceBinding::ImageFormat::kR16Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRg8Uint,
+ std::make_tuple(sem::ImageFormat::kRg8Uint,
ResourceBinding::ImageFormat::kRg8Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kR32Uint,
+ std::make_tuple(sem::ImageFormat::kR32Uint,
ResourceBinding::ImageFormat::kR32Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRg16Uint,
+ std::make_tuple(sem::ImageFormat::kRg16Uint,
ResourceBinding::ImageFormat::kRg16Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRgba8Uint,
+ std::make_tuple(sem::ImageFormat::kRgba8Uint,
ResourceBinding::ImageFormat::kRgba8Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRg32Uint,
+ std::make_tuple(sem::ImageFormat::kRg32Uint,
ResourceBinding::ImageFormat::kRg32Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRgba16Uint,
+ std::make_tuple(sem::ImageFormat::kRgba16Uint,
ResourceBinding::ImageFormat::kRgba16Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kRgba32Uint,
+ std::make_tuple(sem::ImageFormat::kRgba32Uint,
ResourceBinding::ImageFormat::kRgba32Uint,
ResourceBinding::SampledKind::kUInt),
- std::make_tuple(type::ImageFormat::kR8Sint,
+ std::make_tuple(sem::ImageFormat::kR8Sint,
ResourceBinding::ImageFormat::kR8Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kR16Sint,
+ std::make_tuple(sem::ImageFormat::kR16Sint,
ResourceBinding::ImageFormat::kR16Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRg8Sint,
+ std::make_tuple(sem::ImageFormat::kRg8Sint,
ResourceBinding::ImageFormat::kRg8Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kR32Sint,
+ std::make_tuple(sem::ImageFormat::kR32Sint,
ResourceBinding::ImageFormat::kR32Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRg16Sint,
+ std::make_tuple(sem::ImageFormat::kRg16Sint,
ResourceBinding::ImageFormat::kRg16Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRgba8Sint,
+ std::make_tuple(sem::ImageFormat::kRgba8Sint,
ResourceBinding::ImageFormat::kRgba8Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRg32Sint,
+ std::make_tuple(sem::ImageFormat::kRg32Sint,
ResourceBinding::ImageFormat::kRg32Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRgba16Sint,
+ std::make_tuple(sem::ImageFormat::kRgba16Sint,
ResourceBinding::ImageFormat::kRgba16Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kRgba32Sint,
+ std::make_tuple(sem::ImageFormat::kRgba32Sint,
ResourceBinding::ImageFormat::kRgba32Sint,
ResourceBinding::SampledKind::kSInt),
- std::make_tuple(type::ImageFormat::kR8Unorm,
+ std::make_tuple(sem::ImageFormat::kR8Unorm,
ResourceBinding::ImageFormat::kR8Unorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRg8Unorm,
+ std::make_tuple(sem::ImageFormat::kRg8Unorm,
ResourceBinding::ImageFormat::kRg8Unorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgba8Unorm,
+ std::make_tuple(sem::ImageFormat::kRgba8Unorm,
ResourceBinding::ImageFormat::kRgba8Unorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgba8UnormSrgb,
+ std::make_tuple(sem::ImageFormat::kRgba8UnormSrgb,
ResourceBinding::ImageFormat::kRgba8UnormSrgb,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kBgra8Unorm,
+ std::make_tuple(sem::ImageFormat::kBgra8Unorm,
ResourceBinding::ImageFormat::kBgra8Unorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kBgra8UnormSrgb,
+ std::make_tuple(sem::ImageFormat::kBgra8UnormSrgb,
ResourceBinding::ImageFormat::kBgra8UnormSrgb,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgb10A2Unorm,
+ std::make_tuple(sem::ImageFormat::kRgb10A2Unorm,
ResourceBinding::ImageFormat::kRgb10A2Unorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kR8Snorm,
+ std::make_tuple(sem::ImageFormat::kR8Snorm,
ResourceBinding::ImageFormat::kR8Snorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRg8Snorm,
+ std::make_tuple(sem::ImageFormat::kRg8Snorm,
ResourceBinding::ImageFormat::kRg8Snorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgba8Snorm,
+ std::make_tuple(sem::ImageFormat::kRgba8Snorm,
ResourceBinding::ImageFormat::kRgba8Snorm,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kR16Float,
+ std::make_tuple(sem::ImageFormat::kR16Float,
ResourceBinding::ImageFormat::kR16Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kR32Float,
+ std::make_tuple(sem::ImageFormat::kR32Float,
ResourceBinding::ImageFormat::kR32Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRg16Float,
+ std::make_tuple(sem::ImageFormat::kRg16Float,
ResourceBinding::ImageFormat::kRg16Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRg11B10Float,
+ std::make_tuple(sem::ImageFormat::kRg11B10Float,
ResourceBinding::ImageFormat::kRg11B10Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRg32Float,
+ std::make_tuple(sem::ImageFormat::kRg32Float,
ResourceBinding::ImageFormat::kRg32Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgba16Float,
+ std::make_tuple(sem::ImageFormat::kRgba16Float,
ResourceBinding::ImageFormat::kRgba16Float,
ResourceBinding::SampledKind::kFloat),
- std::make_tuple(type::ImageFormat::kRgba32Float,
+ std::make_tuple(sem::ImageFormat::kRgba32Float,
ResourceBinding::ImageFormat::kRgba32Float,
ResourceBinding::SampledKind::kFloat))));
@@ -3103,16 +3102,16 @@
InspectorGetDepthTextureResourceBindingsTestWithParam,
testing::Values(
GetDepthTextureTestParams{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d},
GetDepthTextureTestParams{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray},
GetDepthTextureTestParams{
- type::TextureDimension::kCube,
+ sem::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube},
GetDepthTextureTestParams{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray}));
} // namespace
diff --git a/src/intrinsic_table.cc b/src/intrinsic_table.cc
index 4bcd8c7..004bcbe 100644
--- a/src/intrinsic_table.cc
+++ b/src/intrinsic_table.cc
@@ -77,7 +77,7 @@
/// The map of open types. A new entry is assigned the first time an
/// OpenType is encountered. If the OpenType is encountered again, a
/// comparison is made to see if the type is consistent.
- std::unordered_map<OpenType, type::Type*> open_types;
+ std::unordered_map<OpenType, sem::Type*> open_types;
/// The map of open numbers. A new entry is assigned the first time an
/// OpenNumber is encountered. If the OpenNumber is encountered again, a
/// comparison is made to see if the number is consistent.
@@ -91,7 +91,7 @@
/// Aliases are automatically unwrapped before matching.
/// Match may add to, or compare against the open types and numbers in state.
/// @returns true if the argument type is as expected.
- bool Match(MatchState& state, type::Type* argument_type) const {
+ bool Match(MatchState& state, sem::Type* argument_type) const {
auto* unwrapped = argument_type->UnwrapAliasIfNeeded();
return MatchUnwrapped(state, unwrapped);
}
@@ -110,12 +110,12 @@
/// Match may add to, or compare against the open types and numbers in state.
/// @returns true if the argument type is as expected.
virtual bool MatchUnwrapped(MatchState& state,
- type::Type* argument_type) const = 0;
+ sem::Type* argument_type) const = 0;
/// Checks `state.open_type` to see if the OpenType `t` is equal to the type
/// `ty`. If `state.open_type` does not contain an entry for `t`, then `ty`
/// is added and returns true.
- bool MatchOpenType(MatchState& state, OpenType t, type::Type* ty) const {
+ bool MatchOpenType(MatchState& state, OpenType t, sem::Type* ty) const {
auto it = state.open_types.find(t);
if (it != state.open_types.end()) {
return it->second == ty;
@@ -145,9 +145,9 @@
/// Final matched state passed to Build()
struct BuildState {
/// The type manager used to construct new types
- type::Manager& ty_mgr;
+ sem::Manager& ty_mgr;
/// The final resolved list of open types
- std::unordered_map<OpenType, type::Type*> const open_types;
+ std::unordered_map<OpenType, sem::Type*> const open_types;
/// The final resolved list of open numbers
std::unordered_map<OpenNumber, uint32_t> const open_numbers;
};
@@ -156,7 +156,7 @@
~Builder() override = default;
/// Constructs and returns the expected type
- virtual type::Type* Build(BuildState& state) const = 0;
+ virtual sem::Type* Build(BuildState& state) const = 0;
};
/// OpenTypeBuilder is a Matcher / Builder for an open type (T etc).
@@ -166,11 +166,11 @@
public:
explicit OpenTypeBuilder(OpenType open_type) : open_type_(open_type) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
return MatchOpenType(state, open_type_, ty);
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
return state.open_types.at(open_type_);
}
@@ -183,11 +183,11 @@
/// VoidBuilder is a Matcher / Builder for void types.
class VoidBuilder : public Builder {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::Void>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::Void>();
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::Void>();
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::Void>();
}
std::string str() const override { return "void"; }
};
@@ -195,11 +195,11 @@
/// BoolBuilder is a Matcher / Builder for boolean types.
class BoolBuilder : public Builder {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::Bool>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::Bool>();
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::Bool>();
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::Bool>();
}
std::string str() const override { return "bool"; }
};
@@ -207,11 +207,11 @@
/// F32Builder is a Matcher / Builder for f32 types.
class F32Builder : public Builder {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::F32>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::F32>();
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::F32>();
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::F32>();
}
std::string str() const override { return "f32"; }
};
@@ -219,11 +219,11 @@
/// U32Builder is a Matcher / Builder for u32 types.
class U32Builder : public Builder {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::U32>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::U32>();
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::U32>();
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::U32>();
}
std::string str() const override { return "u32"; }
};
@@ -231,11 +231,11 @@
/// I32Builder is a Matcher / Builder for i32 types.
class I32Builder : public Builder {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::I32>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::I32>();
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::I32>();
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::I32>();
}
std::string str() const override { return "i32"; }
};
@@ -243,8 +243,8 @@
/// IU32Matcher is a Matcher for i32 or u32 types.
class IU32Matcher : public Matcher {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::I32>() || ty->Is<type::U32>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::I32>() || ty->Is<sem::U32>();
}
std::string str() const override { return "i32 or u32"; }
};
@@ -252,8 +252,8 @@
/// FIU32Matcher is a Matcher for f32, i32 or u32 types.
class FIU32Matcher : public Matcher {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- return ty->Is<type::F32>() || ty->Is<type::I32>() || ty->Is<type::U32>();
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ return ty->Is<sem::F32>() || ty->Is<sem::I32>() || ty->Is<sem::U32>();
}
std::string str() const override { return "f32, i32 or u32"; }
};
@@ -261,7 +261,7 @@
/// ScalarMatcher is a Matcher for f32, i32, u32 or boolean types.
class ScalarMatcher : public Matcher {
public:
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
return ty->is_scalar();
}
std::string str() const override { return "scalar"; }
@@ -274,8 +274,8 @@
OpenSizeVecBuilder(OpenNumber size, Builder* element_builder)
: size_(size), element_builder_(element_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* vec = ty->As<type::Vector>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* vec = ty->As<sem::Vector>()) {
if (!MatchOpenNumber(state, size_, vec->size())) {
return false;
}
@@ -284,10 +284,10 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
auto n = state.open_numbers.at(size_);
- return state.ty_mgr.Get<type::Vector>(el, n);
+ return state.ty_mgr.Get<sem::Vector>(el, n);
}
std::string str() const override {
@@ -306,8 +306,8 @@
VecBuilder(uint32_t size, Builder* element_builder)
: size_(size), element_builder_(element_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* vec = ty->As<type::Vector>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* vec = ty->As<sem::Vector>()) {
if (vec->size() == size_) {
return element_builder_->Match(state, vec->type());
}
@@ -315,9 +315,9 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
- return state.ty_mgr.Get<type::Vector>(el, size_);
+ return state.ty_mgr.Get<sem::Vector>(el, size_);
}
std::string str() const override {
@@ -338,8 +338,8 @@
Builder* element_builder)
: columns_(columns), rows_(rows), element_builder_(element_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* mat = ty->As<type::Matrix>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* mat = ty->As<sem::Matrix>()) {
if (!MatchOpenNumber(state, columns_, mat->columns())) {
return false;
}
@@ -351,11 +351,11 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
auto columns = state.open_numbers.at(columns_);
auto rows = state.open_numbers.at(rows_);
- return state.ty_mgr.Get<type::Matrix>(el, rows, columns);
+ return state.ty_mgr.Get<sem::Matrix>(el, rows, columns);
}
std::string str() const override {
@@ -375,16 +375,16 @@
explicit PtrBuilder(Builder* element_builder)
: element_builder_(element_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* ptr = ty->As<type::Pointer>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* ptr = ty->As<sem::Pointer>()) {
return element_builder_->Match(state, ptr->type());
}
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
- return state.ty_mgr.Get<type::Pointer>(el, ast::StorageClass::kNone);
+ return state.ty_mgr.Get<sem::Pointer>(el, ast::StorageClass::kNone);
}
bool ExpectsPointer() const override { return true; }
@@ -403,8 +403,8 @@
explicit ArrayBuilder(Builder* element_builder)
: element_builder_(element_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* arr = ty->As<type::ArrayType>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* arr = ty->As<sem::ArrayType>()) {
if (arr->size() == 0) {
return element_builder_->Match(state, arr->type());
}
@@ -412,9 +412,9 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
- return state.ty_mgr.Get<type::ArrayType>(el, 0, ast::DecorationList{});
+ return state.ty_mgr.Get<sem::ArrayType>(el, 0, ast::DecorationList{});
}
std::string str() const override {
@@ -428,12 +428,12 @@
/// SampledTextureBuilder is a Matcher / Builder for sampled texture types.
class SampledTextureBuilder : public Builder {
public:
- explicit SampledTextureBuilder(type::TextureDimension dimensions,
+ explicit SampledTextureBuilder(sem::TextureDimension dimensions,
Builder* type_builder)
: dimensions_(dimensions), type_builder_(type_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* tex = ty->As<type::SampledTexture>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* tex = ty->As<sem::SampledTexture>()) {
if (tex->dim() == dimensions_) {
return type_builder_->Match(state, tex->type());
}
@@ -441,9 +441,9 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* type = type_builder_->Build(state);
- return state.ty_mgr.Get<type::SampledTexture>(dimensions_, type);
+ return state.ty_mgr.Get<sem::SampledTexture>(dimensions_, type);
}
std::string str() const override {
@@ -453,7 +453,7 @@
}
private:
- type::TextureDimension const dimensions_;
+ sem::TextureDimension const dimensions_;
Builder* const type_builder_;
};
@@ -461,12 +461,12 @@
/// types.
class MultisampledTextureBuilder : public Builder {
public:
- explicit MultisampledTextureBuilder(type::TextureDimension dimensions,
+ explicit MultisampledTextureBuilder(sem::TextureDimension dimensions,
Builder* type_builder)
: dimensions_(dimensions), type_builder_(type_builder) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* tex = ty->As<type::MultisampledTexture>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* tex = ty->As<sem::MultisampledTexture>()) {
if (tex->dim() == dimensions_) {
return type_builder_->Match(state, tex->type());
}
@@ -474,9 +474,9 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* type = type_builder_->Build(state);
- return state.ty_mgr.Get<type::MultisampledTexture>(dimensions_, type);
+ return state.ty_mgr.Get<sem::MultisampledTexture>(dimensions_, type);
}
std::string str() const override {
@@ -487,25 +487,25 @@
}
private:
- type::TextureDimension const dimensions_;
+ sem::TextureDimension const dimensions_;
Builder* const type_builder_;
};
/// DepthTextureBuilder is a Matcher / Builder for depth texture types.
class DepthTextureBuilder : public Builder {
public:
- explicit DepthTextureBuilder(type::TextureDimension dimensions)
+ explicit DepthTextureBuilder(sem::TextureDimension dimensions)
: dimensions_(dimensions) {}
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- if (auto* tex = ty->As<type::DepthTexture>()) {
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ if (auto* tex = ty->As<sem::DepthTexture>()) {
return tex->dim() == dimensions_;
}
return false;
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::DepthTexture>(dimensions_);
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::DepthTexture>(dimensions_);
}
std::string str() const override {
@@ -515,7 +515,7 @@
}
private:
- type::TextureDimension const dimensions_;
+ sem::TextureDimension const dimensions_;
};
/// StorageTextureBuilder is a Matcher / Builder for storage texture types of
@@ -523,15 +523,15 @@
class StorageTextureBuilder : public Builder {
public:
explicit StorageTextureBuilder(
- type::TextureDimension dimensions,
+ sem::TextureDimension dimensions,
OpenNumber texel_format, // a.k.a "image format"
OpenType channel_format) // a.k.a "storage subtype"
: dimensions_(dimensions),
texel_format_(texel_format),
channel_format_(channel_format) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* ac = ty->As<type::AccessControl>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* ac = ty->As<sem::AccessControl>()) {
// If we have an storage texture argument that's got an access control
// type wrapped around it, accept it. Signatures that don't include an
// access control imply any access. Example:
@@ -539,7 +539,7 @@
ty = ac->type();
}
- if (auto* tex = ty->As<type::StorageTexture>()) {
+ if (auto* tex = ty->As<sem::StorageTexture>()) {
if (MatchOpenNumber(state, texel_format_,
static_cast<uint32_t>(tex->image_format()))) {
if (MatchOpenType(state, channel_format_, tex->type())) {
@@ -550,12 +550,12 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto texel_format =
- static_cast<type::ImageFormat>(state.open_numbers.at(texel_format_));
+ static_cast<sem::ImageFormat>(state.open_numbers.at(texel_format_));
auto* channel_format = state.open_types.at(channel_format_);
- return state.ty_mgr.Get<type::StorageTexture>(dimensions_, texel_format,
- channel_format);
+ return state.ty_mgr.Get<sem::StorageTexture>(dimensions_, texel_format,
+ channel_format);
}
std::string str() const override {
@@ -565,7 +565,7 @@
}
private:
- type::TextureDimension const dimensions_;
+ sem::TextureDimension const dimensions_;
OpenNumber const texel_format_;
OpenType const channel_format_;
};
@@ -573,31 +573,31 @@
/// SamplerBuilder is a Matcher / Builder for sampler types of the given kind.
class SamplerBuilder : public Builder {
public:
- explicit SamplerBuilder(type::SamplerKind kind) : kind_(kind) {}
+ explicit SamplerBuilder(sem::SamplerKind kind) : kind_(kind) {}
- bool MatchUnwrapped(MatchState&, type::Type* ty) const override {
- if (auto* sampler = ty->As<type::Sampler>()) {
+ bool MatchUnwrapped(MatchState&, sem::Type* ty) const override {
+ if (auto* sampler = ty->As<sem::Sampler>()) {
return sampler->kind() == kind_;
}
return false;
}
- type::Type* Build(BuildState& state) const override {
- return state.ty_mgr.Get<type::Sampler>(kind_);
+ sem::Type* Build(BuildState& state) const override {
+ return state.ty_mgr.Get<sem::Sampler>(kind_);
}
std::string str() const override {
switch (kind_) {
- case type::SamplerKind::kSampler:
+ case sem::SamplerKind::kSampler:
return "sampler";
- case type::SamplerKind::kComparisonSampler:
+ case sem::SamplerKind::kComparisonSampler:
return "sampler_comparison";
}
return "sampler";
}
private:
- type::SamplerKind const kind_;
+ sem::SamplerKind const kind_;
};
/// AccessControlBuilder is a Matcher / Builder for AccessControl types
@@ -607,8 +607,8 @@
Builder* type)
: access_control_(access_control), type_(type) {}
- bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* ac = ty->As<type::AccessControl>()) {
+ bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override {
+ if (auto* ac = ty->As<sem::AccessControl>()) {
if (ac->access_control() == access_control_) {
return type_->Match(state, ty);
}
@@ -616,9 +616,9 @@
return false;
}
- type::Type* Build(BuildState& state) const override {
+ sem::Type* Build(BuildState& state) const override {
auto* ty = type_->Build(state);
- return state.ty_mgr.Get<type::AccessControl>(access_control_, ty);
+ return state.ty_mgr.Get<sem::AccessControl>(access_control_, ty);
}
std::string str() const override {
@@ -639,7 +639,7 @@
IntrinsicTable::Result Lookup(ProgramBuilder& builder,
sem::IntrinsicType type,
- const std::vector<type::Type*>& args,
+ const std::vector<sem::Type*>& args,
const Source& source) const override;
/// Holds the information about a single overload parameter used for matching
@@ -661,7 +661,7 @@
/// (positive representing a greater match), and nullptr is returned.
sem::Intrinsic* Match(ProgramBuilder& builder,
sem::IntrinsicType type,
- const std::vector<type::Type*>& arg_types,
+ const std::vector<sem::Type*>& arg_types,
diag::List& diagnostics,
int& match_score) const;
@@ -732,13 +732,13 @@
/// @returns a Matcher / Builder that matches a sampled texture with the given
/// dimensions and type
- Builder* sampled_texture(type::TextureDimension dimensions, Builder* type) {
+ Builder* sampled_texture(sem::TextureDimension dimensions, Builder* type) {
return matcher_allocator_.Create<SampledTextureBuilder>(dimensions, type);
}
/// @returns a Matcher / Builder that matches a multisampled texture with the
/// given dimensions and type
- Builder* multisampled_texture(type::TextureDimension dimensions,
+ Builder* multisampled_texture(sem::TextureDimension dimensions,
Builder* type) {
return matcher_allocator_.Create<MultisampledTextureBuilder>(dimensions,
type);
@@ -746,13 +746,13 @@
/// @returns a Matcher / Builder that matches a depth texture with the
/// given dimensions
- Builder* depth_texture(type::TextureDimension dimensions) {
+ Builder* depth_texture(sem::TextureDimension dimensions) {
return matcher_allocator_.Create<DepthTextureBuilder>(dimensions);
}
/// @returns a Matcher / Builder that matches a storage texture of the given
/// format with the given dimensions
- Builder* storage_texture(type::TextureDimension dimensions,
+ Builder* storage_texture(sem::TextureDimension dimensions,
OpenNumber texel_format,
OpenType channel_format) {
return matcher_allocator_.Create<StorageTextureBuilder>(
@@ -760,7 +760,7 @@
}
/// @returns a Matcher / Builder that matches a sampler type
- Builder* sampler(type::SamplerKind kind) {
+ Builder* sampler(sem::SamplerKind kind) {
return matcher_allocator_.Create<SamplerBuilder>(kind);
}
@@ -796,7 +796,7 @@
Impl::Impl() {
using I = sem::IntrinsicType;
- using Dim = type::TextureDimension;
+ using Dim = sem::TextureDimension;
auto* void_ = &matchers_.void_; // void
auto* bool_ = &matchers_.bool_; // bool
@@ -837,12 +837,12 @@
// I - is an alias to sem::IntrinsicType.
// I::kIsInf is shorthand for sem::IntrinsicType::kIsInf.
// bool_ - is a pointer to a pre-constructed BoolBuilder which matches and
- // builds type::Bool types.
+ // builds sem::Bool types.
// {f32} - is the list of parameter Builders for the overload.
// Builders are a type of Matcher that can also build the the type.
// All Builders are Matchers, not all Matchers are Builders.
// f32 is a pointer to a pre-constructed F32Builder which matches and
- // builds type::F32 types.
+ // builds sem::F32 types.
//
// This call registers the overload for the `isInf(f32) -> bool` intrinsic.
//
@@ -851,8 +851,8 @@
//
// (1) Overload::Match() begins by attempting to match the argument types
// from left to right.
- // F32Builder::Match() is called with the type::F32 argument type.
- // F32Builder (only) matches the type::F32 type, so F32Builder::Match()
+ // F32Builder::Match() is called with the sem::F32 argument type.
+ // F32Builder (only) matches the sem::F32 type, so F32Builder::Match()
// returns true.
// (2) All the parameters have had their Matcher::Match() methods return
// true, there are no open-types (more about these later), so the
@@ -1114,9 +1114,9 @@
access_control(ast::AccessControl::kWriteOnly, tex_storage_2d_array_FT);
auto* tex_storage_wo_3d_FT =
access_control(ast::AccessControl::kWriteOnly, tex_storage_3d_FT);
- auto* sampler = this->sampler(type::SamplerKind::kSampler);
+ auto* sampler = this->sampler(sem::SamplerKind::kSampler);
auto* sampler_comparison =
- this->sampler(type::SamplerKind::kComparisonSampler);
+ this->sampler(sem::SamplerKind::kComparisonSampler);
auto t = sem::Parameter::Usage::kTexture;
auto s = sem::Parameter::Usage::kSampler;
auto coords = sem::Parameter::Usage::kCoords;
@@ -1300,7 +1300,7 @@
/// types.
std::string CallSignature(ProgramBuilder& builder,
sem::IntrinsicType type,
- const std::vector<type::Type*>& args) {
+ const std::vector<sem::Type*>& args) {
std::stringstream ss;
ss << sem::str(type) << "(";
{
@@ -1320,7 +1320,7 @@
IntrinsicTable::Result Impl::Lookup(ProgramBuilder& builder,
sem::IntrinsicType type,
- const std::vector<type::Type*>& args,
+ const std::vector<sem::Type*>& args,
const Source& source) const {
diag::List diagnostics;
// Candidate holds information about a mismatched overload that could be what
@@ -1370,7 +1370,7 @@
sem::Intrinsic* Impl::Overload::Match(ProgramBuilder& builder,
sem::IntrinsicType intrinsic,
- const std::vector<type::Type*>& args,
+ const std::vector<sem::Type*>& args,
diag::List& diagnostics,
int& match_score) const {
if (type != intrinsic) {
@@ -1397,7 +1397,7 @@
}
auto* arg_ty = args[i];
- if (auto* ptr = arg_ty->As<type::Pointer>()) {
+ if (auto* ptr = arg_ty->As<sem::Pointer>()) {
if (!parameters[i].matcher->ExpectsPointer()) {
// Argument is a pointer, but the matcher isn't expecting one.
// Perform an implicit dereference.
diff --git a/src/intrinsic_table.h b/src/intrinsic_table.h
index fc0e465..0425255 100644
--- a/src/intrinsic_table.h
+++ b/src/intrinsic_table.h
@@ -51,7 +51,7 @@
/// @return the semantic intrinsic if found, otherwise nullptr
virtual Result Lookup(ProgramBuilder& builder,
sem::IntrinsicType type,
- const std::vector<type::Type*>& args,
+ const std::vector<sem::Type*>& args,
const Source& source) const = 0;
};
diff --git a/src/intrinsic_table_test.cc b/src/intrinsic_table_test.cc
index 073f0df..0b62d46 100644
--- a/src/intrinsic_table_test.cc
+++ b/src/intrinsic_table_test.cc
@@ -69,8 +69,7 @@
}
TEST_F(IntrinsicTableTest, MatchI32) {
- auto* tex =
- create<type::SampledTexture>(type::TextureDimension::k1d, ty.f32());
+ auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.i32(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -84,8 +83,7 @@
}
TEST_F(IntrinsicTableTest, MismatchI32) {
- auto* tex =
- create<type::SampledTexture>(type::TextureDimension::k1d, ty.f32());
+ auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.f32()}, Source{});
ASSERT_EQ(result.intrinsic, nullptr);
@@ -221,9 +219,8 @@
}
TEST_F(IntrinsicTableTest, MatchSampler) {
- auto* tex =
- create<type::SampledTexture>(type::TextureDimension::k2d, ty.f32());
- auto* sampler = create<type::Sampler>(type::SamplerKind::kSampler);
+ auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
+ auto* sampler = create<sem::Sampler>(sem::SamplerKind::kSampler);
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
{tex, sampler, ty.vec2<f32>()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -238,8 +235,7 @@
}
TEST_F(IntrinsicTableTest, MismatchSampler) {
- auto* tex =
- create<type::SampledTexture>(type::TextureDimension::k2d, ty.f32());
+ auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureSample,
{tex, ty.f32(), ty.vec2<f32>()}, Source{});
ASSERT_EQ(result.intrinsic, nullptr);
@@ -247,8 +243,7 @@
}
TEST_F(IntrinsicTableTest, MatchSampledTexture) {
- auto* tex =
- create<type::SampledTexture>(type::TextureDimension::k2d, ty.f32());
+ auto* tex = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -263,7 +258,7 @@
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
auto* tex =
- create<type::MultisampledTexture>(type::TextureDimension::k2d, ty.f32());
+ create<sem::MultisampledTexture>(sem::TextureDimension::k2d, ty.f32());
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -277,7 +272,7 @@
}
TEST_F(IntrinsicTableTest, MatchDepthTexture) {
- auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
+ auto* tex = create<sem::DepthTexture>(sem::TextureDimension::k2d);
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex, ty.vec2<i32>(), ty.i32()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -291,11 +286,10 @@
}
TEST_F(IntrinsicTableTest, MatchROStorageTexture) {
- auto* tex = create<type::StorageTexture>(
- type::TextureDimension::k2d, type::ImageFormat::kR16Float,
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()));
- auto* tex_ac =
- create<type::AccessControl>(ast::AccessControl::kReadOnly, tex);
+ auto* tex = create<sem::StorageTexture>(
+ sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
+ auto* tex_ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex);
auto result = table->Lookup(*this, IntrinsicType::kTextureLoad,
{tex_ac, ty.vec2<i32>()}, Source{});
ASSERT_NE(result.intrinsic, nullptr);
@@ -309,11 +303,11 @@
}
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
- auto* tex = create<type::StorageTexture>(
- type::TextureDimension::k2d, type::ImageFormat::kR16Float,
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()));
+ auto* tex = create<sem::StorageTexture>(
+ sem::TextureDimension::k2d, sem::ImageFormat::kR16Float,
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()));
auto* tex_ac =
- create<type::AccessControl>(ast::AccessControl::kWriteOnly, tex);
+ create<sem::AccessControl>(ast::AccessControl::kWriteOnly, tex);
auto result =
table->Lookup(*this, IntrinsicType::kTextureStore,
{tex_ac, ty.vec2<i32>(), ty.vec4<f32>()}, Source{});
@@ -470,7 +464,7 @@
}
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
- auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
+ auto* tex = create<sem::DepthTexture>(sem::TextureDimension::k2d);
auto result = table->Lookup(*this, IntrinsicType::kTextureDimensions,
{tex, ty.bool_()}, Source{});
ASSERT_EQ(
diff --git a/src/program.cc b/src/program.cc
index 4342d10..a0703e8 100644
--- a/src/program.cc
+++ b/src/program.cc
@@ -102,7 +102,7 @@
return is_valid_;
}
-type::Type* Program::TypeOf(const ast::Expression* expr) const {
+sem::Type* Program::TypeOf(const ast::Expression* expr) const {
auto* sem = Sem().Get(expr);
return sem ? sem->Type() : nullptr;
}
diff --git a/src/program.h b/src/program.h
index 815e751..9f666f1 100644
--- a/src/program.h
+++ b/src/program.h
@@ -66,7 +66,7 @@
ProgramID ID() const { return id_; }
/// @returns a reference to the program's types
- const type::Manager& Types() const {
+ const sem::Manager& Types() const {
AssertNotMoved();
return types_;
}
@@ -129,7 +129,7 @@
/// @param expr the AST expression
/// @return the resolved semantic type for the expression, or nullptr if the
/// expression has no resolved type.
- type::Type* TypeOf(const ast::Expression* expr) const;
+ sem::Type* TypeOf(const ast::Expression* expr) const;
/// @param demangle whether to automatically demangle the symbols in the
/// returned string
@@ -160,7 +160,7 @@
void AssertNotMoved() const;
ProgramID id_;
- type::Manager types_;
+ sem::Manager types_;
ASTNodeAllocator ast_nodes_;
SemNodeAllocator sem_nodes_;
ast::Module* ast_ = nullptr;
diff --git a/src/program_builder.cc b/src/program_builder.cc
index 0f2c695..368efca 100644
--- a/src/program_builder.cc
+++ b/src/program_builder.cc
@@ -56,7 +56,7 @@
ProgramBuilder ProgramBuilder::Wrap(const Program* program) {
ProgramBuilder builder;
builder.id_ = program->ID();
- builder.types_ = type::Manager::Wrap(program->Types());
+ builder.types_ = sem::Manager::Wrap(program->Types());
builder.ast_ = builder.create<ast::Module>(
program->AST().source(), program->AST().GlobalDeclarations());
builder.sem_ = sem::Info::Wrap(program->Sem());
@@ -85,40 +85,40 @@
}
}
-type::Type* ProgramBuilder::TypeOf(ast::Expression* expr) const {
+sem::Type* ProgramBuilder::TypeOf(ast::Expression* expr) const {
auto* sem = Sem().Get(expr);
return sem ? sem->Type() : nullptr;
}
ast::ConstructorExpression* ProgramBuilder::ConstructValueFilledWith(
- type::Type* type,
+ sem::Type* type,
int elem_value) {
auto* unwrapped_type = type->UnwrapAliasIfNeeded();
- if (unwrapped_type->Is<type::Bool>()) {
+ if (unwrapped_type->Is<sem::Bool>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(type, elem_value == 0 ? false : true));
}
- if (unwrapped_type->Is<type::I32>()) {
+ if (unwrapped_type->Is<sem::I32>()) {
return create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
type, static_cast<ProgramBuilder::i32>(elem_value)));
}
- if (unwrapped_type->Is<type::U32>()) {
+ if (unwrapped_type->Is<sem::U32>()) {
return create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
type, static_cast<ProgramBuilder::u32>(elem_value)));
}
- if (unwrapped_type->Is<type::F32>()) {
+ if (unwrapped_type->Is<sem::F32>()) {
return create<ast::ScalarConstructorExpression>(create<ast::FloatLiteral>(
type, static_cast<ProgramBuilder::f32>(elem_value)));
}
- if (auto* v = unwrapped_type->As<type::Vector>()) {
+ if (auto* v = unwrapped_type->As<sem::Vector>()) {
ast::ExpressionList el(v->size());
for (size_t i = 0; i < el.size(); i++) {
el[i] = ConstructValueFilledWith(v->type(), elem_value);
}
return create<ast::TypeConstructorExpression>(type, std::move(el));
}
- if (auto* m = unwrapped_type->As<type::Matrix>()) {
- auto* col_vec_type = create<type::Vector>(m->type(), m->rows());
+ if (auto* m = unwrapped_type->As<sem::Matrix>()) {
+ auto* col_vec_type = create<sem::Vector>(m->type(), m->rows());
ast::ExpressionList el(col_vec_type->size());
for (size_t i = 0; i < el.size(); i++) {
el[i] = ConstructValueFilledWith(col_vec_type, elem_value);
diff --git a/src/program_builder.h b/src/program_builder.h
index e1b0863..b66e904 100644
--- a/src/program_builder.h
+++ b/src/program_builder.h
@@ -124,13 +124,13 @@
ProgramID ID() const { return id_; }
/// @returns a reference to the program's types
- type::Manager& Types() {
+ sem::Manager& Types() {
AssertNotMoved();
return types_;
}
/// @returns a reference to the program's types
- const type::Manager& Types() const {
+ const sem::Manager& Types() const {
AssertNotMoved();
return types_;
}
@@ -287,7 +287,7 @@
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
}
- /// Creates a new type::Type owned by the ProgramBuilder.
+ /// Creates a new sem::Type owned by the ProgramBuilder.
/// When the ProgramBuilder is destructed, owned ProgramBuilder and the
/// returned`Type` will also be destructed.
/// Types are unique (de-aliased), and so calling create() for the same `T`
@@ -300,9 +300,9 @@
/// @param args the arguments to pass to the type constructor
/// @returns the de-aliased type pointer
template <typename T, typename... ARGS>
- traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
- static_assert(std::is_base_of<type::Type, T>::value,
- "T does not derive from type::Type");
+ traits::EnableIfIsType<T, sem::Type>* create(ARGS&&... args) {
+ static_assert(std::is_base_of<sem::Type, T>::value,
+ "T does not derive from sem::Type");
AssertNotMoved();
return types_.Get<T>(std::forward<ARGS>(args)...);
}
@@ -324,185 +324,184 @@
/// @return the tint AST type for the C type `T`.
template <typename T>
- type::Type* Of() const {
+ sem::Type* Of() const {
return CToAST<T>::get(this);
}
/// @returns a boolean type
- type::Bool* bool_() const { return builder->create<type::Bool>(); }
+ sem::Bool* bool_() const { return builder->create<sem::Bool>(); }
/// @returns a f32 type
- type::F32* f32() const { return builder->create<type::F32>(); }
+ sem::F32* f32() const { return builder->create<sem::F32>(); }
/// @returns a i32 type
- type::I32* i32() const { return builder->create<type::I32>(); }
+ sem::I32* i32() const { return builder->create<sem::I32>(); }
/// @returns a u32 type
- type::U32* u32() const { return builder->create<type::U32>(); }
+ sem::U32* u32() const { return builder->create<sem::U32>(); }
/// @returns a void type
- type::Void* void_() const { return builder->create<type::Void>(); }
+ sem::Void* void_() const { return builder->create<sem::Void>(); }
/// @param type vector subtype
/// @return the tint AST type for a 2-element vector of `type`.
- type::Vector* vec2(type::Type* type) const {
- return builder->create<type::Vector>(type, 2u);
+ sem::Vector* vec2(sem::Type* type) const {
+ return builder->create<sem::Vector>(type, 2u);
}
/// @param type vector subtype
/// @return the tint AST type for a 3-element vector of `type`.
- type::Vector* vec3(type::Type* type) const {
- return builder->create<type::Vector>(type, 3u);
+ sem::Vector* vec3(sem::Type* type) const {
+ return builder->create<sem::Vector>(type, 3u);
}
/// @param type vector subtype
/// @return the tint AST type for a 4-element vector of `type`.
- type::Type* vec4(type::Type* type) const {
- return builder->create<type::Vector>(type, 4u);
+ sem::Type* vec4(sem::Type* type) const {
+ return builder->create<sem::Vector>(type, 4u);
}
/// @return the tint AST type for a 2-element vector of the C type `T`.
template <typename T>
- type::Vector* vec2() const {
+ sem::Vector* vec2() const {
return vec2(Of<T>());
}
/// @return the tint AST type for a 3-element vector of the C type `T`.
template <typename T>
- type::Vector* vec3() const {
+ sem::Vector* vec3() const {
return vec3(Of<T>());
}
/// @return the tint AST type for a 4-element vector of the C type `T`.
template <typename T>
- type::Type* vec4() const {
+ sem::Type* vec4() const {
return vec4(Of<T>());
}
/// @param type matrix subtype
/// @return the tint AST type for a 2x3 matrix of `type`.
- type::Matrix* mat2x2(type::Type* type) const {
- return builder->create<type::Matrix>(type, 2u, 2u);
+ sem::Matrix* mat2x2(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 2u, 2u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 2x3 matrix of `type`.
- type::Matrix* mat2x3(type::Type* type) const {
- return builder->create<type::Matrix>(type, 3u, 2u);
+ sem::Matrix* mat2x3(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 3u, 2u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 2x4 matrix of `type`.
- type::Matrix* mat2x4(type::Type* type) const {
- return builder->create<type::Matrix>(type, 4u, 2u);
+ sem::Matrix* mat2x4(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 4u, 2u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 3x2 matrix of `type`.
- type::Matrix* mat3x2(type::Type* type) const {
- return builder->create<type::Matrix>(type, 2u, 3u);
+ sem::Matrix* mat3x2(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 2u, 3u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 3x3 matrix of `type`.
- type::Matrix* mat3x3(type::Type* type) const {
- return builder->create<type::Matrix>(type, 3u, 3u);
+ sem::Matrix* mat3x3(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 3u, 3u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 3x4 matrix of `type`.
- type::Matrix* mat3x4(type::Type* type) const {
- return builder->create<type::Matrix>(type, 4u, 3u);
+ sem::Matrix* mat3x4(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 4u, 3u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 4x2 matrix of `type`.
- type::Matrix* mat4x2(type::Type* type) const {
- return builder->create<type::Matrix>(type, 2u, 4u);
+ sem::Matrix* mat4x2(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 2u, 4u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 4x3 matrix of `type`.
- type::Matrix* mat4x3(type::Type* type) const {
- return builder->create<type::Matrix>(type, 3u, 4u);
+ sem::Matrix* mat4x3(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 3u, 4u);
}
/// @param type matrix subtype
/// @return the tint AST type for a 4x4 matrix of `type`.
- type::Matrix* mat4x4(type::Type* type) const {
- return builder->create<type::Matrix>(type, 4u, 4u);
+ sem::Matrix* mat4x4(sem::Type* type) const {
+ return builder->create<sem::Matrix>(type, 4u, 4u);
}
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat2x2() const {
+ sem::Matrix* mat2x2() const {
return mat2x2(Of<T>());
}
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat2x3() const {
+ sem::Matrix* mat2x3() const {
return mat2x3(Of<T>());
}
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat2x4() const {
+ sem::Matrix* mat2x4() const {
return mat2x4(Of<T>());
}
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat3x2() const {
+ sem::Matrix* mat3x2() const {
return mat3x2(Of<T>());
}
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat3x3() const {
+ sem::Matrix* mat3x3() const {
return mat3x3(Of<T>());
}
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat3x4() const {
+ sem::Matrix* mat3x4() const {
return mat3x4(Of<T>());
}
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat4x2() const {
+ sem::Matrix* mat4x2() const {
return mat4x2(Of<T>());
}
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat4x3() const {
+ sem::Matrix* mat4x3() const {
return mat4x3(Of<T>());
}
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
template <typename T>
- type::Matrix* mat4x4() const {
+ sem::Matrix* mat4x4() const {
return mat4x4(Of<T>());
}
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array.
/// @return the tint AST type for a array of size `n` of type `T`
- type::ArrayType* array(type::Type* subtype, uint32_t n = 0) const {
- return builder->create<type::ArrayType>(subtype, n,
- ast::DecorationList{});
+ sem::ArrayType* array(sem::Type* subtype, uint32_t n = 0) const {
+ return builder->create<sem::ArrayType>(subtype, n, ast::DecorationList{});
}
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array.
/// @param stride the array stride.
/// @return the tint AST type for a array of size `n` of type `T`
- type::ArrayType* array(type::Type* subtype,
- uint32_t n,
- uint32_t stride) const {
- return builder->create<type::ArrayType>(
+ sem::ArrayType* array(sem::Type* subtype,
+ uint32_t n,
+ uint32_t stride) const {
+ return builder->create<sem::ArrayType>(
subtype, n,
ast::DecorationList{
builder->create<ast::StrideDecoration>(stride),
@@ -511,14 +510,14 @@
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
- type::ArrayType* array() const {
+ sem::ArrayType* array() const {
return array(Of<T>(), N);
}
/// @param stride the array stride
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
- type::ArrayType* array(uint32_t stride) const {
+ sem::ArrayType* array(uint32_t stride) const {
return array(Of<T>(), N, stride);
}
@@ -527,33 +526,33 @@
/// @param type the alias type
/// @returns the alias pointer
template <typename NAME>
- type::Alias* alias(NAME&& name, type::Type* type) const {
- return builder->create<type::Alias>(
- builder->Sym(std::forward<NAME>(name)), type);
+ sem::Alias* alias(NAME&& name, sem::Type* type) const {
+ return builder->create<sem::Alias>(builder->Sym(std::forward<NAME>(name)),
+ type);
}
/// Creates an access control qualifier type
/// @param access the access control
/// @param type the inner type
/// @returns the access control qualifier type
- type::AccessControl* access(ast::AccessControl access,
- type::Type* type) const {
- return builder->create<type::AccessControl>(access, type);
+ sem::AccessControl* access(ast::AccessControl access,
+ sem::Type* type) const {
+ return builder->create<sem::AccessControl>(access, type);
}
/// @return the tint AST pointer to `type` with the given ast::StorageClass
/// @param type the type of the pointer
/// @param storage_class the storage class of the pointer
- type::Pointer* pointer(type::Type* type,
- ast::StorageClass storage_class) const {
- return builder->create<type::Pointer>(type, storage_class);
+ sem::Pointer* pointer(sem::Type* type,
+ ast::StorageClass storage_class) const {
+ return builder->create<sem::Pointer>(type, storage_class);
}
/// @return the tint AST pointer to type `T` with the given
/// ast::StorageClass.
/// @param storage_class the storage class of the pointer
template <typename T>
- type::Pointer* pointer(ast::StorageClass storage_class) const {
+ sem::Pointer* pointer(ast::StorageClass storage_class) const {
return pointer(Of<T>(), storage_class);
}
@@ -561,8 +560,8 @@
/// @param impl the struct implementation
/// @returns a struct pointer
template <typename NAME>
- type::StructType* struct_(NAME&& name, ast::Struct* impl) const {
- return builder->create<type::StructType>(
+ sem::StructType* struct_(NAME&& name, ast::Struct* impl) const {
+ return builder->create<sem::StructType>(
builder->Sym(std::forward<NAME>(name)), impl);
}
@@ -571,7 +570,7 @@
/// contains a single static `get()` method for obtaining the corresponding
/// AST type for the C type `T`.
/// `get()` has the signature:
- /// `static type::Type* get(Types* t)`
+ /// `static sem::Type* get(Types* t)`
template <typename T>
struct CToAST {};
@@ -733,7 +732,7 @@
/// @return an `ast::TypeConstructorExpression` of `type` constructed with the
/// values `args`.
template <typename... ARGS>
- ast::TypeConstructorExpression* Construct(type::Type* type, ARGS&&... args) {
+ ast::TypeConstructorExpression* Construct(sem::Type* type, ARGS&&... args) {
return create<ast::TypeConstructorExpression>(
type, ExprList(std::forward<ARGS>(args)...));
}
@@ -746,7 +745,7 @@
/// @param elem_value the initial or element value (for vec and mat) to
/// construct with
/// @return the constructor expression
- ast::ConstructorExpression* ConstructValueFilledWith(type::Type* type,
+ ast::ConstructorExpression* ConstructValueFilledWith(sem::Type* type,
int elem_value = 0);
/// @param args the arguments for the vector constructor
@@ -872,7 +871,7 @@
/// @return an `ast::TypeConstructorExpression` of an array with element type
/// `subtype`, constructed with the values `args`.
template <typename... ARGS>
- ast::TypeConstructorExpression* array(type::Type* subtype,
+ ast::TypeConstructorExpression* array(sem::Type* subtype,
uint32_t n,
ARGS&&... args) {
return create<ast::TypeConstructorExpression>(
@@ -887,7 +886,7 @@
/// @returns a `ast::Variable` with the given name, storage and type
template <typename NAME>
ast::Variable* Var(NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage,
ast::Expression* constructor = nullptr,
ast::DecorationList decorations = {}) {
@@ -905,7 +904,7 @@
template <typename NAME>
ast::Variable* Var(const Source& source,
NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage,
ast::Expression* constructor = nullptr,
ast::DecorationList decorations = {}) {
@@ -920,7 +919,7 @@
/// @returns a constant `ast::Variable` with the given name and type
template <typename NAME>
ast::Variable* Const(NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::Expression* constructor = nullptr,
ast::DecorationList decorations = {}) {
return create<ast::Variable>(Sym(std::forward<NAME>(name)),
@@ -937,7 +936,7 @@
template <typename NAME>
ast::Variable* Const(const Source& source,
NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::Expression* constructor = nullptr,
ast::DecorationList decorations = {}) {
return create<ast::Variable>(source, Sym(std::forward<NAME>(name)),
@@ -951,7 +950,7 @@
/// @returns a constant `ast::Variable` with the given name and type
template <typename NAME>
ast::Variable* Param(NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::DecorationList decorations = {}) {
return create<ast::Variable>(Sym(std::forward<NAME>(name)),
ast::StorageClass::kNone, type, true, nullptr,
@@ -966,7 +965,7 @@
template <typename NAME>
ast::Variable* Param(const Source& source,
NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::DecorationList decorations = {}) {
return create<ast::Variable>(source, Sym(std::forward<NAME>(name)),
ast::StorageClass::kNone, type, true, nullptr,
@@ -1127,7 +1126,7 @@
ast::Function* Func(const Source& source,
NAME&& name,
ast::VariableList params,
- type::Type* type,
+ sem::Type* type,
ast::StatementList body,
ast::DecorationList decorations = {},
ast::DecorationList return_type_decorations = {}) {
@@ -1151,7 +1150,7 @@
template <typename NAME>
ast::Function* Func(NAME&& name,
ast::VariableList params,
- type::Type* type,
+ sem::Type* type,
ast::StatementList body,
ast::DecorationList decorations = {},
ast::DecorationList return_type_decorations = {}) {
@@ -1174,18 +1173,18 @@
return create<ast::ReturnStatement>(Expr(std::forward<EXPR>(val)));
}
- /// Creates a ast::Struct and type::StructType, registering the
- /// type::StructType with the AST().ConstructedTypes().
+ /// Creates a ast::Struct and sem::StructType, registering the
+ /// sem::StructType with the AST().ConstructedTypes().
/// @param source the source information
/// @param name the struct name
/// @param members the struct members
/// @param decorations the optional struct decorations
/// @returns the struct type
template <typename NAME>
- type::StructType* Structure(const Source& source,
- NAME&& name,
- ast::StructMemberList members,
- ast::DecorationList decorations = {}) {
+ sem::StructType* Structure(const Source& source,
+ NAME&& name,
+ ast::StructMemberList members,
+ ast::DecorationList decorations = {}) {
auto* impl =
create<ast::Struct>(source, std::move(members), std::move(decorations));
auto* type = ty.struct_(Sym(std::forward<NAME>(name)), impl);
@@ -1193,16 +1192,16 @@
return type;
}
- /// Creates a ast::Struct and type::StructType, registering the
- /// type::StructType with the AST().ConstructedTypes().
+ /// Creates a ast::Struct and sem::StructType, registering the
+ /// sem::StructType with the AST().ConstructedTypes().
/// @param name the struct name
/// @param members the struct members
/// @param decorations the optional struct decorations
/// @returns the struct type
template <typename NAME>
- type::StructType* Structure(NAME&& name,
- ast::StructMemberList members,
- ast::DecorationList decorations = {}) {
+ sem::StructType* Structure(NAME&& name,
+ ast::StructMemberList members,
+ ast::DecorationList decorations = {}) {
auto* impl =
create<ast::Struct>(std::move(members), std::move(decorations));
auto* type = ty.struct_(Sym(std::forward<NAME>(name)), impl);
@@ -1219,7 +1218,7 @@
template <typename NAME>
ast::StructMember* Member(const Source& source,
NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::DecorationList decorations = {}) {
return create<ast::StructMember>(source, Sym(std::forward<NAME>(name)),
type, std::move(decorations));
@@ -1232,7 +1231,7 @@
/// @returns the struct member pointer
template <typename NAME>
ast::StructMember* Member(NAME&& name,
- type::Type* type,
+ sem::Type* type,
ast::DecorationList decorations = {}) {
return create<ast::StructMember>(source_, Sym(std::forward<NAME>(name)),
type, std::move(decorations));
@@ -1244,7 +1243,7 @@
/// @param type the struct member type
/// @returns the struct member pointer
template <typename NAME>
- ast::StructMember* Member(uint32_t offset, NAME&& name, type::Type* type) {
+ ast::StructMember* Member(uint32_t offset, NAME&& name, sem::Type* type) {
return create<ast::StructMember>(
source_, Sym(std::forward<NAME>(name)), type,
ast::DecorationList{
@@ -1417,7 +1416,7 @@
/// @param expr the AST expression
/// @return the resolved semantic type for the expression, or nullptr if the
/// expression has no resolved type.
- type::Type* TypeOf(ast::Expression* expr) const;
+ sem::Type* TypeOf(ast::Expression* expr) const;
/// Wraps the ast::Literal in a statement. This is used by tests that
/// construct a partial AST and require the Resolver to reach these
@@ -1465,7 +1464,7 @@
private:
ProgramID id_;
- type::Manager types_;
+ sem::Manager types_;
ASTNodeAllocator ast_nodes_;
SemNodeAllocator sem_nodes_;
ast::Module* ast_;
@@ -1489,31 +1488,31 @@
// Various template specializations for ProgramBuilder::TypesBuilder::CToAST.
template <>
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::i32> {
- static type::Type* get(const ProgramBuilder::TypesBuilder* t) {
+ static sem::Type* get(const ProgramBuilder::TypesBuilder* t) {
return t->i32();
}
};
template <>
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::u32> {
- static type::Type* get(const ProgramBuilder::TypesBuilder* t) {
+ static sem::Type* get(const ProgramBuilder::TypesBuilder* t) {
return t->u32();
}
};
template <>
struct ProgramBuilder::TypesBuilder::CToAST<ProgramBuilder::f32> {
- static type::Type* get(const ProgramBuilder::TypesBuilder* t) {
+ static sem::Type* get(const ProgramBuilder::TypesBuilder* t) {
return t->f32();
}
};
template <>
struct ProgramBuilder::TypesBuilder::CToAST<bool> {
- static type::Type* get(const ProgramBuilder::TypesBuilder* t) {
+ static sem::Type* get(const ProgramBuilder::TypesBuilder* t) {
return t->bool_();
}
};
template <>
struct ProgramBuilder::TypesBuilder::CToAST<void> {
- static type::Type* get(const ProgramBuilder::TypesBuilder* t) {
+ static sem::Type* get(const ProgramBuilder::TypesBuilder* t) {
return t->void_();
}
};
diff --git a/src/reader/spirv/enum_converter.cc b/src/reader/spirv/enum_converter.cc
index b07da26..1f82c04 100644
--- a/src/reader/spirv/enum_converter.cc
+++ b/src/reader/spirv/enum_converter.cc
@@ -100,83 +100,83 @@
return ast::Builtin::kNone;
}
-type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
+sem::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
if (arrayed) {
switch (dim) {
case SpvDim2D:
- return type::TextureDimension::k2dArray;
+ return sem::TextureDimension::k2dArray;
case SpvDimCube:
- return type::TextureDimension::kCubeArray;
+ return sem::TextureDimension::kCubeArray;
default:
break;
}
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
- return type::TextureDimension::kNone;
+ return sem::TextureDimension::kNone;
}
// Assume non-arrayed
switch (dim) {
case SpvDim1D:
- return type::TextureDimension::k1d;
+ return sem::TextureDimension::k1d;
case SpvDim2D:
- return type::TextureDimension::k2d;
+ return sem::TextureDimension::k2d;
case SpvDim3D:
- return type::TextureDimension::k3d;
+ return sem::TextureDimension::k3d;
case SpvDimCube:
- return type::TextureDimension::kCube;
+ return sem::TextureDimension::kCube;
default:
break;
}
Fail() << "invalid dimension: " << int(dim);
- return type::TextureDimension::kNone;
+ return sem::TextureDimension::kNone;
}
-type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
+sem::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
switch (fmt) {
case SpvImageFormatUnknown:
- return type::ImageFormat::kNone;
+ return sem::ImageFormat::kNone;
// 8 bit channels
case SpvImageFormatRgba8:
- return type::ImageFormat::kRgba8Unorm;
+ return sem::ImageFormat::kRgba8Unorm;
case SpvImageFormatRgba8Snorm:
- return type::ImageFormat::kRgba8Snorm;
+ return sem::ImageFormat::kRgba8Snorm;
case SpvImageFormatRgba8ui:
- return type::ImageFormat::kRgba8Uint;
+ return sem::ImageFormat::kRgba8Uint;
case SpvImageFormatRgba8i:
- return type::ImageFormat::kRgba8Sint;
+ return sem::ImageFormat::kRgba8Sint;
// 16 bit channels
case SpvImageFormatRgba16ui:
- return type::ImageFormat::kRgba16Uint;
+ return sem::ImageFormat::kRgba16Uint;
case SpvImageFormatRgba16i:
- return type::ImageFormat::kRgba16Sint;
+ return sem::ImageFormat::kRgba16Sint;
case SpvImageFormatRgba16f:
- return type::ImageFormat::kRgba16Float;
+ return sem::ImageFormat::kRgba16Float;
// 32 bit channels
case SpvImageFormatR32ui:
- return type::ImageFormat::kR32Uint;
+ return sem::ImageFormat::kR32Uint;
case SpvImageFormatR32i:
- return type::ImageFormat::kR32Sint;
+ return sem::ImageFormat::kR32Sint;
case SpvImageFormatR32f:
- return type::ImageFormat::kR32Float;
+ return sem::ImageFormat::kR32Float;
case SpvImageFormatRg32ui:
- return type::ImageFormat::kRg32Uint;
+ return sem::ImageFormat::kRg32Uint;
case SpvImageFormatRg32i:
- return type::ImageFormat::kRg32Sint;
+ return sem::ImageFormat::kRg32Sint;
case SpvImageFormatRg32f:
- return type::ImageFormat::kRg32Float;
+ return sem::ImageFormat::kRg32Float;
case SpvImageFormatRgba32ui:
- return type::ImageFormat::kRgba32Uint;
+ return sem::ImageFormat::kRgba32Uint;
case SpvImageFormatRgba32i:
- return type::ImageFormat::kRgba32Sint;
+ return sem::ImageFormat::kRgba32Sint;
case SpvImageFormatRgba32f:
- return type::ImageFormat::kRgba32Float;
+ return sem::ImageFormat::kRgba32Float;
default:
break;
}
Fail() << "invalid image format: " << int(fmt);
- return type::ImageFormat::kNone;
+ return sem::ImageFormat::kNone;
}
} // namespace spirv
diff --git a/src/reader/spirv/enum_converter.h b/src/reader/spirv/enum_converter.h
index 5831a88..1fd535e 100644
--- a/src/reader/spirv/enum_converter.h
+++ b/src/reader/spirv/enum_converter.h
@@ -58,13 +58,13 @@
/// @param dim the SPIR-V Dim value
/// @param arrayed true if the texture is arrayed
/// @returns a Tint AST texture dimension
- type::TextureDimension ToDim(SpvDim dim, bool arrayed);
+ sem::TextureDimension ToDim(SpvDim dim, bool arrayed);
/// Converts a SPIR-V Image Format to a Tint ImageFormat
/// On failure, logs an error and returns kNone
/// @param fmt the SPIR-V format
/// @returns a Tint AST format
- type::ImageFormat ToImageFormat(SpvImageFormat fmt);
+ sem::ImageFormat ToImageFormat(SpvImageFormat fmt);
private:
/// Registers a failure and returns a stream for log diagnostics.
diff --git a/src/reader/spirv/enum_converter_test.cc b/src/reader/spirv/enum_converter_test.cc
index 19f6ad2..4433f9c 100644
--- a/src/reader/spirv/enum_converter_test.cc
+++ b/src/reader/spirv/enum_converter_test.cc
@@ -243,7 +243,7 @@
SpvDim dim;
bool arrayed;
bool expect_success;
- type::TextureDimension expected;
+ sem::TextureDimension expected;
};
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
@@ -287,38 +287,37 @@
SpvDimTest,
testing::Values(
// Non-arrayed
- DimCase{SpvDim1D, false, true, type::TextureDimension::k1d},
- DimCase{SpvDim2D, false, true, type::TextureDimension::k2d},
- DimCase{SpvDim3D, false, true, type::TextureDimension::k3d},
- DimCase{SpvDimCube, false, true, type::TextureDimension::kCube},
+ DimCase{SpvDim1D, false, true, sem::TextureDimension::k1d},
+ DimCase{SpvDim2D, false, true, sem::TextureDimension::k2d},
+ DimCase{SpvDim3D, false, true, sem::TextureDimension::k3d},
+ DimCase{SpvDimCube, false, true, sem::TextureDimension::kCube},
// Arrayed
- DimCase{SpvDim2D, true, true, type::TextureDimension::k2dArray},
- DimCase{SpvDimCube, true, true, type::TextureDimension::kCubeArray}));
+ DimCase{SpvDim2D, true, true, sem::TextureDimension::k2dArray},
+ DimCase{SpvDimCube, true, true, sem::TextureDimension::kCubeArray}));
INSTANTIATE_TEST_SUITE_P(
EnumConverterBad,
SpvDimTest,
testing::Values(
// Invalid SPIR-V dimensionality.
- DimCase{SpvDimMax, false, false, type::TextureDimension::kNone},
- DimCase{SpvDimMax, true, false, type::TextureDimension::kNone},
+ DimCase{SpvDimMax, false, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimMax, true, false, sem::TextureDimension::kNone},
// Vulkan non-arrayed dimensionalities not supported by WGSL.
- DimCase{SpvDimRect, false, false, type::TextureDimension::kNone},
- DimCase{SpvDimBuffer, false, false, type::TextureDimension::kNone},
- DimCase{SpvDimSubpassData, false, false, type::TextureDimension::kNone},
+ DimCase{SpvDimRect, false, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimBuffer, false, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimSubpassData, false, false, sem::TextureDimension::kNone},
// Arrayed dimensionalities not supported by WGSL
- DimCase{SpvDim3D, true, false, type::TextureDimension::kNone},
- DimCase{SpvDimRect, true, false, type::TextureDimension::kNone},
- DimCase{SpvDimBuffer, true, false, type::TextureDimension::kNone},
- DimCase{SpvDimSubpassData, true, false,
- type::TextureDimension::kNone}));
+ DimCase{SpvDim3D, true, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimRect, true, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimBuffer, true, false, sem::TextureDimension::kNone},
+ DimCase{SpvDimSubpassData, true, false, sem::TextureDimension::kNone}));
// ImageFormat
struct ImageFormatCase {
SpvImageFormat format;
bool expect_success;
- type::ImageFormat expected;
+ sem::ImageFormat expected;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
@@ -362,70 +361,68 @@
SpvImageFormatTest,
testing::Values(
// Unknown. This is used for sampled images.
- ImageFormatCase{SpvImageFormatUnknown, true, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatUnknown, true, sem::ImageFormat::kNone},
// 8 bit channels
ImageFormatCase{SpvImageFormatRgba8, true,
- type::ImageFormat::kRgba8Unorm},
+ sem::ImageFormat::kRgba8Unorm},
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
- type::ImageFormat::kRgba8Snorm},
+ sem::ImageFormat::kRgba8Snorm},
ImageFormatCase{SpvImageFormatRgba8ui, true,
- type::ImageFormat::kRgba8Uint},
+ sem::ImageFormat::kRgba8Uint},
ImageFormatCase{SpvImageFormatRgba8i, true,
- type::ImageFormat::kRgba8Sint},
+ sem::ImageFormat::kRgba8Sint},
// 16 bit channels
ImageFormatCase{SpvImageFormatRgba16ui, true,
- type::ImageFormat::kRgba16Uint},
+ sem::ImageFormat::kRgba16Uint},
ImageFormatCase{SpvImageFormatRgba16i, true,
- type::ImageFormat::kRgba16Sint},
+ sem::ImageFormat::kRgba16Sint},
ImageFormatCase{SpvImageFormatRgba16f, true,
- type::ImageFormat::kRgba16Float},
+ sem::ImageFormat::kRgba16Float},
// 32 bit channels
// ... 1 channel
- ImageFormatCase{SpvImageFormatR32ui, true, type::ImageFormat::kR32Uint},
- ImageFormatCase{SpvImageFormatR32i, true, type::ImageFormat::kR32Sint},
- ImageFormatCase{SpvImageFormatR32f, true, type::ImageFormat::kR32Float},
+ ImageFormatCase{SpvImageFormatR32ui, true, sem::ImageFormat::kR32Uint},
+ ImageFormatCase{SpvImageFormatR32i, true, sem::ImageFormat::kR32Sint},
+ ImageFormatCase{SpvImageFormatR32f, true, sem::ImageFormat::kR32Float},
// ... 2 channels
ImageFormatCase{SpvImageFormatRg32ui, true,
- type::ImageFormat::kRg32Uint},
- ImageFormatCase{SpvImageFormatRg32i, true,
- type::ImageFormat::kRg32Sint},
+ sem::ImageFormat::kRg32Uint},
+ ImageFormatCase{SpvImageFormatRg32i, true, sem::ImageFormat::kRg32Sint},
ImageFormatCase{SpvImageFormatRg32f, true,
- type::ImageFormat::kRg32Float},
+ sem::ImageFormat::kRg32Float},
// ... 4 channels
ImageFormatCase{SpvImageFormatRgba32ui, true,
- type::ImageFormat::kRgba32Uint},
+ sem::ImageFormat::kRgba32Uint},
ImageFormatCase{SpvImageFormatRgba32i, true,
- type::ImageFormat::kRgba32Sint},
+ sem::ImageFormat::kRgba32Sint},
ImageFormatCase{SpvImageFormatRgba32f, true,
- type::ImageFormat::kRgba32Float}));
+ sem::ImageFormat::kRgba32Float}));
INSTANTIATE_TEST_SUITE_P(
EnumConverterBad,
SpvImageFormatTest,
testing::Values(
// Scanning in order from the SPIR-V spec.
- ImageFormatCase{SpvImageFormatRg16f, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16f, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
- type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR16f, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRgb10A2, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR16, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR8, false, type::ImageFormat::kNone},
+ sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR16f, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRgb10A2, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR16, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR8, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
- type::ImageFormat::kNone},
+ sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRg16Snorm, false,
- type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8Snorm, false,
- type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16i, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8i, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR8i, false, type::ImageFormat::kNone},
+ sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8Snorm, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16i, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8i, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR8i, false, sem::ImageFormat::kNone},
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
- type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16ui, false, type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8ui, false, type::ImageFormat::kNone}));
+ sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16ui, false, sem::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8ui, false, sem::ImageFormat::kNone}));
} // namespace
} // namespace spirv
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 4b25b05..d66cd4e 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -724,8 +724,8 @@
fail_stream_(pi->fail_stream()),
namer_(pi->namer()),
function_(function),
- i32_(builder_.create<type::I32>()),
- u32_(builder_.create<type::U32>()),
+ i32_(builder_.create<sem::I32>()),
+ u32_(builder_.create<sem::U32>()),
sample_mask_in_id(0u),
sample_mask_out_id(0u),
ep_info_(ep_info) {
@@ -931,7 +931,7 @@
return success();
}
-type::Type* FunctionEmitter::GetVariableStoreType(
+sem::Type* FunctionEmitter::GetVariableStoreType(
const spvtools::opt::Instruction& var_decl_inst) {
const auto type_id = var_decl_inst.type_id();
auto* var_ref_type = type_mgr_->GetType(type_id);
@@ -2029,7 +2029,7 @@
<< id;
return {};
case SkipReason::kPointSizeBuiltinValue: {
- auto* f32 = create<type::F32>();
+ auto* f32 = create<sem::F32>();
return {f32,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, f32, 1.0f))};
@@ -3145,8 +3145,8 @@
}
auto expr = MakeExpression(ptr_id);
// The load result type is the pointee type of its operand.
- TINT_ASSERT(expr.type->Is<type::Pointer>());
- expr.type = expr.type->As<type::Pointer>()->type();
+ TINT_ASSERT(expr.type->Is<sem::Pointer>());
+ expr.type = expr.type->As<sem::Pointer>()->type();
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
@@ -3242,7 +3242,7 @@
const auto opcode = inst.opcode();
- type::Type* ast_type =
+ sem::Type* ast_type =
inst.type_id() != 0 ? parser_impl_.ConvertType(inst.type_id()) : nullptr;
auto binary_op = ConvertBinaryOp(opcode);
@@ -3388,7 +3388,7 @@
auto* func = create<ast::IdentifierExpression>(
Source{}, builder_.Symbols().Register(name));
ast::ExpressionList operands;
- type::Type* first_operand_type = nullptr;
+ sem::Type* first_operand_type = nullptr;
// All parameters to GLSL.std.450 extended instructions are IDs.
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
TypedExpression operand = MakeOperand(inst, iarg);
@@ -3630,7 +3630,7 @@
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
TINT_ASSERT(ast_pointer_type);
- TINT_ASSERT(ast_pointer_type->Is<type::Pointer>());
+ TINT_ASSERT(ast_pointer_type->Is<sem::Pointer>());
current_expr = TypedExpression{ast_pointer_type, next_expr};
}
return current_expr;
@@ -3794,7 +3794,7 @@
}
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
- type::Bool bool_type;
+ sem::Bool bool_type;
return create<ast::ScalarConstructorExpression>(
source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
}
@@ -3815,8 +3815,8 @@
// Generate an ast::TypeConstructor expression.
// Assume the literal indices are valid, and there is a valid number of them.
auto source = GetSourceForInst(inst);
- type::Vector* result_type =
- parser_impl_.ConvertType(inst.type_id())->As<type::Vector>();
+ sem::Vector* result_type =
+ parser_impl_.ConvertType(inst.type_id())->As<sem::Vector>();
ast::ExpressionList values;
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
const auto index = inst.GetSingleWordInOperand(i);
@@ -3907,7 +3907,7 @@
if (type) {
if (type->AsPointer()) {
if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) {
- if (auto* ptr = ast_type->As<type::Pointer>()) {
+ if (auto* ptr = ast_type->As<sem::Pointer>()) {
info->storage_class = ptr->storage_class();
}
}
@@ -3952,21 +3952,21 @@
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
if (type_id) {
auto* ast_type = parser_impl_.ConvertType(type_id);
- if (ast_type && ast_type->Is<type::Pointer>()) {
- return ast_type->As<type::Pointer>()->storage_class();
+ if (ast_type && ast_type->Is<sem::Pointer>()) {
+ return ast_type->As<sem::Pointer>()->storage_class();
}
}
return ast::StorageClass::kNone;
}
-type::Type* FunctionEmitter::RemapStorageClass(type::Type* type,
- uint32_t result_id) {
- if (const auto* ast_ptr_type = type->As<type::Pointer>()) {
+sem::Type* FunctionEmitter::RemapStorageClass(sem::Type* type,
+ uint32_t result_id) {
+ if (const auto* ast_ptr_type = type->As<sem::Pointer>()) {
// Remap an old-style storage buffer pointer to a new-style storage
// buffer pointer.
const auto sc = GetStorageClassForPointerValue(result_id);
if (ast_ptr_type->storage_class() != sc) {
- return builder_.create<type::Pointer>(ast_ptr_type->type(), sc);
+ return builder_.create<sem::Pointer>(ast_ptr_type->type(), sc);
}
}
return type;
@@ -4149,7 +4149,7 @@
return {};
}
- type::Type* expr_type = nullptr;
+ sem::Type* expr_type = nullptr;
if ((opcode == SpvOpConvertSToF) || (opcode == SpvOpConvertUToF)) {
if (arg_expr.type->is_integer_scalar_or_vector()) {
expr_type = requested_type;
@@ -4214,7 +4214,7 @@
<< inst.PrettyPrint();
}
- if (result_type->Is<type::Void>()) {
+ if (result_type->Is<sem::Void>()) {
return nullptr !=
AddStatement(create<ast::CallStatement>(Source{}, call_expr));
}
@@ -4277,7 +4277,7 @@
Source{}, builder_.Symbols().Register(name));
ast::ExpressionList params;
- type::Type* first_operand_type = nullptr;
+ sem::Type* first_operand_type = nullptr;
for (uint32_t iarg = 0; iarg < inst.NumInOperands(); ++iarg) {
TypedExpression operand = MakeOperand(inst, iarg);
if (first_operand_type == nullptr) {
@@ -4309,8 +4309,8 @@
// - you can't select over pointers or pointer vectors, unless you also have
// a VariablePointers* capability, which is not allowed in by WebGPU.
auto* op_ty = operand1.type;
- if (op_ty->Is<type::Vector>() || op_ty->is_float_scalar() ||
- op_ty->is_integer_scalar() || op_ty->Is<type::Bool>()) {
+ if (op_ty->Is<sem::Vector>() || op_ty->is_float_scalar() ||
+ op_ty->is_integer_scalar() || op_ty->Is<sem::Bool>()) {
ast::ExpressionList params;
params.push_back(operand1.expr);
params.push_back(operand2.expr);
@@ -4348,18 +4348,18 @@
return image;
}
-type::Texture* FunctionEmitter::GetImageType(
+sem::Texture* FunctionEmitter::GetImageType(
const spvtools::opt::Instruction& image) {
- type::Pointer* ptr_type = parser_impl_.GetTypeForHandleVar(image);
+ sem::Pointer* ptr_type = parser_impl_.GetTypeForHandleVar(image);
if (!parser_impl_.success()) {
Fail();
return nullptr;
}
- if (!ptr_type || !ptr_type->type()->UnwrapAll()->Is<type::Texture>()) {
+ if (!ptr_type || !ptr_type->type()->UnwrapAll()->Is<sem::Texture>()) {
Fail() << "invalid texture type for " << image.PrettyPrint();
return nullptr;
}
- return As<type::Texture>(ptr_type->type()->UnwrapAll());
+ return As<sem::Texture>(ptr_type->type()->UnwrapAll());
}
ast::Expression* FunctionEmitter::GetImageExpression(
@@ -4409,12 +4409,12 @@
}
}
- type::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
+ sem::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
if (!texture_ptr_type) {
return Fail();
}
- type::Texture* texture_type =
- texture_ptr_type->type()->UnwrapAll()->As<type::Texture>();
+ sem::Texture* texture_type =
+ texture_ptr_type->type()->UnwrapAll()->As<sem::Texture>();
if (!texture_type) {
return Fail();
}
@@ -4516,7 +4516,7 @@
}
TypedExpression lod = MakeOperand(inst, arg_index);
// When sampling from a depth texture, the Lod operand must be an I32.
- if (texture_type->Is<type::DepthTexture>()) {
+ if (texture_type->Is<sem::DepthTexture>()) {
// Convert it to a signed integer type.
lod = ToI32(lod);
}
@@ -4524,8 +4524,8 @@
image_operands_mask ^= SpvImageOperandsLodMask;
arg_index++;
} else if ((opcode == SpvOpImageFetch) &&
- (texture_type->Is<type::SampledTexture>() ||
- texture_type->Is<type::DepthTexture>())) {
+ (texture_type->Is<sem::SampledTexture>() ||
+ texture_type->Is<sem::DepthTexture>())) {
// textureLoad on sampled texture and depth texture requires an explicit
// level-of-detail parameter.
params.push_back(parser_impl_.MakeNullValue(i32_));
@@ -4550,9 +4550,9 @@
<< inst.PrettyPrint();
}
switch (texture_type->dim()) {
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
+ case sem::TextureDimension::k3d:
break;
default:
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
@@ -4588,7 +4588,7 @@
// The result type, derived from the SPIR-V instruction.
auto* result_type = parser_impl_.ConvertType(inst.type_id());
auto* result_component_type = result_type;
- if (auto* result_vector_type = result_type->As<type::Vector>()) {
+ if (auto* result_vector_type = result_type->As<sem::Vector>()) {
result_component_type = result_vector_type->type();
}
@@ -4603,7 +4603,7 @@
// dref gather vec4 ImageFetch vec4 TODO(dneto)
// Construct a 4-element vector with the result from the builtin in the
// first component.
- if (texture_type->Is<type::DepthTexture>()) {
+ if (texture_type->Is<sem::DepthTexture>()) {
if (is_non_dref_sample || (opcode == SpvOpImageFetch)) {
value = create<ast::TypeConstructorExpression>(
Source{},
@@ -4631,7 +4631,7 @@
// or vice versa. Perform a bitcast.
value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
}
- if (!expected_component_type->Is<type::F32>() &&
+ if (!expected_component_type->Is<sem::F32>() &&
IsSampledImageAccess(opcode)) {
// WGSL permits sampled image access only on float textures.
// Reject this case in the SPIR-V reader, at least until SPIR-V validation
@@ -4675,7 +4675,7 @@
}
exprs.push_back(
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
- if (type::IsTextureArray(texture_type->dim())) {
+ if (sem::IsTextureArray(texture_type->dim())) {
auto* layers_ident = create<ast::IdentifierExpression>(
Source{}, builder_.Symbols().Register("textureNumLayers"));
exprs.push_back(create<ast::CallExpression>(
@@ -4750,14 +4750,14 @@
if (!raw_coords.type) {
return {};
}
- type::Texture* texture_type = GetImageType(*image);
+ sem::Texture* texture_type = GetImageType(*image);
if (!texture_type) {
return {};
}
- type::TextureDimension dim = texture_type->dim();
+ sem::TextureDimension dim = texture_type->dim();
// Number of regular coordinates.
- uint32_t num_axes = type::NumCoordinateAxes(dim);
- bool is_arrayed = type::IsTextureArray(dim);
+ uint32_t num_axes = sem::NumCoordinateAxes(dim);
+ bool is_arrayed = sem::IsTextureArray(dim);
if ((num_axes == 0) || (num_axes > 3)) {
Fail() << "unsupported image dimensionality for "
<< texture_type->type_name() << " prompted by "
@@ -4769,7 +4769,7 @@
if (component_type->is_float_scalar() ||
component_type->is_integer_scalar()) {
num_coords_supplied = 1;
- } else if (auto* vec_type = raw_coords.type->As<type::Vector>()) {
+ } else if (auto* vec_type = raw_coords.type->As<sem::Vector>()) {
component_type = vec_type->type();
num_coords_supplied = vec_type->size();
}
@@ -4796,7 +4796,7 @@
raw_coords]() -> ast::Expression* {
auto* swizzle_type = (num_axes == 1)
? component_type
- : create<type::Vector>(component_type, num_axes);
+ : create<sem::Vector>(component_type, num_axes);
auto* swizzle = create<ast::MemberAccessorExpression>(
Source{}, raw_coords.expr, PrefixSwizzle(num_axes));
return ToSignedIfUnsigned({swizzle_type, swizzle}).expr;
@@ -4830,8 +4830,8 @@
ast::Expression* FunctionEmitter::ConvertTexelForStorage(
const spvtools::opt::Instruction& inst,
TypedExpression texel,
- type::Texture* texture_type) {
- auto* storage_texture_type = texture_type->As<type::StorageTexture>();
+ sem::Texture* texture_type) {
+ auto* storage_texture_type = texture_type->As<sem::StorageTexture>();
auto* src_type = texel.type;
if (!storage_texture_type) {
Fail() << "writing to other than storage texture: " << inst.PrettyPrint();
@@ -4848,14 +4848,14 @@
}
const uint32_t dest_count =
- dest_type->is_scalar() ? 1 : dest_type->As<type::Vector>()->size();
+ dest_type->is_scalar() ? 1 : dest_type->As<sem::Vector>()->size();
if (dest_count == 3) {
Fail() << "3-channel storage textures are not supported: "
<< inst.PrettyPrint();
return nullptr;
}
const uint32_t src_count =
- src_type->is_scalar() ? 1 : src_type->As<type::Vector>()->size();
+ src_type->is_scalar() ? 1 : src_type->As<sem::Vector>()->size();
if (src_count < dest_count) {
Fail() << "texel has too few components for storage texture: " << src_count
<< " provided but " << dest_count
@@ -4925,8 +4925,8 @@
if (!value.type || !value.type->is_unsigned_scalar_or_vector()) {
return value;
}
- if (auto* vec_type = value.type->As<type::Vector>()) {
- auto* new_type = create<type::Vector>(i32_, vec_type->size());
+ if (auto* vec_type = value.type->As<sem::Vector>()) {
+ auto* new_type = create<sem::Vector>(i32_, vec_type->size());
return {new_type, create<ast::TypeConstructorExpression>(
Source{}, new_type, ast::ExpressionList{value.expr})};
}
@@ -4976,10 +4976,9 @@
// Synthesize the result.
auto col = MakeOperand(inst, 0);
auto row = MakeOperand(inst, 1);
- auto* col_ty = col.type->As<type::Vector>();
- auto* row_ty = row.type->As<type::Vector>();
- auto* result_ty =
- parser_impl_.ConvertType(inst.type_id())->As<type::Matrix>();
+ auto* col_ty = col.type->As<sem::Vector>();
+ auto* row_ty = row.type->As<sem::Vector>();
+ auto* result_ty = parser_impl_.ConvertType(inst.type_id())->As<sem::Matrix>();
if (!col_ty || !col_ty || !result_ty || result_ty->type() != col_ty->type() ||
result_ty->type() != row_ty->type() ||
result_ty->columns() != row_ty->size() ||
diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h
index f0517b2..778de9a 100644
--- a/src/reader/spirv/function.h
+++ b/src/reader/spirv/function.h
@@ -512,7 +512,7 @@
/// @param type the AST type
/// @param result_id the SPIR-V ID for the locally defined value
/// @returns an possibly updated type
- type::Type* RemapStorageClass(type::Type* type, uint32_t result_id);
+ sem::Type* RemapStorageClass(sem::Type* type, uint32_t result_id);
/// Marks locally defined values when they should get a 'const'
/// definition in WGSL, or a 'var' definition at an outer scope.
@@ -853,7 +853,7 @@
/// Function parameters
ast::VariableList params;
/// Function return type
- type::Type* return_type;
+ sem::Type* return_type;
/// Function decorations
ast::DecorationList decorations;
};
@@ -866,7 +866,7 @@
/// @returns the store type for the OpVariable instruction, or
/// null on failure.
- type::Type* GetVariableStoreType(
+ sem::Type* GetVariableStoreType(
const spvtools::opt::Instruction& var_decl_inst);
/// Returns an expression for an instruction operand. Signedness conversion is
@@ -934,7 +934,7 @@
/// Get the AST texture the SPIR-V image memory object declaration.
/// @param inst the SPIR-V memory object declaration for the image.
/// @returns a texture type, or null on error
- type::Texture* GetImageType(const spvtools::opt::Instruction& inst);
+ sem::Texture* GetImageType(const spvtools::opt::Instruction& inst);
/// Get the expression for the image operand from the first operand to the
/// given instruction.
@@ -971,7 +971,7 @@
ast::Expression* ConvertTexelForStorage(
const spvtools::opt::Instruction& inst,
TypedExpression texel,
- type::Texture* texture_type);
+ sem::Texture* texture_type);
/// Returns an expression for an OpSelect, if its operands are scalars
/// or vectors. These translate directly to WGSL select. Otherwise, return
@@ -1133,8 +1133,8 @@
FailStream& fail_stream_;
Namer& namer_;
const spvtools::opt::Function& function_;
- type::I32* const i32_; // The unique I32 type object.
- type::U32* const u32_; // The unique U32 type object.
+ sem::I32* const i32_; // The unique I32 type object.
+ sem::U32* const u32_; // The unique U32 type object.
// The SPIR-V ID for the SampleMask input variable.
uint32_t sample_mask_in_id;
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 8a17c3c..f031a0e 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -231,7 +231,7 @@
: Reader(),
spv_binary_(spv_binary),
fail_stream_(&success_, &errors_),
- bool_type_(builder_.create<type::Bool>()),
+ bool_type_(builder_.create<sem::Bool>()),
namer_(fail_stream_),
enum_converter_(fail_stream_),
tools_context_(kInputEnv) {
@@ -289,7 +289,7 @@
return tint::Program(std::move(builder_));
}
-type::Type* ParserImpl::ConvertType(uint32_t type_id) {
+sem::Type* ParserImpl::ConvertType(uint32_t type_id) {
if (!success_) {
return nullptr;
}
@@ -310,7 +310,7 @@
return nullptr;
}
- auto save = [this, type_id, spirv_type](type::Type* type) {
+ auto save = [this, type_id, spirv_type](sem::Type* type) {
if (type != nullptr) {
id_to_type_[type_id] = type;
MaybeGenerateAlias(type_id, spirv_type);
@@ -320,7 +320,7 @@
switch (spirv_type->kind()) {
case spvtools::opt::analysis::Type::kVoid:
- return save(builder_.create<type::Void>());
+ return save(builder_.create<sem::Void>());
case spvtools::opt::analysis::Type::kBool:
return save(bool_type_);
case spvtools::opt::analysis::Type::kInteger:
@@ -350,7 +350,7 @@
case spvtools::opt::analysis::Type::kImage:
// Fake it for sampler and texture types. These are handled in an
// entirely different way.
- return save(builder_.create<type::Void>());
+ return save(builder_.create<sem::Void>());
default:
break;
}
@@ -694,11 +694,11 @@
return success_;
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Integer* int_ty) {
if (int_ty->width() == 32) {
- type::Type* signed_ty = builder_.create<type::I32>();
- type::Type* unsigned_ty = builder_.create<type::U32>();
+ sem::Type* signed_ty = builder_.create<sem::I32>();
+ sem::Type* unsigned_ty = builder_.create<sem::U32>();
signed_type_for_[unsigned_ty] = signed_ty;
unsigned_type_for_[signed_ty] = unsigned_ty;
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
@@ -707,39 +707,39 @@
return nullptr;
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Float* float_ty) {
if (float_ty->width() == 32) {
- return builder_.create<type::F32>();
+ return builder_.create<sem::F32>();
}
Fail() << "unhandled float width: " << float_ty->width();
return nullptr;
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Vector* vec_ty) {
const auto num_elem = vec_ty->element_count();
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(vec_ty->element_type()));
if (ast_elem_ty == nullptr) {
return nullptr;
}
- auto* this_ty = builder_.create<type::Vector>(ast_elem_ty, num_elem);
+ auto* this_ty = builder_.create<sem::Vector>(ast_elem_ty, num_elem);
// Generate the opposite-signedness vector type, if this type is integral.
if (unsigned_type_for_.count(ast_elem_ty)) {
- auto* other_ty = builder_.create<type::Vector>(
- unsigned_type_for_[ast_elem_ty], num_elem);
+ auto* other_ty =
+ builder_.create<sem::Vector>(unsigned_type_for_[ast_elem_ty], num_elem);
signed_type_for_[other_ty] = this_ty;
unsigned_type_for_[this_ty] = other_ty;
} else if (signed_type_for_.count(ast_elem_ty)) {
auto* other_ty =
- builder_.create<type::Vector>(signed_type_for_[ast_elem_ty], num_elem);
+ builder_.create<sem::Vector>(signed_type_for_[ast_elem_ty], num_elem);
unsigned_type_for_[other_ty] = this_ty;
signed_type_for_[this_ty] = other_ty;
}
return this_ty;
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Matrix* mat_ty) {
const auto* vec_ty = mat_ty->element_type()->AsVector();
const auto* scalar_ty = vec_ty->element_type();
@@ -749,10 +749,10 @@
if (ast_scalar_ty == nullptr) {
return nullptr;
}
- return builder_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
+ return builder_.create<sem::Matrix>(ast_scalar_ty, num_rows, num_columns);
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::RuntimeArray* rtarr_ty) {
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(rtarr_ty->element_type()));
if (ast_elem_ty == nullptr) {
@@ -762,10 +762,10 @@
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
return nullptr;
}
- return create<type::ArrayType>(ast_elem_ty, 0, std::move(decorations));
+ return create<sem::ArrayType>(ast_elem_ty, 0, std::move(decorations));
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Array* arr_ty) {
const auto elem_type_id = type_mgr_->GetId(arr_ty->element_type());
auto* ast_elem_ty = ConvertType(elem_type_id);
@@ -807,8 +807,8 @@
if (remap_buffer_block_type_.count(elem_type_id)) {
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
}
- return create<type::ArrayType>(ast_elem_ty, static_cast<uint32_t>(num_elem),
- std::move(decorations));
+ return create<sem::ArrayType>(ast_elem_ty, static_cast<uint32_t>(num_elem),
+ std::move(decorations));
}
bool ParserImpl::ParseArrayDecorations(
@@ -840,7 +840,7 @@
return true;
}
-type::Type* ParserImpl::ConvertType(
+sem::Type* ParserImpl::ConvertType(
uint32_t type_id,
const spvtools::opt::analysis::Struct* struct_ty) {
// Compute the struct decoration.
@@ -947,7 +947,7 @@
namer_.SuggestSanitizedName(type_id, "S");
auto name = namer_.GetName(type_id);
- auto* result = builder_.create<type::StructType>(
+ auto* result = builder_.create<sem::StructType>(
builder_.Symbols().Register(name), ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
@@ -957,8 +957,8 @@
return result;
}
-type::Type* ParserImpl::ConvertType(uint32_t type_id,
- const spvtools::opt::analysis::Pointer*) {
+sem::Type* ParserImpl::ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Pointer*) {
const auto* inst = def_use_mgr_->GetDef(type_id);
const auto pointee_type_id = inst->GetSingleWordInOperand(1);
const auto storage_class = SpvStorageClass(inst->GetSingleWordInOperand(0));
@@ -987,7 +987,7 @@
ast_storage_class = ast::StorageClass::kStorage;
remap_buffer_block_type_.insert(type_id);
}
- return builder_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
+ return builder_.create<sem::Pointer>(ast_elem_ty, ast_storage_class);
}
bool ParserImpl::RegisterTypes() {
@@ -1020,7 +1020,7 @@
// that is OpSpecConstantTrue, OpSpecConstantFalse, or OpSpecConstant.
for (auto& inst : module_->types_values()) {
// These will be populated for a valid scalar spec constant.
- type::Type* ast_type = nullptr;
+ sem::Type* ast_type = nullptr;
ast::ScalarConstructorExpression* ast_expr = nullptr;
switch (inst.opcode()) {
@@ -1036,17 +1036,17 @@
case SpvOpSpecConstant: {
ast_type = ConvertType(inst.type_id());
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
- if (ast_type->Is<type::I32>()) {
+ if (ast_type->Is<sem::I32>()) {
ast_expr = create<ast::ScalarConstructorExpression>(
Source{},
create<ast::SintLiteral>(Source{}, ast_type,
static_cast<int32_t>(literal_value)));
- } else if (ast_type->Is<type::U32>()) {
+ } else if (ast_type->Is<sem::U32>()) {
ast_expr = create<ast::ScalarConstructorExpression>(
Source{},
create<ast::UintLiteral>(Source{}, ast_type,
static_cast<uint32_t>(literal_value)));
- } else if (ast_type->Is<type::F32>()) {
+ } else if (ast_type->Is<sem::F32>()) {
float float_value;
// Copy the bits so we can read them as a float.
std::memcpy(&float_value, &literal_value, sizeof(float_value));
@@ -1113,7 +1113,7 @@
return;
}
const auto name = namer_.GetName(type_id);
- auto* ast_alias_type = builder_.create<type::Alias>(
+ auto* ast_alias_type = builder_.create<sem::Alias>(
builder_.Symbols().Register(name), ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
@@ -1158,7 +1158,7 @@
if (!success_) {
return false;
}
- type::Type* ast_type = nullptr;
+ sem::Type* ast_type = nullptr;
if (spirv_storage_class == SpvStorageClassUniformConstant) {
// These are opaque handles: samplers or textures
ast_type = GetTypeForHandleVar(var);
@@ -1172,14 +1172,14 @@
"SPIR-V type with ID: "
<< var.type_id();
}
- if (!ast_type->Is<type::Pointer>()) {
+ if (!ast_type->Is<sem::Pointer>()) {
return Fail() << "variable with ID " << var.result_id()
<< " has non-pointer type " << var.type_id();
}
}
- auto* ast_store_type = ast_type->As<type::Pointer>()->type();
- auto ast_storage_class = ast_type->As<type::Pointer>()->storage_class();
+ auto* ast_store_type = ast_type->As<sem::Pointer>()->type();
+ auto ast_storage_class = ast_type->As<sem::Pointer>()->storage_class();
ast::Expression* ast_constructor = nullptr;
if (var.NumInOperands() > 1) {
// SPIR-V initializers are always constants.
@@ -1242,7 +1242,7 @@
ast::Variable* ParserImpl::MakeVariable(uint32_t id,
ast::StorageClass sc,
- type::Type* type,
+ sem::Type* type,
bool is_const,
ast::Expression* constructor,
ast::DecorationList decorations) {
@@ -1256,7 +1256,7 @@
auto access = read_only_struct_types_.count(type)
? ast::AccessControl::kReadOnly
: ast::AccessControl::kReadWrite;
- type = builder_.create<type::AccessControl>(access, type);
+ type = builder_.create<sem::AccessControl>(access, type);
}
for (auto& deco : GetDecorationsFor(id)) {
@@ -1298,7 +1298,7 @@
"SampleMask must be an array of 1 element.";
}
special_builtins_[id] = spv_builtin;
- type = builder_.create<type::U32>();
+ type = builder_.create<sem::U32>();
break;
}
default:
@@ -1382,25 +1382,25 @@
// So canonicalization should map that way too.
// Currently "null<type>" is missing from the WGSL parser.
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
- if (ast_type->Is<type::U32>()) {
+ if (ast_type->Is<sem::U32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::UintLiteral>(source, ast_type,
spirv_const->GetU32()))};
}
- if (ast_type->Is<type::I32>()) {
+ if (ast_type->Is<sem::I32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(source, ast_type,
spirv_const->GetS32()))};
}
- if (ast_type->Is<type::F32>()) {
+ if (ast_type->Is<sem::F32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(source, ast_type,
spirv_const->GetFloat()))};
}
- if (ast_type->Is<type::Bool>()) {
+ if (ast_type->Is<sem::Bool>()) {
const bool value = spirv_const->AsNullConstant()
? false
: spirv_const->AsBoolConstant()->value();
@@ -1444,7 +1444,7 @@
return {};
}
-ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
+ast::Expression* ParserImpl::MakeNullValue(sem::Type* type) {
// TODO(dneto): Use the no-operands constructor syntax when it becomes
// available in Tint.
// https://github.com/gpuweb/gpuweb/issues/685
@@ -1458,23 +1458,23 @@
auto* original_type = type;
type = type->UnwrapIfNeeded();
- if (type->Is<type::Bool>()) {
+ if (type->Is<sem::Bool>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, type, false));
}
- if (type->Is<type::U32>()) {
+ if (type->Is<sem::U32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
}
- if (type->Is<type::I32>()) {
+ if (type->Is<sem::I32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, type, 0));
}
- if (type->Is<type::F32>()) {
+ if (type->Is<sem::F32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
}
- if (const auto* vec_ty = type->As<type::Vector>()) {
+ if (const auto* vec_ty = type->As<sem::Vector>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < vec_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
@@ -1482,10 +1482,10 @@
return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
- if (const auto* mat_ty = type->As<type::Matrix>()) {
+ if (const auto* mat_ty = type->As<sem::Matrix>()) {
// Matrix components are columns
auto* column_ty =
- builder_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
+ builder_.create<sem::Vector>(mat_ty->type(), mat_ty->rows());
ast::ExpressionList ast_components;
for (size_t i = 0; i < mat_ty->columns(); ++i) {
ast_components.emplace_back(MakeNullValue(column_ty));
@@ -1493,7 +1493,7 @@
return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
- if (auto* arr_ty = type->As<type::ArrayType>()) {
+ if (auto* arr_ty = type->As<sem::ArrayType>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
@@ -1501,7 +1501,7 @@
return create<ast::TypeConstructorExpression>(Source{}, original_type,
std::move(ast_components));
}
- if (auto* struct_ty = type->As<type::StructType>()) {
+ if (auto* struct_ty = type->As<sem::StructType>()) {
ast::ExpressionList ast_components;
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
@@ -1513,7 +1513,7 @@
return nullptr;
}
-TypedExpression ParserImpl::MakeNullExpression(type::Type* type) {
+TypedExpression ParserImpl::MakeNullExpression(sem::Type* type) {
return {type, MakeNullValue(type)};
}
@@ -1567,7 +1567,7 @@
TypedExpression ParserImpl::RectifySecondOperandSignedness(
const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type,
+ sem::Type* first_operand_type,
TypedExpression&& second_operand_expr) {
if ((first_operand_type != second_operand_expr.type) &&
AssumesSecondOperandSignednessMatchesFirstOperand(inst.opcode())) {
@@ -1580,8 +1580,8 @@
return std::move(second_operand_expr);
}
-type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type) {
+sem::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
+ sem::Type* first_operand_type) {
const auto opcode = inst.opcode();
if (AssumesResultSignednessMatchesFirstOperand(opcode)) {
return first_operand_type;
@@ -1596,36 +1596,34 @@
return nullptr;
}
-type::Type* ParserImpl::GetSignedIntMatchingShape(type::Type* other) {
+sem::Type* ParserImpl::GetSignedIntMatchingShape(sem::Type* other) {
if (other == nullptr) {
Fail() << "no type provided";
}
- auto* i32 = builder_.create<type::I32>();
- if (other->Is<type::F32>() || other->Is<type::U32>() ||
- other->Is<type::I32>()) {
+ auto* i32 = builder_.create<sem::I32>();
+ if (other->Is<sem::F32>() || other->Is<sem::U32>() || other->Is<sem::I32>()) {
return i32;
}
- auto* vec_ty = other->As<type::Vector>();
+ auto* vec_ty = other->As<sem::Vector>();
if (vec_ty) {
- return builder_.create<type::Vector>(i32, vec_ty->size());
+ return builder_.create<sem::Vector>(i32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
}
-type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
+sem::Type* ParserImpl::GetUnsignedIntMatchingShape(sem::Type* other) {
if (other == nullptr) {
Fail() << "no type provided";
return nullptr;
}
- auto* u32 = builder_.create<type::U32>();
- if (other->Is<type::F32>() || other->Is<type::U32>() ||
- other->Is<type::I32>()) {
+ auto* u32 = builder_.create<sem::U32>();
+ if (other->Is<sem::F32>() || other->Is<sem::U32>() || other->Is<sem::I32>()) {
return u32;
}
- auto* vec_ty = other->As<type::Vector>();
+ auto* vec_ty = other->As<sem::Vector>();
if (vec_ty) {
- return builder_.create<type::Vector>(u32, vec_ty->size());
+ return builder_.create<sem::Vector>(u32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1634,7 +1632,7 @@
TypedExpression ParserImpl::RectifyForcedResultType(
TypedExpression expr,
const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type) {
+ sem::Type* first_operand_type) {
auto* forced_result_ty = ForcedResultType(inst, first_operand_type);
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
return expr;
@@ -1813,7 +1811,7 @@
return raw_handle_type;
}
-type::Pointer* ParserImpl::GetTypeForHandleVar(
+sem::Pointer* ParserImpl::GetTypeForHandleVar(
const spvtools::opt::Instruction& var) {
auto where = handle_type_.find(&var);
if (where != handle_type_.end()) {
@@ -1897,11 +1895,11 @@
}
// Construct the Tint handle type.
- type::Type* ast_store_type = nullptr;
+ sem::Type* ast_store_type = nullptr;
if (usage.IsSampler()) {
- ast_store_type = builder_.create<type::Sampler>(
- usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
- : type::SamplerKind::kSampler);
+ ast_store_type = builder_.create<sem::Sampler>(
+ usage.IsComparisonSampler() ? sem::SamplerKind::kComparisonSampler
+ : sem::SamplerKind::kSampler);
} else if (usage.IsTexture()) {
const spvtools::opt::analysis::Image* image_type =
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
@@ -1911,9 +1909,9 @@
return nullptr;
}
- const type::TextureDimension dim =
+ const sem::TextureDimension dim =
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
- if (dim == type::TextureDimension::kNone) {
+ if (dim == sem::TextureDimension::kNone) {
return nullptr;
}
@@ -1930,13 +1928,13 @@
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
// treat that as a depth texture.
if (image_type->depth() || usage.IsDepthTexture()) {
- ast_store_type = builder_.create<type::DepthTexture>(dim);
+ ast_store_type = builder_.create<sem::DepthTexture>(dim);
} else if (image_type->is_multisampled()) {
// Multisampled textures are never depth textures.
- ast_store_type = builder_.create<type::MultisampledTexture>(
+ ast_store_type = builder_.create<sem::MultisampledTexture>(
dim, ast_sampled_component_type);
} else {
- ast_store_type = builder_.create<type::SampledTexture>(
+ ast_store_type = builder_.create<sem::SampledTexture>(
dim, ast_sampled_component_type);
}
} else {
@@ -1944,13 +1942,12 @@
? ast::AccessControl::kReadOnly
: ast::AccessControl::kWriteOnly;
const auto format = enum_converter_.ToImageFormat(image_type->format());
- if (format == type::ImageFormat::kNone) {
+ if (format == sem::ImageFormat::kNone) {
return nullptr;
}
- auto* subtype =
- type::StorageTexture::SubtypeFor(format, builder_.Types());
- ast_store_type = builder_.create<type::AccessControl>(
- access, builder_.create<type::StorageTexture>(dim, format, subtype));
+ auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types());
+ ast_store_type = builder_.create<sem::AccessControl>(
+ access, builder_.create<sem::StorageTexture>(dim, format, subtype));
}
} else {
Fail() << "unsupported: UniformConstant variable is not a recognized "
@@ -1960,55 +1957,55 @@
}
// Form the pointer type.
- auto* result = builder_.create<type::Pointer>(
+ auto* result = builder_.create<sem::Pointer>(
ast_store_type, ast::StorageClass::kUniformConstant);
// Remember it for later.
handle_type_[&var] = result;
return result;
}
-type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
+sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
switch (format) {
- case type::ImageFormat::kR8Uint:
- case type::ImageFormat::kR16Uint:
- case type::ImageFormat::kRg8Uint:
- case type::ImageFormat::kR32Uint:
- case type::ImageFormat::kRg16Uint:
- case type::ImageFormat::kRgba8Uint:
- case type::ImageFormat::kRg32Uint:
- case type::ImageFormat::kRgba16Uint:
- case type::ImageFormat::kRgba32Uint:
- return builder_.create<type::U32>();
+ case sem::ImageFormat::kR8Uint:
+ case sem::ImageFormat::kR16Uint:
+ case sem::ImageFormat::kRg8Uint:
+ case sem::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kRg16Uint:
+ case sem::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kRgba32Uint:
+ return builder_.create<sem::U32>();
- case type::ImageFormat::kR8Sint:
- case type::ImageFormat::kR16Sint:
- case type::ImageFormat::kRg8Sint:
- case type::ImageFormat::kR32Sint:
- case type::ImageFormat::kRg16Sint:
- case type::ImageFormat::kRgba8Sint:
- case type::ImageFormat::kRg32Sint:
- case type::ImageFormat::kRgba16Sint:
- case type::ImageFormat::kRgba32Sint:
- return builder_.create<type::I32>();
+ case sem::ImageFormat::kR8Sint:
+ case sem::ImageFormat::kR16Sint:
+ case sem::ImageFormat::kRg8Sint:
+ case sem::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kRg16Sint:
+ case sem::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kRgba32Sint:
+ return builder_.create<sem::I32>();
- case type::ImageFormat::kR8Unorm:
- case type::ImageFormat::kRg8Unorm:
- case type::ImageFormat::kRgba8Unorm:
- case type::ImageFormat::kRgba8UnormSrgb:
- case type::ImageFormat::kBgra8Unorm:
- case type::ImageFormat::kBgra8UnormSrgb:
- case type::ImageFormat::kRgb10A2Unorm:
- case type::ImageFormat::kR8Snorm:
- case type::ImageFormat::kRg8Snorm:
- case type::ImageFormat::kRgba8Snorm:
- case type::ImageFormat::kR16Float:
- case type::ImageFormat::kR32Float:
- case type::ImageFormat::kRg16Float:
- case type::ImageFormat::kRg11B10Float:
- case type::ImageFormat::kRg32Float:
- case type::ImageFormat::kRgba16Float:
- case type::ImageFormat::kRgba32Float:
- return builder_.create<type::F32>();
+ case sem::ImageFormat::kR8Unorm:
+ case sem::ImageFormat::kRg8Unorm:
+ case sem::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8UnormSrgb:
+ case sem::ImageFormat::kBgra8Unorm:
+ case sem::ImageFormat::kBgra8UnormSrgb:
+ case sem::ImageFormat::kRgb10A2Unorm:
+ case sem::ImageFormat::kR8Snorm:
+ case sem::ImageFormat::kRg8Snorm:
+ case sem::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kR16Float:
+ case sem::ImageFormat::kR32Float:
+ case sem::ImageFormat::kRg16Float:
+ case sem::ImageFormat::kRg11B10Float:
+ case sem::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kRgba32Float:
+ return builder_.create<sem::F32>();
default:
break;
}
@@ -2016,56 +2013,56 @@
return nullptr;
}
-type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
+sem::Type* ParserImpl::GetTexelTypeForFormat(sem::ImageFormat format) {
auto* component_type = GetComponentTypeForFormat(format);
if (!component_type) {
return nullptr;
}
switch (format) {
- case type::ImageFormat::kR16Float:
- case type::ImageFormat::kR16Sint:
- case type::ImageFormat::kR16Uint:
- case type::ImageFormat::kR32Float:
- case type::ImageFormat::kR32Sint:
- case type::ImageFormat::kR32Uint:
- case type::ImageFormat::kR8Sint:
- case type::ImageFormat::kR8Snorm:
- case type::ImageFormat::kR8Uint:
- case type::ImageFormat::kR8Unorm:
+ case sem::ImageFormat::kR16Float:
+ case sem::ImageFormat::kR16Sint:
+ case sem::ImageFormat::kR16Uint:
+ case sem::ImageFormat::kR32Float:
+ case sem::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kR8Sint:
+ case sem::ImageFormat::kR8Snorm:
+ case sem::ImageFormat::kR8Uint:
+ case sem::ImageFormat::kR8Unorm:
// One channel
return component_type;
- case type::ImageFormat::kRg11B10Float:
- case type::ImageFormat::kRg16Float:
- case type::ImageFormat::kRg16Sint:
- case type::ImageFormat::kRg16Uint:
- case type::ImageFormat::kRg32Float:
- case type::ImageFormat::kRg32Sint:
- case type::ImageFormat::kRg32Uint:
- case type::ImageFormat::kRg8Sint:
- case type::ImageFormat::kRg8Snorm:
- case type::ImageFormat::kRg8Uint:
- case type::ImageFormat::kRg8Unorm:
+ case sem::ImageFormat::kRg11B10Float:
+ case sem::ImageFormat::kRg16Float:
+ case sem::ImageFormat::kRg16Sint:
+ case sem::ImageFormat::kRg16Uint:
+ case sem::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRg8Sint:
+ case sem::ImageFormat::kRg8Snorm:
+ case sem::ImageFormat::kRg8Uint:
+ case sem::ImageFormat::kRg8Unorm:
// Two channels
- return builder_.create<type::Vector>(component_type, 2);
+ return builder_.create<sem::Vector>(component_type, 2);
- case type::ImageFormat::kBgra8Unorm:
- case type::ImageFormat::kBgra8UnormSrgb:
- case type::ImageFormat::kRgb10A2Unorm:
- case type::ImageFormat::kRgba16Float:
- case type::ImageFormat::kRgba16Sint:
- case type::ImageFormat::kRgba16Uint:
- case type::ImageFormat::kRgba32Float:
- case type::ImageFormat::kRgba32Sint:
- case type::ImageFormat::kRgba32Uint:
- case type::ImageFormat::kRgba8Sint:
- case type::ImageFormat::kRgba8Snorm:
- case type::ImageFormat::kRgba8Uint:
- case type::ImageFormat::kRgba8Unorm:
- case type::ImageFormat::kRgba8UnormSrgb:
+ case sem::ImageFormat::kBgra8Unorm:
+ case sem::ImageFormat::kBgra8UnormSrgb:
+ case sem::ImageFormat::kRgb10A2Unorm:
+ case sem::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kRgba32Float:
+ case sem::ImageFormat::kRgba32Sint:
+ case sem::ImageFormat::kRgba32Uint:
+ case sem::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8UnormSrgb:
// Four channels
- return builder_.create<type::Vector>(component_type, 4);
+ return builder_.create<sem::Vector>(component_type, 4);
default:
break;
diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h
index d645b8c..3eeee28 100644
--- a/src/reader/spirv/parser_impl.h
+++ b/src/reader/spirv/parser_impl.h
@@ -61,7 +61,7 @@
/// An AST expression with its type.
struct TypedExpression {
/// The type
- type::Type* type = nullptr;
+ sem::Type* type = nullptr;
/// The expression
ast::Expression* expr = nullptr;
};
@@ -132,7 +132,7 @@
/// after the internal representation of the module has been built.
/// @param type_id the SPIR-V ID of a type.
/// @returns a Tint type, or nullptr
- type::Type* ConvertType(uint32_t type_id);
+ sem::Type* ConvertType(uint32_t type_id);
/// Emits an alias type declaration for the given type, if necessary, and
/// also updates the mapping of the SPIR-V type ID to the alias type.
@@ -294,7 +294,7 @@
/// in the error case
ast::Variable* MakeVariable(uint32_t id,
ast::StorageClass sc,
- type::Type* type,
+ sem::Type* type,
bool is_const,
ast::Expression* constructor,
ast::DecorationList decorations);
@@ -307,12 +307,12 @@
/// Creates an AST expression node for the null value for the given type.
/// @param type the AST type
/// @returns a new expression
- ast::Expression* MakeNullValue(type::Type* type);
+ ast::Expression* MakeNullValue(sem::Type* type);
/// Make a typed expression for the null value for the given type.
/// @param type the AST type
/// @returns a new typed expression
- TypedExpression MakeNullExpression(type::Type* type);
+ TypedExpression MakeNullExpression(sem::Type* type);
/// Converts a given expression to the signedness demanded for an operand
/// of the given SPIR-V instruction, if required. If the instruction assumes
@@ -337,7 +337,7 @@
/// @returns second_operand_expr, or a cast of it
TypedExpression RectifySecondOperandSignedness(
const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type,
+ sem::Type* first_operand_type,
TypedExpression&& second_operand_expr);
/// Returns the "forced" result type for the given SPIR-V instruction.
@@ -348,8 +348,8 @@
/// @param inst the SPIR-V instruction
/// @param first_operand_type the AST type for the first operand.
/// @returns the forced AST result type, or nullptr if no forcing is required.
- type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type);
+ sem::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
+ sem::Type* first_operand_type);
/// Returns a signed integer scalar or vector type matching the shape (scalar,
/// vector, and component bit width) of another type, which itself is a
@@ -357,7 +357,7 @@
/// requirement.
/// @param other the type whose shape must be matched
/// @returns the signed scalar or vector type
- type::Type* GetSignedIntMatchingShape(type::Type* other);
+ sem::Type* GetSignedIntMatchingShape(sem::Type* other);
/// Returns a signed integer scalar or vector type matching the shape (scalar,
/// vector, and component bit width) of another type, which itself is a
@@ -365,7 +365,7 @@
/// requirement.
/// @param other the type whose shape must be matched
/// @returns the unsigned scalar or vector type
- type::Type* GetUnsignedIntMatchingShape(type::Type* other);
+ sem::Type* GetUnsignedIntMatchingShape(sem::Type* other);
/// Wraps the given expression in an as-cast to the given expression's type,
/// when the underlying operation produces a forced result type different
@@ -378,10 +378,10 @@
TypedExpression RectifyForcedResultType(
TypedExpression expr,
const spvtools::opt::Instruction& inst,
- type::Type* first_operand_type);
+ sem::Type* first_operand_type);
/// @returns the registered boolean type.
- type::Type* Bool() const { return bool_type_; }
+ sem::Type* Bool() const { return bool_type_; }
/// Bookkeeping used for tracking the "position" builtin variable.
struct BuiltInPositionInfo {
@@ -469,18 +469,18 @@
/// @param var the OpVariable instruction
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
/// error
- type::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
+ sem::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
/// Returns the channel component type corresponding to the given image
/// format.
/// @param format image texel format
/// @returns the component type, one of f32, i32, u32
- type::Type* GetComponentTypeForFormat(type::ImageFormat format);
+ sem::Type* GetComponentTypeForFormat(sem::ImageFormat format);
/// Returns texel type corresponding to the given image format.
/// @param format image texel format
/// @returns the texel format
- type::Type* GetTexelTypeForFormat(type::ImageFormat format);
+ sem::Type* GetTexelTypeForFormat(sem::ImageFormat format);
/// Returns the SPIR-V instruction with the given ID, or nullptr.
/// @param id the SPIR-V result ID
@@ -509,20 +509,19 @@
private:
/// Converts a specific SPIR-V type to a Tint type. Integer case
- type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
/// Converts a specific SPIR-V type to a Tint type. Float case
- type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
/// Converts a specific SPIR-V type to a Tint type. Vector case
- type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
/// Converts a specific SPIR-V type to a Tint type. Matrix case
- type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
/// Converts a specific SPIR-V type to a Tint type. RuntimeArray case
/// @param rtarr_ty the Tint type
- type::Type* ConvertType(
- const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
/// Converts a specific SPIR-V type to a Tint type. Array case
/// @param arr_ty the Tint type
- type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
+ sem::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
/// Converts a specific SPIR-V type to a Tint type. Struct case.
/// SPIR-V allows distinct struct type definitions for two OpTypeStruct
/// that otherwise have the same set of members (and struct and member
@@ -534,15 +533,15 @@
/// not significant to the optimizer's module representation.
/// @param type_id the SPIR-V ID for the type.
/// @param struct_ty the Tint type
- type::Type* ConvertType(uint32_t type_id,
- const spvtools::opt::analysis::Struct* struct_ty);
+ sem::Type* ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Struct* struct_ty);
/// Converts a specific SPIR-V type to a Tint type. Pointer case
/// The pointer to gl_PerVertex maps to nullptr, and instead is recorded
/// in member #builtin_position_.
/// @param type_id the SPIR-V ID for the type.
/// @param ptr_ty the Tint type
- type::Type* ConvertType(uint32_t type_id,
- const spvtools::opt::analysis::Pointer* ptr_ty);
+ sem::Type* ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Pointer* ptr_ty);
/// Parses the array or runtime-array decorations.
/// @param spv_type the SPIR-V array or runtime-array type.
@@ -573,7 +572,7 @@
spvtools::MessageConsumer message_consumer_;
// The registered boolean type.
- type::Type* bool_type_;
+ sem::Type* bool_type_;
// An object used to store and generate names for SPIR-V objects.
Namer namer_;
@@ -609,12 +608,12 @@
std::unordered_set<uint32_t> ignored_imports_;
// Maps a SPIR-V type ID to the corresponding Tint type.
- std::unordered_map<uint32_t, type::Type*> id_to_type_;
+ std::unordered_map<uint32_t, sem::Type*> id_to_type_;
// Maps an unsigned type corresponding to the given signed type.
- std::unordered_map<type::Type*, type::Type*> signed_type_for_;
+ std::unordered_map<sem::Type*, sem::Type*> signed_type_for_;
// Maps an signed type corresponding to the given unsigned type.
- std::unordered_map<type::Type*, type::Type*> unsigned_type_for_;
+ std::unordered_map<sem::Type*, sem::Type*> unsigned_type_for_;
// Bookkeeping for the gl_Position builtin.
// In Vulkan SPIR-V, it's the 0 member of the gl_PerVertex structure.
@@ -634,7 +633,7 @@
std::unordered_set<uint32_t> remap_buffer_block_type_;
// The struct types with only read-only members.
- std::unordered_set<type::Type*> read_only_struct_types_;
+ std::unordered_set<sem::Type*> read_only_struct_types_;
// The IDs of scalar spec constants
std::unordered_set<uint32_t> scalar_spec_constants_;
@@ -659,7 +658,7 @@
// usages implied by usages of the memory-object-declaration.
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
// The inferred pointer type for the given handle variable.
- std::unordered_map<const spvtools::opt::Instruction*, type::Pointer*>
+ std::unordered_map<const spvtools::opt::Instruction*, sem::Pointer*>
handle_type_;
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc
index 17600dd..5957329 100644
--- a/src/reader/spirv/parser_impl_convert_type_test.cc
+++ b/src/reader/spirv/parser_impl_convert_type_test.cc
@@ -75,7 +75,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<type::Void>());
+ EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -84,7 +84,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(100);
- EXPECT_TRUE(type->Is<type::Bool>());
+ EXPECT_TRUE(type->Is<sem::Bool>());
EXPECT_TRUE(p->error().empty());
}
@@ -93,7 +93,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(2);
- EXPECT_TRUE(type->Is<type::I32>());
+ EXPECT_TRUE(type->Is<sem::I32>());
EXPECT_TRUE(p->error().empty());
}
@@ -102,7 +102,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::U32>());
+ EXPECT_TRUE(type->Is<sem::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -111,7 +111,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(4);
- EXPECT_TRUE(type->Is<type::F32>());
+ EXPECT_TRUE(type->Is<sem::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -155,19 +155,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xf32 = p->ConvertType(20);
- EXPECT_TRUE(v2xf32->Is<type::Vector>());
- EXPECT_TRUE(v2xf32->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(v2xf32->As<type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xf32->Is<sem::Vector>());
+ EXPECT_TRUE(v2xf32->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(v2xf32->As<sem::Vector>()->size(), 2u);
auto* v3xf32 = p->ConvertType(30);
- EXPECT_TRUE(v3xf32->Is<type::Vector>());
- EXPECT_TRUE(v3xf32->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(v3xf32->As<type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xf32->Is<sem::Vector>());
+ EXPECT_TRUE(v3xf32->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(v3xf32->As<sem::Vector>()->size(), 3u);
auto* v4xf32 = p->ConvertType(40);
- EXPECT_TRUE(v4xf32->Is<type::Vector>());
- EXPECT_TRUE(v4xf32->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(v4xf32->As<type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xf32->Is<sem::Vector>());
+ EXPECT_TRUE(v4xf32->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(v4xf32->As<sem::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -182,19 +182,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xi32 = p->ConvertType(20);
- EXPECT_TRUE(v2xi32->Is<type::Vector>());
- EXPECT_TRUE(v2xi32->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(v2xi32->As<type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xi32->Is<sem::Vector>());
+ EXPECT_TRUE(v2xi32->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(v2xi32->As<sem::Vector>()->size(), 2u);
auto* v3xi32 = p->ConvertType(30);
- EXPECT_TRUE(v3xi32->Is<type::Vector>());
- EXPECT_TRUE(v3xi32->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(v3xi32->As<type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xi32->Is<sem::Vector>());
+ EXPECT_TRUE(v3xi32->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(v3xi32->As<sem::Vector>()->size(), 3u);
auto* v4xi32 = p->ConvertType(40);
- EXPECT_TRUE(v4xi32->Is<type::Vector>());
- EXPECT_TRUE(v4xi32->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(v4xi32->As<type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xi32->Is<sem::Vector>());
+ EXPECT_TRUE(v4xi32->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(v4xi32->As<sem::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -209,19 +209,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xu32 = p->ConvertType(20);
- EXPECT_TRUE(v2xu32->Is<type::Vector>());
- EXPECT_TRUE(v2xu32->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(v2xu32->As<type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xu32->Is<sem::Vector>());
+ EXPECT_TRUE(v2xu32->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(v2xu32->As<sem::Vector>()->size(), 2u);
auto* v3xu32 = p->ConvertType(30);
- EXPECT_TRUE(v3xu32->Is<type::Vector>());
- EXPECT_TRUE(v3xu32->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(v3xu32->As<type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xu32->Is<sem::Vector>());
+ EXPECT_TRUE(v3xu32->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(v3xu32->As<sem::Vector>()->size(), 3u);
auto* v4xu32 = p->ConvertType(40);
- EXPECT_TRUE(v4xu32->Is<type::Vector>());
- EXPECT_TRUE(v4xu32->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(v4xu32->As<type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xu32->Is<sem::Vector>());
+ EXPECT_TRUE(v4xu32->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(v4xu32->As<sem::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -261,58 +261,58 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* m22 = p->ConvertType(22);
- EXPECT_TRUE(m22->Is<type::Matrix>());
- EXPECT_TRUE(m22->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m22->As<type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m22->As<type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m22->Is<sem::Matrix>());
+ EXPECT_TRUE(m22->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m22->As<sem::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m22->As<sem::Matrix>()->columns(), 2u);
auto* m23 = p->ConvertType(23);
- EXPECT_TRUE(m23->Is<type::Matrix>());
- EXPECT_TRUE(m23->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m23->As<type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m23->As<type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m23->Is<sem::Matrix>());
+ EXPECT_TRUE(m23->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m23->As<sem::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m23->As<sem::Matrix>()->columns(), 3u);
auto* m24 = p->ConvertType(24);
- EXPECT_TRUE(m24->Is<type::Matrix>());
- EXPECT_TRUE(m24->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m24->As<type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m24->As<type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m24->Is<sem::Matrix>());
+ EXPECT_TRUE(m24->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m24->As<sem::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m24->As<sem::Matrix>()->columns(), 4u);
auto* m32 = p->ConvertType(32);
- EXPECT_TRUE(m32->Is<type::Matrix>());
- EXPECT_TRUE(m32->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m32->As<type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m32->As<type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m32->Is<sem::Matrix>());
+ EXPECT_TRUE(m32->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m32->As<sem::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m32->As<sem::Matrix>()->columns(), 2u);
auto* m33 = p->ConvertType(33);
- EXPECT_TRUE(m33->Is<type::Matrix>());
- EXPECT_TRUE(m33->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m33->As<type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m33->As<type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m33->Is<sem::Matrix>());
+ EXPECT_TRUE(m33->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m33->As<sem::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m33->As<sem::Matrix>()->columns(), 3u);
auto* m34 = p->ConvertType(34);
- EXPECT_TRUE(m34->Is<type::Matrix>());
- EXPECT_TRUE(m34->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m34->As<type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m34->As<type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m34->Is<sem::Matrix>());
+ EXPECT_TRUE(m34->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m34->As<sem::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m34->As<sem::Matrix>()->columns(), 4u);
auto* m42 = p->ConvertType(42);
- EXPECT_TRUE(m42->Is<type::Matrix>());
- EXPECT_TRUE(m42->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m42->As<type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m42->As<type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m42->Is<sem::Matrix>());
+ EXPECT_TRUE(m42->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m42->As<sem::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m42->As<sem::Matrix>()->columns(), 2u);
auto* m43 = p->ConvertType(43);
- EXPECT_TRUE(m43->Is<type::Matrix>());
- EXPECT_TRUE(m43->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m43->As<type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m43->As<type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m43->Is<sem::Matrix>());
+ EXPECT_TRUE(m43->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m43->As<sem::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m43->As<sem::Matrix>()->columns(), 3u);
auto* m44 = p->ConvertType(44);
- EXPECT_TRUE(m44->Is<type::Matrix>());
- EXPECT_TRUE(m44->As<type::Matrix>()->type()->Is<type::F32>());
- EXPECT_EQ(m44->As<type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m44->As<type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m44->Is<sem::Matrix>());
+ EXPECT_TRUE(m44->As<sem::Matrix>()->type()->Is<sem::F32>());
+ EXPECT_EQ(m44->As<sem::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m44->As<sem::Matrix>()->columns(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -326,15 +326,15 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::ArrayType>());
- auto* arr_type = type->As<type::ArrayType>();
+ EXPECT_TRUE(type->Is<sem::ArrayType>());
+ auto* arr_type = type->As<sem::ArrayType>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 0u);
EXPECT_EQ(arr_type->decorations().size(), 0u);
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<type::U32>());
+ EXPECT_TRUE(elem_type->Is<sem::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -361,7 +361,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- auto* arr_type = type->As<type::ArrayType>();
+ auto* arr_type = type->As<sem::ArrayType>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->decorations().size(), 1u);
@@ -409,15 +409,15 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::ArrayType>());
- auto* arr_type = type->As<type::ArrayType>();
+ EXPECT_TRUE(type->Is<sem::ArrayType>());
+ auto* arr_type = type->As<sem::ArrayType>();
EXPECT_FALSE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 42u);
EXPECT_EQ(arr_type->decorations().size(), 0u);
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<type::U32>());
+ EXPECT_TRUE(elem_type->Is<sem::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -496,8 +496,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::ArrayType>());
- auto* arr_type = type->As<type::ArrayType>();
+ EXPECT_TRUE(type->Is<sem::ArrayType>());
+ auto* arr_type = type->As<sem::ArrayType>();
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->decorations().size(), 1u);
@@ -550,10 +550,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::StructType>());
+ EXPECT_TRUE(type->Is<sem::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
StructMember{field0: __u32}
StructMember{field1: __f32}
}
@@ -571,10 +571,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::StructType>());
+ EXPECT_TRUE(type->Is<sem::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
[[block]]
StructMember{field0: __u32}
}
@@ -596,10 +596,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::StructType>());
+ EXPECT_TRUE(type->Is<sem::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
StructMember{[[ offset 0 ]] field0: __f32}
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
StructMember{[[ offset 16 ]] field2: __mat_2_2__f32}
@@ -645,10 +645,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
EXPECT_TRUE(p->error().empty());
}
@@ -661,10 +661,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
EXPECT_TRUE(p->error().empty());
}
@@ -677,10 +677,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
EXPECT_TRUE(p->error().empty());
}
@@ -693,10 +693,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(p->error().empty());
}
@@ -709,10 +709,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
EXPECT_TRUE(p->error().empty());
}
@@ -725,10 +725,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
EXPECT_TRUE(p->error().empty());
}
@@ -741,10 +741,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
EXPECT_TRUE(p->error().empty());
}
@@ -757,10 +757,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
EXPECT_TRUE(p->error().empty());
}
@@ -773,10 +773,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ EXPECT_TRUE(type->Is<sem::Pointer>());
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
EXPECT_TRUE(p->error().empty());
}
@@ -792,17 +792,17 @@
auto* type = p->ConvertType(3);
EXPECT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Pointer>());
+ EXPECT_TRUE(type->Is<sem::Pointer>());
- auto* ptr_ty = type->As<type::Pointer>();
+ auto* ptr_ty = type->As<sem::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
- EXPECT_TRUE(ptr_ty->type()->Is<type::Pointer>());
+ EXPECT_TRUE(ptr_ty->type()->Is<sem::Pointer>());
- auto* ptr_ptr_ty = ptr_ty->type()->As<type::Pointer>();
+ auto* ptr_ptr_ty = ptr_ty->type()->As<sem::Pointer>();
EXPECT_NE(ptr_ptr_ty, nullptr);
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
- EXPECT_TRUE(ptr_ptr_ty->type()->Is<type::F32>());
+ EXPECT_TRUE(ptr_ptr_ty->type()->Is<sem::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -815,7 +815,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<type::Void>());
+ EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -828,7 +828,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<type::Void>());
+ EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -841,7 +841,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<type::Void>());
+ EXPECT_TRUE(type->Is<sem::Void>());
EXPECT_TRUE(p->error().empty());
}
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 95514e8..24cdda8 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -173,7 +173,7 @@
ParserImpl::FunctionHeader::FunctionHeader(Source src,
std::string n,
ast::VariableList p,
- type::Type* ret_ty,
+ sem::Type* ret_ty,
ast::DecorationList ret_decos)
: source(src),
name(n),
@@ -243,11 +243,11 @@
}
void ParserImpl::register_constructed(const std::string& name,
- type::Type* type) {
+ sem::Type* type) {
registered_constructs_[name] = type;
}
-type::Type* ParserImpl::get_constructed(const std::string& name) {
+sem::Type* ParserImpl::get_constructed(const std::string& name) {
if (registered_constructs_.find(name) == registered_constructs_.end()) {
return nullptr;
}
@@ -507,7 +507,7 @@
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
// | storage_texture_type LESS_THAN image_storage_type GREATER_THAN
-Maybe<type::Type*> ParserImpl::texture_sampler_types() {
+Maybe<sem::Type*> ParserImpl::texture_sampler_types() {
auto type = sampler_type();
if (type.matched)
return type;
@@ -524,7 +524,7 @@
if (subtype.errored)
return Failure::kErrored;
- return builder_.create<type::SampledTexture>(dim.value, subtype.value);
+ return builder_.create<sem::SampledTexture>(dim.value, subtype.value);
}
auto ms_dim = multisampled_texture_type();
@@ -535,8 +535,8 @@
if (subtype.errored)
return Failure::kErrored;
- return builder_.create<type::MultisampledTexture>(ms_dim.value,
- subtype.value);
+ return builder_.create<sem::MultisampledTexture>(ms_dim.value,
+ subtype.value);
}
auto storage = storage_texture_type();
@@ -550,9 +550,9 @@
return Failure::kErrored;
auto* subtype =
- type::StorageTexture::SubtypeFor(format.value, builder_.Types());
- return builder_.create<type::StorageTexture>(storage.value, format.value,
- subtype);
+ sem::StorageTexture::SubtypeFor(format.value, builder_.Types());
+ return builder_.create<sem::StorageTexture>(storage.value, format.value,
+ subtype);
}
return Failure::kNoMatch;
@@ -561,13 +561,12 @@
// sampler_type
// : SAMPLER
// | SAMPLER_COMPARISON
-Maybe<type::Type*> ParserImpl::sampler_type() {
+Maybe<sem::Type*> ParserImpl::sampler_type() {
if (match(Token::Type::kSampler))
- return builder_.create<type::Sampler>(type::SamplerKind::kSampler);
+ return builder_.create<sem::Sampler>(sem::SamplerKind::kSampler);
if (match(Token::Type::kComparisonSampler))
- return builder_.create<type::Sampler>(
- type::SamplerKind::kComparisonSampler);
+ return builder_.create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
return Failure::kNoMatch;
}
@@ -579,33 +578,33 @@
// | TEXTURE_SAMPLED_3D
// | TEXTURE_SAMPLED_CUBE
// | TEXTURE_SAMPLED_CUBE_ARRAY
-Maybe<type::TextureDimension> ParserImpl::sampled_texture_type() {
+Maybe<sem::TextureDimension> ParserImpl::sampled_texture_type() {
if (match(Token::Type::kTextureSampled1d))
- return type::TextureDimension::k1d;
+ return sem::TextureDimension::k1d;
if (match(Token::Type::kTextureSampled2d))
- return type::TextureDimension::k2d;
+ return sem::TextureDimension::k2d;
if (match(Token::Type::kTextureSampled2dArray))
- return type::TextureDimension::k2dArray;
+ return sem::TextureDimension::k2dArray;
if (match(Token::Type::kTextureSampled3d))
- return type::TextureDimension::k3d;
+ return sem::TextureDimension::k3d;
if (match(Token::Type::kTextureSampledCube))
- return type::TextureDimension::kCube;
+ return sem::TextureDimension::kCube;
if (match(Token::Type::kTextureSampledCubeArray))
- return type::TextureDimension::kCubeArray;
+ return sem::TextureDimension::kCubeArray;
return Failure::kNoMatch;
}
// multisampled_texture_type
// : TEXTURE_MULTISAMPLED_2D
-Maybe<type::TextureDimension> ParserImpl::multisampled_texture_type() {
+Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
if (match(Token::Type::kTextureMultisampled2d))
- return type::TextureDimension::k2d;
+ return sem::TextureDimension::k2d;
return Failure::kNoMatch;
}
@@ -615,15 +614,15 @@
// | TEXTURE_STORAGE_2D
// | TEXTURE_STORAGE_2D_ARRAY
// | TEXTURE_STORAGE_3D
-Maybe<type::TextureDimension> ParserImpl::storage_texture_type() {
+Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
if (match(Token::Type::kTextureStorage1d))
- return type::TextureDimension::k1d;
+ return sem::TextureDimension::k1d;
if (match(Token::Type::kTextureStorage2d))
- return type::TextureDimension::k2d;
+ return sem::TextureDimension::k2d;
if (match(Token::Type::kTextureStorage2dArray))
- return type::TextureDimension::k2dArray;
+ return sem::TextureDimension::k2dArray;
if (match(Token::Type::kTextureStorage3d))
- return type::TextureDimension::k3d;
+ return sem::TextureDimension::k3d;
return Failure::kNoMatch;
}
@@ -633,20 +632,19 @@
// | TEXTURE_DEPTH_2D_ARRAY
// | TEXTURE_DEPTH_CUBE
// | TEXTURE_DEPTH_CUBE_ARRAY
-Maybe<type::Type*> ParserImpl::depth_texture_type() {
+Maybe<sem::Type*> ParserImpl::depth_texture_type() {
if (match(Token::Type::kTextureDepth2d))
- return builder_.create<type::DepthTexture>(type::TextureDimension::k2d);
+ return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2d);
if (match(Token::Type::kTextureDepth2dArray))
- return builder_.create<type::DepthTexture>(
- type::TextureDimension::k2dArray);
+ return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2dArray);
if (match(Token::Type::kTextureDepthCube))
- return builder_.create<type::DepthTexture>(type::TextureDimension::kCube);
+ return builder_.create<sem::DepthTexture>(sem::TextureDimension::kCube);
if (match(Token::Type::kTextureDepthCubeArray))
- return builder_.create<type::DepthTexture>(
- type::TextureDimension::kCubeArray);
+ return builder_.create<sem::DepthTexture>(
+ sem::TextureDimension::kCubeArray);
return Failure::kNoMatch;
}
@@ -687,112 +685,112 @@
// | RGBA32UINT
// | RGBA32SINT
// | RGBA32FLOAT
-Expect<type::ImageFormat> ParserImpl::expect_image_storage_type(
+Expect<sem::ImageFormat> ParserImpl::expect_image_storage_type(
const std::string& use) {
if (match(Token::Type::kFormatR8Unorm))
- return type::ImageFormat::kR8Unorm;
+ return sem::ImageFormat::kR8Unorm;
if (match(Token::Type::kFormatR8Snorm))
- return type::ImageFormat::kR8Snorm;
+ return sem::ImageFormat::kR8Snorm;
if (match(Token::Type::kFormatR8Uint))
- return type::ImageFormat::kR8Uint;
+ return sem::ImageFormat::kR8Uint;
if (match(Token::Type::kFormatR8Sint))
- return type::ImageFormat::kR8Sint;
+ return sem::ImageFormat::kR8Sint;
if (match(Token::Type::kFormatR16Uint))
- return type::ImageFormat::kR16Uint;
+ return sem::ImageFormat::kR16Uint;
if (match(Token::Type::kFormatR16Sint))
- return type::ImageFormat::kR16Sint;
+ return sem::ImageFormat::kR16Sint;
if (match(Token::Type::kFormatR16Float))
- return type::ImageFormat::kR16Float;
+ return sem::ImageFormat::kR16Float;
if (match(Token::Type::kFormatRg8Unorm))
- return type::ImageFormat::kRg8Unorm;
+ return sem::ImageFormat::kRg8Unorm;
if (match(Token::Type::kFormatRg8Snorm))
- return type::ImageFormat::kRg8Snorm;
+ return sem::ImageFormat::kRg8Snorm;
if (match(Token::Type::kFormatRg8Uint))
- return type::ImageFormat::kRg8Uint;
+ return sem::ImageFormat::kRg8Uint;
if (match(Token::Type::kFormatRg8Sint))
- return type::ImageFormat::kRg8Sint;
+ return sem::ImageFormat::kRg8Sint;
if (match(Token::Type::kFormatR32Uint))
- return type::ImageFormat::kR32Uint;
+ return sem::ImageFormat::kR32Uint;
if (match(Token::Type::kFormatR32Sint))
- return type::ImageFormat::kR32Sint;
+ return sem::ImageFormat::kR32Sint;
if (match(Token::Type::kFormatR32Float))
- return type::ImageFormat::kR32Float;
+ return sem::ImageFormat::kR32Float;
if (match(Token::Type::kFormatRg16Uint))
- return type::ImageFormat::kRg16Uint;
+ return sem::ImageFormat::kRg16Uint;
if (match(Token::Type::kFormatRg16Sint))
- return type::ImageFormat::kRg16Sint;
+ return sem::ImageFormat::kRg16Sint;
if (match(Token::Type::kFormatRg16Float))
- return type::ImageFormat::kRg16Float;
+ return sem::ImageFormat::kRg16Float;
if (match(Token::Type::kFormatRgba8Unorm))
- return type::ImageFormat::kRgba8Unorm;
+ return sem::ImageFormat::kRgba8Unorm;
if (match(Token::Type::kFormatRgba8UnormSrgb))
- return type::ImageFormat::kRgba8UnormSrgb;
+ return sem::ImageFormat::kRgba8UnormSrgb;
if (match(Token::Type::kFormatRgba8Snorm))
- return type::ImageFormat::kRgba8Snorm;
+ return sem::ImageFormat::kRgba8Snorm;
if (match(Token::Type::kFormatRgba8Uint))
- return type::ImageFormat::kRgba8Uint;
+ return sem::ImageFormat::kRgba8Uint;
if (match(Token::Type::kFormatRgba8Sint))
- return type::ImageFormat::kRgba8Sint;
+ return sem::ImageFormat::kRgba8Sint;
if (match(Token::Type::kFormatBgra8Unorm))
- return type::ImageFormat::kBgra8Unorm;
+ return sem::ImageFormat::kBgra8Unorm;
if (match(Token::Type::kFormatBgra8UnormSrgb))
- return type::ImageFormat::kBgra8UnormSrgb;
+ return sem::ImageFormat::kBgra8UnormSrgb;
if (match(Token::Type::kFormatRgb10A2Unorm))
- return type::ImageFormat::kRgb10A2Unorm;
+ return sem::ImageFormat::kRgb10A2Unorm;
if (match(Token::Type::kFormatRg11B10Float))
- return type::ImageFormat::kRg11B10Float;
+ return sem::ImageFormat::kRg11B10Float;
if (match(Token::Type::kFormatRg32Uint))
- return type::ImageFormat::kRg32Uint;
+ return sem::ImageFormat::kRg32Uint;
if (match(Token::Type::kFormatRg32Sint))
- return type::ImageFormat::kRg32Sint;
+ return sem::ImageFormat::kRg32Sint;
if (match(Token::Type::kFormatRg32Float))
- return type::ImageFormat::kRg32Float;
+ return sem::ImageFormat::kRg32Float;
if (match(Token::Type::kFormatRgba16Uint))
- return type::ImageFormat::kRgba16Uint;
+ return sem::ImageFormat::kRgba16Uint;
if (match(Token::Type::kFormatRgba16Sint))
- return type::ImageFormat::kRgba16Sint;
+ return sem::ImageFormat::kRgba16Sint;
if (match(Token::Type::kFormatRgba16Float))
- return type::ImageFormat::kRgba16Float;
+ return sem::ImageFormat::kRgba16Float;
if (match(Token::Type::kFormatRgba32Uint))
- return type::ImageFormat::kRgba32Uint;
+ return sem::ImageFormat::kRgba32Uint;
if (match(Token::Type::kFormatRgba32Sint))
- return type::ImageFormat::kRgba32Sint;
+ return sem::ImageFormat::kRgba32Sint;
if (match(Token::Type::kFormatRgba32Float))
- return type::ImageFormat::kRgba32Float;
+ return sem::ImageFormat::kRgba32Float;
return add_error(peek().source(), "invalid format", use);
}
@@ -831,7 +829,7 @@
for (auto* deco : access_decos) {
// If we have an access control decoration then we take it and wrap our
// type up with that decoration
- ty = builder_.create<type::AccessControl>(
+ ty = builder_.create<sem::AccessControl>(
deco->As<ast::AccessDecoration>()->value(), ty);
}
@@ -871,7 +869,7 @@
// type_alias
// : TYPE IDENT EQUAL type_decl
-Maybe<type::Type*> ParserImpl::type_alias() {
+Maybe<sem::Type*> ParserImpl::type_alias() {
auto t = peek();
if (!t.IsType())
return Failure::kNoMatch;
@@ -893,7 +891,7 @@
if (!type.matched)
return add_error(peek(), "invalid type alias");
- auto* alias = builder_.create<type::Alias>(
+ auto* alias = builder_.create<sem::Alias>(
builder_.Symbols().Register(name.value), type.value);
register_constructed(name.value, alias);
@@ -924,7 +922,7 @@
// | MAT4x3 LESS_THAN type_decl GREATER_THAN
// | MAT4x4 LESS_THAN type_decl GREATER_THAN
// | texture_sampler_types
-Maybe<type::Type*> ParserImpl::type_decl() {
+Maybe<sem::Type*> ParserImpl::type_decl() {
auto decos = decoration_list();
if (decos.errored)
return Failure::kErrored;
@@ -941,7 +939,7 @@
return type.value;
}
-Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
+Maybe<sem::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
auto t = peek();
if (match(Token::Type::kIdentifier)) {
auto* ty = get_constructed(t.to_str());
@@ -952,16 +950,16 @@
}
if (match(Token::Type::kBool))
- return builder_.create<type::Bool>();
+ return builder_.create<sem::Bool>();
if (match(Token::Type::kF32))
- return builder_.create<type::F32>();
+ return builder_.create<sem::F32>();
if (match(Token::Type::kI32))
- return builder_.create<type::I32>();
+ return builder_.create<sem::I32>();
if (match(Token::Type::kU32))
- return builder_.create<type::U32>();
+ return builder_.create<sem::U32>();
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
next(); // Consume the peek
@@ -991,7 +989,7 @@
return Failure::kNoMatch;
}
-Expect<type::Type*> ParserImpl::expect_type(const std::string& use) {
+Expect<sem::Type*> ParserImpl::expect_type(const std::string& use) {
auto type = type_decl();
if (type.errored)
return Failure::kErrored;
@@ -1000,10 +998,10 @@
return type.value;
}
-Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
+Expect<sem::Type*> ParserImpl::expect_type_decl_pointer() {
const char* use = "ptr declaration";
- return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
+ return expect_lt_gt_block(use, [&]() -> Expect<sem::Type*> {
auto sc = expect_storage_class(use);
if (sc.errored)
return Failure::kErrored;
@@ -1015,11 +1013,11 @@
if (subtype.errored)
return Failure::kErrored;
- return builder_.create<type::Pointer>(subtype.value, sc.value);
+ return builder_.create<sem::Pointer>(subtype.value, sc.value);
});
}
-Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
+Expect<sem::Type*> ParserImpl::expect_type_decl_vector(Token t) {
uint32_t count = 2;
if (t.IsVec3())
count = 3;
@@ -1032,14 +1030,14 @@
if (subtype.errored)
return Failure::kErrored;
- return builder_.create<type::Vector>(subtype.value, count);
+ return builder_.create<sem::Vector>(subtype.value, count);
}
-Expect<type::Type*> ParserImpl::expect_type_decl_array(
+Expect<sem::Type*> ParserImpl::expect_type_decl_array(
ast::DecorationList decos) {
const char* use = "array declaration";
- return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
+ return expect_lt_gt_block(use, [&]() -> Expect<sem::Type*> {
auto subtype = expect_type(use);
if (subtype.errored)
return Failure::kErrored;
@@ -1052,11 +1050,11 @@
size = val.value;
}
- return create<type::ArrayType>(subtype.value, size, std::move(decos));
+ return create<sem::ArrayType>(subtype.value, size, std::move(decos));
});
}
-Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
+Expect<sem::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
uint32_t rows = 2;
uint32_t columns = 2;
if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) {
@@ -1076,7 +1074,7 @@
if (subtype.errored)
return Failure::kErrored;
- return builder_.create<type::Matrix>(subtype.value, rows, columns);
+ return builder_.create<sem::Matrix>(subtype.value, rows, columns);
}
// storage_class
@@ -1121,7 +1119,7 @@
// struct_decl
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
-Maybe<type::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
+Maybe<sem::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
auto t = peek();
auto source = t.source();
@@ -1136,7 +1134,7 @@
if (body.errored)
return Failure::kErrored;
- return create<type::StructType>(
+ return create<sem::StructType>(
builder_.Symbols().Register(name.value),
create<ast::Struct>(source, std::move(body.value), std::move(decos)));
}
@@ -1227,9 +1225,9 @@
// function_type_decl
// : type_decl
// | VOID
-Maybe<type::Type*> ParserImpl::function_type_decl() {
+Maybe<sem::Type*> ParserImpl::function_type_decl() {
if (match(Token::Type::kVoid))
- return builder_.create<type::Void>();
+ return builder_.create<sem::Void>();
return type_decl();
}
@@ -1261,7 +1259,7 @@
}
}
- type::Type* return_type = nullptr;
+ sem::Type* return_type = nullptr;
ast::DecorationList return_decorations;
if (match(Token::Type::kArrow)) {
@@ -1282,7 +1280,7 @@
return_type = type.value;
}
- if (return_type->Is<type::Void>()) {
+ if (return_type->Is<sem::Void>()) {
// crbug.com/tint/677: void has been removed from the language
deprecated(tok.source(),
"omit '-> void' for functions that do not return a value");
@@ -2726,19 +2724,19 @@
Maybe<ast::Literal*> ParserImpl::const_literal() {
auto t = peek();
if (match(Token::Type::kTrue)) {
- auto* type = builder_.create<type::Bool>();
+ auto* type = builder_.create<sem::Bool>();
return create<ast::BoolLiteral>(Source{}, type, true);
}
if (match(Token::Type::kFalse)) {
- auto* type = builder_.create<type::Bool>();
+ auto* type = builder_.create<sem::Bool>();
return create<ast::BoolLiteral>(Source{}, type, false);
}
if (match(Token::Type::kSintLiteral)) {
- auto* type = builder_.create<type::I32>();
+ auto* type = builder_.create<sem::I32>();
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
}
if (match(Token::Type::kUintLiteral)) {
- auto* type = builder_.create<type::U32>();
+ auto* type = builder_.create<sem::U32>();
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
}
if (match(Token::Type::kFloatLiteral)) {
@@ -2747,7 +2745,7 @@
next(); // Consume 'f'
add_error(p.source(), "float literals must not be suffixed with 'f'");
}
- auto* type = builder_.create<type::F32>();
+ auto* type = builder_.create<sem::F32>();
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
}
return Failure::kNoMatch;
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index ba756fd..7c7a7e3 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -199,7 +199,7 @@
/// variable_ident_decl().
struct TypedIdentifier {
/// Parsed type.
- type::Type* type = nullptr;
+ sem::Type* type = nullptr;
/// Parsed identifier.
std::string name;
/// Source to the identifier.
@@ -222,7 +222,7 @@
FunctionHeader(Source src,
std::string n,
ast::VariableList p,
- type::Type* ret_ty,
+ sem::Type* ret_ty,
ast::DecorationList ret_decos);
/// Destructor
~FunctionHeader();
@@ -238,7 +238,7 @@
/// Function parameters
ast::VariableList params;
/// Function return type
- type::Type* return_type;
+ sem::Type* return_type;
/// Function return type decorations
ast::DecorationList return_type_decorations;
};
@@ -252,7 +252,7 @@
/// Variable storage class
ast::StorageClass storage_class;
/// Variable type
- type::Type* type;
+ sem::Type* type;
};
/// Creates a new parser using the given file
@@ -328,11 +328,11 @@
/// Registers a constructed type into the parser
/// @param name the constructed name
/// @param type the constructed type
- void register_constructed(const std::string& name, type::Type* type);
+ void register_constructed(const std::string& name, sem::Type* type);
/// Retrieves a constructed type
/// @param name The name to lookup
/// @returns the constructed type for `name` or `nullptr` if not found
- type::Type* get_constructed(const std::string& name);
+ sem::Type* get_constructed(const std::string& name);
/// Parses the `translation_unit` grammar element
void translation_unit();
@@ -362,15 +362,15 @@
Maybe<ast::StorageClass> variable_storage_decoration();
/// Parses a `type_alias` grammar element
/// @returns the type alias or nullptr on error
- Maybe<type::Type*> type_alias();
+ Maybe<sem::Type*> type_alias();
/// Parses a `type_decl` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<type::Type*> type_decl();
+ Maybe<sem::Type*> type_decl();
/// Parses a `type_decl` grammar element with the given pre-parsed
/// decorations.
/// @param decos the list of decorations for the type.
/// @returns the parsed Type or nullptr if none matched.
- Maybe<type::Type*> type_decl(ast::DecorationList& decos);
+ Maybe<sem::Type*> type_decl(ast::DecorationList& decos);
/// Parses a `storage_class` grammar element, erroring on parse failure.
/// @param use a description of what was being parsed if an error was raised.
/// @returns the storage class or StorageClass::kNone if none matched
@@ -379,7 +379,7 @@
/// `struct_decoration_decl*` provided as `decos`.
/// @returns the struct type or nullptr on error
/// @param decos the list of decorations for the struct declaration.
- Maybe<type::StructType*> struct_decl(ast::DecorationList& decos);
+ Maybe<sem::StructType*> struct_decl(ast::DecorationList& decos);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members
Expect<ast::StructMemberList> expect_struct_body_decl();
@@ -396,31 +396,31 @@
Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
/// Parses a `texture_sampler_types` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<type::Type*> texture_sampler_types();
+ Maybe<sem::Type*> texture_sampler_types();
/// Parses a `sampler_type` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<type::Type*> sampler_type();
+ Maybe<sem::Type*> sampler_type();
/// Parses a `multisampled_texture_type` grammar element
/// @returns returns the multisample texture dimension or kNone if none
/// matched.
- Maybe<type::TextureDimension> multisampled_texture_type();
+ Maybe<sem::TextureDimension> multisampled_texture_type();
/// Parses a `sampled_texture_type` grammar element
/// @returns returns the sample texture dimension or kNone if none matched.
- Maybe<type::TextureDimension> sampled_texture_type();
+ Maybe<sem::TextureDimension> sampled_texture_type();
/// Parses a `storage_texture_type` grammar element
/// @returns returns the storage texture dimension.
/// Returns kNone if none matched.
- Maybe<type::TextureDimension> storage_texture_type();
+ Maybe<sem::TextureDimension> storage_texture_type();
/// Parses a `depth_texture_type` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<type::Type*> depth_texture_type();
+ Maybe<sem::Type*> depth_texture_type();
/// Parses a `image_storage_type` grammar element
/// @param use a description of what was being parsed if an error was raised
/// @returns returns the image format or kNone if none matched.
- Expect<type::ImageFormat> expect_image_storage_type(const std::string& use);
+ Expect<sem::ImageFormat> expect_image_storage_type(const std::string& use);
/// Parses a `function_type_decl` grammar element
/// @returns the parsed type or nullptr otherwise
- Maybe<type::Type*> function_type_decl();
+ Maybe<sem::Type*> function_type_decl();
/// Parses a `function_header` grammar element
/// @returns the parsed function header
Maybe<FunctionHeader> function_header();
@@ -784,12 +784,12 @@
/// Used to ensure that all decorations are consumed.
bool expect_decorations_consumed(const ast::DecorationList& list);
- Expect<type::Type*> expect_type_decl_pointer();
- Expect<type::Type*> expect_type_decl_vector(Token t);
- Expect<type::Type*> expect_type_decl_array(ast::DecorationList decos);
- Expect<type::Type*> expect_type_decl_matrix(Token t);
+ Expect<sem::Type*> expect_type_decl_pointer();
+ Expect<sem::Type*> expect_type_decl_vector(Token t);
+ Expect<sem::Type*> expect_type_decl_array(ast::DecorationList decos);
+ Expect<sem::Type*> expect_type_decl_matrix(Token t);
- Expect<type::Type*> expect_type(const std::string& use);
+ Expect<sem::Type*> expect_type(const std::string& use);
Maybe<ast::Statement*> non_block_statement();
Maybe<ast::Statement*> for_header_initializer();
@@ -810,7 +810,7 @@
uint32_t sync_depth_ = 0;
std::vector<Token::Type> sync_tokens_;
int silence_errors_ = 0;
- std::unordered_map<std::string, type::Type*> registered_constructs_;
+ std::unordered_map<std::string, sem::Type*> registered_constructs_;
ProgramBuilder builder_;
size_t max_errors_ = 25;
};
diff --git a/src/reader/wgsl/parser_impl_const_expr_test.cc b/src/reader/wgsl/parser_impl_const_expr_test.cc
index ee1822b..8498ed4 100644
--- a/src/reader/wgsl/parser_impl_const_expr_test.cc
+++ b/src/reader/wgsl/parser_impl_const_expr_test.cc
@@ -28,8 +28,8 @@
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
auto* t = e->As<ast::TypeConstructorExpression>();
- ASSERT_TRUE(t->type()->Is<type::Vector>());
- EXPECT_EQ(t->type()->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(t->type()->Is<sem::Vector>());
+ EXPECT_EQ(t->type()->As<sem::Vector>()->size(), 2u);
ASSERT_EQ(t->values().size(), 2u);
auto& v = t->values();
diff --git a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
index 9113040..b4ddc85 100644
--- a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
@@ -34,9 +34,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::DepthTexture>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::DepthTexture>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -46,9 +46,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::DepthTexture>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2dArray);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::DepthTexture>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -58,9 +58,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::DepthTexture>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCube);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::DepthTexture>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -70,9 +70,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::DepthTexture>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCubeArray);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::DepthTexture>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_function_decl_test.cc b/src/reader/wgsl/parser_impl_function_decl_test.cc
index 4371bce..97c99f8 100644
--- a/src/reader/wgsl/parser_impl_function_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_decl_test.cc
@@ -34,14 +34,14 @@
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->symbol(), p->builder().Symbols().Get("a"));
EXPECT_EQ(f->params()[1]->symbol(), p->builder().Symbols().Get("b"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
auto* body = f->body();
ASSERT_EQ(body->size(), 1u);
@@ -62,10 +62,10 @@
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 1u);
@@ -100,10 +100,10 @@
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 2u);
@@ -145,10 +145,10 @@
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<sem::Void>());
auto& decos = f->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -187,7 +187,7 @@
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<type::F32>());
+ EXPECT_TRUE(f->return_type()->Is<sem::F32>());
ASSERT_EQ(f->params().size(), 0u);
auto& decorations = f->decorations();
diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc
index c4a064d..fba796e 100644
--- a/src/reader/wgsl/parser_impl_function_header_test.cc
+++ b/src/reader/wgsl/parser_impl_function_header_test.cc
@@ -30,7 +30,7 @@
ASSERT_EQ(f->params.size(), 2u);
EXPECT_EQ(f->params[0]->symbol(), p->builder().Symbols().Get("a"));
EXPECT_EQ(f->params[1]->symbol(), p->builder().Symbols().Get("b"));
- EXPECT_TRUE(f->return_type->Is<type::Void>());
+ EXPECT_TRUE(f->return_type->Is<sem::Void>());
}
TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) {
@@ -42,7 +42,7 @@
EXPECT_EQ(f->name, "main");
EXPECT_EQ(f->params.size(), 0u);
- EXPECT_TRUE(f->return_type->Is<type::F32>());
+ EXPECT_TRUE(f->return_type->Is<sem::F32>());
ASSERT_EQ(f->return_type_decorations.size(), 1u);
auto* loc = f->return_type_decorations[0]->As<ast::LocationDecoration>();
ASSERT_TRUE(loc != nullptr);
diff --git a/src/reader/wgsl/parser_impl_function_type_decl_test.cc b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
index 2779849..f876f5c 100644
--- a/src/reader/wgsl/parser_impl_function_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
@@ -22,7 +22,7 @@
TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
auto p = parser("void");
- auto* v = p->builder().create<type::Void>();
+ auto* v = p->builder().create<sem::Void>();
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
@@ -34,8 +34,8 @@
TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
auto p = parser("vec2<f32>");
- auto* f32 = p->builder().create<type::F32>();
- auto* vec2 = p->builder().create<type::Vector>(f32, 2);
+ auto* f32 = p->builder().create<sem::F32>();
+ auto* vec2 = p->builder().create<sem::Vector>(f32, 2);
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
index f63a0e0..0cdfb90 100644
--- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
@@ -34,7 +34,7 @@
EXPECT_TRUE(e->is_const());
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
ASSERT_NE(e->declared_type(), nullptr);
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->source().range.begin.line, 1u);
EXPECT_EQ(e->source().range.begin.column, 5u);
@@ -115,7 +115,7 @@
EXPECT_TRUE(e->is_const());
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
ASSERT_NE(e->declared_type(), nullptr);
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->source().range.begin.line, 1u);
EXPECT_EQ(e->source().range.begin.column, 24u);
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index 923828a..385d3ec 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -84,10 +84,10 @@
auto program = p->program();
ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
- ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::Alias>());
+ ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<sem::Alias>());
EXPECT_EQ(
program.Symbols().NameFor(
- program.AST().ConstructedTypes()[0]->As<type::Alias>()->symbol()),
+ program.AST().ConstructedTypes()[0]->As<sem::Alias>()->symbol()),
"A");
}
@@ -102,12 +102,12 @@
auto program = p->program();
ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u);
- ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::StructType>());
- auto* str = program.AST().ConstructedTypes()[0]->As<type::StructType>();
+ ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<sem::StructType>());
+ auto* str = program.AST().ConstructedTypes()[0]->As<sem::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
- ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<type::Alias>());
- auto* alias = program.AST().ConstructedTypes()[1]->As<type::Alias>();
+ ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<sem::Alias>());
+ auto* alias = program.AST().ConstructedTypes()[1]->As<sem::Alias>();
EXPECT_EQ(alias->symbol(), program.Symbols().Get("B"));
EXPECT_EQ(alias->type(), str);
}
@@ -165,9 +165,9 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::StructType>());
+ ASSERT_TRUE(t->Is<sem::StructType>());
- auto* str = t->As<type::StructType>();
+ auto* str = t->As<sem::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -183,16 +183,16 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::StructType>());
+ ASSERT_TRUE(t->Is<sem::StructType>());
- auto* str = t->As<type::StructType>();
+ auto* str = t->As<sem::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
const auto* ty = str->impl()->members()[0]->type();
- ASSERT_TRUE(ty->Is<type::ArrayType>());
- const auto* arr = ty->As<type::ArrayType>();
+ ASSERT_TRUE(ty->Is<sem::ArrayType>());
+ const auto* arr = ty->As<sem::ArrayType>();
ASSERT_EQ(arr->decorations().size(), 1u);
auto* stride = arr->decorations()[0];
@@ -210,9 +210,9 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::StructType>());
+ ASSERT_TRUE(t->Is<sem::StructType>());
- auto* str = t->As<type::StructType>();
+ auto* str = t->As<sem::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());
diff --git a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
index b175eea..45cf010 100644
--- a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
@@ -31,7 +31,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -54,7 +54,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -80,7 +80,7 @@
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
ASSERT_NE(e->declared_type(), nullptr);
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -110,7 +110,7 @@
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
ASSERT_NE(e->declared_type(), nullptr);
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -180,7 +180,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s"));
- EXPECT_TRUE(e->declared_type()->Is<type::Sampler>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::Sampler>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant);
}
@@ -196,7 +196,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s"));
- EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is<type::Texture>());
+ EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is<sem::Texture>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant);
}
@@ -210,7 +210,7 @@
ASSERT_FALSE(p->has_error()) << p->error();
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kInput);
EXPECT_EQ(
@@ -231,7 +231,7 @@
ASSERT_FALSE(p->has_error()) << p->error();
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
- EXPECT_TRUE(e->declared_type()->Is<type::F32>());
+ EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(
diff --git a/src/reader/wgsl/parser_impl_image_storage_type_test.cc b/src/reader/wgsl/parser_impl_image_storage_type_test.cc
index 872df12..bf34ed1 100644
--- a/src/reader/wgsl/parser_impl_image_storage_type_test.cc
+++ b/src/reader/wgsl/parser_impl_image_storage_type_test.cc
@@ -31,7 +31,7 @@
auto p = parser("r8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -39,7 +39,7 @@
auto p = parser("r8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR8Snorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -47,7 +47,7 @@
auto p = parser("r8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR8Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -55,7 +55,7 @@
auto p = parser("r8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR8Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -63,7 +63,7 @@
auto p = parser("r16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR16Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -71,7 +71,7 @@
auto p = parser("r16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR16Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -79,7 +79,7 @@
auto p = parser("r16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR16Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR16Float);
EXPECT_FALSE(p->has_error());
}
@@ -87,7 +87,7 @@
auto p = parser("rg8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg8Unorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -95,7 +95,7 @@
auto p = parser("rg8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg8Snorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -103,7 +103,7 @@
auto p = parser("rg8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg8Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -111,7 +111,7 @@
auto p = parser("rg8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg8Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -119,7 +119,7 @@
auto p = parser("r32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR32Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -127,7 +127,7 @@
auto p = parser("r32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR32Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -135,7 +135,7 @@
auto p = parser("r32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kR32Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kR32Float);
EXPECT_FALSE(p->has_error());
}
@@ -143,7 +143,7 @@
auto p = parser("rg16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg16Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -151,7 +151,7 @@
auto p = parser("rg16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg16Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -159,7 +159,7 @@
auto p = parser("rg16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg16Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg16Float);
EXPECT_FALSE(p->has_error());
}
@@ -167,7 +167,7 @@
auto p = parser("rgba8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba8Unorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -175,7 +175,7 @@
auto p = parser("rgba8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba8UnormSrgb);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@@ -183,7 +183,7 @@
auto p = parser("rgba8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba8Snorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -191,7 +191,7 @@
auto p = parser("rgba8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba8Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -199,7 +199,7 @@
auto p = parser("rgba8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba8Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -207,7 +207,7 @@
auto p = parser("bgra8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kBgra8Unorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kBgra8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -215,7 +215,7 @@
auto p = parser("bgra8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kBgra8UnormSrgb);
+ EXPECT_EQ(t.value, sem::ImageFormat::kBgra8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@@ -223,7 +223,7 @@
auto p = parser("rgb10a2unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgb10A2Unorm);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgb10A2Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -231,7 +231,7 @@
auto p = parser("rg11b10float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg11B10Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg11B10Float);
EXPECT_FALSE(p->has_error());
}
@@ -239,7 +239,7 @@
auto p = parser("rg32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg32Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -247,7 +247,7 @@
auto p = parser("rg32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg32Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -255,7 +255,7 @@
auto p = parser("rg32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRg32Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRg32Float);
EXPECT_FALSE(p->has_error());
}
@@ -263,7 +263,7 @@
auto p = parser("rgba16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba16Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -271,7 +271,7 @@
auto p = parser("rgba16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba16Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -279,7 +279,7 @@
auto p = parser("rgba16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba16Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Float);
EXPECT_FALSE(p->has_error());
}
@@ -287,7 +287,7 @@
auto p = parser("rgba32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba32Uint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -295,7 +295,7 @@
auto p = parser("rgba32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba32Sint);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -303,7 +303,7 @@
auto p = parser("rgba32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::ImageFormat::kRgba32Float);
+ EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Float);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_param_list_test.cc b/src/reader/wgsl/parser_impl_param_list_test.cc
index 4949c38..54e30bd 100644
--- a/src/reader/wgsl/parser_impl_param_list_test.cc
+++ b/src/reader/wgsl/parser_impl_param_list_test.cc
@@ -22,7 +22,7 @@
TEST_F(ParserImplTest, ParamList_Single) {
auto p = parser("a : i32");
- auto* i32 = p->builder().create<type::I32>();
+ auto* i32 = p->builder().create<sem::I32>();
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
@@ -42,9 +42,9 @@
TEST_F(ParserImplTest, ParamList_Multiple) {
auto p = parser("a : i32, b: f32, c: vec2<f32>");
- auto* i32 = p->builder().create<type::I32>();
- auto* f32 = p->builder().create<type::F32>();
- auto* vec2 = p->builder().create<type::Vector>(f32, 2);
+ auto* i32 = p->builder().create<sem::I32>();
+ auto* f32 = p->builder().create<sem::F32>();
+ auto* vec2 = p->builder().create<sem::Vector>(f32, 2);
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
@@ -100,8 +100,8 @@
"[[builtin(position)]] coord : vec4<f32>, "
"[[location(1)]] loc1 : f32");
- auto* f32 = p->builder().create<type::F32>();
- auto* vec4 = p->builder().create<type::Vector>(f32, 4);
+ auto* f32 = p->builder().create<sem::F32>();
+ auto* vec4 = p->builder().create<sem::Vector>(f32, 4);
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc
index 596c117..884f1c4 100644
--- a/src/reader/wgsl/parser_impl_primary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc
@@ -237,7 +237,7 @@
TEST_F(ParserImplTest, PrimaryExpression_Cast) {
auto p = parser("f32(1)");
- auto* f32 = p->builder().create<type::F32>();
+ auto* f32 = p->builder().create<sem::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
@@ -258,7 +258,7 @@
TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
auto p = parser("bitcast<f32>(1)");
- auto* f32 = p->builder().create<type::F32>();
+ auto* f32 = p->builder().create<sem::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc b/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
index 5c31846..82550a7 100644
--- a/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
@@ -32,7 +32,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k1d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@@ -41,7 +41,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k2d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -50,7 +50,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
+ EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -59,7 +59,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k3d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
@@ -68,7 +68,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::kCube);
+ EXPECT_EQ(t.value, sem::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -77,7 +77,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
+ EXPECT_EQ(t.value, sem::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_sampler_type_test.cc b/src/reader/wgsl/parser_impl_sampler_type_test.cc
index 46b3d3b..4ec0c01 100644
--- a/src/reader/wgsl/parser_impl_sampler_type_test.cc
+++ b/src/reader/wgsl/parser_impl_sampler_type_test.cc
@@ -34,8 +34,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Sampler>());
- EXPECT_FALSE(t->As<type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<sem::Sampler>());
+ EXPECT_FALSE(t->As<sem::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
@@ -45,8 +45,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Sampler>());
- EXPECT_TRUE(t->As<type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<sem::Sampler>());
+ EXPECT_TRUE(t->As<sem::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_storage_texture_type_test.cc b/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
index 223c187..cd27e99 100644
--- a/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
@@ -32,7 +32,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k1d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@@ -41,7 +41,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k2d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -50,7 +50,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
+ EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -59,7 +59,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, type::TextureDimension::k3d);
+ EXPECT_EQ(t.value, sem::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
index 16bcf4b..d55f583 100644
--- a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
@@ -23,7 +23,7 @@
auto p = parser("{a : i32;}");
auto& builder = p->builder();
- auto* i32 = builder.create<type::I32>();
+ auto* i32 = builder.create<sem::I32>();
auto m = p->expect_struct_body_decl();
ASSERT_FALSE(p->has_error());
diff --git a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
index 1cf9aab..a4378b9 100644
--- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
+++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
@@ -38,8 +38,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Sampler>());
- ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<sem::Sampler>());
+ ASSERT_FALSE(t->As<sem::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
@@ -49,8 +49,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Sampler>());
- ASSERT_TRUE(t->As<type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<sem::Sampler>());
+ ASSERT_TRUE(t->As<sem::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
@@ -60,9 +60,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::DepthTexture>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::DepthTexture>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
@@ -72,10 +72,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::SampledTexture>());
- ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::SampledTexture>());
+ ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
@@ -85,10 +85,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::SampledTexture>());
- ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::SampledTexture>());
+ ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::I32>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
@@ -98,10 +98,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::SampledTexture>());
- ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::SampledTexture>());
+ ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::U32>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k3d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
@@ -151,10 +151,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::MultisampledTexture>());
- ASSERT_TRUE(t->As<type::MultisampledTexture>()->type()->Is<type::I32>());
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::MultisampledTexture>());
+ ASSERT_TRUE(t->As<sem::MultisampledTexture>()->type()->Is<sem::I32>());
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
@@ -205,11 +205,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::StorageTexture>());
- EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
- type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::StorageTexture>());
+ EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
+ sem::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
@@ -220,11 +220,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::StorageTexture>());
- EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
- type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::StorageTexture>());
+ EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
+ sem::ImageFormat::kR16Float);
+ EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index 04a712d..2cda3c3 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -22,23 +22,23 @@
TEST_F(ParserImplTest, TypeDecl_ParsesType) {
auto p = parser("type a = i32");
- auto* i32 = p->builder().create<type::I32>();
+ auto* i32 = p->builder().create<sem::I32>();
auto t = p->type_alias();
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Alias>());
- auto* alias = t->As<type::Alias>();
- ASSERT_TRUE(alias->type()->Is<type::I32>());
+ ASSERT_TRUE(t->Is<sem::Alias>());
+ auto* alias = t->As<sem::Alias>();
+ ASSERT_TRUE(alias->type()->Is<sem::I32>());
ASSERT_EQ(alias->type(), i32);
}
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
auto p = parser("type a = B");
- type::StructType str(p->builder().Symbols().Get("B"), {});
+ sem::StructType str(p->builder().Symbols().Get("B"), {});
p->register_constructed("B", &str);
auto t = p->type_alias();
@@ -46,12 +46,12 @@
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<type::Alias>());
- auto* alias = t->As<type::Alias>();
+ ASSERT_TRUE(t->Is<sem::Alias>());
+ auto* alias = t->As<sem::Alias>();
EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "a");
- ASSERT_TRUE(alias->type()->Is<type::StructType>());
+ ASSERT_TRUE(alias->type()->Is<sem::StructType>());
- auto* s = alias->type()->As<type::StructType>();
+ auto* s = alias->type()->As<sem::StructType>();
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
}
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index 66fc791..ba1b589 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -34,9 +34,9 @@
auto& builder = p->builder();
- auto* int_type = builder.create<type::I32>();
+ auto* int_type = builder.create<sem::I32>();
auto* alias_type =
- builder.create<type::Alias>(builder.Symbols().Register("A"), int_type);
+ builder.create<sem::Alias>(builder.Symbols().Register("A"), int_type);
p->register_constructed("A", alias_type);
@@ -45,9 +45,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, alias_type);
- ASSERT_TRUE(t->Is<type::Alias>());
+ ASSERT_TRUE(t->Is<sem::Alias>());
- auto* alias = t->As<type::Alias>();
+ auto* alias = t->As<sem::Alias>();
EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "A");
EXPECT_EQ(alias->type(), int_type);
}
@@ -67,56 +67,56 @@
auto p = parser("bool");
auto& builder = p->builder();
- auto* bool_type = builder.create<type::Bool>();
+ auto* bool_type = builder.create<sem::Bool>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, bool_type);
- ASSERT_TRUE(t->Is<type::Bool>());
+ ASSERT_TRUE(t->Is<sem::Bool>());
}
TEST_F(ParserImplTest, TypeDecl_F32) {
auto p = parser("f32");
auto& builder = p->builder();
- auto* float_type = builder.create<type::F32>();
+ auto* float_type = builder.create<sem::F32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, float_type);
- ASSERT_TRUE(t->Is<type::F32>());
+ ASSERT_TRUE(t->Is<sem::F32>());
}
TEST_F(ParserImplTest, TypeDecl_I32) {
auto p = parser("i32");
auto& builder = p->builder();
- auto* int_type = builder.create<type::I32>();
+ auto* int_type = builder.create<sem::I32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, int_type);
- ASSERT_TRUE(t->Is<type::I32>());
+ ASSERT_TRUE(t->Is<sem::I32>());
}
TEST_F(ParserImplTest, TypeDecl_U32) {
auto p = parser("u32");
auto& builder = p->builder();
- auto* uint_type = builder.create<type::U32>();
+ auto* uint_type = builder.create<sem::U32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, uint_type);
- ASSERT_TRUE(t->Is<type::U32>());
+ ASSERT_TRUE(t->Is<sem::U32>());
}
struct VecData {
@@ -138,8 +138,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<type::Vector>());
- EXPECT_EQ(t->As<type::Vector>()->size(), params.count);
+ EXPECT_TRUE(t->Is<sem::Vector>());
+ EXPECT_EQ(t->As<sem::Vector>()->size(), params.count);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
VecTest,
@@ -226,10 +226,10 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Pointer>());
+ ASSERT_TRUE(t->Is<sem::Pointer>());
- auto* ptr = t->As<type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = t->As<sem::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<sem::F32>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
}
@@ -240,15 +240,15 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Pointer>());
+ ASSERT_TRUE(t->Is<sem::Pointer>());
- auto* ptr = t->As<type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<type::Vector>());
+ auto* ptr = t->As<sem::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<sem::Vector>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
- auto* vec = ptr->type()->As<type::Vector>();
+ auto* vec = ptr->type()->As<sem::Vector>();
ASSERT_EQ(vec->size(), 2u);
- ASSERT_TRUE(vec->type()->Is<type::F32>());
+ ASSERT_TRUE(vec->type()->Is<sem::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
@@ -338,12 +338,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<type::F32>());
+ ASSERT_TRUE(a->type()->Is<sem::F32>());
EXPECT_EQ(a->decorations().size(), 0u);
}
@@ -354,12 +354,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<type::F32>());
+ ASSERT_TRUE(a->type()->Is<sem::F32>());
ASSERT_EQ(a->decorations().size(), 1u);
auto* stride = a->decorations()[0];
@@ -374,11 +374,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<type::F32>());
+ ASSERT_TRUE(a->type()->Is<sem::F32>());
ASSERT_EQ(a->decorations().size(), 1u);
auto* stride = a->decorations()[0];
@@ -393,11 +393,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<type::F32>());
+ ASSERT_TRUE(a->type()->Is<sem::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -414,11 +414,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<type::F32>());
+ ASSERT_TRUE(a->type()->Is<sem::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -517,11 +517,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<type::U32>());
+ ASSERT_TRUE(a->type()->Is<sem::U32>());
}
TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) {
@@ -531,9 +531,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::ArrayType>());
+ ASSERT_TRUE(t->Is<sem::ArrayType>());
- auto* a = t->As<type::ArrayType>();
+ auto* a = t->As<sem::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->is_unsigned_integer_vector());
}
@@ -628,8 +628,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<type::Matrix>());
- auto* mat = t->As<type::Matrix>();
+ EXPECT_TRUE(t->Is<sem::Matrix>());
+ auto* mat = t->As<sem::Matrix>();
EXPECT_EQ(mat->rows(), params.rows);
EXPECT_EQ(mat->columns(), params.columns);
}
@@ -746,32 +746,32 @@
auto p = parser("sampler");
auto& builder = p->builder();
- auto* type = builder.create<type::Sampler>(type::SamplerKind::kSampler);
+ auto* type = builder.create<sem::Sampler>(sem::SamplerKind::kSampler);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<type::Sampler>());
- ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<sem::Sampler>());
+ ASSERT_FALSE(t->As<sem::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TypeDecl_Texture) {
auto p = parser("texture_cube<f32>");
auto& builder = p->builder();
- auto* type = builder.create<type::SampledTexture>(
- type::TextureDimension::kCube, ty.f32());
+ auto* type = builder.create<sem::SampledTexture>(sem::TextureDimension::kCube,
+ ty.f32());
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<type::Texture>());
- ASSERT_TRUE(t->Is<type::SampledTexture>());
- ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
+ ASSERT_TRUE(t->Is<sem::Texture>());
+ ASSERT_TRUE(t->Is<sem::SampledTexture>());
+ ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
}
} // namespace
diff --git a/src/reader/wgsl/parser_impl_variable_decl_test.cc b/src/reader/wgsl/parser_impl_variable_decl_test.cc
index 6fd1418..19ed638 100644
--- a/src/reader/wgsl/parser_impl_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_decl_test.cc
@@ -27,7 +27,7 @@
EXPECT_FALSE(v.errored);
EXPECT_EQ(v->name, "my_var");
EXPECT_NE(v->type, nullptr);
- EXPECT_TRUE(v->type->Is<type::F32>());
+ EXPECT_TRUE(v->type->Is<sem::F32>());
EXPECT_EQ(v->source.range.begin.line, 1u);
EXPECT_EQ(v->source.range.begin.column, 5u);
@@ -62,7 +62,7 @@
EXPECT_FALSE(v.errored);
EXPECT_FALSE(p->has_error());
EXPECT_EQ(v->name, "my_var");
- EXPECT_TRUE(v->type->Is<type::F32>());
+ EXPECT_TRUE(v->type->Is<sem::F32>());
EXPECT_EQ(v->storage_class, ast::StorageClass::kPrivate);
EXPECT_EQ(v->source.range.begin.line, 1u);
diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
index 2f9274f..4efdac3 100644
--- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
@@ -28,7 +28,7 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<type::F32>());
+ ASSERT_TRUE(decl->type->Is<sem::F32>());
ASSERT_EQ(decl->source.range.begin.line, 1u);
ASSERT_EQ(decl->source.range.begin.column, 1u);
@@ -84,11 +84,10 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<type::AccessControl>());
- EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
- ASSERT_TRUE(decl->type->As<type::AccessControl>()
- ->type()
- ->Is<type::StorageTexture>());
+ ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
+ EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadOnly());
+ ASSERT_TRUE(
+ decl->type->As<sem::AccessControl>()->type()->Is<sem::StorageTexture>());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
@@ -99,11 +98,10 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<type::AccessControl>());
- EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsWriteOnly());
- ASSERT_TRUE(decl->type->As<type::AccessControl>()
- ->type()
- ->Is<type::StorageTexture>());
+ ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
+ EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsWriteOnly());
+ ASSERT_TRUE(
+ decl->type->As<sem::AccessControl>()->type()->Is<sem::StorageTexture>());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
@@ -127,8 +125,8 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<type::AccessControl>());
- EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
+ ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
+ EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadOnly());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
@@ -152,8 +150,8 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<type::AccessControl>());
- EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadWrite());
+ ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
+ EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadWrite());
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
diff --git a/src/resolver/assignment_validation_test.cc b/src/resolver/assignment_validation_test.cc
index 83dbeec..875e379 100644
--- a/src/resolver/assignment_validation_test.cc
+++ b/src/resolver/assignment_validation_test.cc
@@ -255,12 +255,11 @@
// var b : [[access(read)]] texture_storage_1d<rgba8unorm>;
// a = b;
- auto* tex_type = create<type::StorageTexture>(
- type::TextureDimension::k1d, type::ImageFormat::kRgba8Unorm,
- type::StorageTexture::SubtypeFor(type::ImageFormat::kRgba8Unorm,
- Types()));
+ auto* tex_type = create<sem::StorageTexture>(
+ sem::TextureDimension::k1d, sem::ImageFormat::kRgba8Unorm,
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kRgba8Unorm, Types()));
auto* tex_ac =
- create<type::AccessControl>(ast::AccessControl::kReadOnly, tex_type);
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, tex_type);
auto* var_a = Var("a", tex_ac, ast::StorageClass::kFunction);
auto* var_b = Var("b", tex_ac, ast::StorageClass::kFunction);
diff --git a/src/resolver/builtins_validation_test.cc b/src/resolver/builtins_validation_test.cc
index 922e454..494a36d 100644
--- a/src/resolver/builtins_validation_test.cc
+++ b/src/resolver/builtins_validation_test.cc
@@ -113,50 +113,50 @@
WrapInFunction(Decl(a), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
- EXPECT_TRUE(TypeOf(builtin)->Is<type::F32>());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin)->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
auto* a = Var("a", ty.vec2<int>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.i32(), 2),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.i32(), 2),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("frexp", vec2<float>(1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
auto* a = Var("a", ty.vec3<int>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.i32(), 3),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.i32(), 3),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("frexp", vec3<float>(1.0f, 1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
auto* a = Var("a", ty.vec4<int>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.i32(), 4),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.i32(), 4),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("frexp", vec4<float>(1.0f, 1.0f, 1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
@@ -167,50 +167,50 @@
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
- EXPECT_TRUE(TypeOf(builtin)->Is<type::F32>());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin)->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
auto* a = Var("a", ty.vec2<float>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.f32(), 2),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.f32(), 2),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("modf", vec2<float>(1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
auto* a = Var("a", ty.vec3<float>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.f32(), 3),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.f32(), 3),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("modf", vec3<float>(1.0f, 1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
auto* a = Var("a", ty.vec4<float>(), ast::StorageClass::kFunction);
auto* b = Const("b",
- create<type::Pointer>(create<type::Vector>(ty.f32(), 4),
- ast::StorageClass::kFunction),
+ create<sem::Pointer>(create<sem::Vector>(ty.f32(), 4),
+ ast::StorageClass::kFunction),
Expr("a"), {});
auto* builtin = Call("modf", vec4<float>(1.0f, 1.0f, 1.0f, 1.0f), Expr("b"));
WrapInFunction(Decl(a), Decl(b), builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_TRUE(TypeOf(builtin)->is_float_vector());
- EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<type::Pointer>());
+ EXPECT_TRUE(TypeOf(builtin->params()[1])->Is<sem::Pointer>());
}
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
@@ -309,7 +309,7 @@
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
- EXPECT_TRUE(TypeOf(builtin)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(builtin)->Is<sem::F32>());
}
TEST_P(FloatAllMatching, Vec2) {
@@ -417,7 +417,7 @@
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
- EXPECT_TRUE(TypeOf(builtin)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(builtin)->Is<sem::U32>());
}
TEST_P(IntegerAllMatching, Vec2Unsigned) {
@@ -477,7 +477,7 @@
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
- EXPECT_TRUE(TypeOf(builtin)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(builtin)->Is<sem::I32>());
}
TEST_P(IntegerAllMatching, Vec2Signed) {
diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc
index cb3455e..cb4f29f 100644
--- a/src/resolver/decoration_validation_test.cc
+++ b/src/resolver/decoration_validation_test.cc
@@ -127,10 +127,9 @@
auto& params = GetParam();
ast::StructMemberList members{Member(
- "a",
- create<type::ArrayType>(ty.f32(), 0,
- ast::DecorationList{createDecoration(
- Source{{12, 34}}, *this, params.kind)}))};
+ "a", create<sem::ArrayType>(ty.f32(), 0,
+ ast::DecorationList{createDecoration(
+ Source{{12, 34}}, *this, params.kind)}))};
auto* s = create<ast::Struct>(
members, ast::DecorationList{create<ast::StructBlockDecoration>()});
auto* s_ty = ty.struct_("mystruct", s);
@@ -334,10 +333,10 @@
SCOPED_TRACE(ss.str());
auto* arr =
- create<type::ArrayType>(el_ty, 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(params.stride),
- });
+ create<sem::ArrayType>(el_ty, 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(params.stride),
+ });
Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput);
@@ -422,11 +421,11 @@
Params{ty_mat4x4<f32>, (default_mat4x4.align - 1) * 7, false}));
TEST_F(ArrayStrideTest, MultipleDecorations) {
- auto* arr = create<type::ArrayType>(ty.i32(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(4),
- create<ast::StrideDecoration>(4),
- });
+ auto* arr = create<sem::ArrayType>(ty.i32(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(4),
+ create<ast::StrideDecoration>(4),
+ });
Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput);
diff --git a/src/resolver/intrinsic_test.cc b/src/resolver/intrinsic_test.cc
index 60461fb..5d96e6b 100644
--- a/src/resolver/intrinsic_test.cc
+++ b/src/resolver/intrinsic_test.cc
@@ -61,7 +61,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- ASSERT_TRUE(TypeOf(expr)->Is<type::F32>());
+ ASSERT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
TEST_P(ResolverIntrinsicDerivativeTest, Vector) {
@@ -74,9 +74,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- ASSERT_TRUE(TypeOf(expr)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(expr)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->size(), 4u);
}
TEST_P(ResolverIntrinsicDerivativeTest, MissingParam) {
@@ -118,7 +118,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::Bool>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::Bool>());
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
ResolverIntrinsic,
@@ -136,9 +136,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- ASSERT_TRUE(TypeOf(expr)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::Bool>());
- EXPECT_EQ(TypeOf(expr)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::Bool>());
+ EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_FloatMethod, Scalar) {
@@ -152,7 +152,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::Bool>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::Bool>());
}
TEST_P(ResolverIntrinsicTest_FloatMethod, MissingParam) {
@@ -206,9 +206,9 @@
}
struct TextureTestParams {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
Texture type = Texture::kF32;
- type::ImageFormat format = type::ImageFormat::kR16Float;
+ sem::ImageFormat format = sem::ImageFormat::kR16Float;
};
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
out << data.dim << "_" << data.type;
@@ -223,17 +223,17 @@
/// @param dim dimensionality of the texture being sampled
/// @param scalar the scalar type
/// @returns a pointer to a type appropriate for the coord param
- type::Type* GetCoordsType(type::TextureDimension dim, type::Type* scalar) {
+ sem::Type* GetCoordsType(sem::TextureDimension dim, sem::Type* scalar) {
switch (dim) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
return scalar;
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
- return create<type::Vector>(scalar, 2);
- case type::TextureDimension::k3d:
- case type::TextureDimension::kCube:
- case type::TextureDimension::kCubeArray:
- return create<type::Vector>(scalar, 3);
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
+ return create<sem::Vector>(scalar, 2);
+ case sem::TextureDimension::k3d:
+ case sem::TextureDimension::kCube:
+ case sem::TextureDimension::kCubeArray:
+ return create<sem::Vector>(scalar, 3);
default:
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
}
@@ -241,19 +241,19 @@
}
void add_call_param(std::string name,
- type::Type* type,
+ sem::Type* type,
ast::ExpressionList* call_params) {
Global(name, type, ast::StorageClass::kInput);
call_params->push_back(Expr(name));
}
- type::Type* subtype(Texture type) {
+ sem::Type* subtype(Texture type) {
if (type == Texture::kF32) {
- return create<type::F32>();
+ return create<sem::F32>();
}
if (type == Texture::kI32) {
- return create<type::I32>();
+ return create<sem::I32>();
}
- return create<type::U32>();
+ return create<sem::U32>();
}
};
@@ -266,17 +266,17 @@
auto* coords_type = GetCoordsType(dim, ty.i32());
- auto* subtype = type::StorageTexture::SubtypeFor(format, Types());
- auto* texture_type = create<type::StorageTexture>(dim, format, subtype);
+ auto* subtype = sem::StorageTexture::SubtypeFor(format, Types());
+ auto* texture_type = create<sem::StorageTexture>(dim, format, subtype);
auto* ro_texture_type =
- create<type::AccessControl>(ast::AccessControl::kReadOnly, texture_type);
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, texture_type);
ast::ExpressionList call_params;
add_call_param("texture", ro_texture_type, &call_params);
add_call_param("coords", coords_type, &call_params);
- if (type::IsTextureArray(dim)) {
+ if (sem::IsTextureArray(dim)) {
add_call_param("array_index", ty.i32(), &call_params);
}
@@ -286,45 +286,45 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- ASSERT_TRUE(TypeOf(expr)->Is<type::Vector>());
+ ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
if (type == Texture::kF32) {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
} else if (type == Texture::kI32) {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::I32>());
} else {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::U32>());
}
- EXPECT_EQ(TypeOf(expr)->As<type::Vector>()->size(), 4u);
+ EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
ResolverTest,
ResolverIntrinsicTest_StorageTextureOperation,
testing::Values(
- TextureTestParams{type::TextureDimension::k1d, Texture::kF32,
- type::ImageFormat::kR16Float},
- TextureTestParams{type::TextureDimension::k1d, Texture::kI32,
- type::ImageFormat::kR16Sint},
- TextureTestParams{type::TextureDimension::k1d, Texture::kF32,
- type::ImageFormat::kR8Unorm},
- TextureTestParams{type::TextureDimension::k2d, Texture::kF32,
- type::ImageFormat::kR16Float},
- TextureTestParams{type::TextureDimension::k2d, Texture::kI32,
- type::ImageFormat::kR16Sint},
- TextureTestParams{type::TextureDimension::k2d, Texture::kF32,
- type::ImageFormat::kR8Unorm},
- TextureTestParams{type::TextureDimension::k2dArray, Texture::kF32,
- type::ImageFormat::kR16Float},
- TextureTestParams{type::TextureDimension::k2dArray, Texture::kI32,
- type::ImageFormat::kR16Sint},
- TextureTestParams{type::TextureDimension::k2dArray, Texture::kF32,
- type::ImageFormat::kR8Unorm},
- TextureTestParams{type::TextureDimension::k3d, Texture::kF32,
- type::ImageFormat::kR16Float},
- TextureTestParams{type::TextureDimension::k3d, Texture::kI32,
- type::ImageFormat::kR16Sint},
- TextureTestParams{type::TextureDimension::k3d, Texture::kF32,
- type::ImageFormat::kR8Unorm}));
+ TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
+ sem::ImageFormat::kR16Float},
+ TextureTestParams{sem::TextureDimension::k1d, Texture::kI32,
+ sem::ImageFormat::kR16Sint},
+ TextureTestParams{sem::TextureDimension::k1d, Texture::kF32,
+ sem::ImageFormat::kR8Unorm},
+ TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
+ sem::ImageFormat::kR16Float},
+ TextureTestParams{sem::TextureDimension::k2d, Texture::kI32,
+ sem::ImageFormat::kR16Sint},
+ TextureTestParams{sem::TextureDimension::k2d, Texture::kF32,
+ sem::ImageFormat::kR8Unorm},
+ TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
+ sem::ImageFormat::kR16Float},
+ TextureTestParams{sem::TextureDimension::k2dArray, Texture::kI32,
+ sem::ImageFormat::kR16Sint},
+ TextureTestParams{sem::TextureDimension::k2dArray, Texture::kF32,
+ sem::ImageFormat::kR8Unorm},
+ TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
+ sem::ImageFormat::kR16Float},
+ TextureTestParams{sem::TextureDimension::k3d, Texture::kI32,
+ sem::ImageFormat::kR16Sint},
+ TextureTestParams{sem::TextureDimension::k3d, Texture::kF32,
+ sem::ImageFormat::kR8Unorm}));
using ResolverIntrinsicTest_SampledTextureOperation =
ResolverIntrinsicTest_TextureOperation;
@@ -332,15 +332,15 @@
auto dim = GetParam().dim;
auto type = GetParam().type;
- type::Type* s = subtype(type);
+ sem::Type* s = subtype(type);
auto* coords_type = GetCoordsType(dim, ty.i32());
- auto* texture_type = create<type::SampledTexture>(dim, s);
+ auto* texture_type = create<sem::SampledTexture>(dim, s);
ast::ExpressionList call_params;
add_call_param("texture", texture_type, &call_params);
add_call_param("coords", coords_type, &call_params);
- if (dim == type::TextureDimension::k2dArray) {
+ if (dim == sem::TextureDimension::k2dArray) {
add_call_param("array_index", ty.i32(), &call_params);
}
add_call_param("level", ty.i32(), &call_params);
@@ -351,24 +351,24 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- ASSERT_TRUE(TypeOf(expr)->Is<type::Vector>());
+ ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
if (type == Texture::kF32) {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
} else if (type == Texture::kI32) {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::I32>());
} else {
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::U32>());
}
- EXPECT_EQ(TypeOf(expr)->As<type::Vector>()->size(), 4u);
+ EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
ResolverTest,
ResolverIntrinsicTest_SampledTextureOperation,
- testing::Values(TextureTestParams{type::TextureDimension::k1d},
- TextureTestParams{type::TextureDimension::k2d},
- TextureTestParams{type::TextureDimension::k2dArray},
- TextureTestParams{type::TextureDimension::k3d}));
+ testing::Values(TextureTestParams{sem::TextureDimension::k1d},
+ TextureTestParams{sem::TextureDimension::k2d},
+ TextureTestParams{sem::TextureDimension::k2dArray},
+ TextureTestParams{sem::TextureDimension::k3d}));
TEST_F(ResolverIntrinsicTest, Dot_Vec2) {
Global("my_var", ty.vec2<f32>(), ast::StorageClass::kInput);
@@ -379,7 +379,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Dot_Vec3) {
@@ -391,7 +391,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Dot_Vec4) {
@@ -403,7 +403,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Dot_Error_Scalar) {
@@ -448,9 +448,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::Vector>());
- EXPECT_EQ(TypeOf(expr)->As<type::Vector>()->size(), 3u);
- EXPECT_TRUE(TypeOf(expr)->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::Vector>());
+ EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->size(), 3u);
+ EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Select_Error_NoParams) {
@@ -550,7 +550,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::Void>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::Void>());
}
TEST_P(ResolverIntrinsicTest_Barrier, Error_TooManyParams) {
@@ -585,7 +585,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
}
TEST_P(ResolverIntrinsicTest_DataPacking, Error_IncorrectParamType) {
@@ -657,9 +657,9 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
if (pack4) {
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 4u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 4u);
} else {
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 2u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 2u);
}
}
@@ -696,7 +696,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_SingleParam, Error_NoParams) {
@@ -771,7 +771,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
}
TEST_F(ResolverIntrinsicDataTest, ArrayLength_Error_ArraySized) {
@@ -795,7 +795,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverIntrinsicDataTest, Normalize_Error_NoParams) {
@@ -818,7 +818,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicDataTest, FrexpVector) {
@@ -829,8 +829,8 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(call)->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicDataTest, Frexp_Error_FirstParamInt) {
@@ -901,7 +901,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicDataTest, ModfVector) {
@@ -912,8 +912,8 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(call)->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicDataTest, Modf_Error_FirstParamInt) {
@@ -996,7 +996,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Scalar) {
@@ -1008,7 +1008,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
}
TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Vector) {
@@ -1021,7 +1021,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Scalar) {
@@ -1033,7 +1033,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
}
TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Vector) {
@@ -1046,7 +1046,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Error_NoParams) {
@@ -1116,7 +1116,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_TwoParam, Error_NoTooManyParams) {
@@ -1179,7 +1179,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Cross) {
@@ -1191,7 +1191,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverIntrinsicTest, Cross_Error_NoArgs) {
@@ -1273,7 +1273,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverIntrinsicTest, Normalize_NoArgs) {
@@ -1313,7 +1313,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_ThreeParam, Error_NoParams) {
auto param = GetParam();
@@ -1365,7 +1365,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Scalar) {
@@ -1377,7 +1377,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
}
TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Vector) {
@@ -1391,7 +1391,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Scalar) {
@@ -1403,7 +1403,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
}
TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Vector) {
@@ -1417,7 +1417,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Error_NoParams) {
@@ -1468,7 +1468,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_Int_SingleParam, Error_NoParams) {
@@ -1506,7 +1506,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Unsigned) {
@@ -1518,7 +1518,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Float) {
@@ -1530,7 +1530,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Signed) {
@@ -1543,7 +1543,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Unsigned) {
@@ -1556,7 +1556,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Float) {
@@ -1570,7 +1570,7 @@
ASSERT_NE(TypeOf(call), nullptr);
EXPECT_TRUE(TypeOf(call)->is_float_vector());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->size(), 3u);
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->size(), 3u);
}
TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Error_NoParams) {
@@ -1606,7 +1606,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Determinant_3x3) {
@@ -1618,7 +1618,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Determinant_4x4) {
@@ -1630,7 +1630,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverIntrinsicTest, Determinant_NotSquare) {
@@ -1933,16 +1933,16 @@
switch (param.texture_dimension) {
default:
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
EXPECT_EQ(TypeOf(call)->type_name(), ty.i32()->type_name());
break;
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec2<i32>()->type_name());
break;
- case type::TextureDimension::k3d:
- case type::TextureDimension::kCube:
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::k3d:
+ case sem::TextureDimension::kCube:
+ case sem::TextureDimension::kCubeArray:
EXPECT_EQ(TypeOf(call)->type_name(), ty.vec3<i32>()->type_name());
break;
}
@@ -1960,8 +1960,8 @@
case ast::intrinsic::test::TextureKind::kMultisampled:
case ast::intrinsic::test::TextureKind::kStorage: {
auto* datatype = param.resultVectorComponentType(this);
- ASSERT_TRUE(TypeOf(call)->Is<type::Vector>());
- EXPECT_EQ(TypeOf(call)->As<type::Vector>()->type(), datatype);
+ ASSERT_TRUE(TypeOf(call)->Is<sem::Vector>());
+ EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->type(), datatype);
break;
}
case ast::intrinsic::test::TextureKind::kDepth: {
diff --git a/src/resolver/is_host_shareable_test.cc b/src/resolver/is_host_shareable_test.cc
index 8f1d802..707e1da 100644
--- a/src/resolver/is_host_shareable_test.cc
+++ b/src/resolver/is_host_shareable_test.cc
@@ -89,12 +89,12 @@
TEST_F(ResolverIsHostShareable, AccessControlVoid) {
EXPECT_FALSE(r()->IsHostShareable(
- create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
}
TEST_F(ResolverIsHostShareable, AccessControlI32) {
EXPECT_TRUE(r()->IsHostShareable(
- create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
}
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
diff --git a/src/resolver/is_storeable_test.cc b/src/resolver/is_storeable_test.cc
index 7f40f0f..f0d15c1 100644
--- a/src/resolver/is_storeable_test.cc
+++ b/src/resolver/is_storeable_test.cc
@@ -73,12 +73,12 @@
TEST_F(ResolverIsStorableTest, AccessControlVoid) {
EXPECT_FALSE(r()->IsStorable(
- create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
}
TEST_F(ResolverIsStorableTest, AccessControlI32) {
EXPECT_TRUE(r()->IsStorable(
- create<type::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, ty.i32())));
}
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 75b6224..56ce2a7 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -117,16 +117,15 @@
}
// https://gpuweb.github.io/gpuweb/wgsl.html#storable-types
-bool Resolver::IsStorable(type::Type* type) {
+bool Resolver::IsStorable(sem::Type* type) {
type = type->UnwrapIfNeeded();
- if (type->is_scalar() || type->Is<type::Vector>() ||
- type->Is<type::Matrix>()) {
+ if (type->is_scalar() || type->Is<sem::Vector>() || type->Is<sem::Matrix>()) {
return true;
}
- if (type::ArrayType* arr = type->As<type::ArrayType>()) {
+ if (sem::ArrayType* arr = type->As<sem::ArrayType>()) {
return IsStorable(arr->type());
}
- if (type::StructType* str = type->As<type::StructType>()) {
+ if (sem::StructType* str = type->As<sem::StructType>()) {
for (const auto* member : str->impl()->members()) {
if (!IsStorable(member->type())) {
return false;
@@ -138,21 +137,21 @@
}
// https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types
-bool Resolver::IsHostShareable(type::Type* type) {
+bool Resolver::IsHostShareable(sem::Type* type) {
type = type->UnwrapIfNeeded();
- if (type->IsAnyOf<type::I32, type::U32, type::F32>()) {
+ if (type->IsAnyOf<sem::I32, sem::U32, sem::F32>()) {
return true;
}
- if (auto* vec = type->As<type::Vector>()) {
+ if (auto* vec = type->As<sem::Vector>()) {
return IsHostShareable(vec->type());
}
- if (auto* mat = type->As<type::Matrix>()) {
+ if (auto* mat = type->As<sem::Matrix>()) {
return IsHostShareable(mat->type());
}
- if (auto* arr = type->As<type::ArrayType>()) {
+ if (auto* arr = type->As<sem::ArrayType>()) {
return IsHostShareable(arr->type());
}
- if (auto* str = type->As<type::StructType>()) {
+ if (auto* str = type->As<sem::StructType>()) {
for (auto* member : str->impl()->members()) {
if (!IsHostShareable(member->type())) {
return false;
@@ -163,7 +162,7 @@
return false;
}
-bool Resolver::IsValidAssignment(type::Type* lhs, type::Type* rhs) {
+bool Resolver::IsValidAssignment(sem::Type* lhs, sem::Type* rhs) {
// TODO(crbug.com/tint/659): This is a rough approximation, and is missing
// checks for writability of pointer storage class, access control, etc.
// This will need to be fixed after WGSL agrees the behavior of pointers /
@@ -184,7 +183,7 @@
// Process everything else in the order they appear in the module. This is
// necessary for validation of use-before-declaration.
for (auto* decl : builder_->AST().GlobalDeclarations()) {
- if (auto* ty = decl->As<type::Type>()) {
+ if (auto* ty = decl->As<sem::Type>()) {
if (!Type(ty)) {
return false;
}
@@ -209,7 +208,7 @@
if (marked_.count(node) == 0) {
if (node->Is<ast::AccessDecoration>()) {
// These are generated by the WGSL parser, used to build
- // type::AccessControls and then leaked.
+ // sem::AccessControls and then leaked.
// Once we introduce AST types, this should be fixed.
continue;
}
@@ -222,13 +221,13 @@
return true;
}
-bool Resolver::Type(type::Type* ty) {
+bool Resolver::Type(sem::Type* ty) {
ty = ty->UnwrapAliasIfNeeded();
- if (auto* str = ty->As<type::StructType>()) {
+ if (auto* str = ty->As<sem::StructType>()) {
if (!Structure(str)) {
return false;
}
- } else if (auto* arr = ty->As<type::ArrayType>()) {
+ } else if (auto* arr = ty->As<sem::ArrayType>()) {
if (!Array(arr, Source{})) {
return false;
}
@@ -237,7 +236,7 @@
}
Resolver::VariableInfo* Resolver::Variable(ast::Variable* var,
- type::Type* type /*=nullptr*/) {
+ sem::Type* type /*=nullptr*/) {
auto it = variable_to_info_.find(var);
if (it != variable_to_info_.end()) {
return it->second;
@@ -248,7 +247,7 @@
variable_to_info_.emplace(var, info);
// Resolve variable's type
- if (auto* arr = info->type->As<type::ArrayType>()) {
+ if (auto* arr = info->type->As<sem::ArrayType>()) {
if (!Array(arr, var->source())) {
return nullptr;
}
@@ -330,8 +329,8 @@
// store type must be a host-shareable structure type with block attribute,
// satisfying the storage class constraints.
- auto* access = info->type->As<type::AccessControl>();
- auto* str = access ? access->type()->As<type::StructType>() : nullptr;
+ auto* access = info->type->As<sem::AccessControl>();
+ auto* str = access ? access->type()->As<sem::StructType>() : nullptr;
if (!str) {
diagnostics_.add_error(
"variables declared in the <storage> storage class must be of an "
@@ -358,7 +357,7 @@
bool Resolver::ValidateVariable(const ast::Variable* var) {
auto* type = variable_to_info_[var]->type;
- if (auto* r = type->UnwrapAll()->As<type::ArrayType>()) {
+ if (auto* r = type->UnwrapAll()->As<sem::ArrayType>()) {
if (r->IsRuntimeArray()) {
diagnostics_.add_error(
"v-0015",
@@ -390,7 +389,7 @@
}
}
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
if (func->body()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
@@ -466,7 +465,7 @@
};
// Inner lambda that is applied to a type and all of its members.
auto validate_entry_point_decorations_inner =
- [&](const ast::DecorationList& decos, type::Type* ty, Source source,
+ [&](const ast::DecorationList& decos, sem::Type* ty, Source source,
ParamOrRetType param_or_ret, bool is_struct_member) {
// Scan decorations for pipeline IO attributes.
// Check for overlap with attributes that have been seen previously.
@@ -519,7 +518,7 @@
}
// Check that we saw a pipeline IO attribute iff we need one.
- if (Canonical(ty)->Is<type::StructType>()) {
+ if (Canonical(ty)->Is<sem::StructType>()) {
if (pipeline_io_attribute) {
diagnostics_.add_error(
"entry point IO attributes must not be used on structure " +
@@ -547,7 +546,7 @@
// Outer lambda for validating the entry point decorations for a type.
auto validate_entry_point_decorations = [&](const ast::DecorationList& decos,
- type::Type* ty, Source source,
+ sem::Type* ty, Source source,
ParamOrRetType param_or_ret) {
// Validate the decorations for the type.
if (!validate_entry_point_decorations_inner(decos, ty, source, param_or_ret,
@@ -555,12 +554,12 @@
return false;
}
- if (auto* struct_ty = Canonical(ty)->As<type::StructType>()) {
+ if (auto* struct_ty = Canonical(ty)->As<sem::StructType>()) {
// Validate the decorations for each struct members, and also check for
// invalid member types.
for (auto* member : struct_ty->impl()->members()) {
auto* member_ty = Canonical(member->type());
- if (member_ty->Is<type::StructType>()) {
+ if (member_ty->Is<sem::StructType>()) {
diagnostics_.add_error(
"entry point IO types cannot contain nested structures",
member->source());
@@ -568,7 +567,7 @@
builder_->Symbols().NameFor(func->symbol()),
func->source());
return false;
- } else if (auto* arr = member_ty->As<type::ArrayType>()) {
+ } else if (auto* arr = member_ty->As<sem::ArrayType>()) {
if (arr->IsRuntimeArray()) {
diagnostics_.add_error(
"entry point IO types cannot contain runtime sized arrays",
@@ -603,7 +602,7 @@
}
}
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
builtins.clear();
locations.clear();
if (!validate_entry_point_decorations(func->return_type_decorations(),
@@ -646,7 +645,7 @@
return false;
}
- if (auto* str = param_info->type->As<type::StructType>()) {
+ if (auto* str = param_info->type->As<sem::StructType>()) {
auto* info = Structure(str);
if (!info) {
return false;
@@ -670,7 +669,7 @@
}
}
- if (auto* str = Canonical(func->return_type())->As<type::StructType>()) {
+ if (auto* str = Canonical(func->return_type())->As<sem::StructType>()) {
if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str,
func->source())) {
diagnostics_.add_note("while instantiating return type for " +
@@ -945,13 +944,13 @@
auto* res = TypeOf(expr->array());
auto* parent_type = res->UnwrapAll();
- type::Type* ret = nullptr;
- if (auto* arr = parent_type->As<type::ArrayType>()) {
+ sem::Type* ret = nullptr;
+ if (auto* arr = parent_type->As<sem::ArrayType>()) {
ret = arr->type();
- } else if (auto* vec = parent_type->As<type::Vector>()) {
+ } else if (auto* vec = parent_type->As<sem::Vector>()) {
ret = vec->type();
- } else if (auto* mat = parent_type->As<type::Matrix>()) {
- ret = builder_->create<type::Vector>(mat->type(), mat->rows());
+ } else if (auto* mat = parent_type->As<sem::Matrix>()) {
+ ret = builder_->create<sem::Vector>(mat->type(), mat->rows());
} else {
diagnostics_.add_error("invalid parent type (" + parent_type->type_name() +
") in array accessor",
@@ -960,13 +959,13 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<type::Pointer>()) {
- ret = builder_->create<type::Pointer>(ret, ptr->storage_class());
- } else if (auto* arr = parent_type->As<type::ArrayType>()) {
+ if (auto* ptr = res->As<sem::Pointer>()) {
+ ret = builder_->create<sem::Pointer>(ret, ptr->storage_class());
+ } else if (auto* arr = parent_type->As<sem::ArrayType>()) {
if (!arr->type()->is_scalar()) {
// If we extract a non-scalar from an array then we also get a pointer. We
// will generate a Function storage class variable to store this into.
- ret = builder_->create<type::Pointer>(ret, ast::StorageClass::kFunction);
+ ret = builder_->create<sem::Pointer>(ret, ast::StorageClass::kFunction);
}
}
SetType(expr, ret);
@@ -1055,7 +1054,7 @@
bool Resolver::IntrinsicCall(ast::CallExpression* call,
sem::IntrinsicType intrinsic_type) {
- std::vector<type::Type*> arg_tys;
+ std::vector<sem::Type*> arg_tys;
arg_tys.reserve(call->params().size());
for (auto* expr : call->params()) {
arg_tys.emplace_back(TypeOf(expr));
@@ -1088,10 +1087,10 @@
// Now that the argument types have been determined, make sure that they
// obey the constructor type rules laid out in
// https://gpuweb.github.io/gpuweb/wgsl.html#type-constructor-expr.
- if (auto* vec_type = type_ctor->type()->As<type::Vector>()) {
+ if (auto* vec_type = type_ctor->type()->As<sem::Vector>()) {
return ValidateVectorConstructor(vec_type, type_ctor->values());
}
- if (auto* mat_type = type_ctor->type()->As<type::Matrix>()) {
+ if (auto* mat_type = type_ctor->type()->As<sem::Matrix>()) {
return ValidateMatrixConstructor(mat_type, type_ctor->values());
}
// TODO(crbug.com/tint/634): Validate array constructor
@@ -1104,12 +1103,12 @@
return true;
}
-bool Resolver::ValidateVectorConstructor(const type::Vector* vec_type,
+bool Resolver::ValidateVectorConstructor(const sem::Vector* vec_type,
const ast::ExpressionList& values) {
- type::Type* elem_type = vec_type->type()->UnwrapAll();
+ sem::Type* elem_type = vec_type->type()->UnwrapAll();
size_t value_cardinality_sum = 0;
for (auto* value : values) {
- type::Type* value_type = TypeOf(value)->UnwrapAll();
+ sem::Type* value_type = TypeOf(value)->UnwrapAll();
if (value_type->is_scalar()) {
if (elem_type != value_type) {
diagnostics_.add_error(
@@ -1122,8 +1121,8 @@
}
value_cardinality_sum++;
- } else if (auto* value_vec = value_type->As<type::Vector>()) {
- type::Type* value_elem_type = value_vec->type()->UnwrapAll();
+ } else if (auto* value_vec = value_type->As<sem::Vector>()) {
+ sem::Type* value_elem_type = value_vec->type()->UnwrapAll();
// A mismatch of vector type parameter T is only an error if multiple
// arguments are present. A single argument constructor constitutes a
// type conversion expression.
@@ -1172,14 +1171,14 @@
return true;
}
-bool Resolver::ValidateMatrixConstructor(const type::Matrix* matrix_type,
+bool Resolver::ValidateMatrixConstructor(const sem::Matrix* matrix_type,
const ast::ExpressionList& values) {
// Zero Value expression
if (values.empty()) {
return true;
}
- type::Type* elem_type = matrix_type->type()->UnwrapAll();
+ sem::Type* elem_type = matrix_type->type()->UnwrapAll();
if (matrix_type->columns() != values.size()) {
const Source& values_start = values[0]->source();
const Source& values_end = values[values.size() - 1]->source();
@@ -1193,8 +1192,8 @@
}
for (auto* value : values) {
- type::Type* value_type = TypeOf(value)->UnwrapAll();
- auto* value_vec = value_type->As<type::Vector>();
+ sem::Type* value_type = TypeOf(value)->UnwrapAll();
+ auto* value_vec = value_type->As<sem::Vector>();
if (!value_vec || value_vec->size() != matrix_type->rows() ||
elem_type != value_vec->type()->UnwrapAll()) {
@@ -1220,11 +1219,11 @@
// the pointer around the variable type.
if (var->declaration->is_const()) {
SetType(expr, var->type);
- } else if (var->type->Is<type::Pointer>()) {
+ } else if (var->type->Is<sem::Pointer>()) {
SetType(expr, var->type);
} else {
SetType(expr,
- builder_->create<type::Pointer>(var->type, var->storage_class));
+ builder_->create<sem::Pointer>(var->type, var->storage_class));
}
var->users.push_back(expr);
@@ -1293,10 +1292,10 @@
auto* res = TypeOf(expr->structure());
auto* data_type = res->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
- type::Type* ret = nullptr;
+ sem::Type* ret = nullptr;
std::vector<uint32_t> swizzle;
- if (auto* ty = data_type->As<type::StructType>()) {
+ if (auto* ty = data_type->As<sem::StructType>()) {
Mark(expr->member());
auto symbol = expr->member()->symbol();
auto* str = Structure(ty);
@@ -1318,13 +1317,13 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<type::Pointer>()) {
- ret = builder_->create<type::Pointer>(ret, ptr->storage_class());
+ if (auto* ptr = res->As<sem::Pointer>()) {
+ ret = builder_->create<sem::Pointer>(ret, ptr->storage_class());
}
builder_->Sem().Add(expr, builder_->create<sem::StructMemberAccess>(
expr, ret, current_statement_, member));
- } else if (auto* vec = data_type->As<type::Vector>()) {
+ } else if (auto* vec = data_type->As<sem::Vector>()) {
Mark(expr->member());
std::string str = builder_->Symbols().NameFor(expr->member()->symbol());
auto size = str.size();
@@ -1381,14 +1380,14 @@
// A single element swizzle is just the type of the vector.
ret = vec->type();
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<type::Pointer>()) {
- ret = builder_->create<type::Pointer>(ret, ptr->storage_class());
+ if (auto* ptr = res->As<sem::Pointer>()) {
+ ret = builder_->create<sem::Pointer>(ret, ptr->storage_class());
}
} else {
// The vector will have a number of components equal to the length of
// the swizzle.
- ret = builder_->create<type::Vector>(vec->type(),
- static_cast<uint32_t>(size));
+ ret = builder_->create<sem::Vector>(vec->type(),
+ static_cast<uint32_t>(size));
}
builder_->Sem().Add(
expr, builder_->create<sem::Swizzle>(expr, ret, current_statement_,
@@ -1407,12 +1406,12 @@
}
bool Resolver::ValidateBinary(ast::BinaryExpression* expr) {
- using Bool = type::Bool;
- using F32 = type::F32;
- using I32 = type::I32;
- using U32 = type::U32;
- using Matrix = type::Matrix;
- using Vector = type::Vector;
+ using Bool = sem::Bool;
+ using F32 = sem::F32;
+ using I32 = sem::I32;
+ using U32 = sem::U32;
+ using Matrix = sem::Matrix;
+ using Vector = sem::Vector;
auto* lhs_declared_type = TypeOf(expr->lhs())->UnwrapAll();
auto* rhs_declared_type = TypeOf(expr->rhs())->UnwrapAll();
@@ -1592,11 +1591,11 @@
if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() ||
expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() ||
expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) {
- auto* bool_type = builder_->create<type::Bool>();
+ auto* bool_type = builder_->create<sem::Bool>();
auto* param_type = TypeOf(expr->lhs())->UnwrapAll();
- type::Type* result_type = bool_type;
- if (auto* vec = param_type->As<type::Vector>()) {
- result_type = builder_->create<type::Vector>(bool_type, vec->size());
+ sem::Type* result_type = bool_type;
+ if (auto* vec = param_type->As<sem::Vector>()) {
+ result_type = builder_->create<sem::Vector>(bool_type, vec->size());
}
SetType(expr, result_type);
return true;
@@ -1607,20 +1606,20 @@
// Note, the ordering here matters. The later checks depend on the prior
// checks having been done.
- auto* lhs_mat = lhs_type->As<type::Matrix>();
- auto* rhs_mat = rhs_type->As<type::Matrix>();
- auto* lhs_vec = lhs_type->As<type::Vector>();
- auto* rhs_vec = rhs_type->As<type::Vector>();
- type::Type* result_type;
+ auto* lhs_mat = lhs_type->As<sem::Matrix>();
+ auto* rhs_mat = rhs_type->As<sem::Matrix>();
+ auto* lhs_vec = lhs_type->As<sem::Vector>();
+ auto* rhs_vec = rhs_type->As<sem::Vector>();
+ sem::Type* result_type;
if (lhs_mat && rhs_mat) {
- result_type = builder_->create<type::Matrix>(
+ result_type = builder_->create<sem::Matrix>(
lhs_mat->type(), lhs_mat->rows(), rhs_mat->columns());
} else if (lhs_mat && rhs_vec) {
result_type =
- builder_->create<type::Vector>(lhs_mat->type(), lhs_mat->rows());
+ builder_->create<sem::Vector>(lhs_mat->type(), lhs_mat->rows());
} else if (lhs_vec && rhs_mat) {
result_type =
- builder_->create<type::Vector>(rhs_mat->type(), rhs_mat->columns());
+ builder_->create<sem::Vector>(rhs_mat->type(), rhs_mat->columns());
} else if (lhs_mat) {
// matrix * scalar
result_type = lhs_type;
@@ -1665,7 +1664,7 @@
ast::Variable* var = stmt->variable();
Mark(var);
- type::Type* type = var->declared_type();
+ sem::Type* type = var->declared_type();
bool is_global = false;
if (variable_stack_.get(var->symbol(), nullptr, &is_global)) {
@@ -1741,7 +1740,7 @@
return true;
}
-type::Type* Resolver::TypeOf(ast::Expression* expr) {
+sem::Type* Resolver::TypeOf(ast::Expression* expr) {
auto it = expr_info_.find(expr);
if (it != expr_info_.end()) {
return it->second.type;
@@ -1749,7 +1748,7 @@
return nullptr;
}
-void Resolver::SetType(ast::Expression* expr, type::Type* type) {
+void Resolver::SetType(ast::Expression* expr, sem::Type* type) {
if (expr_info_.count(expr)) {
TINT_ICE(builder_->Diagnostics())
<< "SetType() called twice for the same expression";
@@ -1865,7 +1864,7 @@
}
}
-bool Resolver::DefaultAlignAndSize(type::Type* ty,
+bool Resolver::DefaultAlignAndSize(sem::Type* ty,
uint32_t& align,
uint32_t& size,
const Source& source) {
@@ -1890,7 +1889,7 @@
align = 4;
size = 4;
return true;
- } else if (auto* vec = cty->As<type::Vector>()) {
+ } else if (auto* vec = cty->As<sem::Vector>()) {
if (vec->size() < 2 || vec->size() > 4) {
TINT_UNREACHABLE(diagnostics_)
<< "Invalid vector size: vec" << vec->size();
@@ -1899,7 +1898,7 @@
align = vector_align[vec->size()];
size = vector_size[vec->size()];
return true;
- } else if (auto* mat = cty->As<type::Matrix>()) {
+ } else if (auto* mat = cty->As<sem::Matrix>()) {
if (mat->columns() < 2 || mat->columns() > 4 || mat->rows() < 2 ||
mat->rows() > 4) {
TINT_UNREACHABLE(diagnostics_)
@@ -1909,16 +1908,16 @@
align = vector_align[mat->rows()];
size = vector_align[mat->rows()] * mat->columns();
return true;
- } else if (auto* s = cty->As<type::StructType>()) {
+ } else if (auto* s = cty->As<sem::StructType>()) {
if (auto* si = Structure(s)) {
align = si->align;
size = si->size;
return true;
}
return false;
- } else if (cty->Is<type::ArrayType>()) {
+ } else if (cty->Is<sem::ArrayType>()) {
if (auto* sem =
- Array(ty->UnwrapAliasIfNeeded()->As<type::ArrayType>(), source)) {
+ Array(ty->UnwrapAliasIfNeeded()->As<sem::ArrayType>(), source)) {
align = sem->Align();
size = sem->Size();
return true;
@@ -1929,7 +1928,7 @@
return false;
}
-const sem::Array* Resolver::Array(type::ArrayType* arr, const Source& source) {
+const sem::Array* Resolver::Array(sem::ArrayType* arr, const Source& source) {
if (auto* sem = builder_->Sem().Get(arr)) {
// Semantic info already constructed for this array type
return sem;
@@ -1998,9 +1997,9 @@
return create_semantic(implicit_stride);
}
-bool Resolver::ValidateStructure(const type::StructType* st) {
+bool Resolver::ValidateStructure(const sem::StructType* st) {
for (auto* member : st->impl()->members()) {
- if (auto* r = member->type()->UnwrapAll()->As<type::ArrayType>()) {
+ if (auto* r = member->type()->UnwrapAll()->As<sem::ArrayType>()) {
if (r->IsRuntimeArray()) {
if (member != st->impl()->members().back()) {
diagnostics_.add_error(
@@ -2053,7 +2052,7 @@
return true;
}
-Resolver::StructInfo* Resolver::Structure(type::StructType* str) {
+Resolver::StructInfo* Resolver::Structure(sem::StructType* str) {
auto info_it = struct_info_.find(str);
if (info_it != struct_info_.end()) {
// StructInfo already resolved for this structure type
@@ -2173,7 +2172,7 @@
}
bool Resolver::ValidateReturn(const ast::ReturnStatement* ret) {
- type::Type* func_type = current_function_->declaration->return_type();
+ sem::Type* func_type = current_function_->declaration->return_type();
auto* ret_type = ret->has_value() ? TypeOf(ret->value())->UnwrapAll()
: builder_->ty.void_();
@@ -2326,7 +2325,7 @@
// lhs must be a pointer or a constant
auto* lhs_result_type = TypeOf(lhs)->UnwrapIfNeeded();
- if (!lhs_result_type->Is<type::Pointer>()) {
+ if (!lhs_result_type->Is<sem::Pointer>()) {
// In case lhs is a constant identifier, output a nicer message as it's
// likely to be a common programmer error.
if (auto* ident = lhs->As<ast::IdentifierExpression>()) {
@@ -2365,11 +2364,11 @@
}
bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc,
- type::Type* ty,
+ sem::Type* ty,
const Source& usage) {
ty = ty->UnwrapIfNeeded();
- if (auto* str = ty->As<type::StructType>()) {
+ if (auto* str = ty->As<sem::StructType>()) {
auto* info = Structure(str);
if (!info) {
return false;
@@ -2391,7 +2390,7 @@
return true;
}
- if (auto* arr = ty->As<type::ArrayType>()) {
+ if (auto* arr = ty->As<sem::ArrayType>()) {
return ApplyStorageClassUsageToType(sc, arr->type(), usage);
}
@@ -2419,20 +2418,20 @@
return result;
}
-std::string Resolver::VectorPretty(uint32_t size, type::Type* element_type) {
- type::Vector vec_type(element_type, size);
+std::string Resolver::VectorPretty(uint32_t size, sem::Type* element_type) {
+ sem::Vector vec_type(element_type, size);
return vec_type.FriendlyName(builder_->Symbols());
}
-type::Type* Resolver::Canonical(type::Type* type) {
- using AccessControl = type::AccessControl;
- using Alias = type::Alias;
- using Matrix = type::Matrix;
- using Type = type::Type;
- using Vector = type::Vector;
+sem::Type* Resolver::Canonical(sem::Type* type) {
+ using AccessControl = sem::AccessControl;
+ using Alias = sem::Alias;
+ using Matrix = sem::Matrix;
+ using Type = sem::Type;
+ using Vector = sem::Vector;
std::function<Type*(Type*)> make_canonical;
- make_canonical = [&](Type* t) -> type::Type* {
+ make_canonical = [&](Type* t) -> sem::Type* {
// Unwrap alias sequence
Type* ct = t;
while (auto* p = ct->As<Alias>()) {
@@ -2470,7 +2469,7 @@
<< "At: " << node->source();
}
-Resolver::VariableInfo::VariableInfo(ast::Variable* decl, type::Type* ctype)
+Resolver::VariableInfo::VariableInfo(ast::Variable* decl, sem::Type* ctype)
: declaration(decl),
type(ctype),
storage_class(decl->declared_storage_class()) {}
diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h
index 740ebfa..23f8d6e 100644
--- a/src/resolver/resolver.h
+++ b/src/resolver/resolver.h
@@ -49,9 +49,9 @@
class Array;
class Statement;
} // namespace sem
-namespace type {
-class Struct;
-} // namespace type
+namespace sem {
+class StructType;
+} // namespace sem
namespace resolver {
@@ -73,34 +73,34 @@
/// @param type the given type
/// @returns true if the given type is storable
- static bool IsStorable(type::Type* type);
+ static bool IsStorable(sem::Type* type);
/// @param type the given type
/// @returns true if the given type is host-shareable
- static bool IsHostShareable(type::Type* type);
+ static bool IsHostShareable(sem::Type* type);
/// @param lhs the assignment store type (non-pointer)
/// @param rhs the assignment source type (non-pointer or pointer with
/// auto-deref)
/// @returns true an expression of type `rhs` can be assigned to a variable,
/// structure member or array element of type `lhs`
- static bool IsValidAssignment(type::Type* lhs, type::Type* rhs);
+ static bool IsValidAssignment(sem::Type* lhs, sem::Type* rhs);
/// @param type the input type
/// @returns the canonical type for `type`; that is, a type with all aliases
/// removed. For example, `Canonical(alias<alias<vec3<alias<f32>>>>)` is
/// `vec3<f32>`.
- type::Type* Canonical(type::Type* type);
+ sem::Type* Canonical(sem::Type* type);
private:
/// Structure holding semantic information about a variable.
/// Used to build the sem::Variable nodes at the end of resolving.
struct VariableInfo {
- VariableInfo(ast::Variable* decl, type::Type* type);
+ VariableInfo(ast::Variable* decl, sem::Type* type);
~VariableInfo();
ast::Variable* const declaration;
- type::Type* type;
+ sem::Type* type;
ast::StorageClass storage_class;
std::vector<ast::IdentifierExpression*> users;
};
@@ -124,7 +124,7 @@
/// Structure holding semantic information about an expression.
/// Used to build the sem::Expression nodes at the end of resolving.
struct ExpressionInfo {
- type::Type* type;
+ sem::Type* type;
sem::Statement* statement;
};
@@ -199,11 +199,11 @@
/// @param params the parameters to the method call
/// @param id out parameter for the external call ID. Must not be a nullptr.
/// @returns the return type of `name` in `path` or nullptr on error.
- type::Type* GetImportData(const Source& src,
- const std::string& path,
- const std::string& name,
- const ast::ExpressionList& params,
- uint32_t* id);
+ sem::Type* GetImportData(const Source& src,
+ const std::string& path,
+ const std::string& name,
+ const ast::ExpressionList& params,
+ uint32_t* id);
void set_referenced_from_function_if_needed(VariableInfo* var, bool local);
@@ -230,7 +230,7 @@
bool Statement(ast::Statement*);
bool Statements(const ast::StatementList&);
bool Switch(ast::SwitchStatement* s);
- bool Type(type::Type* ty);
+ bool Type(sem::Type* ty);
bool UnaryOp(ast::UnaryOpExpression*);
bool VariableDeclStatement(const ast::VariableDeclStatement*);
@@ -241,14 +241,14 @@
bool ValidateEntryPoint(const ast::Function* func);
bool ValidateFunction(const ast::Function* func);
bool ValidateGlobalVariable(const VariableInfo* var);
- bool ValidateMatrixConstructor(const type::Matrix* matrix_type,
+ bool ValidateMatrixConstructor(const sem::Matrix* matrix_type,
const ast::ExpressionList& values);
bool ValidateParameter(const ast::Variable* param);
bool ValidateReturn(const ast::ReturnStatement* ret);
- bool ValidateStructure(const type::StructType* st);
+ bool ValidateStructure(const sem::StructType* st);
bool ValidateSwitch(const ast::SwitchStatement* s);
bool ValidateVariable(const ast::Variable* param);
- bool ValidateVectorConstructor(const type::Vector* vec_type,
+ bool ValidateVectorConstructor(const sem::Vector* vec_type,
const ast::ExpressionList& values);
/// @returns the semantic information for the array `arr`, building it if it
@@ -256,18 +256,18 @@
/// returned.
/// @param arr the Array to get semantic information for
/// @param source the Source of the ast node with this array as its type
- const sem::Array* Array(type::ArrayType* arr, const Source& source);
+ const sem::Array* Array(sem::ArrayType* arr, const Source& source);
/// @returns the StructInfo for the structure `str`, building it if it hasn't
/// been constructed already. If an error is raised, nullptr is returned.
- StructInfo* Structure(type::StructType* str);
+ StructInfo* Structure(sem::StructType* str);
/// @returns the VariableInfo for the variable `var`, building it if it hasn't
/// been constructed already. If an error is raised, nullptr is returned.
/// @param var the variable to create or return the `VariableInfo` for
/// @param type optional type of `var` to use instead of
/// `var->declared_type()`. For type inference.
- VariableInfo* Variable(ast::Variable* var, type::Type* type = nullptr);
+ VariableInfo* Variable(ast::Variable* var, sem::Type* type = nullptr);
/// Records the storage class usage for the given type, and any transient
/// dependencies of the type. Validates that the type can be used for the
@@ -278,27 +278,27 @@
/// given type and storage class. Used for generating sensible error messages.
/// @returns true on success, false on error
bool ApplyStorageClassUsageToType(ast::StorageClass sc,
- type::Type* ty,
+ sem::Type* ty,
const Source& usage);
/// @param align the output default alignment in bytes for the type `ty`
/// @param size the output default size in bytes for the type `ty`
/// @param source the Source of the variable declaration of type `ty`
/// @returns true on success, false on error
- bool DefaultAlignAndSize(type::Type* ty,
+ bool DefaultAlignAndSize(sem::Type* ty,
uint32_t& align,
uint32_t& size,
const Source& source);
/// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression
- type::Type* TypeOf(ast::Expression* expr);
+ sem::Type* TypeOf(ast::Expression* expr);
/// Creates a sem::Expression node with the resolved type `type`, and
/// assigns this semantic node to the expression `expr`.
/// @param expr the expression
/// @param type the resolved type
- void SetType(ast::Expression* expr, type::Type* type);
+ void SetType(ast::Expression* expr, sem::Type* type);
/// Constructs a new BlockInfo with the given type and with #current_block_ as
/// its parent, assigns this to #current_block_, and then calls `callback`.
@@ -313,7 +313,7 @@
/// @param size the vector dimension
/// @param element_type scalar vector sub-element type
/// @return pretty string representation
- std::string VectorPretty(uint32_t size, type::Type* element_type);
+ std::string VectorPretty(uint32_t size, sem::Type* element_type);
/// Mark records that the given AST node has been visited, and asserts that
/// the given node has not already been seen. Diamonds in the AST are illegal.
@@ -330,8 +330,8 @@
std::unordered_map<const ast::Variable*, VariableInfo*> variable_to_info_;
std::unordered_map<ast::CallExpression*, FunctionCallInfo> function_calls_;
std::unordered_map<ast::Expression*, ExpressionInfo> expr_info_;
- std::unordered_map<type::StructType*, StructInfo*> struct_info_;
- std::unordered_map<type::Type*, type::Type*> type_to_canonical_;
+ std::unordered_map<sem::StructType*, StructInfo*> struct_info_;
+ std::unordered_map<sem::Type*, sem::Type*> type_to_canonical_;
std::unordered_set<ast::Node*> marked_;
FunctionInfo* current_function_ = nullptr;
sem::Statement* current_statement_ = nullptr;
diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc
index ffd7bb9..47f8654 100644
--- a/src/resolver/resolver_test.cc
+++ b/src/resolver/resolver_test.cc
@@ -67,8 +67,8 @@
ASSERT_NE(TypeOf(lhs), nullptr);
ASSERT_NE(TypeOf(rhs), nullptr);
- EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
EXPECT_EQ(StmtOf(lhs), assign);
EXPECT_EQ(StmtOf(rhs), assign);
}
@@ -89,8 +89,8 @@
ASSERT_NE(TypeOf(lhs), nullptr);
ASSERT_NE(TypeOf(rhs), nullptr);
- EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
EXPECT_EQ(StmtOf(lhs), assign);
EXPECT_EQ(StmtOf(rhs), assign);
EXPECT_EQ(BlockOf(assign), block);
@@ -109,8 +109,8 @@
ASSERT_NE(TypeOf(lhs), nullptr);
ASSERT_NE(TypeOf(rhs), nullptr);
- EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
EXPECT_EQ(StmtOf(lhs), assign);
EXPECT_EQ(StmtOf(rhs), assign);
EXPECT_EQ(BlockOf(lhs), block);
@@ -145,11 +145,11 @@
ASSERT_NE(TypeOf(else_rhs), nullptr);
ASSERT_NE(TypeOf(lhs), nullptr);
ASSERT_NE(TypeOf(rhs), nullptr);
- EXPECT_TRUE(TypeOf(stmt->condition())->Is<type::Bool>());
- EXPECT_TRUE(TypeOf(else_lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(else_rhs)->Is<type::F32>());
- EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(stmt->condition())->Is<sem::Bool>());
+ EXPECT_TRUE(TypeOf(else_lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(else_rhs)->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
EXPECT_EQ(StmtOf(lhs), assign);
EXPECT_EQ(StmtOf(rhs), assign);
EXPECT_EQ(StmtOf(cond), stmt);
@@ -181,10 +181,10 @@
ASSERT_NE(TypeOf(body_rhs), nullptr);
ASSERT_NE(TypeOf(continuing_lhs), nullptr);
ASSERT_NE(TypeOf(continuing_rhs), nullptr);
- EXPECT_TRUE(TypeOf(body_lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(body_rhs)->Is<type::F32>());
- EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(continuing_rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(body_lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(body_rhs)->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(continuing_rhs)->Is<sem::F32>());
EXPECT_EQ(BlockOf(body_lhs), body);
EXPECT_EQ(BlockOf(body_rhs), body);
EXPECT_EQ(BlockOf(continuing_lhs), continuing);
@@ -200,7 +200,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(cond), nullptr);
- EXPECT_TRUE(TypeOf(cond)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(cond)->Is<sem::I32>());
}
TEST_F(ResolverTest, Stmt_Return_WithoutValue) {
@@ -224,9 +224,9 @@
ASSERT_NE(TypeOf(lhs), nullptr);
ASSERT_NE(TypeOf(rhs), nullptr);
- EXPECT_TRUE(TypeOf(stmt->condition())->Is<type::I32>());
- EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<type::F32>());
- EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(stmt->condition())->Is<sem::I32>());
+ EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is<sem::F32>());
+ EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
EXPECT_EQ(BlockOf(lhs), case_block);
EXPECT_EQ(BlockOf(rhs), case_block);
}
@@ -244,7 +244,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
EXPECT_EQ(StmtOf(expr), call);
}
@@ -258,7 +258,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(init), nullptr);
- EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
}
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
@@ -272,7 +272,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(init), nullptr);
- EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
}
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
@@ -282,7 +282,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(init), nullptr);
- EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
EXPECT_EQ(StmtOf(init), nullptr);
}
@@ -327,13 +327,13 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(foo_i32_init), nullptr);
- EXPECT_TRUE(TypeOf(foo_i32_init)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(foo_i32_init)->Is<sem::I32>());
ASSERT_NE(TypeOf(foo_f32_init), nullptr);
- EXPECT_TRUE(TypeOf(foo_f32_init)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(foo_f32_init)->Is<sem::F32>());
ASSERT_NE(TypeOf(bar_i32_init), nullptr);
- EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapAll()->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapAll()->Is<sem::I32>());
ASSERT_NE(TypeOf(bar_f32_init), nullptr);
- EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapAll()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapAll()->Is<sem::F32>());
EXPECT_EQ(StmtOf(foo_i32_init), foo_i32_decl);
EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
@@ -379,11 +379,11 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mod_init), nullptr);
- EXPECT_TRUE(TypeOf(mod_init)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(mod_init)->Is<sem::F32>());
ASSERT_NE(TypeOf(fn_i32_init), nullptr);
- EXPECT_TRUE(TypeOf(fn_i32_init)->Is<type::I32>());
+ EXPECT_TRUE(TypeOf(fn_i32_init)->Is<sem::I32>());
ASSERT_NE(TypeOf(fn_f32_init), nullptr);
- EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapAll()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapAll()->Is<sem::F32>());
EXPECT_EQ(StmtOf(fn_i32_init), fn_i32_decl);
EXPECT_EQ(StmtOf(mod_init), nullptr);
EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
@@ -403,10 +403,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- ASSERT_TRUE(TypeOf(acc)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(acc)->Is<sem::Pointer>());
- auto* ptr = TypeOf(acc)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(acc)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_ArrayAccessor_Alias_Array) {
@@ -420,10 +420,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- ASSERT_TRUE(TypeOf(acc)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(acc)->Is<sem::Pointer>());
- auto* ptr = TypeOf(acc)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(acc)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_ArrayAccessor_Array_Constant) {
@@ -435,7 +435,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- EXPECT_TRUE(TypeOf(acc)->Is<type::F32>()) << TypeOf(acc)->type_name();
+ EXPECT_TRUE(TypeOf(acc)->Is<sem::F32>()) << TypeOf(acc)->type_name();
}
TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix) {
@@ -447,11 +447,11 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- ASSERT_TRUE(TypeOf(acc)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(acc)->Is<sem::Pointer>());
- auto* ptr = TypeOf(acc)->As<type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<type::Vector>());
- EXPECT_EQ(ptr->type()->As<type::Vector>()->size(), 3u);
+ auto* ptr = TypeOf(acc)->As<sem::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<sem::Vector>());
+ EXPECT_EQ(ptr->type()->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix_BothDimensions) {
@@ -463,10 +463,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- ASSERT_TRUE(TypeOf(acc)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(acc)->Is<sem::Pointer>());
- auto* ptr = TypeOf(acc)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(acc)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_ArrayAccessor_Vector) {
@@ -478,10 +478,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(acc), nullptr);
- ASSERT_TRUE(TypeOf(acc)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(acc)->Is<sem::Pointer>());
- auto* ptr = TypeOf(acc)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(acc)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Bitcast) {
@@ -493,7 +493,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(bitcast), nullptr);
- EXPECT_TRUE(TypeOf(bitcast)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(bitcast)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Call) {
@@ -507,7 +507,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
@@ -521,7 +521,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Call_WithParams) {
@@ -537,7 +537,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(param), nullptr);
- EXPECT_TRUE(TypeOf(param)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(param)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Call_Intrinsic) {
@@ -547,7 +547,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Cast) {
@@ -559,7 +559,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(cast), nullptr);
- EXPECT_TRUE(TypeOf(cast)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(cast)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Constructor_Scalar) {
@@ -569,7 +569,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(s), nullptr);
- EXPECT_TRUE(TypeOf(s)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(s)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
@@ -579,9 +579,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
@@ -591,9 +591,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
@@ -603,9 +603,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) {
@@ -617,8 +617,8 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(ident), nullptr);
- EXPECT_TRUE(TypeOf(ident)->Is<type::Pointer>());
- EXPECT_TRUE(TypeOf(ident)->As<type::Pointer>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(ident)->Is<sem::Pointer>());
+ EXPECT_TRUE(TypeOf(ident)->As<sem::Pointer>()->type()->Is<sem::F32>());
EXPECT_TRUE(CheckVarUsers(my_var, {ident}));
ASSERT_NE(VarOf(ident), nullptr);
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
@@ -633,7 +633,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(ident), nullptr);
- EXPECT_TRUE(TypeOf(ident)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(ident)->Is<sem::F32>());
EXPECT_TRUE(CheckVarUsers(my_var, {ident}));
ASSERT_NE(VarOf(ident), nullptr);
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
@@ -654,7 +654,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(my_var_a), nullptr);
- EXPECT_TRUE(TypeOf(my_var_a)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(my_var_a)->Is<sem::F32>());
EXPECT_EQ(StmtOf(my_var_a), decl);
EXPECT_TRUE(CheckVarUsers(var, {my_var_a}));
ASSERT_NE(VarOf(my_var_a), nullptr);
@@ -678,12 +678,12 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(my_var_a), nullptr);
- EXPECT_TRUE(TypeOf(my_var_a)->Is<type::Pointer>());
- EXPECT_TRUE(TypeOf(my_var_a)->As<type::Pointer>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(my_var_a)->Is<sem::Pointer>());
+ EXPECT_TRUE(TypeOf(my_var_a)->As<sem::Pointer>()->type()->Is<sem::F32>());
EXPECT_EQ(StmtOf(my_var_a), assign);
ASSERT_NE(TypeOf(my_var_b), nullptr);
- EXPECT_TRUE(TypeOf(my_var_b)->Is<type::Pointer>());
- EXPECT_TRUE(TypeOf(my_var_b)->As<type::Pointer>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(my_var_b)->Is<sem::Pointer>());
+ EXPECT_TRUE(TypeOf(my_var_b)->As<sem::Pointer>()->type()->Is<sem::F32>());
EXPECT_EQ(StmtOf(my_var_b), assign);
EXPECT_TRUE(CheckVarUsers(var, {my_var_a, my_var_b}));
ASSERT_NE(VarOf(my_var_a), nullptr);
@@ -709,12 +709,12 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(my_var_a), nullptr);
- EXPECT_TRUE(TypeOf(my_var_a)->Is<type::Pointer>());
- EXPECT_TRUE(TypeOf(my_var_a)->As<type::Pointer>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(my_var_a)->Is<sem::Pointer>());
+ EXPECT_TRUE(TypeOf(my_var_a)->As<sem::Pointer>()->type()->Is<sem::F32>());
EXPECT_EQ(StmtOf(my_var_a), assign);
ASSERT_NE(TypeOf(my_var_b), nullptr);
- EXPECT_TRUE(TypeOf(my_var_b)->Is<type::Pointer>());
- EXPECT_TRUE(TypeOf(my_var_b)->As<type::Pointer>()->type()->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(my_var_b)->Is<sem::Pointer>());
+ EXPECT_TRUE(TypeOf(my_var_b)->As<sem::Pointer>()->type()->Is<sem::F32>());
EXPECT_EQ(StmtOf(my_var_b), assign);
}
@@ -728,7 +728,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(call), nullptr);
- EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
}
TEST_F(ResolverTest, Expr_Identifier_Unknown) {
@@ -902,10 +902,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mem), nullptr);
- ASSERT_TRUE(TypeOf(mem)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(mem)->Is<sem::Pointer>());
- auto* ptr = TypeOf(mem)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(mem)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
ASSERT_TRUE(Sem().Get(mem)->Is<sem::StructMemberAccess>());
EXPECT_EQ(Sem()
.Get(mem)
@@ -932,10 +932,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mem), nullptr);
- ASSERT_TRUE(TypeOf(mem)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(mem)->Is<sem::Pointer>());
- auto* ptr = TypeOf(mem)->As<type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(mem)->As<sem::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<sem::F32>());
ASSERT_TRUE(Sem().Get(mem)->Is<sem::StructMemberAccess>());
}
@@ -948,9 +948,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mem), nullptr);
- ASSERT_TRUE(TypeOf(mem)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(mem)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(mem)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->size(), 4u);
ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
EXPECT_THAT(Sem().Get(mem)->As<sem::Swizzle>()->Indices(),
ElementsAre(0, 2, 1, 3));
@@ -965,10 +965,10 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mem), nullptr);
- ASSERT_TRUE(TypeOf(mem)->Is<type::Pointer>());
+ ASSERT_TRUE(TypeOf(mem)->Is<sem::Pointer>());
- auto* ptr = TypeOf(mem)->As<type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<type::F32>());
+ auto* ptr = TypeOf(mem)->As<sem::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<sem::F32>());
ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
EXPECT_THAT(Sem().Get(mem)->As<sem::Swizzle>()->Indices(), ElementsAre(2));
}
@@ -1004,7 +1004,7 @@
ast::DecorationList{});
auto* stB = ty.struct_("B", strctB);
- type::Vector vecB(stB, 3);
+ sem::Vector vecB(stB, 3);
auto* strctA = create<ast::Struct>(
ast::StructMemberList{Member("mem", &vecB)}, ast::DecorationList{});
@@ -1019,9 +1019,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(mem), nullptr);
- ASSERT_TRUE(TypeOf(mem)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(mem)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(mem)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->size(), 2u);
ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
}
@@ -1041,7 +1041,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(expr), nullptr);
- EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
+ EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
}
namespace ExprBinaryTest {
@@ -1247,17 +1247,17 @@
<< rhs_type->FriendlyName(Symbols());
// For vectors and matrices, wrap the sub type in an alias
- auto make_alias = [this](type::Type* type) -> type::Type* {
- type::Type* result;
- if (auto* v = type->As<type::Vector>()) {
- result = create<type::Vector>(
- create<type::Alias>(Symbols().New(), v->type()), v->size());
- } else if (auto* m = type->As<type::Matrix>()) {
+ auto make_alias = [this](sem::Type* type) -> sem::Type* {
+ sem::Type* result;
+ if (auto* v = type->As<sem::Vector>()) {
+ result = create<sem::Vector>(
+ create<sem::Alias>(Symbols().New(), v->type()), v->size());
+ } else if (auto* m = type->As<sem::Matrix>()) {
result =
- create<type::Matrix>(create<type::Alias>(Symbols().New(), m->type()),
- m->rows(), m->columns());
+ create<sem::Matrix>(create<sem::Alias>(Symbols().New(), m->type()),
+ m->rows(), m->columns());
} else {
- result = create<type::Alias>(Symbols().New(), type);
+ result = create<sem::Alias>(Symbols().New(), type);
}
return result;
};
@@ -1358,20 +1358,20 @@
uint32_t mat_rows = std::get<2>(GetParam());
uint32_t mat_cols = std::get<3>(GetParam());
- type::Type* lhs_type;
- type::Type* rhs_type;
- type::Type* result_type;
+ sem::Type* lhs_type;
+ sem::Type* rhs_type;
+ sem::Type* result_type;
bool is_valid_expr;
if (vec_by_mat) {
- lhs_type = create<type::Vector>(ty.f32(), vec_size);
- rhs_type = create<type::Matrix>(ty.f32(), mat_rows, mat_cols);
- result_type = create<type::Vector>(ty.f32(), mat_cols);
+ lhs_type = create<sem::Vector>(ty.f32(), vec_size);
+ rhs_type = create<sem::Matrix>(ty.f32(), mat_rows, mat_cols);
+ result_type = create<sem::Vector>(ty.f32(), mat_cols);
is_valid_expr = vec_size == mat_rows;
} else {
- lhs_type = create<type::Matrix>(ty.f32(), mat_rows, mat_cols);
- rhs_type = create<type::Vector>(ty.f32(), vec_size);
- result_type = create<type::Vector>(ty.f32(), mat_rows);
+ lhs_type = create<sem::Matrix>(ty.f32(), mat_rows, mat_cols);
+ rhs_type = create<sem::Vector>(ty.f32(), vec_size);
+ result_type = create<sem::Vector>(ty.f32(), mat_rows);
is_valid_expr = vec_size == mat_cols;
}
@@ -1410,10 +1410,9 @@
uint32_t rhs_mat_rows = std::get<2>(GetParam());
uint32_t rhs_mat_cols = std::get<3>(GetParam());
- auto* lhs_type = create<type::Matrix>(ty.f32(), lhs_mat_rows, lhs_mat_cols);
- auto* rhs_type = create<type::Matrix>(ty.f32(), rhs_mat_rows, rhs_mat_cols);
- auto* result_type =
- create<type::Matrix>(ty.f32(), lhs_mat_rows, rhs_mat_cols);
+ auto* lhs_type = create<sem::Matrix>(ty.f32(), lhs_mat_rows, lhs_mat_cols);
+ auto* rhs_type = create<sem::Matrix>(ty.f32(), rhs_mat_rows, rhs_mat_cols);
+ auto* result_type = create<sem::Matrix>(ty.f32(), lhs_mat_rows, rhs_mat_cols);
Global("lhs", lhs_type, ast::StorageClass::kInput);
Global("rhs", rhs_type, ast::StorageClass::kInput);
@@ -1455,9 +1454,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(der), nullptr);
- ASSERT_TRUE(TypeOf(der)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(der)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(der)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(der)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(der)->As<sem::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
UnaryOpExpressionTest,
diff --git a/src/resolver/resolver_test_helper.h b/src/resolver/resolver_test_helper.h
index b39f975..51701ad 100644
--- a/src/resolver/resolver_test_helper.h
+++ b/src/resolver/resolver_test_helper.h
@@ -105,96 +105,96 @@
class ResolverTestWithParam : public TestHelper,
public testing::TestWithParam<T> {};
-inline type::Type* ty_bool_(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_bool_(const ProgramBuilder::TypesBuilder& ty) {
return ty.bool_();
}
-inline type::Type* ty_i32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_i32(const ProgramBuilder::TypesBuilder& ty) {
return ty.i32();
}
-inline type::Type* ty_u32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_u32(const ProgramBuilder::TypesBuilder& ty) {
return ty.u32();
}
-inline type::Type* ty_f32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_f32(const ProgramBuilder::TypesBuilder& ty) {
return ty.f32();
}
using create_type_func_ptr =
- type::Type* (*)(const ProgramBuilder::TypesBuilder& ty);
+ sem::Type* (*)(const ProgramBuilder::TypesBuilder& ty);
template <typename T>
-type::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec2<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.vec2(type);
}
template <typename T>
-type::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec3<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.vec3(type);
}
template <typename T>
-type::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec4<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.vec4(type);
}
template <typename T>
-type::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat2x2<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.mat2x2(type);
}
template <typename T>
-type::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat3x3<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.mat3x3(type);
}
template <typename T>
-type::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat4x4<T>();
}
template <create_type_func_ptr create_type>
-type::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.mat4x4(type);
}
template <create_type_func_ptr create_type>
-type::Type* ty_alias(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_alias(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.alias("alias_" + type->type_name(), type);
}
template <create_type_func_ptr create_type>
-type::Type* ty_access(const ProgramBuilder::TypesBuilder& ty) {
+sem::Type* ty_access(const ProgramBuilder::TypesBuilder& ty) {
auto* type = create_type(ty);
return ty.access(ast::AccessControl::kReadOnly, type);
}
diff --git a/src/resolver/type_constructor_validation_test.cc b/src/resolver/type_constructor_validation_test.cc
index 81a44e1..bf1b84b 100644
--- a/src/resolver/type_constructor_validation_test.cc
+++ b/src/resolver/type_constructor_validation_test.cc
@@ -19,11 +19,11 @@
namespace {
/// @return the element type of `type` for vec and mat, otherwise `type` itself
-type::Type* ElementTypeOf(type::Type* type) {
- if (auto* v = type->As<type::Vector>()) {
+sem::Type* ElementTypeOf(sem::Type* type) {
+ if (auto* v = type->As<sem::Vector>()) {
return v->type();
}
- if (auto* m = type->As<type::Matrix>()) {
+ if (auto* m = type->As<sem::Matrix>()) {
return m->type();
}
return type;
diff --git a/src/resolver/validation_test.cc b/src/resolver/validation_test.cc
index ab1c622..4c26d0b 100644
--- a/src/resolver/validation_test.cc
+++ b/src/resolver/validation_test.cc
@@ -912,9 +912,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) {
@@ -924,9 +924,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec2U32_Success_Scalar) {
@@ -936,9 +936,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec2I32_Success_Scalar) {
@@ -948,9 +948,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec2Bool_Success_Scalar) {
@@ -960,9 +960,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::Bool>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec2_Success_Identity) {
@@ -972,9 +972,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest,
@@ -985,9 +985,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 2u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 2u);
}
TEST_F(ResolverValidationTest,
@@ -1174,9 +1174,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) {
@@ -1186,9 +1186,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3U32_Success_Scalar) {
@@ -1198,9 +1198,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3I32_Success_Scalar) {
@@ -1210,9 +1210,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3Bool_Success_Scalar) {
@@ -1222,9 +1222,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::Bool>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) {
@@ -1234,9 +1234,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) {
@@ -1246,9 +1246,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Identity) {
@@ -1258,9 +1258,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest,
@@ -1271,9 +1271,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 3u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 3u);
}
TEST_F(ResolverValidationTest,
@@ -1528,9 +1528,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) {
@@ -1540,9 +1540,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4U32_Success_Scalar) {
@@ -1552,9 +1552,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::U32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4I32_Success_Scalar) {
@@ -1564,9 +1564,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::I32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4Bool_Success_Scalar) {
@@ -1576,9 +1576,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::Bool>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) {
@@ -1588,9 +1588,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) {
@@ -1600,9 +1600,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) {
@@ -1612,9 +1612,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2AndVec2) {
@@ -1624,9 +1624,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) {
@@ -1636,9 +1636,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) {
@@ -1648,9 +1648,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Identity) {
@@ -1660,9 +1660,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest,
@@ -1673,9 +1673,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest,
@@ -1700,9 +1700,9 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_NE(TypeOf(tc), nullptr);
- ASSERT_TRUE(TypeOf(tc)->Is<type::Vector>());
- EXPECT_TRUE(TypeOf(tc)->As<type::Vector>()->type()->Is<type::F32>());
- EXPECT_EQ(TypeOf(tc)->As<type::Vector>()->size(), 4u);
+ ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
+ EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
+ EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->size(), 4u);
}
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
@@ -1731,7 +1731,7 @@
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* vec_type = create<type::Vector>(f32_alias, 2);
+ auto* vec_type = create<sem::Vector>(f32_alias, 2);
// vec2<Float32>(1.0f, 1u)
auto* tc = create<ast::TypeConstructorExpression>(
@@ -1749,7 +1749,7 @@
TEST_F(ResolverValidationTest,
Expr_Constructor_Vector_ElementTypeAlias_Success) {
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* vec_type = create<type::Vector>(f32_alias, 2);
+ auto* vec_type = create<sem::Vector>(f32_alias, 2);
// vec2<Float32>(1.0f, 1.0f)
auto* tc = create<ast::TypeConstructorExpression>(Source{{12, 34}}, vec_type,
@@ -1762,7 +1762,7 @@
TEST_F(ResolverValidationTest,
Expr_Constructor_Vector_ArgumentElementTypeAlias_Error) {
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* vec_type = create<type::Vector>(f32_alias, 2);
+ auto* vec_type = create<sem::Vector>(f32_alias, 2);
// vec3<u32>(vec<Float32>(), 1.0f)
auto* tc = vec3<u32>(create<ast::TypeConstructorExpression>(
@@ -1779,7 +1779,7 @@
TEST_F(ResolverValidationTest,
Expr_Constructor_Vector_ArgumentElementTypeAlias_Success) {
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* vec_type = create<type::Vector>(f32_alias, 2);
+ auto* vec_type = create<sem::Vector>(f32_alias, 2);
// vec3<f32>(vec<Float32>(), 1.0f)
auto* tc = vec3<f32>(create<ast::TypeConstructorExpression>(
@@ -1811,8 +1811,8 @@
// matNxM<f32>(vecM<f32>(), ...); with N - 1 arguments
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.f32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.f32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns - 1; i++) {
@@ -1835,8 +1835,8 @@
// matNxM<f32>(vecM<f32>(), ...); with N + 1 arguments
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.f32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.f32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns + 1; i++) {
@@ -1859,7 +1859,7 @@
// matNxM<f32>(1.0, 1.0, ...); N arguments
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -1888,9 +1888,9 @@
return;
}
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* valid_vec_type = create<type::Vector>(ty.f32(), param.rows);
- auto* invalid_vec_type = create<type::Vector>(ty.f32(), param.rows - 1);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* valid_vec_type = create<sem::Vector>(ty.f32(), param.rows);
+ auto* invalid_vec_type = create<sem::Vector>(ty.f32(), param.rows - 1);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns - 1; i++) {
@@ -1924,9 +1924,9 @@
return;
}
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* valid_vec_type = create<type::Vector>(ty.f32(), param.rows);
- auto* invalid_vec_type = create<type::Vector>(ty.f32(), param.rows + 1);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* valid_vec_type = create<sem::Vector>(ty.f32(), param.rows);
+ auto* invalid_vec_type = create<sem::Vector>(ty.f32(), param.rows + 1);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns - 1; i++) {
@@ -1954,8 +1954,8 @@
// matNxM<f32>(vecM<u32>(), ...); with N arguments
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.u32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.u32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -1978,7 +1978,7 @@
// matNxM<f32>();
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
auto* tc = create<ast::TypeConstructorExpression>(Source{{12, 40}},
matrix_type, ExprList());
WrapInFunction(tc);
@@ -1990,8 +1990,8 @@
// matNxM<f32>(vecM<f32>(), ...); with N arguments
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.f32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.f32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -2011,9 +2011,8 @@
const auto param = GetParam();
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* matrix_type =
- create<type::Matrix>(f32_alias, param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.u32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(f32_alias, param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.u32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -2037,9 +2036,8 @@
const auto param = GetParam();
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* matrix_type =
- create<type::Matrix>(f32_alias, param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.f32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(f32_alias, param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.f32(), param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -2069,8 +2067,8 @@
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
- auto* vec_type = create<type::Vector>(ty.f32(), param.rows);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* vec_type = create<sem::Vector>(ty.f32(), param.rows);
auto* vec_alias = ty.alias("VectorFloat2", vec_type);
ast::ExpressionList args;
@@ -2088,9 +2086,9 @@
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
auto* f32_alias = ty.alias("UnsignedInt", ty.u32());
- auto* vec_type = create<type::Vector>(f32_alias, param.rows);
+ auto* vec_type = create<sem::Vector>(f32_alias, param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
@@ -2112,9 +2110,9 @@
TEST_P(MatrixConstructorTest,
Expr_Constructor_ArgumentElementTypeAlias_Success) {
const auto param = GetParam();
- auto* matrix_type = create<type::Matrix>(ty.f32(), param.rows, param.columns);
+ auto* matrix_type = create<sem::Matrix>(ty.f32(), param.rows, param.columns);
auto* f32_alias = ty.alias("Float32", ty.f32());
- auto* vec_type = create<type::Vector>(f32_alias, param.rows);
+ auto* vec_type = create<sem::Vector>(f32_alias, param.rows);
ast::ExpressionList args;
for (uint32_t i = 1; i <= param.columns; i++) {
diff --git a/src/sem/array.cc b/src/sem/array.cc
index 2126a53..fefd8a1 100644
--- a/src/sem/array.cc
+++ b/src/sem/array.cc
@@ -19,7 +19,7 @@
namespace tint {
namespace sem {
-Array::Array(type::ArrayType* type,
+Array::Array(sem::ArrayType* type,
uint32_t align,
uint32_t size,
uint32_t stride)
diff --git a/src/sem/array.h b/src/sem/array.h
index c9861c6..68297b9 100644
--- a/src/sem/array.h
+++ b/src/sem/array.h
@@ -21,12 +21,9 @@
namespace tint {
-// Forward declarations
-namespace type {
-class ArrayType;
-} // namespace type
-
namespace sem {
+// Forward declarations
+class ArrayType;
/// Array holds the semantic information for Array nodes.
class Array : public Castable<Array, Node> {
@@ -37,10 +34,10 @@
/// @param size the byte size of the structure
/// @param stride the number of bytes from the start of one element of the
/// array to the start of the next element
- Array(type::ArrayType* type, uint32_t align, uint32_t size, uint32_t stride);
+ Array(sem::ArrayType* type, uint32_t align, uint32_t size, uint32_t stride);
/// @return the resolved type of the Array
- type::ArrayType* Type() const { return type_; }
+ sem::ArrayType* Type() const { return type_; }
/// @returns the byte alignment of the array
/// @note this may differ from the alignment of a structure member of this
@@ -57,7 +54,7 @@
uint32_t Stride() const { return stride_; }
private:
- type::ArrayType* const type_;
+ sem::ArrayType* const type_;
uint32_t const align_;
uint32_t const size_;
uint32_t const stride_;
diff --git a/src/sem/call_target.cc b/src/sem/call_target.cc
index b048f69..0ce35e9 100644
--- a/src/sem/call_target.cc
+++ b/src/sem/call_target.cc
@@ -21,7 +21,7 @@
namespace tint {
namespace sem {
-CallTarget::CallTarget(type::Type* return_type, const ParameterList& parameters)
+CallTarget::CallTarget(sem::Type* return_type, const ParameterList& parameters)
: return_type_(return_type), parameters_(parameters) {}
CallTarget::~CallTarget() = default;
diff --git a/src/sem/call_target.h b/src/sem/call_target.h
index e0085d4..8f4f013 100644
--- a/src/sem/call_target.h
+++ b/src/sem/call_target.h
@@ -23,9 +23,9 @@
namespace tint {
// Forward declarations
-namespace type {
+namespace sem {
class Type;
-} // namespace type
+} // namespace sem
namespace sem {
@@ -50,7 +50,7 @@
};
/// Parameter type
- type::Type* const type;
+ sem::Type* const type;
/// Parameter usage
Usage const usage = Usage::kNone;
};
@@ -80,10 +80,10 @@
/// Constructor
/// @param return_type the return type of the call target
/// @param parameters the parameters for the call target
- CallTarget(type::Type* return_type, const ParameterList& parameters);
+ CallTarget(sem::Type* return_type, const ParameterList& parameters);
/// @return the return type of the call target
- type::Type* ReturnType() const { return return_type_; }
+ sem::Type* ReturnType() const { return return_type_; }
/// Destructor
~CallTarget() override;
@@ -92,7 +92,7 @@
const ParameterList& Parameters() const { return parameters_; }
private:
- type::Type* const return_type_;
+ sem::Type* const return_type_;
ParameterList const parameters_;
};
diff --git a/src/sem/expression.cc b/src/sem/expression.cc
index 52c27c7..b3b2ee6 100644
--- a/src/sem/expression.cc
+++ b/src/sem/expression.cc
@@ -20,7 +20,7 @@
namespace sem {
Expression::Expression(ast::Expression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement)
: declaration_(declaration),
type_(type->UnwrapIfNeeded()),
diff --git a/src/sem/expression.h b/src/sem/expression.h
index 507699e..10d3eeb 100644
--- a/src/sem/expression.h
+++ b/src/sem/expression.h
@@ -19,16 +19,10 @@
#include "src/sem/node.h"
namespace tint {
-
+namespace sem {
// Forward declarations
-namespace sem {
class Statement;
-} // namespace sem
-namespace type {
class Type;
-} // namespace type
-
-namespace sem {
/// Expression holds the semantic information for expression nodes.
class Expression : public Castable<Expression, Node> {
@@ -38,11 +32,11 @@
/// @param type the resolved type of the expression
/// @param statement the statement that owns this expression
Expression(ast::Expression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement);
/// @return the resolved type of the expression
- type::Type* Type() const { return type_; }
+ sem::Type* Type() const { return type_; }
/// @return the statement that owns this expression
Statement* Stmt() const { return statement_; }
@@ -52,7 +46,7 @@
private:
ast::Expression* declaration_;
- type::Type* const type_;
+ sem::Type* const type_;
Statement* const statement_;
};
diff --git a/src/sem/function.cc b/src/sem/function.cc
index 64c294e..9d22258 100644
--- a/src/sem/function.cc
+++ b/src/sem/function.cc
@@ -117,12 +117,12 @@
}
Function::VariableBindings Function::ReferencedSamplerVariables() const {
- return ReferencedSamplerVariablesImpl(type::SamplerKind::kSampler);
+ return ReferencedSamplerVariablesImpl(sem::SamplerKind::kSampler);
}
Function::VariableBindings Function::ReferencedComparisonSamplerVariables()
const {
- return ReferencedSamplerVariablesImpl(type::SamplerKind::kComparisonSampler);
+ return ReferencedSamplerVariablesImpl(sem::SamplerKind::kComparisonSampler);
}
Function::VariableBindings Function::ReferencedSampledTextureVariables() const {
@@ -140,7 +140,7 @@
for (auto* var : ReferencedModuleVariables()) {
auto* unwrapped_type =
var->Declaration()->declared_type()->UnwrapIfNeeded();
- auto* storage_texture = unwrapped_type->As<type::StorageTexture>();
+ auto* storage_texture = unwrapped_type->As<sem::StorageTexture>();
if (storage_texture == nullptr) {
continue;
}
@@ -158,7 +158,7 @@
for (auto* var : ReferencedModuleVariables()) {
auto* unwrapped_type =
var->Declaration()->declared_type()->UnwrapIfNeeded();
- auto* storage_texture = unwrapped_type->As<type::DepthTexture>();
+ auto* storage_texture = unwrapped_type->As<sem::DepthTexture>();
if (storage_texture == nullptr) {
continue;
}
@@ -180,13 +180,13 @@
}
Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
- type::SamplerKind kind) const {
+ sem::SamplerKind kind) const {
VariableBindings ret;
for (auto* var : ReferencedModuleVariables()) {
auto* unwrapped_type =
var->Declaration()->declared_type()->UnwrapIfNeeded();
- auto* sampler = unwrapped_type->As<type::Sampler>();
+ auto* sampler = unwrapped_type->As<sem::Sampler>();
if (sampler == nullptr || sampler->kind() != kind) {
continue;
}
@@ -205,13 +205,13 @@
for (auto* var : ReferencedModuleVariables()) {
auto* unwrapped_type =
var->Declaration()->declared_type()->UnwrapIfNeeded();
- auto* texture = unwrapped_type->As<type::Texture>();
+ auto* texture = unwrapped_type->As<sem::Texture>();
if (texture == nullptr) {
continue;
}
- auto is_multisampled = texture->Is<type::MultisampledTexture>();
- auto is_sampled = texture->Is<type::SampledTexture>();
+ auto is_multisampled = texture->Is<sem::MultisampledTexture>();
+ auto is_sampled = texture->Is<sem::SampledTexture>();
if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) {
continue;
diff --git a/src/sem/function.h b/src/sem/function.h
index 9483f94..4069245 100644
--- a/src/sem/function.h
+++ b/src/sem/function.h
@@ -142,7 +142,7 @@
bool HasAncestorEntryPoint(Symbol sym) const;
private:
- VariableBindings ReferencedSamplerVariablesImpl(type::SamplerKind kind) const;
+ VariableBindings ReferencedSamplerVariablesImpl(sem::SamplerKind kind) const;
VariableBindings ReferencedSampledTextureVariablesImpl(
bool multisampled) const;
diff --git a/src/sem/intrinsic.cc b/src/sem/intrinsic.cc
index 6b95a1a..24260d1 100644
--- a/src/sem/intrinsic.cc
+++ b/src/sem/intrinsic.cc
@@ -195,7 +195,7 @@
}
Intrinsic::Intrinsic(IntrinsicType type,
- type::Type* return_type,
+ sem::Type* return_type,
const ParameterList& parameters)
: Base(return_type, parameters), type_(type) {}
diff --git a/src/sem/intrinsic.h b/src/sem/intrinsic.h
index b8fe7cb..a862733 100644
--- a/src/sem/intrinsic.h
+++ b/src/sem/intrinsic.h
@@ -174,7 +174,7 @@
/// @param return_type the return type for the intrinsic call
/// @param parameters the parameters for the intrinsic overload
Intrinsic(IntrinsicType type,
- type::Type* return_type,
+ sem::Type* return_type,
const ParameterList& parameters);
/// Destructor
diff --git a/src/sem/member_accessor_expression.cc b/src/sem/member_accessor_expression.cc
index aa73c0d..b2fccb9 100644
--- a/src/sem/member_accessor_expression.cc
+++ b/src/sem/member_accessor_expression.cc
@@ -26,7 +26,7 @@
MemberAccessorExpression::MemberAccessorExpression(
ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement)
: Base(declaration, type, statement) {}
@@ -34,7 +34,7 @@
StructMemberAccess::StructMemberAccess(
ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
const StructMember* member)
: Base(declaration, type, statement), member_(member) {}
@@ -42,7 +42,7 @@
StructMemberAccess::~StructMemberAccess() = default;
Swizzle::Swizzle(ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
std::vector<uint32_t> indices)
: Base(declaration, type, statement), indices_(std::move(indices)) {}
diff --git a/src/sem/member_accessor_expression.h b/src/sem/member_accessor_expression.h
index 1355445..d8665de 100644
--- a/src/sem/member_accessor_expression.h
+++ b/src/sem/member_accessor_expression.h
@@ -42,7 +42,7 @@
/// @param type the resolved type of the expression
/// @param statement the statement that owns this expression
MemberAccessorExpression(ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement);
/// Destructor
@@ -61,7 +61,7 @@
/// @param statement the statement that owns this expression
/// @param member the structure member
StructMemberAccess(ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
const StructMember* member);
@@ -85,7 +85,7 @@
/// @param statement the statement that
/// @param indices the swizzle indices
Swizzle(ast::MemberAccessorExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
std::vector<uint32_t> indices);
diff --git a/src/sem/struct.cc b/src/sem/struct.cc
index 4426800..94212eb 100644
--- a/src/sem/struct.cc
+++ b/src/sem/struct.cc
@@ -23,7 +23,7 @@
namespace tint {
namespace sem {
-Struct::Struct(type::StructType* type,
+Struct::Struct(sem::StructType* type,
StructMemberList members,
uint32_t align,
uint32_t size,
diff --git a/src/sem/struct.h b/src/sem/struct.h
index d4119f4..473775b 100644
--- a/src/sem/struct.h
+++ b/src/sem/struct.h
@@ -30,12 +30,11 @@
namespace ast {
class StructMember;
} // namespace ast
-namespace type {
-class StructType;
-} // namespace type
namespace sem {
+// Forward declarations
+class StructType;
class StructMember;
/// A vector of StructMember pointers.
@@ -63,7 +62,7 @@
/// alignment padding
/// @param storage_class_usage a set of all the storage class usages
/// @param pipeline_stage_uses a set of all the pipeline stage uses
- Struct(type::StructType* type,
+ Struct(sem::StructType* type,
StructMemberList members,
uint32_t align,
uint32_t size,
@@ -75,7 +74,7 @@
~Struct() override;
/// @returns the structure type
- type::StructType* Type() const { return type_; }
+ sem::StructType* Type() const { return type_; }
/// @returns the members of the structure
const StructMemberList& Members() const { return members_; }
@@ -128,7 +127,7 @@
}
private:
- type::StructType* const type_;
+ sem::StructType* const type_;
StructMemberList const members_;
uint32_t const align_;
uint32_t const size_;
diff --git a/src/sem/type_mappings.h b/src/sem/type_mappings.h
index fa4573f..52a1abd 100644
--- a/src/sem/type_mappings.h
+++ b/src/sem/type_mappings.h
@@ -29,21 +29,18 @@
class StructMember;
class Variable;
} // namespace ast
-namespace type {
-class ArrayType;
-class StructType;
-} // namespace type
namespace sem {
-
// Forward declarations
class Array;
+class ArrayType;
class Call;
class Expression;
class Function;
class MemberAccessorExpression;
class Statement;
class Struct;
+class StructType;
class StructMember;
class Variable;
@@ -53,13 +50,13 @@
/// rules will be used to infer the return type based on the argument type.
struct TypeMappings {
//! @cond Doxygen_Suppress
- Array* operator()(type::ArrayType*);
+ Array* operator()(sem::ArrayType*);
Call* operator()(ast::CallExpression*);
Expression* operator()(ast::Expression*);
Function* operator()(ast::Function*);
MemberAccessorExpression* operator()(ast::MemberAccessorExpression*);
Statement* operator()(ast::Statement*);
- Struct* operator()(type::StructType*);
+ Struct* operator()(sem::StructType*);
StructMember* operator()(ast::StructMember*);
Variable* operator()(ast::Variable*);
//! @endcond
diff --git a/src/sem/variable.cc b/src/sem/variable.cc
index 88d951e..89e4bec 100644
--- a/src/sem/variable.cc
+++ b/src/sem/variable.cc
@@ -24,18 +24,18 @@
namespace sem {
Variable::Variable(const ast::Variable* declaration,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage_class)
: declaration_(declaration), type_(type), storage_class_(storage_class) {}
Variable::~Variable() = default;
-type::Type* Variable::DeclaredType() const {
+sem::Type* Variable::DeclaredType() const {
return declaration_->declared_type();
}
VariableUser::VariableUser(ast::IdentifierExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
sem::Variable* variable)
: Base(declaration, type, statement), variable_(variable) {}
diff --git a/src/sem/variable.h b/src/sem/variable.h
index 056d5b6..6a0a618 100644
--- a/src/sem/variable.h
+++ b/src/sem/variable.h
@@ -27,12 +27,11 @@
class IdentifierExpression;
class Variable;
} // namespace ast
-namespace type {
-class Type;
-} // namespace type
namespace sem {
+// Forward declarations
+class Type;
class VariableUser;
/// Variable holds the semantic information for variables.
@@ -43,7 +42,7 @@
/// @param type the variable type
/// @param storage_class the variable storage class
Variable(const ast::Variable* declaration,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage_class);
/// Destructor
@@ -53,10 +52,10 @@
const ast::Variable* Declaration() const { return declaration_; }
/// @returns the canonical type for the variable
- type::Type* Type() const { return type_; }
+ sem::Type* Type() const { return type_; }
/// @returns the AST node's type. May be nullptr.
- type::Type* DeclaredType() const;
+ sem::Type* DeclaredType() const;
/// @returns the storage class for the variable
ast::StorageClass StorageClass() const { return storage_class_; }
@@ -69,7 +68,7 @@
private:
const ast::Variable* const declaration_;
- type::Type* const type_;
+ sem::Type* const type_;
ast::StorageClass const storage_class_;
std::vector<const VariableUser*> users_;
};
@@ -84,7 +83,7 @@
/// @param statement the statement that owns this expression
/// @param variable the semantic variable
VariableUser(ast::IdentifierExpression* declaration,
- type::Type* type,
+ sem::Type* type,
Statement* statement,
sem::Variable* variable);
diff --git a/src/transform/binding_remapper.cc b/src/transform/binding_remapper.cc
index af4b2ac..aa6b7ad 100644
--- a/src/transform/binding_remapper.cc
+++ b/src/transform/binding_remapper.cc
@@ -65,13 +65,13 @@
if (ac_it != remappings->access_controls.end()) {
ast::AccessControl ac = ac_it->second;
auto* ty = in->Sem().Get(var)->Type();
- type::Type* inner_ty = nullptr;
- if (auto* old_ac = ty->As<type::AccessControl>()) {
+ sem::Type* inner_ty = nullptr;
+ if (auto* old_ac = ty->As<sem::AccessControl>()) {
inner_ty = ctx.Clone(old_ac->type());
} else {
inner_ty = ctx.Clone(ty);
}
- auto* new_ty = ctx.dst->create<type::AccessControl>(ac, inner_ty);
+ auto* new_ty = ctx.dst->create<sem::AccessControl>(ac, inner_ty);
auto* new_var = ctx.dst->create<ast::Variable>(
ctx.Clone(var->source()), ctx.Clone(var->symbol()),
var->declared_storage_class(), new_ty, var->is_const(),
diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc
index c08495e..3f56cf0 100644
--- a/src/transform/bound_array_accessors.cc
+++ b/src/transform/bound_array_accessors.cc
@@ -42,8 +42,8 @@
auto& diags = ctx->dst->Diagnostics();
auto* ret_type = ctx->src->Sem().Get(expr->array())->Type()->UnwrapAll();
- if (!ret_type->Is<type::ArrayType>() && !ret_type->Is<type::Matrix>() &&
- !ret_type->Is<type::Vector>()) {
+ if (!ret_type->Is<sem::ArrayType>() && !ret_type->Is<sem::Matrix>() &&
+ !ret_type->Is<sem::Vector>()) {
return nullptr;
}
@@ -51,15 +51,15 @@
using u32 = ProgramBuilder::u32;
uint32_t size = 0;
- bool is_vec = ret_type->Is<type::Vector>();
- bool is_arr = ret_type->Is<type::ArrayType>();
+ bool is_vec = ret_type->Is<sem::Vector>();
+ bool is_arr = ret_type->Is<sem::ArrayType>();
if (is_vec || is_arr) {
- size = is_vec ? ret_type->As<type::Vector>()->size()
- : ret_type->As<type::ArrayType>()->size();
+ size = is_vec ? ret_type->As<sem::Vector>()->size()
+ : ret_type->As<sem::ArrayType>()->size();
} else {
// The row accessor would have been an embedded array accessor and already
// handled, so we just need to do columns here.
- size = ret_type->As<type::Matrix>()->columns();
+ size = ret_type->As<sem::Matrix>()->columns();
}
auto* const old_idx = expr->idx_expr();
diff --git a/src/transform/calculate_array_length.cc b/src/transform/calculate_array_length.cc
index c60a99d..01c0f5e 100644
--- a/src/transform/calculate_array_length.cc
+++ b/src/transform/calculate_array_length.cc
@@ -77,8 +77,8 @@
// get_buffer_size_intrinsic() emits the function decorated with
// BufferSizeIntrinsic that is transformed by the HLSL writer into a call to
// [RW]ByteAddressBuffer.GetDimensions().
- std::unordered_map<type::StructType*, Symbol> buffer_size_intrinsics;
- auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) {
+ std::unordered_map<sem::StructType*, Symbol> buffer_size_intrinsics;
+ auto get_buffer_size_intrinsic = [&](sem::StructType* buffer_type) {
return utils::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] {
auto name = ctx.dst->Symbols().New();
auto* func = ctx.dst->create<ast::Function>(
@@ -138,7 +138,7 @@
auto* storage_buffer_expr = accessor->structure();
auto* storage_buffer_sem = sem.Get(storage_buffer_expr);
auto* storage_buffer_type =
- storage_buffer_sem->Type()->UnwrapAll()->As<type::StructType>();
+ storage_buffer_sem->Type()->UnwrapAll()->As<sem::StructType>();
// Generate BufferSizeIntrinsic for this storage type if we haven't
// already
@@ -146,7 +146,7 @@
if (!storage_buffer_type) {
TINT_ICE(ctx.dst->Diagnostics())
- << "arrayLength(X.Y) expected X to be type::StructType, got "
+ << "arrayLength(X.Y) expected X to be sem::StructType, got "
<< storage_buffer_type->FriendlyName(ctx.src->Symbols());
break;
}
diff --git a/src/transform/canonicalize_entry_point_io.cc b/src/transform/canonicalize_entry_point_io.cc
index 3066d23..90d72b1 100644
--- a/src/transform/canonicalize_entry_point_io.cc
+++ b/src/transform/canonicalize_entry_point_io.cc
@@ -66,7 +66,7 @@
// Strip entry point IO decorations from struct declarations.
// TODO(jrprice): This code is duplicated with the SPIR-V transform.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
- if (auto* struct_ty = ty->As<type::StructType>()) {
+ if (auto* struct_ty = ty->As<sem::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -81,7 +81,7 @@
}
// Redeclare the struct.
- auto* new_struct = ctx.dst->create<type::StructType>(
+ auto* new_struct = ctx.dst->create<sem::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -107,11 +107,11 @@
std::function<ast::Expression*()> func_const_initializer;
- if (auto* struct_ty = param_ty->As<type::StructType>()) {
+ if (auto* struct_ty = param_ty->As<sem::StructType>()) {
// Pull out all struct members and build initializer list.
std::vector<Symbol> member_names;
for (auto* member : struct_ty->impl()->members()) {
- if (member->type()->UnwrapAll()->Is<type::StructType>()) {
+ if (member->type()->UnwrapAll()->Is<sem::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -174,7 +174,7 @@
StructMemberComparator);
// Create the new struct type.
- auto* in_struct = ctx.dst->create<type::StructType>(
+ auto* in_struct = ctx.dst->create<sem::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -187,16 +187,16 @@
// Handle return type.
auto* ret_type = func->return_type()->UnwrapAliasIfNeeded();
- type::Type* new_ret_type;
- if (ret_type->Is<type::Void>()) {
+ sem::Type* new_ret_type;
+ if (ret_type->Is<sem::Void>()) {
new_ret_type = ctx.dst->ty.void_();
} else {
ast::StructMemberList new_struct_members;
- if (auto* struct_ty = ret_type->As<type::StructType>()) {
+ if (auto* struct_ty = ret_type->As<sem::StructType>()) {
// Rebuild struct with only the entry point IO attributes.
for (auto* member : struct_ty->impl()->members()) {
- if (member->type()->UnwrapAll()->Is<type::StructType>()) {
+ if (member->type()->UnwrapAll()->Is<sem::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -220,7 +220,7 @@
StructMemberComparator);
// Create the new struct type.
- auto* out_struct = ctx.dst->create<type::StructType>(
+ auto* out_struct = ctx.dst->create<sem::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -237,7 +237,7 @@
};
ast::ExpressionList ret_values;
- if (ret_type->Is<type::StructType>()) {
+ if (ret_type->Is<sem::StructType>()) {
if (!ret->value()->Is<ast::IdentifierExpression>()) {
// Create a const to hold the return value expression to avoid
// re-evaluating it multiple times.
diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc
index 0ae2587..ea9c5bb 100644
--- a/src/transform/decompose_storage_access.cc
+++ b/src/transform/decompose_storage_access.cc
@@ -57,7 +57,7 @@
ast::Expression* Build(CloneContext& ctx) override {
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapAll();
auto* res = ctx.Clone(expr);
- if (!type->Is<type::U32>()) {
+ if (!type->Is<sem::U32>()) {
res = ctx.dst->Construct<ProgramBuilder::u32>(res);
}
return res;
@@ -174,8 +174,8 @@
/// TypePair is a pair of types that can be used as a unordered map or set key.
struct TypePair {
- type::Type* first;
- type::Type* second;
+ sem::Type* first;
+ sem::Type* second;
bool operator==(const TypePair& rhs) const {
return first == rhs.first && second == rhs.second;
}
@@ -187,67 +187,67 @@
};
/// @returns the size in bytes of a scalar
-uint32_t ScalarSize(type::Type*) {
+uint32_t ScalarSize(sem::Type*) {
// TODO(bclayton): Assumes 32-bit elements
return 4;
}
/// @returns the numer of bytes between columns of the given matrix
-uint32_t MatrixColumnStride(type::Matrix* mat) {
+uint32_t MatrixColumnStride(sem::Matrix* mat) {
return ScalarSize(mat->type()) * ((mat->rows() == 2) ? 2 : 4);
}
/// @returns a DecomposeStorageAccess::Intrinsic decoration that can be applied
/// to a stub function to load the type `ty`.
DecomposeStorageAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder,
- type::Type* ty) {
+ sem::Type* ty) {
using Intrinsic = DecomposeStorageAccess::Intrinsic;
auto intrinsic = [builder](Intrinsic::Type type) {
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
};
- if (ty->Is<type::I32>()) {
+ if (ty->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadI32);
}
- if (ty->Is<type::U32>()) {
+ if (ty->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadU32);
}
- if (ty->Is<type::F32>()) {
+ if (ty->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadF32);
}
- if (auto* vec = ty->As<type::Vector>()) {
+ if (auto* vec = ty->As<sem::Vector>()) {
switch (vec->size()) {
case 2:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec2I32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec2U32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec2F32);
}
break;
case 3:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec3I32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec3U32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec3F32);
}
break;
case 4:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec4I32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec4U32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec4F32);
}
break;
@@ -259,54 +259,54 @@
/// @returns a DecomposeStorageAccess::Intrinsic decoration that can be applied
/// to a stub function to store the type `ty`.
DecomposeStorageAccess::Intrinsic* IntrinsicStoreFor(ProgramBuilder* builder,
- type::Type* ty) {
+ sem::Type* ty) {
using Intrinsic = DecomposeStorageAccess::Intrinsic;
auto intrinsic = [builder](Intrinsic::Type type) {
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
};
- if (ty->Is<type::I32>()) {
+ if (ty->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreI32);
}
- if (ty->Is<type::U32>()) {
+ if (ty->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreU32);
}
- if (ty->Is<type::F32>()) {
+ if (ty->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreF32);
}
- if (auto* vec = ty->As<type::Vector>()) {
+ if (auto* vec = ty->As<sem::Vector>()) {
switch (vec->size()) {
case 2:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec2U32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec2F32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec2I32);
}
break;
case 3:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec3U32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec3F32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec3I32);
}
break;
case 4:
- if (vec->type()->Is<type::I32>()) {
+ if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec4U32);
}
- if (vec->type()->Is<type::U32>()) {
+ if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec4F32);
}
- if (vec->type()->Is<type::F32>()) {
+ if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec4I32);
}
break;
@@ -328,20 +328,20 @@
}
/// @returns the unwrapped, user-declared constructed type of ty.
-type::Type* ConstructedTypeOf(type::Type* ty) {
+sem::Type* ConstructedTypeOf(sem::Type* ty) {
while (true) {
- if (auto* ptr = ty->As<type::Pointer>()) {
+ if (auto* ptr = ty->As<sem::Pointer>()) {
ty = ptr->type();
continue;
}
- if (auto* access = ty->As<type::AccessControl>()) {
+ if (auto* access = ty->As<sem::AccessControl>()) {
ty = access->type();
continue;
}
- if (auto* alias = ty->As<type::Alias>()) {
+ if (auto* alias = ty->As<sem::Alias>()) {
return alias;
}
- if (auto* str = ty->As<type::StructType>()) {
+ if (auto* str = ty->As<sem::StructType>()) {
return str;
}
// Not a constructed type
@@ -350,7 +350,7 @@
}
/// @returns the given type with all pointers and aliases removed.
-type::Type* UnwrapPtrAndAlias(type::Type* ty) {
+sem::Type* UnwrapPtrAndAlias(sem::Type* ty) {
return ty->UnwrapPtrIfNeeded()->UnwrapAliasIfNeeded()->UnwrapPtrIfNeeded();
}
@@ -358,7 +358,7 @@
struct StorageBufferAccess {
sem::Expression const* var = nullptr; // Storage buffer variable
std::unique_ptr<Offset> offset; // The byte offset on var
- type::Type* type = nullptr; // The type of the access
+ sem::Type* type = nullptr; // The type of the access
operator bool() const { return var; } // Returns true if valid
};
@@ -410,8 +410,8 @@
/// the signature: `fn load(buf : buf_ty, offset : u32) -> el_ty`
Symbol LoadFunc(CloneContext& ctx,
Cloneable* insert_after,
- type::Type* buf_ty,
- type::Type* el_ty) {
+ sem::Type* buf_ty,
+ sem::Type* el_ty) {
return utils::GetOrCreate(load_funcs, TypePair{buf_ty, el_ty}, [&] {
ast::VariableList params = {
// Note: The buffer parameter requires the kStorage StorageClass in
@@ -429,16 +429,16 @@
ast::DecorationList{intrinsic}, ast::DecorationList{});
} else {
ast::ExpressionList values;
- if (auto* mat_ty = el_ty->As<type::Matrix>()) {
- auto* vec_ty = ctx.dst->create<type::Vector>(
- ctx.Clone(mat_ty->type()), mat_ty->rows());
+ if (auto* mat_ty = el_ty->As<sem::Matrix>()) {
+ auto* vec_ty = ctx.dst->create<sem::Vector>(ctx.Clone(mat_ty->type()),
+ mat_ty->rows());
Symbol load = LoadFunc(ctx, insert_after, buf_ty, vec_ty);
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
auto* offset =
ctx.dst->Add("offset", i * MatrixColumnStride(mat_ty));
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
- } else if (auto* str_ty = el_ty->As<type::StructType>()) {
+ } else if (auto* str_ty = el_ty->As<sem::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -447,7 +447,7 @@
member->Declaration()->type()->UnwrapAll());
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
- } else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
+ } else if (auto* arr_ty = el_ty->As<sem::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -474,8 +474,8 @@
/// has the signature: `fn store(buf : buf_ty, offset : u32, value : el_ty)`
Symbol StoreFunc(CloneContext& ctx,
Cloneable* insert_after,
- type::Type* buf_ty,
- type::Type* el_ty) {
+ sem::Type* buf_ty,
+ sem::Type* el_ty) {
return utils::GetOrCreate(store_funcs, TypePair{buf_ty, el_ty}, [&] {
ast::VariableList params{
// Note: The buffer parameter requires the kStorage StorageClass in
@@ -494,9 +494,9 @@
} else {
ast::StatementList body;
- if (auto* mat_ty = el_ty->As<type::Matrix>()) {
- auto* vec_ty = ctx.dst->create<type::Vector>(
- ctx.Clone(mat_ty->type()), mat_ty->rows());
+ if (auto* mat_ty = el_ty->As<sem::Matrix>()) {
+ auto* vec_ty = ctx.dst->create<sem::Vector>(ctx.Clone(mat_ty->type()),
+ mat_ty->rows());
Symbol store = StoreFunc(ctx, insert_after, buf_ty, vec_ty);
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
auto* offset =
@@ -505,7 +505,7 @@
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
- } else if (auto* str_ty = el_ty->As<type::StructType>()) {
+ } else if (auto* str_ty = el_ty->As<sem::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -518,7 +518,7 @@
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
- } else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
+ } else if (auto* arr_ty = el_ty->As<sem::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -647,7 +647,7 @@
if (auto* swizzle = accessor_sem->As<sem::Swizzle>()) {
if (swizzle->Indices().size() == 1) {
if (auto access = state.TakeAccess(accessor->structure())) {
- auto* vec_ty = access.type->As<type::Vector>();
+ auto* vec_ty = access.type->As<sem::Vector>();
auto offset =
Mul(ScalarSize(vec_ty->type()), swizzle->Indices()[0]);
state.AddAccesss(
@@ -660,7 +660,7 @@
}
} else {
if (auto access = state.TakeAccess(accessor->structure())) {
- auto* str_ty = access.type->As<type::StructType>();
+ auto* str_ty = access.type->As<sem::StructType>();
auto* member =
sem.Get(str_ty)->FindMember(accessor->member()->symbol());
auto offset = member->Offset();
@@ -678,7 +678,7 @@
if (auto* accessor = node->As<ast::ArrayAccessorExpression>()) {
if (auto access = state.TakeAccess(accessor->array())) {
// X[Y]
- if (auto* arr_ty = access.type->As<type::ArrayType>()) {
+ if (auto* arr_ty = access.type->As<sem::ArrayType>()) {
auto stride = sem.Get(arr_ty)->Stride();
auto offset = Mul(stride, accessor->idx_expr());
state.AddAccesss(accessor,
@@ -689,7 +689,7 @@
});
continue;
}
- if (auto* vec_ty = access.type->As<type::Vector>()) {
+ if (auto* vec_ty = access.type->As<sem::Vector>()) {
auto offset = Mul(ScalarSize(vec_ty->type()), accessor->idx_expr());
state.AddAccesss(accessor,
{
@@ -699,9 +699,9 @@
});
continue;
}
- if (auto* mat_ty = access.type->As<type::Matrix>()) {
+ if (auto* mat_ty = access.type->As<sem::Matrix>()) {
auto offset = Mul(MatrixColumnStride(mat_ty), accessor->idx_expr());
- auto* vec_ty = ctx.dst->create<type::Vector>(
+ auto* vec_ty = ctx.dst->create<sem::Vector>(
ctx.Clone(mat_ty->type()->UnwrapAll()), mat_ty->rows());
state.AddAccesss(accessor,
{
diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc
index a1d7dbf..4d17f6e 100644
--- a/src/transform/hlsl.cc
+++ b/src/transform/hlsl.cc
@@ -96,7 +96,7 @@
}
auto* src_ty = src_sem_expr->Type();
- if (src_ty->IsAnyOf<type::ArrayType, type::StructType>()) {
+ if (src_ty->IsAnyOf<sem::ArrayType, sem::StructType>()) {
// Create a new symbol for the constant
auto dst_symbol = ctx.dst->Symbols().New();
// Clone the type
diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc
index b8c44e6..e16a22a 100644
--- a/src/transform/spirv.cc
+++ b/src/transform/spirv.cc
@@ -111,7 +111,7 @@
// Strip entry point IO decorations from struct declarations.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
- if (auto* struct_ty = ty->As<type::StructType>()) {
+ if (auto* struct_ty = ty->As<sem::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -126,7 +126,7 @@
}
// Redeclare the struct.
- auto* new_struct = ctx.dst->create<type::StructType>(
+ auto* new_struct = ctx.dst->create<sem::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -151,7 +151,7 @@
}
}
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
ast::StatementList stores;
auto store_value_symbol = ctx.dst->Symbols().New();
HoistToOutputVariables(
@@ -252,10 +252,10 @@
Symbol Spirv::HoistToInputVariables(
CloneContext& ctx,
const ast::Function* func,
- type::Type* ty,
- type::Type* declared_ty,
+ sem::Type* ty,
+ sem::Type* declared_ty,
const ast::DecorationList& decorations) const {
- if (!ty->Is<type::StructType>()) {
+ if (!ty->Is<sem::StructType>()) {
// Base case: create a global variable and return.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -272,7 +272,7 @@
// Recurse into struct members and build the initializer list.
std::vector<Symbol> init_value_names;
- auto* struct_ty = ty->As<type::StructType>();
+ auto* struct_ty = ty->As<sem::StructType>();
for (auto* member : struct_ty->impl()->members()) {
auto member_var = HoistToInputVariables(
ctx, func, member->type(), member->type(), member->decorations());
@@ -301,14 +301,14 @@
void Spirv::HoistToOutputVariables(CloneContext& ctx,
const ast::Function* func,
- type::Type* ty,
- type::Type* declared_ty,
+ sem::Type* ty,
+ sem::Type* declared_ty,
const ast::DecorationList& decorations,
std::vector<Symbol> member_accesses,
Symbol store_value,
ast::StatementList& stores) const {
// Base case.
- if (!ty->Is<type::StructType>()) {
+ if (!ty->Is<sem::StructType>()) {
// Create a global variable.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -332,7 +332,7 @@
}
// Recurse into struct members.
- auto* struct_ty = ty->As<type::StructType>();
+ auto* struct_ty = ty->As<sem::StructType>();
for (auto* member : struct_ty->impl()->members()) {
member_accesses.push_back(ctx.Clone(member->symbol()));
HoistToOutputVariables(ctx, func, member->type(), member->type(),
diff --git a/src/transform/spirv.h b/src/transform/spirv.h
index a80a1dc..2d60852 100644
--- a/src/transform/spirv.h
+++ b/src/transform/spirv.h
@@ -59,8 +59,8 @@
/// Return the symbol for the variable that was created.
Symbol HoistToInputVariables(CloneContext& ctx,
const ast::Function* func,
- type::Type* ty,
- type::Type* declared_ty,
+ sem::Type* ty,
+ sem::Type* declared_ty,
const ast::DecorationList& decorations) const;
/// Recursively create module-scope output variables for `ty` and build a list
@@ -73,8 +73,8 @@
/// Returns the list of variable assignments in `stores`.
void HoistToOutputVariables(CloneContext& ctx,
const ast::Function* func,
- type::Type* ty,
- type::Type* declared_ty,
+ sem::Type* ty,
+ sem::Type* declared_ty,
const ast::DecorationList& decorations,
std::vector<Symbol> member_accesses,
Symbol store_value,
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index 973afe3..a022e66 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -367,7 +367,7 @@
/// @param count how many elements the vector has
ast::Expression* AccessVec(uint32_t buffer,
uint32_t element_stride,
- type::Type* base_type,
+ sem::Type* base_type,
VertexFormat base_format,
uint32_t count) {
ast::ExpressionList expr_list;
@@ -379,7 +379,7 @@
}
return ctx.dst->create<ast::TypeConstructorExpression>(
- ctx.dst->create<type::Vector>(base_type, count), std::move(expr_list));
+ ctx.dst->create<sem::Vector>(base_type, count), std::move(expr_list));
}
};
diff --git a/src/type/access_control_type.cc b/src/type/access_control_type.cc
index 0d1cbf5..59f9f13 100644
--- a/src/type/access_control_type.cc
+++ b/src/type/access_control_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::AccessControl);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::AccessControl);
namespace tint {
-namespace type {
+namespace sem {
AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
: access_(access), subtype_(subtype) {
@@ -71,5 +71,5 @@
return ctx->dst->create<AccessControl>(access_, ty);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/access_control_type.h b/src/type/access_control_type.h
index 7002ea4..55de524 100644
--- a/src/type/access_control_type.h
+++ b/src/type/access_control_type.h
@@ -21,7 +21,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// An access control type. Holds an access setting and pointer to another type.
class AccessControl : public Castable<AccessControl, Type> {
@@ -64,7 +64,7 @@
Type* const subtype_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_ACCESS_CONTROL_TYPE_H_
diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc
index b8fd5aa..2e88ca1 100644
--- a/src/type/access_control_type_test.cc
+++ b/src/type/access_control_type_test.cc
@@ -18,7 +18,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using AccessControlTest = TestHelper;
@@ -96,5 +96,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/alias_type.cc b/src/type/alias_type.cc
index d0ec9c0..19ce929 100644
--- a/src/type/alias_type.cc
+++ b/src/type/alias_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Alias);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Alias);
namespace tint {
-namespace type {
+namespace sem {
Alias::Alias(const Symbol& sym, Type* subtype)
: symbol_(sym), subtype_(subtype) {
@@ -45,5 +45,5 @@
return ctx->dst->create<Alias>(sym, ty);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/alias_type.h b/src/type/alias_type.h
index ede6218..ba8cd61 100644
--- a/src/type/alias_type.h
+++ b/src/type/alias_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A type alias type. Holds a name and pointer to another type.
class Alias : public Castable<Alias, Type> {
@@ -57,7 +57,7 @@
Type* const subtype_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_ALIAS_TYPE_H_
diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc
index b9a8f89..24ba051 100644
--- a/src/type/alias_type_test.cc
+++ b/src/type/alias_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using AliasTest = TestHelper;
@@ -30,7 +30,7 @@
TEST_F(AliasTest, Is) {
auto* at = ty.alias("a", ty.i32());
- type::Type* ty = at;
+ sem::Type* ty = at;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_TRUE(ty->Is<Alias>());
EXPECT_FALSE(ty->Is<ArrayType>());
@@ -145,5 +145,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/array_type.cc b/src/type/array_type.cc
index f7f7208..d2d866c 100644
--- a/src/type/array_type.cc
+++ b/src/type/array_type.cc
@@ -18,10 +18,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::ArrayType);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::ArrayType);
namespace tint {
-namespace type {
+namespace sem {
ArrayType::ArrayType(Type* subtype,
uint32_t size,
@@ -70,5 +70,5 @@
return ctx->dst->create<ArrayType>(ty, size_, decos);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/array_type.h b/src/type/array_type.h
index 2dc8228..0f833f1 100644
--- a/src/type/array_type.h
+++ b/src/type/array_type.h
@@ -21,7 +21,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// An array type. If size is zero then it is a runtime array.
// TODO(amaiorano): https://crbug.com/tint/724 Fold into sem::Array once parsers
@@ -69,7 +69,7 @@
ast::DecorationList const decos_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_ARRAY_TYPE_H_
diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc
index f45f989..b37cc4c 100644
--- a/src/type/array_type_test.cc
+++ b/src/type/array_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using ArrayTest = TestHelper;
@@ -96,5 +96,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/bool_type.cc b/src/type/bool_type.cc
index b21227d..d17cf2c 100644
--- a/src/type/bool_type.cc
+++ b/src/type/bool_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Bool);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Bool);
namespace tint {
-namespace type {
+namespace sem {
Bool::Bool() = default;
@@ -39,5 +39,5 @@
return ctx->dst->create<Bool>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/bool_type.h b/src/type/bool_type.h
index 97863c5..7402e47 100644
--- a/src/type/bool_type.h
+++ b/src/type/bool_type.h
@@ -26,7 +26,7 @@
#endif
namespace tint {
-namespace type {
+namespace sem {
/// A boolean type
class Bool : public Castable<Bool, Type> {
@@ -51,7 +51,7 @@
Bool* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_BOOL_TYPE_H_
diff --git a/src/type/bool_type_test.cc b/src/type/bool_type_test.cc
index 0775657..64094bf 100644
--- a/src/type/bool_type_test.cc
+++ b/src/type/bool_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using BoolTest = TestHelper;
@@ -51,5 +51,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/depth_texture_type.cc b/src/type/depth_texture_type.cc
index 2dbd64c..6ead318 100644
--- a/src/type/depth_texture_type.cc
+++ b/src/type/depth_texture_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::DepthTexture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::DepthTexture);
namespace tint {
-namespace type {
+namespace sem {
namespace {
bool IsValidDepthDimension(TextureDimension dim) {
@@ -53,5 +53,5 @@
return ctx->dst->create<DepthTexture>(dim());
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/depth_texture_type.h b/src/type/depth_texture_type.h
index 2cff86c..2a2bbfd 100644
--- a/src/type/depth_texture_type.h
+++ b/src/type/depth_texture_type.h
@@ -20,7 +20,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A depth texture type.
class DepthTexture : public Castable<DepthTexture, Texture> {
@@ -46,7 +46,7 @@
DepthTexture* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
diff --git a/src/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc
index eef75d5..993879c 100644
--- a/src/type/depth_texture_type_test.cc
+++ b/src/type/depth_texture_type_test.cc
@@ -22,7 +22,7 @@
#include "src/type/storage_texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using DepthTextureTest = TestHelper;
@@ -70,5 +70,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/external_texture_type.cc b/src/type/external_texture_type.cc
index c7d475a..3dba140 100644
--- a/src/type/external_texture_type.cc
+++ b/src/type/external_texture_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::ExternalTexture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::ExternalTexture);
namespace tint {
-namespace type {
+namespace sem {
ExternalTexture::ExternalTexture() : Base(TextureDimension::k2d) {}
@@ -43,5 +43,5 @@
return ctx->dst->create<ExternalTexture>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/external_texture_type.h b/src/type/external_texture_type.h
index b6ffbc3..c2ceb46 100644
--- a/src/type/external_texture_type.h
+++ b/src/type/external_texture_type.h
@@ -15,10 +15,12 @@
#ifndef SRC_TYPE_EXTERNAL_TEXTURE_TYPE_H_
#define SRC_TYPE_EXTERNAL_TEXTURE_TYPE_H_
+#include <string>
+
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
class ExternalTexture : public Castable<ExternalTexture, Texture> {
public:
/// Constructor
@@ -42,6 +44,6 @@
ExternalTexture* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_EXTERNAL_TEXTURE_TYPE_H_
diff --git a/src/type/external_texture_type_test.cc b/src/type/external_texture_type_test.cc
index 7c73d62..2fb7485 100644
--- a/src/type/external_texture_type_test.cc
+++ b/src/type/external_texture_type_test.cc
@@ -22,7 +22,7 @@
#include "src/type/test_helper.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using ExternalTextureTest = TestHelper;
@@ -75,5 +75,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/f32_type.cc b/src/type/f32_type.cc
index 5e7e2a5..7398957 100644
--- a/src/type/f32_type.cc
+++ b/src/type/f32_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::F32);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::F32);
namespace tint {
-namespace type {
+namespace sem {
F32::F32() = default;
@@ -39,5 +39,5 @@
return ctx->dst->create<F32>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/f32_type.h b/src/type/f32_type.h
index 156ddd1..2391404 100644
--- a/src/type/f32_type.h
+++ b/src/type/f32_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A float 32 type
class F32 : public Castable<F32, Type> {
@@ -45,7 +45,7 @@
F32* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_F32_TYPE_H_
diff --git a/src/type/f32_type_test.cc b/src/type/f32_type_test.cc
index a1b89d4..421ca9e 100644
--- a/src/type/f32_type_test.cc
+++ b/src/type/f32_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using F32Test = TestHelper;
@@ -51,5 +51,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/i32_type.cc b/src/type/i32_type.cc
index 7807385..5297a34 100644
--- a/src/type/i32_type.cc
+++ b/src/type/i32_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::I32);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::I32);
namespace tint {
-namespace type {
+namespace sem {
I32::I32() = default;
@@ -39,5 +39,5 @@
return ctx->dst->create<I32>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/i32_type.h b/src/type/i32_type.h
index a376974..2722e87 100644
--- a/src/type/i32_type.h
+++ b/src/type/i32_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A signed int 32 type.
class I32 : public Castable<I32, Type> {
@@ -45,7 +45,7 @@
I32* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_I32_TYPE_H_
diff --git a/src/type/i32_type_test.cc b/src/type/i32_type_test.cc
index 8def688..bf3a1ec 100644
--- a/src/type/i32_type_test.cc
+++ b/src/type/i32_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using I32Test = TestHelper;
@@ -51,5 +51,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/matrix_type.cc b/src/type/matrix_type.cc
index c840d0f..4daa6b8 100644
--- a/src/type/matrix_type.cc
+++ b/src/type/matrix_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Matrix);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Matrix);
namespace tint {
-namespace type {
+namespace sem {
Matrix::Matrix(Type* subtype, uint32_t rows, uint32_t columns)
: subtype_(subtype), rows_(rows), columns_(columns) {
@@ -51,5 +51,5 @@
return ctx->dst->create<Matrix>(ty, rows_, columns_);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/matrix_type.h b/src/type/matrix_type.h
index 59c878c..3eefdd1 100644
--- a/src/type/matrix_type.h
+++ b/src/type/matrix_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A matrix type
class Matrix : public Castable<Matrix, Type> {
@@ -60,7 +60,7 @@
uint32_t const columns_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_MATRIX_TYPE_H_
diff --git a/src/type/matrix_type_test.cc b/src/type/matrix_type_test.cc
index 92c2aaf..87b3273 100644
--- a/src/type/matrix_type_test.cc
+++ b/src/type/matrix_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using MatrixTest = TestHelper;
@@ -61,5 +61,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/multisampled_texture_type.cc b/src/type/multisampled_texture_type.cc
index e55ebd5..e3d1990 100644
--- a/src/type/multisampled_texture_type.cc
+++ b/src/type/multisampled_texture_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::MultisampledTexture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::MultisampledTexture);
namespace tint {
-namespace type {
+namespace sem {
MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
: Base(dim), type_(type) {
@@ -50,5 +50,5 @@
return ctx->dst->create<MultisampledTexture>(dim(), ty);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/multisampled_texture_type.h b/src/type/multisampled_texture_type.h
index 78c4073..7542402 100644
--- a/src/type/multisampled_texture_type.h
+++ b/src/type/multisampled_texture_type.h
@@ -20,7 +20,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A multisampled texture type.
class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
@@ -53,7 +53,7 @@
Type* const type_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
diff --git a/src/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc
index f18c9bf..3add47c 100644
--- a/src/type/multisampled_texture_type_test.cc
+++ b/src/type/multisampled_texture_type_test.cc
@@ -22,7 +22,7 @@
#include "src/type/test_helper.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using MultisampledTextureTest = TestHelper;
@@ -81,5 +81,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/pointer_type.cc b/src/type/pointer_type.cc
index 7f98966..c9b2230 100644
--- a/src/type/pointer_type.cc
+++ b/src/type/pointer_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Pointer);
namespace tint {
-namespace type {
+namespace sem {
Pointer::Pointer(Type* subtype, ast::StorageClass storage_class)
: subtype_(subtype), storage_class_(storage_class) {}
@@ -50,5 +50,5 @@
return ctx->dst->create<Pointer>(ty, storage_class_);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/pointer_type.h b/src/type/pointer_type.h
index abbef7f..3290009 100644
--- a/src/type/pointer_type.h
+++ b/src/type/pointer_type.h
@@ -21,7 +21,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A pointer type.
class Pointer : public Castable<Pointer, Type> {
@@ -57,7 +57,7 @@
ast::StorageClass const storage_class_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_POINTER_TYPE_H_
diff --git a/src/type/pointer_type_test.cc b/src/type/pointer_type_test.cc
index ec8d062..79a0bf2 100644
--- a/src/type/pointer_type_test.cc
+++ b/src/type/pointer_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using PointerTest = TestHelper;
@@ -65,5 +65,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/sampled_texture_type.cc b/src/type/sampled_texture_type.cc
index 1e3d636..703de48 100644
--- a/src/type/sampled_texture_type.cc
+++ b/src/type/sampled_texture_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::SampledTexture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::SampledTexture);
namespace tint {
-namespace type {
+namespace sem {
SampledTexture::SampledTexture(TextureDimension dim, Type* type)
: Base(dim), type_(type) {
@@ -48,5 +48,5 @@
return ctx->dst->create<SampledTexture>(dim(), ty);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/sampled_texture_type.h b/src/type/sampled_texture_type.h
index fc03f72..bcd2705 100644
--- a/src/type/sampled_texture_type.h
+++ b/src/type/sampled_texture_type.h
@@ -20,7 +20,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A sampled texture type.
class SampledTexture : public Castable<SampledTexture, Texture> {
@@ -53,7 +53,7 @@
Type* const type_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_SAMPLED_TEXTURE_TYPE_H_
diff --git a/src/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc
index f7e2751..97d4eb6 100644
--- a/src/type/sampled_texture_type_test.cc
+++ b/src/type/sampled_texture_type_test.cc
@@ -21,7 +21,7 @@
#include "src/type/test_helper.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using SampledTextureTest = TestHelper;
@@ -79,5 +79,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/sampler_type.cc b/src/type/sampler_type.cc
index abfa64d..4679297 100644
--- a/src/type/sampler_type.cc
+++ b/src/type/sampler_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Sampler);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Sampler);
namespace tint {
-namespace type {
+namespace sem {
std::ostream& operator<<(std::ostream& out, SamplerKind kind) {
switch (kind) {
@@ -52,5 +52,5 @@
return ctx->dst->create<Sampler>(kind_);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/sampler_type.h b/src/type/sampler_type.h
index f74d873..23ef24c 100644
--- a/src/type/sampler_type.h
+++ b/src/type/sampler_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// The different kinds of samplers
enum class SamplerKind {
@@ -64,7 +64,7 @@
SamplerKind const kind_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_SAMPLER_TYPE_H_
diff --git a/src/type/sampler_type_test.cc b/src/type/sampler_type_test.cc
index b39f675..c7ef3c9 100644
--- a/src/type/sampler_type_test.cc
+++ b/src/type/sampler_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using SamplerTest = TestHelper;
@@ -72,5 +72,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/storage_texture_type.cc b/src/type/storage_texture_type.cc
index c430ea6..e693dbe 100644
--- a/src/type/storage_texture_type.cc
+++ b/src/type/storage_texture_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::StorageTexture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::StorageTexture);
namespace tint {
-namespace type {
+namespace sem {
// Note, these names match the names in the WGSL spec. This behaviour is used
// in the WGSL writer to emit the texture format names.
@@ -139,7 +139,7 @@
StorageTexture::StorageTexture(TextureDimension dim,
ImageFormat format,
- type::Type* subtype)
+ sem::Type* subtype)
: Base(dim), image_format_(format), subtype_(subtype) {}
StorageTexture::StorageTexture(StorageTexture&&) = default;
@@ -164,59 +164,59 @@
return ctx->dst->create<StorageTexture>(dim(), image_format_, ty);
}
-type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
- type::Manager& type_mgr) {
+sem::Type* StorageTexture::SubtypeFor(sem::ImageFormat format,
+ sem::Manager& type_mgr) {
switch (format) {
- case type::ImageFormat::kR8Uint:
- case type::ImageFormat::kR16Uint:
- case type::ImageFormat::kRg8Uint:
- case type::ImageFormat::kR32Uint:
- case type::ImageFormat::kRg16Uint:
- case type::ImageFormat::kRgba8Uint:
- case type::ImageFormat::kRg32Uint:
- case type::ImageFormat::kRgba16Uint:
- case type::ImageFormat::kRgba32Uint: {
- return type_mgr.Get<type::U32>();
+ case sem::ImageFormat::kR8Uint:
+ case sem::ImageFormat::kR16Uint:
+ case sem::ImageFormat::kRg8Uint:
+ case sem::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kRg16Uint:
+ case sem::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kRgba32Uint: {
+ return type_mgr.Get<sem::U32>();
}
- case type::ImageFormat::kR8Sint:
- case type::ImageFormat::kR16Sint:
- case type::ImageFormat::kRg8Sint:
- case type::ImageFormat::kR32Sint:
- case type::ImageFormat::kRg16Sint:
- case type::ImageFormat::kRgba8Sint:
- case type::ImageFormat::kRg32Sint:
- case type::ImageFormat::kRgba16Sint:
- case type::ImageFormat::kRgba32Sint: {
- return type_mgr.Get<type::I32>();
+ case sem::ImageFormat::kR8Sint:
+ case sem::ImageFormat::kR16Sint:
+ case sem::ImageFormat::kRg8Sint:
+ case sem::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kRg16Sint:
+ case sem::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kRgba32Sint: {
+ return type_mgr.Get<sem::I32>();
}
- case type::ImageFormat::kR8Unorm:
- case type::ImageFormat::kRg8Unorm:
- case type::ImageFormat::kRgba8Unorm:
- case type::ImageFormat::kRgba8UnormSrgb:
- case type::ImageFormat::kBgra8Unorm:
- case type::ImageFormat::kBgra8UnormSrgb:
- case type::ImageFormat::kRgb10A2Unorm:
- case type::ImageFormat::kR8Snorm:
- case type::ImageFormat::kRg8Snorm:
- case type::ImageFormat::kRgba8Snorm:
- case type::ImageFormat::kR16Float:
- case type::ImageFormat::kR32Float:
- case type::ImageFormat::kRg16Float:
- case type::ImageFormat::kRg11B10Float:
- case type::ImageFormat::kRg32Float:
- case type::ImageFormat::kRgba16Float:
- case type::ImageFormat::kRgba32Float: {
- return type_mgr.Get<type::F32>();
+ case sem::ImageFormat::kR8Unorm:
+ case sem::ImageFormat::kRg8Unorm:
+ case sem::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8UnormSrgb:
+ case sem::ImageFormat::kBgra8Unorm:
+ case sem::ImageFormat::kBgra8UnormSrgb:
+ case sem::ImageFormat::kRgb10A2Unorm:
+ case sem::ImageFormat::kR8Snorm:
+ case sem::ImageFormat::kRg8Snorm:
+ case sem::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kR16Float:
+ case sem::ImageFormat::kR32Float:
+ case sem::ImageFormat::kRg16Float:
+ case sem::ImageFormat::kRg11B10Float:
+ case sem::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kRgba32Float: {
+ return type_mgr.Get<sem::F32>();
}
- case type::ImageFormat::kNone:
+ case sem::ImageFormat::kNone:
break;
}
return nullptr;
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/storage_texture_type.h b/src/type/storage_texture_type.h
index 7342c57..933133c 100644
--- a/src/type/storage_texture_type.h
+++ b/src/type/storage_texture_type.h
@@ -20,7 +20,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
class Manager;
@@ -72,7 +72,7 @@
/// @param dim the dimensionality of the texture
/// @param format the image format of the texture
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
- StorageTexture(TextureDimension dim, ImageFormat format, type::Type* subtype);
+ StorageTexture(TextureDimension dim, ImageFormat format, sem::Type* subtype);
/// Move constructor
StorageTexture(StorageTexture&&);
@@ -98,17 +98,16 @@
StorageTexture* Clone(CloneContext* ctx) const override;
/// @param format the storage texture image format
- /// @param type_mgr the type::Manager used to build the returned type
+ /// @param type_mgr the sem::Manager used to build the returned type
/// @returns the storage texture subtype for the given ImageFormat
- static type::Type* SubtypeFor(type::ImageFormat format,
- type::Manager& type_mgr);
+ static sem::Type* SubtypeFor(sem::ImageFormat format, sem::Manager& type_mgr);
private:
ImageFormat const image_format_;
Type* const subtype_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_STORAGE_TEXTURE_TYPE_H_
diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc
index 6931059..eb18999 100644
--- a/src/type/storage_texture_type_test.cc
+++ b/src/type/storage_texture_type_test.cc
@@ -21,7 +21,7 @@
#include "src/type/test_helper.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using StorageTextureTest = TestHelper;
@@ -94,7 +94,7 @@
TEST_F(StorageTextureTest, F32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
+ sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Float, subtype);
@@ -108,7 +108,7 @@
TEST_F(StorageTextureTest, U32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types());
+ sem::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRg32Uint, subtype);
@@ -122,7 +122,7 @@
TEST_F(StorageTextureTest, I32) {
auto* subtype =
- type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
+ sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
ImageFormat::kRgba32Sint, subtype);
@@ -135,5 +135,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/struct_type.cc b/src/type/struct_type.cc
index f35ff86..1fa1cf6 100644
--- a/src/type/struct_type.cc
+++ b/src/type/struct_type.cc
@@ -18,10 +18,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::StructType);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::StructType);
namespace tint {
-namespace type {
+namespace sem {
StructType::StructType(const Symbol& sym, ast::Struct* impl)
: symbol_(sym), struct_(impl) {}
@@ -45,5 +45,5 @@
return ctx->dst->create<StructType>(sym, str);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/struct_type.h b/src/type/struct_type.h
index 4d9d8d2..139c61f 100644
--- a/src/type/struct_type.h
+++ b/src/type/struct_type.h
@@ -21,7 +21,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A structure type
class StructType : public Castable<StructType, Type> {
@@ -63,7 +63,7 @@
uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_STRUCT_TYPE_H_
diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc
index 34cafbf..e81afd3 100644
--- a/src/type/struct_type_test.cc
+++ b/src/type/struct_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using StructTypeTest = TestHelper;
@@ -34,7 +34,7 @@
auto* impl =
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
auto* s = ty.struct_("S", impl);
- type::Type* ty = s;
+ sem::Type* ty = s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
EXPECT_FALSE(ty->Is<ArrayType>());
@@ -65,5 +65,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/test_helper.h b/src/type/test_helper.h
index 1c08c60..4ee2802 100644
--- a/src/type/test_helper.h
+++ b/src/type/test_helper.h
@@ -21,7 +21,7 @@
#include "src/program_builder.h"
namespace tint {
-namespace type {
+namespace sem {
/// Helper class for testing
template <typename BASE>
@@ -43,7 +43,7 @@
template <typename T>
using TestParamHelper = TestHelperBase<testing::TestWithParam<T>>;
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_TEST_HELPER_H_
diff --git a/src/type/texture_type.cc b/src/type/texture_type.cc
index 1f66a37..df16729 100644
--- a/src/type/texture_type.cc
+++ b/src/type/texture_type.cc
@@ -14,10 +14,10 @@
#include "src/type/texture_type.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Texture);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Texture);
namespace tint {
-namespace type {
+namespace sem {
std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
switch (dim) {
@@ -84,5 +84,5 @@
Texture::~Texture() = default;
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/texture_type.h b/src/type/texture_type.h
index c36ba88..9c83deb 100644
--- a/src/type/texture_type.h
+++ b/src/type/texture_type.h
@@ -18,7 +18,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// The dimensionality of the texture
enum class TextureDimension {
@@ -69,7 +69,7 @@
TextureDimension const dim_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_TEXTURE_TYPE_H_
diff --git a/src/type/texture_type_test.cc b/src/type/texture_type_test.cc
index 57c52a4..a1dec3b 100644
--- a/src/type/texture_type_test.cc
+++ b/src/type/texture_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/test_helper.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using TextureTypeTest = TestHelper;
@@ -43,5 +43,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/type.cc b/src/type/type.cc
index 3637f87..eee7d54 100644
--- a/src/type/type.cc
+++ b/src/type/type.cc
@@ -26,10 +26,10 @@
#include "src/type/u32_type.h"
#include "src/type/vector_type.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Type);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Type);
namespace tint {
-namespace type {
+namespace sem {
Type::Type() = default;
@@ -38,7 +38,7 @@
Type::~Type() = default;
Type* Type::UnwrapPtrIfNeeded() {
- if (auto* ptr = As<type::Pointer>()) {
+ if (auto* ptr = As<sem::Pointer>()) {
return ptr->type();
}
return this;
@@ -46,7 +46,7 @@
Type* Type::UnwrapAliasIfNeeded() {
Type* unwrapped = this;
- while (auto* ptr = unwrapped->As<type::Alias>()) {
+ while (auto* ptr = unwrapped->As<sem::Alias>()) {
unwrapped = ptr->type();
}
return unwrapped;
@@ -55,9 +55,9 @@
Type* Type::UnwrapIfNeeded() {
auto* where = this;
while (true) {
- if (auto* alias = where->As<type::Alias>()) {
+ if (auto* alias = where->As<sem::Alias>()) {
where = alias->type();
- } else if (auto* access = where->As<type::AccessControl>()) {
+ } else if (auto* access = where->As<sem::AccessControl>()) {
where = access->type();
} else {
break;
@@ -132,5 +132,5 @@
return IsAnyOf<Sampler, Texture>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/type.h b/src/type/type.h
index 95ed371..7c23d67 100644
--- a/src/type/type.h
+++ b/src/type/type.h
@@ -25,7 +25,7 @@
class ProgramBuilder;
class SymbolTable;
-namespace type {
+namespace sem {
/// Supported memory layouts for calculating sizes
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
@@ -109,7 +109,7 @@
return ProgramID();
}
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_TYPE_H_
diff --git a/src/type/type_manager.cc b/src/type/type_manager.cc
index 1f6833d..76e97f4 100644
--- a/src/type/type_manager.cc
+++ b/src/type/type_manager.cc
@@ -15,12 +15,12 @@
#include "src/type/type_manager.h"
namespace tint {
-namespace type {
+namespace sem {
Manager::Manager() = default;
Manager::Manager(Manager&&) = default;
Manager& Manager::operator=(Manager&& rhs) = default;
Manager::~Manager() = default;
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/type_manager.h b/src/type/type_manager.h
index a3ece09..b42c287 100644
--- a/src/type/type_manager.h
+++ b/src/type/type_manager.h
@@ -23,13 +23,13 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// The type manager holds all the pointers to the known types.
class Manager {
public:
/// Iterator is the type returned by begin() and end()
- using Iterator = BlockAllocator<type::Type>::ConstIterator;
+ using Iterator = BlockAllocator<sem::Type>::ConstIterator;
/// Constructor
Manager();
@@ -80,7 +80,7 @@
/// Returns the type map
/// @returns the mapping from name string to type.
- const std::unordered_map<std::string, type::Type*>& types() const {
+ const std::unordered_map<std::string, sem::Type*>& types() const {
return by_name_;
}
@@ -90,11 +90,11 @@
Iterator end() const { return types_.Objects().end(); }
private:
- std::unordered_map<std::string, type::Type*> by_name_;
- BlockAllocator<type::Type> types_;
+ std::unordered_map<std::string, sem::Type*> by_name_;
+ BlockAllocator<sem::Type> types_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_TYPE_MANAGER_H_
diff --git a/src/type/type_manager_test.cc b/src/type/type_manager_test.cc
index 71846ef..0dc83c9 100644
--- a/src/type/type_manager_test.cc
+++ b/src/type/type_manager_test.cc
@@ -19,7 +19,7 @@
#include "src/type/u32_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
template <typename T>
@@ -79,5 +79,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/u32_type.cc b/src/type/u32_type.cc
index 775abc3..7a8ac3a 100644
--- a/src/type/u32_type.cc
+++ b/src/type/u32_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::U32);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::U32);
namespace tint {
-namespace type {
+namespace sem {
U32::U32() = default;
@@ -39,5 +39,5 @@
return ctx->dst->create<U32>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/u32_type.h b/src/type/u32_type.h
index 7aadc89..bfd81a0 100644
--- a/src/type/u32_type.h
+++ b/src/type/u32_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A unsigned int 32 type.
class U32 : public Castable<U32, Type> {
@@ -45,7 +45,7 @@
U32* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_U32_TYPE_H_
diff --git a/src/type/u32_type_test.cc b/src/type/u32_type_test.cc
index d2e4597..39f657f 100644
--- a/src/type/u32_type_test.cc
+++ b/src/type/u32_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using U32Test = TestHelper;
@@ -51,5 +51,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/vector_type.cc b/src/type/vector_type.cc
index ce65744..5e12305 100644
--- a/src/type/vector_type.cc
+++ b/src/type/vector_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Vector);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Vector);
namespace tint {
-namespace type {
+namespace sem {
Vector::Vector(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {
TINT_ASSERT(size_ > 1);
@@ -46,5 +46,5 @@
return ctx->dst->create<Vector>(ty, size_);
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/vector_type.h b/src/type/vector_type.h
index cbb9022..34ed908 100644
--- a/src/type/vector_type.h
+++ b/src/type/vector_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A vector type.
class Vector : public Castable<Vector, Type> {
@@ -56,7 +56,7 @@
uint32_t const size_;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_VECTOR_TYPE_H_
diff --git a/src/type/vector_type_test.cc b/src/type/vector_type_test.cc
index 8b12cc3..656721f 100644
--- a/src/type/vector_type_test.cc
+++ b/src/type/vector_type_test.cc
@@ -17,7 +17,7 @@
#include "src/type/texture_type.h"
namespace tint {
-namespace type {
+namespace sem {
namespace {
using VectorTest = TestHelper;
@@ -60,5 +60,5 @@
}
} // namespace
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/void_type.cc b/src/type/void_type.cc
index f615a20..c0445b8 100644
--- a/src/type/void_type.cc
+++ b/src/type/void_type.cc
@@ -16,10 +16,10 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Void);
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Void);
namespace tint {
-namespace type {
+namespace sem {
Void::Void() = default;
@@ -39,5 +39,5 @@
return ctx->dst->create<Void>();
}
-} // namespace type
+} // namespace sem
} // namespace tint
diff --git a/src/type/void_type.h b/src/type/void_type.h
index 406b36b..88fef42 100644
--- a/src/type/void_type.h
+++ b/src/type/void_type.h
@@ -20,7 +20,7 @@
#include "src/type/type.h"
namespace tint {
-namespace type {
+namespace sem {
/// A void type
class Void : public Castable<Void, Type> {
@@ -45,7 +45,7 @@
Void* Clone(CloneContext* ctx) const override;
};
-} // namespace type
+} // namespace sem
} // namespace tint
#endif // SRC_TYPE_VOID_TYPE_H_
diff --git a/src/writer/append_vector.cc b/src/writer/append_vector.cc
index 4e98d24..1c84d45 100644
--- a/src/writer/append_vector.cc
+++ b/src/writer/append_vector.cc
@@ -25,7 +25,7 @@
ast::TypeConstructorExpression* AsVectorConstructor(ast::Expression* expr) {
if (auto* constructor = expr->As<ast::TypeConstructorExpression>()) {
- if (constructor->type()->Is<type::Vector>()) {
+ if (constructor->type()->Is<sem::Vector>()) {
return constructor;
}
}
@@ -38,10 +38,10 @@
ast::Expression* vector,
ast::Expression* scalar) {
uint32_t packed_size;
- type::Type* packed_el_ty; // Currently must be f32.
+ sem::Type* packed_el_ty; // Currently must be f32.
auto* vector_sem = b->Sem().Get(vector);
auto* vector_ty = vector_sem->Type()->UnwrapPtrIfNeeded();
- if (auto* vec = vector_ty->As<type::Vector>()) {
+ if (auto* vec = vector_ty->As<sem::Vector>()) {
packed_size = vec->size() + 1;
packed_el_ty = vec->type();
} else {
@@ -51,7 +51,7 @@
auto* statement = vector_sem->Stmt();
- auto* packed_ty = b->create<type::Vector>(packed_el_ty, packed_size);
+ auto* packed_ty = b->create<sem::Vector>(packed_el_ty, packed_size);
// If the coordinates are already passed in a vector constructor, extract
// the elements into the new vector instead of nesting a vector-in-vector.
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index b3f7de0..6efadf4 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -58,26 +58,26 @@
stmts->last()->Is<ast::FallthroughStatement>();
}
-const char* image_format_to_rwtexture_type(type::ImageFormat image_format) {
+const char* image_format_to_rwtexture_type(sem::ImageFormat image_format) {
switch (image_format) {
- case type::ImageFormat::kRgba8Unorm:
- case type::ImageFormat::kRgba8Snorm:
- case type::ImageFormat::kRgba16Float:
- case type::ImageFormat::kR32Float:
- case type::ImageFormat::kRg32Float:
- case type::ImageFormat::kRgba32Float:
+ case sem::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kR32Float:
+ case sem::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRgba32Float:
return "float4";
- case type::ImageFormat::kRgba8Uint:
- case type::ImageFormat::kRgba16Uint:
- case type::ImageFormat::kR32Uint:
- case type::ImageFormat::kRg32Uint:
- case type::ImageFormat::kRgba32Uint:
+ case sem::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRgba32Uint:
return "uint4";
- case type::ImageFormat::kRgba8Sint:
- case type::ImageFormat::kRgba16Sint:
- case type::ImageFormat::kR32Sint:
- case type::ImageFormat::kRg32Sint:
- case type::ImageFormat::kRgba32Sint:
+ case sem::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRgba32Sint:
return "int4";
default:
return nullptr;
@@ -201,13 +201,13 @@
}
bool GeneratorImpl::EmitConstructedType(std::ostream& out,
- const type::Type* ty) {
+ const sem::Type* ty) {
make_indent(out);
- if (auto* alias = ty->As<type::Alias>()) {
+ if (auto* alias = ty->As<sem::Alias>()) {
// HLSL typedef is for intrinsic types only. For an alias'd struct,
// generate a secondary struct with the new name.
- if (auto* str = alias->type()->As<type::StructType>()) {
+ if (auto* str = alias->type()->As<sem::StructType>()) {
if (!EmitStructType(out, str,
builder_.Symbols().NameFor(alias->symbol()))) {
return false;
@@ -220,7 +220,7 @@
}
out << " " << builder_.Symbols().NameFor(alias->symbol()) << ";"
<< std::endl;
- } else if (auto* str = ty->As<type::StructType>()) {
+ } else if (auto* str = ty->As<sem::StructType>()) {
if (!EmitStructType(out, str, builder_.Symbols().NameFor(str->symbol()))) {
return false;
}
@@ -333,9 +333,9 @@
// Multiplying by a matrix requires the use of `mul` in order to get the
// type of multiply we desire.
if (expr->op() == ast::BinaryOp::kMultiply &&
- ((lhs_type->Is<type::Vector>() && rhs_type->Is<type::Matrix>()) ||
- (lhs_type->Is<type::Matrix>() && rhs_type->Is<type::Vector>()) ||
- (lhs_type->Is<type::Matrix>() && rhs_type->Is<type::Matrix>()))) {
+ ((lhs_type->Is<sem::Vector>() && rhs_type->Is<sem::Matrix>()) ||
+ (lhs_type->Is<sem::Matrix>() && rhs_type->Is<sem::Vector>()) ||
+ (lhs_type->Is<sem::Matrix>() && rhs_type->Is<sem::Matrix>()))) {
// Matrices are transposed, so swap LHS and RHS.
out << "mul(";
if (!EmitExpression(pre, out, expr->rhs())) {
@@ -865,7 +865,7 @@
return false;
}
- auto* texture_type = TypeOf(texture)->UnwrapAll()->As<type::Texture>();
+ auto* texture_type = TypeOf(texture)->UnwrapAll()->As<sem::Texture>();
switch (intrinsic->Type()) {
case sem::IntrinsicType::kTextureDimensions:
@@ -873,37 +873,37 @@
case sem::IntrinsicType::kTextureNumLevels:
case sem::IntrinsicType::kTextureNumSamples: {
// All of these intrinsics use the GetDimensions() method on the texture
- bool is_ms = texture_type->Is<type::MultisampledTexture>();
+ bool is_ms = texture_type->Is<sem::MultisampledTexture>();
int num_dimensions = 0;
std::string swizzle;
switch (intrinsic->Type()) {
case sem::IntrinsicType::kTextureDimensions:
switch (texture_type->dim()) {
- case type::TextureDimension::kNone:
+ case sem::TextureDimension::kNone:
TINT_ICE(diagnostics_) << "texture dimension is kNone";
return false;
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
num_dimensions = 1;
break;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
num_dimensions = is_ms ? 3 : 2;
swizzle = is_ms ? ".xy" : "";
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
num_dimensions = is_ms ? 4 : 3;
swizzle = ".xy";
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
num_dimensions = 3;
break;
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 2;
swizzle = ".xyy"; // [width, height, height]
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 3;
@@ -916,11 +916,11 @@
default:
TINT_ICE(diagnostics_) << "texture dimension is not arrayed";
return false;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
num_dimensions = is_ms ? 4 : 3;
swizzle = ".z";
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
num_dimensions = 3;
swizzle = ".z";
break;
@@ -932,14 +932,14 @@
TINT_ICE(diagnostics_)
<< "texture dimension does not support mips";
return false;
- case type::TextureDimension::k2d:
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::kCube:
num_dimensions = 3;
swizzle = ".z";
break;
- case type::TextureDimension::k2dArray:
- case type::TextureDimension::k3d:
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::k2dArray:
+ case sem::TextureDimension::k3d:
+ case sem::TextureDimension::kCubeArray:
num_dimensions = 4;
swizzle = ".w";
break;
@@ -951,11 +951,11 @@
TINT_ICE(diagnostics_)
<< "texture dimension does not support multisampling";
return false;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
num_dimensions = 3;
swizzle = ".z";
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
num_dimensions = 4;
swizzle = ".w";
break;
@@ -1093,7 +1093,7 @@
}
auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) {
- auto* i32 = builder_.create<type::I32>();
+ auto* i32 = builder_.create<sem::I32>();
auto* zero = builder_.Expr(0);
auto* stmt = builder_.Sem().Get(vector)->Stmt();
builder_.Sem().Add(zero, builder_.create<sem::Expression>(zero, i32, stmt));
@@ -1317,7 +1317,7 @@
bool brackets = expr->type()
->UnwrapAliasIfNeeded()
- ->IsAnyOf<type::ArrayType, type::StructType>();
+ ->IsAnyOf<sem::ArrayType, sem::StructType>();
if (brackets) {
out << "{";
@@ -1644,7 +1644,7 @@
return false;
}
// Array name is output as part of the type
- if (!type->Is<type::ArrayType>()) {
+ if (!type->Is<sem::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(v->symbol());
}
}
@@ -1708,7 +1708,7 @@
}
auto* type = var->Type()->UnwrapIfNeeded();
- if (auto* strct = type->As<type::StructType>()) {
+ if (auto* strct = type->As<sem::StructType>()) {
out << "ConstantBuffer<" << builder_.Symbols().NameFor(strct->symbol())
<< "> " << builder_.Symbols().NameFor(decl->symbol())
<< RegisterAndSpace('b', binding_point) << ";" << std::endl;
@@ -1750,7 +1750,7 @@
continue; // Global already emitted
}
- auto* access = var->Type()->As<type::AccessControl>();
+ auto* access = var->Type()->As<sem::AccessControl>();
if (access == nullptr) {
diagnostics_.add_error("access control type required for storage buffer");
return false;
@@ -1910,22 +1910,22 @@
if (!EmitType(out, var->DeclaredType(), var->StorageClass(), name)) {
return false;
}
- if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is<type::ArrayType>()) {
+ if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is<sem::ArrayType>()) {
out << " " << name;
}
const char* register_space = nullptr;
- if (unwrapped_type->Is<type::Texture>()) {
+ if (unwrapped_type->Is<sem::Texture>()) {
register_space = "t";
- if (unwrapped_type->Is<type::StorageTexture>()) {
- if (auto* ac = var->Type()->As<type::AccessControl>()) {
+ if (unwrapped_type->Is<sem::StorageTexture>()) {
+ if (auto* ac = var->Type()->As<sem::AccessControl>()) {
if (!ac->IsReadOnly()) {
register_space = "u";
}
}
}
- } else if (unwrapped_type->Is<type::Sampler>()) {
+ } else if (unwrapped_type->Is<sem::Sampler>()) {
register_space = "s";
}
@@ -2007,7 +2007,7 @@
bool has_outdata = outdata != ep_sym_to_out_data_.end();
if (has_outdata) {
// TODO(crbug.com/tint/697): Remove this.
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
TINT_ICE(diagnostics_) << "Mixing module-scope variables and return "
"types for shader outputs";
}
@@ -2030,7 +2030,7 @@
for (auto* var : func->params()) {
auto* sem = builder_.Sem().Get(var);
auto* type = sem->Type();
- if (!type->Is<type::StructType>()) {
+ if (!type->Is<sem::StructType>()) {
TINT_ICE(diagnostics_) << "Unsupported non-struct entry point parameter";
}
@@ -2097,16 +2097,16 @@
return true;
}
-bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) {
- if (type->Is<type::Bool>()) {
+bool GeneratorImpl::EmitZeroValue(std::ostream& out, sem::Type* type) {
+ if (type->Is<sem::Bool>()) {
out << "false";
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
out << "0.0f";
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
out << "0";
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
out << "0u";
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
if (!EmitType(out, type, ast::StorageClass::kNone, "")) {
return false;
}
@@ -2119,7 +2119,7 @@
return false;
}
}
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
if (!EmitType(out, type, ast::StorageClass::kNone, "")) {
return false;
}
@@ -2132,7 +2132,7 @@
return false;
}
}
- } else if (auto* str = type->As<type::StructType>()) {
+ } else if (auto* str = type->As<sem::StructType>()) {
out << "{";
bool first = true;
for (auto* member : str->impl()->members()) {
@@ -2310,7 +2310,7 @@
return false;
}
out << pre.str();
- if (!TypeOf(c->expr())->Is<type::Void>()) {
+ if (!TypeOf(c->expr())->Is<sem::Void>()) {
out << "(void) ";
}
out << call_out.str() << ";" << std::endl;
@@ -2375,10 +2375,10 @@
}
bool GeneratorImpl::EmitType(std::ostream& out,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage_class,
const std::string& name) {
- auto* access = type->As<type::AccessControl>();
+ auto* access = type->As<sem::AccessControl>();
if (access) {
type = access->type();
}
@@ -2396,12 +2396,12 @@
return true;
}
- if (auto* alias = type->As<type::Alias>()) {
+ if (auto* alias = type->As<sem::Alias>()) {
out << builder_.Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::ArrayType>()) {
- type::Type* base_type = ary;
+ } else if (auto* ary = type->As<sem::ArrayType>()) {
+ sem::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<type::ArrayType>()) {
+ while (auto* arr = base_type->As<sem::ArrayType>()) {
if (arr->IsRuntimeArray()) {
TINT_ICE(diagnostics_)
<< "Runtime arrays may only exist in storage buffers, which should "
@@ -2420,13 +2420,13 @@
for (uint32_t size : sizes) {
out << "[" << size << "]";
}
- } else if (type->Is<type::Bool>()) {
+ } else if (type->Is<sem::Bool>()) {
out << "bool";
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
out << "float";
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
out << "int";
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
if (!EmitType(out, mat->type(), storage_class, "")) {
return false;
}
@@ -2438,23 +2438,23 @@
// See:
// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math#matrix-ordering
out << mat->columns() << "x" << mat->rows();
- } else if (type->Is<type::Pointer>()) {
+ } else if (type->Is<sem::Pointer>()) {
// TODO(dsinclair): What do we do with pointers in HLSL?
// https://bugs.chromium.org/p/tint/issues/detail?id=183
diagnostics_.add_error("pointers not supported in HLSL");
return false;
- } else if (auto* sampler = type->As<type::Sampler>()) {
+ } else if (auto* sampler = type->As<sem::Sampler>()) {
out << "Sampler";
if (sampler->IsComparison()) {
out << "Comparison";
}
out << "State";
- } else if (auto* str = type->As<type::StructType>()) {
+ } else if (auto* str = type->As<sem::StructType>()) {
out << builder_.Symbols().NameFor(str->symbol());
- } else if (auto* tex = type->As<type::Texture>()) {
- auto* storage = tex->As<type::StorageTexture>();
- auto* multism = tex->As<type::MultisampledTexture>();
- auto* sampled = tex->As<type::SampledTexture>();
+ } else if (auto* tex = type->As<sem::Texture>()) {
+ auto* storage = tex->As<sem::StorageTexture>();
+ auto* multism = tex->As<sem::MultisampledTexture>();
+ auto* sampled = tex->As<sem::SampledTexture>();
if (storage) {
if (access && !access->IsReadOnly()) {
@@ -2464,22 +2464,22 @@
out << "Texture";
switch (tex->dim()) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
out << "1D";
break;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
out << (multism ? "2DMS" : "2D");
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
out << (multism ? "2DMSArray" : "2DArray");
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
out << "3D";
break;
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
out << "Cube";
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
out << "CubeArray";
break;
default:
@@ -2499,11 +2499,11 @@
} else if (sampled || multism) {
auto* subtype = sampled ? sampled->type() : multism->type();
out << "<";
- if (subtype->Is<type::F32>()) {
+ if (subtype->Is<sem::F32>()) {
out << "float4";
- } else if (subtype->Is<type::I32>()) {
+ } else if (subtype->Is<sem::I32>()) {
out << "int4";
- } else if (subtype->Is<type::U32>()) {
+ } else if (subtype->Is<sem::U32>()) {
out << "uint4";
} else {
TINT_ICE(diagnostics_) << "Unsupported multisampled texture type";
@@ -2511,15 +2511,15 @@
}
out << ">";
}
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
out << "uint";
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
auto size = vec->size();
- if (vec->type()->Is<type::F32>() && size >= 1 && size <= 4) {
+ if (vec->type()->Is<sem::F32>() && size >= 1 && size <= 4) {
out << "float" << size;
- } else if (vec->type()->Is<type::I32>() && size >= 1 && size <= 4) {
+ } else if (vec->type()->Is<sem::I32>() && size >= 1 && size <= 4) {
out << "int" << size;
- } else if (vec->type()->Is<type::U32>() && size >= 1 && size <= 4) {
+ } else if (vec->type()->Is<sem::U32>() && size >= 1 && size <= 4) {
out << "uint" << size;
} else {
out << "vector<";
@@ -2528,7 +2528,7 @@
}
out << ", " << size << ">";
}
- } else if (type->Is<type::Void>()) {
+ } else if (type->Is<sem::Void>()) {
out << "void";
} else {
diagnostics_.add_error("unknown type in EmitType");
@@ -2539,7 +2539,7 @@
}
bool GeneratorImpl::EmitStructType(std::ostream& out,
- const type::StructType* str,
+ const sem::StructType* str,
const std::string& name) {
auto* sem_str = builder_.Sem().Get(str);
@@ -2565,7 +2565,7 @@
return false;
}
// Array member name will be output with the type
- if (!mem->type()->Is<type::ArrayType>()) {
+ if (!mem->type()->Is<sem::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(mem->symbol());
}
@@ -2664,7 +2664,7 @@
builder_.Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::ArrayType>()) {
+ if (!type->Is<sem::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(var->symbol());
}
out << constructor_out.str() << ";" << std::endl;
@@ -2726,7 +2726,7 @@
builder_.Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::ArrayType>()) {
+ if (!type->Is<sem::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(var->symbol());
}
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index 4e5410a..0059fc0 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -36,9 +36,9 @@
namespace tint {
// Forward declarations
-namespace type {
+namespace sem {
class AccessControl;
-} // namespace type
+} // namespace sem
namespace sem {
class Call;
class Intrinsic;
@@ -63,7 +63,7 @@
/// @param out the output stream
/// @param ty the constructed type to generate
/// @returns true if the constructed type was emitted
- bool EmitConstructedType(std::ostream& out, const type::Type* ty);
+ bool EmitConstructedType(std::ostream& out, const sem::Type* ty);
/// Handles an array accessor expression
/// @param pre the preamble for the expression stream
/// @param out the output of the expression stream
@@ -290,7 +290,7 @@
/// @param name the name of the variable, only used for array emission
/// @returns true if the type is emitted
bool EmitType(std::ostream& out,
- type::Type* type,
+ sem::Type* type,
ast::StorageClass storage_class,
const std::string& name);
/// Handles generating a structure declaration
@@ -299,7 +299,7 @@
/// @param name the struct name
/// @returns true if the struct is emitted
bool EmitStructType(std::ostream& out,
- const type::StructType* ty,
+ const sem::StructType* ty,
const std::string& name);
/// Handles a unary op expression
/// @param pre the preamble for the expression stream
@@ -313,7 +313,7 @@
/// @param out the output stream
/// @param type the type to emit the value for
/// @returns true if the zero value was successfully emitted.
- bool EmitZeroValue(std::ostream& out, type::Type* type);
+ bool EmitZeroValue(std::ostream& out, sem::Type* type);
/// Handles generating a variable
/// @param out the output stream
/// @param var the variable to generate
@@ -375,7 +375,7 @@
/// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression
- type::Type* TypeOf(ast::Expression* expr) const {
+ sem::Type* TypeOf(ast::Expression* expr) const {
return builder_.TypeOf(expr);
}
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index 923ee9b..0f73a30 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -395,7 +395,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
@@ -441,7 +441,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ sem::AccessControl ac(ast::AccessControl::kReadOnly, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
@@ -487,7 +487,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kWriteOnly, s);
+ sem::AccessControl ac(ast::AccessControl::kWriteOnly, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
@@ -531,7 +531,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
@@ -983,7 +983,7 @@
Structure("Data", {Member("d", ty.f32())},
ast::DecorationList{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("data", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc
index 04aeb5e..dec7275 100644
--- a/src/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -26,63 +26,63 @@
using ::testing::HasSubstr;
using create_type_func_ptr =
- type::Type* (*)(const ProgramBuilder::TypesBuilder& ty);
+ sem::Type* (*)(const ProgramBuilder::TypesBuilder& ty);
-inline type::Type* ty_i32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_i32(const ProgramBuilder::TypesBuilder& ty) {
return ty.i32();
}
-inline type::Type* ty_u32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_u32(const ProgramBuilder::TypesBuilder& ty) {
return ty.u32();
}
-inline type::Type* ty_f32(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_f32(const ProgramBuilder::TypesBuilder& ty) {
return ty.f32();
}
template <typename T>
-inline type::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec2<T>();
}
template <typename T>
-inline type::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec3<T>();
}
template <typename T>
-inline type::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) {
return ty.vec4<T>();
}
template <typename T>
-inline type::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat2x2<T>();
}
template <typename T>
-inline type::Type* ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat2x3<T>();
}
template <typename T>
-inline type::Type* ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat2x4<T>();
}
template <typename T>
-inline type::Type* ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat3x2<T>();
}
template <typename T>
-inline type::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat3x3<T>();
}
template <typename T>
-inline type::Type* ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat3x4<T>();
}
template <typename T>
-inline type::Type* ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat4x2<T>();
}
template <typename T>
-inline type::Type* ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat4x3<T>();
}
template <typename T>
-inline type::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
+inline sem::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) {
return ty.mat4x4<T>();
}
@@ -100,7 +100,7 @@
b.Structure("Data", members, {b.create<ast::StructBlockDecoration>()});
auto* ac_ty =
- b.create<type::AccessControl>(ast::AccessControl::kReadWrite, s);
+ b.create<sem::AccessControl>(ast::AccessControl::kReadWrite, s);
b.Global("data", ac_ty, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
diff --git a/src/writer/hlsl/generator_impl_sanitizer_test.cc b/src/writer/hlsl/generator_impl_sanitizer_test.cc
index 2f40138..7093713 100644
--- a/src/writer/hlsl/generator_impl_sanitizer_test.cc
+++ b/src/writer/hlsl/generator_impl_sanitizer_test.cc
@@ -35,7 +35,7 @@
create<ast::StructBlockDecoration>(),
});
auto* ac_ty =
- create<type::AccessControl>(ast::AccessControl::kReadOnly, sb_ty);
+ create<sem::AccessControl>(ast::AccessControl::kReadOnly, sb_ty);
Global("sb", ac_ty, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc
index d9bb495..de36717 100644
--- a/src/writer/hlsl/generator_impl_type_test.cc
+++ b/src/writer/hlsl/generator_impl_type_test.cc
@@ -146,7 +146,7 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) {
- type::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
+ sem::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
GeneratorImpl& gen = Build();
@@ -295,7 +295,7 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
- type::Sampler sampler(type::SamplerKind::kSampler);
+ sem::Sampler sampler(sem::SamplerKind::kSampler);
GeneratorImpl& gen = Build();
@@ -305,7 +305,7 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
- type::Sampler sampler(type::SamplerKind::kComparisonSampler);
+ sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
GeneratorImpl& gen = Build();
@@ -315,7 +315,7 @@
}
struct HlslDepthTextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
@@ -326,7 +326,7 @@
TEST_P(HlslDepthTexturesTest, Emit) {
auto params = GetParam();
- auto* t = create<type::DepthTexture>(params.dim);
+ auto* t = create<sem::DepthTexture>(params.dim);
Global("tex", t, ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@@ -349,18 +349,18 @@
HlslGeneratorImplTest_Type,
HlslDepthTexturesTest,
testing::Values(
- HlslDepthTextureData{type::TextureDimension::k2d,
+ HlslDepthTextureData{sem::TextureDimension::k2d,
"Texture2D tex : register(t1, space2);"},
- HlslDepthTextureData{type::TextureDimension::k2dArray,
+ HlslDepthTextureData{sem::TextureDimension::k2dArray,
"Texture2DArray tex : register(t1, space2);"},
- HlslDepthTextureData{type::TextureDimension::kCube,
+ HlslDepthTextureData{sem::TextureDimension::kCube,
"TextureCube tex : register(t1, space2);"},
- HlslDepthTextureData{type::TextureDimension::kCubeArray,
+ HlslDepthTextureData{sem::TextureDimension::kCubeArray,
"TextureCubeArray tex : register(t1, space2);"}));
enum class TextureDataType { F32, U32, I32 };
struct HlslSampledTextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
TextureDataType datatype;
std::string result;
};
@@ -373,7 +373,7 @@
TEST_P(HlslSampledTexturesTest, Emit) {
auto params = GetParam();
- type::Type* datatype = nullptr;
+ sem::Type* datatype = nullptr;
switch (params.datatype) {
case TextureDataType::F32:
datatype = ty.f32();
@@ -385,7 +385,7 @@
datatype = ty.i32();
break;
}
- auto* t = create<type::SampledTexture>(params.dim, datatype);
+ auto* t = create<sem::SampledTexture>(params.dim, datatype);
Global("tex", t, ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@@ -409,98 +409,98 @@
HlslSampledTexturesTest,
testing::Values(
HlslSampledTextureData{
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::F32,
"Texture1D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::F32,
"Texture2D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::F32,
"Texture2DArray<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::F32,
"Texture3D<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCube,
+ sem::TextureDimension::kCube,
TextureDataType::F32,
"TextureCube<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
TextureDataType::F32,
"TextureCubeArray<float4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::U32,
"Texture1D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::U32,
"Texture2D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::U32,
"Texture2DArray<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::U32,
"Texture3D<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCube,
+ sem::TextureDimension::kCube,
TextureDataType::U32,
"TextureCube<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
TextureDataType::U32,
"TextureCubeArray<uint4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k1d,
+ sem::TextureDimension::k1d,
TextureDataType::I32,
"Texture1D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
TextureDataType::I32,
"Texture2D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k2dArray,
+ sem::TextureDimension::k2dArray,
TextureDataType::I32,
"Texture2DArray<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::k3d,
+ sem::TextureDimension::k3d,
TextureDataType::I32,
"Texture3D<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCube,
+ sem::TextureDimension::kCube,
TextureDataType::I32,
"TextureCube<int4> tex : register(t1, space2);",
},
HlslSampledTextureData{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
TextureDataType::I32,
"TextureCubeArray<int4> tex : register(t1, space2);",
}));
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
- type::MultisampledTexture s(type::TextureDimension::k2d, ty.f32());
+ sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.f32());
GeneratorImpl& gen = Build();
@@ -510,8 +510,8 @@
}
struct HlslStorageTextureData {
- type::TextureDimension dim;
- type::ImageFormat imgfmt;
+ sem::TextureDimension dim;
+ sem::ImageFormat imgfmt;
bool ro;
std::string result;
};
@@ -524,12 +524,12 @@
TEST_P(HlslStorageTexturesTest, Emit) {
auto params = GetParam();
- auto* subtype = type::StorageTexture::SubtypeFor(params.imgfmt, Types());
- auto* t = create<type::StorageTexture>(params.dim, params.imgfmt, subtype);
+ auto* subtype = sem::StorageTexture::SubtypeFor(params.imgfmt, Types());
+ auto* t = create<sem::StorageTexture>(params.dim, params.imgfmt, subtype);
auto* ac =
- create<type::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- t);
+ create<sem::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ t);
Global("tex", ac, ast::StorageClass::kUniformConstant, nullptr,
ast::DecorationList{
@@ -552,44 +552,44 @@
HlslGeneratorImplTest_Type,
HlslStorageTexturesTest,
testing::Values(
- HlslStorageTextureData{type::TextureDimension::k1d,
- type::ImageFormat::kRgba8Unorm, true,
+ HlslStorageTextureData{sem::TextureDimension::k1d,
+ sem::ImageFormat::kRgba8Unorm, true,
"Texture1D<float4> tex : register(t1, space2);"},
- HlslStorageTextureData{type::TextureDimension::k2d,
- type::ImageFormat::kRgba16Float, true,
+ HlslStorageTextureData{sem::TextureDimension::k2d,
+ sem::ImageFormat::kRgba16Float, true,
"Texture2D<float4> tex : register(t1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k2dArray, type::ImageFormat::kR32Float,
- true, "Texture2DArray<float4> tex : register(t1, space2);"},
- HlslStorageTextureData{type::TextureDimension::k3d,
- type::ImageFormat::kRg32Float, true,
+ sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Float, true,
+ "Texture2DArray<float4> tex : register(t1, space2);"},
+ HlslStorageTextureData{sem::TextureDimension::k3d,
+ sem::ImageFormat::kRg32Float, true,
"Texture3D<float4> tex : register(t1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k1d, type::ImageFormat::kRgba32Float, false,
+ sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Float, false,
"RWTexture1D<float4> tex : register(u1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k2d, type::ImageFormat::kRgba16Uint, false,
+ sem::TextureDimension::k2d, sem::ImageFormat::kRgba16Uint, false,
"RWTexture2D<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k2dArray, type::ImageFormat::kR32Uint,
- false, "RWTexture2DArray<uint4> tex : register(u1, space2);"},
+ sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Uint, false,
+ "RWTexture2DArray<uint4> tex : register(u1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k3d, type::ImageFormat::kRg32Uint, false,
+ sem::TextureDimension::k3d, sem::ImageFormat::kRg32Uint, false,
"RWTexture3D<uint4> tex : register(u1, space2);"},
- HlslStorageTextureData{type::TextureDimension::k1d,
- type::ImageFormat::kRgba32Uint, true,
+ HlslStorageTextureData{sem::TextureDimension::k1d,
+ sem::ImageFormat::kRgba32Uint, true,
"Texture1D<uint4> tex : register(t1, space2);"},
- HlslStorageTextureData{type::TextureDimension::k2d,
- type::ImageFormat::kRgba16Sint, true,
+ HlslStorageTextureData{sem::TextureDimension::k2d,
+ sem::ImageFormat::kRgba16Sint, true,
"Texture2D<int4> tex : register(t1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k2dArray, type::ImageFormat::kR32Sint, true,
+ sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Sint, true,
"Texture2DArray<int4> tex : register(t1, space2);"},
- HlslStorageTextureData{type::TextureDimension::k3d,
- type::ImageFormat::kRg32Sint, true,
+ HlslStorageTextureData{sem::TextureDimension::k3d,
+ sem::ImageFormat::kRg32Sint, true,
"Texture3D<int4> tex : register(t1, space2);"},
HlslStorageTextureData{
- type::TextureDimension::k1d, type::ImageFormat::kRgba32Sint, false,
+ sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Sint, false,
"RWTexture1D<int4> tex : register(u1, space2);"}));
} // namespace
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 1c3474b..2fb8fc2 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -145,17 +145,17 @@
return true;
}
-bool GeneratorImpl::EmitConstructedType(const type::Type* ty) {
+bool GeneratorImpl::EmitConstructedType(const sem::Type* ty) {
make_indent();
- if (auto* alias = ty->As<type::Alias>()) {
+ if (auto* alias = ty->As<sem::Alias>()) {
out_ << "typedef ";
if (!EmitType(alias->type(), "")) {
return false;
}
out_ << " " << program_->Symbols().NameFor(alias->symbol()) << ";"
<< std::endl;
- } else if (auto* str = ty->As<type::StructType>()) {
+ } else if (auto* str = ty->As<sem::StructType>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -490,27 +490,27 @@
return false;
}
- auto* texture_type = TypeOf(texture)->UnwrapAll()->As<type::Texture>();
+ auto* texture_type = TypeOf(texture)->UnwrapAll()->As<sem::Texture>();
switch (intrinsic->Type()) {
case sem::IntrinsicType::kTextureDimensions: {
std::vector<const char*> dims;
switch (texture_type->dim()) {
- case type::TextureDimension::kNone:
+ case sem::TextureDimension::kNone:
diagnostics_.add_error("texture dimension is kNone");
return false;
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
dims = {"width"};
break;
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
dims = {"width", "height"};
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
dims = {"width", "height", "depth"};
break;
- case type::TextureDimension::kCube:
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCube:
+ case sem::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
dims = {"width", "height", "height"};
@@ -645,17 +645,17 @@
if (auto* ddx = arg(Usage::kDdx)) {
auto dim = texture_type->dim();
switch (dim) {
- case type::TextureDimension::k2d:
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k2dArray:
maybe_write_comma();
out_ << "gradient2d(";
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
maybe_write_comma();
out_ << "gradient3d(";
break;
- case type::TextureDimension::kCube:
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCube:
+ case sem::TextureDimension::kCubeArray:
maybe_write_comma();
out_ << "gradientcube(";
break;
@@ -886,7 +886,7 @@
}
bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
- if (expr->type()->IsAnyOf<type::ArrayType, type::StructType>()) {
+ if (expr->type()->IsAnyOf<sem::ArrayType, sem::StructType>()) {
out_ << "{";
} else {
if (!EmitType(expr->type(), "")) {
@@ -915,7 +915,7 @@
}
}
- if (expr->type()->IsAnyOf<type::ArrayType, type::StructType>()) {
+ if (expr->type()->IsAnyOf<sem::ArrayType, sem::StructType>()) {
out_ << "}";
} else {
out_ << ")";
@@ -923,26 +923,26 @@
return true;
}
-bool GeneratorImpl::EmitZeroValue(type::Type* type) {
- if (type->Is<type::Bool>()) {
+bool GeneratorImpl::EmitZeroValue(sem::Type* type) {
+ if (type->Is<sem::Bool>()) {
out_ << "false";
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
out_ << "0.0f";
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
out_ << "0";
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
out_ << "0u";
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
return EmitZeroValue(vec->type());
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
return EmitZeroValue(mat->type());
- } else if (auto* arr = type->As<type::ArrayType>()) {
+ } else if (auto* arr = type->As<sem::ArrayType>()) {
out_ << "{";
if (!EmitZeroValue(arr->type())) {
return false;
}
out_ << "}";
- } else if (type->As<type::StructType>()) {
+ } else if (type->As<sem::StructType>()) {
out_ << "{}";
} else {
diagnostics_.add_error("Invalid type for zero emission: " +
@@ -1296,7 +1296,7 @@
}
first = false;
- auto* ac = var->Type()->As<type::AccessControl>();
+ auto* ac = var->Type()->As<sem::AccessControl>();
if (ac == nullptr) {
diagnostics_.add_error(
"invalid type for storage buffer, expected access control");
@@ -1325,7 +1325,7 @@
return false;
}
// Array name is output as part of the type
- if (!type->Is<type::ArrayType>()) {
+ if (!type->Is<sem::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(v->symbol());
}
}
@@ -1395,7 +1395,7 @@
bool has_out_data = out_data != ep_sym_to_out_data_.end();
if (has_out_data) {
// TODO(crbug.com/tint/697): Remove this.
- if (!func->return_type()->Is<type::Void>()) {
+ if (!func->return_type()->Is<sem::Void>()) {
TINT_ICE(diagnostics_) << "Mixing module-scope variables and return "
"types for shader outputs";
}
@@ -1429,7 +1429,7 @@
out_ << " " << program_->Symbols().NameFor(var->symbol());
- if (type->Is<type::StructType>()) {
+ if (type->Is<sem::StructType>()) {
out_ << " [[stage_in]]";
} else {
auto& decos = var->decorations();
@@ -1524,7 +1524,7 @@
auto* binding = data.second.binding;
// auto* set = data.second.set;
- auto* ac = var->Type()->As<type::AccessControl>();
+ auto* ac = var->Type()->As<sem::AccessControl>();
if (ac == nullptr) {
diagnostics_.add_error(
"invalid type for storage buffer, expected access control");
@@ -1891,9 +1891,9 @@
return true;
}
-bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) {
+bool GeneratorImpl::EmitType(sem::Type* type, const std::string& name) {
std::string access_str = "";
- if (auto* ac = type->As<type::AccessControl>()) {
+ if (auto* ac = type->As<sem::AccessControl>()) {
if (ac->access_control() == ast::AccessControl::kReadOnly) {
access_str = "read";
} else if (ac->access_control() == ast::AccessControl::kWriteOnly) {
@@ -1906,12 +1906,12 @@
type = ac->type();
}
- if (auto* alias = type->As<type::Alias>()) {
+ if (auto* alias = type->As<sem::Alias>()) {
out_ << program_->Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::ArrayType>()) {
- type::Type* base_type = ary;
+ } else if (auto* ary = type->As<sem::ArrayType>()) {
+ sem::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<type::ArrayType>()) {
+ while (auto* arr = base_type->As<sem::ArrayType>()) {
if (arr->IsRuntimeArray()) {
sizes.push_back(1);
} else {
@@ -1928,76 +1928,76 @@
for (uint32_t size : sizes) {
out_ << "[" << size << "]";
}
- } else if (type->Is<type::Bool>()) {
+ } else if (type->Is<sem::Bool>()) {
out_ << "bool";
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
out_ << "float";
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
out_ << "int";
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
if (!EmitType(mat->type(), "")) {
return false;
}
out_ << mat->columns() << "x" << mat->rows();
- } else if (auto* ptr = type->As<type::Pointer>()) {
+ } else if (auto* ptr = type->As<sem::Pointer>()) {
// TODO(dsinclair): Storage class?
if (!EmitType(ptr->type(), "")) {
return false;
}
out_ << "*";
- } else if (type->Is<type::Sampler>()) {
+ } else if (type->Is<sem::Sampler>()) {
out_ << "sampler";
- } else if (auto* str = type->As<type::StructType>()) {
+ } else if (auto* str = type->As<sem::StructType>()) {
// The struct type emits as just the name. The declaration would be emitted
// as part of emitting the constructed types.
out_ << program_->Symbols().NameFor(str->symbol());
- } else if (auto* tex = type->As<type::Texture>()) {
- if (tex->Is<type::DepthTexture>()) {
+ } else if (auto* tex = type->As<sem::Texture>()) {
+ if (tex->Is<sem::DepthTexture>()) {
out_ << "depth";
} else {
out_ << "texture";
}
switch (tex->dim()) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
out_ << "1d";
break;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
out_ << "2d";
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
out_ << "2d_array";
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
out_ << "3d";
break;
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
out_ << "cube";
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:
diagnostics_.add_error("Invalid texture dimensions");
return false;
}
- if (tex->Is<type::MultisampledTexture>()) {
+ if (tex->Is<sem::MultisampledTexture>()) {
out_ << "_ms";
}
out_ << "<";
- if (tex->Is<type::DepthTexture>()) {
+ if (tex->Is<sem::DepthTexture>()) {
out_ << "float, access::sample";
- } else if (auto* storage = tex->As<type::StorageTexture>()) {
+ } else if (auto* storage = tex->As<sem::StorageTexture>()) {
if (!EmitType(storage->type(), "")) {
return false;
}
out_ << ", access::" << access_str;
- } else if (auto* ms = tex->As<type::MultisampledTexture>()) {
+ } else if (auto* ms = tex->As<sem::MultisampledTexture>()) {
if (!EmitType(ms->type(), "")) {
return false;
}
out_ << ", access::sample";
- } else if (auto* sampled = tex->As<type::SampledTexture>()) {
+ } else if (auto* sampled = tex->As<sem::SampledTexture>()) {
if (!EmitType(sampled->type(), "")) {
return false;
}
@@ -2008,14 +2008,14 @@
}
out_ << ">";
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
out_ << "uint";
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
if (!EmitType(vec->type(), "")) {
return false;
}
out_ << vec->size();
- } else if (type->Is<type::Void>()) {
+ } else if (type->Is<sem::Void>()) {
out_ << "void";
} else {
diagnostics_.add_error("unknown type in EmitType: " + type->type_name());
@@ -2025,12 +2025,12 @@
return true;
}
-bool GeneratorImpl::EmitPackedType(type::Type* type, const std::string& name) {
- if (auto* alias = type->As<type::Alias>()) {
+bool GeneratorImpl::EmitPackedType(sem::Type* type, const std::string& name) {
+ if (auto* alias = type->As<sem::Alias>()) {
return EmitPackedType(alias->type(), name);
}
- if (auto* vec = type->As<type::Vector>()) {
+ if (auto* vec = type->As<sem::Vector>()) {
out_ << "packed_";
if (!EmitType(vec->type(), "")) {
return false;
@@ -2042,7 +2042,7 @@
return EmitType(type, name);
}
-bool GeneratorImpl::EmitStructType(const type::StructType* str) {
+bool GeneratorImpl::EmitStructType(const sem::StructType* str) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::Decoration::kNone) {
// }
@@ -2120,7 +2120,7 @@
auto* ty = mem->type()->UnwrapAliasIfNeeded();
// Array member name will be output with the type
- if (!ty->Is<type::ArrayType>()) {
+ if (!ty->Is<sem::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(mem->symbol());
}
@@ -2222,7 +2222,7 @@
if (!EmitType(var->Type(), program_->Symbols().NameFor(decl->symbol()))) {
return false;
}
- if (!var->Type()->Is<type::ArrayType>()) {
+ if (!var->Type()->Is<sem::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(decl->symbol());
}
@@ -2265,7 +2265,7 @@
if (!EmitType(type, program_->Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::ArrayType>()) {
+ if (!type->Is<sem::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(var->symbol());
}
@@ -2283,32 +2283,32 @@
}
GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(
- type::Type* ty) {
+ sem::Type* ty) {
ty = ty->UnwrapAliasIfNeeded();
- if (ty->IsAnyOf<type::U32, type::I32, type::F32>()) {
+ if (ty->IsAnyOf<sem::U32, sem::I32, sem::F32>()) {
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
// 2.1 Scalar Data Types
return {4, 4};
}
- if (auto* vec = ty->As<type::Vector>()) {
+ if (auto* vec = ty->As<sem::Vector>()) {
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
// 2.2.3 Packed Vector Types
auto num_els = vec->size();
auto* el_ty = vec->type()->UnwrapAll();
- if (el_ty->IsAnyOf<type::U32, type::I32, type::F32>()) {
+ if (el_ty->IsAnyOf<sem::U32, sem::I32, sem::F32>()) {
return SizeAndAlign{num_els * 4, 4};
}
}
- if (auto* mat = ty->As<type::Matrix>()) {
+ if (auto* mat = ty->As<sem::Matrix>()) {
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
// 2.3 Matrix Data Types
auto cols = mat->columns();
auto rows = mat->rows();
auto* el_ty = mat->type()->UnwrapAll();
- if (el_ty->IsAnyOf<type::U32, type::I32, type::F32>()) {
+ if (el_ty->IsAnyOf<sem::U32, sem::I32, sem::F32>()) {
static constexpr SizeAndAlign table[] = {
/* float2x2 */ {16, 8},
/* float2x3 */ {32, 16},
@@ -2326,7 +2326,7 @@
}
}
- if (auto* arr = ty->As<type::ArrayType>()) {
+ if (auto* arr = ty->As<sem::ArrayType>()) {
auto* sem = program_->Sem().Get(arr);
if (!sem) {
TINT_ICE(diagnostics_) << "Array missing semantic info";
@@ -2345,7 +2345,7 @@
return SizeAndAlign{el_size_align.size * num_els, el_size_align.align};
}
- if (auto* str = ty->As<type::StructType>()) {
+ if (auto* str = ty->As<sem::StructType>()) {
// TODO(crbug.com/tint/650): There's an assumption here that MSL's default
// structure size and alignment matches WGSL's. We need to confirm this.
auto* sem = program_->Sem().Get(str);
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index c576476..fd1f9fb 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -63,7 +63,7 @@
/// Handles generating a constructed
/// @param ty the constructed type to generate
/// @returns true if the constructed type was emitted
- bool EmitConstructedType(const type::Type* ty);
+ bool EmitConstructedType(const sem::Type* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
@@ -195,18 +195,18 @@
/// @param type the type to generate
/// @param name the name of the variable, only used for array emission
/// @returns true if the type is emitted
- bool EmitType(type::Type* type, const std::string& name);
+ bool EmitType(sem::Type* type, const std::string& name);
/// Handles generating an MSL-packed storage type.
/// If the type does not have a packed form, the standard non-packed form is
/// emitted.
/// @param type the type to generate
/// @param name the name of the variable, only used for array emission
/// @returns true if the type is emitted
- bool EmitPackedType(type::Type* type, const std::string& name);
+ bool EmitPackedType(sem::Type* type, const std::string& name);
/// Handles generating a struct declaration
/// @param str the struct to generate
/// @returns true if the struct is emitted
- bool EmitStructType(const type::StructType* str);
+ bool EmitStructType(const sem::StructType* str);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
@@ -227,7 +227,7 @@
/// Emits the zero value for the given type
/// @param type the type to emit the value for
/// @returns true if the zero value was successfully emitted.
- bool EmitZeroValue(type::Type* type);
+ bool EmitZeroValue(sem::Type* type);
/// Determines if the function needs the input struct passed to it.
/// @param func the function to check
@@ -269,7 +269,7 @@
/// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression
- type::Type* TypeOf(ast::Expression* expr) const {
+ sem::Type* TypeOf(ast::Expression* expr) const {
return program_->TypeOf(expr);
}
@@ -281,7 +281,7 @@
/// @returns the MSL packed type size and alignment in bytes for the given
/// type.
- SizeAndAlign MslPackedTypeSizeAndAlign(type::Type* ty);
+ SizeAndAlign MslPackedTypeSizeAndAlign(sem::Type* ty);
ScopeStack<const sem::Variable*> global_variables_;
Symbol current_ep_sym_;
diff --git a/src/writer/msl/generator_impl_binary_test.cc b/src/writer/msl/generator_impl_binary_test.cc
index 1f91e90..fb8ae0f 100644
--- a/src/writer/msl/generator_impl_binary_test.cc
+++ b/src/writer/msl/generator_impl_binary_test.cc
@@ -33,8 +33,8 @@
auto* type = ((params.op == ast::BinaryOp::kLogicalAnd) ||
(params.op == ast::BinaryOp::kLogicalOr))
- ? static_cast<type::Type*>(ty.bool_())
- : static_cast<type::Type*>(ty.u32());
+ ? static_cast<sem::Type*>(ty.bool_())
+ : static_cast<sem::Type*>(ty.u32());
auto* left = Var("left", type, ast::StorageClass::kFunction);
auto* right = Var("right", type, ast::StorageClass::kFunction);
diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc
index 8cf5908..34b0b31 100644
--- a/src/writer/msl/generator_impl_function_test.cc
+++ b/src/writer/msl/generator_impl_function_test.cc
@@ -314,7 +314,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{create<ast::BindingDecoration>(0),
@@ -360,7 +360,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ sem::AccessControl ac(ast::AccessControl::kReadOnly, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{create<ast::BindingDecoration>(0),
@@ -620,7 +620,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{create<ast::BindingDecoration>(0),
@@ -678,7 +678,7 @@
},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ sem::AccessControl ac(ast::AccessControl::kReadOnly, s);
Global("coord", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{create<ast::BindingDecoration>(0),
@@ -818,7 +818,7 @@
auto* s = Structure("Data", {Member("d", ty.f32())},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("data", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{create<ast::BindingDecoration>(0),
diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc
index fbad91a..0a00963 100644
--- a/src/writer/msl/generator_impl_type_test.cc
+++ b/src/writer/msl/generator_impl_type_test.cc
@@ -164,7 +164,7 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) {
- type::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
+ sem::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
GeneratorImpl& gen = Build();
@@ -631,7 +631,7 @@
}
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
- type::Sampler sampler(type::SamplerKind::kSampler);
+ sem::Sampler sampler(sem::SamplerKind::kSampler);
GeneratorImpl& gen = Build();
@@ -640,7 +640,7 @@
}
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
- type::Sampler sampler(type::SamplerKind::kComparisonSampler);
+ sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
GeneratorImpl& gen = Build();
@@ -649,7 +649,7 @@
}
struct MslDepthTextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
@@ -660,7 +660,7 @@
TEST_P(MslDepthTexturesTest, Emit) {
auto params = GetParam();
- type::DepthTexture s(params.dim);
+ sem::DepthTexture s(params.dim);
GeneratorImpl& gen = Build();
@@ -670,18 +670,18 @@
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslDepthTexturesTest,
- testing::Values(MslDepthTextureData{type::TextureDimension::k2d,
+ testing::Values(MslDepthTextureData{sem::TextureDimension::k2d,
"depth2d<float, access::sample>"},
- MslDepthTextureData{type::TextureDimension::k2dArray,
+ MslDepthTextureData{sem::TextureDimension::k2dArray,
"depth2d_array<float, access::sample>"},
- MslDepthTextureData{type::TextureDimension::kCube,
+ MslDepthTextureData{sem::TextureDimension::kCube,
"depthcube<float, access::sample>"},
MslDepthTextureData{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
"depthcube_array<float, access::sample>"}));
struct MslTextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
@@ -692,7 +692,7 @@
TEST_P(MslSampledtexturesTest, Emit) {
auto params = GetParam();
- type::SampledTexture s(params.dim, ty.f32());
+ sem::SampledTexture s(params.dim, ty.f32());
GeneratorImpl& gen = Build();
@@ -702,22 +702,22 @@
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslSampledtexturesTest,
- testing::Values(MslTextureData{type::TextureDimension::k1d,
+ testing::Values(MslTextureData{sem::TextureDimension::k1d,
"texture1d<float, access::sample>"},
- MslTextureData{type::TextureDimension::k2d,
+ MslTextureData{sem::TextureDimension::k2d,
"texture2d<float, access::sample>"},
- MslTextureData{type::TextureDimension::k2dArray,
+ MslTextureData{sem::TextureDimension::k2dArray,
"texture2d_array<float, access::sample>"},
- MslTextureData{type::TextureDimension::k3d,
+ MslTextureData{sem::TextureDimension::k3d,
"texture3d<float, access::sample>"},
- MslTextureData{type::TextureDimension::kCube,
+ MslTextureData{sem::TextureDimension::kCube,
"texturecube<float, access::sample>"},
MslTextureData{
- type::TextureDimension::kCubeArray,
+ sem::TextureDimension::kCubeArray,
"texturecube_array<float, access::sample>"}));
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
- type::MultisampledTexture s(type::TextureDimension::k2d, ty.u32());
+ sem::MultisampledTexture s(sem::TextureDimension::k2d, ty.u32());
GeneratorImpl& gen = Build();
@@ -726,7 +726,7 @@
}
struct MslStorageTextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
bool ro;
std::string result;
};
@@ -739,13 +739,13 @@
auto params = GetParam();
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
- auto* s = create<type::StorageTexture>(params.dim,
- type::ImageFormat::kR16Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types());
+ auto* s = create<sem::StorageTexture>(params.dim, sem::ImageFormat::kR16Float,
+ subtype);
auto* ac =
- create<type::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- s);
+ create<sem::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ s);
Global("test_var", ac, ast::StorageClass::kInput);
GeneratorImpl& gen = Build();
@@ -757,21 +757,21 @@
MslGeneratorImplTest,
MslStorageTexturesTest,
testing::Values(
- MslStorageTextureData{type::TextureDimension::k1d, true,
+ MslStorageTextureData{sem::TextureDimension::k1d, true,
"texture1d<float, access::read>"},
- MslStorageTextureData{type::TextureDimension::k2d, true,
+ MslStorageTextureData{sem::TextureDimension::k2d, true,
"texture2d<float, access::read>"},
- MslStorageTextureData{type::TextureDimension::k2dArray, true,
+ MslStorageTextureData{sem::TextureDimension::k2dArray, true,
"texture2d_array<float, access::read>"},
- MslStorageTextureData{type::TextureDimension::k3d, true,
+ MslStorageTextureData{sem::TextureDimension::k3d, true,
"texture3d<float, access::read>"},
- MslStorageTextureData{type::TextureDimension::k1d, false,
+ MslStorageTextureData{sem::TextureDimension::k1d, false,
"texture1d<float, access::write>"},
- MslStorageTextureData{type::TextureDimension::k2d, false,
+ MslStorageTextureData{sem::TextureDimension::k2d, false,
"texture2d<float, access::write>"},
- MslStorageTextureData{type::TextureDimension::k2dArray, false,
+ MslStorageTextureData{sem::TextureDimension::k2dArray, false,
"texture2d_array<float, access::write>"},
- MslStorageTextureData{type::TextureDimension::k3d, false,
+ MslStorageTextureData{sem::TextureDimension::k3d, false,
"texture3d<float, access::write>"}));
} // namespace
diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
index 72d6ade..fce13d2 100644
--- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -52,7 +52,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
- type::ArrayType ary(ty.f32(), 5, ast::DecorationList{});
+ sem::ArrayType ary(ty.f32(), 5, ast::DecorationList{});
auto* var = Var("a", &ary, ast::StorageClass::kNone);
auto* stmt = create<ast::VariableDeclStatement>(var);
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index a78dad2..fd80ef3 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -111,11 +111,11 @@
/// one or more levels of an arrays inside of `type`.
/// @param type the given type, which must not be null
/// @returns the nested matrix type, or nullptr if none
-type::Matrix* GetNestedMatrixType(type::Type* type) {
- while (auto* arr = type->As<type::ArrayType>()) {
+sem::Matrix* GetNestedMatrixType(sem::Type* type) {
+ while (auto* arr = type->As<sem::ArrayType>()) {
type = arr->type();
}
- return type->As<type::Matrix>();
+ return type->As<sem::Matrix>();
}
uint32_t intrinsic_to_glsl_method(const sem::Intrinsic* intrinsic) {
@@ -251,8 +251,8 @@
}
/// @return the vector element type if ty is a vector, otherwise return ty.
-type::Type* ElementTypeOf(type::Type* ty) {
- if (auto* v = ty->As<type::Vector>()) {
+sem::Type* ElementTypeOf(sem::Type* ty) {
+ if (auto* v = ty->As<sem::Vector>()) {
return v->type();
}
return ty;
@@ -632,7 +632,7 @@
auto var_id = result.to_i();
auto sc = ast::StorageClass::kFunction;
auto* type = builder_.Sem().Get(var)->Type();
- type::Pointer pt(type, sc);
+ sem::Pointer pt(type, sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -707,7 +707,7 @@
? ast::StorageClass::kPrivate
: sem->StorageClass();
- type::Pointer pt(sem->Type(), sc);
+ sem::Pointer pt(sem->Type(), sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -725,8 +725,8 @@
auto* type_no_ac = sem->Type()->UnwrapAll();
if (var->has_constructor()) {
ops.push_back(Operand::Int(init_id));
- } else if (type_no_ac->Is<type::Texture>()) {
- if (auto* ac = sem->Type()->As<type::AccessControl>()) {
+ } else if (type_no_ac->Is<sem::Texture>()) {
+ if (auto* ac = sem->Type()->As<sem::AccessControl>()) {
switch (ac->access_control()) {
case ast::AccessControl::kWriteOnly:
push_annot(
@@ -742,7 +742,7 @@
break;
}
}
- } else if (!type_no_ac->Is<type::Sampler>()) {
+ } else if (!type_no_ac->Is<sem::Sampler>()) {
// Certain cases require us to generate a constructor value.
//
// 1- ConstantId's must be attached to the OpConstant, if we have a
@@ -751,16 +751,16 @@
// 2- If we don't have a constructor and we're an Output or Private variable
// then WGSL requires an initializer.
if (ast::HasDecoration<ast::ConstantIdDecoration>(var->decorations())) {
- if (type_no_ac->Is<type::F32>()) {
+ if (type_no_ac->Is<sem::F32>()) {
ast::FloatLiteral l(ProgramID(), Source{}, type_no_ac, 0.0f);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type_no_ac->Is<type::U32>()) {
+ } else if (type_no_ac->Is<sem::U32>()) {
ast::UintLiteral l(ProgramID(), Source{}, type_no_ac, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type_no_ac->Is<type::I32>()) {
+ } else if (type_no_ac->Is<sem::I32>()) {
ast::SintLiteral l(ProgramID(), Source{}, type_no_ac, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type_no_ac->Is<type::Bool>()) {
+ } else if (type_no_ac->Is<sem::Bool>()) {
ast::BoolLiteral l(ProgramID(), Source{}, type_no_ac, false);
init_id = GenerateLiteralIfNeeded(var, &l);
} else {
@@ -826,9 +826,9 @@
// If the source is a pointer we access chain into it. We also access chain
// into an array of non-scalar types.
- if (info->source_type->Is<type::Pointer>() ||
- (info->source_type->Is<type::ArrayType>() &&
- !info->source_type->As<type::ArrayType>()->type()->is_scalar())) {
+ if (info->source_type->Is<sem::Pointer>() ||
+ (info->source_type->Is<sem::ArrayType>() &&
+ !info->source_type->As<sem::ArrayType>()->type()->is_scalar())) {
info->access_chain_indices.push_back(idx_id);
info->source_type = TypeOf(expr);
return true;
@@ -864,8 +864,8 @@
// If the data_type is a structure we're accessing a member, if it's a
// vector we're accessing a swizzle.
- if (data_type->Is<type::StructType>()) {
- auto* strct = data_type->As<type::StructType>()->impl();
+ if (data_type->Is<sem::StructType>()) {
+ auto* strct = data_type->As<sem::StructType>()->impl();
auto symbol = expr->member()->symbol();
uint32_t idx = 0;
@@ -876,7 +876,7 @@
}
}
- if (info->source_type->Is<type::Pointer>()) {
+ if (info->source_type->Is<sem::Pointer>()) {
auto idx_id = GenerateConstantIfNeeded(ScalarConstant::U32(idx));
if (idx_id == 0) {
return 0;
@@ -905,7 +905,7 @@
return true;
}
- if (!data_type->Is<type::Vector>()) {
+ if (!data_type->Is<sem::Vector>()) {
error_ = "Member accessor without a struct or vector. Something is wrong";
return false;
}
@@ -920,7 +920,7 @@
return false;
}
- if (info->source_type->Is<type::Pointer>()) {
+ if (info->source_type->Is<sem::Pointer>()) {
auto idx_id = GenerateConstantIfNeeded(ScalarConstant::U32(val));
if (idx_id == 0) {
return 0;
@@ -1044,10 +1044,10 @@
if (auto* array = accessors[0]->As<ast::ArrayAccessorExpression>()) {
auto* ary_res_type = TypeOf(array->array());
- if (!ary_res_type->Is<type::Pointer>() &&
- (ary_res_type->Is<type::ArrayType>() &&
- !ary_res_type->As<type::ArrayType>()->type()->is_scalar())) {
- type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
+ if (!ary_res_type->Is<sem::Pointer>() &&
+ (ary_res_type->Is<sem::ArrayType>() &&
+ !ary_res_type->As<sem::ArrayType>()->type()->is_scalar())) {
+ sem::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
auto result_type_id = GenerateTypeIfNeeded(&ptr);
if (result_type_id == 0) {
return 0;
@@ -1125,8 +1125,8 @@
return 0;
}
-uint32_t Builder::GenerateLoadIfNeeded(type::Type* type, uint32_t id) {
- if (!type->Is<type::Pointer>()) {
+uint32_t Builder::GenerateLoadIfNeeded(sem::Type* type, uint32_t id) {
+ if (!type->Is<sem::Pointer>()) {
return id;
}
@@ -1236,7 +1236,7 @@
}
auto* sc = e->As<ast::ScalarConstructorExpression>();
- if (result_type->Is<type::Vector>() && sc == nullptr) {
+ if (result_type->Is<sem::Vector>() && sc == nullptr) {
return false;
}
@@ -1245,14 +1245,14 @@
continue;
}
- type::Type* subtype = result_type->UnwrapAll();
- if (auto* vec = subtype->As<type::Vector>()) {
+ sem::Type* subtype = result_type->UnwrapAll();
+ if (auto* vec = subtype->As<sem::Vector>()) {
subtype = vec->type()->UnwrapAll();
- } else if (auto* mat = subtype->As<type::Matrix>()) {
+ } else if (auto* mat = subtype->As<sem::Matrix>()) {
subtype = mat->type()->UnwrapAll();
- } else if (auto* arr = subtype->As<type::ArrayType>()) {
+ } else if (auto* arr = subtype->As<sem::ArrayType>()) {
subtype = arr->type()->UnwrapAll();
- } else if (auto* str = subtype->As<type::StructType>()) {
+ } else if (auto* str = subtype->As<sem::StructType>()) {
subtype = str->impl()->members()[i]->type()->UnwrapAll();
}
if (subtype != TypeOf(sc)->UnwrapAll()) {
@@ -1283,10 +1283,10 @@
bool can_cast_or_copy = result_type->is_scalar();
- if (auto* res_vec = result_type->As<type::Vector>()) {
+ if (auto* res_vec = result_type->As<sem::Vector>()) {
if (res_vec->type()->is_scalar()) {
auto* value_type = TypeOf(values[0])->UnwrapAll();
- if (auto* val_vec = value_type->As<type::Vector>()) {
+ if (auto* val_vec = value_type->As<sem::Vector>()) {
if (val_vec->type()->is_scalar()) {
can_cast_or_copy = res_vec->size() == val_vec->size();
}
@@ -1306,7 +1306,7 @@
bool result_is_constant_composite = constructor_is_const;
bool result_is_spec_composite = false;
- if (auto* vec = result_type->As<type::Vector>()) {
+ if (auto* vec = result_type->As<sem::Vector>()) {
result_type = vec->type();
}
@@ -1328,9 +1328,9 @@
// If the result and value types are the same we can just use the object.
// If the result is not a vector then we should have validated that the
// value type is a correctly sized vector so we can just use it directly.
- if (result_type == value_type || result_type->Is<type::Matrix>() ||
- result_type->Is<type::ArrayType>() ||
- result_type->Is<type::StructType>()) {
+ if (result_type == value_type || result_type->Is<sem::Matrix>() ||
+ result_type->Is<sem::ArrayType>() ||
+ result_type->Is<sem::StructType>()) {
out << "_" << id;
ops.push_back(Operand::Int(id));
@@ -1355,7 +1355,7 @@
//
// For cases 1 and 2, if the type is different we also may need to insert
// a type cast.
- if (auto* vec = value_type->As<type::Vector>()) {
+ if (auto* vec = value_type->As<sem::Vector>()) {
auto* vec_type = vec->type();
auto value_type_id = GenerateTypeIfNeeded(vec_type);
@@ -1426,7 +1426,7 @@
return result.to_i();
}
-uint32_t Builder::GenerateCastOrCopyOrPassthrough(type::Type* to_type,
+uint32_t Builder::GenerateCastOrCopyOrPassthrough(sem::Type* to_type,
ast::Expression* from_expr) {
auto result = result_op();
auto result_id = result.to_i();
@@ -1445,29 +1445,29 @@
auto* from_type = TypeOf(from_expr)->UnwrapPtrIfNeeded();
spv::Op op = spv::Op::OpNop;
- if ((from_type->Is<type::I32>() && to_type->Is<type::F32>()) ||
+ if ((from_type->Is<sem::I32>() && to_type->Is<sem::F32>()) ||
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
op = spv::Op::OpConvertSToF;
- } else if ((from_type->Is<type::U32>() && to_type->Is<type::F32>()) ||
+ } else if ((from_type->Is<sem::U32>() && to_type->Is<sem::F32>()) ||
(from_type->is_unsigned_integer_vector() &&
to_type->is_float_vector())) {
op = spv::Op::OpConvertUToF;
- } else if ((from_type->Is<type::F32>() && to_type->Is<type::I32>()) ||
+ } else if ((from_type->Is<sem::F32>() && to_type->Is<sem::I32>()) ||
(from_type->is_float_vector() &&
to_type->is_signed_integer_vector())) {
op = spv::Op::OpConvertFToS;
- } else if ((from_type->Is<type::F32>() && to_type->Is<type::U32>()) ||
+ } else if ((from_type->Is<sem::F32>() && to_type->Is<sem::U32>()) ||
(from_type->is_float_vector() &&
to_type->is_unsigned_integer_vector())) {
op = spv::Op::OpConvertFToU;
- } else if ((from_type->Is<type::Bool>() && to_type->Is<type::Bool>()) ||
- (from_type->Is<type::U32>() && to_type->Is<type::U32>()) ||
- (from_type->Is<type::I32>() && to_type->Is<type::I32>()) ||
- (from_type->Is<type::F32>() && to_type->Is<type::F32>()) ||
- (from_type->Is<type::Vector>() && (from_type == to_type))) {
+ } else if ((from_type->Is<sem::Bool>() && to_type->Is<sem::Bool>()) ||
+ (from_type->Is<sem::U32>() && to_type->Is<sem::U32>()) ||
+ (from_type->Is<sem::I32>() && to_type->Is<sem::I32>()) ||
+ (from_type->Is<sem::F32>() && to_type->Is<sem::F32>()) ||
+ (from_type->Is<sem::Vector>() && (from_type == to_type))) {
return val_id;
- } else if ((from_type->Is<type::I32>() && to_type->Is<type::U32>()) ||
- (from_type->Is<type::U32>() && to_type->Is<type::I32>()) ||
+ } else if ((from_type->Is<sem::I32>() && to_type->Is<sem::U32>()) ||
+ (from_type->Is<sem::U32>() && to_type->Is<sem::I32>()) ||
(from_type->is_signed_integer_vector() &&
to_type->is_unsigned_integer_vector()) ||
(from_type->is_unsigned_integer_vector() &&
@@ -1528,22 +1528,22 @@
switch (constant.kind) {
case ScalarConstant::Kind::kU32: {
- type::U32 u32;
+ sem::U32 u32;
type_id = GenerateTypeIfNeeded(&u32);
break;
}
case ScalarConstant::Kind::kI32: {
- type::I32 i32;
+ sem::I32 i32;
type_id = GenerateTypeIfNeeded(&i32);
break;
}
case ScalarConstant::Kind::kF32: {
- type::F32 f32;
+ sem::F32 f32;
type_id = GenerateTypeIfNeeded(&f32);
break;
}
case ScalarConstant::Kind::kBool: {
- type::Bool bool_;
+ sem::Bool bool_;
type_id = GenerateTypeIfNeeded(&bool_);
break;
}
@@ -1599,7 +1599,7 @@
return result_id;
}
-uint32_t Builder::GenerateConstantNullIfNeeded(type::Type* type) {
+uint32_t Builder::GenerateConstantNullIfNeeded(sem::Type* type) {
auto type_id = GenerateTypeIfNeeded(type);
if (type_id == 0) {
return 0;
@@ -1981,14 +1981,14 @@
params.push_back(Operand::Int(struct_id));
auto* type = TypeOf(accessor->structure())->UnwrapAll();
- if (!type->Is<type::StructType>()) {
+ if (!type->Is<sem::StructType>()) {
error_ =
"invalid type (" + type->type_name() + ") for runtime array length";
return 0;
}
// Runtime array must be the last member in the structure
- params.push_back(Operand::Int(uint32_t(
- type->As<type::StructType>()->impl()->members().size() - 1)));
+ params.push_back(Operand::Int(
+ uint32_t(type->As<sem::StructType>()->impl()->members().size() - 1)));
if (!push_function_inst(spv::Op::OpArrayLength, params)) {
return 0;
@@ -2077,7 +2077,7 @@
return false;
}
- if (!param.type->Is<type::Pointer>()) {
+ if (!param.type->Is<sem::Pointer>()) {
val_id = GenerateLoadIfNeeded(TypeOf(arg), val_id);
}
@@ -2132,7 +2132,7 @@
TINT_ICE(builder_.Diagnostics()) << "missing texture argument";
}
- auto* texture_type = TypeOf(texture)->UnwrapAll()->As<type::Texture>();
+ auto* texture_type = TypeOf(texture)->UnwrapAll()->As<sem::Texture>();
auto op = spv::Op::OpNop;
@@ -2168,9 +2168,9 @@
// If the texture is not a depth texture, then this function simply delegates
// to calling append_result_type_and_id_to_spirv_params().
auto append_result_type_and_id_to_spirv_params_for_read = [&]() {
- if (texture_type->Is<type::DepthTexture>()) {
- auto* f32 = builder_.create<type::F32>();
- auto* spirv_result_type = builder_.create<type::Vector>(f32, 4);
+ if (texture_type->Is<sem::DepthTexture>()) {
+ auto* f32 = builder_.create<sem::F32>();
+ auto* spirv_result_type = builder_.create<sem::Vector>(f32, 4);
auto spirv_result = result_op();
post_emission = [=] {
return push_function_inst(
@@ -2202,7 +2202,7 @@
auto* element_type = ElementTypeOf(TypeOf(call));
auto spirv_result = result_op();
auto* spirv_result_type =
- builder_.create<type::Vector>(element_type, spirv_result_width);
+ builder_.create<sem::Vector>(element_type, spirv_result_width);
if (swizzle.size() > 1) {
post_emission = [=] {
OperandList operands{
@@ -2271,22 +2271,22 @@
std::vector<uint32_t> swizzle;
uint32_t spirv_dims = 0;
switch (texture_type->dim()) {
- case type::TextureDimension::kNone:
+ case sem::TextureDimension::kNone:
error_ = "texture dimension is kNone";
return false;
- case type::TextureDimension::k1d:
- case type::TextureDimension::k2d:
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k1d:
+ case sem::TextureDimension::k2d:
+ case sem::TextureDimension::k3d:
break; // No swizzle needed
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
swizzle = {0, 1, 1}; // Duplicate height for depth
spirv_dims = 2; // [width, height]
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
swizzle = {0, 1}; // Strip array index
spirv_dims = 3; // [width, height, array_count]
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
swizzle = {0, 1, 1}; // Strip array index, duplicate height for depth
spirv_dims = 3; // [width, height, array_count]
break;
@@ -2298,15 +2298,15 @@
}
spirv_params.emplace_back(gen_arg(Usage::kTexture));
- if (texture_type->Is<type::MultisampledTexture>() ||
- texture_type->Is<type::StorageTexture>()) {
+ if (texture_type->Is<sem::MultisampledTexture>() ||
+ texture_type->Is<sem::StorageTexture>()) {
op = spv::Op::OpImageQuerySize;
} else if (auto* level = arg(Usage::kLevel)) {
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(gen(level));
} else {
ast::SintLiteral i32_0(ProgramID(), Source{},
- builder_.create<type::I32>(), 0);
+ builder_.create<sem::I32>(), 0);
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(
Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0)));
@@ -2319,8 +2319,8 @@
default:
error_ = "texture is not arrayed";
return false;
- case type::TextureDimension::k2dArray:
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::k2dArray:
+ case sem::TextureDimension::kCubeArray:
spirv_dims = 3;
break;
}
@@ -2334,12 +2334,12 @@
spirv_params.emplace_back(gen_arg(Usage::kTexture));
- if (texture_type->Is<type::MultisampledTexture>() ||
- texture_type->Is<type::StorageTexture>()) {
+ if (texture_type->Is<sem::MultisampledTexture>() ||
+ texture_type->Is<sem::StorageTexture>()) {
op = spv::Op::OpImageQuerySize;
} else {
ast::SintLiteral i32_0(ProgramID(), Source{},
- builder_.create<type::I32>(), 0);
+ builder_.create<sem::I32>(), 0);
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(
Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0)));
@@ -2359,8 +2359,8 @@
break;
}
case IntrinsicType::kTextureLoad: {
- op = texture_type->Is<type::StorageTexture>() ? spv::Op::OpImageRead
- : spv::Op::OpImageFetch;
+ op = texture_type->Is<sem::StorageTexture>() ? spv::Op::OpImageRead
+ : spv::Op::OpImageFetch;
append_result_type_and_id_to_spirv_params_for_read();
spirv_params.emplace_back(gen_arg(Usage::kTexture));
if (!append_coords_to_spirv_params()) {
@@ -2413,10 +2413,10 @@
return false;
}
auto level = Operand::Int(0);
- if (TypeOf(arg(Usage::kLevel))->Is<type::I32>()) {
+ if (TypeOf(arg(Usage::kLevel))->Is<sem::I32>()) {
// Depth textures have i32 parameters for the level, but SPIR-V expects
// F32. Cast.
- auto* f32 = builder_.create<type::F32>();
+ auto* f32 = builder_.create<sem::F32>();
ast::TypeConstructorExpression cast(ProgramID(), Source{}, f32,
{arg(Usage::kLevel)});
level = Operand::Int(GenerateExpression(&cast));
@@ -2449,7 +2449,7 @@
}
spirv_params.emplace_back(gen_arg(Usage::kDepthRef));
- type::F32 f32;
+ sem::F32 f32;
ast::FloatLiteral float_0(ProgramID(), Source{}, &f32, 0.0);
image_operands.emplace_back(ImageOperand{
SpvImageOperandsLodMask,
@@ -2532,7 +2532,7 @@
});
}
-uint32_t Builder::GenerateSampledImage(type::Type* texture_type,
+uint32_t Builder::GenerateSampledImage(sem::Type* texture_type,
Operand texture_operand,
Operand sampler_operand) {
uint32_t sampled_image_type_id = 0;
@@ -2924,18 +2924,18 @@
return GenerateFunctionVariable(stmt->variable());
}
-uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) {
+uint32_t Builder::GenerateTypeIfNeeded(sem::Type* type) {
if (type == nullptr) {
error_ = "attempting to generate type from null type";
return 0;
}
// The alias is a wrapper around the subtype, so emit the subtype
- if (auto* alias = type->As<type::Alias>()) {
+ if (auto* alias = type->As<sem::Alias>()) {
return GenerateTypeIfNeeded(alias->type());
}
- if (auto* ac = type->As<type::AccessControl>()) {
- if (!ac->type()->UnwrapIfNeeded()->Is<type::StructType>()) {
+ if (auto* ac = type->As<sem::AccessControl>()) {
+ if (!ac->type()->UnwrapIfNeeded()->Is<sem::StructType>()) {
return GenerateTypeIfNeeded(ac->type());
}
}
@@ -2947,48 +2947,48 @@
auto result = result_op();
auto id = result.to_i();
- if (auto* ac = type->As<type::AccessControl>()) {
+ if (auto* ac = type->As<sem::AccessControl>()) {
// The non-struct case was handled above.
auto* subtype = ac->type()->UnwrapIfNeeded();
- if (!GenerateStructType(subtype->As<type::StructType>(),
+ if (!GenerateStructType(subtype->As<sem::StructType>(),
ac->access_control(), result)) {
return 0;
}
- } else if (auto* arr = type->As<type::ArrayType>()) {
+ } else if (auto* arr = type->As<sem::ArrayType>()) {
if (!GenerateArrayType(arr, result)) {
return 0;
}
- } else if (type->Is<type::Bool>()) {
+ } else if (type->Is<sem::Bool>()) {
push_type(spv::Op::OpTypeBool, {result});
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)});
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(1)});
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
if (!GenerateMatrixType(mat, result)) {
return 0;
}
- } else if (auto* ptr = type->As<type::Pointer>()) {
+ } else if (auto* ptr = type->As<sem::Pointer>()) {
if (!GeneratePointerType(ptr, result)) {
return 0;
}
- } else if (auto* str = type->As<type::StructType>()) {
+ } else if (auto* str = type->As<sem::StructType>()) {
if (!GenerateStructType(str, ast::AccessControl::kReadWrite, result)) {
return 0;
}
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)});
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
if (!GenerateVectorType(vec, result)) {
return 0;
}
- } else if (type->Is<type::Void>()) {
+ } else if (type->Is<sem::Void>()) {
push_type(spv::Op::OpTypeVoid, {result});
- } else if (auto* tex = type->As<type::Texture>()) {
+ } else if (auto* tex = type->As<sem::Texture>()) {
if (!GenerateTextureType(tex, result)) {
return 0;
}
- } else if (type->Is<type::Sampler>()) {
+ } else if (type->Is<sem::Sampler>()) {
push_type(spv::Op::OpTypeSampler, {result});
// Register both of the sampler type names. In SPIR-V they're the same
@@ -3006,65 +3006,64 @@
}
// TODO(tommek): Cover multisampled textures here when they're included in AST
-bool Builder::GenerateTextureType(type::Texture* texture,
+bool Builder::GenerateTextureType(sem::Texture* texture,
const Operand& result) {
uint32_t array_literal = 0u;
const auto dim = texture->dim();
- if (dim == type::TextureDimension::k2dArray ||
- dim == type::TextureDimension::kCubeArray) {
+ if (dim == sem::TextureDimension::k2dArray ||
+ dim == sem::TextureDimension::kCubeArray) {
array_literal = 1u;
}
uint32_t dim_literal = SpvDim2D;
- if (dim == type::TextureDimension::k1d) {
+ if (dim == sem::TextureDimension::k1d) {
dim_literal = SpvDim1D;
- if (texture->Is<type::SampledTexture>()) {
+ if (texture->Is<sem::SampledTexture>()) {
push_capability(SpvCapabilitySampled1D);
- } else if (texture->Is<type::StorageTexture>()) {
+ } else if (texture->Is<sem::StorageTexture>()) {
push_capability(SpvCapabilityImage1D);
}
}
- if (dim == type::TextureDimension::k3d) {
+ if (dim == sem::TextureDimension::k3d) {
dim_literal = SpvDim3D;
}
- if (dim == type::TextureDimension::kCube ||
- dim == type::TextureDimension::kCubeArray) {
+ if (dim == sem::TextureDimension::kCube ||
+ dim == sem::TextureDimension::kCubeArray) {
dim_literal = SpvDimCube;
}
uint32_t ms_literal = 0u;
- if (texture->Is<type::MultisampledTexture>()) {
+ if (texture->Is<sem::MultisampledTexture>()) {
ms_literal = 1u;
}
uint32_t depth_literal = 0u;
- if (texture->Is<type::DepthTexture>()) {
+ if (texture->Is<sem::DepthTexture>()) {
depth_literal = 1u;
}
uint32_t sampled_literal = 2u;
- if (texture->Is<type::MultisampledTexture>() ||
- texture->Is<type::SampledTexture>() ||
- texture->Is<type::DepthTexture>()) {
+ if (texture->Is<sem::MultisampledTexture>() ||
+ texture->Is<sem::SampledTexture>() || texture->Is<sem::DepthTexture>()) {
sampled_literal = 1u;
}
- if (dim == type::TextureDimension::kCubeArray) {
- if (texture->Is<type::SampledTexture>() ||
- texture->Is<type::DepthTexture>()) {
+ if (dim == sem::TextureDimension::kCubeArray) {
+ if (texture->Is<sem::SampledTexture>() ||
+ texture->Is<sem::DepthTexture>()) {
push_capability(SpvCapabilitySampledCubeArray);
}
}
uint32_t type_id = 0u;
- if (texture->Is<type::DepthTexture>()) {
- type::F32 f32;
+ if (texture->Is<sem::DepthTexture>()) {
+ sem::F32 f32;
type_id = GenerateTypeIfNeeded(&f32);
- } else if (auto* s = texture->As<type::SampledTexture>()) {
+ } else if (auto* s = texture->As<sem::SampledTexture>()) {
type_id = GenerateTypeIfNeeded(s->type());
- } else if (auto* ms = texture->As<type::MultisampledTexture>()) {
+ } else if (auto* ms = texture->As<sem::MultisampledTexture>()) {
type_id = GenerateTypeIfNeeded(ms->type());
- } else if (auto* st = texture->As<type::StorageTexture>()) {
+ } else if (auto* st = texture->As<sem::StorageTexture>()) {
type_id = GenerateTypeIfNeeded(st->type());
}
if (type_id == 0u) {
@@ -3072,7 +3071,7 @@
}
uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown;
- if (auto* t = texture->As<type::StorageTexture>()) {
+ if (auto* t = texture->As<sem::StorageTexture>()) {
format_literal = convert_image_format_to_spv(t->image_format());
}
@@ -3085,7 +3084,7 @@
return true;
}
-bool Builder::GenerateArrayType(type::ArrayType* ary, const Operand& result) {
+bool Builder::GenerateArrayType(sem::ArrayType* ary, const Operand& result) {
auto elem_type = GenerateTypeIfNeeded(ary->type());
if (elem_type == 0) {
return false;
@@ -3115,8 +3114,8 @@
return true;
}
-bool Builder::GenerateMatrixType(type::Matrix* mat, const Operand& result) {
- type::Vector col_type(mat->type(), mat->rows());
+bool Builder::GenerateMatrixType(sem::Matrix* mat, const Operand& result) {
+ sem::Vector col_type(mat->type(), mat->rows());
auto col_type_id = GenerateTypeIfNeeded(&col_type);
if (has_error()) {
return false;
@@ -3127,7 +3126,7 @@
return true;
}
-bool Builder::GeneratePointerType(type::Pointer* ptr, const Operand& result) {
+bool Builder::GeneratePointerType(sem::Pointer* ptr, const Operand& result) {
auto pointee_id = GenerateTypeIfNeeded(ptr->type());
if (pointee_id == 0) {
return false;
@@ -3145,7 +3144,7 @@
return true;
}
-bool Builder::GenerateStructType(type::StructType* struct_type,
+bool Builder::GenerateStructType(sem::StructType* struct_type,
ast::AccessControl access_control,
const Operand& result) {
auto struct_id = result.to_i();
@@ -3223,7 +3222,7 @@
push_annot(spv::Op::OpMemberDecorate,
{Operand::Int(struct_id), Operand::Int(idx),
Operand::Int(SpvDecorationColMajor)});
- if (!matrix_type->type()->Is<type::F32>()) {
+ if (!matrix_type->type()->Is<sem::F32>()) {
error_ = "matrix scalar element type must be f32";
return 0;
}
@@ -3238,7 +3237,7 @@
return GenerateTypeIfNeeded(member->type());
}
-bool Builder::GenerateVectorType(type::Vector* vec, const Operand& result) {
+bool Builder::GenerateVectorType(sem::Vector* vec, const Operand& result) {
auto type_id = GenerateTypeIfNeeded(vec->type());
if (has_error()) {
return false;
@@ -3323,98 +3322,98 @@
}
SpvImageFormat Builder::convert_image_format_to_spv(
- const type::ImageFormat format) {
+ const sem::ImageFormat format) {
switch (format) {
- case type::ImageFormat::kR8Unorm:
+ case sem::ImageFormat::kR8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8;
- case type::ImageFormat::kR8Snorm:
+ case sem::ImageFormat::kR8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8Snorm;
- case type::ImageFormat::kR8Uint:
+ case sem::ImageFormat::kR8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8ui;
- case type::ImageFormat::kR8Sint:
+ case sem::ImageFormat::kR8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8i;
- case type::ImageFormat::kR16Uint:
+ case sem::ImageFormat::kR16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16ui;
- case type::ImageFormat::kR16Sint:
+ case sem::ImageFormat::kR16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16i;
- case type::ImageFormat::kR16Float:
+ case sem::ImageFormat::kR16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16f;
- case type::ImageFormat::kRg8Unorm:
+ case sem::ImageFormat::kRg8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8;
- case type::ImageFormat::kRg8Snorm:
+ case sem::ImageFormat::kRg8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8Snorm;
- case type::ImageFormat::kRg8Uint:
+ case sem::ImageFormat::kRg8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8ui;
- case type::ImageFormat::kRg8Sint:
+ case sem::ImageFormat::kRg8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8i;
- case type::ImageFormat::kR32Uint:
+ case sem::ImageFormat::kR32Uint:
return SpvImageFormatR32ui;
- case type::ImageFormat::kR32Sint:
+ case sem::ImageFormat::kR32Sint:
return SpvImageFormatR32i;
- case type::ImageFormat::kR32Float:
+ case sem::ImageFormat::kR32Float:
return SpvImageFormatR32f;
- case type::ImageFormat::kRg16Uint:
+ case sem::ImageFormat::kRg16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16ui;
- case type::ImageFormat::kRg16Sint:
+ case sem::ImageFormat::kRg16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16i;
- case type::ImageFormat::kRg16Float:
+ case sem::ImageFormat::kRg16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16f;
- case type::ImageFormat::kRgba8Unorm:
+ case sem::ImageFormat::kRgba8Unorm:
return SpvImageFormatRgba8;
- case type::ImageFormat::kRgba8UnormSrgb:
+ case sem::ImageFormat::kRgba8UnormSrgb:
return SpvImageFormatUnknown;
- case type::ImageFormat::kRgba8Snorm:
+ case sem::ImageFormat::kRgba8Snorm:
return SpvImageFormatRgba8Snorm;
- case type::ImageFormat::kRgba8Uint:
+ case sem::ImageFormat::kRgba8Uint:
return SpvImageFormatRgba8ui;
- case type::ImageFormat::kRgba8Sint:
+ case sem::ImageFormat::kRgba8Sint:
return SpvImageFormatRgba8i;
- case type::ImageFormat::kBgra8Unorm:
+ case sem::ImageFormat::kBgra8Unorm:
return SpvImageFormatUnknown;
- case type::ImageFormat::kBgra8UnormSrgb:
+ case sem::ImageFormat::kBgra8UnormSrgb:
return SpvImageFormatUnknown;
- case type::ImageFormat::kRgb10A2Unorm:
+ case sem::ImageFormat::kRgb10A2Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRgb10A2;
- case type::ImageFormat::kRg11B10Float:
+ case sem::ImageFormat::kRg11B10Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR11fG11fB10f;
- case type::ImageFormat::kRg32Uint:
+ case sem::ImageFormat::kRg32Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32ui;
- case type::ImageFormat::kRg32Sint:
+ case sem::ImageFormat::kRg32Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32i;
- case type::ImageFormat::kRg32Float:
+ case sem::ImageFormat::kRg32Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32f;
- case type::ImageFormat::kRgba16Uint:
+ case sem::ImageFormat::kRgba16Uint:
return SpvImageFormatRgba16ui;
- case type::ImageFormat::kRgba16Sint:
+ case sem::ImageFormat::kRgba16Sint:
return SpvImageFormatRgba16i;
- case type::ImageFormat::kRgba16Float:
+ case sem::ImageFormat::kRgba16Float:
return SpvImageFormatRgba16f;
- case type::ImageFormat::kRgba32Uint:
+ case sem::ImageFormat::kRgba32Uint:
return SpvImageFormatRgba32ui;
- case type::ImageFormat::kRgba32Sint:
+ case sem::ImageFormat::kRgba32Sint:
return SpvImageFormatRgba32i;
- case type::ImageFormat::kRgba32Float:
+ case sem::ImageFormat::kRgba32Float:
return SpvImageFormatRgba32f;
- case type::ImageFormat::kNone:
+ case sem::ImageFormat::kNone:
return SpvImageFormatUnknown;
}
return SpvImageFormatUnknown;
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index f45918d..878ab25 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -65,7 +65,7 @@
uint32_t source_id;
/// The type of the current chain source. This type matches the deduced
/// result_type of the current source defined above.
- type::Type* source_type;
+ sem::Type* source_type;
/// A list of access chain indices to emit. Note, we _only_ have access
/// chain indices if the source is pointer.
std::vector<uint32_t> access_chain_indices;
@@ -263,7 +263,7 @@
/// @param type the type to generate for
/// @param struct_id the struct id
/// @param member_idx the member index
- void GenerateMemberAccessControlIfNeeded(type::Type* type,
+ void GenerateMemberAccessControlIfNeeded(sem::Type* type,
uint32_t struct_id,
uint32_t member_idx);
/// Generates a function variable
@@ -372,7 +372,7 @@
/// @param texture_operand the texture operand
/// @param sampler_operand the sampler operand
/// @returns the expression ID
- uint32_t GenerateSampledImage(type::Type* texture_type,
+ uint32_t GenerateSampledImage(sem::Type* texture_type,
Operand texture_operand,
Operand sampler_operand);
/// Generates a cast or object copy for the expression result,
@@ -381,7 +381,7 @@
/// @param to_type the type we're casting too
/// @param from_expr the expression to cast
/// @returns the expression ID on success or 0 otherwise
- uint32_t GenerateCastOrCopyOrPassthrough(type::Type* to_type,
+ uint32_t GenerateCastOrCopyOrPassthrough(sem::Type* to_type,
ast::Expression* from_expr);
/// Generates a loop statement
/// @param stmt the statement to generate
@@ -413,7 +413,7 @@
/// @param type the type to load
/// @param id the variable id to load
/// @returns the ID of the loaded value or `id` if type is not a pointer
- uint32_t GenerateLoadIfNeeded(type::Type* type, uint32_t id);
+ uint32_t GenerateLoadIfNeeded(sem::Type* type, uint32_t id);
/// Generates an OpStore. Emits an error and returns false if we're
/// currently outside a function.
/// @param to the ID to store too
@@ -423,33 +423,33 @@
/// Generates a type if not already created
/// @param type the type to create
/// @returns the ID to use for the given type. Returns 0 on unknown type.
- uint32_t GenerateTypeIfNeeded(type::Type* type);
+ uint32_t GenerateTypeIfNeeded(sem::Type* type);
/// Generates a texture type declaration
/// @param texture the texture to generate
/// @param result the result operand
/// @returns true if the texture was successfully generated
- bool GenerateTextureType(type::Texture* texture, const Operand& result);
+ bool GenerateTextureType(sem::Texture* texture, const Operand& result);
/// Generates an array type declaration
/// @param ary the array to generate
/// @param result the result operand
/// @returns true if the array was successfully generated
- bool GenerateArrayType(type::ArrayType* ary, const Operand& result);
+ bool GenerateArrayType(sem::ArrayType* ary, const Operand& result);
/// Generates a matrix type declaration
/// @param mat the matrix to generate
/// @param result the result operand
/// @returns true if the matrix was successfully generated
- bool GenerateMatrixType(type::Matrix* mat, const Operand& result);
+ bool GenerateMatrixType(sem::Matrix* mat, const Operand& result);
/// Generates a pointer type declaration
/// @param ptr the pointer type to generate
/// @param result the result operand
/// @returns true if the pointer was successfully generated
- bool GeneratePointerType(type::Pointer* ptr, const Operand& result);
+ bool GeneratePointerType(sem::Pointer* ptr, const Operand& result);
/// Generates a vector type declaration
/// @param struct_type the vector to generate
/// @param access_control the access controls to assign to the struct
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateStructType(type::StructType* struct_type,
+ bool GenerateStructType(sem::StructType* struct_type,
ast::AccessControl access_control,
const Operand& result);
/// Generates a struct member
@@ -468,12 +468,12 @@
/// @param vec the vector to generate
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateVectorType(type::Vector* vec, const Operand& result);
+ bool GenerateVectorType(sem::Vector* vec, const Operand& result);
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
/// @param format AST image format type
/// @returns SPIR-V image format type
- SpvImageFormat convert_image_format_to_spv(const type::ImageFormat format);
+ SpvImageFormat convert_image_format_to_spv(const sem::ImageFormat format);
/// Determines if the given type constructor is created from constant values
/// @param expr the expression to check
@@ -488,7 +488,7 @@
/// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression
- type::Type* TypeOf(ast::Expression* expr) const {
+ sem::Type* TypeOf(ast::Expression* expr) const {
return builder_.TypeOf(expr);
}
@@ -500,7 +500,7 @@
/// Generates a constant-null of the given type, if needed
/// @param type the type of the constant null to generate.
/// @returns the ID on success or 0 on failure
- uint32_t GenerateConstantNullIfNeeded(type::Type* type);
+ uint32_t GenerateConstantNullIfNeeded(sem::Type* type);
ProgramBuilder builder_;
std::string error_;
diff --git a/src/writer/spirv/builder_format_conversion_test.cc b/src/writer/spirv/builder_format_conversion_test.cc
index c5f3994..62fcd23 100644
--- a/src/writer/spirv/builder_format_conversion_test.cc
+++ b/src/writer/spirv/builder_format_conversion_test.cc
@@ -21,7 +21,7 @@
namespace {
struct TestData {
- type::ImageFormat ast_format;
+ sem::ImageFormat ast_format;
SpvImageFormat_ spv_format;
bool extended_format = false;
};
@@ -51,42 +51,42 @@
BuilderTest,
ImageFormatConversionTest,
testing::Values(
- TestData{type::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
- TestData{type::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
- TestData{type::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
- TestData{type::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
- TestData{type::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
- TestData{type::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
- TestData{type::ImageFormat::kR16Float, SpvImageFormatR16f, true},
- TestData{type::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
- TestData{type::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
- TestData{type::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
- TestData{type::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
- TestData{type::ImageFormat::kR32Uint, SpvImageFormatR32ui},
- TestData{type::ImageFormat::kR32Sint, SpvImageFormatR32i},
- TestData{type::ImageFormat::kR32Float, SpvImageFormatR32f},
- TestData{type::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
- TestData{type::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
- TestData{type::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
- TestData{type::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
- TestData{type::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
- TestData{type::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
- TestData{type::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
- TestData{type::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
- TestData{type::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
- TestData{type::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
- TestData{type::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
- TestData{type::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
+ TestData{sem::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
+ TestData{sem::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
+ TestData{sem::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
+ TestData{sem::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
+ TestData{sem::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
+ TestData{sem::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
+ TestData{sem::ImageFormat::kR16Float, SpvImageFormatR16f, true},
+ TestData{sem::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
+ TestData{sem::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
+ TestData{sem::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
+ TestData{sem::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
+ TestData{sem::ImageFormat::kR32Uint, SpvImageFormatR32ui},
+ TestData{sem::ImageFormat::kR32Sint, SpvImageFormatR32i},
+ TestData{sem::ImageFormat::kR32Float, SpvImageFormatR32f},
+ TestData{sem::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
+ TestData{sem::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
+ TestData{sem::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
+ TestData{sem::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
+ TestData{sem::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
+ TestData{sem::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
+ TestData{sem::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
+ TestData{sem::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
+ TestData{sem::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
+ TestData{sem::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
+ TestData{sem::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
+ TestData{sem::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
true},
- TestData{type::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
- TestData{type::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
- TestData{type::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
- TestData{type::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
- TestData{type::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
- TestData{type::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
- TestData{type::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
- TestData{type::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
- TestData{type::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
+ TestData{sem::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
+ TestData{sem::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
+ TestData{sem::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
+ TestData{sem::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
+ TestData{sem::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
+ TestData{sem::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
+ TestData{sem::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
+ TestData{sem::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
+ TestData{sem::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
} // namespace
} // namespace spirv
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index be78a58..2f951b4 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -206,7 +206,7 @@
auto* s = Structure("Data", {Member("d", ty.f32())},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("data", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 6b541ef..fad90dd 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -394,7 +394,7 @@
Member("b", ty.i32()),
},
{create<ast::StructBlockDecoration>()});
- auto* ac = create<type::AccessControl>(ast::AccessControl::kReadOnly, A);
+ auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, A);
auto* var = Global("b", ac, ast::StorageClass::kStorage);
@@ -430,7 +430,7 @@
auto* A = Structure("A", {Member("a", ty.i32())},
{create<ast::StructBlockDecoration>()});
auto* B = ty.alias("B", A);
- auto* ac = create<type::AccessControl>(ast::AccessControl::kReadOnly, B);
+ auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, B);
auto* var = Global("b", ac, ast::StorageClass::kStorage);
spirv::Builder& b = Build();
@@ -461,7 +461,7 @@
auto* A = Structure("A", {Member("a", ty.i32())},
{create<ast::StructBlockDecoration>()});
- auto* ac = create<type::AccessControl>(ast::AccessControl::kReadOnly, A);
+ auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, A);
auto* B = ty.alias("B", ac);
auto* var = Global("b", B, ast::StorageClass::kStorage);
@@ -493,8 +493,8 @@
auto* A = Structure("A", {Member("a", ty.i32())},
{create<ast::StructBlockDecoration>()});
- type::AccessControl read{ast::AccessControl::kReadOnly, A};
- type::AccessControl rw{ast::AccessControl::kReadWrite, A};
+ sem::AccessControl read{ast::AccessControl::kReadOnly, A};
+ sem::AccessControl rw{ast::AccessControl::kReadWrite, A};
auto* var_b = Global("b", &read, ast::StorageClass::kStorage);
auto* var_c = Global("c", &rw, ast::StorageClass::kStorage);
@@ -532,11 +532,11 @@
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
- auto* type = create<type::StorageTexture>(
- type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
+ auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Uint, subtype);
- auto* ac = create<type::AccessControl>(ast::AccessControl::kReadOnly, type);
+ auto* ac = create<sem::AccessControl>(ast::AccessControl::kReadOnly, type);
auto* var_a = Global("a", ac, ast::StorageClass::kUniformConstant);
@@ -557,12 +557,12 @@
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
- auto* type = create<type::StorageTexture>(
- type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
+ auto* type = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Uint, subtype);
Global("test_var", type, ast::StorageClass::kInput);
- auto* ac = create<type::AccessControl>(ast::AccessControl::kWriteOnly, type);
+ auto* ac = create<sem::AccessControl>(ast::AccessControl::kWriteOnly, type);
auto* var_a = Global("a", ac, ast::StorageClass::kUniformConstant);
@@ -586,17 +586,16 @@
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
- auto* st = create<type::StorageTexture>(type::TextureDimension::k2d,
- type::ImageFormat::kR32Uint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
+ auto* st = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Uint, subtype);
Global("test_var", st, ast::StorageClass::kInput);
- auto* type_a = create<type::AccessControl>(ast::AccessControl::kReadOnly, st);
+ auto* type_a = create<sem::AccessControl>(ast::AccessControl::kReadOnly, st);
auto* var_a = Global("a", type_a, ast::StorageClass::kUniformConstant);
- auto* type_b =
- create<type::AccessControl>(ast::AccessControl::kWriteOnly, st);
+ auto* type_b = create<sem::AccessControl>(ast::AccessControl::kWriteOnly, st);
auto* var_b = Global("b", type_b, ast::StorageClass::kUniformConstant);
spirv::Builder& b = Build();
diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc
index feb2c17..3a0457d 100644
--- a/src/writer/spirv/builder_intrinsic_test.cc
+++ b/src/writer/spirv/builder_intrinsic_test.cc
@@ -370,8 +370,8 @@
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
- type::Sampler s(type::SamplerKind::kComparisonSampler);
- type::DepthTexture t(type::TextureDimension::k2d);
+ sem::Sampler s(sem::SamplerKind::kComparisonSampler);
+ sem::DepthTexture t(sem::TextureDimension::k2d);
auto* tex = Global("texture", &t, ast::StorageClass::kInput);
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index 964d227..812cbb5 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -262,7 +262,7 @@
}
TEST_F(BuilderTest_Type, GeneratePtr) {
- type::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
+ sem::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
spirv::Builder& b = Build();
@@ -276,7 +276,7 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
- type::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
+ sem::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
spirv::Builder& b = Build();
@@ -617,7 +617,7 @@
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
- type::DepthTexture two_d(type::TextureDimension::k2d);
+ sem::DepthTexture two_d(sem::TextureDimension::k2d);
spirv::Builder& b = Build();
@@ -631,7 +631,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
- type::DepthTexture two_d_array(type::TextureDimension::k2dArray);
+ sem::DepthTexture two_d_array(sem::TextureDimension::k2dArray);
spirv::Builder& b = Build();
@@ -645,7 +645,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
- type::DepthTexture cube(type::TextureDimension::kCube);
+ sem::DepthTexture cube(sem::TextureDimension::kCube);
spirv::Builder& b = Build();
@@ -660,7 +660,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
- type::DepthTexture cube_array(type::TextureDimension::kCubeArray);
+ sem::DepthTexture cube_array(sem::TextureDimension::kCubeArray);
spirv::Builder& b = Build();
@@ -677,7 +677,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
- type::MultisampledTexture ms(type::TextureDimension::k2d, ty.i32());
+ sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.i32());
spirv::Builder& b = Build();
@@ -689,7 +689,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
- type::MultisampledTexture ms(type::TextureDimension::k2d, ty.u32());
+ sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.u32());
spirv::Builder& b = Build();
@@ -702,7 +702,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
- type::MultisampledTexture ms(type::TextureDimension::k2d, ty.f32());
+ sem::MultisampledTexture ms(sem::TextureDimension::k2d, ty.f32());
spirv::Builder& b = Build();
@@ -715,7 +715,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, ty.i32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.i32());
spirv::Builder& b = Build();
@@ -732,7 +732,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, ty.u32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.u32());
spirv::Builder& b = Build();
@@ -749,7 +749,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, ty.f32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
spirv::Builder& b = Build();
@@ -766,7 +766,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::k2d, ty.f32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::k2d, ty.f32());
spirv::Builder& b = Build();
@@ -780,7 +780,7 @@
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
auto* s =
- create<type::SampledTexture>(type::TextureDimension::k2dArray, ty.f32());
+ create<sem::SampledTexture>(sem::TextureDimension::k2dArray, ty.f32());
spirv::Builder& b = Build();
@@ -793,7 +793,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::k3d, ty.f32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::k3d, ty.f32());
spirv::Builder& b = Build();
@@ -806,8 +806,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
- auto* s =
- create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32());
+ auto* s = create<sem::SampledTexture>(sem::TextureDimension::kCube, ty.f32());
spirv::Builder& b = Build();
@@ -821,8 +820,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
- auto* s = create<type::SampledTexture>(type::TextureDimension::kCubeArray,
- ty.f32());
+ auto* s =
+ create<sem::SampledTexture>(sem::TextureDimension::kCubeArray, ty.f32());
spirv::Builder& b = Build();
@@ -839,9 +838,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R16Float) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
- type::ImageFormat::kR16Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
+ sem::ImageFormat::kR16Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -861,9 +860,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8SNorm) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Snorm, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
- type::ImageFormat::kR8Snorm, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Snorm, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
+ sem::ImageFormat::kR8Snorm, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -883,9 +882,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8UNorm) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Unorm, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
- type::ImageFormat::kR8Unorm, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Unorm, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
+ sem::ImageFormat::kR8Unorm, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -905,9 +904,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Uint, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
- type::ImageFormat::kR8Uint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Uint, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
+ sem::ImageFormat::kR8Uint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -922,9 +921,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Sint, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
- type::ImageFormat::kR8Sint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Sint, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k1d,
+ sem::ImageFormat::kR8Sint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -939,9 +938,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
- type::ImageFormat::kR16Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR16Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -956,9 +955,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k2dArray,
- type::ImageFormat::kR16Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2dArray,
+ sem::ImageFormat::kR16Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -973,9 +972,9 @@
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k3d,
- type::ImageFormat::kR16Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k3d,
+ sem::ImageFormat::kR16Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -991,9 +990,9 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Float, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
- type::ImageFormat::kR32Float, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Float, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -1009,9 +1008,9 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Sint, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
- type::ImageFormat::kR32Sint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Sint, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Sint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -1027,9 +1026,9 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
auto* subtype =
- type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types());
- auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
- type::ImageFormat::kR32Uint, subtype);
+ sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types());
+ auto* s = create<sem::StorageTexture>(sem::TextureDimension::k2d,
+ sem::ImageFormat::kR32Uint, subtype);
Global("test_var", s, ast::StorageClass::kInput);
@@ -1043,7 +1042,7 @@
}
TEST_F(BuilderTest_Type, Sampler) {
- type::Sampler sampler(type::SamplerKind::kSampler);
+ sem::Sampler sampler(sem::SamplerKind::kSampler);
spirv::Builder& b = Build();
@@ -1053,7 +1052,7 @@
}
TEST_F(BuilderTest_Type, ComparisonSampler) {
- type::Sampler sampler(type::SamplerKind::kComparisonSampler);
+ sem::Sampler sampler(sem::SamplerKind::kComparisonSampler);
spirv::Builder& b = Build();
@@ -1063,8 +1062,8 @@
}
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
- type::Sampler comp_sampler(type::SamplerKind::kComparisonSampler);
- type::Sampler sampler(type::SamplerKind::kSampler);
+ sem::Sampler comp_sampler(sem::SamplerKind::kComparisonSampler);
+ sem::Sampler sampler(sem::SamplerKind::kSampler);
spirv::Builder& b = Build();
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index 3aeafe4..212a8aa 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -64,7 +64,7 @@
bool GeneratorImpl::Generate(const ast::Function* entry) {
// Generate global declarations in the order they appear in the module.
for (auto* decl : program_->AST().GlobalDeclarations()) {
- if (auto* ty = decl->As<type::Type>()) {
+ if (auto* ty = decl->As<sem::Type>()) {
if (!EmitConstructedType(ty)) {
return false;
}
@@ -115,15 +115,15 @@
return Generate(func);
}
-bool GeneratorImpl::EmitConstructedType(const type::Type* ty) {
+bool GeneratorImpl::EmitConstructedType(const sem::Type* ty) {
make_indent();
- if (auto* alias = ty->As<type::Alias>()) {
+ if (auto* alias = ty->As<sem::Alias>()) {
out_ << "type " << program_->Symbols().NameFor(alias->symbol()) << " = ";
if (!EmitType(alias->type())) {
return false;
}
out_ << ";" << std::endl;
- } else if (auto* str = ty->As<type::StructType>()) {
+ } else if (auto* str = ty->As<sem::StructType>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -332,7 +332,7 @@
out_ << ")";
- if (!func->return_type()->Is<type::Void>() ||
+ if (!func->return_type()->Is<sem::Void>() ||
!func->return_type_decorations().empty()) {
out_ << " -> ";
@@ -358,9 +358,9 @@
return true;
}
-bool GeneratorImpl::EmitImageFormat(const type::ImageFormat fmt) {
+bool GeneratorImpl::EmitImageFormat(const sem::ImageFormat fmt) {
switch (fmt) {
- case type::ImageFormat::kNone:
+ case sem::ImageFormat::kNone:
diagnostics_.add_error("unknown image format");
return false;
default:
@@ -369,9 +369,9 @@
return true;
}
-bool GeneratorImpl::EmitType(type::Type* type) {
+bool GeneratorImpl::EmitType(sem::Type* type) {
std::string storage_texture_access = "";
- if (auto* ac = type->As<type::AccessControl>()) {
+ if (auto* ac = type->As<sem::AccessControl>()) {
out_ << "[[access(";
if (ac->IsReadOnly()) {
out_ << "read";
@@ -388,9 +388,9 @@
return false;
}
return true;
- } else if (auto* alias = type->As<type::Alias>()) {
+ } else if (auto* alias = type->As<sem::Alias>()) {
out_ << program_->Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::ArrayType>()) {
+ } else if (auto* ary = type->As<sem::ArrayType>()) {
for (auto* deco : ary->decorations()) {
if (auto* stride = deco->As<ast::StrideDecoration>()) {
out_ << "[[stride(" << stride->stride() << ")]] ";
@@ -406,43 +406,43 @@
out_ << ", " << ary->size();
out_ << ">";
- } else if (type->Is<type::Bool>()) {
+ } else if (type->Is<sem::Bool>()) {
out_ << "bool";
- } else if (type->Is<type::F32>()) {
+ } else if (type->Is<sem::F32>()) {
out_ << "f32";
- } else if (type->Is<type::I32>()) {
+ } else if (type->Is<sem::I32>()) {
out_ << "i32";
- } else if (auto* mat = type->As<type::Matrix>()) {
+ } else if (auto* mat = type->As<sem::Matrix>()) {
out_ << "mat" << mat->columns() << "x" << mat->rows() << "<";
if (!EmitType(mat->type())) {
return false;
}
out_ << ">";
- } else if (auto* ptr = type->As<type::Pointer>()) {
+ } else if (auto* ptr = type->As<sem::Pointer>()) {
out_ << "ptr<" << ptr->storage_class() << ", ";
if (!EmitType(ptr->type())) {
return false;
}
out_ << ">";
- } else if (auto* sampler = type->As<type::Sampler>()) {
+ } else if (auto* sampler = type->As<sem::Sampler>()) {
out_ << "sampler";
if (sampler->IsComparison()) {
out_ << "_comparison";
}
- } else if (auto* str = type->As<type::StructType>()) {
+ } else if (auto* str = type->As<sem::StructType>()) {
// The struct, as a type, is just the name. We should have already emitted
// the declaration through a call to |EmitStructType| earlier.
out_ << program_->Symbols().NameFor(str->symbol());
- } else if (auto* texture = type->As<type::Texture>()) {
+ } else if (auto* texture = type->As<sem::Texture>()) {
out_ << "texture_";
- if (texture->Is<type::DepthTexture>()) {
+ if (texture->Is<sem::DepthTexture>()) {
out_ << "depth_";
- } else if (texture->Is<type::SampledTexture>()) {
+ } else if (texture->Is<sem::SampledTexture>()) {
/* nothing to emit */
- } else if (texture->Is<type::MultisampledTexture>()) {
+ } else if (texture->Is<sem::MultisampledTexture>()) {
out_ << "multisampled_";
- } else if (texture->Is<type::StorageTexture>()) {
+ } else if (texture->Is<sem::StorageTexture>()) {
out_ << "storage_";
} else {
diagnostics_.add_error("unknown texture type");
@@ -450,22 +450,22 @@
}
switch (texture->dim()) {
- case type::TextureDimension::k1d:
+ case sem::TextureDimension::k1d:
out_ << "1d";
break;
- case type::TextureDimension::k2d:
+ case sem::TextureDimension::k2d:
out_ << "2d";
break;
- case type::TextureDimension::k2dArray:
+ case sem::TextureDimension::k2dArray:
out_ << "2d_array";
break;
- case type::TextureDimension::k3d:
+ case sem::TextureDimension::k3d:
out_ << "3d";
break;
- case type::TextureDimension::kCube:
+ case sem::TextureDimension::kCube:
out_ << "cube";
break;
- case type::TextureDimension::kCubeArray:
+ case sem::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:
@@ -473,19 +473,19 @@
return false;
}
- if (auto* sampled = texture->As<type::SampledTexture>()) {
+ if (auto* sampled = texture->As<sem::SampledTexture>()) {
out_ << "<";
if (!EmitType(sampled->type())) {
return false;
}
out_ << ">";
- } else if (auto* ms = texture->As<type::MultisampledTexture>()) {
+ } else if (auto* ms = texture->As<sem::MultisampledTexture>()) {
out_ << "<";
if (!EmitType(ms->type())) {
return false;
}
out_ << ">";
- } else if (auto* storage = texture->As<type::StorageTexture>()) {
+ } else if (auto* storage = texture->As<sem::StorageTexture>()) {
out_ << "<";
if (!EmitImageFormat(storage->image_format())) {
return false;
@@ -493,15 +493,15 @@
out_ << ">";
}
- } else if (type->Is<type::U32>()) {
+ } else if (type->Is<sem::U32>()) {
out_ << "u32";
- } else if (auto* vec = type->As<type::Vector>()) {
+ } else if (auto* vec = type->As<sem::Vector>()) {
out_ << "vec" << vec->size() << "<";
if (!EmitType(vec->type())) {
return false;
}
out_ << ">";
- } else if (type->Is<type::Void>()) {
+ } else if (type->Is<sem::Void>()) {
out_ << "void";
} else {
diagnostics_.add_error("unknown type in EmitType: " + type->type_name());
@@ -511,7 +511,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const type::StructType* str) {
+bool GeneratorImpl::EmitStructType(const sem::StructType* str) {
auto* impl = str->impl();
for (auto* deco : impl->decorations()) {
out_ << "[[";
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index 984bba3..0c0bb51 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -64,7 +64,7 @@
/// Handles generating a constructed type
/// @param ty the constructed to generate
/// @returns true if the constructed was emitted
- bool EmitConstructedType(const type::Type* ty);
+ bool EmitConstructedType(const sem::Type* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
@@ -172,15 +172,15 @@
/// Handles generating type
/// @param type the type to generate
/// @returns true if the type is emitted
- bool EmitType(type::Type* type);
+ bool EmitType(sem::Type* type);
/// Handles generating a struct declaration
/// @param str the struct
/// @returns true if the struct is emitted
- bool EmitStructType(const type::StructType* str);
+ bool EmitStructType(const sem::StructType* str);
/// Handles emitting an image format
/// @param fmt the format to generate
/// @returns true if the format is emitted
- bool EmitImageFormat(const type::ImageFormat fmt);
+ bool EmitImageFormat(const sem::ImageFormat fmt);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc
index 4f06993..b5dfe45 100644
--- a/src/writer/wgsl/generator_impl_function_test.cc
+++ b/src/writer/wgsl/generator_impl_function_test.cc
@@ -210,7 +210,7 @@
auto* s = Structure("Data", {Member("d", ty.f32())},
{create<ast::StructBlockDecoration>()});
- type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ sem::AccessControl ac(ast::AccessControl::kReadWrite, s);
Global("data", &ac, ast::StorageClass::kStorage, nullptr,
ast::DecorationList{
diff --git a/src/writer/wgsl/generator_impl_global_decl_test.cc b/src/writer/wgsl/generator_impl_global_decl_test.cc
index 92250da..a2a0ab9 100644
--- a/src/writer/wgsl/generator_impl_global_decl_test.cc
+++ b/src/writer/wgsl/generator_impl_global_decl_test.cc
@@ -101,7 +101,7 @@
}
TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
- Global("s", create<type::Sampler>(type::SamplerKind::kSampler),
+ Global("s", create<sem::Sampler>(sem::SamplerKind::kSampler),
ast::StorageClass::kUniformConstant);
GeneratorImpl& gen = Build();
@@ -113,8 +113,7 @@
}
TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
- auto* st =
- create<type::SampledTexture>(type::TextureDimension::k1d, ty.f32());
+ auto* st = create<sem::SampledTexture>(sem::TextureDimension::k1d, ty.f32());
Global("t", ty.access(ast::AccessControl::kReadOnly, st),
ast::StorageClass::kUniformConstant);
diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc
index 87f9df1..71721aa 100644
--- a/src/writer/wgsl/generator_impl_type_test.cc
+++ b/src/writer/wgsl/generator_impl_type_test.cc
@@ -73,10 +73,10 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
- auto* a = create<type::ArrayType>(ty.bool_(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(16u),
- });
+ auto* a = create<sem::ArrayType>(ty.bool_(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(16u),
+ });
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();
@@ -86,11 +86,11 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
- auto* a = create<type::ArrayType>(ty.bool_(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(16u),
- create<ast::StrideDecoration>(32u),
- });
+ auto* a = create<sem::ArrayType>(ty.bool_(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(16u),
+ create<ast::StrideDecoration>(32u),
+ });
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();
@@ -100,7 +100,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
- auto* a = create<type::ArrayType>(ty.bool_(), 0, ast::DecorationList{});
+ auto* a = create<sem::ArrayType>(ty.bool_(), 0, ast::DecorationList{});
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();
@@ -150,7 +150,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
- auto* p = create<type::Pointer>(ty.f32(), ast::StorageClass::kWorkgroup);
+ auto* p = create<sem::Pointer>(ty.f32(), ast::StorageClass::kWorkgroup);
AST().AddConstructedType(ty.alias("make_type_reachable", p));
GeneratorImpl& gen = Build();
@@ -314,7 +314,7 @@
}
struct TextureData {
- type::TextureDimension dim;
+ sem::TextureDimension dim;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
@@ -326,7 +326,7 @@
TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
auto param = GetParam();
- auto* d = create<type::DepthTexture>(param.dim);
+ auto* d = create<sem::DepthTexture>(param.dim);
AST().AddConstructedType(ty.alias("make_type_reachable", d));
GeneratorImpl& gen = Build();
@@ -338,17 +338,17 @@
WgslGeneratorImplTest,
WgslGenerator_DepthTextureTest,
testing::Values(
- TextureData{type::TextureDimension::k2d, "texture_depth_2d"},
- TextureData{type::TextureDimension::k2dArray, "texture_depth_2d_array"},
- TextureData{type::TextureDimension::kCube, "texture_depth_cube"},
- TextureData{type::TextureDimension::kCubeArray,
+ TextureData{sem::TextureDimension::k2d, "texture_depth_2d"},
+ TextureData{sem::TextureDimension::k2dArray, "texture_depth_2d_array"},
+ TextureData{sem::TextureDimension::kCube, "texture_depth_cube"},
+ TextureData{sem::TextureDimension::kCubeArray,
"texture_depth_cube_array"}));
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
auto param = GetParam();
- auto* t = create<type::SampledTexture>(param.dim, ty.f32());
+ auto* t = create<sem::SampledTexture>(param.dim, ty.f32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -360,7 +360,7 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
auto param = GetParam();
- auto* t = create<type::SampledTexture>(param.dim, ty.i32());
+ auto* t = create<sem::SampledTexture>(param.dim, ty.i32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -372,7 +372,7 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
auto param = GetParam();
- auto* t = create<type::SampledTexture>(param.dim, ty.u32());
+ auto* t = create<sem::SampledTexture>(param.dim, ty.u32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -384,18 +384,18 @@
WgslGeneratorImplTest,
WgslGenerator_SampledTextureTest,
testing::Values(
- TextureData{type::TextureDimension::k1d, "texture_1d"},
- TextureData{type::TextureDimension::k2d, "texture_2d"},
- TextureData{type::TextureDimension::k2dArray, "texture_2d_array"},
- TextureData{type::TextureDimension::k3d, "texture_3d"},
- TextureData{type::TextureDimension::kCube, "texture_cube"},
- TextureData{type::TextureDimension::kCubeArray, "texture_cube_array"}));
+ TextureData{sem::TextureDimension::k1d, "texture_1d"},
+ TextureData{sem::TextureDimension::k2d, "texture_2d"},
+ TextureData{sem::TextureDimension::k2dArray, "texture_2d_array"},
+ TextureData{sem::TextureDimension::k3d, "texture_3d"},
+ TextureData{sem::TextureDimension::kCube, "texture_cube"},
+ TextureData{sem::TextureDimension::kCubeArray, "texture_cube_array"}));
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
auto param = GetParam();
- auto* t = create<type::MultisampledTexture>(param.dim, ty.f32());
+ auto* t = create<sem::MultisampledTexture>(param.dim, ty.f32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -407,7 +407,7 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
auto param = GetParam();
- auto* t = create<type::MultisampledTexture>(param.dim, ty.i32());
+ auto* t = create<sem::MultisampledTexture>(param.dim, ty.i32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -419,7 +419,7 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
auto param = GetParam();
- auto* t = create<type::MultisampledTexture>(param.dim, ty.u32());
+ auto* t = create<sem::MultisampledTexture>(param.dim, ty.u32());
AST().AddConstructedType(ty.alias("make_type_reachable", t));
GeneratorImpl& gen = Build();
@@ -430,12 +430,12 @@
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
WgslGenerator_MultiampledTextureTest,
testing::Values(TextureData{
- type::TextureDimension::k2d,
+ sem::TextureDimension::k2d,
"texture_multisampled_2d"}));
struct StorageTextureData {
- type::ImageFormat fmt;
- type::TextureDimension dim;
+ sem::ImageFormat fmt;
+ sem::TextureDimension dim;
ast::AccessControl access;
const char* name;
};
@@ -447,8 +447,8 @@
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
auto param = GetParam();
- auto* subtype = type::StorageTexture::SubtypeFor(param.fmt, Types());
- auto* t = create<type::StorageTexture>(param.dim, param.fmt, subtype);
+ auto* subtype = sem::StorageTexture::SubtypeFor(param.fmt, Types());
+ auto* t = create<sem::StorageTexture>(param.dim, param.fmt, subtype);
auto* ac = ty.access(param.access, t);
GeneratorImpl& gen = Build();
@@ -460,41 +460,41 @@
WgslGeneratorImplTest,
WgslGenerator_StorageTextureTest,
testing::Values(
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k1d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k1d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_1d<r8unorm>"},
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k2d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k2d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_2d<r8unorm>"},
StorageTextureData{
- type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray,
+ sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_2d_array<r8unorm>"},
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k3d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k3d,
ast::AccessControl::kReadOnly,
"[[access(read)]] texture_storage_3d<r8unorm>"},
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k1d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k1d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_1d<r8unorm>"},
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k2d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k2d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_2d<r8unorm>"},
StorageTextureData{
- type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray,
+ sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_2d_array<r8unorm>"},
- StorageTextureData{type::ImageFormat::kR8Unorm,
- type::TextureDimension::k3d,
+ StorageTextureData{sem::ImageFormat::kR8Unorm,
+ sem::TextureDimension::k3d,
ast::AccessControl::kWriteOnly,
"[[access(write)]] texture_storage_3d<r8unorm>"}));
struct ImageFormatData {
- type::ImageFormat fmt;
+ sem::ImageFormat fmt;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
@@ -515,44 +515,44 @@
WgslGeneratorImplTest,
WgslGenerator_ImageFormatTest,
testing::Values(
- ImageFormatData{type::ImageFormat::kR8Unorm, "r8unorm"},
- ImageFormatData{type::ImageFormat::kR8Snorm, "r8snorm"},
- ImageFormatData{type::ImageFormat::kR8Uint, "r8uint"},
- ImageFormatData{type::ImageFormat::kR8Sint, "r8sint"},
- ImageFormatData{type::ImageFormat::kR16Uint, "r16uint"},
- ImageFormatData{type::ImageFormat::kR16Sint, "r16sint"},
- ImageFormatData{type::ImageFormat::kR16Float, "r16float"},
- ImageFormatData{type::ImageFormat::kRg8Unorm, "rg8unorm"},
- ImageFormatData{type::ImageFormat::kRg8Snorm, "rg8snorm"},
- ImageFormatData{type::ImageFormat::kRg8Uint, "rg8uint"},
- ImageFormatData{type::ImageFormat::kRg8Sint, "rg8sint"},
- ImageFormatData{type::ImageFormat::kR32Uint, "r32uint"},
- ImageFormatData{type::ImageFormat::kR32Sint, "r32sint"},
- ImageFormatData{type::ImageFormat::kR32Float, "r32float"},
- ImageFormatData{type::ImageFormat::kRg16Uint, "rg16uint"},
- ImageFormatData{type::ImageFormat::kRg16Sint, "rg16sint"},
- ImageFormatData{type::ImageFormat::kRg16Float, "rg16float"},
- ImageFormatData{type::ImageFormat::kRgba8Unorm, "rgba8unorm"},
- ImageFormatData{type::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
- ImageFormatData{type::ImageFormat::kRgba8Snorm, "rgba8snorm"},
- ImageFormatData{type::ImageFormat::kRgba8Uint, "rgba8uint"},
- ImageFormatData{type::ImageFormat::kRgba8Sint, "rgba8sint"},
- ImageFormatData{type::ImageFormat::kBgra8Unorm, "bgra8unorm"},
- ImageFormatData{type::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
- ImageFormatData{type::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
- ImageFormatData{type::ImageFormat::kRg11B10Float, "rg11b10float"},
- ImageFormatData{type::ImageFormat::kRg32Uint, "rg32uint"},
- ImageFormatData{type::ImageFormat::kRg32Sint, "rg32sint"},
- ImageFormatData{type::ImageFormat::kRg32Float, "rg32float"},
- ImageFormatData{type::ImageFormat::kRgba16Uint, "rgba16uint"},
- ImageFormatData{type::ImageFormat::kRgba16Sint, "rgba16sint"},
- ImageFormatData{type::ImageFormat::kRgba16Float, "rgba16float"},
- ImageFormatData{type::ImageFormat::kRgba32Uint, "rgba32uint"},
- ImageFormatData{type::ImageFormat::kRgba32Sint, "rgba32sint"},
- ImageFormatData{type::ImageFormat::kRgba32Float, "rgba32float"}));
+ ImageFormatData{sem::ImageFormat::kR8Unorm, "r8unorm"},
+ ImageFormatData{sem::ImageFormat::kR8Snorm, "r8snorm"},
+ ImageFormatData{sem::ImageFormat::kR8Uint, "r8uint"},
+ ImageFormatData{sem::ImageFormat::kR8Sint, "r8sint"},
+ ImageFormatData{sem::ImageFormat::kR16Uint, "r16uint"},
+ ImageFormatData{sem::ImageFormat::kR16Sint, "r16sint"},
+ ImageFormatData{sem::ImageFormat::kR16Float, "r16float"},
+ ImageFormatData{sem::ImageFormat::kRg8Unorm, "rg8unorm"},
+ ImageFormatData{sem::ImageFormat::kRg8Snorm, "rg8snorm"},
+ ImageFormatData{sem::ImageFormat::kRg8Uint, "rg8uint"},
+ ImageFormatData{sem::ImageFormat::kRg8Sint, "rg8sint"},
+ ImageFormatData{sem::ImageFormat::kR32Uint, "r32uint"},
+ ImageFormatData{sem::ImageFormat::kR32Sint, "r32sint"},
+ ImageFormatData{sem::ImageFormat::kR32Float, "r32float"},
+ ImageFormatData{sem::ImageFormat::kRg16Uint, "rg16uint"},
+ ImageFormatData{sem::ImageFormat::kRg16Sint, "rg16sint"},
+ ImageFormatData{sem::ImageFormat::kRg16Float, "rg16float"},
+ ImageFormatData{sem::ImageFormat::kRgba8Unorm, "rgba8unorm"},
+ ImageFormatData{sem::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
+ ImageFormatData{sem::ImageFormat::kRgba8Snorm, "rgba8snorm"},
+ ImageFormatData{sem::ImageFormat::kRgba8Uint, "rgba8uint"},
+ ImageFormatData{sem::ImageFormat::kRgba8Sint, "rgba8sint"},
+ ImageFormatData{sem::ImageFormat::kBgra8Unorm, "bgra8unorm"},
+ ImageFormatData{sem::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
+ ImageFormatData{sem::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
+ ImageFormatData{sem::ImageFormat::kRg11B10Float, "rg11b10float"},
+ ImageFormatData{sem::ImageFormat::kRg32Uint, "rg32uint"},
+ ImageFormatData{sem::ImageFormat::kRg32Sint, "rg32sint"},
+ ImageFormatData{sem::ImageFormat::kRg32Float, "rg32float"},
+ ImageFormatData{sem::ImageFormat::kRgba16Uint, "rgba16uint"},
+ ImageFormatData{sem::ImageFormat::kRgba16Sint, "rgba16sint"},
+ ImageFormatData{sem::ImageFormat::kRgba16Float, "rgba16float"},
+ ImageFormatData{sem::ImageFormat::kRgba32Uint, "rgba32uint"},
+ ImageFormatData{sem::ImageFormat::kRgba32Sint, "rgba32sint"},
+ ImageFormatData{sem::ImageFormat::kRgba32Float, "rgba32float"}));
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
- auto* sampler = create<type::Sampler>(type::SamplerKind::kSampler);
+ auto* sampler = create<sem::Sampler>(sem::SamplerKind::kSampler);
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
GeneratorImpl& gen = Build();
@@ -562,7 +562,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
- auto* sampler = create<type::Sampler>(type::SamplerKind::kComparisonSampler);
+ auto* sampler = create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
GeneratorImpl& gen = Build();
diff --git a/src/writer/wgsl/generator_impl_unary_op_test.cc b/src/writer/wgsl/generator_impl_unary_op_test.cc
index 40df2bc..1bf93ff 100644
--- a/src/writer/wgsl/generator_impl_unary_op_test.cc
+++ b/src/writer/wgsl/generator_impl_unary_op_test.cc
@@ -32,8 +32,8 @@
auto params = GetParam();
auto* type = (params.op == ast::UnaryOp::kNot)
- ? static_cast<type::Type*>(ty.bool_())
- : static_cast<type::Type*>(ty.i32());
+ ? static_cast<sem::Type*>(ty.bool_())
+ : static_cast<sem::Type*>(ty.i32());
Global("expr", type, ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(params.op, Expr("expr"));