Replace Type::(Is|As)U32 with Castable

Change-Id: I4999d45950fdffe4345cf0abae1b026244abba1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34273
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-11-30 23:30:58 +00:00
parent 38409c79dc
commit d11ced4765
33 changed files with 124 additions and 118 deletions

View File

@ -63,7 +63,7 @@ TEST_F(AccessControlTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -64,7 +64,7 @@ TEST_F(AliasTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -70,7 +70,7 @@ TEST_F(ArrayTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -45,7 +46,7 @@ TEST_F(BoolTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -24,6 +24,7 @@
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -46,7 +47,7 @@ TEST_F(DepthTextureTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -45,7 +46,7 @@ TEST_F(F32TypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -45,7 +46,7 @@ TEST_F(I32TypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -54,7 +55,7 @@ TEST_F(MatrixTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -46,7 +47,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -53,7 +54,7 @@ TEST_F(PointerTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -23,6 +23,7 @@
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -46,7 +47,7 @@ TEST_F(SampledTextureTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -24,6 +24,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -57,7 +58,7 @@ TEST_F(SamplerTypeTest, Is) {
EXPECT_TRUE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -26,6 +26,7 @@
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/u32_type.h"
#include "src/type_determiner.h"
namespace tint {
@ -50,7 +51,7 @@ TEST_F(StorageTextureTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}
@ -111,7 +112,8 @@ TEST_F(StorageTextureTypeTest, U32Type) {
ASSERT_TRUE(td.Determine()) << td.error();
ASSERT_TRUE(s->Is<TextureType>());
ASSERT_TRUE(s->As<TextureType>()->IsStorage());
EXPECT_TRUE(s->As<TextureType>()->AsStorage()->type()->IsU32());
EXPECT_TRUE(
s->As<TextureType>()->AsStorage()->type()->Is<ast::type::U32Type>());
}
TEST_F(StorageTextureTypeTest, I32Type) {

View File

@ -61,7 +61,7 @@ TEST_F(StructTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_TRUE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
}
bool Type::IsU32() const {
return false;
}
bool Type::IsVector() const {
return false;
}
@ -107,11 +103,11 @@ bool Type::is_float_scalar_or_vector() {
}
bool Type::is_integer_scalar() {
return IsU32() || Is<I32Type>();
return Is<U32Type>() || Is<I32Type>();
}
bool Type::is_unsigned_integer_vector() {
return IsVector() && AsVector()->type()->IsU32();
return IsVector() && AsVector()->type()->Is<U32Type>();
}
bool Type::is_signed_integer_vector() {
@ -119,7 +115,7 @@ bool Type::is_signed_integer_vector() {
}
bool Type::is_unsigned_scalar_or_vector() {
return IsU32() || (IsVector() && AsVector()->type()->IsU32());
return Is<U32Type>() || (IsVector() && AsVector()->type()->Is<U32Type>());
}
bool Type::is_signed_scalar_or_vector() {
@ -130,11 +126,6 @@ bool Type::is_integer_scalar_or_vector() {
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
}
const U32Type* Type::AsU32() const {
assert(IsU32());
return static_cast<const U32Type*>(this);
}
const VectorType* Type::AsVector() const {
assert(IsVector());
return static_cast<const VectorType*>(this);
@ -145,11 +136,6 @@ const VoidType* Type::AsVoid() const {
return static_cast<const VoidType*>(this);
}
U32Type* Type::AsU32() {
assert(IsU32());
return static_cast<U32Type*>(this);
}
VectorType* Type::AsVector() {
assert(IsVector());
return static_cast<VectorType*>(this);

View File

@ -23,7 +23,6 @@ namespace tint {
namespace ast {
namespace type {
class U32Type;
class VectorType;
class VoidType;
@ -37,8 +36,6 @@ class Type : public Castable<Type> {
Type(Type&&);
~Type() override;
/// @returns true if the type is a u32 type
virtual bool IsU32() const;
/// @returns true if the type is a vec type
virtual bool IsVector() const;
/// @returns true if the type is a void type
@ -98,15 +95,11 @@ class Type : public Castable<Type> {
/// @returns true if this type is an integer scalar or vector
bool is_integer_scalar_or_vector();
/// @returns the type as a u32 type
const U32Type* AsU32() const;
/// @returns the type as a vector type
const VectorType* AsVector() const;
/// @returns the type as a void type
const VoidType* AsVoid() const;
/// @returns the type as a u32 type
U32Type* AsU32();
/// @returns the type as a vector type
VectorType* AsVector();
/// @returns the type as a void type

View File

@ -24,10 +24,6 @@ U32Type::~U32Type() = default;
U32Type::U32Type(U32Type&&) = default;
bool U32Type::IsU32() const {
return true;
}
std::string U32Type::type_name() const {
return "__u32";
}

View File

@ -32,9 +32,6 @@ class U32Type : public Castable<U32Type, Type> {
U32Type(U32Type&&);
~U32Type() override;
/// @returns true if the type is a u32 type
bool IsU32() const override;
/// @returns the name for th type
std::string type_name() const override;

View File

@ -47,7 +47,7 @@ TEST_F(U32TypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_TRUE(ty->IsU32());
EXPECT_TRUE(ty->Is<U32Type>());
EXPECT_FALSE(ty->IsVector());
}

View File

@ -24,6 +24,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
@ -54,7 +55,7 @@ TEST_F(VectorTypeTest, Is) {
EXPECT_FALSE(ty->Is<SamplerType>());
EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<TextureType>());
EXPECT_FALSE(ty->IsU32());
EXPECT_FALSE(ty->Is<U32Type>());
EXPECT_TRUE(ty->IsVector());
}

View File

@ -50,7 +50,7 @@ TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
auto* t2 = tm.Get(std::make_unique<ast::type::U32Type>());
ASSERT_NE(t2, nullptr);
EXPECT_NE(t, t2);
EXPECT_TRUE(t2->IsU32());
EXPECT_TRUE(t2->Is<ast::type::U32Type>());
}
TEST_F(TypeManagerTest, ResetClearsPreviousData) {

View File

@ -36,6 +36,7 @@
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/type.h"
#include "src/ast/type/u32_type.h"
#include "src/ast/type/vector_type.h"
#include "src/ast/uint_literal.h"
@ -396,7 +397,7 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
if (base_type->Is<ast::type::F32Type>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kFloat;
} else if (base_type->IsU32()) {
} else if (base_type->Is<ast::type::U32Type>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kUInt;
} else if (base_type->Is<ast::type::I32Type>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kSInt;

View File

@ -979,7 +979,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
ast_type, static_cast<int32_t>(literal_value)));
} else if (ast_type->IsU32()) {
} else if (ast_type->Is<ast::type::U32Type>()) {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
ast_type, static_cast<uint32_t>(literal_value)));
@ -1263,7 +1263,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
// So canonicalization should map that way too.
// Currently "null<type>" is missing from the WGSL parser.
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
if (ast_type->IsU32()) {
if (ast_type->Is<ast::type::U32Type>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(ast_type, spirv_const->GetU32()))};
@ -1339,7 +1339,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(type, false));
}
if (type->IsU32()) {
if (type->Is<ast::type::U32Type>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(type, 0u));
}
@ -1446,7 +1446,7 @@ ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
Fail() << "no type provided";
}
auto* i32 = ast_module_.create<ast::type::I32Type>();
if (other->Is<ast::type::F32Type>() || other->IsU32() ||
if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
other->Is<ast::type::I32Type>()) {
return i32;
}
@ -1465,7 +1465,7 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
return nullptr;
}
auto* u32 = ast_module_.create<ast::type::U32Type>();
if (other->Is<ast::type::F32Type>() || other->IsU32() ||
if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
other->Is<ast::type::I32Type>()) {
return u32;
}

View File

@ -26,6 +26,7 @@
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/type.h"
#include "src/ast/type/u32_type.h"
#include "src/ast/type/vector_type.h"
#include "src/reader/spirv/parser_impl.h"
#include "src/reader/spirv/parser_impl_test_helper.h"
@ -117,7 +118,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->IsU32());
EXPECT_TRUE(type->Is<ast::type::U32Type>());
EXPECT_TRUE(p->error().empty());
}
@ -225,17 +226,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
auto* v2xu32 = p->ConvertType(20);
EXPECT_TRUE(v2xu32->IsVector());
EXPECT_TRUE(v2xu32->AsVector()->type()->IsU32());
EXPECT_TRUE(v2xu32->AsVector()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v2xu32->AsVector()->size(), 2u);
auto* v3xu32 = p->ConvertType(30);
EXPECT_TRUE(v3xu32->IsVector());
EXPECT_TRUE(v3xu32->AsVector()->type()->IsU32());
EXPECT_TRUE(v3xu32->AsVector()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v3xu32->AsVector()->size(), 3u);
auto* v4xu32 = p->ConvertType(40);
EXPECT_TRUE(v4xu32->IsVector());
EXPECT_TRUE(v4xu32->AsVector()->type()->IsU32());
EXPECT_TRUE(v4xu32->AsVector()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v4xu32->AsVector()->size(), 4u);
EXPECT_TRUE(p->error().empty());
@ -359,7 +360,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
EXPECT_TRUE(elem_type->IsU32());
EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
EXPECT_TRUE(p->error().empty());
}
@ -441,7 +442,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
EXPECT_TRUE(elem_type->IsU32());
EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
EXPECT_TRUE(p->error().empty());
}

View File

@ -18,6 +18,7 @@
#include "src/ast/type/multisampled_texture_type.h"
#include "src/ast/type/sampled_texture_type.h"
#include "src/ast/type/sampler_type.h"
#include "src/ast/type/u32_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@ -113,7 +114,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
ASSERT_TRUE(t->As<ast::type::TextureType>()->AsSampled()->type()->IsU32());
ASSERT_TRUE(t->As<ast::type::TextureType>()
->AsSampled()
->type()
->Is<ast::type::U32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::k3d);
}
@ -202,7 +206,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
ASSERT_TRUE(t->As<ast::type::TextureType>()->AsSampled()->type()->IsU32());
ASSERT_TRUE(t->As<ast::type::TextureType>()
->AsSampled()
->type()
->Is<ast::type::U32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::k3d);
}

View File

@ -129,7 +129,7 @@ TEST_F(ParserImplTest, TypeDecl_U32) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, uint_type);
ASSERT_TRUE(t->IsU32());
ASSERT_TRUE(t->Is<ast::type::U32Type>());
}
struct VecData {
@ -528,7 +528,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
auto* a = t->As<ast::type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->IsU32());
ASSERT_TRUE(a->type()->Is<ast::type::U32Type>());
}
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {

View File

@ -141,7 +141,7 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@ -152,7 +152,7 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
@ -204,7 +204,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
auto* sub = tc->values()[0];
@ -218,7 +218,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
ASSERT_TRUE(sub_idx->params()[0]->IsConstructor());
ASSERT_TRUE(sub_idx->params()[0]->AsConstructor()->IsTypeConstructor());
tc = sub_idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], b_access_idx);
@ -235,7 +235,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) {
@ -274,7 +274,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) {
@ -325,7 +325,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@ -336,7 +336,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) {
@ -414,7 +414,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) {
@ -453,7 +453,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) {
@ -503,7 +503,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@ -514,7 +514,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) {
@ -592,7 +592,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) {
@ -637,7 +637,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ary->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
ASSERT_TRUE(ptr->idx_expr()->IsConstructor());
ASSERT_TRUE(ptr->idx_expr()->AsConstructor()->IsScalarConstructor());
@ -647,7 +647,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
@ -704,7 +704,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@ -715,7 +715,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ary->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
ASSERT_TRUE(ptr->idx_expr()->IsConstructor());
ASSERT_TRUE(ptr->idx_expr()->AsConstructor()->IsScalarConstructor());
@ -725,7 +725,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) {
@ -790,7 +790,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) {
ASSERT_TRUE(idx->params()[0]->IsConstructor());
ASSERT_TRUE(idx->params()[0]->AsConstructor()->IsTypeConstructor());
auto* tc = idx->params()[0]->AsConstructor()->AsTypeConstructor();
EXPECT_TRUE(tc->type()->IsU32());
EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@ -801,10 +801,10 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ary->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) {
@ -957,7 +957,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ary->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
ASSERT_TRUE(ptr->idx_expr()->IsConstructor());
ASSERT_TRUE(ptr->idx_expr()->AsConstructor()->IsScalarConstructor());
@ -967,7 +967,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) {
@ -1012,7 +1012,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ary->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
ASSERT_TRUE(ptr->idx_expr()->IsConstructor());
ASSERT_TRUE(ptr->idx_expr()->AsConstructor()->IsScalarConstructor());
@ -1022,7 +1022,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) {
EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
ASSERT_TRUE(ptr->idx_expr()->result_type()->IsU32());
ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
}
// TODO(dsinclair): Implement when constant_id exists

View File

@ -1756,7 +1756,7 @@ class Intrinsic_TextureOperation
if (dim == ast::type::TextureDimension::k1d) {
if (type->Is<ast::type::I32Type>()) {
return std::make_unique<ast::type::I32Type>();
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
return std::make_unique<ast::type::U32Type>();
} else {
return std::make_unique<ast::type::F32Type>();
@ -1823,7 +1823,8 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
EXPECT_TRUE(
expr.result_type()->AsVector()->type()->Is<ast::type::I32Type>());
} else {
EXPECT_TRUE(expr.result_type()->AsVector()->type()->IsU32());
EXPECT_TRUE(
expr.result_type()->AsVector()->type()->Is<ast::type::U32Type>());
}
EXPECT_EQ(expr.result_type()->AsVector()->size(), 4u);
}
@ -1895,7 +1896,8 @@ TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) {
EXPECT_TRUE(
expr.result_type()->AsVector()->type()->Is<ast::type::I32Type>());
} else {
EXPECT_TRUE(expr.result_type()->AsVector()->type()->IsU32());
EXPECT_TRUE(
expr.result_type()->AsVector()->type()->Is<ast::type::U32Type>());
}
EXPECT_EQ(expr.result_type()->AsVector()->size(), 4u);
}
@ -2479,7 +2481,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) {
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->IsU32());
EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) {
@ -3563,7 +3565,7 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) {
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->IsU32());
EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) {
@ -3922,7 +3924,7 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) {
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->IsU32());
EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) {

View File

@ -316,7 +316,8 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
}
auto* cond_type = s->condition()->result_type()->UnwrapAll();
if (!(cond_type->Is<ast::type::I32Type>() || cond_type->IsU32())) {
if (!(cond_type->Is<ast::type::I32Type>() ||
cond_type->Is<ast::type::U32Type>())) {
add_error(s->condition()->source(), "v-0025",
"switch statement selector expression must be of a "
"scalar integer type");
@ -342,12 +343,13 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
return false;
}
auto v = static_cast<int32_t>(selector->type()->IsU32()
auto v = static_cast<int32_t>(selector->type()->Is<ast::type::U32Type>()
? selector->AsUint()->value()
: selector->AsSint()->value());
if (selector_set.count(v)) {
auto v_str = selector->type()->IsU32() ? selector->AsUint()->to_str()
: selector->AsSint()->to_str();
auto v_str = selector->type()->Is<ast::type::U32Type>()
? selector->AsUint()->to_str()
: selector->AsSint()->to_str();
add_error(case_stmt->source(), "v-0027",
"a literal value must not appear more than once in "
"the case selectors for a switch statement: '" +

View File

@ -49,6 +49,7 @@
#include "src/ast/type/sampler_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
#include "src/ast/type/u32_type.h"
#include "src/ast/type/vector_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
@ -268,7 +269,8 @@ bool GeneratorImpl::EmitBitcast(std::ostream& pre,
std::ostream& out,
ast::BitcastExpression* expr) {
if (!expr->type()->Is<ast::type::F32Type>() &&
!expr->type()->Is<ast::type::I32Type>() && !expr->type()->IsU32()) {
!expr->type()->Is<ast::type::I32Type>() &&
!expr->type()->Is<ast::type::U32Type>()) {
error_ = "Unable to do bitcast to type " + expr->type()->type_name();
return false;
}
@ -1552,7 +1554,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::type::Type* type) {
out << "0.0f";
} else if (type->Is<ast::type::I32Type>()) {
out << "0";
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
out << "0u";
} else if (type->IsVector()) {
return EmitZeroValue(out, type->AsVector()->type());
@ -2123,7 +2125,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
return false;
}
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
out << "uint";
} else if (type->IsVector()) {
auto* vec = type->AsVector();
@ -2133,7 +2135,8 @@ bool GeneratorImpl::EmitType(std::ostream& out,
} else if (vec->type()->Is<ast::type::I32Type>() && size >= 1 &&
size <= 4) {
out << "int" << size;
} else if (vec->type()->IsU32() && size >= 1 && size <= 4) {
} else if (vec->type()->Is<ast::type::U32Type>() && size >= 1 &&
size <= 4) {
out << "uint" << size;
} else {
out << "vector<";

View File

@ -201,7 +201,7 @@ uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) {
return 0;
}
if (type->Is<ast::type::F32Type>() || type->Is<ast::type::I32Type>() ||
type->IsU32()) {
type->Is<ast::type::U32Type>()) {
return 4;
}
if (type->Is<ast::type::MatrixType>()) {
@ -796,7 +796,7 @@ std::string GeneratorImpl::generate_builtin_name(
case ast::Intrinsic::kAbs:
if (ident->result_type()->Is<ast::type::F32Type>()) {
out += "fabs";
} else if (ident->result_type()->IsU32() ||
} else if (ident->result_type()->Is<ast::type::U32Type>() ||
ident->result_type()->Is<ast::type::I32Type>()) {
out += "abs";
}
@ -804,7 +804,7 @@ std::string GeneratorImpl::generate_builtin_name(
case ast::Intrinsic::kMax:
if (ident->result_type()->Is<ast::type::F32Type>()) {
out += "fmax";
} else if (ident->result_type()->IsU32() ||
} else if (ident->result_type()->Is<ast::type::U32Type>() ||
ident->result_type()->Is<ast::type::I32Type>()) {
out += "max";
}
@ -812,7 +812,7 @@ std::string GeneratorImpl::generate_builtin_name(
case ast::Intrinsic::kMin:
if (ident->result_type()->Is<ast::type::F32Type>()) {
out += "fmin";
} else if (ident->result_type()->IsU32() ||
} else if (ident->result_type()->Is<ast::type::U32Type>() ||
ident->result_type()->Is<ast::type::I32Type>()) {
out += "min";
}
@ -935,7 +935,7 @@ bool GeneratorImpl::EmitZeroValue(ast::type::Type* type) {
out_ << "0.0f";
} else if (type->Is<ast::type::I32Type>()) {
out_ << "0";
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
out_ << "0u";
} else if (type->IsVector()) {
return EmitZeroValue(type->AsVector()->type());
@ -1909,7 +1909,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
}
out_ << ">";
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
out_ << "uint";
} else if (type->IsVector()) {
auto* vec = type->AsVector();

View File

@ -746,7 +746,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
if (type->Is<ast::type::F32Type>()) {
ast::FloatLiteral l(type, 0.0f);
init_id = GenerateLiteralIfNeeded(var, &l);
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
ast::UintLiteral l(type, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
} else if (type->Is<ast::type::I32Type>()) {
@ -1403,7 +1403,8 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type,
to_type->Is<ast::type::F32Type>()) ||
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
op = spv::Op::OpConvertSToF;
} else if ((from_type->IsU32() && to_type->Is<ast::type::F32Type>()) ||
} else if ((from_type->Is<ast::type::U32Type>() &&
to_type->Is<ast::type::F32Type>()) ||
(from_type->is_unsigned_integer_vector() &&
to_type->is_float_vector())) {
op = spv::Op::OpConvertUToF;
@ -1412,21 +1413,25 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type,
(from_type->is_float_vector() &&
to_type->is_signed_integer_vector())) {
op = spv::Op::OpConvertFToS;
} else if ((from_type->Is<ast::type::F32Type>() && to_type->IsU32()) ||
} else if ((from_type->Is<ast::type::F32Type>() &&
to_type->Is<ast::type::U32Type>()) ||
(from_type->is_float_vector() &&
to_type->is_unsigned_integer_vector())) {
op = spv::Op::OpConvertFToU;
} else if ((from_type->Is<ast::type::BoolType>() &&
to_type->Is<ast::type::BoolType>()) ||
(from_type->IsU32() && to_type->IsU32()) ||
(from_type->Is<ast::type::U32Type>() &&
to_type->Is<ast::type::U32Type>()) ||
(from_type->Is<ast::type::I32Type>() &&
to_type->Is<ast::type::I32Type>()) ||
(from_type->Is<ast::type::F32Type>() &&
to_type->Is<ast::type::F32Type>()) ||
(from_type->IsVector() && (from_type == to_type))) {
return val_id;
} else if ((from_type->Is<ast::type::I32Type>() && to_type->IsU32()) ||
(from_type->IsU32() && to_type->Is<ast::type::I32Type>()) ||
} else if ((from_type->Is<ast::type::I32Type>() &&
to_type->Is<ast::type::U32Type>()) ||
(from_type->Is<ast::type::U32Type>() &&
to_type->Is<ast::type::I32Type>()) ||
(from_type->is_signed_integer_vector() &&
to_type->is_unsigned_integer_vector()) ||
(from_type->is_unsigned_integer_vector() &&
@ -2447,7 +2452,7 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
ast::AccessControl::kReadWrite, result)) {
return 0;
}
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)});
} else if (type->IsVector()) {
if (!GenerateVectorType(type->AsVector(), result)) {

View File

@ -64,6 +64,7 @@
#include "src/ast/type/sampler_type.h"
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/u32_type.h"
#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
@ -544,7 +545,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) {
out_ << ">";
}
} else if (type->IsU32()) {
} else if (type->Is<ast::type::U32Type>()) {
out_ << "u32";
} else if (type->IsVector()) {
auto* vec = type->AsVector();