mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
intrinsics: Remove deprected arrayLength instrinsic
Fixed: tint:806 Change-Id: I1d4ad27af73a1f64b926af64a123e2c0c2941e29 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55240 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -216,13 +216,18 @@ TEST_F(IntrinsicTableTest, MismatchPointer) {
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchArray) {
|
||||
auto* arr = create<sem::Array>(create<sem::U32>(), 0, 4, 4, 4, true);
|
||||
auto* result = table->Lookup(IntrinsicType::kArrayLength, {arr}, Source{});
|
||||
auto* arr_ptr = create<sem::Pointer>(arr, ast::StorageClass::kStorage,
|
||||
ast::Access::kReadWrite);
|
||||
auto* result =
|
||||
table->Lookup(IntrinsicType::kArrayLength, {arr_ptr}, Source{});
|
||||
ASSERT_NE(result, nullptr) << Diagnostics().str();
|
||||
ASSERT_EQ(Diagnostics().str(), "");
|
||||
EXPECT_THAT(result->Type(), IntrinsicType::kArrayLength);
|
||||
EXPECT_TRUE(result->ReturnType()->Is<sem::U32>());
|
||||
ASSERT_EQ(result->Parameters().size(), 1u);
|
||||
EXPECT_TRUE(result->Parameters()[0].type->Is<sem::Array>());
|
||||
auto* param_type = result->Parameters()[0].type;
|
||||
ASSERT_TRUE(param_type->Is<sem::Pointer>());
|
||||
EXPECT_TRUE(param_type->As<sem::Pointer>()->StoreType()->Is<sem::Array>());
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MismatchArray) {
|
||||
|
||||
@@ -263,7 +263,6 @@ fn acos(f32) -> f32
|
||||
fn acos<N: num>(vec<N, f32>) -> vec<N, f32>
|
||||
fn all<N: num>(vec<N, bool>) -> bool
|
||||
fn any<N: num>(vec<N, bool>) -> bool
|
||||
[[deprecated]] fn arrayLength<T>(array<T>) -> u32
|
||||
fn arrayLength<T, A: access>(ptr<storage, array<T>, A>) -> u32
|
||||
fn asin(f32) -> f32
|
||||
fn asin<N: num>(vec<N, f32>) -> vec<N, f32>
|
||||
|
||||
@@ -774,7 +774,7 @@ TEST_F(ResolverIntrinsicDataTest, ArrayLength_Vector) {
|
||||
create<ast::GroupDecoration>(0),
|
||||
});
|
||||
|
||||
auto* call = Call("arrayLength", MemberAccessor("a", "x"));
|
||||
auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x")));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
@@ -785,15 +785,16 @@ TEST_F(ResolverIntrinsicDataTest, ArrayLength_Vector) {
|
||||
|
||||
TEST_F(ResolverIntrinsicDataTest, ArrayLength_Error_ArraySized) {
|
||||
Global("arr", ty.array<int, 4>(), ast::StorageClass::kInput);
|
||||
auto* call = Call("arrayLength", "arr");
|
||||
auto* call = Call("arrayLength", AddressOf("arr"));
|
||||
WrapInFunction(call);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
||||
EXPECT_EQ(r()->error(), R"(error: no matching call to arrayLength(array<i32, 4>)
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(error: no matching call to arrayLength(ptr<in, array<i32, 4>, read_write>)
|
||||
|
||||
2 candidate functions:
|
||||
arrayLength(array<T>) -> u32
|
||||
1 candidate function:
|
||||
arrayLength(ptr<storage, array<T>, A>) -> u32
|
||||
)");
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ let c : u32 = 1u;
|
||||
fn f() {
|
||||
let b : f32 = s.b[c];
|
||||
let x : i32 = min(1, 2);
|
||||
let y : u32 = arrayLength(s.b);
|
||||
let y : u32 = arrayLength(&s.b);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -626,7 +626,7 @@ let c : u32 = 1u;
|
||||
fn f() {
|
||||
let b : f32 = s.b[min(u32(c), (arrayLength(&(s.b)) - 1u))];
|
||||
let x : i32 = min(1, 2);
|
||||
let y : u32 = arrayLength(s.b);
|
||||
let y : u32 = arrayLength(&(s.b));
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
@@ -129,23 +129,22 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
|
||||
// * An expression must not evaluate to a runtime-sized array type.
|
||||
//
|
||||
// We can assume that the arrayLength() call has a single argument of
|
||||
// the form: arrayLength(&X.Y) or the now deprecated form
|
||||
// arrayLength(X.Y) where X is an expression that resolves to the
|
||||
// storage buffer structure, and Y is the runtime sized array.
|
||||
auto* array_expr = call_expr->params()[0];
|
||||
|
||||
// TODO(crbug.com/tint/806): Once the deprecated arrayLength()
|
||||
// overload is removed, this can safely assume a pointer arg.
|
||||
if (auto* address_of = array_expr->As<ast::UnaryOpExpression>()) {
|
||||
if (address_of->op() == ast::UnaryOp::kAddressOf) {
|
||||
array_expr = address_of->expr();
|
||||
}
|
||||
// the form: arrayLength(&X.Y) where X is an expression that resolves
|
||||
// to the storage buffer structure, and Y is the runtime sized array.
|
||||
auto* arg = call_expr->params()[0];
|
||||
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||
TINT_ICE(ctx.dst->Diagnostics())
|
||||
<< "arrayLength() expected pointer to member access, got "
|
||||
<< address_of->TypeInfo().name;
|
||||
}
|
||||
auto* array_expr = address_of->expr();
|
||||
|
||||
auto* accessor = array_expr->As<ast::MemberAccessorExpression>();
|
||||
if (!accessor) {
|
||||
TINT_ICE(ctx.dst->Diagnostics())
|
||||
<< "arrayLength() expected ast::MemberAccessorExpression, got "
|
||||
<< "arrayLength() expected pointer to member access, got "
|
||||
"pointer to "
|
||||
<< array_expr->TypeInfo().name;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,268 +22,6 @@ namespace {
|
||||
|
||||
using CalculateArrayLengthTest = TransformTest;
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(CalculateArrayLengthTest, Basic_DEPRECATED) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(sb.arr);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol(buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
let tint_symbol_2 : u32 = ((tint_symbol_1 - 4u) / 4u);
|
||||
var len : u32 = tint_symbol_2;
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<CalculateArrayLength>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(CalculateArrayLengthTest, InSameBlock_DEPRECATED) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var a : u32 = arrayLength(sb.arr);
|
||||
var b : u32 = arrayLength(sb.arr);
|
||||
var c : u32 = arrayLength(sb.arr);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol(buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
let tint_symbol_2 : u32 = ((tint_symbol_1 - 4u) / 4u);
|
||||
var a : u32 = tint_symbol_2;
|
||||
var b : u32 = tint_symbol_2;
|
||||
var c : u32 = tint_symbol_2;
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<CalculateArrayLength>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(CalculateArrayLengthTest, WithStride_DEPRECATED) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(sb.arr);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol(buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
let tint_symbol_2 : u32 = ((tint_symbol_1 - 8u) / 64u);
|
||||
var len : u32 = tint_symbol_2;
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<CalculateArrayLength>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(CalculateArrayLengthTest, Nested_DEPRECATED) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
if (true) {
|
||||
var len : u32 = arrayLength(sb.arr);
|
||||
} else {
|
||||
if (true) {
|
||||
var len : u32 = arrayLength(sb.arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol(buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
if (true) {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
let tint_symbol_2 : u32 = ((tint_symbol_1 - 4u) / 4u);
|
||||
var len : u32 = tint_symbol_2;
|
||||
} else {
|
||||
if (true) {
|
||||
var tint_symbol_3 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_3));
|
||||
let tint_symbol_4 : u32 = ((tint_symbol_3 - 4u) / 4u);
|
||||
var len : u32 = tint_symbol_4;
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<CalculateArrayLength>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(CalculateArrayLengthTest, MultipleStorageBuffers_DEPRECATED) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
arr1 : array<i32>;
|
||||
};
|
||||
|
||||
[[block]]
|
||||
struct SB2 {
|
||||
x : i32;
|
||||
arr2 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(0), binding(1)]] var<storage, read> sb2 : SB2;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var len1 : u32 = arrayLength(sb1.arr1);
|
||||
var len2 : u32 = arrayLength(sb2.arr2);
|
||||
var x : u32 = (len1 + len2);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
arr1 : array<i32>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol(buffer : SB1, result : ptr<function, u32>)
|
||||
|
||||
[[block]]
|
||||
struct SB2 {
|
||||
x : i32;
|
||||
arr2 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol_3(buffer : SB2, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(0), binding(1)]] var<storage, read> sb2 : SB2;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb1, &(tint_symbol_1));
|
||||
let tint_symbol_2 : u32 = ((tint_symbol_1 - 4u) / 4u);
|
||||
var tint_symbol_4 : u32 = 0u;
|
||||
tint_symbol_3(sb2, &(tint_symbol_4));
|
||||
let tint_symbol_5 : u32 = ((tint_symbol_4 - 16u) / 16u);
|
||||
var len1 : u32 = tint_symbol_2;
|
||||
var len2 : u32 = tint_symbol_5;
|
||||
var x : u32 = (len1 + len2);
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<CalculateArrayLength>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(CalculateArrayLengthTest, Basic) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
|
||||
@@ -25,50 +25,6 @@ namespace {
|
||||
|
||||
using HlslSanitizerTest = TestHelper;
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(HlslSanitizerTest, ArrayLength_DEPRECATED) {
|
||||
auto* sb_ty = Structure("SB",
|
||||
{
|
||||
Member("x", ty.f32()),
|
||||
Member("arr", ty.array(ty.vec4<f32>())),
|
||||
},
|
||||
{
|
||||
create<ast::StructBlockDecoration>(),
|
||||
});
|
||||
|
||||
Global("sb", ty.Of(sb_ty), ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1),
|
||||
});
|
||||
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
{
|
||||
Decl(Var("len", ty.u32(), ast::StorageClass::kNone,
|
||||
Call("arrayLength", MemberAccessor("sb", "arr")))),
|
||||
},
|
||||
{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate(out)) << gen.error();
|
||||
|
||||
auto got = result();
|
||||
auto* expect = R"(ByteAddressBuffer sb : register(t0, space1);
|
||||
|
||||
void main() {
|
||||
uint tint_symbol_1 = 0u;
|
||||
sb.GetDimensions(tint_symbol_1);
|
||||
const uint tint_symbol_2 = ((tint_symbol_1 - 16u) / 16u);
|
||||
uint len = tint_symbol_2;
|
||||
return;
|
||||
}
|
||||
)";
|
||||
EXPECT_EQ(expect, got);
|
||||
}
|
||||
|
||||
TEST_F(HlslSanitizerTest, Call_ArrayLength) {
|
||||
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
|
||||
@@ -2230,17 +2230,19 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
||||
}
|
||||
auto* arg = call->params()[0];
|
||||
|
||||
// TODO(crbug.com/tint/806): Once the deprecated arrayLength()
|
||||
// overload is removed, this can safely assume a pointer arg.
|
||||
if (auto* address_of = arg->As<ast::UnaryOpExpression>()) {
|
||||
arg = address_of->expr();
|
||||
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||
error_ = "arrayLength() expected pointer to member access, got " +
|
||||
std::string(address_of->TypeInfo().name);
|
||||
return 0;
|
||||
}
|
||||
auto* array_expr = address_of->expr();
|
||||
|
||||
auto* accessor = arg->As<ast::MemberAccessorExpression>();
|
||||
if (accessor == nullptr) {
|
||||
// The InlinePtrLets and Simplify transforms should have sanitized any
|
||||
// lets, or &*&*& noise.
|
||||
error_ = "expected argument to arrayLength() to be a member accessor";
|
||||
auto* accessor = array_expr->As<ast::MemberAccessorExpression>();
|
||||
if (!accessor) {
|
||||
error_ =
|
||||
"arrayLength() expected pointer to member access, got pointer to " +
|
||||
std::string(array_expr->TypeInfo().name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1570,102 +1570,6 @@ OpFunctionEnd
|
||||
)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(IntrinsicBuilderTest, Call_ArrayLength_DEPRECATED) {
|
||||
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(1),
|
||||
create<ast::GroupDecoration>(2),
|
||||
});
|
||||
|
||||
auto* expr = Call("arrayLength", MemberAccessor("b", "a"));
|
||||
|
||||
Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
Ignore(expr),
|
||||
},
|
||||
ast::DecorationList{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
ASSERT_TRUE(b.Build()) << b.error();
|
||||
|
||||
ASSERT_EQ(b.functions().size(), 1u);
|
||||
|
||||
auto* expected_types = R"(%5 = OpTypeFloat 32
|
||||
%4 = OpTypeRuntimeArray %5
|
||||
%3 = OpTypeStruct %4
|
||||
%2 = OpTypePointer StorageBuffer %3
|
||||
%1 = OpVariable %2 StorageBuffer
|
||||
%7 = OpTypeVoid
|
||||
%6 = OpTypeFunction %7
|
||||
%12 = OpTypeInt 32 0
|
||||
)";
|
||||
auto got_types = DumpInstructions(b.types());
|
||||
EXPECT_EQ(expected_types, got_types);
|
||||
|
||||
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 0
|
||||
)";
|
||||
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
|
||||
EXPECT_EQ(expected_instructions, got_instructions);
|
||||
|
||||
Validate(b);
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/806): Remove
|
||||
TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct_DEPRECATED) {
|
||||
auto* s = Structure("my_struct",
|
||||
{
|
||||
Member("z", ty.f32()),
|
||||
Member(4, "a", ty.array<f32>(4)),
|
||||
},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(1),
|
||||
create<ast::GroupDecoration>(2),
|
||||
});
|
||||
|
||||
auto* expr = Call("arrayLength", MemberAccessor("b", "a"));
|
||||
|
||||
Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
Ignore(expr),
|
||||
},
|
||||
ast::DecorationList{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
ASSERT_TRUE(b.Build()) << b.error();
|
||||
|
||||
ASSERT_EQ(b.functions().size(), 1u);
|
||||
|
||||
auto* expected_types = R"(%4 = OpTypeFloat 32
|
||||
%5 = OpTypeRuntimeArray %4
|
||||
%3 = OpTypeStruct %4 %5
|
||||
%2 = OpTypePointer StorageBuffer %3
|
||||
%1 = OpVariable %2 StorageBuffer
|
||||
%7 = OpTypeVoid
|
||||
%6 = OpTypeFunction %7
|
||||
%12 = OpTypeInt 32 0
|
||||
)";
|
||||
auto got_types = DumpInstructions(b.types());
|
||||
EXPECT_EQ(expected_types, got_types);
|
||||
|
||||
auto* expected_instructions = R"(%11 = OpArrayLength %12 %1 1
|
||||
)";
|
||||
auto got_instructions = DumpInstructions(b.functions()[0].instructions());
|
||||
EXPECT_EQ(expected_instructions, got_instructions);
|
||||
|
||||
Validate(b);
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
|
||||
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
|
||||
Reference in New Issue
Block a user