diff --git a/src/ast/bitcast_expression.cc b/src/ast/bitcast_expression.cc index 6b78366d1e..a39870bf27 100644 --- a/src/ast/bitcast_expression.cc +++ b/src/ast/bitcast_expression.cc @@ -23,7 +23,7 @@ namespace ast { 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 9c87ba578b..6b6cc2b9b0 100644 --- a/src/ast/bitcast_expression.h +++ b/src/ast/bitcast_expression.h @@ -30,14 +30,14 @@ class BitcastExpression : public Castable { /// @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 @@ class BitcastExpression : public Castable { 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 5e4cf866e9..b264c4a56f 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -23,7 +23,7 @@ namespace ast { 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 b95adc0302..4f2fce1837 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -32,7 +32,7 @@ class BoolLiteral : public Castable { /// @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 de3a358202..f7a8005794 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -21,7 +21,7 @@ namespace { using BoolLiteralTest = TestHelper; TEST_F(BoolLiteralTest, True) { - type::Bool bool_type; + sem::Bool bool_type; auto* b = create(&bool_type, true); ASSERT_TRUE(b->Is()); ASSERT_TRUE(b->IsTrue()); @@ -29,7 +29,7 @@ TEST_F(BoolLiteralTest, True) { } TEST_F(BoolLiteralTest, False) { - type::Bool bool_type; + sem::Bool bool_type; auto* b = create(&bool_type, false); ASSERT_TRUE(b->Is()); ASSERT_FALSE(b->IsTrue()); @@ -37,7 +37,7 @@ TEST_F(BoolLiteralTest, False) { } TEST_F(BoolLiteralTest, Is) { - type::Bool bool_type; + sem::Bool bool_type; ast::Literal* l = create(&bool_type, false); EXPECT_TRUE(l->Is()); EXPECT_FALSE(l->Is()); @@ -47,7 +47,7 @@ TEST_F(BoolLiteralTest, Is) { } TEST_F(BoolLiteralTest, ToStr) { - type::Bool bool_type; + sem::Bool bool_type; auto* t = create(&bool_type, true); auto* f = create(&bool_type, false); diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index 1c301b7163..b23742c4eb 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -25,7 +25,7 @@ namespace ast { 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 82e37ba247..9d030937d4 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -32,7 +32,7 @@ class FloatLiteral : public Castable { /// @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 df83626915..a14d3cbc3b 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -27,7 +27,7 @@ Function::Function(ProgramID program_id, 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 62f3bd7632..bb43b2f168 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -48,7 +48,7 @@ class Function : public Castable { 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 @@ class Function : public Castable { 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 @@ class Function : public Castable { 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 0b3db78272..b959e0ad8d 100644 --- a/src/ast/int_literal.cc +++ b/src/ast/int_literal.cc @@ -21,7 +21,7 @@ namespace ast { 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 2c2afeb008..5aca29e097 100644 --- a/src/ast/int_literal.h +++ b/src/ast/int_literal.h @@ -36,7 +36,7 @@ class IntLiteral : public Castable { /// @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 0d9632e82b..f9be5ba4f6 100644 --- a/src/ast/intrinsic_texture_helper_test.cc +++ b/src/ast/intrinsic_texture_helper_test.cc @@ -32,8 +32,8 @@ TextureOverloadCase::TextureOverloadCase( 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 a) @@ -49,7 +49,7 @@ TextureOverloadCase::TextureOverloadCase( ValidTextureOverload o, const char* desc, TextureKind tk, - type::TextureDimension dims, + sem::TextureDimension dims, TextureDataType datatype, const char* f, std::function a) @@ -64,8 +64,8 @@ TextureOverloadCase::TextureOverloadCase( 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 a) @@ -132,7 +132,7 @@ std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data) { 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 @@ ast::Variable* TextureOverloadCase::buildTextureVariable( case ast::intrinsic::test::TextureKind::kRegular: return b->Global( "texture", - b->create(texture_dimension, datatype), + b->create(texture_dimension, datatype), ast::StorageClass::kUniformConstant, nullptr, decos); case ast::intrinsic::test::TextureKind::kDepth: return b->Global("texture", - b->create(texture_dimension), + b->create(texture_dimension), ast::StorageClass::kUniformConstant, nullptr, decos); case ast::intrinsic::test::TextureKind::kMultisampled: return b->Global( "texture", - b->create(texture_dimension, datatype), + b->create(texture_dimension, datatype), ast::StorageClass::kUniformConstant, nullptr, decos); case ast::intrinsic::test::TextureKind::kStorage: { - auto* st = b->create(texture_dimension, - image_format, datatype); + auto* st = b->create(texture_dimension, image_format, + datatype); - auto* ac = b->create(access_control, st); + auto* ac = b->create(access_control, st); return b->Global("texture", ac, ast::StorageClass::kUniformConstant, nullptr, decos); } @@ -193,7 +193,7 @@ ast::Variable* TextureOverloadCase::buildSamplerVariable( b->create(0), b->create(1), }; - return b->Global("sampler", b->create(sampler_kind), + return b->Global("sampler", b->create(sampler_kind), ast::StorageClass::kUniformConstant, nullptr, decos); } @@ -203,8 +203,8 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensions1d, "textureDimensions(t : texture_1d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensions2d, "textureDimensions(t : texture_2d) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_2d,\n" " level : i32) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensions2dArray, "textureDimensions(t : texture_2d_array) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_2d_array,\n" " level : i32) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensions3d, "textureDimensions(t : texture_3d) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_3d,\n" " level : i32) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsCube, "textureDimensions(t : texture_cube) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_cube,\n" " level : i32) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsCubeArray, "textureDimensions(t : texture_cube_array) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_cube_array,\n" " level : i32) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsMultisampled2d, "textureDimensions(t : texture_multisampled_2d)-> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_multisampled_2d_array)-> " "vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsDepth2d, "textureDimensions(t : texture_depth_2d) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_depth_2d,\n" " level : i32) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsDepth2dArray, "textureDimensions(t : texture_depth_2d_array) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_depth_2d_array,\n" " level : i32) -> vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsDepthCube, "textureDimensions(t : texture_depth_cube) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_depth_cube,\n" " level : i32) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsDepthCubeArray, "textureDimensions(t : texture_depth_cube_array) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_depth_cube_array,\n" " level : i32) -> vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsStorageRO1d, "textureDimensions(t : texture_storage_1d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_2d) -> " "vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_2d_array) -> " "vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_3d) -> " "vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kDimensionsStorageWO1d, "textureDimensions(t : texture_storage_1d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_2d) -> " "vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_2d_array) -> " "vec2", 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 @@ std::vector TextureOverloadCase::ValidCases() { "textureDimensions(t : texture_storage_3d) -> " "vec3", 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLayers2dArray, "textureNumLayers(t : texture_2d_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLayersCubeArray, "textureNumLayers(t : texture_cube_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLayersMultisampled2dArray, "textureNumLayers(t : texture_multisampled_2d_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLayersStorageWO2dArray, "textureNumLayers(t : texture_storage_2d_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLevels2d, "textureNumLevels(t : texture_2d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLevels2dArray, "textureNumLevels(t : texture_2d_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLevels3d, "textureNumLevels(t : texture_3d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLevelsCube, "textureNumLevels(t : texture_cube) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumLevelsCubeArray, "textureNumLevels(t : texture_cube_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumSamplesMultisampled2d, "textureNumSamples(t : texture_multisampled_2d) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { ValidTextureOverload::kNumSamplesMultisampled2dArray, "textureNumSamples(t : texture_multisampled_2d_array) -> 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 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k1d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k1d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -697,8 +697,8 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -714,8 +714,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -732,8 +732,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " array_index : i32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -751,8 +751,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -769,8 +769,8 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -786,8 +786,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3\n" " offset : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -803,8 +803,8 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCube, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCube, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -820,8 +820,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " array_index : i32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCubeArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCubeArray, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -837,8 +837,8 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -854,8 +854,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -872,8 +872,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -909,8 +909,8 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::kCube, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCube, TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { @@ -926,8 +926,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " bias : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -963,8 +963,8 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -983,8 +983,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " bias : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1004,8 +1004,8 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1024,8 +1024,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " bias : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1043,8 +1043,8 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1062,8 +1062,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " bias : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCube, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCube, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1081,8 +1081,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " bias : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCubeArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCubeArray, TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { @@ -1100,8 +1100,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1119,8 +1119,8 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1139,8 +1139,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1160,8 +1160,8 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1180,8 +1180,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1199,8 +1199,8 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1218,8 +1218,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCube, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCube, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1237,8 +1237,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : f32) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCubeArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCubeArray, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1256,8 +1256,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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 @@ std::vector TextureOverloadCase::ValidCases() { " level : i32,\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1295,8 +1295,8 @@ std::vector TextureOverloadCase::ValidCases() { " 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 @@ std::vector TextureOverloadCase::ValidCases() { " level : i32,\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { @@ -1336,8 +1336,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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 @@ std::vector TextureOverloadCase::ValidCases() { " 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 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec2,\n" " ddy : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1396,8 +1396,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec2,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1418,8 +1418,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec2,\n" " ddy : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1441,8 +1441,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec2,\n" " offset : vec2) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1463,8 +1463,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1484,8 +1484,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec3,\n" " offset : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::k3d, + sem::SamplerKind::kSampler, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1505,8 +1505,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCube, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCube, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1526,8 +1526,8 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", TextureKind::kRegular, - type::SamplerKind::kSampler, - type::TextureDimension::kCubeArray, + sem::SamplerKind::kSampler, + sem::TextureDimension::kCubeArray, TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { @@ -1546,8 +1546,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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 @@ std::vector TextureOverloadCase::ValidCases() { " depth_ref : f32,\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kComparisonSampler, - type::TextureDimension::k2d, + sem::SamplerKind::kComparisonSampler, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { @@ -1585,8 +1585,8 @@ std::vector TextureOverloadCase::ValidCases() { " 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 @@ std::vector TextureOverloadCase::ValidCases() { " depth_ref : f32,\n" " offset : vec2) -> f32", TextureKind::kDepth, - type::SamplerKind::kComparisonSampler, - type::TextureDimension::k2dArray, + sem::SamplerKind::kComparisonSampler, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { @@ -1626,8 +1626,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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 @@ std::vector TextureOverloadCase::ValidCases() { " 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 @@ std::vector TextureOverloadCase::ValidCases() { " coords : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1678,7 +1678,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1693,7 +1693,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1708,7 +1708,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1723,7 +1723,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1738,7 +1738,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1754,7 +1754,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1771,7 +1771,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1788,7 +1788,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1804,7 +1804,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1819,7 +1819,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1834,7 +1834,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : i32) -> vec4", TextureKind::kRegular, - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1849,7 +1849,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1864,7 +1864,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1879,7 +1879,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1895,7 +1895,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1912,7 +1912,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -1929,7 +1929,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " sample_index : i32) -> vec4", TextureKind::kMultisampled, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -1945,7 +1945,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : i32) -> f32", TextureKind::kDepth, - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1961,7 +1961,7 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " level : i32) -> f32", TextureKind::kDepth, - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1976,8 +1976,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_1d,\n" " coords : i32) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k1d, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k1d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -1990,8 +1990,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba8Unorm, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba8Unorm, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2004,8 +2004,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba8Snorm, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba8Snorm, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2018,8 +2018,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba8Uint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba8Uint, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -2032,8 +2032,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba8Sint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba8Sint, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -2046,8 +2046,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba16Uint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba16Uint, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -2060,8 +2060,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba16Sint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba16Sint, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -2074,8 +2074,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba16Float, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba16Float, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2088,8 +2088,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kR32Uint, - type::TextureDimension::k2d, + sem::ImageFormat::kR32Uint, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -2102,8 +2102,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kR32Sint, - type::TextureDimension::k2d, + sem::ImageFormat::kR32Sint, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -2116,8 +2116,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kR32Float, - type::TextureDimension::k2d, + sem::ImageFormat::kR32Float, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2130,8 +2130,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRg32Uint, - type::TextureDimension::k2d, + sem::ImageFormat::kRg32Uint, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -2144,8 +2144,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRg32Sint, - type::TextureDimension::k2d, + sem::ImageFormat::kRg32Sint, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -2158,8 +2158,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRg32Float, - type::TextureDimension::k2d, + sem::ImageFormat::kRg32Float, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2172,8 +2172,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Uint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba32Uint, + sem::TextureDimension::k2d, TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { @@ -2186,8 +2186,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Sint, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba32Sint, + sem::TextureDimension::k2d, TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { @@ -2200,8 +2200,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_2d,\n" " coords : vec2) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2216,8 +2216,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " array_index : i32) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k2dArray, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2231,8 +2231,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureLoad(t : texture_storage_3d,\n" " coords : vec3) -> vec4", ast::AccessControl::kReadOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k3d, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k3d, TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { @@ -2246,8 +2246,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : i32,\n" " value : vec4)", ast::AccessControl::kWriteOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k1d, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k1d, TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { @@ -2262,8 +2262,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " value : vec4)", ast::AccessControl::kWriteOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k2d, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k2d, TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { @@ -2279,8 +2279,8 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : i32,\n" " value : vec4)", ast::AccessControl::kWriteOnly, - type::ImageFormat::kRgba32Float, - type::TextureDimension::k2dArray, + sem::ImageFormat::kRgba32Float, + sem::TextureDimension::k2dArray, TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { @@ -2296,8 +2296,8 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " value : vec4)", 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 521d2c9fab..4ff154e717 100644 --- a/src/ast/intrinsic_texture_helper_test.h +++ b/src/ast/intrinsic_texture_helper_test.h @@ -182,8 +182,8 @@ struct TextureOverloadCase { TextureOverloadCase(ValidTextureOverload, const char*, TextureKind, - type::SamplerKind, - type::TextureDimension, + sem::SamplerKind, + sem::TextureDimension, TextureDataType, const char*, std::function); @@ -191,7 +191,7 @@ struct TextureOverloadCase { TextureOverloadCase(ValidTextureOverload, const char*, TextureKind, - type::TextureDimension, + sem::TextureDimension, TextureDataType, const char*, std::function); @@ -199,8 +199,8 @@ struct TextureOverloadCase { TextureOverloadCase(ValidTextureOverload, const char*, AccessControl, - type::ImageFormat, - type::TextureDimension, + sem::ImageFormat, + sem::TextureDimension, TextureDataType, const char*, std::function); @@ -215,7 +215,7 @@ struct TextureOverloadCase { /// @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 @@ struct TextureOverloadCase { 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 457ca6bce0..bea8d6cd4b 100644 --- a/src/ast/literal.cc +++ b/src/ast/literal.cc @@ -19,7 +19,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Literal); 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 39b826c10b..6ea656b41a 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -28,7 +28,7 @@ class Literal : public Castable { ~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 @@ class Literal : public Castable { /// @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 c26e6ed7f0..31ac2f38c9 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -35,7 +35,7 @@ Module::Module(ProgramID program_id, continue; } - if (auto* ty = decl->As()) { + if (auto* ty = decl->As()) { constructed_types_.push_back(ty); } else if (auto* func = decl->As()) { functions_.push_back(func); @@ -62,7 +62,7 @@ void Module::Copy(CloneContext* ctx, const Module* src) { TINT_ICE(ctx->dst->Diagnostics()) << "src global declaration was nullptr"; continue; } - if (auto* ty = decl->As()) { + if (auto* ty = decl->As()) { AddConstructedType(ty); } else if (auto* func = decl->As()) { AddFunction(func); @@ -82,13 +82,13 @@ void Module::to_str(const sem::Info& sem, indent += 2; for (auto* const ty : constructed_types_) { make_indent(out, indent); - if (auto* alias = ty->As()) { + if (auto* alias = ty->As()) { out << alias->symbol().to_str() << " -> " << alias->type()->type_name() << std::endl; - if (auto* str = alias->type()->As()) { + if (auto* str = alias->type()->As()) { str->impl()->to_str(sem, out, indent); } - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { 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 b2b7673f9c..fe319bc2a6 100644 --- a/src/ast/module.h +++ b/src/ast/module.h @@ -67,14 +67,14 @@ class Module : public Castable { /// 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& ConstructedTypes() const { + const std::vector& ConstructedTypes() const { return constructed_types_; } @@ -115,7 +115,7 @@ class Module : public Castable { private: std::vector global_declarations_; - std::vector constructed_types_; + std::vector constructed_types_; FunctionList functions_; VariableList global_variables_; }; diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc index d89f9d993a..6f39c42ad2 100644 --- a/src/ast/module_clone_test.cc +++ b/src/ast/module_clone_test.cc @@ -128,7 +128,7 @@ let declaration_order_check_3 : i32 = 1; for (auto* src_node : src.ASTNodes().Objects()) { src_nodes.emplace(src_node); } - std::unordered_set src_types; + std::unordered_set 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 18eee89209..24320bb282 100644 --- a/src/ast/node.h +++ b/src/ast/node.h @@ -24,7 +24,7 @@ namespace tint { // 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 8fc435f240..7d3c151b69 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -23,7 +23,7 @@ namespace ast { SintLiteral::SintLiteral(ProgramID program_id, const Source& source, - type::Type* type, + sem::Type* type, int32_t value) : Base(program_id, source, type, static_cast(value)) {} diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index ddc2ac8bde..e215382075 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -32,7 +32,7 @@ class SintLiteral : public Castable { /// @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 cfd7ec62ef..da4121b6f8 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -45,7 +45,7 @@ TEST_F(SintLiteralTest, Name_I32) { } TEST_F(SintLiteralTest, Name_U32) { - type::U32 u32; + sem::U32 u32; auto* i = create(&u32, 2); EXPECT_EQ("__sint__u32_2", i->name()); } diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc index 68c9340288..d9b895cc1b 100644 --- a/src/ast/struct_member.cc +++ b/src/ast/struct_member.cc @@ -24,7 +24,7 @@ namespace ast { 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 afb0e6b303..246aa2fc69 100644 --- a/src/ast/struct_member.h +++ b/src/ast/struct_member.h @@ -35,7 +35,7 @@ class StructMember : public Castable { 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 @@ class StructMember : public Castable { /// @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 @@ class StructMember : public Castable { 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 2b4a940d75..1b2c3d1e11 100644 --- a/src/ast/type_constructor_expression.cc +++ b/src/ast/type_constructor_expression.cc @@ -23,7 +23,7 @@ namespace ast { 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 805212129f..8270865a90 100644 --- a/src/ast/type_constructor_expression.h +++ b/src/ast/type_constructor_expression.h @@ -33,14 +33,14 @@ class TypeConstructorExpression /// @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 @@ class TypeConstructorExpression 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 335385f59f..e9e8acec77 100644 --- a/src/ast/type_constructor_expression_test.cc +++ b/src/ast/type_constructor_expression_test.cc @@ -81,7 +81,7 @@ TEST_F(TypeConstructorExpressionTest, Assert_DifferentProgramID_Value) { } 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 1616c5040c..a65a36b25f 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -23,7 +23,7 @@ namespace ast { 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 557be53c3c..0b12775f69 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -32,7 +32,7 @@ class UintLiteral : public Castable { /// @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 3e5f7f8014..1371ce48c8 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -27,7 +27,7 @@ Variable::Variable(ProgramID program_id, 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 ab88e3a58c..9094f9eaea 100644 --- a/src/ast/variable.h +++ b/src/ast/variable.h @@ -103,7 +103,7 @@ class Variable : public Castable { 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 @@ class Variable : public Castable { 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 @@ class Variable : public Castable { 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 16f8fa1c15..ec562f38f2 100644 --- a/src/clone_context.h +++ b/src/clone_context.h @@ -84,7 +84,7 @@ class CloneContext { /// 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 @@ class CloneContext { /// 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 T* Clone(T* a) { @@ -144,7 +144,7 @@ class CloneContext { 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 @@ class CloneContext { /// 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 T* CloneWithoutTransform(T* a) { diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index c9ca62d532..34983cd1e7 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -57,44 +57,44 @@ void AppendResourceBindings(std::vector* dest, 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()) { + if (auto* at = base_type->As()) { base_type = at->type(); - } else if (auto* mt = base_type->As()) { + } else if (auto* mt = base_type->As()) { base_type = mt->type(); - } else if (auto* vt = base_type->As()) { + } else if (auto* vt = base_type->As()) { base_type = vt->type(); } - if (base_type->Is()) { + if (base_type->Is()) { return ResourceBinding::SampledKind::kFloat; - } else if (base_type->Is()) { + } else if (base_type->Is()) { return ResourceBinding::SampledKind::kUInt; - } else if (base_type->Is()) { + } else if (base_type->Is()) { return ResourceBinding::SampledKind::kSInt; } else { return ResourceBinding::SampledKind::kUnknown; @@ -102,79 +102,79 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(type::Type* base_type) { } 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 @@ std::vector Inspector::GetEntryPoints() { entry_point.input_variables); } - if (!func->return_type()->Is()) { + if (!func->return_type()->Is()) { AddEntryPointInOutVariables("", func->return_type(), func->return_type_decorations(), entry_point.output_variables); @@ -386,7 +386,7 @@ std::vector Inspector::GetUniformBufferResourceBindings( auto binding_info = ruv.second; auto* unwrapped_type = var->Type()->UnwrapIfNeeded(); - auto* str = unwrapped_type->As(); + auto* str = unwrapped_type->As(); if (str == nullptr) { continue; } @@ -514,7 +514,7 @@ std::vector Inspector::GetDepthTextureResourceBindings( entry.bind_group = binding_info.group->value(); entry.binding = binding_info.binding->value(); - auto* texture_type = var->Type()->UnwrapIfNeeded()->As(); + auto* texture_type = var->Type()->UnwrapIfNeeded()->As(); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension( texture_type->dim()); @@ -541,7 +541,7 @@ ast::Function* Inspector::FindEntryPointByName(const std::string& name) { void Inspector::AddEntryPointInOutVariables( std::string name, - type::Type* type, + sem::Type* type, const ast::DecorationList& decorations, std::vector& variables) const { // Skip builtins. @@ -551,7 +551,7 @@ void Inspector::AddEntryPointInOutVariables( auto* unwrapped_type = type->UnwrapAll(); - if (auto* struct_ty = unwrapped_type->As()) { + if (auto* struct_ty = unwrapped_type->As()) { // Recurse into members. for (auto* member : struct_ty->impl()->members()) { AddEntryPointInOutVariables( @@ -597,7 +597,7 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( auto* var = rsv.first; auto binding_info = rsv.second; - auto* ac_type = var->Type()->As(); + auto* ac_type = var->Type()->As(); if (ac_type == nullptr) { continue; } @@ -606,7 +606,7 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( continue; } - auto* str = var->Type()->UnwrapIfNeeded()->As(); + auto* str = var->Type()->UnwrapIfNeeded()->As(); if (!str) { continue; } @@ -657,18 +657,18 @@ std::vector Inspector::GetSampledTextureResourceBindingsImpl( entry.bind_group = binding_info.group->value(); entry.binding = binding_info.binding->value(); - auto* texture_type = var->Type()->UnwrapIfNeeded()->As(); + auto* texture_type = var->Type()->UnwrapIfNeeded()->As(); entry.dim = TypeTextureDimensionToResourceBindingTextureDimension( texture_type->dim()); - type::Type* base_type = nullptr; + sem::Type* base_type = nullptr; if (multisampled_only) { - base_type = texture_type->As() + base_type = texture_type->As() ->type() ->UnwrapIfNeeded(); } else { base_type = - texture_type->As()->type()->UnwrapIfNeeded(); + texture_type->As()->type()->UnwrapIfNeeded(); } entry.sampled_kind = BaseTypeToSampledKind(base_type); @@ -692,7 +692,7 @@ std::vector Inspector::GetStorageTextureResourceBindingsImpl( auto* var = ref.first; auto binding_info = ref.second; - auto* ac_type = var->Type()->As(); + auto* ac_type = var->Type()->As(); if (ac_type == nullptr) { continue; } @@ -709,11 +709,11 @@ std::vector Inspector::GetStorageTextureResourceBindingsImpl( entry.binding = binding_info.binding->value(); auto* texture_type = - var->Type()->UnwrapIfNeeded()->As(); + var->Type()->UnwrapIfNeeded()->As(); 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 7258b7b4e2..34723dd76b 100644 --- a/src/inspector/inspector.h +++ b/src/inspector/inspector.h @@ -223,7 +223,7 @@ class Inspector { /// @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& variables) const; diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index f3ea3110f2..54c5838058 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -30,8 +30,8 @@ namespace { 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 @@ class InspectorHelper : public ProgramBuilder { /// 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> inout_vars) { ast::StructMemberList members; @@ -146,7 +146,7 @@ class InspectorHelper : public ProgramBuilder { /// @param val value to initialize the variable with, if NULL no initializer /// will be added. template - 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 @@ class InspectorHelper : public ProgramBuilder { /// @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(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(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(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(type, *val); } @@ -203,7 +203,7 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { /// @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 member_types, - bool is_block) { + sem::StructType* MakeStructType(const std::string& name, + std::vector 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 @@ class InspectorHelper : public ProgramBuilder { /// @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 member_types) { + sem::StructType* MakeUniformBufferType(const std::string& name, + std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); return struct_type; } @@ -248,12 +247,12 @@ class InspectorHelper : public ProgramBuilder { /// @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 MakeStorageBufferTypes( + std::tuple MakeStorageBufferTypes( const std::string& name, - std::vector member_types) { + std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); - auto* access_type = create( - ast::AccessControl::kReadWrite, struct_type); + auto* access_type = + create(ast::AccessControl::kReadWrite, struct_type); return {struct_type, std::move(access_type)}; } @@ -263,12 +262,12 @@ class InspectorHelper : public ProgramBuilder { /// @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 + std::tuple MakeReadOnlyStorageBufferTypes(const std::string& name, - std::vector member_types) { + std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); auto* access_type = - create(ast::AccessControl::kReadOnly, struct_type); + create(ast::AccessControl::kReadOnly, struct_type); return {struct_type, std::move(access_type)}; } @@ -279,7 +278,7 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { void MakeStructVariableReferenceBodyFunction( std::string func_name, std::string struct_name, - std::vector> members) { + std::vector> 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 @@ class InspectorHelper : public ProgramBuilder { 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 @@ class InspectorHelper : public ProgramBuilder { /// @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(dim, type); + sem::SampledTexture* MakeSampledTextureType(sem::TextureDimension dim, + sem::Type* type) { + return create(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(dim); + sem::DepthTexture* MakeDepthTextureType(sem::TextureDimension dim) { + return create(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(dim, type); + sem::MultisampledTexture* MakeMultisampledTextureType( + sem::TextureDimension dim, + sem::Type* type) { + return create(dim, type); } /// Adds a sampled texture variable to the program @@ -402,7 +401,7 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { 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 @@ class InspectorHelper : public ProgramBuilder { 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 @@ class InspectorHelper : public ProgramBuilder { 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 @@ class InspectorHelper : public ProgramBuilder { /// 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 @@ class InspectorHelper : public ProgramBuilder { /// @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(scalar, 2); - case type::TextureDimension::k3d: - case type::TextureDimension::kCube: - case type::TextureDimension::kCubeArray: - return create(scalar, 3); + case sem::TextureDimension::k2d: + case sem::TextureDimension::k2dArray: + return create(scalar, 2); + case sem::TextureDimension::k3d: + case sem::TextureDimension::kCube: + case sem::TextureDimension::kCubeArray: + return create(scalar, 3); default: [=]() { FAIL() << "Unsupported texture dimension: " << dim; }(); } @@ -573,11 +572,11 @@ class InspectorHelper : public ProgramBuilder { /// @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 MakeStorageTextureTypes( - type::TextureDimension dim, - type::ImageFormat format) { - type::Type* subtype = type::StorageTexture::SubtypeFor(format, Types()); - return {create(dim, format, subtype), subtype}; + std::tuple MakeStorageTextureTypes( + sem::TextureDimension dim, + sem::ImageFormat format) { + sem::Type* subtype = sem::StorageTexture::SubtypeFor(format, Types()); + return {create(dim, format, subtype), subtype}; } /// Generates appropriate types for a Read-Only StorageTexture @@ -585,17 +584,17 @@ class InspectorHelper : public ProgramBuilder { /// @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 - MakeStorageTextureTypes(type::TextureDimension dim, - type::ImageFormat format, + std::tuple + 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(read_only ? ast::AccessControl::kReadOnly - : ast::AccessControl::kWriteOnly, - texture_type); + create(read_only ? ast::AccessControl::kReadOnly + : ast::AccessControl::kWriteOnly, + texture_type); return {texture_type, subtype, access_control}; } @@ -605,7 +604,7 @@ class InspectorHelper : public ProgramBuilder { /// @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 @@ class InspectorHelper : public ProgramBuilder { 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 @@ class InspectorHelper : public ProgramBuilder { 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(ty.u32(), count, - ast::DecorationList{ - create(4), - }); + create(ty.u32(), count, + ast::DecorationList{ + create(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, count); + create(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_; std::unique_ptr inspector_; - type::Sampler sampler_type_; - type::Sampler comparison_sampler_type_; - std::map array_type_memo_; - std::map, type::Vector*> vector_type_memo_; + sem::Sampler sampler_type_; + sem::Sampler comparison_sampler_type_; + std::map array_type_memo_; + std::map, sem::Vector*> vector_type_memo_; }; class InspectorGetEntryPointTest : public InspectorHelper, @@ -705,7 +704,7 @@ class InspectorGetSampledArrayTextureResourceBindingsTest : 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 InspectorGetMultisampledTextureResourceBindingsTestWithParam 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 {}; -typedef std::tuple +typedef std::tuple DimensionParams; -typedef std::tuple ImageFormatParams; @@ -905,7 +904,7 @@ TEST_F(InspectorGetEntryPointTest, NoInOutVariables) { 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, Empty) { } 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 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { {{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 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { 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()); @@ -1718,19 +1717,19 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { 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(), {}); - 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(), {}); @@ -1803,7 +1802,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) { } 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, MissingBlockDeco) { } 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, Simple) { } 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, MultipleMembers) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) { - type::StructType* foo_struct_type = + sem::StructType* foo_struct_type = MakeUniformBufferType("foo_type", {ty.vec3()}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); @@ -1930,7 +1929,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) { } 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 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { // 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(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { } 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, Simple) { } 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, MultipleMembers) { } 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, MultipleStorageBuffers) { } 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, ContainingArray) { } 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, ContainingRuntimeArray) { } 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()}); AddStorageBuffer("foo_sb", foo_control_type, 0, 0); @@ -2224,8 +2223,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { } 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(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { } 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, Simple) { 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, } 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, ContainingArray) { 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, } 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(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { 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, NoSampler) { 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, InFunction) { 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, UnknownEntryPoint) { } 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()); @@ -2523,7 +2522,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) { } 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()); @@ -2562,7 +2561,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) { } 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()); @@ -2591,7 +2590,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) { } 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()); @@ -2611,7 +2610,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) { 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 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) { 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(); break; - case type::TextureDimension::k3d: + case sem::TextureDimension::k3d: dim_type = ty.vec3(); break; default: @@ -2955,118 +2954,118 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ INSTANTIATE_TEST_SUITE_P( 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 4bcd8c7183..004bcbe558 100644 --- a/src/intrinsic_table.cc +++ b/src/intrinsic_table.cc @@ -77,7 +77,7 @@ class Matcher { /// 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 open_types; + std::unordered_map 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 @@ class Matcher { /// 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 @@ class Matcher { /// 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 @@ class Builder : public Matcher { /// 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 const open_types; + std::unordered_map const open_types; /// The final resolved list of open numbers std::unordered_map const open_numbers; }; @@ -156,7 +156,7 @@ class Builder : public Matcher { ~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 @@ class OpenTypeBuilder : public Builder { 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 @@ class OpenTypeBuilder : public Builder { /// VoidBuilder is a Matcher / Builder for void types. class VoidBuilder : public Builder { public: - bool MatchUnwrapped(MatchState&, type::Type* ty) const override { - return ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is(); } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(); } std::string str() const override { return "void"; } }; @@ -195,11 +195,11 @@ class VoidBuilder : public Builder { /// BoolBuilder is a Matcher / Builder for boolean types. class BoolBuilder : public Builder { public: - bool MatchUnwrapped(MatchState&, type::Type* ty) const override { - return ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is(); } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(); } std::string str() const override { return "bool"; } }; @@ -207,11 +207,11 @@ class BoolBuilder : public Builder { /// F32Builder is a Matcher / Builder for f32 types. class F32Builder : public Builder { public: - bool MatchUnwrapped(MatchState&, type::Type* ty) const override { - return ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is(); } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(); } std::string str() const override { return "f32"; } }; @@ -219,11 +219,11 @@ class F32Builder : public Builder { /// U32Builder is a Matcher / Builder for u32 types. class U32Builder : public Builder { public: - bool MatchUnwrapped(MatchState&, type::Type* ty) const override { - return ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is(); } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(); } std::string str() const override { return "u32"; } }; @@ -231,11 +231,11 @@ class U32Builder : public Builder { /// I32Builder is a Matcher / Builder for i32 types. class I32Builder : public Builder { public: - bool MatchUnwrapped(MatchState&, type::Type* ty) const override { - return ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is(); } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(); } std::string str() const override { return "i32"; } }; @@ -243,8 +243,8 @@ class I32Builder : public Builder { /// 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() || ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is() || ty->Is(); } std::string str() const override { return "i32 or u32"; } }; @@ -252,8 +252,8 @@ class IU32Matcher : public Matcher { /// 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() || ty->Is() || ty->Is(); + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + return ty->Is() || ty->Is() || ty->Is(); } std::string str() const override { return "f32, i32 or u32"; } }; @@ -261,7 +261,7 @@ class FIU32Matcher : public Matcher { /// 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 @@ class OpenSizeVecBuilder : public Builder { 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* vec = ty->As()) { if (!MatchOpenNumber(state, size_, vec->size())) { return false; } @@ -284,10 +284,10 @@ class OpenSizeVecBuilder : public Builder { 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(el, n); + return state.ty_mgr.Get(el, n); } std::string str() const override { @@ -306,8 +306,8 @@ class VecBuilder : public Builder { 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* vec = ty->As()) { if (vec->size() == size_) { return element_builder_->Match(state, vec->type()); } @@ -315,9 +315,9 @@ class VecBuilder : public Builder { 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(el, size_); + return state.ty_mgr.Get(el, size_); } std::string str() const override { @@ -338,8 +338,8 @@ class OpenSizeMatBuilder : public Builder { 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* mat = ty->As()) { if (!MatchOpenNumber(state, columns_, mat->columns())) { return false; } @@ -351,11 +351,11 @@ class OpenSizeMatBuilder : public Builder { 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(el, rows, columns); + return state.ty_mgr.Get(el, rows, columns); } std::string str() const override { @@ -375,16 +375,16 @@ class PtrBuilder : public Builder { explicit PtrBuilder(Builder* element_builder) : element_builder_(element_builder) {} - bool MatchUnwrapped(MatchState& state, type::Type* ty) const override { - if (auto* ptr = ty->As()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* ptr = ty->As()) { 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(el, ast::StorageClass::kNone); + return state.ty_mgr.Get(el, ast::StorageClass::kNone); } bool ExpectsPointer() const override { return true; } @@ -403,8 +403,8 @@ class ArrayBuilder : public Builder { explicit ArrayBuilder(Builder* element_builder) : element_builder_(element_builder) {} - bool MatchUnwrapped(MatchState& state, type::Type* ty) const override { - if (auto* arr = ty->As()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* arr = ty->As()) { if (arr->size() == 0) { return element_builder_->Match(state, arr->type()); } @@ -412,9 +412,9 @@ class ArrayBuilder : public Builder { 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(el, 0, ast::DecorationList{}); + return state.ty_mgr.Get(el, 0, ast::DecorationList{}); } std::string str() const override { @@ -428,12 +428,12 @@ class ArrayBuilder : public Builder { /// 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* tex = ty->As()) { if (tex->dim() == dimensions_) { return type_builder_->Match(state, tex->type()); } @@ -441,9 +441,9 @@ class SampledTextureBuilder : public Builder { 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(dimensions_, type); + return state.ty_mgr.Get(dimensions_, type); } std::string str() const override { @@ -453,7 +453,7 @@ class SampledTextureBuilder : public Builder { } private: - type::TextureDimension const dimensions_; + sem::TextureDimension const dimensions_; Builder* const type_builder_; }; @@ -461,12 +461,12 @@ class SampledTextureBuilder : public Builder { /// 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* tex = ty->As()) { if (tex->dim() == dimensions_) { return type_builder_->Match(state, tex->type()); } @@ -474,9 +474,9 @@ class MultisampledTextureBuilder : public Builder { 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(dimensions_, type); + return state.ty_mgr.Get(dimensions_, type); } std::string str() const override { @@ -487,25 +487,25 @@ class MultisampledTextureBuilder : public Builder { } 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()) { + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + if (auto* tex = ty->As()) { return tex->dim() == dimensions_; } return false; } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(dimensions_); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(dimensions_); } std::string str() const override { @@ -515,7 +515,7 @@ class DepthTextureBuilder : public Builder { } private: - type::TextureDimension const dimensions_; + sem::TextureDimension const dimensions_; }; /// StorageTextureBuilder is a Matcher / Builder for storage texture types of @@ -523,15 +523,15 @@ class DepthTextureBuilder : public Builder { 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()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* ac = ty->As()) { // 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 @@ class StorageTextureBuilder : public Builder { ty = ac->type(); } - if (auto* tex = ty->As()) { + if (auto* tex = ty->As()) { if (MatchOpenNumber(state, texel_format_, static_cast(tex->image_format()))) { if (MatchOpenType(state, channel_format_, tex->type())) { @@ -550,12 +550,12 @@ class StorageTextureBuilder : public Builder { return false; } - type::Type* Build(BuildState& state) const override { + sem::Type* Build(BuildState& state) const override { auto texel_format = - static_cast(state.open_numbers.at(texel_format_)); + static_cast(state.open_numbers.at(texel_format_)); auto* channel_format = state.open_types.at(channel_format_); - return state.ty_mgr.Get(dimensions_, texel_format, - channel_format); + return state.ty_mgr.Get(dimensions_, texel_format, + channel_format); } std::string str() const override { @@ -565,7 +565,7 @@ class StorageTextureBuilder : public Builder { } private: - type::TextureDimension const dimensions_; + sem::TextureDimension const dimensions_; OpenNumber const texel_format_; OpenType const channel_format_; }; @@ -573,31 +573,31 @@ class StorageTextureBuilder : public Builder { /// 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()) { + bool MatchUnwrapped(MatchState&, sem::Type* ty) const override { + if (auto* sampler = ty->As()) { return sampler->kind() == kind_; } return false; } - type::Type* Build(BuildState& state) const override { - return state.ty_mgr.Get(kind_); + sem::Type* Build(BuildState& state) const override { + return state.ty_mgr.Get(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 @@ class AccessControlBuilder : public Builder { Builder* type) : access_control_(access_control), type_(type) {} - bool MatchUnwrapped(MatchState& state, type::Type* ty) const override { - if (auto* ac = ty->As()) { + bool MatchUnwrapped(MatchState& state, sem::Type* ty) const override { + if (auto* ac = ty->As()) { if (ac->access_control() == access_control_) { return type_->Match(state, ty); } @@ -616,9 +616,9 @@ class AccessControlBuilder : public Builder { 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(access_control_, ty); + return state.ty_mgr.Get(access_control_, ty); } std::string str() const override { @@ -639,7 +639,7 @@ class Impl : public IntrinsicTable { IntrinsicTable::Result Lookup(ProgramBuilder& builder, sem::IntrinsicType type, - const std::vector& args, + const std::vector& args, const Source& source) const override; /// Holds the information about a single overload parameter used for matching @@ -661,7 +661,7 @@ class Impl : public IntrinsicTable { /// (positive representing a greater match), and nullptr is returned. sem::Intrinsic* Match(ProgramBuilder& builder, sem::IntrinsicType type, - const std::vector& arg_types, + const std::vector& arg_types, diag::List& diagnostics, int& match_score) const; @@ -732,13 +732,13 @@ class Impl : public IntrinsicTable { /// @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(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(dimensions, type); @@ -746,13 +746,13 @@ class Impl : public IntrinsicTable { /// @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(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( @@ -760,7 +760,7 @@ class Impl : public IntrinsicTable { } /// @returns a Matcher / Builder that matches a sampler type - Builder* sampler(type::SamplerKind kind) { + Builder* sampler(sem::SamplerKind kind) { return matcher_allocator_.Create(kind); } @@ -796,7 +796,7 @@ class Impl : public IntrinsicTable { 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 @@ Impl::Impl() { // 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 @@ Impl::Impl() { // // (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 @@ Impl::Impl() { 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 @@ std::string str(const Impl::Overload& overload) { /// types. std::string CallSignature(ProgramBuilder& builder, sem::IntrinsicType type, - const std::vector& args) { + const std::vector& args) { std::stringstream ss; ss << sem::str(type) << "("; { @@ -1320,7 +1320,7 @@ std::string CallSignature(ProgramBuilder& builder, IntrinsicTable::Result Impl::Lookup(ProgramBuilder& builder, sem::IntrinsicType type, - const std::vector& args, + const std::vector& args, const Source& source) const { diag::List diagnostics; // Candidate holds information about a mismatched overload that could be what @@ -1370,7 +1370,7 @@ IntrinsicTable::Result Impl::Lookup(ProgramBuilder& builder, sem::Intrinsic* Impl::Overload::Match(ProgramBuilder& builder, sem::IntrinsicType intrinsic, - const std::vector& args, + const std::vector& args, diag::List& diagnostics, int& match_score) const { if (type != intrinsic) { @@ -1397,7 +1397,7 @@ sem::Intrinsic* Impl::Overload::Match(ProgramBuilder& builder, } auto* arg_ty = args[i]; - if (auto* ptr = arg_ty->As()) { + if (auto* ptr = arg_ty->As()) { 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 fc0e465177..04252554ad 100644 --- a/src/intrinsic_table.h +++ b/src/intrinsic_table.h @@ -51,7 +51,7 @@ class IntrinsicTable { /// @return the semantic intrinsic if found, otherwise nullptr virtual Result Lookup(ProgramBuilder& builder, sem::IntrinsicType type, - const std::vector& args, + const std::vector& args, const Source& source) const = 0; }; diff --git a/src/intrinsic_table_test.cc b/src/intrinsic_table_test.cc index 073f0dfcfb..0b62d46b97 100644 --- a/src/intrinsic_table_test.cc +++ b/src/intrinsic_table_test.cc @@ -69,8 +69,7 @@ TEST_F(IntrinsicTableTest, MismatchU32) { } TEST_F(IntrinsicTableTest, MatchI32) { - auto* tex = - create(type::TextureDimension::k1d, ty.f32()); + auto* tex = create(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, MatchI32) { } TEST_F(IntrinsicTableTest, MismatchI32) { - auto* tex = - create(type::TextureDimension::k1d, ty.f32()); + auto* tex = create(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, MismatchArray) { } TEST_F(IntrinsicTableTest, MatchSampler) { - auto* tex = - create(type::TextureDimension::k2d, ty.f32()); - auto* sampler = create(type::SamplerKind::kSampler); + auto* tex = create(sem::TextureDimension::k2d, ty.f32()); + auto* sampler = create(sem::SamplerKind::kSampler); auto result = table->Lookup(*this, IntrinsicType::kTextureSample, {tex, sampler, ty.vec2()}, Source{}); ASSERT_NE(result.intrinsic, nullptr); @@ -238,8 +235,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) { } TEST_F(IntrinsicTableTest, MismatchSampler) { - auto* tex = - create(type::TextureDimension::k2d, ty.f32()); + auto* tex = create(sem::TextureDimension::k2d, ty.f32()); auto result = table->Lookup(*this, IntrinsicType::kTextureSample, {tex, ty.f32(), ty.vec2()}, Source{}); ASSERT_EQ(result.intrinsic, nullptr); @@ -247,8 +243,7 @@ TEST_F(IntrinsicTableTest, MismatchSampler) { } TEST_F(IntrinsicTableTest, MatchSampledTexture) { - auto* tex = - create(type::TextureDimension::k2d, ty.f32()); + auto* tex = create(sem::TextureDimension::k2d, ty.f32()); auto result = table->Lookup(*this, IntrinsicType::kTextureLoad, {tex, ty.vec2(), ty.i32()}, Source{}); ASSERT_NE(result.intrinsic, nullptr); @@ -263,7 +258,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) { TEST_F(IntrinsicTableTest, MatchMultisampledTexture) { auto* tex = - create(type::TextureDimension::k2d, ty.f32()); + create(sem::TextureDimension::k2d, ty.f32()); auto result = table->Lookup(*this, IntrinsicType::kTextureLoad, {tex, ty.vec2(), ty.i32()}, Source{}); ASSERT_NE(result.intrinsic, nullptr); @@ -277,7 +272,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) { } TEST_F(IntrinsicTableTest, MatchDepthTexture) { - auto* tex = create(type::TextureDimension::k2d); + auto* tex = create(sem::TextureDimension::k2d); auto result = table->Lookup(*this, IntrinsicType::kTextureLoad, {tex, ty.vec2(), ty.i32()}, Source{}); ASSERT_NE(result.intrinsic, nullptr); @@ -291,11 +286,10 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) { } TEST_F(IntrinsicTableTest, MatchROStorageTexture) { - auto* tex = create( - type::TextureDimension::k2d, type::ImageFormat::kR16Float, - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types())); - auto* tex_ac = - create(ast::AccessControl::kReadOnly, tex); + auto* tex = create( + sem::TextureDimension::k2d, sem::ImageFormat::kR16Float, + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types())); + auto* tex_ac = create(ast::AccessControl::kReadOnly, tex); auto result = table->Lookup(*this, IntrinsicType::kTextureLoad, {tex_ac, ty.vec2()}, Source{}); ASSERT_NE(result.intrinsic, nullptr); @@ -309,11 +303,11 @@ TEST_F(IntrinsicTableTest, MatchROStorageTexture) { } TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { - auto* tex = create( - type::TextureDimension::k2d, type::ImageFormat::kR16Float, - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types())); + auto* tex = create( + sem::TextureDimension::k2d, sem::ImageFormat::kR16Float, + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types())); auto* tex_ac = - create(ast::AccessControl::kWriteOnly, tex); + create(ast::AccessControl::kWriteOnly, tex); auto result = table->Lookup(*this, IntrinsicType::kTextureStore, {tex_ac, ty.vec2(), ty.vec4()}, Source{}); @@ -470,7 +464,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) { } TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) { - auto* tex = create(type::TextureDimension::k2d); + auto* tex = create(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 4342d102ff..a0703e891e 100644 --- a/src/program.cc +++ b/src/program.cc @@ -102,7 +102,7 @@ bool Program::IsValid() const { 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 815e751459..9f666f144d 100644 --- a/src/program.h +++ b/src/program.h @@ -66,7 +66,7 @@ class Program { 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 @@ class Program { /// @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 @@ class Program { 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 0f2c695365..368efca67d 100644 --- a/src/program_builder.cc +++ b/src/program_builder.cc @@ -56,7 +56,7 @@ ProgramBuilder& ProgramBuilder::operator=(ProgramBuilder&& rhs) { 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( program->AST().source(), program->AST().GlobalDeclarations()); builder.sem_ = sem::Info::Wrap(program->Sem()); @@ -85,40 +85,40 @@ void ProgramBuilder::AssertNotMoved() const { } } -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()) { + if (unwrapped_type->Is()) { return create( create(type, elem_value == 0 ? false : true)); } - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { return create(create( type, static_cast(elem_value))); } - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { return create(create( type, static_cast(elem_value))); } - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { return create(create( type, static_cast(elem_value))); } - if (auto* v = unwrapped_type->As()) { + if (auto* v = unwrapped_type->As()) { ast::ExpressionList el(v->size()); for (size_t i = 0; i < el.size(); i++) { el[i] = ConstructValueFilledWith(v->type(), elem_value); } return create(type, std::move(el)); } - if (auto* m = unwrapped_type->As()) { - auto* col_vec_type = create(m->type(), m->rows()); + if (auto* m = unwrapped_type->As()) { + auto* col_vec_type = create(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 e1b08636b9..b66e904584 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -124,13 +124,13 @@ class ProgramBuilder { 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 @@ class ProgramBuilder { return sem_nodes_.Create(std::forward(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 @@ class ProgramBuilder { /// @param args the arguments to pass to the type constructor /// @returns the de-aliased type pointer template - traits::EnableIfIsType* create(ARGS&&... args) { - static_assert(std::is_base_of::value, - "T does not derive from type::Type"); + traits::EnableIfIsType* create(ARGS&&... args) { + static_assert(std::is_base_of::value, + "T does not derive from sem::Type"); AssertNotMoved(); return types_.Get(std::forward(args)...); } @@ -324,185 +324,184 @@ class ProgramBuilder { /// @return the tint AST type for the C type `T`. template - type::Type* Of() const { + sem::Type* Of() const { return CToAST::get(this); } /// @returns a boolean type - type::Bool* bool_() const { return builder->create(); } + sem::Bool* bool_() const { return builder->create(); } /// @returns a f32 type - type::F32* f32() const { return builder->create(); } + sem::F32* f32() const { return builder->create(); } /// @returns a i32 type - type::I32* i32() const { return builder->create(); } + sem::I32* i32() const { return builder->create(); } /// @returns a u32 type - type::U32* u32() const { return builder->create(); } + sem::U32* u32() const { return builder->create(); } /// @returns a void type - type::Void* void_() const { return builder->create(); } + sem::Void* void_() const { return builder->create(); } /// @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, 2u); + sem::Vector* vec2(sem::Type* type) const { + return builder->create(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, 3u); + sem::Vector* vec3(sem::Type* type) const { + return builder->create(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, 4u); + sem::Type* vec4(sem::Type* type) const { + return builder->create(type, 4u); } /// @return the tint AST type for a 2-element vector of the C type `T`. template - type::Vector* vec2() const { + sem::Vector* vec2() const { return vec2(Of()); } /// @return the tint AST type for a 3-element vector of the C type `T`. template - type::Vector* vec3() const { + sem::Vector* vec3() const { return vec3(Of()); } /// @return the tint AST type for a 4-element vector of the C type `T`. template - type::Type* vec4() const { + sem::Type* vec4() const { return vec4(Of()); } /// @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, 2u, 2u); + sem::Matrix* mat2x2(sem::Type* type) const { + return builder->create(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, 3u, 2u); + sem::Matrix* mat2x3(sem::Type* type) const { + return builder->create(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, 4u, 2u); + sem::Matrix* mat2x4(sem::Type* type) const { + return builder->create(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, 2u, 3u); + sem::Matrix* mat3x2(sem::Type* type) const { + return builder->create(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, 3u, 3u); + sem::Matrix* mat3x3(sem::Type* type) const { + return builder->create(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, 4u, 3u); + sem::Matrix* mat3x4(sem::Type* type) const { + return builder->create(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, 2u, 4u); + sem::Matrix* mat4x2(sem::Type* type) const { + return builder->create(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, 3u, 4u); + sem::Matrix* mat4x3(sem::Type* type) const { + return builder->create(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, 4u, 4u); + sem::Matrix* mat4x4(sem::Type* type) const { + return builder->create(type, 4u, 4u); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - type::Matrix* mat2x2() const { + sem::Matrix* mat2x2() const { return mat2x2(Of()); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - type::Matrix* mat2x3() const { + sem::Matrix* mat2x3() const { return mat2x3(Of()); } /// @return the tint AST type for a 2x4 matrix of the C type `T`. template - type::Matrix* mat2x4() const { + sem::Matrix* mat2x4() const { return mat2x4(Of()); } /// @return the tint AST type for a 3x2 matrix of the C type `T`. template - type::Matrix* mat3x2() const { + sem::Matrix* mat3x2() const { return mat3x2(Of()); } /// @return the tint AST type for a 3x3 matrix of the C type `T`. template - type::Matrix* mat3x3() const { + sem::Matrix* mat3x3() const { return mat3x3(Of()); } /// @return the tint AST type for a 3x4 matrix of the C type `T`. template - type::Matrix* mat3x4() const { + sem::Matrix* mat3x4() const { return mat3x4(Of()); } /// @return the tint AST type for a 4x2 matrix of the C type `T`. template - type::Matrix* mat4x2() const { + sem::Matrix* mat4x2() const { return mat4x2(Of()); } /// @return the tint AST type for a 4x3 matrix of the C type `T`. template - type::Matrix* mat4x3() const { + sem::Matrix* mat4x3() const { return mat4x3(Of()); } /// @return the tint AST type for a 4x4 matrix of the C type `T`. template - type::Matrix* mat4x4() const { + sem::Matrix* mat4x4() const { return mat4x4(Of()); } /// @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(subtype, n, - ast::DecorationList{}); + sem::ArrayType* array(sem::Type* subtype, uint32_t n = 0) const { + return builder->create(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( + sem::ArrayType* array(sem::Type* subtype, + uint32_t n, + uint32_t stride) const { + return builder->create( subtype, n, ast::DecorationList{ builder->create(stride), @@ -511,14 +510,14 @@ class ProgramBuilder { /// @return the tint AST type for an array of size `N` of type `T` template - type::ArrayType* array() const { + sem::ArrayType* array() const { return array(Of(), N); } /// @param stride the array stride /// @return the tint AST type for an array of size `N` of type `T` template - type::ArrayType* array(uint32_t stride) const { + sem::ArrayType* array(uint32_t stride) const { return array(Of(), N, stride); } @@ -527,33 +526,33 @@ class ProgramBuilder { /// @param type the alias type /// @returns the alias pointer template - type::Alias* alias(NAME&& name, type::Type* type) const { - return builder->create( - builder->Sym(std::forward(name)), type); + sem::Alias* alias(NAME&& name, sem::Type* type) const { + return builder->create(builder->Sym(std::forward(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(access, type); + sem::AccessControl* access(ast::AccessControl access, + sem::Type* type) const { + return builder->create(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, storage_class); + sem::Pointer* pointer(sem::Type* type, + ast::StorageClass storage_class) const { + return builder->create(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 - type::Pointer* pointer(ast::StorageClass storage_class) const { + sem::Pointer* pointer(ast::StorageClass storage_class) const { return pointer(Of(), storage_class); } @@ -561,8 +560,8 @@ class ProgramBuilder { /// @param impl the struct implementation /// @returns a struct pointer template - type::StructType* struct_(NAME&& name, ast::Struct* impl) const { - return builder->create( + sem::StructType* struct_(NAME&& name, ast::Struct* impl) const { + return builder->create( builder->Sym(std::forward(name)), impl); } @@ -571,7 +570,7 @@ class ProgramBuilder { /// 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 struct CToAST {}; @@ -733,7 +732,7 @@ class ProgramBuilder { /// @return an `ast::TypeConstructorExpression` of `type` constructed with the /// values `args`. template - ast::TypeConstructorExpression* Construct(type::Type* type, ARGS&&... args) { + ast::TypeConstructorExpression* Construct(sem::Type* type, ARGS&&... args) { return create( type, ExprList(std::forward(args)...)); } @@ -746,7 +745,7 @@ class ProgramBuilder { /// @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 @@ class ProgramBuilder { /// @return an `ast::TypeConstructorExpression` of an array with element type /// `subtype`, constructed with the values `args`. template - ast::TypeConstructorExpression* array(type::Type* subtype, + ast::TypeConstructorExpression* array(sem::Type* subtype, uint32_t n, ARGS&&... args) { return create( @@ -887,7 +886,7 @@ class ProgramBuilder { /// @returns a `ast::Variable` with the given name, storage and type template 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 @@ class ProgramBuilder { template 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 @@ class ProgramBuilder { /// @returns a constant `ast::Variable` with the given name and type template ast::Variable* Const(NAME&& name, - type::Type* type, + sem::Type* type, ast::Expression* constructor = nullptr, ast::DecorationList decorations = {}) { return create(Sym(std::forward(name)), @@ -937,7 +936,7 @@ class ProgramBuilder { template ast::Variable* Const(const Source& source, NAME&& name, - type::Type* type, + sem::Type* type, ast::Expression* constructor = nullptr, ast::DecorationList decorations = {}) { return create(source, Sym(std::forward(name)), @@ -951,7 +950,7 @@ class ProgramBuilder { /// @returns a constant `ast::Variable` with the given name and type template ast::Variable* Param(NAME&& name, - type::Type* type, + sem::Type* type, ast::DecorationList decorations = {}) { return create(Sym(std::forward(name)), ast::StorageClass::kNone, type, true, nullptr, @@ -966,7 +965,7 @@ class ProgramBuilder { template ast::Variable* Param(const Source& source, NAME&& name, - type::Type* type, + sem::Type* type, ast::DecorationList decorations = {}) { return create(source, Sym(std::forward(name)), ast::StorageClass::kNone, type, true, nullptr, @@ -1127,7 +1126,7 @@ class ProgramBuilder { 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 @@ class ProgramBuilder { template 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 @@ class ProgramBuilder { return create(Expr(std::forward(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 - 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(source, std::move(members), std::move(decorations)); auto* type = ty.struct_(Sym(std::forward(name)), impl); @@ -1193,16 +1192,16 @@ class ProgramBuilder { 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 - 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(std::move(members), std::move(decorations)); auto* type = ty.struct_(Sym(std::forward(name)), impl); @@ -1219,7 +1218,7 @@ class ProgramBuilder { template ast::StructMember* Member(const Source& source, NAME&& name, - type::Type* type, + sem::Type* type, ast::DecorationList decorations = {}) { return create(source, Sym(std::forward(name)), type, std::move(decorations)); @@ -1232,7 +1231,7 @@ class ProgramBuilder { /// @returns the struct member pointer template ast::StructMember* Member(NAME&& name, - type::Type* type, + sem::Type* type, ast::DecorationList decorations = {}) { return create(source_, Sym(std::forward(name)), type, std::move(decorations)); @@ -1244,7 +1243,7 @@ class ProgramBuilder { /// @param type the struct member type /// @returns the struct member pointer template - ast::StructMember* Member(uint32_t offset, NAME&& name, type::Type* type) { + ast::StructMember* Member(uint32_t offset, NAME&& name, sem::Type* type) { return create( source_, Sym(std::forward(name)), type, ast::DecorationList{ @@ -1417,7 +1416,7 @@ class ProgramBuilder { /// @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 @@ class ProgramBuilder { private: ProgramID id_; - type::Manager types_; + sem::Manager types_; ASTNodeAllocator ast_nodes_; SemNodeAllocator sem_nodes_; ast::Module* ast_; @@ -1489,31 +1488,31 @@ class ProgramBuilder { // Various template specializations for ProgramBuilder::TypesBuilder::CToAST. template <> struct ProgramBuilder::TypesBuilder::CToAST { - static type::Type* get(const ProgramBuilder::TypesBuilder* t) { + static sem::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->i32(); } }; template <> struct ProgramBuilder::TypesBuilder::CToAST { - static type::Type* get(const ProgramBuilder::TypesBuilder* t) { + static sem::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->u32(); } }; template <> struct ProgramBuilder::TypesBuilder::CToAST { - static type::Type* get(const ProgramBuilder::TypesBuilder* t) { + static sem::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->f32(); } }; template <> struct ProgramBuilder::TypesBuilder::CToAST { - static type::Type* get(const ProgramBuilder::TypesBuilder* t) { + static sem::Type* get(const ProgramBuilder::TypesBuilder* t) { return t->bool_(); } }; template <> struct ProgramBuilder::TypesBuilder::CToAST { - 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 b07da2679f..1f82c040c6 100644 --- a/src/reader/spirv/enum_converter.cc +++ b/src/reader/spirv/enum_converter.cc @@ -100,83 +100,83 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) { 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 5831a88a73..1fd535e88a 100644 --- a/src/reader/spirv/enum_converter.h +++ b/src/reader/spirv/enum_converter.h @@ -58,13 +58,13 @@ class EnumConverter { /// @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 19f6ad2167..4433f9c8fb 100644 --- a/src/reader/spirv/enum_converter_test.cc +++ b/src/reader/spirv/enum_converter_test.cc @@ -243,7 +243,7 @@ struct DimCase { 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 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ INSTANTIATE_TEST_SUITE_P( 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 4b25b05744..d66cd4e02b 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -724,8 +724,8 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi, fail_stream_(pi->fail_stream()), namer_(pi->namer()), function_(function), - i32_(builder_.create()), - u32_(builder_.create()), + i32_(builder_.create()), + u32_(builder_.create()), sample_mask_in_id(0u), sample_mask_out_id(0u), ep_info_(ep_info) { @@ -931,7 +931,7 @@ bool FunctionEmitter::ParseFunctionDeclaration(FunctionDeclaration* decl) { 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 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { << id; return {}; case SkipReason::kPointSizeBuiltinValue: { - auto* f32 = create(); + auto* f32 = create(); return {f32, create( Source{}, create(Source{}, f32, 1.0f))}; @@ -3145,8 +3145,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { } auto expr = MakeExpression(ptr_id); // The load result type is the pointee type of its operand. - TINT_ASSERT(expr.type->Is()); - expr.type = expr.type->As()->type(); + TINT_ASSERT(expr.type->Is()); + expr.type = expr.type->As()->type(); return EmitConstDefOrWriteToHoistedVar(inst, expr); } @@ -3242,7 +3242,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue( 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 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst( auto* func = create( 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 @@ TypedExpression FunctionEmitter::MakeAccessChain( 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()); + TINT_ASSERT(ast_pointer_type->Is()); current_expr = TypedExpression{ast_pointer_type, next_expr}; } return current_expr; @@ -3794,7 +3794,7 @@ ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const { } ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const { - type::Bool bool_type; + sem::Bool bool_type; return create( source, create(source, parser_impl_.Bool(), false)); } @@ -3815,8 +3815,8 @@ TypedExpression FunctionEmitter::MakeVectorShuffle( // 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(); + sem::Vector* result_type = + parser_impl_.ConvertType(inst.type_id())->As(); ast::ExpressionList values; for (uint32_t i = 2; i < inst.NumInOperands(); ++i) { const auto index = inst.GetSingleWordInOperand(i); @@ -3907,7 +3907,7 @@ bool FunctionEmitter::RegisterLocallyDefinedValues() { if (type) { if (type->AsPointer()) { if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) { - if (auto* ptr = ast_type->As()) { + if (auto* ptr = ast_type->As()) { info->storage_class = ptr->storage_class(); } } @@ -3952,21 +3952,21 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) { 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()) { - return ast_type->As()->storage_class(); + if (ast_type && ast_type->Is()) { + return ast_type->As()->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()) { +sem::Type* FunctionEmitter::RemapStorageClass(sem::Type* type, + uint32_t result_id) { + if (const auto* ast_ptr_type = type->As()) { // 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(ast_ptr_type->type(), sc); + return builder_.create(ast_ptr_type->type(), sc); } } return type; @@ -4149,7 +4149,7 @@ TypedExpression FunctionEmitter::MakeNumericConversion( 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 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) { << inst.PrettyPrint(); } - if (result_type->Is()) { + if (result_type->Is()) { return nullptr != AddStatement(create(Source{}, call_expr)); } @@ -4277,7 +4277,7 @@ TypedExpression FunctionEmitter::MakeIntrinsicCall( 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 @@ TypedExpression FunctionEmitter::MakeSimpleSelect( // - 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() || op_ty->is_float_scalar() || - op_ty->is_integer_scalar() || op_ty->Is()) { + if (op_ty->Is() || op_ty->is_float_scalar() || + op_ty->is_integer_scalar() || op_ty->Is()) { ast::ExpressionList params; params.push_back(operand1.expr); params.push_back(operand2.expr); @@ -4348,18 +4348,18 @@ const spvtools::opt::Instruction* FunctionEmitter::GetImage( 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()) { + if (!ptr_type || !ptr_type->type()->UnwrapAll()->Is()) { Fail() << "invalid texture type for " << image.PrettyPrint(); return nullptr; } - return As(ptr_type->type()->UnwrapAll()); + return As(ptr_type->type()->UnwrapAll()); } ast::Expression* FunctionEmitter::GetImageExpression( @@ -4409,12 +4409,12 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { } } - 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(); + sem::Texture* texture_type = + texture_ptr_type->type()->UnwrapAll()->As(); if (!texture_type) { return Fail(); } @@ -4516,7 +4516,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { } TypedExpression lod = MakeOperand(inst, arg_index); // When sampling from a depth texture, the Lod operand must be an I32. - if (texture_type->Is()) { + if (texture_type->Is()) { // Convert it to a signed integer type. lod = ToI32(lod); } @@ -4524,8 +4524,8 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { image_operands_mask ^= SpvImageOperandsLodMask; arg_index++; } else if ((opcode == SpvOpImageFetch) && - (texture_type->Is() || - texture_type->Is())) { + (texture_type->Is() || + texture_type->Is())) { // 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 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { << 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 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { // 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()) { + if (auto* result_vector_type = result_type->As()) { result_component_type = result_vector_type->type(); } @@ -4603,7 +4603,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { // 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()) { + if (texture_type->Is()) { if (is_non_dref_sample || (opcode == SpvOpImageFetch)) { value = create( Source{}, @@ -4631,7 +4631,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { // or vice versa. Perform a bitcast. value = create(Source{}, result_type, call_expr); } - if (!expected_component_type->Is() && + if (!expected_component_type->Is() && 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 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) { } exprs.push_back( create(Source{}, dims_ident, dims_args)); - if (type::IsTextureArray(texture_type->dim())) { + if (sem::IsTextureArray(texture_type->dim())) { auto* layers_ident = create( Source{}, builder_.Symbols().Register("textureNumLayers")); exprs.push_back(create( @@ -4750,14 +4750,14 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( 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 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( if (component_type->is_float_scalar() || component_type->is_integer_scalar()) { num_coords_supplied = 1; - } else if (auto* vec_type = raw_coords.type->As()) { + } else if (auto* vec_type = raw_coords.type->As()) { component_type = vec_type->type(); num_coords_supplied = vec_type->size(); } @@ -4796,7 +4796,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( raw_coords]() -> ast::Expression* { auto* swizzle_type = (num_axes == 1) ? component_type - : create(component_type, num_axes); + : create(component_type, num_axes); auto* swizzle = create( Source{}, raw_coords.expr, PrefixSwizzle(num_axes)); return ToSignedIfUnsigned({swizzle_type, swizzle}).expr; @@ -4830,8 +4830,8 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( ast::Expression* FunctionEmitter::ConvertTexelForStorage( const spvtools::opt::Instruction& inst, TypedExpression texel, - type::Texture* texture_type) { - auto* storage_texture_type = texture_type->As(); + sem::Texture* texture_type) { + auto* storage_texture_type = texture_type->As(); auto* src_type = texel.type; if (!storage_texture_type) { Fail() << "writing to other than storage texture: " << inst.PrettyPrint(); @@ -4848,14 +4848,14 @@ ast::Expression* FunctionEmitter::ConvertTexelForStorage( } const uint32_t dest_count = - dest_type->is_scalar() ? 1 : dest_type->As()->size(); + dest_type->is_scalar() ? 1 : dest_type->As()->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()->size(); + src_type->is_scalar() ? 1 : src_type->As()->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 @@ TypedExpression FunctionEmitter::ToSignedIfUnsigned(TypedExpression value) { if (!value.type || !value.type->is_unsigned_scalar_or_vector()) { return value; } - if (auto* vec_type = value.type->As()) { - auto* new_type = create(i32_, vec_type->size()); + if (auto* vec_type = value.type->As()) { + auto* new_type = create(i32_, vec_type->size()); return {new_type, create( Source{}, new_type, ast::ExpressionList{value.expr})}; } @@ -4976,10 +4976,9 @@ TypedExpression FunctionEmitter::MakeOuterProduct( // Synthesize the result. auto col = MakeOperand(inst, 0); auto row = MakeOperand(inst, 1); - auto* col_ty = col.type->As(); - auto* row_ty = row.type->As(); - auto* result_ty = - parser_impl_.ConvertType(inst.type_id())->As(); + auto* col_ty = col.type->As(); + auto* row_ty = row.type->As(); + auto* result_ty = parser_impl_.ConvertType(inst.type_id())->As(); 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 f0517b2e6f..778de9a829 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -512,7 +512,7 @@ class FunctionEmitter { /// @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 @@ class FunctionEmitter { /// 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 @@ class FunctionEmitter { /// @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 @@ class FunctionEmitter { /// 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 @@ class FunctionEmitter { 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 @@ class FunctionEmitter { 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 8a17c3cf50..f031a0e317 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -231,7 +231,7 @@ ParserImpl::ParserImpl(const std::vector& spv_binary) : Reader(), spv_binary_(spv_binary), fail_stream_(&success_, &errors_), - bool_type_(builder_.create()), + bool_type_(builder_.create()), namer_(fail_stream_), enum_converter_(fail_stream_), tools_context_(kInputEnv) { @@ -289,7 +289,7 @@ Program ParserImpl::program() { 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 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) { 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 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) { switch (spirv_type->kind()) { case spvtools::opt::analysis::Type::kVoid: - return save(builder_.create()); + return save(builder_.create()); case spvtools::opt::analysis::Type::kBool: return save(bool_type_); case spvtools::opt::analysis::Type::kInteger: @@ -350,7 +350,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) { 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()); + return save(builder_.create()); default: break; } @@ -694,11 +694,11 @@ bool ParserImpl::RegisterEntryPoints() { 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::Type* unsigned_ty = builder_.create(); + sem::Type* signed_ty = builder_.create(); + sem::Type* unsigned_ty = builder_.create(); 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 @@ type::Type* ParserImpl::ConvertType( 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(); + return builder_.create(); } 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(ast_elem_ty, num_elem); + auto* this_ty = builder_.create(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( - unsigned_type_for_[ast_elem_ty], num_elem); + auto* other_ty = + builder_.create(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(signed_type_for_[ast_elem_ty], num_elem); + builder_.create(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 @@ type::Type* ParserImpl::ConvertType( if (ast_scalar_ty == nullptr) { return nullptr; } - return builder_.create(ast_scalar_ty, num_rows, num_columns); + return builder_.create(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 @@ type::Type* ParserImpl::ConvertType( if (!ParseArrayDecorations(rtarr_ty, &decorations)) { return nullptr; } - return create(ast_elem_ty, 0, std::move(decorations)); + return create(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 @@ type::Type* ParserImpl::ConvertType( if (remap_buffer_block_type_.count(elem_type_id)) { remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty)); } - return create(ast_elem_ty, static_cast(num_elem), - std::move(decorations)); + return create(ast_elem_ty, static_cast(num_elem), + std::move(decorations)); } bool ParserImpl::ParseArrayDecorations( @@ -840,7 +840,7 @@ bool ParserImpl::ParseArrayDecorations( 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 @@ type::Type* ParserImpl::ConvertType( namer_.SuggestSanitizedName(type_id, "S"); auto name = namer_.GetName(type_id); - auto* result = builder_.create( + auto* result = builder_.create( builder_.Symbols().Register(name), ast_struct); id_to_type_[type_id] = result; if (num_non_writable_members == members.size()) { @@ -957,8 +957,8 @@ type::Type* ParserImpl::ConvertType( 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 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id, ast_storage_class = ast::StorageClass::kStorage; remap_buffer_block_type_.insert(type_id); } - return builder_.create(ast_elem_ty, ast_storage_class); + return builder_.create(ast_elem_ty, ast_storage_class); } bool ParserImpl::RegisterTypes() { @@ -1020,7 +1020,7 @@ bool ParserImpl::EmitScalarSpecConstants() { // 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 @@ bool ParserImpl::EmitScalarSpecConstants() { case SpvOpSpecConstant: { ast_type = ConvertType(inst.type_id()); const uint32_t literal_value = inst.GetSingleWordInOperand(0); - if (ast_type->Is()) { + if (ast_type->Is()) { ast_expr = create( Source{}, create(Source{}, ast_type, static_cast(literal_value))); - } else if (ast_type->Is()) { + } else if (ast_type->Is()) { ast_expr = create( Source{}, create(Source{}, ast_type, static_cast(literal_value))); - } else if (ast_type->Is()) { + } else if (ast_type->Is()) { 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 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id, return; } const auto name = namer_.GetName(type_id); - auto* ast_alias_type = builder_.create( + auto* ast_alias_type = builder_.create( 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 @@ bool ParserImpl::EmitModuleScopeVariables() { 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 @@ bool ParserImpl::EmitModuleScopeVariables() { "SPIR-V type with ID: " << var.type_id(); } - if (!ast_type->Is()) { + if (!ast_type->Is()) { return Fail() << "variable with ID " << var.result_id() << " has non-pointer type " << var.type_id(); } } - auto* ast_store_type = ast_type->As()->type(); - auto ast_storage_class = ast_type->As()->storage_class(); + auto* ast_store_type = ast_type->As()->type(); + auto ast_storage_class = ast_type->As()->storage_class(); ast::Expression* ast_constructor = nullptr; if (var.NumInOperands() > 1) { // SPIR-V initializers are always constants. @@ -1242,7 +1242,7 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize( 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 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id, auto access = read_only_struct_types_.count(type) ? ast::AccessControl::kReadOnly : ast::AccessControl::kReadWrite; - type = builder_.create(access, type); + type = builder_.create(access, type); } for (auto& deco : GetDecorationsFor(id)) { @@ -1298,7 +1298,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id, "SampleMask must be an array of 1 element."; } special_builtins_[id] = spv_builtin; - type = builder_.create(); + type = builder_.create(); break; } default: @@ -1382,25 +1382,25 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { // So canonicalization should map that way too. // Currently "null" is missing from the WGSL parser. // See https://bugs.chromium.org/p/tint/issues/detail?id=34 - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( Source{}, create(source, ast_type, spirv_const->GetU32()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( Source{}, create(source, ast_type, spirv_const->GetS32()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( Source{}, create(source, ast_type, spirv_const->GetFloat()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { const bool value = spirv_const->AsNullConstant() ? false : spirv_const->AsBoolConstant()->value(); @@ -1444,7 +1444,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { 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 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { auto* original_type = type; type = type->UnwrapIfNeeded(); - if (type->Is()) { + if (type->Is()) { return create( Source{}, create(Source{}, type, false)); } - if (type->Is()) { + if (type->Is()) { return create( Source{}, create(Source{}, type, 0u)); } - if (type->Is()) { + if (type->Is()) { return create( Source{}, create(Source{}, type, 0)); } - if (type->Is()) { + if (type->Is()) { return create( Source{}, create(Source{}, type, 0.0f)); } - if (const auto* vec_ty = type->As()) { + if (const auto* vec_ty = type->As()) { 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 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return create(Source{}, type, std::move(ast_components)); } - if (const auto* mat_ty = type->As()) { + if (const auto* mat_ty = type->As()) { // Matrix components are columns auto* column_ty = - builder_.create(mat_ty->type(), mat_ty->rows()); + builder_.create(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 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return create(Source{}, type, std::move(ast_components)); } - if (auto* arr_ty = type->As()) { + if (auto* arr_ty = type->As()) { 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 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return create(Source{}, original_type, std::move(ast_components)); } - if (auto* struct_ty = type->As()) { + if (auto* struct_ty = type->As()) { ast::ExpressionList ast_components; for (auto* member : struct_ty->impl()->members()) { ast_components.emplace_back(MakeNullValue(member->type())); @@ -1513,7 +1513,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return nullptr; } -TypedExpression ParserImpl::MakeNullExpression(type::Type* type) { +TypedExpression ParserImpl::MakeNullExpression(sem::Type* type) { return {type, MakeNullValue(type)}; } @@ -1567,7 +1567,7 @@ TypedExpression ParserImpl::RectifyOperandSignedness( 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 @@ TypedExpression ParserImpl::RectifySecondOperandSignedness( 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 @@ type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst, 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(); - if (other->Is() || other->Is() || - other->Is()) { + auto* i32 = builder_.create(); + if (other->Is() || other->Is() || other->Is()) { return i32; } - auto* vec_ty = other->As(); + auto* vec_ty = other->As(); if (vec_ty) { - return builder_.create(i32, vec_ty->size()); + return builder_.create(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(); - if (other->Is() || other->Is() || - other->Is()) { + auto* u32 = builder_.create(); + if (other->Is() || other->Is() || other->Is()) { return u32; } - auto* vec_ty = other->As(); + auto* vec_ty = other->As(); if (vec_ty) { - return builder_.create(u32, vec_ty->size()); + return builder_.create(u32, vec_ty->size()); } Fail() << "required numeric scalar or vector, but got " << other->type_name(); return nullptr; @@ -1634,7 +1632,7 @@ type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) { 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 @@ ParserImpl::GetSpirvTypeForHandleMemoryObjectDeclaration( 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 @@ type::Pointer* ParserImpl::GetTypeForHandleVar( } // 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( - usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler - : type::SamplerKind::kSampler); + ast_store_type = builder_.create( + 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 @@ type::Pointer* ParserImpl::GetTypeForHandleVar( 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 @@ type::Pointer* ParserImpl::GetTypeForHandleVar( // 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(dim); + ast_store_type = builder_.create(dim); } else if (image_type->is_multisampled()) { // Multisampled textures are never depth textures. - ast_store_type = builder_.create( + ast_store_type = builder_.create( dim, ast_sampled_component_type); } else { - ast_store_type = builder_.create( + ast_store_type = builder_.create( dim, ast_sampled_component_type); } } else { @@ -1944,13 +1942,12 @@ type::Pointer* ParserImpl::GetTypeForHandleVar( ? 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( - access, builder_.create(dim, format, subtype)); + auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types()); + ast_store_type = builder_.create( + access, builder_.create(dim, format, subtype)); } } else { Fail() << "unsupported: UniformConstant variable is not a recognized " @@ -1960,55 +1957,55 @@ type::Pointer* ParserImpl::GetTypeForHandleVar( } // Form the pointer type. - auto* result = builder_.create( + auto* result = builder_.create( 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(); + 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(); - 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(); + 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(); - 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(); + 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(); default: break; } @@ -2016,56 +2013,56 @@ type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) { 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(component_type, 2); + return builder_.create(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(component_type, 4); + return builder_.create(component_type, 4); default: break; diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h index d645b8cf19..3eeee28ee6 100644 --- a/src/reader/spirv/parser_impl.h +++ b/src/reader/spirv/parser_impl.h @@ -61,7 +61,7 @@ using DecorationList = std::vector; /// 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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { /// @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 @@ class ParserImpl : Reader { /// @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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { 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 @@ class ParserImpl : Reader { /// @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 @@ class ParserImpl : Reader { 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 @@ class ParserImpl : Reader { /// 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 @@ class ParserImpl : Reader { 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 @@ class ParserImpl : Reader { std::unordered_set ignored_imports_; // Maps a SPIR-V type ID to the corresponding Tint type. - std::unordered_map id_to_type_; + std::unordered_map id_to_type_; // Maps an unsigned type corresponding to the given signed type. - std::unordered_map signed_type_for_; + std::unordered_map signed_type_for_; // Maps an signed type corresponding to the given unsigned type. - std::unordered_map unsigned_type_for_; + std::unordered_map 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 @@ class ParserImpl : Reader { std::unordered_set remap_buffer_block_type_; // The struct types with only read-only members. - std::unordered_set read_only_struct_types_; + std::unordered_set read_only_struct_types_; // The IDs of scalar spec constants std::unordered_set scalar_spec_constants_; @@ -659,7 +658,7 @@ class ParserImpl : Reader { // usages implied by usages of the memory-object-declaration. std::unordered_map handle_usage_; // The inferred pointer type for the given handle variable. - std::unordered_map + std::unordered_map 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 17600dda73..5957329a61 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 @@ TEST_F(SpvParserTest, ConvertType_Void) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -84,7 +84,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(100); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -93,7 +93,7 @@ TEST_F(SpvParserTest, ConvertType_I32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(2); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -102,7 +102,7 @@ TEST_F(SpvParserTest, ConvertType_U32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -111,7 +111,7 @@ TEST_F(SpvParserTest, ConvertType_F32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(4); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -155,19 +155,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xf32 = p->ConvertType(20); - EXPECT_TRUE(v2xf32->Is()); - EXPECT_TRUE(v2xf32->As()->type()->Is()); - EXPECT_EQ(v2xf32->As()->size(), 2u); + EXPECT_TRUE(v2xf32->Is()); + EXPECT_TRUE(v2xf32->As()->type()->Is()); + EXPECT_EQ(v2xf32->As()->size(), 2u); auto* v3xf32 = p->ConvertType(30); - EXPECT_TRUE(v3xf32->Is()); - EXPECT_TRUE(v3xf32->As()->type()->Is()); - EXPECT_EQ(v3xf32->As()->size(), 3u); + EXPECT_TRUE(v3xf32->Is()); + EXPECT_TRUE(v3xf32->As()->type()->Is()); + EXPECT_EQ(v3xf32->As()->size(), 3u); auto* v4xf32 = p->ConvertType(40); - EXPECT_TRUE(v4xf32->Is()); - EXPECT_TRUE(v4xf32->As()->type()->Is()); - EXPECT_EQ(v4xf32->As()->size(), 4u); + EXPECT_TRUE(v4xf32->Is()); + EXPECT_TRUE(v4xf32->As()->type()->Is()); + EXPECT_EQ(v4xf32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -182,19 +182,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xi32 = p->ConvertType(20); - EXPECT_TRUE(v2xi32->Is()); - EXPECT_TRUE(v2xi32->As()->type()->Is()); - EXPECT_EQ(v2xi32->As()->size(), 2u); + EXPECT_TRUE(v2xi32->Is()); + EXPECT_TRUE(v2xi32->As()->type()->Is()); + EXPECT_EQ(v2xi32->As()->size(), 2u); auto* v3xi32 = p->ConvertType(30); - EXPECT_TRUE(v3xi32->Is()); - EXPECT_TRUE(v3xi32->As()->type()->Is()); - EXPECT_EQ(v3xi32->As()->size(), 3u); + EXPECT_TRUE(v3xi32->Is()); + EXPECT_TRUE(v3xi32->As()->type()->Is()); + EXPECT_EQ(v3xi32->As()->size(), 3u); auto* v4xi32 = p->ConvertType(40); - EXPECT_TRUE(v4xi32->Is()); - EXPECT_TRUE(v4xi32->As()->type()->Is()); - EXPECT_EQ(v4xi32->As()->size(), 4u); + EXPECT_TRUE(v4xi32->Is()); + EXPECT_TRUE(v4xi32->As()->type()->Is()); + EXPECT_EQ(v4xi32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -209,19 +209,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xu32 = p->ConvertType(20); - EXPECT_TRUE(v2xu32->Is()); - EXPECT_TRUE(v2xu32->As()->type()->Is()); - EXPECT_EQ(v2xu32->As()->size(), 2u); + EXPECT_TRUE(v2xu32->Is()); + EXPECT_TRUE(v2xu32->As()->type()->Is()); + EXPECT_EQ(v2xu32->As()->size(), 2u); auto* v3xu32 = p->ConvertType(30); - EXPECT_TRUE(v3xu32->Is()); - EXPECT_TRUE(v3xu32->As()->type()->Is()); - EXPECT_EQ(v3xu32->As()->size(), 3u); + EXPECT_TRUE(v3xu32->Is()); + EXPECT_TRUE(v3xu32->As()->type()->Is()); + EXPECT_EQ(v3xu32->As()->size(), 3u); auto* v4xu32 = p->ConvertType(40); - EXPECT_TRUE(v4xu32->Is()); - EXPECT_TRUE(v4xu32->As()->type()->Is()); - EXPECT_EQ(v4xu32->As()->size(), 4u); + EXPECT_TRUE(v4xu32->Is()); + EXPECT_TRUE(v4xu32->As()->type()->Is()); + EXPECT_EQ(v4xu32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -261,58 +261,58 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) { EXPECT_TRUE(p->BuildInternalModule()); auto* m22 = p->ConvertType(22); - EXPECT_TRUE(m22->Is()); - EXPECT_TRUE(m22->As()->type()->Is()); - EXPECT_EQ(m22->As()->rows(), 2u); - EXPECT_EQ(m22->As()->columns(), 2u); + EXPECT_TRUE(m22->Is()); + EXPECT_TRUE(m22->As()->type()->Is()); + EXPECT_EQ(m22->As()->rows(), 2u); + EXPECT_EQ(m22->As()->columns(), 2u); auto* m23 = p->ConvertType(23); - EXPECT_TRUE(m23->Is()); - EXPECT_TRUE(m23->As()->type()->Is()); - EXPECT_EQ(m23->As()->rows(), 2u); - EXPECT_EQ(m23->As()->columns(), 3u); + EXPECT_TRUE(m23->Is()); + EXPECT_TRUE(m23->As()->type()->Is()); + EXPECT_EQ(m23->As()->rows(), 2u); + EXPECT_EQ(m23->As()->columns(), 3u); auto* m24 = p->ConvertType(24); - EXPECT_TRUE(m24->Is()); - EXPECT_TRUE(m24->As()->type()->Is()); - EXPECT_EQ(m24->As()->rows(), 2u); - EXPECT_EQ(m24->As()->columns(), 4u); + EXPECT_TRUE(m24->Is()); + EXPECT_TRUE(m24->As()->type()->Is()); + EXPECT_EQ(m24->As()->rows(), 2u); + EXPECT_EQ(m24->As()->columns(), 4u); auto* m32 = p->ConvertType(32); - EXPECT_TRUE(m32->Is()); - EXPECT_TRUE(m32->As()->type()->Is()); - EXPECT_EQ(m32->As()->rows(), 3u); - EXPECT_EQ(m32->As()->columns(), 2u); + EXPECT_TRUE(m32->Is()); + EXPECT_TRUE(m32->As()->type()->Is()); + EXPECT_EQ(m32->As()->rows(), 3u); + EXPECT_EQ(m32->As()->columns(), 2u); auto* m33 = p->ConvertType(33); - EXPECT_TRUE(m33->Is()); - EXPECT_TRUE(m33->As()->type()->Is()); - EXPECT_EQ(m33->As()->rows(), 3u); - EXPECT_EQ(m33->As()->columns(), 3u); + EXPECT_TRUE(m33->Is()); + EXPECT_TRUE(m33->As()->type()->Is()); + EXPECT_EQ(m33->As()->rows(), 3u); + EXPECT_EQ(m33->As()->columns(), 3u); auto* m34 = p->ConvertType(34); - EXPECT_TRUE(m34->Is()); - EXPECT_TRUE(m34->As()->type()->Is()); - EXPECT_EQ(m34->As()->rows(), 3u); - EXPECT_EQ(m34->As()->columns(), 4u); + EXPECT_TRUE(m34->Is()); + EXPECT_TRUE(m34->As()->type()->Is()); + EXPECT_EQ(m34->As()->rows(), 3u); + EXPECT_EQ(m34->As()->columns(), 4u); auto* m42 = p->ConvertType(42); - EXPECT_TRUE(m42->Is()); - EXPECT_TRUE(m42->As()->type()->Is()); - EXPECT_EQ(m42->As()->rows(), 4u); - EXPECT_EQ(m42->As()->columns(), 2u); + EXPECT_TRUE(m42->Is()); + EXPECT_TRUE(m42->As()->type()->Is()); + EXPECT_EQ(m42->As()->rows(), 4u); + EXPECT_EQ(m42->As()->columns(), 2u); auto* m43 = p->ConvertType(43); - EXPECT_TRUE(m43->Is()); - EXPECT_TRUE(m43->As()->type()->Is()); - EXPECT_EQ(m43->As()->rows(), 4u); - EXPECT_EQ(m43->As()->columns(), 3u); + EXPECT_TRUE(m43->Is()); + EXPECT_TRUE(m43->As()->type()->Is()); + EXPECT_EQ(m43->As()->rows(), 4u); + EXPECT_EQ(m43->As()->columns(), 3u); auto* m44 = p->ConvertType(44); - EXPECT_TRUE(m44->Is()); - EXPECT_TRUE(m44->As()->type()->Is()); - EXPECT_EQ(m44->As()->rows(), 4u); - EXPECT_EQ(m44->As()->columns(), 4u); + EXPECT_TRUE(m44->Is()); + EXPECT_TRUE(m44->As()->type()->Is()); + EXPECT_EQ(m44->As()->rows(), 4u); + EXPECT_EQ(m44->As()->columns(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -326,15 +326,15 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); 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()); + EXPECT_TRUE(elem_type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -361,7 +361,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - auto* arr_type = type->As(); + auto* arr_type = type->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); ASSERT_EQ(arr_type->decorations().size(), 1u); @@ -409,15 +409,15 @@ TEST_F(SpvParserTest, ConvertType_Array) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); 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()); + EXPECT_TRUE(elem_type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -496,8 +496,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); ASSERT_NE(arr_type, nullptr); ASSERT_EQ(arr_type->decorations().size(), 1u); @@ -550,10 +550,10 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ StructMember{field0: __u32} StructMember{field1: __f32} } @@ -571,10 +571,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ [[block]] StructMember{field0: __u32} } @@ -596,10 +596,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->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 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput); EXPECT_TRUE(p->error().empty()); } @@ -661,10 +661,10 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput); EXPECT_TRUE(p->error().empty()); } @@ -677,10 +677,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform); EXPECT_TRUE(p->error().empty()); } @@ -693,10 +693,10 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup); EXPECT_TRUE(p->error().empty()); } @@ -709,10 +709,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant); EXPECT_TRUE(p->error().empty()); } @@ -725,10 +725,10 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage); EXPECT_TRUE(p->error().empty()); } @@ -741,10 +741,10 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage); EXPECT_TRUE(p->error().empty()); } @@ -757,10 +757,10 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate); EXPECT_TRUE(p->error().empty()); } @@ -773,10 +773,10 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction); EXPECT_TRUE(p->error().empty()); } @@ -792,17 +792,17 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) { auto* type = p->ConvertType(3); EXPECT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); - auto* ptr_ptr_ty = ptr_ty->type()->As(); + auto* ptr_ptr_ty = ptr_ty->type()->As(); EXPECT_NE(ptr_ptr_ty, nullptr); EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput); - EXPECT_TRUE(ptr_ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ptr_ty->type()->Is()); EXPECT_TRUE(p->error().empty()); } @@ -815,7 +815,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -828,7 +828,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -841,7 +841,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 95514e8a54..24cdda8996 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -173,7 +173,7 @@ ParserImpl::FunctionHeader::FunctionHeader(const FunctionHeader&) = default; 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 @@ Token ParserImpl::peek() { } 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 @@ Maybe ParserImpl::variable_decl() { // | 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 ParserImpl::texture_sampler_types() { +Maybe ParserImpl::texture_sampler_types() { auto type = sampler_type(); if (type.matched) return type; @@ -524,7 +524,7 @@ Maybe ParserImpl::texture_sampler_types() { if (subtype.errored) return Failure::kErrored; - return builder_.create(dim.value, subtype.value); + return builder_.create(dim.value, subtype.value); } auto ms_dim = multisampled_texture_type(); @@ -535,8 +535,8 @@ Maybe ParserImpl::texture_sampler_types() { if (subtype.errored) return Failure::kErrored; - return builder_.create(ms_dim.value, - subtype.value); + return builder_.create(ms_dim.value, + subtype.value); } auto storage = storage_texture_type(); @@ -550,9 +550,9 @@ Maybe ParserImpl::texture_sampler_types() { return Failure::kErrored; auto* subtype = - type::StorageTexture::SubtypeFor(format.value, builder_.Types()); - return builder_.create(storage.value, format.value, - subtype); + sem::StorageTexture::SubtypeFor(format.value, builder_.Types()); + return builder_.create(storage.value, format.value, + subtype); } return Failure::kNoMatch; @@ -561,13 +561,12 @@ Maybe ParserImpl::texture_sampler_types() { // sampler_type // : SAMPLER // | SAMPLER_COMPARISON -Maybe ParserImpl::sampler_type() { +Maybe ParserImpl::sampler_type() { if (match(Token::Type::kSampler)) - return builder_.create(type::SamplerKind::kSampler); + return builder_.create(sem::SamplerKind::kSampler); if (match(Token::Type::kComparisonSampler)) - return builder_.create( - type::SamplerKind::kComparisonSampler); + return builder_.create(sem::SamplerKind::kComparisonSampler); return Failure::kNoMatch; } @@ -579,33 +578,33 @@ Maybe ParserImpl::sampler_type() { // | TEXTURE_SAMPLED_3D // | TEXTURE_SAMPLED_CUBE // | TEXTURE_SAMPLED_CUBE_ARRAY -Maybe ParserImpl::sampled_texture_type() { +Maybe 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 ParserImpl::multisampled_texture_type() { +Maybe ParserImpl::multisampled_texture_type() { if (match(Token::Type::kTextureMultisampled2d)) - return type::TextureDimension::k2d; + return sem::TextureDimension::k2d; return Failure::kNoMatch; } @@ -615,15 +614,15 @@ Maybe ParserImpl::multisampled_texture_type() { // | TEXTURE_STORAGE_2D // | TEXTURE_STORAGE_2D_ARRAY // | TEXTURE_STORAGE_3D -Maybe ParserImpl::storage_texture_type() { +Maybe 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 @@ Maybe ParserImpl::storage_texture_type() { // | TEXTURE_DEPTH_2D_ARRAY // | TEXTURE_DEPTH_CUBE // | TEXTURE_DEPTH_CUBE_ARRAY -Maybe ParserImpl::depth_texture_type() { +Maybe ParserImpl::depth_texture_type() { if (match(Token::Type::kTextureDepth2d)) - return builder_.create(type::TextureDimension::k2d); + return builder_.create(sem::TextureDimension::k2d); if (match(Token::Type::kTextureDepth2dArray)) - return builder_.create( - type::TextureDimension::k2dArray); + return builder_.create(sem::TextureDimension::k2dArray); if (match(Token::Type::kTextureDepthCube)) - return builder_.create(type::TextureDimension::kCube); + return builder_.create(sem::TextureDimension::kCube); if (match(Token::Type::kTextureDepthCubeArray)) - return builder_.create( - type::TextureDimension::kCubeArray); + return builder_.create( + sem::TextureDimension::kCubeArray); return Failure::kNoMatch; } @@ -687,112 +685,112 @@ Maybe ParserImpl::depth_texture_type() { // | RGBA32UINT // | RGBA32SINT // | RGBA32FLOAT -Expect ParserImpl::expect_image_storage_type( +Expect 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 @@ Expect ParserImpl::expect_variable_ident_decl( 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( + ty = builder_.create( deco->As()->value(), ty); } @@ -871,7 +869,7 @@ Maybe ParserImpl::variable_storage_decoration() { // type_alias // : TYPE IDENT EQUAL type_decl -Maybe ParserImpl::type_alias() { +Maybe ParserImpl::type_alias() { auto t = peek(); if (!t.IsType()) return Failure::kNoMatch; @@ -893,7 +891,7 @@ Maybe ParserImpl::type_alias() { if (!type.matched) return add_error(peek(), "invalid type alias"); - auto* alias = builder_.create( + auto* alias = builder_.create( builder_.Symbols().Register(name.value), type.value); register_constructed(name.value, alias); @@ -924,7 +922,7 @@ Maybe ParserImpl::type_alias() { // | MAT4x3 LESS_THAN type_decl GREATER_THAN // | MAT4x4 LESS_THAN type_decl GREATER_THAN // | texture_sampler_types -Maybe ParserImpl::type_decl() { +Maybe ParserImpl::type_decl() { auto decos = decoration_list(); if (decos.errored) return Failure::kErrored; @@ -941,7 +939,7 @@ Maybe ParserImpl::type_decl() { return type.value; } -Maybe ParserImpl::type_decl(ast::DecorationList& decos) { +Maybe 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 @@ Maybe ParserImpl::type_decl(ast::DecorationList& decos) { } if (match(Token::Type::kBool)) - return builder_.create(); + return builder_.create(); if (match(Token::Type::kF32)) - return builder_.create(); + return builder_.create(); if (match(Token::Type::kI32)) - return builder_.create(); + return builder_.create(); if (match(Token::Type::kU32)) - return builder_.create(); + return builder_.create(); if (t.IsVec2() || t.IsVec3() || t.IsVec4()) { next(); // Consume the peek @@ -991,7 +989,7 @@ Maybe ParserImpl::type_decl(ast::DecorationList& decos) { return Failure::kNoMatch; } -Expect ParserImpl::expect_type(const std::string& use) { +Expect ParserImpl::expect_type(const std::string& use) { auto type = type_decl(); if (type.errored) return Failure::kErrored; @@ -1000,10 +998,10 @@ Expect ParserImpl::expect_type(const std::string& use) { return type.value; } -Expect ParserImpl::expect_type_decl_pointer() { +Expect ParserImpl::expect_type_decl_pointer() { const char* use = "ptr declaration"; - return expect_lt_gt_block(use, [&]() -> Expect { + return expect_lt_gt_block(use, [&]() -> Expect { auto sc = expect_storage_class(use); if (sc.errored) return Failure::kErrored; @@ -1015,11 +1013,11 @@ Expect ParserImpl::expect_type_decl_pointer() { if (subtype.errored) return Failure::kErrored; - return builder_.create(subtype.value, sc.value); + return builder_.create(subtype.value, sc.value); }); } -Expect ParserImpl::expect_type_decl_vector(Token t) { +Expect ParserImpl::expect_type_decl_vector(Token t) { uint32_t count = 2; if (t.IsVec3()) count = 3; @@ -1032,14 +1030,14 @@ Expect ParserImpl::expect_type_decl_vector(Token t) { if (subtype.errored) return Failure::kErrored; - return builder_.create(subtype.value, count); + return builder_.create(subtype.value, count); } -Expect ParserImpl::expect_type_decl_array( +Expect ParserImpl::expect_type_decl_array( ast::DecorationList decos) { const char* use = "array declaration"; - return expect_lt_gt_block(use, [&]() -> Expect { + return expect_lt_gt_block(use, [&]() -> Expect { auto subtype = expect_type(use); if (subtype.errored) return Failure::kErrored; @@ -1052,11 +1050,11 @@ Expect ParserImpl::expect_type_decl_array( size = val.value; } - return create(subtype.value, size, std::move(decos)); + return create(subtype.value, size, std::move(decos)); }); } -Expect ParserImpl::expect_type_decl_matrix(Token t) { +Expect 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 @@ Expect ParserImpl::expect_type_decl_matrix(Token t) { if (subtype.errored) return Failure::kErrored; - return builder_.create(subtype.value, rows, columns); + return builder_.create(subtype.value, rows, columns); } // storage_class @@ -1121,7 +1119,7 @@ Expect ParserImpl::expect_storage_class( // struct_decl // : struct_decoration_decl* STRUCT IDENT struct_body_decl -Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { +Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { auto t = peek(); auto source = t.source(); @@ -1136,7 +1134,7 @@ Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { if (body.errored) return Failure::kErrored; - return create( + return create( builder_.Symbols().Register(name.value), create(source, std::move(body.value), std::move(decos))); } @@ -1227,9 +1225,9 @@ Maybe ParserImpl::function_decl(ast::DecorationList& decos) { // function_type_decl // : type_decl // | VOID -Maybe ParserImpl::function_type_decl() { +Maybe ParserImpl::function_type_decl() { if (match(Token::Type::kVoid)) - return builder_.create(); + return builder_.create(); return type_decl(); } @@ -1261,7 +1259,7 @@ Maybe ParserImpl::function_header() { } } - type::Type* return_type = nullptr; + sem::Type* return_type = nullptr; ast::DecorationList return_decorations; if (match(Token::Type::kArrow)) { @@ -1282,7 +1280,7 @@ Maybe ParserImpl::function_header() { return_type = type.value; } - if (return_type->Is()) { + if (return_type->Is()) { // 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 ParserImpl::assignment_stmt() { Maybe ParserImpl::const_literal() { auto t = peek(); if (match(Token::Type::kTrue)) { - auto* type = builder_.create(); + auto* type = builder_.create(); return create(Source{}, type, true); } if (match(Token::Type::kFalse)) { - auto* type = builder_.create(); + auto* type = builder_.create(); return create(Source{}, type, false); } if (match(Token::Type::kSintLiteral)) { - auto* type = builder_.create(); + auto* type = builder_.create(); return create(Source{}, type, t.to_i32()); } if (match(Token::Type::kUintLiteral)) { - auto* type = builder_.create(); + auto* type = builder_.create(); return create(Source{}, type, t.to_u32()); } if (match(Token::Type::kFloatLiteral)) { @@ -2747,7 +2745,7 @@ Maybe ParserImpl::const_literal() { next(); // Consume 'f' add_error(p.source(), "float literals must not be suffixed with 'f'"); } - auto* type = builder_.create(); + auto* type = builder_.create(); return create(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 ba756fd0cd..7c7a7e3b87 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -199,7 +199,7 @@ class ParserImpl { /// 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 @@ class ParserImpl { 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 @@ class ParserImpl { /// 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 @@ class ParserImpl { /// 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 @@ class ParserImpl { /// 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 @@ class ParserImpl { Maybe variable_storage_decoration(); /// Parses a `type_alias` grammar element /// @returns the type alias or nullptr on error - Maybe type_alias(); + Maybe type_alias(); /// Parses a `type_decl` grammar element /// @returns the parsed Type or nullptr if none matched. - Maybe type_decl(); + Maybe 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_decl(ast::DecorationList& decos); + Maybe 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 @@ class ParserImpl { /// `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 struct_decl(ast::DecorationList& decos); + Maybe struct_decl(ast::DecorationList& decos); /// Parses a `struct_body_decl` grammar element, erroring on parse failure. /// @returns the struct members Expect expect_struct_body_decl(); @@ -396,31 +396,31 @@ class ParserImpl { Maybe function_decl(ast::DecorationList& decos); /// Parses a `texture_sampler_types` grammar element /// @returns the parsed Type or nullptr if none matched. - Maybe texture_sampler_types(); + Maybe texture_sampler_types(); /// Parses a `sampler_type` grammar element /// @returns the parsed Type or nullptr if none matched. - Maybe sampler_type(); + Maybe sampler_type(); /// Parses a `multisampled_texture_type` grammar element /// @returns returns the multisample texture dimension or kNone if none /// matched. - Maybe multisampled_texture_type(); + Maybe multisampled_texture_type(); /// Parses a `sampled_texture_type` grammar element /// @returns returns the sample texture dimension or kNone if none matched. - Maybe sampled_texture_type(); + Maybe sampled_texture_type(); /// Parses a `storage_texture_type` grammar element /// @returns returns the storage texture dimension. /// Returns kNone if none matched. - Maybe storage_texture_type(); + Maybe storage_texture_type(); /// Parses a `depth_texture_type` grammar element /// @returns the parsed Type or nullptr if none matched. - Maybe depth_texture_type(); + Maybe 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 expect_image_storage_type(const std::string& use); + Expect expect_image_storage_type(const std::string& use); /// Parses a `function_type_decl` grammar element /// @returns the parsed type or nullptr otherwise - Maybe function_type_decl(); + Maybe function_type_decl(); /// Parses a `function_header` grammar element /// @returns the parsed function header Maybe function_header(); @@ -784,12 +784,12 @@ class ParserImpl { /// Used to ensure that all decorations are consumed. bool expect_decorations_consumed(const ast::DecorationList& list); - Expect expect_type_decl_pointer(); - Expect expect_type_decl_vector(Token t); - Expect expect_type_decl_array(ast::DecorationList decos); - Expect expect_type_decl_matrix(Token t); + Expect expect_type_decl_pointer(); + Expect expect_type_decl_vector(Token t); + Expect expect_type_decl_array(ast::DecorationList decos); + Expect expect_type_decl_matrix(Token t); - Expect expect_type(const std::string& use); + Expect expect_type(const std::string& use); Maybe non_block_statement(); Maybe for_header_initializer(); @@ -810,7 +810,7 @@ class ParserImpl { uint32_t sync_depth_ = 0; std::vector sync_tokens_; int silence_errors_ = 0; - std::unordered_map registered_constructs_; + std::unordered_map 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 ee1822bba1..8498ed4e8a 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 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) { ASSERT_TRUE(e->Is()); auto* t = e->As(); - ASSERT_TRUE(t->type()->Is()); - EXPECT_EQ(t->type()->As()->size(), 2u); + ASSERT_TRUE(t->type()->Is()); + EXPECT_EQ(t->type()->As()->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 9113040375..b4ddc85892 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 @@ TEST_F(ParserImplTest, DepthTextureType_2d) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k2d); EXPECT_FALSE(p->has_error()); } @@ -46,9 +46,9 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2dArray); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k2dArray); EXPECT_FALSE(p->has_error()); } @@ -58,9 +58,9 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::kCube); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::kCube); EXPECT_FALSE(p->has_error()); } @@ -70,9 +70,9 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::kCubeArray); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->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 4371bce7f7..97c99f8a72 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 @@ TEST_F(ParserImplTest, FunctionDecl) { EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); 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()); + EXPECT_TRUE(f->return_type()->Is()); auto* body = f->body(); ASSERT_EQ(body->size(), 1u); @@ -62,10 +62,10 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) { EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decorations = f->decorations(); ASSERT_EQ(decorations.size(), 1u); @@ -100,10 +100,10 @@ fn main() { return; })"); EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decorations = f->decorations(); ASSERT_EQ(decorations.size(), 2u); @@ -145,10 +145,10 @@ fn main() { return; })"); EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decos = f->decorations(); ASSERT_EQ(decos.size(), 2u); @@ -187,7 +187,7 @@ TEST_F(ParserImplTest, FunctionDecl_ReturnTypeDecorationList) { EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); 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 c4a064d3ef..fba796e384 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 @@ TEST_F(ParserImplTest, FunctionHeader) { 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()); + EXPECT_TRUE(f->return_type->Is()); } TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) { @@ -42,7 +42,7 @@ TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) { EXPECT_EQ(f->name, "main"); EXPECT_EQ(f->params.size(), 0u); - EXPECT_TRUE(f->return_type->Is()); + EXPECT_TRUE(f->return_type->Is()); ASSERT_EQ(f->return_type_decorations.size(), 1u); auto* loc = f->return_type_decorations[0]->As(); 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 2779849565..f876f5cca5 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 @@ namespace { TEST_F(ParserImplTest, FunctionTypeDecl_Void) { auto p = parser("void"); - auto* v = p->builder().create(); + auto* v = p->builder().create(); auto e = p->function_type_decl(); EXPECT_TRUE(e.matched); @@ -34,8 +34,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) { TEST_F(ParserImplTest, FunctionTypeDecl_Type) { auto p = parser("vec2"); - auto* f32 = p->builder().create(); - auto* vec2 = p->builder().create(f32, 2); + auto* f32 = p->builder().create(); + auto* vec2 = p->builder().create(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 f63a0e028e..0cdfb905c0 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 @@ TEST_F(ParserImplTest, GlobalConstantDecl) { 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()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->source().range.begin.line, 1u); EXPECT_EQ(e->source().range.begin.column, 5u); @@ -115,7 +115,7 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) { 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()); + EXPECT_TRUE(e->declared_type()->Is()); 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 923828ac79..385d3ecaf6 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 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) { auto program = p->program(); ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u); - ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); + ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); EXPECT_EQ( program.Symbols().NameFor( - program.AST().ConstructedTypes()[0]->As()->symbol()), + program.AST().ConstructedTypes()[0]->As()->symbol()), "A"); } @@ -102,12 +102,12 @@ type B = A;)"); auto program = p->program(); ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u); - ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); - auto* str = program.AST().ConstructedTypes()[0]->As(); + ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); + auto* str = program.AST().ConstructedTypes()[0]->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); - ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is()); - auto* alias = program.AST().ConstructedTypes()[1]->As(); + ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is()); + auto* alias = program.AST().ConstructedTypes()[1]->As(); EXPECT_EQ(alias->symbol(), program.Symbols().Get("B")); EXPECT_EQ(alias->type(), str); } @@ -165,9 +165,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); EXPECT_EQ(str->impl()->members().size(), 2u); } @@ -183,16 +183,16 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); 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()); - const auto* arr = ty->As(); + ASSERT_TRUE(ty->Is()); + const auto* arr = ty->As(); ASSERT_EQ(arr->decorations().size(), 1u); auto* stride = arr->decorations()[0]; @@ -210,9 +210,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); 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 b175eea37c..45cf0102d9 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 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -54,7 +54,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -80,7 +80,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) { EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); ASSERT_NE(e->declared_type(), nullptr); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -110,7 +110,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) { EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); ASSERT_NE(e->declared_type(), nullptr); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -180,7 +180,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_SamplerImplicitStorageClass) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s")); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant); } @@ -196,7 +196,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_TextureImplicitStorageClass) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s")); - EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is()); + EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant); } @@ -210,7 +210,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_StorageClassIn_Deprecated) { ASSERT_FALSE(p->has_error()) << p->error(); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kInput); EXPECT_EQ( @@ -231,7 +231,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_StorageClassOut_Deprecated) { ASSERT_FALSE(p->has_error()) << p->error(); EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a")); - EXPECT_TRUE(e->declared_type()->Is()); + EXPECT_TRUE(e->declared_type()->Is()); 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 872df127e0..bf34ed1677 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 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) { 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 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) { 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 4949c38cf2..54e30bdb67 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 @@ namespace { TEST_F(ParserImplTest, ParamList_Single) { auto p = parser("a : i32"); - auto* i32 = p->builder().create(); + auto* i32 = p->builder().create(); auto e = p->expect_param_list(); ASSERT_FALSE(p->has_error()) << p->error(); @@ -42,9 +42,9 @@ TEST_F(ParserImplTest, ParamList_Single) { TEST_F(ParserImplTest, ParamList_Multiple) { auto p = parser("a : i32, b: f32, c: vec2"); - auto* i32 = p->builder().create(); - auto* f32 = p->builder().create(); - auto* vec2 = p->builder().create(f32, 2); + auto* i32 = p->builder().create(); + auto* f32 = p->builder().create(); + auto* vec2 = p->builder().create(f32, 2); auto e = p->expect_param_list(); ASSERT_FALSE(p->has_error()) << p->error(); @@ -100,8 +100,8 @@ TEST_F(ParserImplTest, ParamList_Decorations) { "[[builtin(position)]] coord : vec4, " "[[location(1)]] loc1 : f32"); - auto* f32 = p->builder().create(); - auto* vec4 = p->builder().create(f32, 4); + auto* f32 = p->builder().create(); + auto* vec4 = p->builder().create(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 596c1173f5..884f1c4f14 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_ParenExpr_InvalidExpr) { TEST_F(ParserImplTest, PrimaryExpression_Cast) { auto p = parser("f32(1)"); - auto* f32 = p->builder().create(); + auto* f32 = p->builder().create(); auto e = p->primary_expression(); EXPECT_TRUE(e.matched); @@ -258,7 +258,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) { TEST_F(ParserImplTest, PrimaryExpression_Bitcast) { auto p = parser("bitcast(1)"); - auto* f32 = p->builder().create(); + auto* f32 = p->builder().create(); 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 5c31846697..82550a719d 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 @@ TEST_F(ParserImplTest, SampledTextureType_1d) { 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 @@ TEST_F(ParserImplTest, SampledTextureType_2d) { 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 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) { 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 @@ TEST_F(ParserImplTest, SampledTextureType_3d) { 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 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) { 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 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) { 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 46b3d3bffc..4ec0c01dab 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 @@ TEST_F(ParserImplTest, SamplerType_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + EXPECT_FALSE(t->As()->IsComparison()); EXPECT_FALSE(p->has_error()); } @@ -45,8 +45,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_TRUE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + EXPECT_TRUE(t->As()->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 223c1879a9..cd27e99968 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 @@ TEST_F(ParserImplTest, StorageTextureType_1d) { 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 @@ TEST_F(ParserImplTest, StorageTextureType_2d) { 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 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) { 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 @@ TEST_F(ParserImplTest, StorageTextureType_3d) { 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 16bcf4b13c..d55f5839be 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 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) { auto p = parser("{a : i32;}"); auto& builder = p->builder(); - auto* i32 = builder.create(); + auto* i32 = builder.create(); 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 1cf9aabf18..a4378b95c0 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 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_FALSE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) { @@ -49,8 +49,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) { @@ -60,9 +60,9 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k2d); } TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) { @@ -72,10 +72,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k1d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k1d); } TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) { @@ -85,10 +85,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k2d); } TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) { @@ -98,10 +98,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k3d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k3d); } TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) { @@ -151,10 +151,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k2d); } TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) { @@ -205,11 +205,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), - type::ImageFormat::kR8Unorm); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k1d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), + sem::ImageFormat::kR8Unorm); + EXPECT_EQ(t->As()->dim(), sem::TextureDimension::k1d); } TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) { @@ -220,11 +220,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), - type::ImageFormat::kR16Float); - EXPECT_EQ(t->As()->dim(), type::TextureDimension::k2d); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), + sem::ImageFormat::kR16Float); + EXPECT_EQ(t->As()->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 04a712db84..2cda3c3092 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 @@ namespace { TEST_F(ParserImplTest, TypeDecl_ParsesType) { auto p = parser("type a = i32"); - auto* i32 = p->builder().create(); + auto* i32 = p->builder().create(); 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()); - auto* alias = t->As(); - ASSERT_TRUE(alias->type()->Is()); + ASSERT_TRUE(t->Is()); + auto* alias = t->As(); + ASSERT_TRUE(alias->type()->Is()); 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 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { EXPECT_FALSE(t.errored); EXPECT_TRUE(t.matched); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - auto* alias = t->As(); + ASSERT_TRUE(t->Is()); + auto* alias = t->As(); EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "a"); - ASSERT_TRUE(alias->type()->Is()); + ASSERT_TRUE(alias->type()->Is()); - auto* s = alias->type()->As(); + auto* s = alias->type()->As(); 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 66fc791dfc..ba1b589116 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 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) { auto& builder = p->builder(); - auto* int_type = builder.create(); + auto* int_type = builder.create(); auto* alias_type = - builder.create(builder.Symbols().Register("A"), int_type); + builder.create(builder.Symbols().Register("A"), int_type); p->register_constructed("A", alias_type); @@ -45,9 +45,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, alias_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* alias = t->As(); + auto* alias = t->As(); EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "A"); EXPECT_EQ(alias->type(), int_type); } @@ -67,56 +67,56 @@ TEST_F(ParserImplTest, TypeDecl_Bool) { auto p = parser("bool"); auto& builder = p->builder(); - auto* bool_type = builder.create(); + auto* bool_type = builder.create(); 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()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_F32) { auto p = parser("f32"); auto& builder = p->builder(); - auto* float_type = builder.create(); + auto* float_type = builder.create(); 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()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_I32) { auto p = parser("i32"); auto& builder = p->builder(); - auto* int_type = builder.create(); + auto* int_type = builder.create(); 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()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_U32) { auto p = parser("u32"); auto& builder = p->builder(); - auto* uint_type = builder.create(); + auto* uint_type = builder.create(); 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()); + ASSERT_TRUE(t->Is()); } struct VecData { @@ -138,8 +138,8 @@ TEST_P(VecTest, Parse) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - EXPECT_TRUE(t->Is()); - EXPECT_EQ(t->As()->size(), params.count); + EXPECT_TRUE(t->Is()); + EXPECT_EQ(t->As()->size(), params.count); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, VecTest, @@ -226,10 +226,10 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* ptr = t->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = t->As(); + ASSERT_TRUE(ptr->type()->Is()); ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction); } @@ -240,15 +240,15 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* ptr = t->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = t->As(); + ASSERT_TRUE(ptr->type()->Is()); ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction); - auto* vec = ptr->type()->As(); + auto* vec = ptr->type()->As(); ASSERT_EQ(vec->size(), 2u); - ASSERT_TRUE(vec->type()->Is()); + ASSERT_TRUE(vec->type()->Is()); } TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) { @@ -338,12 +338,12 @@ TEST_F(ParserImplTest, TypeDecl_Array) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); EXPECT_EQ(a->decorations().size(), 0u); } @@ -354,12 +354,12 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); ASSERT_EQ(a->decorations().size(), 1u); auto* stride = a->decorations()[0]; @@ -374,11 +374,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); ASSERT_EQ(a->decorations().size(), 1u); auto* stride = a->decorations()[0]; @@ -393,11 +393,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); auto& decos = a->decorations(); ASSERT_EQ(decos.size(), 2u); @@ -414,11 +414,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); auto& decos = a->decorations(); ASSERT_EQ(decos.size(), 2u); @@ -517,11 +517,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); } TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) { @@ -531,9 +531,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->is_unsigned_integer_vector()); } @@ -628,8 +628,8 @@ TEST_P(MatrixTest, Parse) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - EXPECT_TRUE(t->Is()); - auto* mat = t->As(); + EXPECT_TRUE(t->Is()); + auto* mat = t->As(); EXPECT_EQ(mat->rows(), params.rows); EXPECT_EQ(mat->columns(), params.columns); } @@ -746,32 +746,32 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) { auto p = parser("sampler"); auto& builder = p->builder(); - auto* type = builder.create(type::SamplerKind::kSampler); + auto* type = builder.create(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()); - ASSERT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_FALSE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TypeDecl_Texture) { auto p = parser("texture_cube"); auto& builder = p->builder(); - auto* type = builder.create( - type::TextureDimension::kCube, ty.f32()); + auto* type = builder.create(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()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->type()->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); } } // namespace diff --git a/src/reader/wgsl/parser_impl_variable_decl_test.cc b/src/reader/wgsl/parser_impl_variable_decl_test.cc index 6fd1418ac5..19ed638076 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 @@ TEST_F(ParserImplTest, VariableDecl_Parses) { EXPECT_FALSE(v.errored); EXPECT_EQ(v->name, "my_var"); EXPECT_NE(v->type, nullptr); - EXPECT_TRUE(v->type->Is()); + EXPECT_TRUE(v->type->Is()); EXPECT_EQ(v->source.range.begin.line, 1u); EXPECT_EQ(v->source.range.begin.column, 5u); @@ -62,7 +62,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) { EXPECT_FALSE(v.errored); EXPECT_FALSE(p->has_error()); EXPECT_EQ(v->name, "my_var"); - EXPECT_TRUE(v->type->Is()); + EXPECT_TRUE(v->type->Is()); 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 2f9274f1ee..4efdac3eb9 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 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); + ASSERT_TRUE(decl->type->Is()); ASSERT_EQ(decl->source.range.begin.line, 1u); ASSERT_EQ(decl->source.range.begin.column, 1u); @@ -84,11 +84,10 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Read) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsReadOnly()); - ASSERT_TRUE(decl->type->As() - ->type() - ->Is()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsReadOnly()); + ASSERT_TRUE( + decl->type->As()->type()->Is()); } TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) { @@ -99,11 +98,10 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsWriteOnly()); - ASSERT_TRUE(decl->type->As() - ->type() - ->Is()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsWriteOnly()); + ASSERT_TRUE( + decl->type->As()->type()->Is()); } TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { @@ -127,8 +125,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsReadOnly()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsReadOnly()); } TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { @@ -152,8 +150,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsReadWrite()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsReadWrite()); } TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { diff --git a/src/resolver/assignment_validation_test.cc b/src/resolver/assignment_validation_test.cc index 83dbeec0e9..875e379b71 100644 --- a/src/resolver/assignment_validation_test.cc +++ b/src/resolver/assignment_validation_test.cc @@ -255,12 +255,11 @@ TEST_F(ResolverAssignmentValidationTest, AssignFromPointer_Fail) { // var b : [[access(read)]] texture_storage_1d; // a = b; - auto* tex_type = create( - type::TextureDimension::k1d, type::ImageFormat::kRgba8Unorm, - type::StorageTexture::SubtypeFor(type::ImageFormat::kRgba8Unorm, - Types())); + auto* tex_type = create( + sem::TextureDimension::k1d, sem::ImageFormat::kRgba8Unorm, + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kRgba8Unorm, Types())); auto* tex_ac = - create(ast::AccessControl::kReadOnly, tex_type); + create(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 922e454523..494a36df8d 100644 --- a/src/resolver/builtins_validation_test.cc +++ b/src/resolver/builtins_validation_test.cc @@ -113,50 +113,50 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) { WrapInFunction(Decl(a), builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); - EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) { auto* a = Var("a", ty.vec2(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.i32(), 2), - ast::StorageClass::kFunction), + create(create(ty.i32(), 2), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("frexp", vec2(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) { auto* a = Var("a", ty.vec3(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.i32(), 3), - ast::StorageClass::kFunction), + create(create(ty.i32(), 3), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("frexp", vec3(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) { auto* a = Var("a", ty.vec4(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.i32(), 4), - ast::StorageClass::kFunction), + create(create(ty.i32(), 4), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("frexp", vec4(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) { @@ -167,50 +167,50 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) { WrapInFunction(Decl(a), Decl(b), builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); - EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) { auto* a = Var("a", ty.vec2(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.f32(), 2), - ast::StorageClass::kFunction), + create(create(ty.f32(), 2), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("modf", vec2(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) { auto* a = Var("a", ty.vec3(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.f32(), 3), - ast::StorageClass::kFunction), + create(create(ty.f32(), 3), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("modf", vec3(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) { auto* a = Var("a", ty.vec4(), ast::StorageClass::kFunction); auto* b = Const("b", - create(create(ty.f32(), 4), - ast::StorageClass::kFunction), + create(create(ty.f32(), 4), + ast::StorageClass::kFunction), Expr("a"), {}); auto* builtin = Call("modf", vec4(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()); + EXPECT_TRUE(TypeOf(builtin->params()[1])->Is()); } TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) { @@ -309,7 +309,7 @@ TEST_P(FloatAllMatching, Scalar) { WrapInFunction(builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(FloatAllMatching, Vec2) { @@ -417,7 +417,7 @@ TEST_P(IntegerAllMatching, ScalarUnsigned) { WrapInFunction(builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(IntegerAllMatching, Vec2Unsigned) { @@ -477,7 +477,7 @@ TEST_P(IntegerAllMatching, ScalarSigned) { WrapInFunction(builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(IntegerAllMatching, Vec2Signed) { diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc index cb3455edad..cb4f29f145 100644 --- a/src/resolver/decoration_validation_test.cc +++ b/src/resolver/decoration_validation_test.cc @@ -127,10 +127,9 @@ TEST_P(ArrayDecorationTest, IsValid) { auto& params = GetParam(); ast::StructMemberList members{Member( - "a", - create(ty.f32(), 0, - ast::DecorationList{createDecoration( - Source{{12, 34}}, *this, params.kind)}))}; + "a", create(ty.f32(), 0, + ast::DecorationList{createDecoration( + Source{{12, 34}}, *this, params.kind)}))}; auto* s = create( members, ast::DecorationList{create()}); auto* s_ty = ty.struct_("mystruct", s); @@ -334,10 +333,10 @@ TEST_P(ArrayStrideTest, All) { SCOPED_TRACE(ss.str()); auto* arr = - create(el_ty, 4, - ast::DecorationList{ - create(params.stride), - }); + create(el_ty, 4, + ast::DecorationList{ + create(params.stride), + }); Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput); @@ -422,11 +421,11 @@ INSTANTIATE_TEST_SUITE_P( Params{ty_mat4x4, (default_mat4x4.align - 1) * 7, false})); TEST_F(ArrayStrideTest, MultipleDecorations) { - auto* arr = create(ty.i32(), 4, - ast::DecorationList{ - create(4), - create(4), - }); + auto* arr = create(ty.i32(), 4, + ast::DecorationList{ + create(4), + create(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 60461fbe53..5d96e6b00e 100644 --- a/src/resolver/intrinsic_test.cc +++ b/src/resolver/intrinsic_test.cc @@ -61,7 +61,7 @@ TEST_P(ResolverIntrinsicDerivativeTest, Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); } TEST_P(ResolverIntrinsicDerivativeTest, Vector) { @@ -74,9 +74,9 @@ TEST_P(ResolverIntrinsicDerivativeTest, Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); } TEST_P(ResolverIntrinsicDerivativeTest, MissingParam) { @@ -118,7 +118,7 @@ TEST_P(ResolverIntrinsic, Test) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverIntrinsic, @@ -136,9 +136,9 @@ TEST_P(ResolverIntrinsicTest_FloatMethod, Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_FloatMethod, Scalar) { @@ -152,7 +152,7 @@ TEST_P(ResolverIntrinsicTest_FloatMethod, Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_P(ResolverIntrinsicTest_FloatMethod, MissingParam) { @@ -206,9 +206,9 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) { } 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 @@ class ResolverIntrinsicTest_TextureOperation /// @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(scalar, 2); - case type::TextureDimension::k3d: - case type::TextureDimension::kCube: - case type::TextureDimension::kCubeArray: - return create(scalar, 3); + case sem::TextureDimension::k2d: + case sem::TextureDimension::k2dArray: + return create(scalar, 2); + case sem::TextureDimension::k3d: + case sem::TextureDimension::kCube: + case sem::TextureDimension::kCubeArray: + return create(scalar, 3); default: [=]() { FAIL() << "Unsupported texture dimension: " << dim; }(); } @@ -241,19 +241,19 @@ class ResolverIntrinsicTest_TextureOperation } 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(); + return create(); } if (type == Texture::kI32) { - return create(); + return create(); } - return create(); + return create(); } }; @@ -266,17 +266,17 @@ TEST_P(ResolverIntrinsicTest_StorageTextureOperation, TextureLoadRo) { auto* coords_type = GetCoordsType(dim, ty.i32()); - auto* subtype = type::StorageTexture::SubtypeFor(format, Types()); - auto* texture_type = create(dim, format, subtype); + auto* subtype = sem::StorageTexture::SubtypeFor(format, Types()); + auto* texture_type = create(dim, format, subtype); auto* ro_texture_type = - create(ast::AccessControl::kReadOnly, texture_type); + create(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 @@ TEST_P(ResolverIntrinsicTest_StorageTextureOperation, TextureLoadRo) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); if (type == Texture::kF32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else if (type == Texture::kI32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + EXPECT_EQ(TypeOf(expr)->As()->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 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) { 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(dim, s); + auto* texture_type = create(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 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); if (type == Texture::kF32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else if (type == Texture::kI32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + EXPECT_EQ(TypeOf(expr)->As()->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(), ast::StorageClass::kInput); @@ -379,7 +379,7 @@ TEST_F(ResolverIntrinsicTest, Dot_Vec2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverIntrinsicTest, Dot_Vec3) { @@ -391,7 +391,7 @@ TEST_F(ResolverIntrinsicTest, Dot_Vec3) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverIntrinsicTest, Dot_Vec4) { @@ -403,7 +403,7 @@ TEST_F(ResolverIntrinsicTest, Dot_Vec4) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverIntrinsicTest, Dot_Error_Scalar) { @@ -448,9 +448,9 @@ TEST_F(ResolverIntrinsicTest, Select) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } TEST_F(ResolverIntrinsicTest, Select_Error_NoParams) { @@ -550,7 +550,7 @@ TEST_P(ResolverIntrinsicTest_Barrier, InferType) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_Barrier, Error_TooManyParams) { @@ -585,7 +585,7 @@ TEST_P(ResolverIntrinsicTest_DataPacking, InferType) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_DataPacking, Error_IncorrectParamType) { @@ -657,9 +657,9 @@ TEST_P(ResolverIntrinsicTest_DataUnpacking, InferType) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); if (pack4) { - EXPECT_EQ(TypeOf(call)->As()->size(), 4u); + EXPECT_EQ(TypeOf(call)->As()->size(), 4u); } else { - EXPECT_EQ(TypeOf(call)->As()->size(), 2u); + EXPECT_EQ(TypeOf(call)->As()->size(), 2u); } } @@ -696,7 +696,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam, Error_NoParams) { @@ -771,7 +771,7 @@ TEST_F(ResolverIntrinsicDataTest, ArrayLength_Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicDataTest, ArrayLength_Error_ArraySized) { @@ -795,7 +795,7 @@ TEST_F(ResolverIntrinsicDataTest, Normalize_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_F(ResolverIntrinsicDataTest, Normalize_Error_NoParams) { @@ -818,7 +818,7 @@ TEST_F(ResolverIntrinsicDataTest, FrexpScalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicDataTest, FrexpVector) { @@ -829,8 +829,8 @@ TEST_F(ResolverIntrinsicDataTest, FrexpVector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverIntrinsicDataTest, Frexp_Error_FirstParamInt) { @@ -901,7 +901,7 @@ TEST_F(ResolverIntrinsicDataTest, ModfScalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicDataTest, ModfVector) { @@ -912,8 +912,8 @@ TEST_F(ResolverIntrinsicDataTest, ModfVector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverIntrinsicDataTest, Modf_Error_FirstParamInt) { @@ -996,7 +996,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Float_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Scalar) { @@ -1008,7 +1008,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Vector) { @@ -1021,7 +1021,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Scalar) { @@ -1033,7 +1033,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Vector) { @@ -1046,7 +1046,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Error_NoParams) { @@ -1116,7 +1116,7 @@ TEST_P(ResolverIntrinsicTest_TwoParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_TwoParam, Error_NoTooManyParams) { @@ -1179,7 +1179,7 @@ TEST_F(ResolverIntrinsicTest, Distance_Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicTest, Cross) { @@ -1191,7 +1191,7 @@ TEST_F(ResolverIntrinsicTest, Cross) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_F(ResolverIntrinsicTest, Cross_Error_NoArgs) { @@ -1273,7 +1273,7 @@ TEST_F(ResolverIntrinsicTest, Normalize) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_F(ResolverIntrinsicTest, Normalize_NoArgs) { @@ -1313,7 +1313,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam, Error_NoParams) { auto param = GetParam(); @@ -1365,7 +1365,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Float_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Scalar) { @@ -1377,7 +1377,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Vector) { @@ -1391,7 +1391,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Scalar) { @@ -1403,7 +1403,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Vector) { @@ -1417,7 +1417,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Error_NoParams) { @@ -1468,7 +1468,7 @@ TEST_P(ResolverIntrinsicTest_Int_SingleParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_Int_SingleParam, Error_NoParams) { @@ -1506,7 +1506,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Signed) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Unsigned) { @@ -1518,7 +1518,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Unsigned) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Float) { @@ -1530,7 +1530,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Scalar_Float) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Signed) { @@ -1543,7 +1543,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Signed) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Unsigned) { @@ -1556,7 +1556,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Unsigned) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Float) { @@ -1570,7 +1570,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Float) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->size(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Error_NoParams) { @@ -1606,7 +1606,7 @@ TEST_F(ResolverIntrinsicTest, Determinant_2x2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicTest, Determinant_3x3) { @@ -1618,7 +1618,7 @@ TEST_F(ResolverIntrinsicTest, Determinant_3x3) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicTest, Determinant_4x4) { @@ -1630,7 +1630,7 @@ TEST_F(ResolverIntrinsicTest, Determinant_4x4) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverIntrinsicTest, Determinant_NotSquare) { @@ -1933,16 +1933,16 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) { 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()->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()->type_name()); break; } @@ -1960,8 +1960,8 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) { case ast::intrinsic::test::TextureKind::kMultisampled: case ast::intrinsic::test::TextureKind::kStorage: { auto* datatype = param.resultVectorComponentType(this); - ASSERT_TRUE(TypeOf(call)->Is()); - EXPECT_EQ(TypeOf(call)->As()->type(), datatype); + ASSERT_TRUE(TypeOf(call)->Is()); + EXPECT_EQ(TypeOf(call)->As()->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 8f1d802d6a..707e1daff2 100644 --- a/src/resolver/is_host_shareable_test.cc +++ b/src/resolver/is_host_shareable_test.cc @@ -89,12 +89,12 @@ TEST_F(ResolverIsHostShareable, AliasI32) { TEST_F(ResolverIsHostShareable, AccessControlVoid) { EXPECT_FALSE(r()->IsHostShareable( - create(ast::AccessControl::kReadOnly, ty.void_()))); + create(ast::AccessControl::kReadOnly, ty.void_()))); } TEST_F(ResolverIsHostShareable, AccessControlI32) { EXPECT_TRUE(r()->IsHostShareable( - create(ast::AccessControl::kReadOnly, ty.i32()))); + create(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 7f40f0fe34..f0d15c1b37 100644 --- a/src/resolver/is_storeable_test.cc +++ b/src/resolver/is_storeable_test.cc @@ -73,12 +73,12 @@ TEST_F(ResolverIsStorableTest, AliasI32) { TEST_F(ResolverIsStorableTest, AccessControlVoid) { EXPECT_FALSE(r()->IsStorable( - create(ast::AccessControl::kReadOnly, ty.void_()))); + create(ast::AccessControl::kReadOnly, ty.void_()))); } TEST_F(ResolverIsStorableTest, AccessControlI32) { EXPECT_TRUE(r()->IsStorable( - create(ast::AccessControl::kReadOnly, ty.i32()))); + create(ast::AccessControl::kReadOnly, ty.i32()))); } TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) { diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 75b622445e..56ce2a7f91 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -117,16 +117,15 @@ bool Resolver::Resolve() { } // 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->Is()) { + if (type->is_scalar() || type->Is() || type->Is()) { return true; } - if (type::ArrayType* arr = type->As()) { + if (sem::ArrayType* arr = type->As()) { return IsStorable(arr->type()); } - if (type::StructType* str = type->As()) { + if (sem::StructType* str = type->As()) { for (const auto* member : str->impl()->members()) { if (!IsStorable(member->type())) { return false; @@ -138,21 +137,21 @@ bool Resolver::IsStorable(type::Type* type) { } // 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()) { + if (type->IsAnyOf()) { return true; } - if (auto* vec = type->As()) { + if (auto* vec = type->As()) { return IsHostShareable(vec->type()); } - if (auto* mat = type->As()) { + if (auto* mat = type->As()) { return IsHostShareable(mat->type()); } - if (auto* arr = type->As()) { + if (auto* arr = type->As()) { return IsHostShareable(arr->type()); } - if (auto* str = type->As()) { + if (auto* str = type->As()) { for (auto* member : str->impl()->members()) { if (!IsHostShareable(member->type())) { return false; @@ -163,7 +162,7 @@ bool Resolver::IsHostShareable(type::Type* type) { 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 @@ bool Resolver::ResolveInternal() { // 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()) { + if (auto* ty = decl->As()) { if (!Type(ty)) { return false; } @@ -209,7 +208,7 @@ bool Resolver::ResolveInternal() { if (marked_.count(node) == 0) { if (node->Is()) { // 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 @@ bool Resolver::ResolveInternal() { return true; } -bool Resolver::Type(type::Type* ty) { +bool Resolver::Type(sem::Type* ty) { ty = ty->UnwrapAliasIfNeeded(); - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { if (!Structure(str)) { return false; } - } else if (auto* arr = ty->As()) { + } else if (auto* arr = ty->As()) { if (!Array(arr, Source{})) { return false; } @@ -237,7 +236,7 @@ bool Resolver::Type(type::Type* ty) { } 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 @@ Resolver::VariableInfo* Resolver::Variable(ast::Variable* var, variable_to_info_.emplace(var, info); // Resolve variable's type - if (auto* arr = info->type->As()) { + if (auto* arr = info->type->As()) { if (!Array(arr, var->source())) { return nullptr; } @@ -330,8 +329,8 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { // store type must be a host-shareable structure type with block attribute, // satisfying the storage class constraints. - auto* access = info->type->As(); - auto* str = access ? access->type()->As() : nullptr; + auto* access = info->type->As(); + auto* str = access ? access->type()->As() : nullptr; if (!str) { diagnostics_.add_error( "variables declared in the storage class must be of an " @@ -358,7 +357,7 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { bool Resolver::ValidateVariable(const ast::Variable* var) { auto* type = variable_to_info_[var]->type; - if (auto* r = type->UnwrapAll()->As()) { + if (auto* r = type->UnwrapAll()->As()) { if (r->IsRuntimeArray()) { diagnostics_.add_error( "v-0015", @@ -390,7 +389,7 @@ bool Resolver::ValidateFunction(const ast::Function* func) { } } - if (!func->return_type()->Is()) { + if (!func->return_type()->Is()) { if (func->body()) { if (!func->get_last_statement() || !func->get_last_statement()->Is()) { @@ -466,7 +465,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { }; // 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 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { } // Check that we saw a pipeline IO attribute iff we need one. - if (Canonical(ty)->Is()) { + if (Canonical(ty)->Is()) { if (pipeline_io_attribute) { diagnostics_.add_error( "entry point IO attributes must not be used on structure " + @@ -547,7 +546,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { // 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 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { return false; } - if (auto* struct_ty = Canonical(ty)->As()) { + if (auto* struct_ty = Canonical(ty)->As()) { // 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()) { + if (member_ty->Is()) { diagnostics_.add_error( "entry point IO types cannot contain nested structures", member->source()); @@ -568,7 +567,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { builder_->Symbols().NameFor(func->symbol()), func->source()); return false; - } else if (auto* arr = member_ty->As()) { + } else if (auto* arr = member_ty->As()) { if (arr->IsRuntimeArray()) { diagnostics_.add_error( "entry point IO types cannot contain runtime sized arrays", @@ -603,7 +602,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { } } - if (!func->return_type()->Is()) { + if (!func->return_type()->Is()) { builtins.clear(); locations.clear(); if (!validate_entry_point_decorations(func->return_type_decorations(), @@ -646,7 +645,7 @@ bool Resolver::Function(ast::Function* func) { return false; } - if (auto* str = param_info->type->As()) { + if (auto* str = param_info->type->As()) { auto* info = Structure(str); if (!info) { return false; @@ -670,7 +669,7 @@ bool Resolver::Function(ast::Function* func) { } } - if (auto* str = Canonical(func->return_type())->As()) { + if (auto* str = Canonical(func->return_type())->As()) { if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str, func->source())) { diagnostics_.add_note("while instantiating return type for " + @@ -945,13 +944,13 @@ bool Resolver::ArrayAccessor(ast::ArrayAccessorExpression* expr) { auto* res = TypeOf(expr->array()); auto* parent_type = res->UnwrapAll(); - type::Type* ret = nullptr; - if (auto* arr = parent_type->As()) { + sem::Type* ret = nullptr; + if (auto* arr = parent_type->As()) { ret = arr->type(); - } else if (auto* vec = parent_type->As()) { + } else if (auto* vec = parent_type->As()) { ret = vec->type(); - } else if (auto* mat = parent_type->As()) { - ret = builder_->create(mat->type(), mat->rows()); + } else if (auto* mat = parent_type->As()) { + ret = builder_->create(mat->type(), mat->rows()); } else { diagnostics_.add_error("invalid parent type (" + parent_type->type_name() + ") in array accessor", @@ -960,13 +959,13 @@ bool Resolver::ArrayAccessor(ast::ArrayAccessorExpression* expr) { } // If we're extracting from a pointer, we return a pointer. - if (auto* ptr = res->As()) { - ret = builder_->create(ret, ptr->storage_class()); - } else if (auto* arr = parent_type->As()) { + if (auto* ptr = res->As()) { + ret = builder_->create(ret, ptr->storage_class()); + } else if (auto* arr = parent_type->As()) { 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(ret, ast::StorageClass::kFunction); + ret = builder_->create(ret, ast::StorageClass::kFunction); } } SetType(expr, ret); @@ -1055,7 +1054,7 @@ bool Resolver::Call(ast::CallExpression* call) { bool Resolver::IntrinsicCall(ast::CallExpression* call, sem::IntrinsicType intrinsic_type) { - std::vector arg_tys; + std::vector arg_tys; arg_tys.reserve(call->params().size()); for (auto* expr : call->params()) { arg_tys.emplace_back(TypeOf(expr)); @@ -1088,10 +1087,10 @@ bool Resolver::Constructor(ast::ConstructorExpression* expr) { // 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()) { + if (auto* vec_type = type_ctor->type()->As()) { return ValidateVectorConstructor(vec_type, type_ctor->values()); } - if (auto* mat_type = type_ctor->type()->As()) { + if (auto* mat_type = type_ctor->type()->As()) { return ValidateMatrixConstructor(mat_type, type_ctor->values()); } // TODO(crbug.com/tint/634): Validate array constructor @@ -1104,12 +1103,12 @@ bool Resolver::Constructor(ast::ConstructorExpression* expr) { 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 @@ bool Resolver::ValidateVectorConstructor(const type::Vector* vec_type, } value_cardinality_sum++; - } else if (auto* value_vec = value_type->As()) { - type::Type* value_elem_type = value_vec->type()->UnwrapAll(); + } else if (auto* value_vec = value_type->As()) { + 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 @@ bool Resolver::ValidateVectorConstructor(const type::Vector* vec_type, 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 @@ bool Resolver::ValidateMatrixConstructor(const type::Matrix* matrix_type, } for (auto* value : values) { - type::Type* value_type = TypeOf(value)->UnwrapAll(); - auto* value_vec = value_type->As(); + sem::Type* value_type = TypeOf(value)->UnwrapAll(); + auto* value_vec = value_type->As(); if (!value_vec || value_vec->size() != matrix_type->rows() || elem_type != value_vec->type()->UnwrapAll()) { @@ -1220,11 +1219,11 @@ bool Resolver::Identifier(ast::IdentifierExpression* expr) { // the pointer around the variable type. if (var->declaration->is_const()) { SetType(expr, var->type); - } else if (var->type->Is()) { + } else if (var->type->Is()) { SetType(expr, var->type); } else { SetType(expr, - builder_->create(var->type, var->storage_class)); + builder_->create(var->type, var->storage_class)); } var->users.push_back(expr); @@ -1293,10 +1292,10 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { auto* res = TypeOf(expr->structure()); auto* data_type = res->UnwrapPtrIfNeeded()->UnwrapIfNeeded(); - type::Type* ret = nullptr; + sem::Type* ret = nullptr; std::vector swizzle; - if (auto* ty = data_type->As()) { + if (auto* ty = data_type->As()) { Mark(expr->member()); auto symbol = expr->member()->symbol(); auto* str = Structure(ty); @@ -1318,13 +1317,13 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { } // If we're extracting from a pointer, we return a pointer. - if (auto* ptr = res->As()) { - ret = builder_->create(ret, ptr->storage_class()); + if (auto* ptr = res->As()) { + ret = builder_->create(ret, ptr->storage_class()); } builder_->Sem().Add(expr, builder_->create( expr, ret, current_statement_, member)); - } else if (auto* vec = data_type->As()) { + } else if (auto* vec = data_type->As()) { Mark(expr->member()); std::string str = builder_->Symbols().NameFor(expr->member()->symbol()); auto size = str.size(); @@ -1381,14 +1380,14 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { // 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()) { - ret = builder_->create(ret, ptr->storage_class()); + if (auto* ptr = res->As()) { + ret = builder_->create(ret, ptr->storage_class()); } } else { // The vector will have a number of components equal to the length of // the swizzle. - ret = builder_->create(vec->type(), - static_cast(size)); + ret = builder_->create(vec->type(), + static_cast(size)); } builder_->Sem().Add( expr, builder_->create(expr, ret, current_statement_, @@ -1407,12 +1406,12 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { } 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 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() || expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() || expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) { - auto* bool_type = builder_->create(); + auto* bool_type = builder_->create(); auto* param_type = TypeOf(expr->lhs())->UnwrapAll(); - type::Type* result_type = bool_type; - if (auto* vec = param_type->As()) { - result_type = builder_->create(bool_type, vec->size()); + sem::Type* result_type = bool_type; + if (auto* vec = param_type->As()) { + result_type = builder_->create(bool_type, vec->size()); } SetType(expr, result_type); return true; @@ -1607,20 +1606,20 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { // Note, the ordering here matters. The later checks depend on the prior // checks having been done. - auto* lhs_mat = lhs_type->As(); - auto* rhs_mat = rhs_type->As(); - auto* lhs_vec = lhs_type->As(); - auto* rhs_vec = rhs_type->As(); - type::Type* result_type; + auto* lhs_mat = lhs_type->As(); + auto* rhs_mat = rhs_type->As(); + auto* lhs_vec = lhs_type->As(); + auto* rhs_vec = rhs_type->As(); + sem::Type* result_type; if (lhs_mat && rhs_mat) { - result_type = builder_->create( + result_type = builder_->create( lhs_mat->type(), lhs_mat->rows(), rhs_mat->columns()); } else if (lhs_mat && rhs_vec) { result_type = - builder_->create(lhs_mat->type(), lhs_mat->rows()); + builder_->create(lhs_mat->type(), lhs_mat->rows()); } else if (lhs_vec && rhs_mat) { result_type = - builder_->create(rhs_mat->type(), rhs_mat->columns()); + builder_->create(rhs_mat->type(), rhs_mat->columns()); } else if (lhs_mat) { // matrix * scalar result_type = lhs_type; @@ -1665,7 +1664,7 @@ bool Resolver::VariableDeclStatement(const ast::VariableDeclStatement* stmt) { 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 @@ bool Resolver::VariableDeclStatement(const ast::VariableDeclStatement* stmt) { 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 @@ type::Type* Resolver::TypeOf(ast::Expression* expr) { 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 @@ void Resolver::CreateSemanticNodes() const { } } -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 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, align = 4; size = 4; return true; - } else if (auto* vec = cty->As()) { + } else if (auto* vec = cty->As()) { if (vec->size() < 2 || vec->size() > 4) { TINT_UNREACHABLE(diagnostics_) << "Invalid vector size: vec" << vec->size(); @@ -1899,7 +1898,7 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, align = vector_align[vec->size()]; size = vector_size[vec->size()]; return true; - } else if (auto* mat = cty->As()) { + } else if (auto* mat = cty->As()) { if (mat->columns() < 2 || mat->columns() > 4 || mat->rows() < 2 || mat->rows() > 4) { TINT_UNREACHABLE(diagnostics_) @@ -1909,16 +1908,16 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, align = vector_align[mat->rows()]; size = vector_align[mat->rows()] * mat->columns(); return true; - } else if (auto* s = cty->As()) { + } else if (auto* s = cty->As()) { if (auto* si = Structure(s)) { align = si->align; size = si->size; return true; } return false; - } else if (cty->Is()) { + } else if (cty->Is()) { if (auto* sem = - Array(ty->UnwrapAliasIfNeeded()->As(), source)) { + Array(ty->UnwrapAliasIfNeeded()->As(), source)) { align = sem->Align(); size = sem->Size(); return true; @@ -1929,7 +1928,7 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, 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 @@ const sem::Array* Resolver::Array(type::ArrayType* arr, const Source& source) { 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()) { + if (auto* r = member->type()->UnwrapAll()->As()) { if (r->IsRuntimeArray()) { if (member != st->impl()->members().back()) { diagnostics_.add_error( @@ -2053,7 +2052,7 @@ bool Resolver::ValidateStructure(const type::StructType* st) { 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 @@ Resolver::StructInfo* Resolver::Structure(type::StructType* str) { } 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 @@ bool Resolver::ValidateAssignment(const ast::AssignmentStatement* a) { // lhs must be a pointer or a constant auto* lhs_result_type = TypeOf(lhs)->UnwrapIfNeeded(); - if (!lhs_result_type->Is()) { + if (!lhs_result_type->Is()) { // 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()) { @@ -2365,11 +2364,11 @@ bool Resolver::Assignment(ast::AssignmentStatement* a) { } bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc, - type::Type* ty, + sem::Type* ty, const Source& usage) { ty = ty->UnwrapIfNeeded(); - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { auto* info = Structure(str); if (!info) { return false; @@ -2391,7 +2390,7 @@ bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc, return true; } - if (auto* arr = ty->As()) { + if (auto* arr = ty->As()) { return ApplyStorageClassUsageToType(sc, arr->type(), usage); } @@ -2419,20 +2418,20 @@ bool Resolver::BlockScope(const ast::BlockStatement* block, 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 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()) { @@ -2470,7 +2469,7 @@ void Resolver::Mark(ast::Node* node) { << "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 740ebfaf53..23f8d6e82e 100644 --- a/src/resolver/resolver.h +++ b/src/resolver/resolver.h @@ -49,9 +49,9 @@ namespace sem { class Array; class Statement; } // namespace sem -namespace type { -class Struct; -} // namespace type +namespace sem { +class StructType; +} // namespace sem namespace resolver { @@ -73,34 +73,34 @@ class Resolver { /// @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>>>)` is /// `vec3`. - 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 users; }; @@ -124,7 +124,7 @@ class Resolver { /// 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 @@ class Resolver { /// @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 @@ class Resolver { 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 @@ class Resolver { 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 @@ class Resolver { /// 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 @@ class Resolver { /// 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 @@ class Resolver { /// @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 @@ class Resolver { std::unordered_map variable_to_info_; std::unordered_map function_calls_; std::unordered_map expr_info_; - std::unordered_map struct_info_; - std::unordered_map type_to_canonical_; + std::unordered_map struct_info_; + std::unordered_map type_to_canonical_; std::unordered_set 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 ffd7bb9b6c..47f8654739 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -67,8 +67,8 @@ TEST_F(ResolverTest, Stmt_Assign) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); } @@ -89,8 +89,8 @@ TEST_F(ResolverTest, Stmt_Case) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(BlockOf(assign), block); @@ -109,8 +109,8 @@ TEST_F(ResolverTest, Stmt_Block) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(BlockOf(lhs), block); @@ -145,11 +145,11 @@ TEST_F(ResolverTest, Stmt_If) { ASSERT_NE(TypeOf(else_rhs), nullptr); ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(stmt->condition())->Is()); - EXPECT_TRUE(TypeOf(else_lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(else_rhs)->Is()); - EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(stmt->condition())->Is()); + EXPECT_TRUE(TypeOf(else_lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(else_rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(StmtOf(cond), stmt); @@ -181,10 +181,10 @@ TEST_F(ResolverTest, Stmt_Loop) { 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()); - EXPECT_TRUE(TypeOf(body_rhs)->Is()); - EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(continuing_rhs)->Is()); + EXPECT_TRUE(TypeOf(body_lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(body_rhs)->Is()); + EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(continuing_rhs)->Is()); EXPECT_EQ(BlockOf(body_lhs), body); EXPECT_EQ(BlockOf(body_rhs), body); EXPECT_EQ(BlockOf(continuing_lhs), continuing); @@ -200,7 +200,7 @@ TEST_F(ResolverTest, Stmt_Return) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(cond), nullptr); - EXPECT_TRUE(TypeOf(cond)->Is()); + EXPECT_TRUE(TypeOf(cond)->Is()); } TEST_F(ResolverTest, Stmt_Return_WithoutValue) { @@ -224,9 +224,9 @@ TEST_F(ResolverTest, Stmt_Switch) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(stmt->condition())->Is()); - EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(stmt->condition())->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(BlockOf(lhs), case_block); EXPECT_EQ(BlockOf(rhs), case_block); } @@ -244,7 +244,7 @@ TEST_F(ResolverTest, Stmt_Call) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); EXPECT_EQ(StmtOf(expr), call); } @@ -258,7 +258,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); } TEST_F(ResolverTest, Stmt_VariableDecl_Alias) { @@ -272,7 +272,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); } TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) { @@ -282,7 +282,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); EXPECT_EQ(StmtOf(init), nullptr); } @@ -327,13 +327,13 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(foo_i32_init), nullptr); - EXPECT_TRUE(TypeOf(foo_i32_init)->Is()); + EXPECT_TRUE(TypeOf(foo_i32_init)->Is()); ASSERT_NE(TypeOf(foo_f32_init), nullptr); - EXPECT_TRUE(TypeOf(foo_f32_init)->Is()); + EXPECT_TRUE(TypeOf(foo_f32_init)->Is()); ASSERT_NE(TypeOf(bar_i32_init), nullptr); - EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapAll()->Is()); ASSERT_NE(TypeOf(bar_f32_init), nullptr); - EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapAll()->Is()); 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 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mod_init), nullptr); - EXPECT_TRUE(TypeOf(mod_init)->Is()); + EXPECT_TRUE(TypeOf(mod_init)->Is()); ASSERT_NE(TypeOf(fn_i32_init), nullptr); - EXPECT_TRUE(TypeOf(fn_i32_init)->Is()); + EXPECT_TRUE(TypeOf(fn_i32_init)->Is()); ASSERT_NE(TypeOf(fn_f32_init), nullptr); - EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapAll()->Is()); + EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapAll()->Is()); 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 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Array) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - ASSERT_TRUE(TypeOf(acc)->Is()); + ASSERT_TRUE(TypeOf(acc)->Is()); - auto* ptr = TypeOf(acc)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(acc)->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(ResolverTest, Expr_ArrayAccessor_Alias_Array) { @@ -420,10 +420,10 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Alias_Array) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - ASSERT_TRUE(TypeOf(acc)->Is()); + ASSERT_TRUE(TypeOf(acc)->Is()); - auto* ptr = TypeOf(acc)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(acc)->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(ResolverTest, Expr_ArrayAccessor_Array_Constant) { @@ -435,7 +435,7 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Array_Constant) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - EXPECT_TRUE(TypeOf(acc)->Is()) << TypeOf(acc)->type_name(); + EXPECT_TRUE(TypeOf(acc)->Is()) << TypeOf(acc)->type_name(); } TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix) { @@ -447,11 +447,11 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - ASSERT_TRUE(TypeOf(acc)->Is()); + ASSERT_TRUE(TypeOf(acc)->Is()); - auto* ptr = TypeOf(acc)->As(); - ASSERT_TRUE(ptr->type()->Is()); - EXPECT_EQ(ptr->type()->As()->size(), 3u); + auto* ptr = TypeOf(acc)->As(); + ASSERT_TRUE(ptr->type()->Is()); + EXPECT_EQ(ptr->type()->As()->size(), 3u); } TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix_BothDimensions) { @@ -463,10 +463,10 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix_BothDimensions) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - ASSERT_TRUE(TypeOf(acc)->Is()); + ASSERT_TRUE(TypeOf(acc)->Is()); - auto* ptr = TypeOf(acc)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(acc)->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(ResolverTest, Expr_ArrayAccessor_Vector) { @@ -478,10 +478,10 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - ASSERT_TRUE(TypeOf(acc)->Is()); + ASSERT_TRUE(TypeOf(acc)->Is()); - auto* ptr = TypeOf(acc)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(acc)->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(ResolverTest, Expr_Bitcast) { @@ -493,7 +493,7 @@ TEST_F(ResolverTest, Expr_Bitcast) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(bitcast), nullptr); - EXPECT_TRUE(TypeOf(bitcast)->Is()); + EXPECT_TRUE(TypeOf(bitcast)->Is()); } TEST_F(ResolverTest, Expr_Call) { @@ -507,7 +507,7 @@ TEST_F(ResolverTest, Expr_Call) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Call_InBinaryOp) { @@ -521,7 +521,7 @@ TEST_F(ResolverTest, Expr_Call_InBinaryOp) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverTest, Expr_Call_WithParams) { @@ -537,7 +537,7 @@ TEST_F(ResolverTest, Expr_Call_WithParams) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(param), nullptr); - EXPECT_TRUE(TypeOf(param)->Is()); + EXPECT_TRUE(TypeOf(param)->Is()); } TEST_F(ResolverTest, Expr_Call_Intrinsic) { @@ -547,7 +547,7 @@ TEST_F(ResolverTest, Expr_Call_Intrinsic) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Cast) { @@ -559,7 +559,7 @@ TEST_F(ResolverTest, Expr_Cast) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(cast), nullptr); - EXPECT_TRUE(TypeOf(cast)->Is()); + EXPECT_TRUE(TypeOf(cast)->Is()); } TEST_F(ResolverTest, Expr_Constructor_Scalar) { @@ -569,7 +569,7 @@ TEST_F(ResolverTest, Expr_Constructor_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(s), nullptr); - EXPECT_TRUE(TypeOf(s)->Is()); + EXPECT_TRUE(TypeOf(s)->Is()); } TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) { @@ -579,9 +579,9 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) { @@ -591,9 +591,9 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) { @@ -603,9 +603,9 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) { @@ -617,8 +617,8 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(ident), nullptr); - EXPECT_TRUE(TypeOf(ident)->Is()); - EXPECT_TRUE(TypeOf(ident)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(ident)->Is()); + EXPECT_TRUE(TypeOf(ident)->As()->type()->Is()); EXPECT_TRUE(CheckVarUsers(my_var, {ident})); ASSERT_NE(VarOf(ident), nullptr); EXPECT_EQ(VarOf(ident)->Declaration(), my_var); @@ -633,7 +633,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalConstant) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(ident), nullptr); - EXPECT_TRUE(TypeOf(ident)->Is()); + EXPECT_TRUE(TypeOf(ident)->Is()); EXPECT_TRUE(CheckVarUsers(my_var, {ident})); ASSERT_NE(VarOf(ident), nullptr); EXPECT_EQ(VarOf(ident)->Declaration(), my_var); @@ -654,7 +654,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(my_var_a), nullptr); - EXPECT_TRUE(TypeOf(my_var_a)->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->Is()); 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 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(my_var_a), nullptr); - EXPECT_TRUE(TypeOf(my_var_a)->Is()); - EXPECT_TRUE(TypeOf(my_var_a)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->As()->type()->Is()); EXPECT_EQ(StmtOf(my_var_a), assign); ASSERT_NE(TypeOf(my_var_b), nullptr); - EXPECT_TRUE(TypeOf(my_var_b)->Is()); - EXPECT_TRUE(TypeOf(my_var_b)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(my_var_b)->Is()); + EXPECT_TRUE(TypeOf(my_var_b)->As()->type()->Is()); 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 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(my_var_a), nullptr); - EXPECT_TRUE(TypeOf(my_var_a)->Is()); - EXPECT_TRUE(TypeOf(my_var_a)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->As()->type()->Is()); EXPECT_EQ(StmtOf(my_var_a), assign); ASSERT_NE(TypeOf(my_var_b), nullptr); - EXPECT_TRUE(TypeOf(my_var_b)->Is()); - EXPECT_TRUE(TypeOf(my_var_b)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(my_var_b)->Is()); + EXPECT_TRUE(TypeOf(my_var_b)->As()->type()->Is()); EXPECT_EQ(StmtOf(my_var_b), assign); } @@ -728,7 +728,7 @@ TEST_F(ResolverTest, Expr_Call_Function) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Identifier_Unknown) { @@ -902,10 +902,10 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mem), nullptr); - ASSERT_TRUE(TypeOf(mem)->Is()); + ASSERT_TRUE(TypeOf(mem)->Is()); - auto* ptr = TypeOf(mem)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(mem)->As(); + EXPECT_TRUE(ptr->type()->Is()); ASSERT_TRUE(Sem().Get(mem)->Is()); EXPECT_EQ(Sem() .Get(mem) @@ -932,10 +932,10 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mem), nullptr); - ASSERT_TRUE(TypeOf(mem)->Is()); + ASSERT_TRUE(TypeOf(mem)->Is()); - auto* ptr = TypeOf(mem)->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(mem)->As(); + EXPECT_TRUE(ptr->type()->Is()); ASSERT_TRUE(Sem().Get(mem)->Is()); } @@ -948,9 +948,9 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mem), nullptr); - ASSERT_TRUE(TypeOf(mem)->Is()); - EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); - EXPECT_EQ(TypeOf(mem)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(mem)->Is()); + EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); + EXPECT_EQ(TypeOf(mem)->As()->size(), 4u); ASSERT_TRUE(Sem().Get(mem)->Is()); EXPECT_THAT(Sem().Get(mem)->As()->Indices(), ElementsAre(0, 2, 1, 3)); @@ -965,10 +965,10 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mem), nullptr); - ASSERT_TRUE(TypeOf(mem)->Is()); + ASSERT_TRUE(TypeOf(mem)->Is()); - auto* ptr = TypeOf(mem)->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = TypeOf(mem)->As(); + ASSERT_TRUE(ptr->type()->Is()); ASSERT_TRUE(Sem().Get(mem)->Is()); EXPECT_THAT(Sem().Get(mem)->As()->Indices(), ElementsAre(2)); } @@ -1004,7 +1004,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { ast::DecorationList{}); auto* stB = ty.struct_("B", strctB); - type::Vector vecB(stB, 3); + sem::Vector vecB(stB, 3); auto* strctA = create( ast::StructMemberList{Member("mem", &vecB)}, ast::DecorationList{}); @@ -1019,9 +1019,9 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mem), nullptr); - ASSERT_TRUE(TypeOf(mem)->Is()); - EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); - EXPECT_EQ(TypeOf(mem)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(mem)->Is()); + EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); + EXPECT_EQ(TypeOf(mem)->As()->size(), 2u); ASSERT_TRUE(Sem().Get(mem)->Is()); } @@ -1041,7 +1041,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } namespace ExprBinaryTest { @@ -1247,17 +1247,17 @@ TEST_P(Expr_Binary_Test_WithAlias_Valid, All) { << 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()) { - result = create( - create(Symbols().New(), v->type()), v->size()); - } else if (auto* m = type->As()) { + auto make_alias = [this](sem::Type* type) -> sem::Type* { + sem::Type* result; + if (auto* v = type->As()) { + result = create( + create(Symbols().New(), v->type()), v->size()); + } else if (auto* m = type->As()) { result = - create(create(Symbols().New(), m->type()), - m->rows(), m->columns()); + create(create(Symbols().New(), m->type()), + m->rows(), m->columns()); } else { - result = create(Symbols().New(), type); + result = create(Symbols().New(), type); } return result; }; @@ -1358,20 +1358,20 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) { 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(ty.f32(), vec_size); - rhs_type = create(ty.f32(), mat_rows, mat_cols); - result_type = create(ty.f32(), mat_cols); + lhs_type = create(ty.f32(), vec_size); + rhs_type = create(ty.f32(), mat_rows, mat_cols); + result_type = create(ty.f32(), mat_cols); is_valid_expr = vec_size == mat_rows; } else { - lhs_type = create(ty.f32(), mat_rows, mat_cols); - rhs_type = create(ty.f32(), vec_size); - result_type = create(ty.f32(), mat_rows); + lhs_type = create(ty.f32(), mat_rows, mat_cols); + rhs_type = create(ty.f32(), vec_size); + result_type = create(ty.f32(), mat_rows); is_valid_expr = vec_size == mat_cols; } @@ -1410,10 +1410,9 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) { uint32_t rhs_mat_rows = std::get<2>(GetParam()); uint32_t rhs_mat_cols = std::get<3>(GetParam()); - auto* lhs_type = create(ty.f32(), lhs_mat_rows, lhs_mat_cols); - auto* rhs_type = create(ty.f32(), rhs_mat_rows, rhs_mat_cols); - auto* result_type = - create(ty.f32(), lhs_mat_rows, rhs_mat_cols); + auto* lhs_type = create(ty.f32(), lhs_mat_rows, lhs_mat_cols); + auto* rhs_type = create(ty.f32(), rhs_mat_rows, rhs_mat_cols); + auto* result_type = create(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 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(der), nullptr); - ASSERT_TRUE(TypeOf(der)->Is()); - EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); - EXPECT_EQ(TypeOf(der)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(der)->Is()); + EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); + EXPECT_EQ(TypeOf(der)->As()->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 b39f975354..51701ad776 100644 --- a/src/resolver/resolver_test_helper.h +++ b/src/resolver/resolver_test_helper.h @@ -105,96 +105,96 @@ template class ResolverTestWithParam : public TestHelper, public testing::TestWithParam {}; -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 -type::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) { return ty.vec2(); } template -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 -type::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) { return ty.vec3(); } template -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 -type::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) { return ty.vec4(); } template -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 -type::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) { return ty.mat2x2(); } template -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 -type::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) { return ty.mat3x3(); } template -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 -type::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) { +sem::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) { return ty.mat4x4(); } template -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 -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 -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 81a44e167c..bf1b84bb9c 100644 --- a/src/resolver/type_constructor_validation_test.cc +++ b/src/resolver/type_constructor_validation_test.cc @@ -19,11 +19,11 @@ namespace resolver { 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()) { +sem::Type* ElementTypeOf(sem::Type* type) { + if (auto* v = type->As()) { return v->type(); } - if (auto* m = type->As()) { + if (auto* m = type->As()) { return m->type(); } return type; diff --git a/src/resolver/validation_test.cc b/src/resolver/validation_test.cc index ab1c622d69..4c26d0bcdd 100644 --- a/src/resolver/validation_test.cc +++ b/src/resolver/validation_test.cc @@ -912,9 +912,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2_Success_ZeroValue) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) { @@ -924,9 +924,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec2U32_Success_Scalar) { @@ -936,9 +936,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2U32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec2I32_Success_Scalar) { @@ -948,9 +948,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2I32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec2Bool_Success_Scalar) { @@ -960,9 +960,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2Bool_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec2_Success_Identity) { @@ -972,9 +972,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec2_Success_Identity) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, @@ -985,9 +985,9 @@ TEST_F(ResolverValidationTest, EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); } TEST_F(ResolverValidationTest, @@ -1174,9 +1174,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_ZeroValue) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) { @@ -1186,9 +1186,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3U32_Success_Scalar) { @@ -1198,9 +1198,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3U32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3I32_Success_Scalar) { @@ -1210,9 +1210,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3I32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3Bool_Success_Scalar) { @@ -1222,9 +1222,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3Bool_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) { @@ -1234,9 +1234,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) { @@ -1246,9 +1246,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Identity) { @@ -1258,9 +1258,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec3_Success_Identity) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, @@ -1271,9 +1271,9 @@ TEST_F(ResolverValidationTest, EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); } TEST_F(ResolverValidationTest, @@ -1528,9 +1528,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ZeroValue) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) { @@ -1540,9 +1540,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4U32_Success_Scalar) { @@ -1552,9 +1552,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4U32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4I32_Success_Scalar) { @@ -1564,9 +1564,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4I32_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4Bool_Success_Scalar) { @@ -1576,9 +1576,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4Bool_Success_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) { @@ -1588,9 +1588,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) { @@ -1600,9 +1600,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) { @@ -1612,9 +1612,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2AndVec2) { @@ -1624,9 +1624,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec2AndVec2) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) { @@ -1636,9 +1636,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) { @@ -1648,9 +1648,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Identity) { @@ -1660,9 +1660,9 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vec4_Success_Identity) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, @@ -1673,9 +1673,9 @@ TEST_F(ResolverValidationTest, EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, @@ -1700,9 +1700,9 @@ TEST_F(ResolverValidationTest, EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(tc), nullptr); - ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + ASSERT_TRUE(TypeOf(tc)->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); } TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) { @@ -1731,7 +1731,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) { TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) { auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* vec_type = create(f32_alias, 2); + auto* vec_type = create(f32_alias, 2); // vec2(1.0f, 1u) auto* tc = create( @@ -1749,7 +1749,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) { TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Success) { auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* vec_type = create(f32_alias, 2); + auto* vec_type = create(f32_alias, 2); // vec2(1.0f, 1.0f) auto* tc = create(Source{{12, 34}}, vec_type, @@ -1762,7 +1762,7 @@ TEST_F(ResolverValidationTest, TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ArgumentElementTypeAlias_Error) { auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* vec_type = create(f32_alias, 2); + auto* vec_type = create(f32_alias, 2); // vec3(vec(), 1.0f) auto* tc = vec3(create( @@ -1779,7 +1779,7 @@ TEST_F(ResolverValidationTest, TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ArgumentElementTypeAlias_Success) { auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* vec_type = create(f32_alias, 2); + auto* vec_type = create(f32_alias, 2); // vec3(vec(), 1.0f) auto* tc = vec3(create( @@ -1811,8 +1811,8 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_TooFewArguments) { // matNxM(vecM(), ...); with N - 1 arguments const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* vec_type = create(ty.f32(), param.rows); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* vec_type = create(ty.f32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns - 1; i++) { @@ -1835,8 +1835,8 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_TooManyArguments) { // matNxM(vecM(), ...); with N + 1 arguments const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* vec_type = create(ty.f32(), param.rows); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* vec_type = create(ty.f32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns + 1; i++) { @@ -1859,7 +1859,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_Error_InvalidArgumentType) { // matNxM(1.0, 1.0, ...); N arguments const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns; i++) { @@ -1888,9 +1888,9 @@ TEST_P(MatrixConstructorTest, return; } - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* valid_vec_type = create(ty.f32(), param.rows); - auto* invalid_vec_type = create(ty.f32(), param.rows - 1); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* valid_vec_type = create(ty.f32(), param.rows); + auto* invalid_vec_type = create(ty.f32(), param.rows - 1); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns - 1; i++) { @@ -1924,9 +1924,9 @@ TEST_P(MatrixConstructorTest, return; } - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* valid_vec_type = create(ty.f32(), param.rows); - auto* invalid_vec_type = create(ty.f32(), param.rows + 1); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* valid_vec_type = create(ty.f32(), param.rows); + auto* invalid_vec_type = create(ty.f32(), param.rows + 1); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns - 1; i++) { @@ -1954,8 +1954,8 @@ TEST_P(MatrixConstructorTest, // matNxM(vecM(), ...); with N arguments const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* vec_type = create(ty.u32(), param.rows); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* vec_type = create(ty.u32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns; i++) { @@ -1978,7 +1978,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ZeroValue_Success) { // matNxM(); const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); auto* tc = create(Source{{12, 40}}, matrix_type, ExprList()); WrapInFunction(tc); @@ -1990,8 +1990,8 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_WithArguments_Success) { // matNxM(vecM(), ...); with N arguments const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* vec_type = create(ty.f32(), param.rows); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* vec_type = create(ty.f32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns; i++) { @@ -2011,9 +2011,8 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Error) { const auto param = GetParam(); auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* matrix_type = - create(f32_alias, param.rows, param.columns); - auto* vec_type = create(ty.u32(), param.rows); + auto* matrix_type = create(f32_alias, param.rows, param.columns); + auto* vec_type = create(ty.u32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns; i++) { @@ -2037,9 +2036,8 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) { const auto param = GetParam(); auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* matrix_type = - create(f32_alias, param.rows, param.columns); - auto* vec_type = create(ty.f32(), param.rows); + auto* matrix_type = create(f32_alias, param.rows, param.columns); + auto* vec_type = create(ty.f32(), param.rows); ast::ExpressionList args; for (uint32_t i = 1; i <= param.columns; i++) { @@ -2069,8 +2067,8 @@ TEST_F(ResolverValidationTest, Expr_MatrixConstructor_ArgumentTypeAlias_Error) { TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) { const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); - auto* vec_type = create(ty.f32(), param.rows); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* vec_type = create(ty.f32(), param.rows); auto* vec_alias = ty.alias("VectorFloat2", vec_type); ast::ExpressionList args; @@ -2088,9 +2086,9 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) { TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) { const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); auto* f32_alias = ty.alias("UnsignedInt", ty.u32()); - auto* vec_type = create(f32_alias, param.rows); + auto* vec_type = create(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_Error) { TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Success) { const auto param = GetParam(); - auto* matrix_type = create(ty.f32(), param.rows, param.columns); + auto* matrix_type = create(ty.f32(), param.rows, param.columns); auto* f32_alias = ty.alias("Float32", ty.f32()); - auto* vec_type = create(f32_alias, param.rows); + auto* vec_type = create(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 2126a53349..fefd8a1505 100644 --- a/src/sem/array.cc +++ b/src/sem/array.cc @@ -19,7 +19,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Array); 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 c9861c68c4..68297b9ce3 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 { @@ -37,10 +34,10 @@ class Array : public Castable { /// @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 @@ class Array : public Castable { 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 b048f69711..0ce35e9498 100644 --- a/src/sem/call_target.cc +++ b/src/sem/call_target.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::CallTarget); 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 e0085d4dbb..8f4f013f90 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 @@ struct Parameter { }; /// Parameter type - type::Type* const type; + sem::Type* const type; /// Parameter usage Usage const usage = Usage::kNone; }; @@ -80,10 +80,10 @@ class CallTarget : public Castable { /// 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 @@ class CallTarget : public Castable { 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 52c27c745e..b3b2ee6047 100644 --- a/src/sem/expression.cc +++ b/src/sem/expression.cc @@ -20,7 +20,7 @@ namespace tint { 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 507699e2d6..10d3eeb0f7 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 { @@ -38,11 +32,11 @@ class Expression : public Castable { /// @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 @@ class Expression : public Castable { 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 64c294edb4..9d222587d8 100644 --- a/src/sem/function.cc +++ b/src/sem/function.cc @@ -117,12 +117,12 @@ Function::ReferencedBuiltinVariables() const { } 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 @@ Function::VariableBindings Function::ReferencedStorageTextureVariables() const { for (auto* var : ReferencedModuleVariables()) { auto* unwrapped_type = var->Declaration()->declared_type()->UnwrapIfNeeded(); - auto* storage_texture = unwrapped_type->As(); + auto* storage_texture = unwrapped_type->As(); if (storage_texture == nullptr) { continue; } @@ -158,7 +158,7 @@ Function::VariableBindings Function::ReferencedDepthTextureVariables() const { for (auto* var : ReferencedModuleVariables()) { auto* unwrapped_type = var->Declaration()->declared_type()->UnwrapIfNeeded(); - auto* storage_texture = unwrapped_type->As(); + auto* storage_texture = unwrapped_type->As(); if (storage_texture == nullptr) { continue; } @@ -180,13 +180,13 @@ bool Function::HasAncestorEntryPoint(Symbol symbol) const { } 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(); + auto* sampler = unwrapped_type->As(); if (sampler == nullptr || sampler->kind() != kind) { continue; } @@ -205,13 +205,13 @@ Function::VariableBindings Function::ReferencedSampledTextureVariablesImpl( for (auto* var : ReferencedModuleVariables()) { auto* unwrapped_type = var->Declaration()->declared_type()->UnwrapIfNeeded(); - auto* texture = unwrapped_type->As(); + auto* texture = unwrapped_type->As(); if (texture == nullptr) { continue; } - auto is_multisampled = texture->Is(); - auto is_sampled = texture->Is(); + auto is_multisampled = texture->Is(); + auto is_sampled = texture->Is(); if ((multisampled && !is_multisampled) || (!multisampled && !is_sampled)) { continue; diff --git a/src/sem/function.h b/src/sem/function.h index 9483f949ce..4069245871 100644 --- a/src/sem/function.h +++ b/src/sem/function.h @@ -142,7 +142,7 @@ class Function : public Castable { 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 6b95a1a8b6..24260d1fff 100644 --- a/src/sem/intrinsic.cc +++ b/src/sem/intrinsic.cc @@ -195,7 +195,7 @@ bool IsBarrierIntrinsic(IntrinsicType i) { } 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 b8fe7cb7ed..a8627331c7 100644 --- a/src/sem/intrinsic.h +++ b/src/sem/intrinsic.h @@ -174,7 +174,7 @@ class Intrinsic : public Castable { /// @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 aa73c0d264..b2fccb9eab 100644 --- a/src/sem/member_accessor_expression.cc +++ b/src/sem/member_accessor_expression.cc @@ -26,7 +26,7 @@ namespace sem { MemberAccessorExpression::MemberAccessorExpression( ast::MemberAccessorExpression* declaration, - type::Type* type, + sem::Type* type, Statement* statement) : Base(declaration, type, statement) {} @@ -34,7 +34,7 @@ MemberAccessorExpression::~MemberAccessorExpression() = default; 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( StructMemberAccess::~StructMemberAccess() = default; Swizzle::Swizzle(ast::MemberAccessorExpression* declaration, - type::Type* type, + sem::Type* type, Statement* statement, std::vector 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 13554452bb..d8665ded71 100644 --- a/src/sem/member_accessor_expression.h +++ b/src/sem/member_accessor_expression.h @@ -42,7 +42,7 @@ class MemberAccessorExpression /// @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 @@ class StructMemberAccess /// @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 @@ class Swizzle : public Castable { /// @param statement the statement that /// @param indices the swizzle indices Swizzle(ast::MemberAccessorExpression* declaration, - type::Type* type, + sem::Type* type, Statement* statement, std::vector indices); diff --git a/src/sem/struct.cc b/src/sem/struct.cc index 4426800859..94212ebdd7 100644 --- a/src/sem/struct.cc +++ b/src/sem/struct.cc @@ -23,7 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::StructMember); 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 d4119f4b92..473775b6f8 100644 --- a/src/sem/struct.h +++ b/src/sem/struct.h @@ -30,12 +30,11 @@ namespace tint { 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 @@ class Struct : public Castable { /// 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 @@ class Struct : public Castable { ~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 @@ class Struct : public Castable { } 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 fa4573fe08..52a1abdba5 100644 --- a/src/sem/type_mappings.h +++ b/src/sem/type_mappings.h @@ -29,21 +29,18 @@ class Statement; 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 @@ class Variable; /// 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 88d951e252..89e4bec48b 100644 --- a/src/sem/variable.cc +++ b/src/sem/variable.cc @@ -24,18 +24,18 @@ namespace tint { 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 056d5b6f18..6a0a618898 100644 --- a/src/sem/variable.h +++ b/src/sem/variable.h @@ -27,12 +27,11 @@ namespace ast { 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 @@ class Variable : public Castable { /// @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 @@ class Variable : public Castable { 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 @@ class Variable : public Castable { private: const ast::Variable* const declaration_; - type::Type* const type_; + sem::Type* const type_; ast::StorageClass const storage_class_; std::vector users_; }; @@ -84,7 +83,7 @@ class VariableUser : public Castable { /// @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 af4b2ac54d..aa6b7ad64b 100644 --- a/src/transform/binding_remapper.cc +++ b/src/transform/binding_remapper.cc @@ -65,13 +65,13 @@ Output BindingRemapper::Run(const Program* in, const DataMap& datamap) { 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()) { + sem::Type* inner_ty = nullptr; + if (auto* old_ac = ty->As()) { inner_ty = ctx.Clone(old_ac->type()); } else { inner_ty = ctx.Clone(ty); } - auto* new_ty = ctx.dst->create(ac, inner_ty); + auto* new_ty = ctx.dst->create(ac, inner_ty); auto* new_var = ctx.dst->create( 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 c08495e551..3f56cf071f 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/bound_array_accessors.cc @@ -42,8 +42,8 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( auto& diags = ctx->dst->Diagnostics(); auto* ret_type = ctx->src->Sem().Get(expr->array())->Type()->UnwrapAll(); - if (!ret_type->Is() && !ret_type->Is() && - !ret_type->Is()) { + if (!ret_type->Is() && !ret_type->Is() && + !ret_type->Is()) { return nullptr; } @@ -51,15 +51,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( using u32 = ProgramBuilder::u32; uint32_t size = 0; - bool is_vec = ret_type->Is(); - bool is_arr = ret_type->Is(); + bool is_vec = ret_type->Is(); + bool is_arr = ret_type->Is(); if (is_vec || is_arr) { - size = is_vec ? ret_type->As()->size() - : ret_type->As()->size(); + size = is_vec ? ret_type->As()->size() + : ret_type->As()->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()->columns(); + size = ret_type->As()->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 c60a99dc17..01c0f5e096 100644 --- a/src/transform/calculate_array_length.cc +++ b/src/transform/calculate_array_length.cc @@ -77,8 +77,8 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { // 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 buffer_size_intrinsics; - auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) { + std::unordered_map 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( @@ -138,7 +138,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { 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(); + storage_buffer_sem->Type()->UnwrapAll()->As(); // Generate BufferSizeIntrinsic for this storage type if we haven't // already @@ -146,7 +146,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { 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 3066d239ae..90d72b1406 100644 --- a/src/transform/canonicalize_entry_point_io.cc +++ b/src/transform/canonicalize_entry_point_io.cc @@ -66,7 +66,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { // 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()) { + if (auto* struct_ty = ty->As()) { // 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 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { } // Redeclare the struct. - auto* new_struct = ctx.dst->create( + auto* new_struct = ctx.dst->create( ctx.Clone(struct_ty->symbol()), ctx.dst->create( new_struct_members, ctx.Clone(struct_ty->impl()->decorations()))); @@ -107,11 +107,11 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { std::function func_const_initializer; - if (auto* struct_ty = param_ty->As()) { + if (auto* struct_ty = param_ty->As()) { // Pull out all struct members and build initializer list. std::vector member_names; for (auto* member : struct_ty->impl()->members()) { - if (member->type()->UnwrapAll()->Is()) { + if (member->type()->UnwrapAll()->Is()) { TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct"; } @@ -174,7 +174,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { StructMemberComparator); // Create the new struct type. - auto* in_struct = ctx.dst->create( + auto* in_struct = ctx.dst->create( ctx.dst->Symbols().New(), ctx.dst->create(new_struct_members, ast::DecorationList{})); @@ -187,16 +187,16 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { // Handle return type. auto* ret_type = func->return_type()->UnwrapAliasIfNeeded(); - type::Type* new_ret_type; - if (ret_type->Is()) { + sem::Type* new_ret_type; + if (ret_type->Is()) { new_ret_type = ctx.dst->ty.void_(); } else { ast::StructMemberList new_struct_members; - if (auto* struct_ty = ret_type->As()) { + if (auto* struct_ty = ret_type->As()) { // Rebuild struct with only the entry point IO attributes. for (auto* member : struct_ty->impl()->members()) { - if (member->type()->UnwrapAll()->Is()) { + if (member->type()->UnwrapAll()->Is()) { TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct"; } @@ -220,7 +220,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { StructMemberComparator); // Create the new struct type. - auto* out_struct = ctx.dst->create( + auto* out_struct = ctx.dst->create( ctx.dst->Symbols().New(), ctx.dst->create(new_struct_members, ast::DecorationList{})); @@ -237,7 +237,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { }; ast::ExpressionList ret_values; - if (ret_type->Is()) { + if (ret_type->Is()) { if (!ret->value()->Is()) { // 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 0ae2587d54..ea9c5bb5c6 100644 --- a/src/transform/decompose_storage_access.cc +++ b/src/transform/decompose_storage_access.cc @@ -57,7 +57,7 @@ struct OffsetExpr : Offset { ast::Expression* Build(CloneContext& ctx) override { auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapAll(); auto* res = ctx.Clone(expr); - if (!type->Is()) { + if (!type->Is()) { res = ctx.dst->Construct(res); } return res; @@ -174,8 +174,8 @@ std::unique_ptr Mul(LHS&& lhs_, RHS&& rhs_) { /// 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 @@ struct TypePair { }; /// @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(builder->ID(), type); }; - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kLoadI32); } - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kLoadU32); } - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kLoadF32); } - if (auto* vec = ty->As()) { + if (auto* vec = ty->As()) { switch (vec->size()) { case 2: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec2I32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec2U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec2F32); } break; case 3: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec3I32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec3U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec3F32); } break; case 4: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec4I32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec4U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kLoadVec4F32); } break; @@ -259,54 +259,54 @@ DecomposeStorageAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder, /// @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(builder->ID(), type); }; - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kStoreI32); } - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kStoreU32); } - if (ty->Is()) { + if (ty->Is()) { return intrinsic(Intrinsic::kStoreF32); } - if (auto* vec = ty->As()) { + if (auto* vec = ty->As()) { switch (vec->size()) { case 2: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec2U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec2F32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec2I32); } break; case 3: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec3U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec3F32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec3I32); } break; case 4: - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec4U32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec4F32); } - if (vec->type()->Is()) { + if (vec->type()->Is()) { return intrinsic(Intrinsic::kStoreVec4I32); } break; @@ -328,20 +328,20 @@ void InsertGlobal(CloneContext& ctx, Cloneable* insert_after, Cloneable* node) { } /// @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()) { + if (auto* ptr = ty->As()) { ty = ptr->type(); continue; } - if (auto* access = ty->As()) { + if (auto* access = ty->As()) { ty = access->type(); continue; } - if (auto* alias = ty->As()) { + if (auto* alias = ty->As()) { return alias; } - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { return str; } // Not a constructed type @@ -350,7 +350,7 @@ type::Type* ConstructedTypeOf(type::Type* ty) { } /// @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 @@ type::Type* UnwrapPtrAndAlias(type::Type* ty) { struct StorageBufferAccess { sem::Expression const* var = nullptr; // Storage buffer variable std::unique_ptr 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 @@ struct State { /// 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 @@ struct State { ast::DecorationList{intrinsic}, ast::DecorationList{}); } else { ast::ExpressionList values; - if (auto* mat_ty = el_ty->As()) { - auto* vec_ty = ctx.dst->create( - ctx.Clone(mat_ty->type()), mat_ty->rows()); + if (auto* mat_ty = el_ty->As()) { + auto* vec_ty = ctx.dst->create(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()) { + } else if (auto* str_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* str = sem.Get(str_ty); for (auto* member : str->Members()) { @@ -447,7 +447,7 @@ struct State { member->Declaration()->type()->UnwrapAll()); values.emplace_back(ctx.dst->Call(load, "buffer", offset)); } - } else if (auto* arr_ty = el_ty->As()) { + } else if (auto* arr_ty = el_ty->As()) { 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 @@ struct State { /// 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 @@ struct State { } else { ast::StatementList body; - if (auto* mat_ty = el_ty->As()) { - auto* vec_ty = ctx.dst->create( - ctx.Clone(mat_ty->type()), mat_ty->rows()); + if (auto* mat_ty = el_ty->As()) { + auto* vec_ty = ctx.dst->create(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 @@ struct State { auto* call = ctx.dst->Call(store, "buffer", offset, access); body.emplace_back(ctx.dst->create(call)); } - } else if (auto* str_ty = el_ty->As()) { + } else if (auto* str_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* str = sem.Get(str_ty); for (auto* member : str->Members()) { @@ -518,7 +518,7 @@ struct State { auto* call = ctx.dst->Call(store, "buffer", offset, access); body.emplace_back(ctx.dst->create(call)); } - } else if (auto* arr_ty = el_ty->As()) { + } else if (auto* arr_ty = el_ty->As()) { 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 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { if (auto* swizzle = accessor_sem->As()) { if (swizzle->Indices().size() == 1) { if (auto access = state.TakeAccess(accessor->structure())) { - auto* vec_ty = access.type->As(); + auto* vec_ty = access.type->As(); auto offset = Mul(ScalarSize(vec_ty->type()), swizzle->Indices()[0]); state.AddAccesss( @@ -660,7 +660,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { } } else { if (auto access = state.TakeAccess(accessor->structure())) { - auto* str_ty = access.type->As(); + auto* str_ty = access.type->As(); auto* member = sem.Get(str_ty)->FindMember(accessor->member()->symbol()); auto offset = member->Offset(); @@ -678,7 +678,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { if (auto* accessor = node->As()) { if (auto access = state.TakeAccess(accessor->array())) { // X[Y] - if (auto* arr_ty = access.type->As()) { + if (auto* arr_ty = access.type->As()) { auto stride = sem.Get(arr_ty)->Stride(); auto offset = Mul(stride, accessor->idx_expr()); state.AddAccesss(accessor, @@ -689,7 +689,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { }); continue; } - if (auto* vec_ty = access.type->As()) { + if (auto* vec_ty = access.type->As()) { auto offset = Mul(ScalarSize(vec_ty->type()), accessor->idx_expr()); state.AddAccesss(accessor, { @@ -699,9 +699,9 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { }); continue; } - if (auto* mat_ty = access.type->As()) { + if (auto* mat_ty = access.type->As()) { auto offset = Mul(MatrixColumnStride(mat_ty), accessor->idx_expr()); - auto* vec_ty = ctx.dst->create( + auto* vec_ty = ctx.dst->create( 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 a1d7dbfac7..4d17f6edfe 100644 --- a/src/transform/hlsl.cc +++ b/src/transform/hlsl.cc @@ -96,7 +96,7 @@ void Hlsl::PromoteInitializersToConstVar(CloneContext& ctx) const { } auto* src_ty = src_sem_expr->Type(); - if (src_ty->IsAnyOf()) { + if (src_ty->IsAnyOf()) { // 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 b8c44e6fc5..e16a22a672 100644 --- a/src/transform/spirv.cc +++ b/src/transform/spirv.cc @@ -111,7 +111,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const { // Strip entry point IO decorations from struct declarations. for (auto* ty : ctx.src->AST().ConstructedTypes()) { - if (auto* struct_ty = ty->As()) { + if (auto* struct_ty = ty->As()) { // 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 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const { } // Redeclare the struct. - auto* new_struct = ctx.dst->create( + auto* new_struct = ctx.dst->create( ctx.Clone(struct_ty->symbol()), ctx.dst->create( new_struct_members, ctx.Clone(struct_ty->impl()->decorations()))); @@ -151,7 +151,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const { } } - if (!func->return_type()->Is()) { + if (!func->return_type()->Is()) { ast::StatementList stores; auto store_value_symbol = ctx.dst->Symbols().New(); HoistToOutputVariables( @@ -252,10 +252,10 @@ void Spirv::AddEmptyEntryPoint(CloneContext& ctx) const { 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()) { + if (!ty->Is()) { // Base case: create a global variable and return. ast::DecorationList new_decorations = RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) { @@ -272,7 +272,7 @@ Symbol Spirv::HoistToInputVariables( // Recurse into struct members and build the initializer list. std::vector init_value_names; - auto* struct_ty = ty->As(); + auto* struct_ty = ty->As(); for (auto* member : struct_ty->impl()->members()) { auto member_var = HoistToInputVariables( ctx, func, member->type(), member->type(), member->decorations()); @@ -301,14 +301,14 @@ Symbol Spirv::HoistToInputVariables( 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 member_accesses, Symbol store_value, ast::StatementList& stores) const { // Base case. - if (!ty->Is()) { + if (!ty->Is()) { // Create a global variable. ast::DecorationList new_decorations = RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) { @@ -332,7 +332,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx, } // Recurse into struct members. - auto* struct_ty = ty->As(); + auto* struct_ty = ty->As(); 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 a80a1dc050..2d6085284c 100644 --- a/src/transform/spirv.h +++ b/src/transform/spirv.h @@ -59,8 +59,8 @@ class Spirv : public Transform { /// 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 @@ class Spirv : public Transform { /// 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 member_accesses, Symbol store_value, diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 973afe3bb8..a022e66227 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -367,7 +367,7 @@ struct State { /// @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 @@ struct State { } return ctx.dst->create( - ctx.dst->create(base_type, count), std::move(expr_list)); + ctx.dst->create(base_type, count), std::move(expr_list)); } }; diff --git a/src/type/access_control_type.cc b/src/type/access_control_type.cc index 0d1cbf5f64..59f9f13bf0 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 @@ AccessControl* AccessControl::Clone(CloneContext* ctx) const { return ctx->dst->create(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 7002ea432e..55de5247e0 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 { @@ -64,7 +64,7 @@ class AccessControl : public Castable { 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 b8fd5aaf8c..2e88ca171a 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 @@ TEST_F(AccessControlTest, FriendlyNameReadWrite) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/alias_type.cc b/src/type/alias_type.cc index d0ec9c0dd0..19ce92921e 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 @@ Alias* Alias::Clone(CloneContext* ctx) const { return ctx->dst->create(sym, ty); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/alias_type.h b/src/type/alias_type.h index ede6218d7e..ba8cd61547 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 { @@ -57,7 +57,7 @@ class Alias : public Castable { 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 b9a8f893d0..24ba051f25 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, Create) { TEST_F(AliasTest, Is) { auto* at = ty.alias("a", ty.i32()); - type::Type* ty = at; + sem::Type* ty = at; EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); @@ -145,5 +145,5 @@ TEST_F(AliasTest, UnwrapAliasIfNeeded) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/array_type.cc b/src/type/array_type.cc index f7f7208a8b..d2d866ca58 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 @@ ArrayType* ArrayType::Clone(CloneContext* ctx) const { return ctx->dst->create(ty, size_, decos); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/array_type.h b/src/type/array_type.h index 2dc8228010..0f833f1be3 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 @@ class ArrayType : public Castable { 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 f45f989e78..b37cc4ca69 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 @@ TEST_F(ArrayTest, TypeName_WithStride) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/bool_type.cc b/src/type/bool_type.cc index b21227d60f..d17cf2c4a7 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 @@ Bool* Bool::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/bool_type.h b/src/type/bool_type.h index 97863c53ff..7402e47058 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 { @@ -51,7 +51,7 @@ class Bool : public Castable { 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 077565730b..64094bf735 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 @@ TEST_F(BoolTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/depth_texture_type.cc b/src/type/depth_texture_type.cc index 2dbd64c33b..6ead318eb1 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 @@ DepthTexture* DepthTexture::Clone(CloneContext* ctx) const { return ctx->dst->create(dim()); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/depth_texture_type.h b/src/type/depth_texture_type.h index 2cff86ce62..2a2bbfd42f 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 { @@ -46,7 +46,7 @@ class DepthTexture : public Castable { 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 eef75d571e..993879c380 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 @@ TEST_F(DepthTextureTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/external_texture_type.cc b/src/type/external_texture_type.cc index c7d475a3de..3dba14063a 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 @@ ExternalTexture* ExternalTexture::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/external_texture_type.h b/src/type/external_texture_type.h index b6ffbc3389..c2ceb46335 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 + #include "src/type/texture_type.h" namespace tint { -namespace type { +namespace sem { class ExternalTexture : public Castable { public: /// Constructor @@ -42,6 +44,6 @@ class ExternalTexture : public Castable { 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 7c73d62109..2fb74853ec 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 @@ TEST_F(ExternalTextureTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/f32_type.cc b/src/type/f32_type.cc index 5e7e2a521a..7398957f51 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 @@ F32* F32::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/f32_type.h b/src/type/f32_type.h index 156ddd121c..2391404c51 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 { @@ -45,7 +45,7 @@ class F32 : public Castable { 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 a1b89d4eb8..421ca9ed62 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 @@ TEST_F(F32Test, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/i32_type.cc b/src/type/i32_type.cc index 780738510a..5297a343f1 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 @@ I32* I32::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/i32_type.h b/src/type/i32_type.h index a376974884..2722e87cca 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 { @@ -45,7 +45,7 @@ class I32 : public Castable { 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 8def688936..bf3a1ecbd5 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 @@ TEST_F(I32Test, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/matrix_type.cc b/src/type/matrix_type.cc index c840d0f893..4daa6b83ec 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 @@ Matrix* Matrix::Clone(CloneContext* ctx) const { return ctx->dst->create(ty, rows_, columns_); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/matrix_type.h b/src/type/matrix_type.h index 59c878c54f..3eefdd1a7d 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 { @@ -60,7 +60,7 @@ class Matrix : public Castable { 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 92c2aaf059..87b32733b1 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 @@ TEST_F(MatrixTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/multisampled_texture_type.cc b/src/type/multisampled_texture_type.cc index e55ebd56ca..e3d19900a9 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 @@ MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const { return ctx->dst->create(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 78c40737d8..7542402eca 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 { @@ -53,7 +53,7 @@ class MultisampledTexture : public Castable { 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 f18c9bf97b..3add47c983 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 @@ TEST_F(MultisampledTextureTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/pointer_type.cc b/src/type/pointer_type.cc index 7f989669b9..c9b22304a3 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 @@ Pointer* Pointer::Clone(CloneContext* ctx) const { return ctx->dst->create(ty, storage_class_); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/pointer_type.h b/src/type/pointer_type.h index abbef7fe1b..3290009f80 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 { @@ -57,7 +57,7 @@ class Pointer : public Castable { 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 ec8d062340..79a0bf2778 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 @@ TEST_F(PointerTest, FriendlyNameWithoutStorageClass) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/sampled_texture_type.cc b/src/type/sampled_texture_type.cc index 1e3d636697..703de485d8 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 @@ SampledTexture* SampledTexture::Clone(CloneContext* ctx) const { return ctx->dst->create(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 fc03f72d54..bcd27058ec 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 { @@ -53,7 +53,7 @@ class SampledTexture : public Castable { 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 f7e2751e5b..97d4eb679d 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 @@ TEST_F(SampledTextureTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/sampler_type.cc b/src/type/sampler_type.cc index abfa64dfcf..4679297a29 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 @@ Sampler* Sampler::Clone(CloneContext* ctx) const { return ctx->dst->create(kind_); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/sampler_type.h b/src/type/sampler_type.h index f74d873970..23ef24c6bc 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 @@ class Sampler : public Castable { 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 b39f67572c..c7ef3c9f41 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 @@ TEST_F(SamplerTest, FriendlyNameComparisonSampler) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/storage_texture_type.cc b/src/type/storage_texture_type.cc index c430ea6c0d..e693dbe6de 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 @@ std::ostream& operator<<(std::ostream& out, ImageFormat format) { 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 @@ StorageTexture* StorageTexture::Clone(CloneContext* ctx) const { return ctx->dst->create(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(); + 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(); } - 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(); + 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(); } - 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(); + 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(); } - 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 7342c57c72..933133c12c 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 @@ class StorageTexture : public Castable { /// @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 @@ class StorageTexture : public Castable { 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 6931059063..eb18999128 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, FriendlyName) { TEST_F(StorageTextureTest, F32) { auto* subtype = - type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types()); + sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, Types()); Type* s = create(TextureDimension::k2dArray, ImageFormat::kRgba32Float, subtype); @@ -108,7 +108,7 @@ TEST_F(StorageTextureTest, F32) { TEST_F(StorageTextureTest, U32) { auto* subtype = - type::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types()); + sem::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, Types()); Type* s = create(TextureDimension::k2dArray, ImageFormat::kRg32Uint, subtype); @@ -122,7 +122,7 @@ TEST_F(StorageTextureTest, U32) { TEST_F(StorageTextureTest, I32) { auto* subtype = - type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types()); + sem::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, Types()); Type* s = create(TextureDimension::k2dArray, ImageFormat::kRgba32Sint, subtype); @@ -135,5 +135,5 @@ TEST_F(StorageTextureTest, I32) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/struct_type.cc b/src/type/struct_type.cc index f35ff863ff..1fa1cf66d4 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 @@ StructType* StructType::Clone(CloneContext* ctx) const { return ctx->dst->create(sym, str); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/struct_type.h b/src/type/struct_type.h index 4d9d8d27ba..139c61f6a5 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 { @@ -63,7 +63,7 @@ class StructType : public Castable { 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 34cafbfb39..e81afd3945 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 @@ TEST_F(StructTypeTest, Is) { auto* impl = create(ast::StructMemberList{}, ast::DecorationList{}); auto* s = ty.struct_("S", impl); - type::Type* ty = s; + sem::Type* ty = s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); @@ -65,5 +65,5 @@ TEST_F(StructTypeTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/test_helper.h b/src/type/test_helper.h index 1c08c60b36..4ee2802054 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 @@ -43,7 +43,7 @@ using TestHelper = TestHelperBase; template using TestParamHelper = TestHelperBase>; -} // 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 1f66a37131..df16729c39 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(Texture&&) = default; Texture::~Texture() = default; -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/texture_type.h b/src/type/texture_type.h index c36ba882f2..9c83debbed 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 @@ class Texture : public Castable { 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 57c52a4d5d..a1dec3baed 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 @@ TEST_F(TextureTypeTest, NumCoordinateAxes) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/type.cc b/src/type/type.cc index 3637f87ea7..eee7d543bf 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(Type&&) = default; Type::~Type() = default; Type* Type::UnwrapPtrIfNeeded() { - if (auto* ptr = As()) { + if (auto* ptr = As()) { return ptr->type(); } return this; @@ -46,7 +46,7 @@ Type* Type::UnwrapPtrIfNeeded() { Type* Type::UnwrapAliasIfNeeded() { Type* unwrapped = this; - while (auto* ptr = unwrapped->As()) { + while (auto* ptr = unwrapped->As()) { unwrapped = ptr->type(); } return unwrapped; @@ -55,9 +55,9 @@ Type* Type::UnwrapAliasIfNeeded() { Type* Type::UnwrapIfNeeded() { auto* where = this; while (true) { - if (auto* alias = where->As()) { + if (auto* alias = where->As()) { where = alias->type(); - } else if (auto* access = where->As()) { + } else if (auto* access = where->As()) { where = access->type(); } else { break; @@ -132,5 +132,5 @@ bool Type::is_handle() const { return IsAnyOf(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/type.h b/src/type/type.h index 95ed3710ff..7c23d679bd 100644 --- a/src/type/type.h +++ b/src/type/type.h @@ -25,7 +25,7 @@ namespace tint { class ProgramBuilder; class SymbolTable; -namespace type { +namespace sem { /// Supported memory layouts for calculating sizes enum class MemoryLayout { kUniformBuffer, kStorageBuffer }; @@ -109,7 +109,7 @@ inline ProgramID ProgramIDOf(const Type*) { 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 1f6833d1e9..76e97f467f 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 a3ece09971..b42c2871ad 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::ConstIterator; + using Iterator = BlockAllocator::ConstIterator; /// Constructor Manager(); @@ -80,7 +80,7 @@ class Manager { /// Returns the type map /// @returns the mapping from name string to type. - const std::unordered_map& types() const { + const std::unordered_map& types() const { return by_name_; } @@ -90,11 +90,11 @@ class Manager { Iterator end() const { return types_.Objects().end(); } private: - std::unordered_map by_name_; - BlockAllocator types_; + std::unordered_map by_name_; + BlockAllocator 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 71846ef926..0dc83c93ed 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 @@ -79,5 +79,5 @@ TEST_F(TypeManagerTest, WrapDoesntAffectInner) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/u32_type.cc b/src/type/u32_type.cc index 775abc30ba..7a8ac3adb7 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 @@ U32* U32::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/u32_type.h b/src/type/u32_type.h index 7aadc8922d..bfd81a0184 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 { @@ -45,7 +45,7 @@ class U32 : public Castable { 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 d2e45970ee..39f657f61a 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 @@ TEST_F(U32Test, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/vector_type.cc b/src/type/vector_type.cc index ce65744b89..5e12305970 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 @@ Vector* Vector::Clone(CloneContext* ctx) const { return ctx->dst->create(ty, size_); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/vector_type.h b/src/type/vector_type.h index cbb9022ac7..34ed90872e 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 { @@ -56,7 +56,7 @@ class Vector : public Castable { 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 8b12cc374b..656721fb6d 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 @@ TEST_F(VectorTest, FriendlyName) { } } // namespace -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/void_type.cc b/src/type/void_type.cc index f615a20cb9..c0445b83f2 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 @@ Void* Void::Clone(CloneContext* ctx) const { return ctx->dst->create(); } -} // namespace type +} // namespace sem } // namespace tint diff --git a/src/type/void_type.h b/src/type/void_type.h index 406b36b19d..88fef42641 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 { @@ -45,7 +45,7 @@ class Void : public Castable { 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 4e98d248ca..1c84d457b6 100644 --- a/src/writer/append_vector.cc +++ b/src/writer/append_vector.cc @@ -25,7 +25,7 @@ namespace { ast::TypeConstructorExpression* AsVectorConstructor(ast::Expression* expr) { if (auto* constructor = expr->As()) { - if (constructor->type()->Is()) { + if (constructor->type()->Is()) { return constructor; } } @@ -38,10 +38,10 @@ ast::TypeConstructorExpression* AppendVector(ProgramBuilder* b, 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()) { + if (auto* vec = vector_ty->As()) { packed_size = vec->size() + 1; packed_el_ty = vec->type(); } else { @@ -51,7 +51,7 @@ ast::TypeConstructorExpression* AppendVector(ProgramBuilder* b, auto* statement = vector_sem->Stmt(); - auto* packed_ty = b->create(packed_el_ty, packed_size); + auto* packed_ty = b->create(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 b3f7de0a63..6efadf439f 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -58,26 +58,26 @@ bool last_is_break_or_fallthrough(const ast::BlockStatement* stmts) { stmts->last()->Is(); } -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 @@ std::string GeneratorImpl::current_ep_var_name(VarType type) { } bool GeneratorImpl::EmitConstructedType(std::ostream& out, - const type::Type* ty) { + const sem::Type* ty) { make_indent(out); - if (auto* alias = ty->As()) { + if (auto* alias = ty->As()) { // 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()) { + if (auto* str = alias->type()->As()) { if (!EmitStructType(out, str, builder_.Symbols().NameFor(alias->symbol()))) { return false; @@ -220,7 +220,7 @@ bool GeneratorImpl::EmitConstructedType(std::ostream& out, } out << " " << builder_.Symbols().NameFor(alias->symbol()) << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(out, str, builder_.Symbols().NameFor(str->symbol()))) { return false; } @@ -333,9 +333,9 @@ bool GeneratorImpl::EmitBinary(std::ostream& pre, // 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() && rhs_type->Is()) || - (lhs_type->Is() && rhs_type->Is()) || - (lhs_type->Is() && rhs_type->Is()))) { + ((lhs_type->Is() && rhs_type->Is()) || + (lhs_type->Is() && rhs_type->Is()) || + (lhs_type->Is() && rhs_type->Is()))) { // Matrices are transposed, so swap LHS and RHS. out << "mul("; if (!EmitExpression(pre, out, expr->rhs())) { @@ -865,7 +865,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, return false; } - auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); + auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); switch (intrinsic->Type()) { case sem::IntrinsicType::kTextureDimensions: @@ -873,37 +873,37 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, 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(); + bool is_ms = texture_type->Is(); 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 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, 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 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, 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 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, 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 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, } auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) { - auto* i32 = builder_.create(); + auto* i32 = builder_.create(); auto* zero = builder_.Expr(0); auto* stmt = builder_.Sem().Get(vector)->Stmt(); builder_.Sem().Add(zero, builder_.create(zero, i32, stmt)); @@ -1317,7 +1317,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre, bool brackets = expr->type() ->UnwrapAliasIfNeeded() - ->IsAnyOf(); + ->IsAnyOf(); if (brackets) { out << "{"; @@ -1644,7 +1644,7 @@ bool GeneratorImpl::EmitFunctionInternal(std::ostream& out, return false; } // Array name is output as part of the type - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(v->symbol()); } } @@ -1708,7 +1708,7 @@ bool GeneratorImpl::EmitEntryPointData( } auto* type = var->Type()->UnwrapIfNeeded(); - if (auto* strct = type->As()) { + if (auto* strct = type->As()) { out << "ConstantBuffer<" << builder_.Symbols().NameFor(strct->symbol()) << "> " << builder_.Symbols().NameFor(decl->symbol()) << RegisterAndSpace('b', binding_point) << ";" << std::endl; @@ -1750,7 +1750,7 @@ bool GeneratorImpl::EmitEntryPointData( continue; // Global already emitted } - auto* access = var->Type()->As(); + auto* access = var->Type()->As(); if (access == nullptr) { diagnostics_.add_error("access control type required for storage buffer"); return false; @@ -1910,22 +1910,22 @@ bool GeneratorImpl::EmitEntryPointData( if (!EmitType(out, var->DeclaredType(), var->StorageClass(), name)) { return false; } - if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is()) { + if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is()) { out << " " << name; } const char* register_space = nullptr; - if (unwrapped_type->Is()) { + if (unwrapped_type->Is()) { register_space = "t"; - if (unwrapped_type->Is()) { - if (auto* ac = var->Type()->As()) { + if (unwrapped_type->Is()) { + if (auto* ac = var->Type()->As()) { if (!ac->IsReadOnly()) { register_space = "u"; } } } - } else if (unwrapped_type->Is()) { + } else if (unwrapped_type->Is()) { register_space = "s"; } @@ -2007,7 +2007,7 @@ bool GeneratorImpl::EmitEntryPointFunction(std::ostream& out, 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()) { + if (!func->return_type()->Is()) { TINT_ICE(diagnostics_) << "Mixing module-scope variables and return " "types for shader outputs"; } @@ -2030,7 +2030,7 @@ bool GeneratorImpl::EmitEntryPointFunction(std::ostream& out, for (auto* var : func->params()) { auto* sem = builder_.Sem().Get(var); auto* type = sem->Type(); - if (!type->Is()) { + if (!type->Is()) { TINT_ICE(diagnostics_) << "Unsupported non-struct entry point parameter"; } @@ -2097,16 +2097,16 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, ast::Literal* lit) { return true; } -bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) { - if (type->Is()) { +bool GeneratorImpl::EmitZeroValue(std::ostream& out, sem::Type* type) { + if (type->Is()) { out << "false"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0.0f"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0u"; - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { if (!EmitType(out, type, ast::StorageClass::kNone, "")) { return false; } @@ -2119,7 +2119,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) { return false; } } - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { if (!EmitType(out, type, ast::StorageClass::kNone, "")) { return false; } @@ -2132,7 +2132,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) { return false; } } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { out << "{"; bool first = true; for (auto* member : str->impl()->members()) { @@ -2310,7 +2310,7 @@ bool GeneratorImpl::EmitStatement(std::ostream& out, ast::Statement* stmt) { return false; } out << pre.str(); - if (!TypeOf(c->expr())->Is()) { + if (!TypeOf(c->expr())->Is()) { out << "(void) "; } out << call_out.str() << ";" << std::endl; @@ -2375,10 +2375,10 @@ bool GeneratorImpl::EmitSwitch(std::ostream& out, ast::SwitchStatement* stmt) { } bool GeneratorImpl::EmitType(std::ostream& out, - type::Type* type, + sem::Type* type, ast::StorageClass storage_class, const std::string& name) { - auto* access = type->As(); + auto* access = type->As(); if (access) { type = access->type(); } @@ -2396,12 +2396,12 @@ bool GeneratorImpl::EmitType(std::ostream& out, return true; } - if (auto* alias = type->As()) { + if (auto* alias = type->As()) { out << builder_.Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { - type::Type* base_type = ary; + } else if (auto* ary = type->As()) { + sem::Type* base_type = ary; std::vector sizes; - while (auto* arr = base_type->As()) { + while (auto* arr = base_type->As()) { if (arr->IsRuntimeArray()) { TINT_ICE(diagnostics_) << "Runtime arrays may only exist in storage buffers, which should " @@ -2420,13 +2420,13 @@ bool GeneratorImpl::EmitType(std::ostream& out, for (uint32_t size : sizes) { out << "[" << size << "]"; } - } else if (type->Is()) { + } else if (type->Is()) { out << "bool"; - } else if (type->Is()) { + } else if (type->Is()) { out << "float"; - } else if (type->Is()) { + } else if (type->Is()) { out << "int"; - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { if (!EmitType(out, mat->type(), storage_class, "")) { return false; } @@ -2438,23 +2438,23 @@ bool GeneratorImpl::EmitType(std::ostream& out, // 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()) { + } else if (type->Is()) { // 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()) { + } else if (auto* sampler = type->As()) { out << "Sampler"; if (sampler->IsComparison()) { out << "Comparison"; } out << "State"; - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { out << builder_.Symbols().NameFor(str->symbol()); - } else if (auto* tex = type->As()) { - auto* storage = tex->As(); - auto* multism = tex->As(); - auto* sampled = tex->As(); + } else if (auto* tex = type->As()) { + auto* storage = tex->As(); + auto* multism = tex->As(); + auto* sampled = tex->As(); if (storage) { if (access && !access->IsReadOnly()) { @@ -2464,22 +2464,22 @@ bool GeneratorImpl::EmitType(std::ostream& out, 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 @@ bool GeneratorImpl::EmitType(std::ostream& out, } else if (sampled || multism) { auto* subtype = sampled ? sampled->type() : multism->type(); out << "<"; - if (subtype->Is()) { + if (subtype->Is()) { out << "float4"; - } else if (subtype->Is()) { + } else if (subtype->Is()) { out << "int4"; - } else if (subtype->Is()) { + } else if (subtype->Is()) { out << "uint4"; } else { TINT_ICE(diagnostics_) << "Unsupported multisampled texture type"; @@ -2511,15 +2511,15 @@ bool GeneratorImpl::EmitType(std::ostream& out, } out << ">"; } - } else if (type->Is()) { + } else if (type->Is()) { out << "uint"; - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { auto size = vec->size(); - if (vec->type()->Is() && size >= 1 && size <= 4) { + if (vec->type()->Is() && size >= 1 && size <= 4) { out << "float" << size; - } else if (vec->type()->Is() && size >= 1 && size <= 4) { + } else if (vec->type()->Is() && size >= 1 && size <= 4) { out << "int" << size; - } else if (vec->type()->Is() && size >= 1 && size <= 4) { + } else if (vec->type()->Is() && size >= 1 && size <= 4) { out << "uint" << size; } else { out << "vector<"; @@ -2528,7 +2528,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } out << ", " << size << ">"; } - } else if (type->Is()) { + } else if (type->Is()) { out << "void"; } else { diagnostics_.add_error("unknown type in EmitType"); @@ -2539,7 +2539,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } 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 @@ bool GeneratorImpl::EmitStructType(std::ostream& out, return false; } // Array member name will be output with the type - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { out << " " << builder_.Symbols().NameFor(mem->symbol()); } @@ -2664,7 +2664,7 @@ bool GeneratorImpl::EmitVariable(std::ostream& out, builder_.Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(var->symbol()); } out << constructor_out.str() << ";" << std::endl; @@ -2726,7 +2726,7 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out, builder_.Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(var->symbol()); } diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h index 4e5410a584..0059fc05c0 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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// @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 923ee9bf02..0f73a3092b 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -395,7 +395,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, {create()}); - 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 @@ TEST_F(HlslGeneratorImplTest_Function, }, {create()}); - 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 @@ TEST_F(HlslGeneratorImplTest_Function, }, {create()}); - 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 @@ TEST_F(HlslGeneratorImplTest_Function, }, {create()}); - 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 @@ TEST_F(HlslGeneratorImplTest_Function, Structure("Data", {Member("d", ty.f32())}, ast::DecorationList{create()}); - 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 04aeb5eca7..dec727599d 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 @@ namespace { 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 -inline type::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_vec2(const ProgramBuilder::TypesBuilder& ty) { return ty.vec2(); } template -inline type::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_vec3(const ProgramBuilder::TypesBuilder& ty) { return ty.vec3(); } template -inline type::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_vec4(const ProgramBuilder::TypesBuilder& ty) { return ty.vec4(); } template -inline type::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat2x2(const ProgramBuilder::TypesBuilder& ty) { return ty.mat2x2(); } template -inline type::Type* ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat2x3(const ProgramBuilder::TypesBuilder& ty) { return ty.mat2x3(); } template -inline type::Type* ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat2x4(const ProgramBuilder::TypesBuilder& ty) { return ty.mat2x4(); } template -inline type::Type* ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat3x2(const ProgramBuilder::TypesBuilder& ty) { return ty.mat3x2(); } template -inline type::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat3x3(const ProgramBuilder::TypesBuilder& ty) { return ty.mat3x3(); } template -inline type::Type* ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat3x4(const ProgramBuilder::TypesBuilder& ty) { return ty.mat3x4(); } template -inline type::Type* ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat4x2(const ProgramBuilder::TypesBuilder& ty) { return ty.mat4x2(); } template -inline type::Type* ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat4x3(const ProgramBuilder::TypesBuilder& ty) { return ty.mat4x3(); } template -inline type::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) { +inline sem::Type* ty_mat4x4(const ProgramBuilder::TypesBuilder& ty) { return ty.mat4x4(); } @@ -100,7 +100,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { b.Structure("Data", members, {b.create()}); auto* ac_ty = - b.create(ast::AccessControl::kReadWrite, s); + b.create(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 2f40138568..70937135bc 100644 --- a/src/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/writer/hlsl/generator_impl_sanitizer_test.cc @@ -35,7 +35,7 @@ TEST_F(HlslSanitizerTest, ArrayLength) { create(), }); auto* ac_ty = - create(ast::AccessControl::kReadOnly, sb_ty); + create(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 d9bb495fcb..de367173b4 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -146,7 +146,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix) { // 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, EmitType_Void) { } 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, EmitSampler) { } TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { - type::Sampler sampler(type::SamplerKind::kComparisonSampler); + sem::Sampler sampler(sem::SamplerKind::kComparisonSampler); GeneratorImpl& gen = Build(); @@ -315,7 +315,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { } struct HlslDepthTextureData { - type::TextureDimension dim; + sem::TextureDimension dim; std::string result; }; inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) { @@ -326,7 +326,7 @@ using HlslDepthTexturesTest = TestParamHelper; TEST_P(HlslDepthTexturesTest, Emit) { auto params = GetParam(); - auto* t = create(params.dim); + auto* t = create(params.dim); Global("tex", t, ast::StorageClass::kUniformConstant, nullptr, ast::DecorationList{ @@ -349,18 +349,18 @@ INSTANTIATE_TEST_SUITE_P( 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 @@ using HlslSampledTexturesTest = TestParamHelper; 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 @@ TEST_P(HlslSampledTexturesTest, Emit) { datatype = ty.i32(); break; } - auto* t = create(params.dim, datatype); + auto* t = create(params.dim, datatype); Global("tex", t, ast::StorageClass::kUniformConstant, nullptr, ast::DecorationList{ @@ -409,98 +409,98 @@ INSTANTIATE_TEST_SUITE_P( HlslSampledTexturesTest, testing::Values( HlslSampledTextureData{ - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::F32, "Texture1D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::F32, "Texture2D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::F32, "Texture2DArray tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::F32, "Texture3D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCube, + sem::TextureDimension::kCube, TextureDataType::F32, "TextureCube tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCubeArray, + sem::TextureDimension::kCubeArray, TextureDataType::F32, "TextureCubeArray tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::U32, "Texture1D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::U32, "Texture2D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::U32, "Texture2DArray tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::U32, "Texture3D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCube, + sem::TextureDimension::kCube, TextureDataType::U32, "TextureCube tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCubeArray, + sem::TextureDimension::kCubeArray, TextureDataType::U32, "TextureCubeArray tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k1d, + sem::TextureDimension::k1d, TextureDataType::I32, "Texture1D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2d, + sem::TextureDimension::k2d, TextureDataType::I32, "Texture2D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k2dArray, + sem::TextureDimension::k2dArray, TextureDataType::I32, "Texture2DArray tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::k3d, + sem::TextureDimension::k3d, TextureDataType::I32, "Texture3D tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCube, + sem::TextureDimension::kCube, TextureDataType::I32, "TextureCube tex : register(t1, space2);", }, HlslSampledTextureData{ - type::TextureDimension::kCubeArray, + sem::TextureDimension::kCubeArray, TextureDataType::I32, "TextureCubeArray 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 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { } struct HlslStorageTextureData { - type::TextureDimension dim; - type::ImageFormat imgfmt; + sem::TextureDimension dim; + sem::ImageFormat imgfmt; bool ro; std::string result; }; @@ -524,12 +524,12 @@ using HlslStorageTexturesTest = TestParamHelper; TEST_P(HlslStorageTexturesTest, Emit) { auto params = GetParam(); - auto* subtype = type::StorageTexture::SubtypeFor(params.imgfmt, Types()); - auto* t = create(params.dim, params.imgfmt, subtype); + auto* subtype = sem::StorageTexture::SubtypeFor(params.imgfmt, Types()); + auto* t = create(params.dim, params.imgfmt, subtype); auto* ac = - create(params.ro ? ast::AccessControl::kReadOnly - : ast::AccessControl::kWriteOnly, - t); + create(params.ro ? ast::AccessControl::kReadOnly + : ast::AccessControl::kWriteOnly, + t); Global("tex", ac, ast::StorageClass::kUniformConstant, nullptr, ast::DecorationList{ @@ -552,44 +552,44 @@ INSTANTIATE_TEST_SUITE_P( HlslGeneratorImplTest_Type, HlslStorageTexturesTest, testing::Values( - HlslStorageTextureData{type::TextureDimension::k1d, - type::ImageFormat::kRgba8Unorm, true, + HlslStorageTextureData{sem::TextureDimension::k1d, + sem::ImageFormat::kRgba8Unorm, true, "Texture1D tex : register(t1, space2);"}, - HlslStorageTextureData{type::TextureDimension::k2d, - type::ImageFormat::kRgba16Float, true, + HlslStorageTextureData{sem::TextureDimension::k2d, + sem::ImageFormat::kRgba16Float, true, "Texture2D tex : register(t1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k2dArray, type::ImageFormat::kR32Float, - true, "Texture2DArray tex : register(t1, space2);"}, - HlslStorageTextureData{type::TextureDimension::k3d, - type::ImageFormat::kRg32Float, true, + sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Float, true, + "Texture2DArray tex : register(t1, space2);"}, + HlslStorageTextureData{sem::TextureDimension::k3d, + sem::ImageFormat::kRg32Float, true, "Texture3D tex : register(t1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k1d, type::ImageFormat::kRgba32Float, false, + sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Float, false, "RWTexture1D tex : register(u1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k2d, type::ImageFormat::kRgba16Uint, false, + sem::TextureDimension::k2d, sem::ImageFormat::kRgba16Uint, false, "RWTexture2D tex : register(u1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k2dArray, type::ImageFormat::kR32Uint, - false, "RWTexture2DArray tex : register(u1, space2);"}, + sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Uint, false, + "RWTexture2DArray tex : register(u1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k3d, type::ImageFormat::kRg32Uint, false, + sem::TextureDimension::k3d, sem::ImageFormat::kRg32Uint, false, "RWTexture3D tex : register(u1, space2);"}, - HlslStorageTextureData{type::TextureDimension::k1d, - type::ImageFormat::kRgba32Uint, true, + HlslStorageTextureData{sem::TextureDimension::k1d, + sem::ImageFormat::kRgba32Uint, true, "Texture1D tex : register(t1, space2);"}, - HlslStorageTextureData{type::TextureDimension::k2d, - type::ImageFormat::kRgba16Sint, true, + HlslStorageTextureData{sem::TextureDimension::k2d, + sem::ImageFormat::kRgba16Sint, true, "Texture2D tex : register(t1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k2dArray, type::ImageFormat::kR32Sint, true, + sem::TextureDimension::k2dArray, sem::ImageFormat::kR32Sint, true, "Texture2DArray tex : register(t1, space2);"}, - HlslStorageTextureData{type::TextureDimension::k3d, - type::ImageFormat::kRg32Sint, true, + HlslStorageTextureData{sem::TextureDimension::k3d, + sem::ImageFormat::kRg32Sint, true, "Texture3D tex : register(t1, space2);"}, HlslStorageTextureData{ - type::TextureDimension::k1d, type::ImageFormat::kRgba32Sint, false, + sem::TextureDimension::k1d, sem::ImageFormat::kRgba32Sint, false, "RWTexture1D tex : register(u1, space2);"})); } // namespace diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 1c3474bed0..2fb8fc2744 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -145,17 +145,17 @@ bool GeneratorImpl::Generate() { return true; } -bool GeneratorImpl::EmitConstructedType(const type::Type* ty) { +bool GeneratorImpl::EmitConstructedType(const sem::Type* ty) { make_indent(); - if (auto* alias = ty->As()) { + if (auto* alias = ty->As()) { out_ << "typedef "; if (!EmitType(alias->type(), "")) { return false; } out_ << " " << program_->Symbols().NameFor(alias->symbol()) << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(str)) { return false; } @@ -490,27 +490,27 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr, return false; } - auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); + auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); switch (intrinsic->Type()) { case sem::IntrinsicType::kTextureDimensions: { std::vector 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 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr, 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::EmitContinue(ast::ContinueStatement*) { } bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "{"; } else { if (!EmitType(expr->type(), "")) { @@ -915,7 +915,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { } } - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "}"; } else { out_ << ")"; @@ -923,26 +923,26 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { return true; } -bool GeneratorImpl::EmitZeroValue(type::Type* type) { - if (type->Is()) { +bool GeneratorImpl::EmitZeroValue(sem::Type* type) { + if (type->Is()) { out_ << "false"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "0.0f"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "0"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "0u"; - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { return EmitZeroValue(vec->type()); - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { return EmitZeroValue(mat->type()); - } else if (auto* arr = type->As()) { + } else if (auto* arr = type->As()) { out_ << "{"; if (!EmitZeroValue(arr->type())) { return false; } out_ << "}"; - } else if (type->As()) { + } else if (type->As()) { out_ << "{}"; } else { diagnostics_.add_error("Invalid type for zero emission: " + @@ -1296,7 +1296,7 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, } first = false; - auto* ac = var->Type()->As(); + auto* ac = var->Type()->As(); if (ac == nullptr) { diagnostics_.add_error( "invalid type for storage buffer, expected access control"); @@ -1325,7 +1325,7 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, return false; } // Array name is output as part of the type - if (!type->Is()) { + if (!type->Is()) { out_ << " " << program_->Symbols().NameFor(v->symbol()); } } @@ -1395,7 +1395,7 @@ bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) { 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()) { + if (!func->return_type()->Is()) { TINT_ICE(diagnostics_) << "Mixing module-scope variables and return " "types for shader outputs"; } @@ -1429,7 +1429,7 @@ bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) { out_ << " " << program_->Symbols().NameFor(var->symbol()); - if (type->Is()) { + if (type->Is()) { out_ << " [[stage_in]]"; } else { auto& decos = var->decorations(); @@ -1524,7 +1524,7 @@ bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) { auto* binding = data.second.binding; // auto* set = data.second.set; - auto* ac = var->Type()->As(); + auto* ac = var->Type()->As(); if (ac == nullptr) { diagnostics_.add_error( "invalid type for storage buffer, expected access control"); @@ -1891,9 +1891,9 @@ bool GeneratorImpl::EmitSwitch(ast::SwitchStatement* stmt) { 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()) { + if (auto* ac = type->As()) { if (ac->access_control() == ast::AccessControl::kReadOnly) { access_str = "read"; } else if (ac->access_control() == ast::AccessControl::kWriteOnly) { @@ -1906,12 +1906,12 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { type = ac->type(); } - if (auto* alias = type->As()) { + if (auto* alias = type->As()) { out_ << program_->Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { - type::Type* base_type = ary; + } else if (auto* ary = type->As()) { + sem::Type* base_type = ary; std::vector sizes; - while (auto* arr = base_type->As()) { + while (auto* arr = base_type->As()) { if (arr->IsRuntimeArray()) { sizes.push_back(1); } else { @@ -1928,76 +1928,76 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { for (uint32_t size : sizes) { out_ << "[" << size << "]"; } - } else if (type->Is()) { + } else if (type->Is()) { out_ << "bool"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "float"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "int"; - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { if (!EmitType(mat->type(), "")) { return false; } out_ << mat->columns() << "x" << mat->rows(); - } else if (auto* ptr = type->As()) { + } else if (auto* ptr = type->As()) { // TODO(dsinclair): Storage class? if (!EmitType(ptr->type(), "")) { return false; } out_ << "*"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "sampler"; - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { // 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()) { - if (tex->Is()) { + } else if (auto* tex = type->As()) { + if (tex->Is()) { 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()) { + if (tex->Is()) { out_ << "_ms"; } out_ << "<"; - if (tex->Is()) { + if (tex->Is()) { out_ << "float, access::sample"; - } else if (auto* storage = tex->As()) { + } else if (auto* storage = tex->As()) { if (!EmitType(storage->type(), "")) { return false; } out_ << ", access::" << access_str; - } else if (auto* ms = tex->As()) { + } else if (auto* ms = tex->As()) { if (!EmitType(ms->type(), "")) { return false; } out_ << ", access::sample"; - } else if (auto* sampled = tex->As()) { + } else if (auto* sampled = tex->As()) { if (!EmitType(sampled->type(), "")) { return false; } @@ -2008,14 +2008,14 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { } out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "uint"; - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { if (!EmitType(vec->type(), "")) { return false; } out_ << vec->size(); - } else if (type->Is()) { + } else if (type->Is()) { out_ << "void"; } else { diagnostics_.add_error("unknown type in EmitType: " + type->type_name()); @@ -2025,12 +2025,12 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { return true; } -bool GeneratorImpl::EmitPackedType(type::Type* type, const std::string& name) { - if (auto* alias = type->As()) { +bool GeneratorImpl::EmitPackedType(sem::Type* type, const std::string& name) { + if (auto* alias = type->As()) { return EmitPackedType(alias->type(), name); } - if (auto* vec = type->As()) { + if (auto* vec = type->As()) { out_ << "packed_"; if (!EmitType(vec->type(), "")) { return false; @@ -2042,7 +2042,7 @@ bool GeneratorImpl::EmitPackedType(type::Type* type, const std::string& name) { 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 @@ bool GeneratorImpl::EmitStructType(const type::StructType* str) { auto* ty = mem->type()->UnwrapAliasIfNeeded(); // Array member name will be output with the type - if (!ty->Is()) { + if (!ty->Is()) { out_ << " " << program_->Symbols().NameFor(mem->symbol()); } @@ -2222,7 +2222,7 @@ bool GeneratorImpl::EmitVariable(const sem::Variable* var, if (!EmitType(var->Type(), program_->Symbols().NameFor(decl->symbol()))) { return false; } - if (!var->Type()->Is()) { + if (!var->Type()->Is()) { out_ << " " << program_->Symbols().NameFor(decl->symbol()); } @@ -2265,7 +2265,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { if (!EmitType(type, program_->Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out_ << " " << program_->Symbols().NameFor(var->symbol()); } @@ -2283,32 +2283,32 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { } GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( - type::Type* ty) { + sem::Type* ty) { ty = ty->UnwrapAliasIfNeeded(); - if (ty->IsAnyOf()) { + if (ty->IsAnyOf()) { // https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf // 2.1 Scalar Data Types return {4, 4}; } - if (auto* vec = ty->As()) { + if (auto* vec = ty->As()) { // 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()) { + if (el_ty->IsAnyOf()) { return SizeAndAlign{num_els * 4, 4}; } } - if (auto* mat = ty->As()) { + if (auto* mat = ty->As()) { // 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()) { + if (el_ty->IsAnyOf()) { static constexpr SizeAndAlign table[] = { /* float2x2 */ {16, 8}, /* float2x3 */ {32, 16}, @@ -2326,7 +2326,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( } } - if (auto* arr = ty->As()) { + if (auto* arr = ty->As()) { auto* sem = program_->Sem().Get(arr); if (!sem) { TINT_ICE(diagnostics_) << "Array missing semantic info"; @@ -2345,7 +2345,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( return SizeAndAlign{el_size_align.size * num_els, el_size_align.align}; } - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { // 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 c576476538..fd1f9fba8d 100644 --- a/src/writer/msl/generator_impl.h +++ b/src/writer/msl/generator_impl.h @@ -63,7 +63,7 @@ class GeneratorImpl : public TextGenerator { /// 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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// 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 @@ class GeneratorImpl : public TextGenerator { /// @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 @@ class GeneratorImpl : public TextGenerator { /// @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 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 1f91e90672..fb8ae0fe88 100644 --- a/src/writer/msl/generator_impl_binary_test.cc +++ b/src/writer/msl/generator_impl_binary_test.cc @@ -33,8 +33,8 @@ TEST_P(MslBinaryTest, Emit) { auto* type = ((params.op == ast::BinaryOp::kLogicalAnd) || (params.op == ast::BinaryOp::kLogicalOr)) - ? static_cast(ty.bool_()) - : static_cast(ty.u32()); + ? static_cast(ty.bool_()) + : static_cast(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 8cf5908bf6..34b0b315f8 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -314,7 +314,7 @@ TEST_F(MslGeneratorImplTest, }, {create()}); - type::AccessControl ac(ast::AccessControl::kReadWrite, s); + sem::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, ast::DecorationList{create(0), @@ -360,7 +360,7 @@ TEST_F(MslGeneratorImplTest, }, {create()}); - type::AccessControl ac(ast::AccessControl::kReadOnly, s); + sem::AccessControl ac(ast::AccessControl::kReadOnly, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, ast::DecorationList{create(0), @@ -620,7 +620,7 @@ TEST_F(MslGeneratorImplTest, }, {create()}); - type::AccessControl ac(ast::AccessControl::kReadWrite, s); + sem::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, ast::DecorationList{create(0), @@ -678,7 +678,7 @@ TEST_F(MslGeneratorImplTest, }, {create()}); - type::AccessControl ac(ast::AccessControl::kReadOnly, s); + sem::AccessControl ac(ast::AccessControl::kReadOnly, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, ast::DecorationList{create(0), @@ -818,7 +818,7 @@ TEST_F(MslGeneratorImplTest, auto* s = Structure("Data", {Member("d", ty.f32())}, {create()}); - type::AccessControl ac(ast::AccessControl::kReadWrite, s); + sem::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("data", &ac, ast::StorageClass::kStorage, nullptr, ast::DecorationList{create(0), diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index fbad91ae9a..0a00963b97 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -164,7 +164,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix) { // 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_Void) { } 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_Sampler) { } TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) { - type::Sampler sampler(type::SamplerKind::kComparisonSampler); + sem::Sampler sampler(sem::SamplerKind::kComparisonSampler); GeneratorImpl& gen = Build(); @@ -649,7 +649,7 @@ TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) { } struct MslDepthTextureData { - type::TextureDimension dim; + sem::TextureDimension dim; std::string result; }; inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) { @@ -660,7 +660,7 @@ using MslDepthTexturesTest = TestParamHelper; TEST_P(MslDepthTexturesTest, Emit) { auto params = GetParam(); - type::DepthTexture s(params.dim); + sem::DepthTexture s(params.dim); GeneratorImpl& gen = Build(); @@ -670,18 +670,18 @@ TEST_P(MslDepthTexturesTest, Emit) { INSTANTIATE_TEST_SUITE_P( MslGeneratorImplTest, MslDepthTexturesTest, - testing::Values(MslDepthTextureData{type::TextureDimension::k2d, + testing::Values(MslDepthTextureData{sem::TextureDimension::k2d, "depth2d"}, - MslDepthTextureData{type::TextureDimension::k2dArray, + MslDepthTextureData{sem::TextureDimension::k2dArray, "depth2d_array"}, - MslDepthTextureData{type::TextureDimension::kCube, + MslDepthTextureData{sem::TextureDimension::kCube, "depthcube"}, MslDepthTextureData{ - type::TextureDimension::kCubeArray, + sem::TextureDimension::kCubeArray, "depthcube_array"})); struct MslTextureData { - type::TextureDimension dim; + sem::TextureDimension dim; std::string result; }; inline std::ostream& operator<<(std::ostream& out, MslTextureData data) { @@ -692,7 +692,7 @@ using MslSampledtexturesTest = TestParamHelper; 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 @@ TEST_P(MslSampledtexturesTest, Emit) { INSTANTIATE_TEST_SUITE_P( MslGeneratorImplTest, MslSampledtexturesTest, - testing::Values(MslTextureData{type::TextureDimension::k1d, + testing::Values(MslTextureData{sem::TextureDimension::k1d, "texture1d"}, - MslTextureData{type::TextureDimension::k2d, + MslTextureData{sem::TextureDimension::k2d, "texture2d"}, - MslTextureData{type::TextureDimension::k2dArray, + MslTextureData{sem::TextureDimension::k2dArray, "texture2d_array"}, - MslTextureData{type::TextureDimension::k3d, + MslTextureData{sem::TextureDimension::k3d, "texture3d"}, - MslTextureData{type::TextureDimension::kCube, + MslTextureData{sem::TextureDimension::kCube, "texturecube"}, MslTextureData{ - type::TextureDimension::kCubeArray, + sem::TextureDimension::kCubeArray, "texturecube_array"})); 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 @@ TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { } struct MslStorageTextureData { - type::TextureDimension dim; + sem::TextureDimension dim; bool ro; std::string result; }; @@ -739,13 +739,13 @@ TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()); - auto* s = create(params.dim, - type::ImageFormat::kR16Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()); + auto* s = create(params.dim, sem::ImageFormat::kR16Float, + subtype); auto* ac = - create(params.ro ? ast::AccessControl::kReadOnly - : ast::AccessControl::kWriteOnly, - s); + create(params.ro ? ast::AccessControl::kReadOnly + : ast::AccessControl::kWriteOnly, + s); Global("test_var", ac, ast::StorageClass::kInput); GeneratorImpl& gen = Build(); @@ -757,21 +757,21 @@ INSTANTIATE_TEST_SUITE_P( MslGeneratorImplTest, MslStorageTexturesTest, testing::Values( - MslStorageTextureData{type::TextureDimension::k1d, true, + MslStorageTextureData{sem::TextureDimension::k1d, true, "texture1d"}, - MslStorageTextureData{type::TextureDimension::k2d, true, + MslStorageTextureData{sem::TextureDimension::k2d, true, "texture2d"}, - MslStorageTextureData{type::TextureDimension::k2dArray, true, + MslStorageTextureData{sem::TextureDimension::k2dArray, true, "texture2d_array"}, - MslStorageTextureData{type::TextureDimension::k3d, true, + MslStorageTextureData{sem::TextureDimension::k3d, true, "texture3d"}, - MslStorageTextureData{type::TextureDimension::k1d, false, + MslStorageTextureData{sem::TextureDimension::k1d, false, "texture1d"}, - MslStorageTextureData{type::TextureDimension::k2d, false, + MslStorageTextureData{sem::TextureDimension::k2d, false, "texture2d"}, - MslStorageTextureData{type::TextureDimension::k2dArray, false, + MslStorageTextureData{sem::TextureDimension::k2dArray, false, "texture2d_array"}, - MslStorageTextureData{type::TextureDimension::k3d, false, + MslStorageTextureData{sem::TextureDimension::k3d, false, "texture3d"})); } // 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 72d6ade695..fce13d20bb 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_Const) { } 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(var); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index a78dad2e45..fd80ef3df6 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -111,11 +111,11 @@ uint32_t IndexFromName(char name) { /// 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()) { +sem::Matrix* GetNestedMatrixType(sem::Type* type) { + while (auto* arr = type->As()) { type = arr->type(); } - return type->As(); + return type->As(); } uint32_t intrinsic_to_glsl_method(const sem::Intrinsic* intrinsic) { @@ -251,8 +251,8 @@ uint32_t intrinsic_to_glsl_method(const sem::Intrinsic* intrinsic) { } /// @return the vector element type if ty is a vector, otherwise return ty. -type::Type* ElementTypeOf(type::Type* ty) { - if (auto* v = ty->As()) { +sem::Type* ElementTypeOf(sem::Type* ty) { + if (auto* v = ty->As()) { return v->type(); } return ty; @@ -632,7 +632,7 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) { 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 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { ? 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 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { auto* type_no_ac = sem->Type()->UnwrapAll(); if (var->has_constructor()) { ops.push_back(Operand::Int(init_id)); - } else if (type_no_ac->Is()) { - if (auto* ac = sem->Type()->As()) { + } else if (type_no_ac->Is()) { + if (auto* ac = sem->Type()->As()) { switch (ac->access_control()) { case ast::AccessControl::kWriteOnly: push_annot( @@ -742,7 +742,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { break; } } - } else if (!type_no_ac->Is()) { + } else if (!type_no_ac->Is()) { // 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 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { // 2- If we don't have a constructor and we're an Output or Private variable // then WGSL requires an initializer. if (ast::HasDecoration(var->decorations())) { - if (type_no_ac->Is()) { + if (type_no_ac->Is()) { ast::FloatLiteral l(ProgramID(), Source{}, type_no_ac, 0.0f); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type_no_ac->Is()) { + } else if (type_no_ac->Is()) { ast::UintLiteral l(ProgramID(), Source{}, type_no_ac, 0); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type_no_ac->Is()) { + } else if (type_no_ac->Is()) { ast::SintLiteral l(ProgramID(), Source{}, type_no_ac, 0); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type_no_ac->Is()) { + } else if (type_no_ac->Is()) { ast::BoolLiteral l(ProgramID(), Source{}, type_no_ac, false); init_id = GenerateLiteralIfNeeded(var, &l); } else { @@ -826,9 +826,9 @@ bool Builder::GenerateArrayAccessor(ast::ArrayAccessorExpression* expr, // 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() || - (info->source_type->Is() && - !info->source_type->As()->type()->is_scalar())) { + if (info->source_type->Is() || + (info->source_type->Is() && + !info->source_type->As()->type()->is_scalar())) { info->access_chain_indices.push_back(idx_id); info->source_type = TypeOf(expr); return true; @@ -864,8 +864,8 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, // 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()) { - auto* strct = data_type->As()->impl(); + if (data_type->Is()) { + auto* strct = data_type->As()->impl(); auto symbol = expr->member()->symbol(); uint32_t idx = 0; @@ -876,7 +876,7 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, } } - if (info->source_type->Is()) { + if (info->source_type->Is()) { auto idx_id = GenerateConstantIfNeeded(ScalarConstant::U32(idx)); if (idx_id == 0) { return 0; @@ -905,7 +905,7 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, return true; } - if (!data_type->Is()) { + if (!data_type->Is()) { error_ = "Member accessor without a struct or vector. Something is wrong"; return false; } @@ -920,7 +920,7 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, return false; } - if (info->source_type->Is()) { + if (info->source_type->Is()) { auto idx_id = GenerateConstantIfNeeded(ScalarConstant::U32(val)); if (idx_id == 0) { return 0; @@ -1044,10 +1044,10 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) { if (auto* array = accessors[0]->As()) { auto* ary_res_type = TypeOf(array->array()); - if (!ary_res_type->Is() && - (ary_res_type->Is() && - !ary_res_type->As()->type()->is_scalar())) { - type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction); + if (!ary_res_type->Is() && + (ary_res_type->Is() && + !ary_res_type->As()->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 @@ uint32_t Builder::GenerateIdentifierExpression( return 0; } -uint32_t Builder::GenerateLoadIfNeeded(type::Type* type, uint32_t id) { - if (!type->Is()) { +uint32_t Builder::GenerateLoadIfNeeded(sem::Type* type, uint32_t id) { + if (!type->Is()) { return id; } @@ -1236,7 +1236,7 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { } auto* sc = e->As(); - if (result_type->Is() && sc == nullptr) { + if (result_type->Is() && sc == nullptr) { return false; } @@ -1245,14 +1245,14 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { continue; } - type::Type* subtype = result_type->UnwrapAll(); - if (auto* vec = subtype->As()) { + sem::Type* subtype = result_type->UnwrapAll(); + if (auto* vec = subtype->As()) { subtype = vec->type()->UnwrapAll(); - } else if (auto* mat = subtype->As()) { + } else if (auto* mat = subtype->As()) { subtype = mat->type()->UnwrapAll(); - } else if (auto* arr = subtype->As()) { + } else if (auto* arr = subtype->As()) { subtype = arr->type()->UnwrapAll(); - } else if (auto* str = subtype->As()) { + } else if (auto* str = subtype->As()) { subtype = str->impl()->members()[i]->type()->UnwrapAll(); } if (subtype != TypeOf(sc)->UnwrapAll()) { @@ -1283,10 +1283,10 @@ uint32_t Builder::GenerateTypeConstructorExpression( bool can_cast_or_copy = result_type->is_scalar(); - if (auto* res_vec = result_type->As()) { + if (auto* res_vec = result_type->As()) { if (res_vec->type()->is_scalar()) { auto* value_type = TypeOf(values[0])->UnwrapAll(); - if (auto* val_vec = value_type->As()) { + if (auto* val_vec = value_type->As()) { if (val_vec->type()->is_scalar()) { can_cast_or_copy = res_vec->size() == val_vec->size(); } @@ -1306,7 +1306,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( bool result_is_constant_composite = constructor_is_const; bool result_is_spec_composite = false; - if (auto* vec = result_type->As()) { + if (auto* vec = result_type->As()) { result_type = vec->type(); } @@ -1328,9 +1328,9 @@ uint32_t Builder::GenerateTypeConstructorExpression( // 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() || - result_type->Is() || - result_type->Is()) { + if (result_type == value_type || result_type->Is() || + result_type->Is() || + result_type->Is()) { out << "_" << id; ops.push_back(Operand::Int(id)); @@ -1355,7 +1355,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( // // 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()) { + if (auto* vec = value_type->As()) { auto* vec_type = vec->type(); auto value_type_id = GenerateTypeIfNeeded(vec_type); @@ -1426,7 +1426,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( 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 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(type::Type* to_type, auto* from_type = TypeOf(from_expr)->UnwrapPtrIfNeeded(); spv::Op op = spv::Op::OpNop; - if ((from_type->Is() && to_type->Is()) || + if ((from_type->Is() && to_type->Is()) || (from_type->is_signed_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertSToF; - } else if ((from_type->Is() && to_type->Is()) || + } else if ((from_type->Is() && to_type->Is()) || (from_type->is_unsigned_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertUToF; - } else if ((from_type->Is() && to_type->Is()) || + } else if ((from_type->Is() && to_type->Is()) || (from_type->is_float_vector() && to_type->is_signed_integer_vector())) { op = spv::Op::OpConvertFToS; - } else if ((from_type->Is() && to_type->Is()) || + } else if ((from_type->Is() && to_type->Is()) || (from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) { op = spv::Op::OpConvertFToU; - } else if ((from_type->Is() && to_type->Is()) || - (from_type->Is() && to_type->Is()) || - (from_type->Is() && to_type->Is()) || - (from_type->Is() && to_type->Is()) || - (from_type->Is() && (from_type == to_type))) { + } else if ((from_type->Is() && to_type->Is()) || + (from_type->Is() && to_type->Is()) || + (from_type->Is() && to_type->Is()) || + (from_type->Is() && to_type->Is()) || + (from_type->Is() && (from_type == to_type))) { return val_id; - } else if ((from_type->Is() && to_type->Is()) || - (from_type->Is() && to_type->Is()) || + } else if ((from_type->Is() && to_type->Is()) || + (from_type->Is() && to_type->Is()) || (from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) || (from_type->is_unsigned_integer_vector() && @@ -1528,22 +1528,22 @@ uint32_t Builder::GenerateConstantIfNeeded(const ScalarConstant& constant) { 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 @@ uint32_t Builder::GenerateConstantIfNeeded(const ScalarConstant& constant) { 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 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, params.push_back(Operand::Int(struct_id)); auto* type = TypeOf(accessor->structure())->UnwrapAll(); - if (!type->Is()) { + if (!type->Is()) { 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()->impl()->members().size() - 1))); + params.push_back(Operand::Int( + uint32_t(type->As()->impl()->members().size() - 1))); if (!push_function_inst(spv::Op::OpArrayLength, params)) { return 0; @@ -2077,7 +2077,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, return false; } - if (!param.type->Is()) { + if (!param.type->Is()) { val_id = GenerateLoadIfNeeded(TypeOf(arg), val_id); } @@ -2132,7 +2132,7 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, TINT_ICE(builder_.Diagnostics()) << "missing texture argument"; } - auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); + auto* texture_type = TypeOf(texture)->UnwrapAll()->As(); auto op = spv::Op::OpNop; @@ -2168,9 +2168,9 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, // 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()) { - auto* f32 = builder_.create(); - auto* spirv_result_type = builder_.create(f32, 4); + if (texture_type->Is()) { + auto* f32 = builder_.create(); + auto* spirv_result_type = builder_.create(f32, 4); auto spirv_result = result_op(); post_emission = [=] { return push_function_inst( @@ -2202,7 +2202,7 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, auto* element_type = ElementTypeOf(TypeOf(call)); auto spirv_result = result_op(); auto* spirv_result_type = - builder_.create(element_type, spirv_result_width); + builder_.create(element_type, spirv_result_width); if (swizzle.size() > 1) { post_emission = [=] { OperandList operands{ @@ -2271,22 +2271,22 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, std::vector 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 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, } spirv_params.emplace_back(gen_arg(Usage::kTexture)); - if (texture_type->Is() || - texture_type->Is()) { + if (texture_type->Is() || + texture_type->Is()) { 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(), 0); + builder_.create(), 0); op = spv::Op::OpImageQuerySizeLod; spirv_params.emplace_back( Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0))); @@ -2319,8 +2319,8 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, 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 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, spirv_params.emplace_back(gen_arg(Usage::kTexture)); - if (texture_type->Is() || - texture_type->Is()) { + if (texture_type->Is() || + texture_type->Is()) { op = spv::Op::OpImageQuerySize; } else { ast::SintLiteral i32_0(ProgramID(), Source{}, - builder_.create(), 0); + builder_.create(), 0); op = spv::Op::OpImageQuerySizeLod; spirv_params.emplace_back( Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0))); @@ -2359,8 +2359,8 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, break; } case IntrinsicType::kTextureLoad: { - op = texture_type->Is() ? spv::Op::OpImageRead - : spv::Op::OpImageFetch; + op = texture_type->Is() ? 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 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, return false; } auto level = Operand::Int(0); - if (TypeOf(arg(Usage::kLevel))->Is()) { + if (TypeOf(arg(Usage::kLevel))->Is()) { // Depth textures have i32 parameters for the level, but SPIR-V expects // F32. Cast. - auto* f32 = builder_.create(); + auto* f32 = builder_.create(); ast::TypeConstructorExpression cast(ProgramID(), Source{}, f32, {arg(Usage::kLevel)}); level = Operand::Int(GenerateExpression(&cast)); @@ -2449,7 +2449,7 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call, } 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 @@ bool Builder::GenerateControlBarrierIntrinsic(const sem::Intrinsic* intrinsic) { }); } -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 @@ bool Builder::GenerateVariableDeclStatement(ast::VariableDeclStatement* stmt) { 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()) { + if (auto* alias = type->As()) { return GenerateTypeIfNeeded(alias->type()); } - if (auto* ac = type->As()) { - if (!ac->type()->UnwrapIfNeeded()->Is()) { + if (auto* ac = type->As()) { + if (!ac->type()->UnwrapIfNeeded()->Is()) { return GenerateTypeIfNeeded(ac->type()); } } @@ -2947,48 +2947,48 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { auto result = result_op(); auto id = result.to_i(); - if (auto* ac = type->As()) { + if (auto* ac = type->As()) { // The non-struct case was handled above. auto* subtype = ac->type()->UnwrapIfNeeded(); - if (!GenerateStructType(subtype->As(), + if (!GenerateStructType(subtype->As(), ac->access_control(), result)) { return 0; } - } else if (auto* arr = type->As()) { + } else if (auto* arr = type->As()) { if (!GenerateArrayType(arr, result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeBool, {result}); - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)}); - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(1)}); - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { if (!GenerateMatrixType(mat, result)) { return 0; } - } else if (auto* ptr = type->As()) { + } else if (auto* ptr = type->As()) { if (!GeneratePointerType(ptr, result)) { return 0; } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { if (!GenerateStructType(str, ast::AccessControl::kReadWrite, result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)}); - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { if (!GenerateVectorType(vec, result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeVoid, {result}); - } else if (auto* tex = type->As()) { + } else if (auto* tex = type->As()) { if (!GenerateTextureType(tex, result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeSampler, {result}); // Register both of the sampler type names. In SPIR-V they're the same @@ -3006,65 +3006,64 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { } // 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()) { + if (texture->Is()) { push_capability(SpvCapabilitySampled1D); - } else if (texture->Is()) { + } else if (texture->Is()) { 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()) { + if (texture->Is()) { ms_literal = 1u; } uint32_t depth_literal = 0u; - if (texture->Is()) { + if (texture->Is()) { depth_literal = 1u; } uint32_t sampled_literal = 2u; - if (texture->Is() || - texture->Is() || - texture->Is()) { + if (texture->Is() || + texture->Is() || texture->Is()) { sampled_literal = 1u; } - if (dim == type::TextureDimension::kCubeArray) { - if (texture->Is() || - texture->Is()) { + if (dim == sem::TextureDimension::kCubeArray) { + if (texture->Is() || + texture->Is()) { push_capability(SpvCapabilitySampledCubeArray); } } uint32_t type_id = 0u; - if (texture->Is()) { - type::F32 f32; + if (texture->Is()) { + sem::F32 f32; type_id = GenerateTypeIfNeeded(&f32); - } else if (auto* s = texture->As()) { + } else if (auto* s = texture->As()) { type_id = GenerateTypeIfNeeded(s->type()); - } else if (auto* ms = texture->As()) { + } else if (auto* ms = texture->As()) { type_id = GenerateTypeIfNeeded(ms->type()); - } else if (auto* st = texture->As()) { + } else if (auto* st = texture->As()) { type_id = GenerateTypeIfNeeded(st->type()); } if (type_id == 0u) { @@ -3072,7 +3071,7 @@ bool Builder::GenerateTextureType(type::Texture* texture, } uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown; - if (auto* t = texture->As()) { + if (auto* t = texture->As()) { format_literal = convert_image_format_to_spv(t->image_format()); } @@ -3085,7 +3084,7 @@ bool Builder::GenerateTextureType(type::Texture* texture, 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 @@ bool Builder::GenerateArrayType(type::ArrayType* ary, const Operand& result) { 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 @@ bool Builder::GenerateMatrixType(type::Matrix* mat, const Operand& result) { 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 @@ bool Builder::GeneratePointerType(type::Pointer* ptr, const Operand& result) { 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 @@ uint32_t Builder::GenerateStructMember(uint32_t struct_id, push_annot(spv::Op::OpMemberDecorate, {Operand::Int(struct_id), Operand::Int(idx), Operand::Int(SpvDecorationColMajor)}); - if (!matrix_type->type()->Is()) { + if (!matrix_type->type()->Is()) { error_ = "matrix scalar element type must be f32"; return 0; } @@ -3238,7 +3237,7 @@ uint32_t Builder::GenerateStructMember(uint32_t struct_id, 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 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin, } 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 f45918db68..878ab25018 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -65,7 +65,7 @@ class Builder { 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 access_chain_indices; @@ -263,7 +263,7 @@ class Builder { /// @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 @@ class Builder { /// @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 @@ class Builder { /// @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 @@ class Builder { /// @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 @@ class Builder { /// 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 @@ class Builder { /// @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 @@ class Builder { /// @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 @@ class Builder { /// 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 c5f3994600..62fcd234f5 100644 --- a/src/writer/spirv/builder_format_conversion_test.cc +++ b/src/writer/spirv/builder_format_conversion_test.cc @@ -21,7 +21,7 @@ namespace spirv { namespace { struct TestData { - type::ImageFormat ast_format; + sem::ImageFormat ast_format; SpvImageFormat_ spv_format; bool extended_format = false; }; @@ -51,42 +51,42 @@ INSTANTIATE_TEST_SUITE_P( 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 be78a581e6..2f951b42b7 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -206,7 +206,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* s = Structure("Data", {Member("d", ty.f32())}, {create()}); - 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 6b541efdd9..fad90dd2cc 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -394,7 +394,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { Member("b", ty.i32()), }, {create()}); - auto* ac = create(ast::AccessControl::kReadOnly, A); + auto* ac = create(ast::AccessControl::kReadOnly, A); auto* var = Global("b", ac, ast::StorageClass::kStorage); @@ -430,7 +430,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}, {create()}); auto* B = ty.alias("B", A); - auto* ac = create(ast::AccessControl::kReadOnly, B); + auto* ac = create(ast::AccessControl::kReadOnly, B); auto* var = Global("b", ac, ast::StorageClass::kStorage); spirv::Builder& b = Build(); @@ -461,7 +461,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}, {create()}); - auto* ac = create(ast::AccessControl::kReadOnly, A); + auto* ac = create(ast::AccessControl::kReadOnly, A); auto* B = ty.alias("B", ac); auto* var = Global("b", B, ast::StorageClass::kStorage); @@ -493,8 +493,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}, {create()}); - 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 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) { // var a : [[access(read)]] texture_storage_2d; auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types()); - auto* type = create( - type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types()); + auto* type = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Uint, subtype); - auto* ac = create(ast::AccessControl::kReadOnly, type); + auto* ac = create(ast::AccessControl::kReadOnly, type); auto* var_a = Global("a", ac, ast::StorageClass::kUniformConstant); @@ -557,12 +557,12 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { // var a : [[access(write)]] texture_storage_2d; auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types()); - auto* type = create( - type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types()); + auto* type = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Uint, subtype); Global("test_var", type, ast::StorageClass::kInput); - auto* ac = create(ast::AccessControl::kWriteOnly, type); + auto* ac = create(ast::AccessControl::kWriteOnly, type); auto* var_a = Global("a", ac, ast::StorageClass::kUniformConstant); @@ -586,17 +586,16 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWithDifferentAccess) { // var b : [[access(write)]] texture_storage_2d; auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types()); - auto* st = create(type::TextureDimension::k2d, - type::ImageFormat::kR32Uint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types()); + auto* st = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Uint, subtype); Global("test_var", st, ast::StorageClass::kInput); - auto* type_a = create(ast::AccessControl::kReadOnly, st); + auto* type_a = create(ast::AccessControl::kReadOnly, st); auto* var_a = Global("a", type_a, ast::StorageClass::kUniformConstant); - auto* type_b = - create(ast::AccessControl::kWriteOnly, st); + auto* type_b = create(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 feb2c17812..3a0457d4fe 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -370,8 +370,8 @@ TEST_F(IntrinsicBuilderTest, Call_Select) { // 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 964d2276fb..812cbb5f9a 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, ReturnsGeneratedMatrix) { } 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, GeneratePtr) { } 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 @@ INSTANTIATE_TEST_SUITE_P( 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_2d) { } 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_2dArray) { } 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_Cube) { } 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, DepthTexture_Generate_CubeArray) { } 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_i32) { } 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_u32) { } 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, MultisampledTexture_Generate_2d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { - auto* s = create(type::TextureDimension::k1d, ty.i32()); + auto* s = create(sem::TextureDimension::k1d, ty.i32()); spirv::Builder& b = Build(); @@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { - auto* s = create(type::TextureDimension::k1d, ty.u32()); + auto* s = create(sem::TextureDimension::k1d, ty.u32()); spirv::Builder& b = Build(); @@ -749,7 +749,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { - auto* s = create(type::TextureDimension::k1d, ty.f32()); + auto* s = create(sem::TextureDimension::k1d, ty.f32()); spirv::Builder& b = Build(); @@ -766,7 +766,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { - auto* s = create(type::TextureDimension::k2d, ty.f32()); + auto* s = create(sem::TextureDimension::k2d, ty.f32()); spirv::Builder& b = Build(); @@ -780,7 +780,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { auto* s = - create(type::TextureDimension::k2dArray, ty.f32()); + create(sem::TextureDimension::k2dArray, ty.f32()); spirv::Builder& b = Build(); @@ -793,7 +793,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { - auto* s = create(type::TextureDimension::k3d, ty.f32()); + auto* s = create(sem::TextureDimension::k3d, ty.f32()); spirv::Builder& b = Build(); @@ -806,8 +806,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { - auto* s = - create(type::TextureDimension::kCube, ty.f32()); + auto* s = create(sem::TextureDimension::kCube, ty.f32()); spirv::Builder& b = Build(); @@ -821,8 +820,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { - auto* s = create(type::TextureDimension::kCubeArray, - ty.f32()); + auto* s = + create(sem::TextureDimension::kCubeArray, ty.f32()); spirv::Builder& b = Build(); @@ -839,9 +838,9 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R16Float) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()); - auto* s = create(type::TextureDimension::k1d, - type::ImageFormat::kR16Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()); + auto* s = create(sem::TextureDimension::k1d, + sem::ImageFormat::kR16Float, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -861,9 +860,9 @@ OpCapability StorageImageExtendedFormats TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8SNorm) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Snorm, Types()); - auto* s = create(type::TextureDimension::k1d, - type::ImageFormat::kR8Snorm, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Snorm, Types()); + auto* s = create(sem::TextureDimension::k1d, + sem::ImageFormat::kR8Snorm, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -883,9 +882,9 @@ OpCapability StorageImageExtendedFormats TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8UNorm) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Unorm, Types()); - auto* s = create(type::TextureDimension::k1d, - type::ImageFormat::kR8Unorm, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Unorm, Types()); + auto* s = create(sem::TextureDimension::k1d, + sem::ImageFormat::kR8Unorm, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -905,9 +904,9 @@ OpCapability StorageImageExtendedFormats TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Uint, Types()); - auto* s = create(type::TextureDimension::k1d, - type::ImageFormat::kR8Uint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Uint, Types()); + auto* s = create(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_R8Uint) { TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Sint, Types()); - auto* s = create(type::TextureDimension::k1d, - type::ImageFormat::kR8Sint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR8Sint, Types()); + auto* s = create(sem::TextureDimension::k1d, + sem::ImageFormat::kR8Sint, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -939,9 +938,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()); - auto* s = create(type::TextureDimension::k2d, - type::ImageFormat::kR16Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()); + auto* s = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR16Float, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -956,9 +955,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()); - auto* s = create(type::TextureDimension::k2dArray, - type::ImageFormat::kR16Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()); + auto* s = create(sem::TextureDimension::k2dArray, + sem::ImageFormat::kR16Float, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -973,9 +972,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, Types()); - auto* s = create(type::TextureDimension::k3d, - type::ImageFormat::kR16Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR16Float, Types()); + auto* s = create(sem::TextureDimension::k3d, + sem::ImageFormat::kR16Float, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -991,9 +990,9 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Float, Types()); - auto* s = create(type::TextureDimension::k2d, - type::ImageFormat::kR32Float, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Float, Types()); + auto* s = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Float, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -1009,9 +1008,9 @@ TEST_F(BuilderTest_Type, TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Sint, Types()); - auto* s = create(type::TextureDimension::k2d, - type::ImageFormat::kR32Sint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Sint, Types()); + auto* s = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Sint, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -1027,9 +1026,9 @@ TEST_F(BuilderTest_Type, TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) { auto* subtype = - type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, Types()); - auto* s = create(type::TextureDimension::k2d, - type::ImageFormat::kR32Uint, subtype); + sem::StorageTexture::SubtypeFor(sem::ImageFormat::kR32Uint, Types()); + auto* s = create(sem::TextureDimension::k2d, + sem::ImageFormat::kR32Uint, subtype); Global("test_var", s, ast::StorageClass::kInput); @@ -1043,7 +1042,7 @@ TEST_F(BuilderTest_Type, } 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, Sampler) { } 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, ComparisonSampler) { } 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 3aeafe422d..212a8aa46f 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -64,7 +64,7 @@ GeneratorImpl::~GeneratorImpl() = default; 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()) { + if (auto* ty = decl->As()) { if (!EmitConstructedType(ty)) { return false; } @@ -115,15 +115,15 @@ bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage, return Generate(func); } -bool GeneratorImpl::EmitConstructedType(const type::Type* ty) { +bool GeneratorImpl::EmitConstructedType(const sem::Type* ty) { make_indent(); - if (auto* alias = ty->As()) { + if (auto* alias = ty->As()) { out_ << "type " << program_->Symbols().NameFor(alias->symbol()) << " = "; if (!EmitType(alias->type())) { return false; } out_ << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(str)) { return false; } @@ -332,7 +332,7 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) { out_ << ")"; - if (!func->return_type()->Is() || + if (!func->return_type()->Is() || !func->return_type_decorations().empty()) { out_ << " -> "; @@ -358,9 +358,9 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) { 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 @@ bool GeneratorImpl::EmitImageFormat(const type::ImageFormat fmt) { return true; } -bool GeneratorImpl::EmitType(type::Type* type) { +bool GeneratorImpl::EmitType(sem::Type* type) { std::string storage_texture_access = ""; - if (auto* ac = type->As()) { + if (auto* ac = type->As()) { out_ << "[[access("; if (ac->IsReadOnly()) { out_ << "read"; @@ -388,9 +388,9 @@ bool GeneratorImpl::EmitType(type::Type* type) { return false; } return true; - } else if (auto* alias = type->As()) { + } else if (auto* alias = type->As()) { out_ << program_->Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { + } else if (auto* ary = type->As()) { for (auto* deco : ary->decorations()) { if (auto* stride = deco->As()) { out_ << "[[stride(" << stride->stride() << ")]] "; @@ -406,43 +406,43 @@ bool GeneratorImpl::EmitType(type::Type* type) { out_ << ", " << ary->size(); out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "bool"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "f32"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "i32"; - } else if (auto* mat = type->As()) { + } else if (auto* mat = type->As()) { out_ << "mat" << mat->columns() << "x" << mat->rows() << "<"; if (!EmitType(mat->type())) { return false; } out_ << ">"; - } else if (auto* ptr = type->As()) { + } else if (auto* ptr = type->As()) { out_ << "ptr<" << ptr->storage_class() << ", "; if (!EmitType(ptr->type())) { return false; } out_ << ">"; - } else if (auto* sampler = type->As()) { + } else if (auto* sampler = type->As()) { out_ << "sampler"; if (sampler->IsComparison()) { out_ << "_comparison"; } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { // 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()) { + } else if (auto* texture = type->As()) { out_ << "texture_"; - if (texture->Is()) { + if (texture->Is()) { out_ << "depth_"; - } else if (texture->Is()) { + } else if (texture->Is()) { /* nothing to emit */ - } else if (texture->Is()) { + } else if (texture->Is()) { out_ << "multisampled_"; - } else if (texture->Is()) { + } else if (texture->Is()) { out_ << "storage_"; } else { diagnostics_.add_error("unknown texture type"); @@ -450,22 +450,22 @@ bool GeneratorImpl::EmitType(type::Type* type) { } 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 @@ bool GeneratorImpl::EmitType(type::Type* type) { return false; } - if (auto* sampled = texture->As()) { + if (auto* sampled = texture->As()) { out_ << "<"; if (!EmitType(sampled->type())) { return false; } out_ << ">"; - } else if (auto* ms = texture->As()) { + } else if (auto* ms = texture->As()) { out_ << "<"; if (!EmitType(ms->type())) { return false; } out_ << ">"; - } else if (auto* storage = texture->As()) { + } else if (auto* storage = texture->As()) { out_ << "<"; if (!EmitImageFormat(storage->image_format())) { return false; @@ -493,15 +493,15 @@ bool GeneratorImpl::EmitType(type::Type* type) { out_ << ">"; } - } else if (type->Is()) { + } else if (type->Is()) { out_ << "u32"; - } else if (auto* vec = type->As()) { + } else if (auto* vec = type->As()) { out_ << "vec" << vec->size() << "<"; if (!EmitType(vec->type())) { return false; } out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "void"; } else { diagnostics_.add_error("unknown type in EmitType: " + type->type_name()); @@ -511,7 +511,7 @@ bool GeneratorImpl::EmitType(type::Type* type) { 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 984bba3f8d..0c0bb51d6b 100644 --- a/src/writer/wgsl/generator_impl.h +++ b/src/writer/wgsl/generator_impl.h @@ -64,7 +64,7 @@ class GeneratorImpl : public TextGenerator { /// 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 @@ class GeneratorImpl : public TextGenerator { /// 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 4f069932fa..b5dfe450b1 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -210,7 +210,7 @@ TEST_F(WgslGeneratorImplTest, auto* s = Structure("Data", {Member("d", ty.f32())}, {create()}); - 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 92250daeab..a2a0ab91e4 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_GlobalsInterleaved) { } TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { - Global("s", create(type::SamplerKind::kSampler), + Global("s", create(sem::SamplerKind::kSampler), ast::StorageClass::kUniformConstant); GeneratorImpl& gen = Build(); @@ -113,8 +113,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { } TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) { - auto* st = - create(type::TextureDimension::k1d, ty.f32()); + auto* st = create(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 87f9df1f76..71721aa4e5 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_AccessControl_ReadWrite) { } TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { - auto* a = create(ty.bool_(), 4, - ast::DecorationList{ - create(16u), - }); + auto* a = create(ty.bool_(), 4, + ast::DecorationList{ + create(16u), + }); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build(); @@ -86,11 +86,11 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { } TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { - auto* a = create(ty.bool_(), 4, - ast::DecorationList{ - create(16u), - create(32u), - }); + auto* a = create(ty.bool_(), 4, + ast::DecorationList{ + create(16u), + create(32u), + }); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build(); @@ -100,7 +100,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { } TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) { - auto* a = create(ty.bool_(), 0, ast::DecorationList{}); + auto* a = create(ty.bool_(), 0, ast::DecorationList{}); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build(); @@ -150,7 +150,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Matrix) { } TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { - auto* p = create(ty.f32(), ast::StorageClass::kWorkgroup); + auto* p = create(ty.f32(), ast::StorageClass::kWorkgroup); AST().AddConstructedType(ty.alias("make_type_reachable", p)); GeneratorImpl& gen = Build(); @@ -314,7 +314,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector) { } struct TextureData { - type::TextureDimension dim; + sem::TextureDimension dim; const char* name; }; inline std::ostream& operator<<(std::ostream& out, TextureData data) { @@ -326,7 +326,7 @@ using WgslGenerator_DepthTextureTest = TestParamHelper; TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) { auto param = GetParam(); - auto* d = create(param.dim); + auto* d = create(param.dim); AST().AddConstructedType(ty.alias("make_type_reachable", d)); GeneratorImpl& gen = Build(); @@ -338,17 +338,17 @@ INSTANTIATE_TEST_SUITE_P( 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; TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) { auto param = GetParam(); - auto* t = create(param.dim, ty.f32()); + auto* t = create(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_F32) { TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) { auto param = GetParam(); - auto* t = create(param.dim, ty.i32()); + auto* t = create(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_I32) { TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) { auto param = GetParam(); - auto* t = create(param.dim, ty.u32()); + auto* t = create(param.dim, ty.u32()); AST().AddConstructedType(ty.alias("make_type_reachable", t)); GeneratorImpl& gen = Build(); @@ -384,18 +384,18 @@ INSTANTIATE_TEST_SUITE_P( 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; TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) { auto param = GetParam(); - auto* t = create(param.dim, ty.f32()); + auto* t = create(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_F32) { TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) { auto param = GetParam(); - auto* t = create(param.dim, ty.i32()); + auto* t = create(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_I32) { TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) { auto param = GetParam(); - auto* t = create(param.dim, ty.u32()); + auto* t = create(param.dim, ty.u32()); AST().AddConstructedType(ty.alias("make_type_reachable", t)); GeneratorImpl& gen = Build(); @@ -430,12 +430,12 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) { 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 @@ using WgslGenerator_StorageTextureTest = TestParamHelper; TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { auto param = GetParam(); - auto* subtype = type::StorageTexture::SubtypeFor(param.fmt, Types()); - auto* t = create(param.dim, param.fmt, subtype); + auto* subtype = sem::StorageTexture::SubtypeFor(param.fmt, Types()); + auto* t = create(param.dim, param.fmt, subtype); auto* ac = ty.access(param.access, t); GeneratorImpl& gen = Build(); @@ -460,41 +460,41 @@ INSTANTIATE_TEST_SUITE_P( 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"}, - StorageTextureData{type::ImageFormat::kR8Unorm, - type::TextureDimension::k2d, + StorageTextureData{sem::ImageFormat::kR8Unorm, + sem::TextureDimension::k2d, ast::AccessControl::kReadOnly, "[[access(read)]] texture_storage_2d"}, StorageTextureData{ - type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray, + sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray, ast::AccessControl::kReadOnly, "[[access(read)]] texture_storage_2d_array"}, - StorageTextureData{type::ImageFormat::kR8Unorm, - type::TextureDimension::k3d, + StorageTextureData{sem::ImageFormat::kR8Unorm, + sem::TextureDimension::k3d, ast::AccessControl::kReadOnly, "[[access(read)]] texture_storage_3d"}, - StorageTextureData{type::ImageFormat::kR8Unorm, - type::TextureDimension::k1d, + StorageTextureData{sem::ImageFormat::kR8Unorm, + sem::TextureDimension::k1d, ast::AccessControl::kWriteOnly, "[[access(write)]] texture_storage_1d"}, - StorageTextureData{type::ImageFormat::kR8Unorm, - type::TextureDimension::k2d, + StorageTextureData{sem::ImageFormat::kR8Unorm, + sem::TextureDimension::k2d, ast::AccessControl::kWriteOnly, "[[access(write)]] texture_storage_2d"}, StorageTextureData{ - type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray, + sem::ImageFormat::kR8Unorm, sem::TextureDimension::k2dArray, ast::AccessControl::kWriteOnly, "[[access(write)]] texture_storage_2d_array"}, - StorageTextureData{type::ImageFormat::kR8Unorm, - type::TextureDimension::k3d, + StorageTextureData{sem::ImageFormat::kR8Unorm, + sem::TextureDimension::k3d, ast::AccessControl::kWriteOnly, "[[access(write)]] texture_storage_3d"})); struct ImageFormatData { - type::ImageFormat fmt; + sem::ImageFormat fmt; const char* name; }; inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) { @@ -515,44 +515,44 @@ INSTANTIATE_TEST_SUITE_P( 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::SamplerKind::kSampler); + auto* sampler = create(sem::SamplerKind::kSampler); AST().AddConstructedType(ty.alias("make_type_reachable", sampler)); GeneratorImpl& gen = Build(); @@ -562,7 +562,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Sampler) { } TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) { - auto* sampler = create(type::SamplerKind::kComparisonSampler); + auto* sampler = create(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 40df2bc7e0..1bf93ff32f 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 @@ TEST_P(WgslUnaryOpTest, Emit) { auto params = GetParam(); auto* type = (params.op == ast::UnaryOp::kNot) - ? static_cast(ty.bool_()) - : static_cast(ty.i32()); + ? static_cast(ty.bool_()) + : static_cast(ty.i32()); Global("expr", type, ast::StorageClass::kPrivate); auto* op = create(params.op, Expr("expr"));