Move scalar types over to type/ folder.
This CL moves Bool, F16, F32, I32, U32, and Void over to the type folder and updates namespaces as needed. Bug: tint:1718 Change-Id: If3056521e5283ac2d9e1fd09c6daf0f647dd3846 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113342 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
c223ae26ec
commit
d37ecf9055
|
@ -420,7 +420,6 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"sem/atomic.h",
|
"sem/atomic.h",
|
||||||
"sem/behavior.h",
|
"sem/behavior.h",
|
||||||
"sem/binding_point.h",
|
"sem/binding_point.h",
|
||||||
"sem/bool.h",
|
|
||||||
"sem/break_if_statement.h",
|
"sem/break_if_statement.h",
|
||||||
"sem/builtin.h",
|
"sem/builtin.h",
|
||||||
"sem/builtin_type.h",
|
"sem/builtin_type.h",
|
||||||
|
@ -429,10 +428,7 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"sem/constant.h",
|
"sem/constant.h",
|
||||||
"sem/evaluation_stage.h",
|
"sem/evaluation_stage.h",
|
||||||
"sem/expression.h",
|
"sem/expression.h",
|
||||||
"sem/f16.h",
|
|
||||||
"sem/f32.h",
|
|
||||||
"sem/for_loop_statement.h",
|
"sem/for_loop_statement.h",
|
||||||
"sem/i32.h",
|
|
||||||
"sem/if_statement.h",
|
"sem/if_statement.h",
|
||||||
"sem/index_accessor_expression.h",
|
"sem/index_accessor_expression.h",
|
||||||
"sem/info.h",
|
"sem/info.h",
|
||||||
|
@ -451,9 +447,7 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"sem/type_conversion.h",
|
"sem/type_conversion.h",
|
||||||
"sem/type_initializer.h",
|
"sem/type_initializer.h",
|
||||||
"sem/type_mappings.h",
|
"sem/type_mappings.h",
|
||||||
"sem/u32.h",
|
|
||||||
"sem/vector.h",
|
"sem/vector.h",
|
||||||
"sem/void.h",
|
|
||||||
"sem/while_statement.h",
|
"sem/while_statement.h",
|
||||||
"source.cc",
|
"source.cc",
|
||||||
"source.h",
|
"source.h",
|
||||||
|
@ -569,9 +563,13 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"type/abstract_int.h",
|
"type/abstract_int.h",
|
||||||
"type/abstract_numeric.h",
|
"type/abstract_numeric.h",
|
||||||
"type/array_count.h",
|
"type/array_count.h",
|
||||||
|
"type/bool.h",
|
||||||
"type/depth_multisampled_texture.h",
|
"type/depth_multisampled_texture.h",
|
||||||
"type/depth_texture.h",
|
"type/depth_texture.h",
|
||||||
"type/external_texture.h",
|
"type/external_texture.h",
|
||||||
|
"type/f16.h",
|
||||||
|
"type/f32.h",
|
||||||
|
"type/i32.h",
|
||||||
"type/multisampled_texture.h",
|
"type/multisampled_texture.h",
|
||||||
"type/node.h",
|
"type/node.h",
|
||||||
"type/sampled_texture.h",
|
"type/sampled_texture.h",
|
||||||
|
@ -580,6 +578,8 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"type/texture.h",
|
"type/texture.h",
|
||||||
"type/type.h",
|
"type/type.h",
|
||||||
"type/type_manager.h",
|
"type/type_manager.h",
|
||||||
|
"type/u32.h",
|
||||||
|
"type/void.h",
|
||||||
"utils/bitcast.h",
|
"utils/bitcast.h",
|
||||||
"utils/bitset.h",
|
"utils/bitset.h",
|
||||||
"utils/block_allocator.h",
|
"utils/block_allocator.h",
|
||||||
|
@ -643,8 +643,6 @@ libtint_source_set("libtint_sem_src") {
|
||||||
"sem/behavior.h",
|
"sem/behavior.h",
|
||||||
"sem/binding_point.h",
|
"sem/binding_point.h",
|
||||||
"sem/block_statement.cc",
|
"sem/block_statement.cc",
|
||||||
"sem/bool.cc",
|
|
||||||
"sem/bool.h",
|
|
||||||
"sem/break_if_statement.cc",
|
"sem/break_if_statement.cc",
|
||||||
"sem/break_if_statement.h",
|
"sem/break_if_statement.h",
|
||||||
"sem/builtin.cc",
|
"sem/builtin.cc",
|
||||||
|
@ -660,15 +658,9 @@ libtint_source_set("libtint_sem_src") {
|
||||||
"sem/evaluation_stage.h",
|
"sem/evaluation_stage.h",
|
||||||
"sem/expression.cc",
|
"sem/expression.cc",
|
||||||
"sem/expression.h",
|
"sem/expression.h",
|
||||||
"sem/f16.cc",
|
|
||||||
"sem/f16.h",
|
|
||||||
"sem/f32.cc",
|
|
||||||
"sem/f32.h",
|
|
||||||
"sem/for_loop_statement.cc",
|
"sem/for_loop_statement.cc",
|
||||||
"sem/for_loop_statement.h",
|
"sem/for_loop_statement.h",
|
||||||
"sem/function.cc",
|
"sem/function.cc",
|
||||||
"sem/i32.cc",
|
|
||||||
"sem/i32.h",
|
|
||||||
"sem/if_statement.cc",
|
"sem/if_statement.cc",
|
||||||
"sem/if_statement.h",
|
"sem/if_statement.h",
|
||||||
"sem/index_accessor_expression.cc",
|
"sem/index_accessor_expression.cc",
|
||||||
|
@ -703,13 +695,9 @@ libtint_source_set("libtint_sem_src") {
|
||||||
"sem/type_initializer.cc",
|
"sem/type_initializer.cc",
|
||||||
"sem/type_initializer.h",
|
"sem/type_initializer.h",
|
||||||
"sem/type_mappings.h",
|
"sem/type_mappings.h",
|
||||||
"sem/u32.cc",
|
|
||||||
"sem/u32.h",
|
|
||||||
"sem/variable.cc",
|
"sem/variable.cc",
|
||||||
"sem/vector.cc",
|
"sem/vector.cc",
|
||||||
"sem/vector.h",
|
"sem/vector.h",
|
||||||
"sem/void.cc",
|
|
||||||
"sem/void.h",
|
|
||||||
"sem/while_statement.cc",
|
"sem/while_statement.cc",
|
||||||
"sem/while_statement.h",
|
"sem/while_statement.h",
|
||||||
]
|
]
|
||||||
|
@ -727,12 +715,20 @@ libtint_source_set("libtint_type_src") {
|
||||||
"type/abstract_numeric.h",
|
"type/abstract_numeric.h",
|
||||||
"type/array_count.cc",
|
"type/array_count.cc",
|
||||||
"type/array_count.h",
|
"type/array_count.h",
|
||||||
|
"type/bool.cc",
|
||||||
|
"type/bool.h",
|
||||||
"type/depth_multisampled_texture.cc",
|
"type/depth_multisampled_texture.cc",
|
||||||
"type/depth_multisampled_texture.h",
|
"type/depth_multisampled_texture.h",
|
||||||
"type/depth_texture.cc",
|
"type/depth_texture.cc",
|
||||||
"type/depth_texture.h",
|
"type/depth_texture.h",
|
||||||
"type/external_texture.cc",
|
"type/external_texture.cc",
|
||||||
"type/external_texture.h",
|
"type/external_texture.h",
|
||||||
|
"type/f16.cc",
|
||||||
|
"type/f16.h",
|
||||||
|
"type/f32.cc",
|
||||||
|
"type/f32.h",
|
||||||
|
"type/i32.cc",
|
||||||
|
"type/i32.h",
|
||||||
"type/multisampled_texture.cc",
|
"type/multisampled_texture.cc",
|
||||||
"type/multisampled_texture.h",
|
"type/multisampled_texture.h",
|
||||||
"type/node.cc",
|
"type/node.cc",
|
||||||
|
@ -749,6 +745,10 @@ libtint_source_set("libtint_type_src") {
|
||||||
"type/type.h",
|
"type/type.h",
|
||||||
"type/type_manager.cc",
|
"type/type_manager.cc",
|
||||||
"type/type_manager.h",
|
"type/type_manager.h",
|
||||||
|
"type/u32.cc",
|
||||||
|
"type/u32.h",
|
||||||
|
"type/void.cc",
|
||||||
|
"type/void.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
public_deps = [ ":libtint_core_all_src" ]
|
public_deps = [ ":libtint_core_all_src" ]
|
||||||
|
@ -1204,26 +1204,25 @@ if (tint_build_unittests) {
|
||||||
sources = [
|
sources = [
|
||||||
"sem/array_test.cc",
|
"sem/array_test.cc",
|
||||||
"sem/atomic_test.cc",
|
"sem/atomic_test.cc",
|
||||||
"sem/bool_test.cc",
|
|
||||||
"sem/builtin_test.cc",
|
"sem/builtin_test.cc",
|
||||||
"sem/expression_test.cc",
|
"sem/expression_test.cc",
|
||||||
"sem/f16_test.cc",
|
|
||||||
"sem/f32_test.cc",
|
|
||||||
"sem/i32_test.cc",
|
|
||||||
"sem/matrix_test.cc",
|
"sem/matrix_test.cc",
|
||||||
"sem/pointer_test.cc",
|
"sem/pointer_test.cc",
|
||||||
"sem/reference_test.cc",
|
"sem/reference_test.cc",
|
||||||
"sem/struct_test.cc",
|
"sem/struct_test.cc",
|
||||||
"sem/u32_test.cc",
|
|
||||||
"sem/vector_test.cc",
|
"sem/vector_test.cc",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
tint_unittests_source_set("tint_unittests_type_src") {
|
tint_unittests_source_set("tint_unittests_type_src") {
|
||||||
sources = [
|
sources = [
|
||||||
|
"type/bool_test.cc",
|
||||||
"type/depth_multisampled_texture_test.cc",
|
"type/depth_multisampled_texture_test.cc",
|
||||||
"type/depth_texture_test.cc",
|
"type/depth_texture_test.cc",
|
||||||
"type/external_texture_test.cc",
|
"type/external_texture_test.cc",
|
||||||
|
"type/f16_test.cc",
|
||||||
|
"type/f32_test.cc",
|
||||||
|
"type/i32_test.cc",
|
||||||
"type/multisampled_texture_test.cc",
|
"type/multisampled_texture_test.cc",
|
||||||
"type/sampled_texture_test.cc",
|
"type/sampled_texture_test.cc",
|
||||||
"type/sampler_test.cc",
|
"type/sampler_test.cc",
|
||||||
|
@ -1231,6 +1230,7 @@ if (tint_build_unittests) {
|
||||||
"type/texture_test.cc",
|
"type/texture_test.cc",
|
||||||
"type/type_manager_test.cc",
|
"type/type_manager_test.cc",
|
||||||
"type/type_test.cc",
|
"type/type_test.cc",
|
||||||
|
"type/u32_test.cc",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,8 +302,6 @@ list(APPEND TINT_LIB_SRCS
|
||||||
sem/binding_point.h
|
sem/binding_point.h
|
||||||
sem/block_statement.cc
|
sem/block_statement.cc
|
||||||
sem/block_statement.h
|
sem/block_statement.h
|
||||||
sem/bool.cc
|
|
||||||
sem/bool.h
|
|
||||||
sem/break_if_statement.cc
|
sem/break_if_statement.cc
|
||||||
sem/break_if_statement.h
|
sem/break_if_statement.h
|
||||||
sem/builtin.cc
|
sem/builtin.cc
|
||||||
|
@ -317,15 +315,9 @@ list(APPEND TINT_LIB_SRCS
|
||||||
sem/evaluation_stage.h
|
sem/evaluation_stage.h
|
||||||
sem/expression.cc
|
sem/expression.cc
|
||||||
sem/expression.h
|
sem/expression.h
|
||||||
sem/f16.cc
|
|
||||||
sem/f16.h
|
|
||||||
sem/f32.cc
|
|
||||||
sem/f32.h
|
|
||||||
sem/for_loop_statement.cc
|
sem/for_loop_statement.cc
|
||||||
sem/for_loop_statement.h
|
sem/for_loop_statement.h
|
||||||
sem/function.cc
|
sem/function.cc
|
||||||
sem/i32.cc
|
|
||||||
sem/i32.h
|
|
||||||
sem/if_statement.cc
|
sem/if_statement.cc
|
||||||
sem/if_statement.h
|
sem/if_statement.h
|
||||||
sem/index_accessor_expression.cc
|
sem/index_accessor_expression.cc
|
||||||
|
@ -358,13 +350,9 @@ list(APPEND TINT_LIB_SRCS
|
||||||
sem/type_conversion.cc
|
sem/type_conversion.cc
|
||||||
sem/type_conversion.h
|
sem/type_conversion.h
|
||||||
sem/type_mappings.h
|
sem/type_mappings.h
|
||||||
sem/u32.cc
|
|
||||||
sem/u32.h
|
|
||||||
sem/variable.cc
|
sem/variable.cc
|
||||||
sem/vector.cc
|
sem/vector.cc
|
||||||
sem/vector.h
|
sem/vector.h
|
||||||
sem/void.cc
|
|
||||||
sem/void.h
|
|
||||||
sem/while_statement.cc
|
sem/while_statement.cc
|
||||||
sem/while_statement.h
|
sem/while_statement.h
|
||||||
symbol_table.cc
|
symbol_table.cc
|
||||||
|
@ -483,12 +471,20 @@ list(APPEND TINT_LIB_SRCS
|
||||||
type/abstract_numeric.h
|
type/abstract_numeric.h
|
||||||
type/array_count.cc
|
type/array_count.cc
|
||||||
type/array_count.h
|
type/array_count.h
|
||||||
|
type/bool.cc
|
||||||
|
type/bool.h
|
||||||
type/depth_multisampled_texture.cc
|
type/depth_multisampled_texture.cc
|
||||||
type/depth_multisampled_texture.h
|
type/depth_multisampled_texture.h
|
||||||
type/depth_texture.cc
|
type/depth_texture.cc
|
||||||
type/depth_texture.h
|
type/depth_texture.h
|
||||||
type/external_texture.cc
|
type/external_texture.cc
|
||||||
type/external_texture.h
|
type/external_texture.h
|
||||||
|
type/f16.cc
|
||||||
|
type/f16.h
|
||||||
|
type/f32.cc
|
||||||
|
type/f32.h
|
||||||
|
type/i32.cc
|
||||||
|
type/i32.h
|
||||||
type/multisampled_texture.cc
|
type/multisampled_texture.cc
|
||||||
type/multisampled_texture.h
|
type/multisampled_texture.h
|
||||||
type/node.cc
|
type/node.cc
|
||||||
|
@ -505,6 +501,10 @@ list(APPEND TINT_LIB_SRCS
|
||||||
type/type.h
|
type/type.h
|
||||||
type/type_manager.cc
|
type/type_manager.cc
|
||||||
type/type_manager.h
|
type/type_manager.h
|
||||||
|
type/u32.cc
|
||||||
|
type/u32.h
|
||||||
|
type/void.cc
|
||||||
|
type/void.h
|
||||||
utils/bitcast.h
|
utils/bitcast.h
|
||||||
utils/bitset.h
|
utils/bitset.h
|
||||||
utils/block_allocator.h
|
utils/block_allocator.h
|
||||||
|
@ -922,17 +922,12 @@ if(TINT_BUILD_TESTS)
|
||||||
scope_stack_test.cc
|
scope_stack_test.cc
|
||||||
sem/array_test.cc
|
sem/array_test.cc
|
||||||
sem/atomic.cc
|
sem/atomic.cc
|
||||||
sem/bool_test.cc
|
|
||||||
sem/builtin_test.cc
|
sem/builtin_test.cc
|
||||||
sem/expression_test.cc
|
sem/expression_test.cc
|
||||||
sem/f16_test.cc
|
|
||||||
sem/f32_test.cc
|
|
||||||
sem/i32_test.cc
|
|
||||||
sem/matrix_test.cc
|
sem/matrix_test.cc
|
||||||
sem/pointer_test.cc
|
sem/pointer_test.cc
|
||||||
sem/reference_test.cc
|
sem/reference_test.cc
|
||||||
sem/struct_test.cc
|
sem/struct_test.cc
|
||||||
sem/u32_test.cc
|
|
||||||
sem/vector_test.cc
|
sem/vector_test.cc
|
||||||
source_test.cc
|
source_test.cc
|
||||||
symbol_table_test.cc
|
symbol_table_test.cc
|
||||||
|
@ -941,9 +936,13 @@ if(TINT_BUILD_TESTS)
|
||||||
text/unicode_test.cc
|
text/unicode_test.cc
|
||||||
traits_test.cc
|
traits_test.cc
|
||||||
transform/transform_test.cc
|
transform/transform_test.cc
|
||||||
|
type/bool_test.cc
|
||||||
type/depth_multisampled_texture_test.cc
|
type/depth_multisampled_texture_test.cc
|
||||||
type/depth_texture_test.cc
|
type/depth_texture_test.cc
|
||||||
type/external_texture_test.cc
|
type/external_texture_test.cc
|
||||||
|
type/f16_test.cc
|
||||||
|
type/f32_test.cc
|
||||||
|
type/i32_test.cc
|
||||||
type/multisampled_texture_test.cc
|
type/multisampled_texture_test.cc
|
||||||
type/sampled_texture_test.cc
|
type/sampled_texture_test.cc
|
||||||
type/sampler_test.cc
|
type/sampler_test.cc
|
||||||
|
@ -951,6 +950,7 @@ if(TINT_BUILD_TESTS)
|
||||||
type/texture_test.cc
|
type/texture_test.cc
|
||||||
type/type_test.cc
|
type/type_test.cc
|
||||||
type/type_manager_test.cc
|
type/type_manager_test.cc
|
||||||
|
type/u32_test.cc
|
||||||
utils/bitcast_test.cc
|
utils/bitcast_test.cc
|
||||||
utils/bitset_test.cc
|
utils/bitset_test.cc
|
||||||
utils/block_allocator_test.cc
|
utils/block_allocator_test.cc
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/reference.h"
|
#include "src/tint/sem/reference.h"
|
||||||
|
#include "src/tint/type/bool.h"
|
||||||
|
|
||||||
namespace tint::fuzzers::ast_fuzzer {
|
namespace tint::fuzzers::ast_fuzzer {
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ bool CanReplaceAndOrWith(const type::Type* lhs_type,
|
||||||
case ast::BinaryOp::kLogicalOr:
|
case ast::BinaryOp::kLogicalOr:
|
||||||
// '&' and '|' can be applied to booleans, and for boolean scalar
|
// '&' and '|' can be applied to booleans, and for boolean scalar
|
||||||
// scalar contexts, their logical counterparts work.
|
// scalar contexts, their logical counterparts work.
|
||||||
return lhs_type->Is<sem::Bool>();
|
return lhs_type->Is<type::Bool>();
|
||||||
case ast::BinaryOp::kEqual:
|
case ast::BinaryOp::kEqual:
|
||||||
case ast::BinaryOp::kNotEqual:
|
case ast::BinaryOp::kNotEqual:
|
||||||
// '&' and '|' can be applied to booleans, and in these contexts equality
|
// '&' and '|' can be applied to booleans, and in these contexts equality
|
||||||
|
@ -249,7 +249,7 @@ bool CanReplaceEqualNotEqualWith(const type::Type* lhs_type, ast::BinaryOp new_o
|
||||||
case ast::BinaryOp::kLogicalOr:
|
case ast::BinaryOp::kLogicalOr:
|
||||||
// An equality comparison between boolean scalars can be turned into a
|
// An equality comparison between boolean scalars can be turned into a
|
||||||
// logical operation.
|
// logical operation.
|
||||||
return lhs_type->Is<sem::Bool>();
|
return lhs_type->Is<type::Bool>();
|
||||||
case ast::BinaryOp::kAnd:
|
case ast::BinaryOp::kAnd:
|
||||||
case ast::BinaryOp::kOr:
|
case ast::BinaryOp::kOr:
|
||||||
// An equality comparison between boolean scalars or vectors can be turned
|
// An equality comparison between boolean scalars or vectors can be turned
|
||||||
|
|
|
@ -29,26 +29,26 @@
|
||||||
#include "src/tint/ast/override.h"
|
#include "src/tint/ast/override.h"
|
||||||
#include "src/tint/ast/var.h"
|
#include "src/tint/ast/var.h"
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/module.h"
|
#include "src/tint/sem/module.h"
|
||||||
#include "src/tint/sem/statement.h"
|
#include "src/tint/sem/statement.h"
|
||||||
#include "src/tint/sem/struct.h"
|
#include "src/tint/sem/struct.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/variable.h"
|
#include "src/tint/sem/variable.h"
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
#include "src/tint/sem/void.h"
|
#include "src/tint/type/bool.h"
|
||||||
#include "src/tint/type/depth_multisampled_texture.h"
|
#include "src/tint/type/depth_multisampled_texture.h"
|
||||||
#include "src/tint/type/depth_texture.h"
|
#include "src/tint/type/depth_texture.h"
|
||||||
#include "src/tint/type/external_texture.h"
|
#include "src/tint/type/external_texture.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/type/multisampled_texture.h"
|
#include "src/tint/type/multisampled_texture.h"
|
||||||
#include "src/tint/type/sampled_texture.h"
|
#include "src/tint/type/sampled_texture.h"
|
||||||
#include "src/tint/type/storage_texture.h"
|
#include "src/tint/type/storage_texture.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
|
#include "src/tint/type/void.h"
|
||||||
#include "src/tint/utils/math.h"
|
#include "src/tint/utils/math.h"
|
||||||
#include "src/tint/utils/string.h"
|
#include "src/tint/utils/string.h"
|
||||||
#include "src/tint/utils/unique_vector.h"
|
#include "src/tint/utils/unique_vector.h"
|
||||||
|
@ -75,10 +75,10 @@ std::tuple<ComponentType, CompositionType> CalculateComponentAndComposition(
|
||||||
|
|
||||||
ComponentType componentType = Switch(
|
ComponentType componentType = Switch(
|
||||||
type::Type::DeepestElementOf(type), //
|
type::Type::DeepestElementOf(type), //
|
||||||
[&](const sem::F32*) { return ComponentType::kF32; },
|
[&](const type::F32*) { return ComponentType::kF32; },
|
||||||
[&](const sem::F16*) { return ComponentType::kF16; },
|
[&](const type::F16*) { return ComponentType::kF16; },
|
||||||
[&](const sem::I32*) { return ComponentType::kI32; },
|
[&](const type::I32*) { return ComponentType::kI32; },
|
||||||
[&](const sem::U32*) { return ComponentType::kU32; },
|
[&](const type::U32*) { return ComponentType::kU32; },
|
||||||
[&](Default) {
|
[&](Default) {
|
||||||
tint::diag::List diagnostics;
|
tint::diag::List diagnostics;
|
||||||
TINT_UNREACHABLE(Inspector, diagnostics) << "unhandled component type";
|
TINT_UNREACHABLE(Inspector, diagnostics) << "unhandled component type";
|
||||||
|
@ -226,7 +226,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
||||||
ast::BuiltinValue::kNumWorkgroups, param->Type(), param->Declaration()->attributes);
|
ast::BuiltinValue::kNumWorkgroups, param->Type(), param->Declaration()->attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sem->ReturnType()->Is<sem::Void>()) {
|
if (!sem->ReturnType()->Is<type::Void>()) {
|
||||||
AddEntryPointInOutVariables("<retval>", sem->ReturnType(), func->return_type_attributes,
|
AddEntryPointInOutVariables("<retval>", sem->ReturnType(), func->return_type_attributes,
|
||||||
sem->ReturnLocation(), entry_point.output_variables);
|
sem->ReturnLocation(), entry_point.output_variables);
|
||||||
|
|
||||||
|
@ -314,10 +314,10 @@ std::map<OverrideId, Scalar> Inspector::GetOverrideDefaultValues() {
|
||||||
if (auto* value = global->Initializer()->ConstantValue()) {
|
if (auto* value = global->Initializer()->ConstantValue()) {
|
||||||
result[override_id] = Switch(
|
result[override_id] = Switch(
|
||||||
value->Type(), //
|
value->Type(), //
|
||||||
[&](const sem::I32*) { return Scalar(value->As<i32>()); },
|
[&](const type::I32*) { return Scalar(value->As<i32>()); },
|
||||||
[&](const sem::U32*) { return Scalar(value->As<u32>()); },
|
[&](const type::U32*) { return Scalar(value->As<u32>()); },
|
||||||
[&](const sem::F32*) { return Scalar(value->As<f32>()); },
|
[&](const type::F32*) { return Scalar(value->As<f32>()); },
|
||||||
[&](const sem::Bool*) { return Scalar(value->As<bool>()); });
|
[&](const type::Bool*) { return Scalar(value->As<bool>()); });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
#include "src/tint/inspector/resource_binding.h"
|
#include "src/tint/inspector/resource_binding.h"
|
||||||
|
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
|
|
||||||
namespace tint::inspector {
|
namespace tint::inspector {
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type)
|
||||||
base_type = vt->type();
|
base_type = vt->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_type->Is<sem::F32>()) {
|
if (base_type->Is<type::F32>()) {
|
||||||
return ResourceBinding::SampledKind::kFloat;
|
return ResourceBinding::SampledKind::kFloat;
|
||||||
} else if (base_type->Is<sem::U32>()) {
|
} else if (base_type->Is<type::U32>()) {
|
||||||
return ResourceBinding::SampledKind::kUInt;
|
return ResourceBinding::SampledKind::kUInt;
|
||||||
} else if (base_type->Is<sem::I32>()) {
|
} else if (base_type->Is<type::I32>()) {
|
||||||
return ResourceBinding::SampledKind::kSInt;
|
return ResourceBinding::SampledKind::kSInt;
|
||||||
} else {
|
} else {
|
||||||
return ResourceBinding::SampledKind::kUnknown;
|
return ResourceBinding::SampledKind::kUnknown;
|
||||||
|
|
|
@ -92,22 +92,22 @@
|
||||||
#include "src/tint/program_id.h"
|
#include "src/tint/program_id.h"
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/array_count.h"
|
#include "src/tint/sem/array_count.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/constant.h"
|
#include "src/tint/sem/constant.h"
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/pointer.h"
|
#include "src/tint/sem/pointer.h"
|
||||||
#include "src/tint/sem/struct.h"
|
#include "src/tint/sem/struct.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
#include "src/tint/sem/void.h"
|
#include "src/tint/type/bool.h"
|
||||||
#include "src/tint/type/depth_texture.h"
|
#include "src/tint/type/depth_texture.h"
|
||||||
#include "src/tint/type/external_texture.h"
|
#include "src/tint/type/external_texture.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/type/multisampled_texture.h"
|
#include "src/tint/type/multisampled_texture.h"
|
||||||
#include "src/tint/type/sampled_texture.h"
|
#include "src/tint/type/sampled_texture.h"
|
||||||
#include "src/tint/type/storage_texture.h"
|
#include "src/tint/type/storage_texture.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
|
#include "src/tint/type/void.h"
|
||||||
|
|
||||||
#ifdef CURRENTLY_IN_TINT_PUBLIC_HEADER
|
#ifdef CURRENTLY_IN_TINT_PUBLIC_HEADER
|
||||||
#error "internal tint header being #included from tint.h"
|
#error "internal tint header being #included from tint.h"
|
||||||
|
|
|
@ -132,7 +132,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
|
||||||
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -184,7 +184,7 @@ TEST_F(ResolverIndexAccessorTest, Vector) {
|
||||||
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -200,7 +200,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) {
|
||||||
ASSERT_NE(TypeOf(acc), nullptr);
|
ASSERT_NE(TypeOf(acc), nullptr);
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
ASSERT_NE(ref, nullptr);
|
ASSERT_NE(ref, nullptr);
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -216,7 +216,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) {
|
||||||
ASSERT_NE(TypeOf(acc), nullptr);
|
ASSERT_NE(TypeOf(acc), nullptr);
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
ASSERT_NE(ref, nullptr);
|
ASSERT_NE(ref, nullptr);
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -232,7 +232,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) {
|
||||||
ASSERT_NE(TypeOf(acc), nullptr);
|
ASSERT_NE(TypeOf(acc), nullptr);
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
ASSERT_NE(ref, nullptr);
|
ASSERT_NE(ref, nullptr);
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -254,7 +254,7 @@ TEST_F(ResolverIndexAccessorTest, Alias_Array) {
|
||||||
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(acc)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
auto* ref = TypeOf(acc)->As<sem::Reference>();
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
|
|
||||||
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
auto idx_sem = Sem().Get<sem::IndexAccessorExpression>(acc);
|
||||||
ASSERT_NE(idx_sem, nullptr);
|
ASSERT_NE(idx_sem, nullptr);
|
||||||
|
@ -271,7 +271,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Constant) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(acc), nullptr);
|
ASSERT_NE(TypeOf(acc), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(acc)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(acc)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) {
|
TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) {
|
||||||
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
||||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
||||||
ASSERT_NE(atomic, nullptr);
|
ASSERT_NE(atomic, nullptr);
|
||||||
EXPECT_TRUE(atomic->Type()->Is<sem::I32>());
|
EXPECT_TRUE(atomic->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
|
TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
|
||||||
|
@ -43,7 +43,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
|
||||||
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
|
||||||
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
auto* atomic = TypeOf(g)->UnwrapRef()->As<sem::Atomic>();
|
||||||
ASSERT_NE(atomic, nullptr);
|
ASSERT_NE(atomic, nullptr);
|
||||||
EXPECT_TRUE(atomic->Type()->Is<sem::U32>());
|
EXPECT_TRUE(atomic->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
|
TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
|
||||||
|
@ -58,7 +58,7 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
|
||||||
ASSERT_EQ(str->Members().Length(), 1u);
|
ASSERT_EQ(str->Members().Length(), 1u);
|
||||||
auto* atomic = str->Members()[0]->Type()->As<sem::Atomic>();
|
auto* atomic = str->Members()[0]->Type()->As<sem::Atomic>();
|
||||||
ASSERT_NE(atomic, nullptr);
|
ASSERT_NE(atomic, nullptr);
|
||||||
ASSERT_TRUE(atomic->Type()->Is<sem::I32>());
|
ASSERT_TRUE(atomic->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -87,7 +87,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
TEST_P(ResolverBuiltinTest_BoolMethod, Vector) {
|
TEST_P(ResolverBuiltinTest_BoolMethod, Vector) {
|
||||||
auto name = GetParam();
|
auto name = GetParam();
|
||||||
|
@ -100,7 +100,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Vector) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
||||||
ResolverBuiltinTest_BoolMethod,
|
ResolverBuiltinTest_BoolMethod,
|
||||||
|
@ -119,7 +119,7 @@ TEST_F(ResolverBuiltinTest, Select) {
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
EXPECT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
||||||
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Select_Error_NoParams) {
|
TEST_F(ResolverBuiltinTest, Select_Error_NoParams) {
|
||||||
|
@ -222,7 +222,7 @@ TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinArrayTest, ArrayLength_Error_ArraySized) {
|
TEST_F(ResolverBuiltinArrayTest, ArrayLength_Error_ArraySized) {
|
||||||
|
@ -290,7 +290,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -317,7 +317,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -338,7 +338,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -362,7 +362,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -383,7 +383,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -408,7 +408,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -430,7 +430,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -455,7 +455,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -484,7 +484,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -513,7 +513,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f16) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -536,7 +536,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -562,7 +562,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f16) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -585,7 +585,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -612,7 +612,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f16) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -636,7 +636,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -663,7 +663,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f16) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -739,7 +739,7 @@ TEST_F(ResolverBuiltinFloatTest, Cross_f32) {
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Cross_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Cross_f16) {
|
||||||
|
@ -753,7 +753,7 @@ TEST_F(ResolverBuiltinFloatTest, Cross_f16) {
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Cross_Error_NoArgs) {
|
TEST_F(ResolverBuiltinFloatTest, Cross_Error_NoArgs) {
|
||||||
|
@ -835,7 +835,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) {
|
||||||
|
@ -847,7 +847,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) {
|
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) {
|
||||||
|
@ -857,7 +857,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) {
|
||||||
|
@ -869,7 +869,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Distance_TooManyParams) {
|
TEST_F(ResolverBuiltinFloatTest, Distance_TooManyParams) {
|
||||||
|
@ -929,14 +929,14 @@ TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f32) {
|
||||||
ASSERT_EQ(ty->Members().Length(), 2u);
|
ASSERT_EQ(ty->Members().Length(), 2u);
|
||||||
|
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
EXPECT_TRUE(fract->Type()->Is<sem::F32>());
|
EXPECT_TRUE(fract->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 4u);
|
EXPECT_EQ(fract->Size(), 4u);
|
||||||
EXPECT_EQ(fract->Align(), 4u);
|
EXPECT_EQ(fract->Align(), 4u);
|
||||||
EXPECT_EQ(fract->Name(), Sym("fract"));
|
EXPECT_EQ(fract->Name(), Sym("fract"));
|
||||||
|
|
||||||
auto* exp = ty->Members()[1];
|
auto* exp = ty->Members()[1];
|
||||||
EXPECT_TRUE(exp->Type()->Is<sem::I32>());
|
EXPECT_TRUE(exp->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(exp->Offset(), 4u);
|
EXPECT_EQ(exp->Offset(), 4u);
|
||||||
EXPECT_EQ(exp->Size(), 4u);
|
EXPECT_EQ(exp->Size(), 4u);
|
||||||
EXPECT_EQ(exp->Align(), 4u);
|
EXPECT_EQ(exp->Align(), 4u);
|
||||||
|
@ -960,14 +960,14 @@ TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f16) {
|
||||||
ASSERT_EQ(ty->Members().Length(), 2u);
|
ASSERT_EQ(ty->Members().Length(), 2u);
|
||||||
|
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
EXPECT_TRUE(fract->Type()->Is<sem::F16>());
|
EXPECT_TRUE(fract->Type()->Is<type::F16>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 2u);
|
EXPECT_EQ(fract->Size(), 2u);
|
||||||
EXPECT_EQ(fract->Align(), 2u);
|
EXPECT_EQ(fract->Align(), 2u);
|
||||||
EXPECT_EQ(fract->Name(), Sym("fract"));
|
EXPECT_EQ(fract->Name(), Sym("fract"));
|
||||||
|
|
||||||
auto* exp = ty->Members()[1];
|
auto* exp = ty->Members()[1];
|
||||||
EXPECT_TRUE(exp->Type()->Is<sem::I32>());
|
EXPECT_TRUE(exp->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(exp->Offset(), 4u);
|
EXPECT_EQ(exp->Offset(), 4u);
|
||||||
EXPECT_EQ(exp->Size(), 4u);
|
EXPECT_EQ(exp->Size(), 4u);
|
||||||
EXPECT_EQ(exp->Align(), 4u);
|
EXPECT_EQ(exp->Align(), 4u);
|
||||||
|
@ -991,7 +991,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f32) {
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 12u);
|
EXPECT_EQ(fract->Size(), 12u);
|
||||||
EXPECT_EQ(fract->Align(), 16u);
|
EXPECT_EQ(fract->Align(), 16u);
|
||||||
|
@ -1000,7 +1000,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f32) {
|
||||||
auto* exp = ty->Members()[1];
|
auto* exp = ty->Members()[1];
|
||||||
ASSERT_TRUE(exp->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(exp->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(exp->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(exp->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(exp->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(exp->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(exp->Offset(), 16u);
|
EXPECT_EQ(exp->Offset(), 16u);
|
||||||
EXPECT_EQ(exp->Size(), 12u);
|
EXPECT_EQ(exp->Size(), 12u);
|
||||||
EXPECT_EQ(exp->Align(), 16u);
|
EXPECT_EQ(exp->Align(), 16u);
|
||||||
|
@ -1026,7 +1026,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) {
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 6u);
|
EXPECT_EQ(fract->Size(), 6u);
|
||||||
EXPECT_EQ(fract->Align(), 8u);
|
EXPECT_EQ(fract->Align(), 8u);
|
||||||
|
@ -1035,7 +1035,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) {
|
||||||
auto* exp = ty->Members()[1];
|
auto* exp = ty->Members()[1];
|
||||||
ASSERT_TRUE(exp->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(exp->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(exp->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(exp->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(exp->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(exp->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(exp->Offset(), 16u);
|
EXPECT_EQ(exp->Offset(), 16u);
|
||||||
EXPECT_EQ(exp->Size(), 12u);
|
EXPECT_EQ(exp->Size(), 12u);
|
||||||
EXPECT_EQ(exp->Align(), 16u);
|
EXPECT_EQ(exp->Align(), 16u);
|
||||||
|
@ -1092,7 +1092,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) {
|
||||||
|
@ -1104,7 +1104,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) {
|
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) {
|
||||||
|
@ -1114,7 +1114,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) {
|
||||||
|
@ -1126,7 +1126,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Length_NoParams) {
|
TEST_F(ResolverBuiltinFloatTest, Length_NoParams) {
|
||||||
|
@ -1169,7 +1169,7 @@ TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) {
|
||||||
|
@ -1184,7 +1184,7 @@ TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// modf: (f32) -> __modf_result, (vecN<f32>) -> __modf_result_vecN, (f16) -> __modf_result_f16,
|
// modf: (f32) -> __modf_result, (vecN<f32>) -> __modf_result_vecN, (f16) -> __modf_result_f16,
|
||||||
|
@ -1201,14 +1201,14 @@ TEST_F(ResolverBuiltinFloatTest, ModfScalar_f32) {
|
||||||
ASSERT_EQ(ty->Members().Length(), 2u);
|
ASSERT_EQ(ty->Members().Length(), 2u);
|
||||||
|
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
EXPECT_TRUE(fract->Type()->Is<sem::F32>());
|
EXPECT_TRUE(fract->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 4u);
|
EXPECT_EQ(fract->Size(), 4u);
|
||||||
EXPECT_EQ(fract->Align(), 4u);
|
EXPECT_EQ(fract->Align(), 4u);
|
||||||
EXPECT_EQ(fract->Name(), Sym("fract"));
|
EXPECT_EQ(fract->Name(), Sym("fract"));
|
||||||
|
|
||||||
auto* whole = ty->Members()[1];
|
auto* whole = ty->Members()[1];
|
||||||
EXPECT_TRUE(whole->Type()->Is<sem::F32>());
|
EXPECT_TRUE(whole->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(whole->Offset(), 4u);
|
EXPECT_EQ(whole->Offset(), 4u);
|
||||||
EXPECT_EQ(whole->Size(), 4u);
|
EXPECT_EQ(whole->Size(), 4u);
|
||||||
EXPECT_EQ(whole->Align(), 4u);
|
EXPECT_EQ(whole->Align(), 4u);
|
||||||
|
@ -1232,14 +1232,14 @@ TEST_F(ResolverBuiltinFloatTest, ModfScalar_f16) {
|
||||||
ASSERT_EQ(ty->Members().Length(), 2u);
|
ASSERT_EQ(ty->Members().Length(), 2u);
|
||||||
|
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
EXPECT_TRUE(fract->Type()->Is<sem::F16>());
|
EXPECT_TRUE(fract->Type()->Is<type::F16>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 2u);
|
EXPECT_EQ(fract->Size(), 2u);
|
||||||
EXPECT_EQ(fract->Align(), 2u);
|
EXPECT_EQ(fract->Align(), 2u);
|
||||||
EXPECT_EQ(fract->Name(), Sym("fract"));
|
EXPECT_EQ(fract->Name(), Sym("fract"));
|
||||||
|
|
||||||
auto* whole = ty->Members()[1];
|
auto* whole = ty->Members()[1];
|
||||||
EXPECT_TRUE(whole->Type()->Is<sem::F16>());
|
EXPECT_TRUE(whole->Type()->Is<type::F16>());
|
||||||
EXPECT_EQ(whole->Offset(), 2u);
|
EXPECT_EQ(whole->Offset(), 2u);
|
||||||
EXPECT_EQ(whole->Size(), 2u);
|
EXPECT_EQ(whole->Size(), 2u);
|
||||||
EXPECT_EQ(whole->Align(), 2u);
|
EXPECT_EQ(whole->Align(), 2u);
|
||||||
|
@ -1263,7 +1263,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f32) {
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 12u);
|
EXPECT_EQ(fract->Size(), 12u);
|
||||||
EXPECT_EQ(fract->Align(), 16u);
|
EXPECT_EQ(fract->Align(), 16u);
|
||||||
|
@ -1272,7 +1272,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f32) {
|
||||||
auto* whole = ty->Members()[1];
|
auto* whole = ty->Members()[1];
|
||||||
ASSERT_TRUE(whole->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(whole->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(whole->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(whole->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(whole->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(whole->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(whole->Offset(), 16u);
|
EXPECT_EQ(whole->Offset(), 16u);
|
||||||
EXPECT_EQ(whole->Size(), 12u);
|
EXPECT_EQ(whole->Size(), 12u);
|
||||||
EXPECT_EQ(whole->Align(), 16u);
|
EXPECT_EQ(whole->Align(), 16u);
|
||||||
|
@ -1298,7 +1298,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) {
|
||||||
auto* fract = ty->Members()[0];
|
auto* fract = ty->Members()[0];
|
||||||
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(fract->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(fract->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(fract->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(fract->Offset(), 0u);
|
EXPECT_EQ(fract->Offset(), 0u);
|
||||||
EXPECT_EQ(fract->Size(), 6u);
|
EXPECT_EQ(fract->Size(), 6u);
|
||||||
EXPECT_EQ(fract->Align(), 8u);
|
EXPECT_EQ(fract->Align(), 8u);
|
||||||
|
@ -1307,7 +1307,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) {
|
||||||
auto* whole = ty->Members()[1];
|
auto* whole = ty->Members()[1];
|
||||||
ASSERT_TRUE(whole->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(whole->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(whole->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(whole->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(whole->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(whole->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(whole->Offset(), 8u);
|
EXPECT_EQ(whole->Offset(), 8u);
|
||||||
EXPECT_EQ(whole->Size(), 6u);
|
EXPECT_EQ(whole->Size(), 6u);
|
||||||
EXPECT_EQ(whole->Align(), 8u);
|
EXPECT_EQ(whole->Align(), 8u);
|
||||||
|
@ -1389,7 +1389,7 @@ TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f32) {
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) {
|
TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) {
|
||||||
|
@ -1403,7 +1403,7 @@ TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) {
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
EXPECT_TRUE(TypeOf(call)->is_float_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinFloatTest, Normalize_Error_NoParams) {
|
TEST_F(ResolverBuiltinFloatTest, Normalize_Error_NoParams) {
|
||||||
|
@ -1464,7 +1464,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_i32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1488,7 +1488,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_i32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1509,7 +1509,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_u32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1533,7 +1533,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_u32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1554,7 +1554,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_i32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1578,7 +1578,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_i32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1599,7 +1599,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_u32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1623,7 +1623,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_u32) {
|
||||||
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1644,7 +1644,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_i32)
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1669,7 +1669,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_i32)
|
||||||
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1691,7 +1691,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_u32)
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1716,7 +1716,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_u32)
|
||||||
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1738,7 +1738,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_i32)
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1763,7 +1763,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_i32)
|
||||||
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1785,7 +1785,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_u32)
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1810,7 +1810,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_u32)
|
||||||
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector());
|
||||||
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(call)->As<sem::Vector>()->Width(), 3u);
|
||||||
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
ASSERT_NE(TypeOf(call)->As<sem::Vector>()->type(), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
} else {
|
} else {
|
||||||
// Invalid parameter count.
|
// Invalid parameter count.
|
||||||
EXPECT_FALSE(r()->Resolve());
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
@ -1852,7 +1852,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) {
|
TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) {
|
||||||
|
@ -1866,7 +1866,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) {
|
TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) {
|
||||||
|
@ -1878,7 +1878,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) {
|
TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) {
|
||||||
|
@ -1892,7 +1892,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) {
|
TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) {
|
||||||
|
@ -1904,7 +1904,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) {
|
TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) {
|
||||||
|
@ -1918,7 +1918,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Determinant_NotSquare) {
|
TEST_F(ResolverBuiltinTest, Determinant_NotSquare) {
|
||||||
|
@ -1965,7 +1965,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) {
|
TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) {
|
||||||
|
@ -1979,7 +1979,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) {
|
TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) {
|
||||||
|
@ -1991,7 +1991,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) {
|
TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) {
|
||||||
|
@ -2003,7 +2003,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
|
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
|
||||||
|
@ -2039,7 +2039,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Scalar) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ResolverBuiltinDerivativeTest, Vector) {
|
TEST_P(ResolverBuiltinDerivativeTest, Vector) {
|
||||||
|
@ -2054,7 +2054,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Vector) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2182,11 +2182,11 @@ TEST_P(ResolverBuiltinTest_SampledTextureOperation, TextureLoadSampled) {
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(expr)->Is<sem::Vector>());
|
||||||
if (type == Texture::kF32) {
|
if (type == Texture::kF32) {
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
} else if (type == Texture::kI32) {
|
} else if (type == Texture::kI32) {
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(expr)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
@ -2470,7 +2470,7 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
|
||||||
default:
|
default:
|
||||||
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
|
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
|
||||||
case ast::TextureDimension::k1d:
|
case ast::TextureDimension::k1d:
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
break;
|
break;
|
||||||
case ast::TextureDimension::k2d:
|
case ast::TextureDimension::k2d:
|
||||||
case ast::TextureDimension::k2dArray:
|
case ast::TextureDimension::k2dArray:
|
||||||
|
@ -2479,45 +2479,45 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
|
||||||
auto* vec = As<sem::Vector>(TypeOf(call));
|
auto* vec = As<sem::Vector>(TypeOf(call));
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_EQ(vec->Width(), 2u);
|
EXPECT_EQ(vec->Width(), 2u);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ast::TextureDimension::k3d: {
|
case ast::TextureDimension::k3d: {
|
||||||
auto* vec = As<sem::Vector>(TypeOf(call));
|
auto* vec = As<sem::Vector>(TypeOf(call));
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (std::string(param.function) == "textureNumLayers") {
|
} else if (std::string(param.function) == "textureNumLayers") {
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else if (std::string(param.function) == "textureNumLevels") {
|
} else if (std::string(param.function) == "textureNumLevels") {
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else if (std::string(param.function) == "textureNumSamples") {
|
} else if (std::string(param.function) == "textureNumSamples") {
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
} else if (std::string(param.function) == "textureStore") {
|
} else if (std::string(param.function) == "textureStore") {
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::Void>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::Void>());
|
||||||
} else if (std::string(param.function) == "textureGather") {
|
} else if (std::string(param.function) == "textureGather") {
|
||||||
auto* vec = As<sem::Vector>(TypeOf(call));
|
auto* vec = As<sem::Vector>(TypeOf(call));
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_EQ(vec->Width(), 4u);
|
EXPECT_EQ(vec->Width(), 4u);
|
||||||
switch (param.texture_data_type) {
|
switch (param.texture_data_type) {
|
||||||
case ast::builtin::test::TextureDataType::kF32:
|
case ast::builtin::test::TextureDataType::kF32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
break;
|
break;
|
||||||
case ast::builtin::test::TextureDataType::kU32:
|
case ast::builtin::test::TextureDataType::kU32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
break;
|
break;
|
||||||
case ast::builtin::test::TextureDataType::kI32:
|
case ast::builtin::test::TextureDataType::kI32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (std::string(param.function) == "textureGatherCompare") {
|
} else if (std::string(param.function) == "textureGatherCompare") {
|
||||||
auto* vec = As<sem::Vector>(TypeOf(call));
|
auto* vec = As<sem::Vector>(TypeOf(call));
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_EQ(vec->Width(), 4u);
|
EXPECT_EQ(vec->Width(), 4u);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
} else {
|
} else {
|
||||||
switch (param.texture_kind) {
|
switch (param.texture_kind) {
|
||||||
case ast::builtin::test::TextureKind::kRegular:
|
case ast::builtin::test::TextureKind::kRegular:
|
||||||
|
@ -2527,20 +2527,20 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
switch (param.texture_data_type) {
|
switch (param.texture_data_type) {
|
||||||
case ast::builtin::test::TextureDataType::kF32:
|
case ast::builtin::test::TextureDataType::kF32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
break;
|
break;
|
||||||
case ast::builtin::test::TextureDataType::kU32:
|
case ast::builtin::test::TextureDataType::kU32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
break;
|
break;
|
||||||
case ast::builtin::test::TextureDataType::kI32:
|
case ast::builtin::test::TextureDataType::kI32:
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ast::builtin::test::TextureKind::kDepth:
|
case ast::builtin::test::TextureKind::kDepth:
|
||||||
case ast::builtin::test::TextureKind::kDepthMultisampled: {
|
case ast::builtin::test::TextureKind::kDepthMultisampled: {
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2574,7 +2574,7 @@ TEST_P(ResolverBuiltinTest_DataPacking, InferType) {
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) {
|
TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) {
|
||||||
|
@ -2675,7 +2675,7 @@ TEST_P(ResolverBuiltinTest_Barrier, InferType) {
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::Void>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) {
|
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) {
|
||||||
|
|
|
@ -894,8 +894,8 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {
|
||||||
ASSERT_TRUE(res_ty != nullptr);
|
ASSERT_TRUE(res_ty != nullptr);
|
||||||
auto members = res_ty->Members();
|
auto members = res_ty->Members();
|
||||||
ASSERT_EQ(members.Length(), 2u);
|
ASSERT_EQ(members.Length(), 2u);
|
||||||
EXPECT_TRUE(members[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(members[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(members[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
||||||
|
@ -910,9 +910,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
||||||
|
@ -927,9 +927,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
||||||
|
@ -944,9 +944,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
||||||
|
@ -958,8 +958,8 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
|
||||||
ASSERT_TRUE(res_ty != nullptr);
|
ASSERT_TRUE(res_ty != nullptr);
|
||||||
auto members = res_ty->Members();
|
auto members = res_ty->Members();
|
||||||
ASSERT_EQ(members.Length(), 2u);
|
ASSERT_EQ(members.Length(), 2u);
|
||||||
EXPECT_TRUE(members[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(members[1]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(members[1]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
||||||
|
@ -974,9 +974,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
||||||
|
@ -991,9 +991,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
||||||
|
@ -1008,9 +1008,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
|
||||||
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(members[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(members[0]->Type()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(members[1]->Type()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(members[1]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
|
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
|
||||||
|
@ -1111,7 +1111,7 @@ TEST_P(FloatAllMatching, Scalar) {
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
EXPECT_TRUE(TypeOf(builtin)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(builtin)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(FloatAllMatching, Vec2) {
|
TEST_P(FloatAllMatching, Vec2) {
|
||||||
|
@ -1235,7 +1235,7 @@ TEST_P(IntegerAllMatching, ScalarUnsigned) {
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
EXPECT_TRUE(TypeOf(builtin)->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(builtin)->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(IntegerAllMatching, Vec2Unsigned) {
|
TEST_P(IntegerAllMatching, Vec2Unsigned) {
|
||||||
|
@ -1295,7 +1295,7 @@ TEST_P(IntegerAllMatching, ScalarSigned) {
|
||||||
WrapInFunction(builtin);
|
WrapInFunction(builtin);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
EXPECT_TRUE(TypeOf(builtin)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(builtin)->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(IntegerAllMatching, Vec2Signed) {
|
TEST_P(IntegerAllMatching, Vec2Signed) {
|
||||||
|
|
|
@ -24,18 +24,18 @@
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/constant.h"
|
#include "src/tint/sem/constant.h"
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
#include "src/tint/sem/type_initializer.h"
|
#include "src/tint/sem/type_initializer.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
#include "src/tint/type/abstract_float.h"
|
#include "src/tint/type/abstract_float.h"
|
||||||
#include "src/tint/type/abstract_int.h"
|
#include "src/tint/type/abstract_int.h"
|
||||||
|
#include "src/tint/type/bool.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
#include "src/tint/utils/bitcast.h"
|
#include "src/tint/utils/bitcast.h"
|
||||||
#include "src/tint/utils/compiler_macros.h"
|
#include "src/tint/utils/compiler_macros.h"
|
||||||
#include "src/tint/utils/map.h"
|
#include "src/tint/utils/map.h"
|
||||||
|
@ -59,8 +59,8 @@ template <typename F, typename... CONSTANTS>
|
||||||
auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) {
|
auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) {
|
||||||
return Switch(
|
return Switch(
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); });
|
[&](const type::U32*) { return f(cs->template As<u32>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -70,8 +70,8 @@ auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) {
|
||||||
return Switch(
|
return Switch(
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); });
|
[&](const type::U32*) { return f(cs->template As<u32>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -81,9 +81,9 @@ auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) {
|
||||||
return Switch(
|
return Switch(
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
[&](const type::U32*) { return f(cs->template As<u32>()...); },
|
||||||
[&](const sem::Bool*) { return f(cs->template As<bool>()...); });
|
[&](const type::Bool*) { return f(cs->template As<bool>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -94,9 +94,9 @@ auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) {
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
[&](const type::F32*) { return f(cs->template As<f32>()...); },
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
|
[&](const type::F16*) { return f(cs->template As<f16>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -107,10 +107,10 @@ auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) {
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
[&](const type::F32*) { return f(cs->template As<f32>()...); },
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
[&](const type::U32*) { return f(cs->template As<u32>()...); },
|
||||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
|
[&](const type::F16*) { return f(cs->template As<f16>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -121,11 +121,11 @@ auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) {
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
[&](const type::AbstractInt*) { return f(cs->template As<AInt>()...); },
|
||||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
[&](const type::F32*) { return f(cs->template As<f32>()...); },
|
||||||
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
|
[&](const type::I32*) { return f(cs->template As<i32>()...); },
|
||||||
[&](const sem::U32*) { return f(cs->template As<u32>()...); },
|
[&](const type::U32*) { return f(cs->template As<u32>()...); },
|
||||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); },
|
[&](const type::F16*) { return f(cs->template As<f16>()...); },
|
||||||
[&](const sem::Bool*) { return f(cs->template As<bool>()...); });
|
[&](const type::Bool*) { return f(cs->template As<bool>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -135,8 +135,8 @@ auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) {
|
||||||
return Switch(
|
return Switch(
|
||||||
First(cs...)->Type(), //
|
First(cs...)->Type(), //
|
||||||
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
[&](const type::AbstractFloat*) { return f(cs->template As<AFloat>()...); },
|
||||||
[&](const sem::F32*) { return f(cs->template As<f32>()...); },
|
[&](const type::F32*) { return f(cs->template As<f32>()...); },
|
||||||
[&](const sem::F16*) { return f(cs->template As<f16>()...); });
|
[&](const type::F16*) { return f(cs->template As<f16>()...); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper that calls `f` passing in the value of all `cs`.
|
/// Helper that calls `f` passing in the value of all `cs`.
|
||||||
|
@ -148,7 +148,7 @@ auto Dispatch_bool(F&& f, CONSTANTS&&... cs) {
|
||||||
|
|
||||||
/// ZeroTypeDispatch is a helper for calling the function `f`, passing a single zero-value argument
|
/// ZeroTypeDispatch is a helper for calling the function `f`, passing a single zero-value argument
|
||||||
/// of the C++ type that corresponds to the type::Type `type`. For example, calling
|
/// of the C++ type that corresponds to the type::Type `type`. For example, calling
|
||||||
/// `ZeroTypeDispatch()` with a type of `sem::I32*` will call the function f with a single argument
|
/// `ZeroTypeDispatch()` with a type of `type::I32*` will call the function f with a single argument
|
||||||
/// of `i32(0)`.
|
/// of `i32(0)`.
|
||||||
/// @returns the value returned by calling `f`.
|
/// @returns the value returned by calling `f`.
|
||||||
/// @note `type` must be a scalar or abstract numeric type. Other types will not call `f`, and will
|
/// @note `type` must be a scalar or abstract numeric type. Other types will not call `f`, and will
|
||||||
|
@ -159,11 +159,11 @@ auto ZeroTypeDispatch(const type::Type* type, F&& f) {
|
||||||
type, //
|
type, //
|
||||||
[&](const type::AbstractInt*) { return f(AInt(0)); }, //
|
[&](const type::AbstractInt*) { return f(AInt(0)); }, //
|
||||||
[&](const type::AbstractFloat*) { return f(AFloat(0)); }, //
|
[&](const type::AbstractFloat*) { return f(AFloat(0)); }, //
|
||||||
[&](const sem::I32*) { return f(i32(0)); }, //
|
[&](const type::I32*) { return f(i32(0)); }, //
|
||||||
[&](const sem::U32*) { return f(u32(0)); }, //
|
[&](const type::U32*) { return f(u32(0)); }, //
|
||||||
[&](const sem::F32*) { return f(f32(0)); }, //
|
[&](const type::F32*) { return f(f32(0)); }, //
|
||||||
[&](const sem::F16*) { return f(f16(0)); }, //
|
[&](const type::F16*) { return f(f16(0)); }, //
|
||||||
[&](const sem::Bool*) { return f(static_cast<bool>(0)); });
|
[&](const type::Bool*) { return f(static_cast<bool>(0)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns `value` if `T` is not a Number, otherwise ValueOf returns the inner value of the
|
/// @returns `value` if `T` is not a Number, otherwise ValueOf returns the inner value of the
|
||||||
|
@ -1954,7 +1954,7 @@ ConstEval::Result ConstEval::OpShiftLeft(const type::Type* ty,
|
||||||
return Dispatch_ia_iu32(create, c0, c1);
|
return Dispatch_ia_iu32(create, c0, c1);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!type::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
|
if (!type::Type::DeepestElementOf(args[1]->Type())->Is<type::U32>()) {
|
||||||
TINT_ICE(Resolver, builder.Diagnostics())
|
TINT_ICE(Resolver, builder.Diagnostics())
|
||||||
<< "Element type of rhs of ShiftLeft must be a u32";
|
<< "Element type of rhs of ShiftLeft must be a u32";
|
||||||
return utils::Failure;
|
return utils::Failure;
|
||||||
|
@ -2019,7 +2019,7 @@ ConstEval::Result ConstEval::OpShiftRight(const type::Type* ty,
|
||||||
return Dispatch_ia_iu32(create, c0, c1);
|
return Dispatch_ia_iu32(create, c0, c1);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!type::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
|
if (!type::Type::DeepestElementOf(args[1]->Type())->Is<type::U32>()) {
|
||||||
TINT_ICE(Resolver, builder.Diagnostics())
|
TINT_ICE(Resolver, builder.Diagnostics())
|
||||||
<< "Element type of rhs of ShiftLeft must be a u32";
|
<< "Element type of rhs of ShiftLeft must be a u32";
|
||||||
return utils::Failure;
|
return utils::Failure;
|
||||||
|
@ -2647,16 +2647,16 @@ ConstEval::Result ConstEval::frexp(const type::Type* ty,
|
||||||
double fract = std::frexp(s->As<AFloat>(), &exp);
|
double fract = std::frexp(s->As<AFloat>(), &exp);
|
||||||
return Switch(
|
return Switch(
|
||||||
s->Type(),
|
s->Type(),
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
return FractExp{
|
return FractExp{
|
||||||
CreateElement(builder, source, builder.create<sem::F32>(), f32(fract)),
|
CreateElement(builder, source, builder.create<type::F32>(), f32(fract)),
|
||||||
CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)),
|
CreateElement(builder, source, builder.create<type::I32>(), i32(exp)),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
return FractExp{
|
return FractExp{
|
||||||
CreateElement(builder, source, builder.create<sem::F16>(), f16(fract)),
|
CreateElement(builder, source, builder.create<type::F16>(), f16(fract)),
|
||||||
CreateElement(builder, source, builder.create<sem::I32>(), i32(exp)),
|
CreateElement(builder, source, builder.create<type::I32>(), i32(exp)),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ TEST_F(ResolverConstEvalTest, Scalar_i32) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
EXPECT_TRUE(sem->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->Type()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -43,7 +43,7 @@ TEST_F(ResolverConstEvalTest, Scalar_u32) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
EXPECT_TRUE(sem->Type()->Is<sem::U32>());
|
EXPECT_TRUE(sem->Type()->Is<type::U32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(ResolverConstEvalTest, Scalar_f32) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
EXPECT_TRUE(sem->Type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->Type()->Is<type::F32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -77,7 +77,7 @@ TEST_F(ResolverConstEvalTest, Scalar_f16) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
EXPECT_TRUE(sem->Type()->Is<sem::F16>());
|
EXPECT_TRUE(sem->Type()->Is<type::F16>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -94,7 +94,7 @@ TEST_F(ResolverConstEvalTest, Scalar_bool) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
EXPECT_TRUE(sem->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(sem->Type()->Is<type::Bool>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -112,7 +112,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -145,7 +145,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_u32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -178,7 +178,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -213,7 +213,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -246,7 +246,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_bool) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -279,7 +279,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -312,7 +312,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_u32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -345,7 +345,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -380,7 +380,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -414,7 +414,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_bool) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -447,7 +447,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -480,7 +480,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_u32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -513,7 +513,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -548,7 +548,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -581,7 +581,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_bool) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -614,7 +614,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -647,7 +647,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_u32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -680,7 +680,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -713,7 +713,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_10) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -746,7 +746,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_positive_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -779,7 +779,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_negative_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -812,7 +812,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_mixed_sign_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -847,7 +847,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -882,7 +882,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_10) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -917,7 +917,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_positive_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -952,7 +952,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_negative_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -987,7 +987,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_mixed_sign_0) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -1020,7 +1020,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_bool) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -1053,7 +1053,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_all_true) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -1086,7 +1086,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_all_false) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::Bool>());
|
EXPECT_TRUE(vec->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -1119,7 +1119,7 @@ TEST_F(ResolverConstEvalTest, Mat2x3_ZeroInit_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* mat = sem->Type()->As<sem::Matrix>();
|
auto* mat = sem->Type()->As<sem::Matrix>();
|
||||||
ASSERT_NE(mat, nullptr);
|
ASSERT_NE(mat, nullptr);
|
||||||
EXPECT_TRUE(mat->type()->Is<sem::F32>());
|
EXPECT_TRUE(mat->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(mat->columns(), 2u);
|
EXPECT_EQ(mat->columns(), 2u);
|
||||||
EXPECT_EQ(mat->rows(), 3u);
|
EXPECT_EQ(mat->rows(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
@ -1170,7 +1170,7 @@ TEST_F(ResolverConstEvalTest, Mat2x3_ZeroInit_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* mat = sem->Type()->As<sem::Matrix>();
|
auto* mat = sem->Type()->As<sem::Matrix>();
|
||||||
ASSERT_NE(mat, nullptr);
|
ASSERT_NE(mat, nullptr);
|
||||||
EXPECT_TRUE(mat->type()->Is<sem::F16>());
|
EXPECT_TRUE(mat->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(mat->columns(), 2u);
|
EXPECT_EQ(mat->columns(), 2u);
|
||||||
EXPECT_EQ(mat->rows(), 3u);
|
EXPECT_EQ(mat->rows(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
@ -1219,7 +1219,7 @@ TEST_F(ResolverConstEvalTest, Mat3x2_Construct_Scalars_af) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* mat = sem->Type()->As<sem::Matrix>();
|
auto* mat = sem->Type()->As<sem::Matrix>();
|
||||||
ASSERT_NE(mat, nullptr);
|
ASSERT_NE(mat, nullptr);
|
||||||
EXPECT_TRUE(mat->type()->Is<sem::F32>());
|
EXPECT_TRUE(mat->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(mat->columns(), 3u);
|
EXPECT_EQ(mat->columns(), 3u);
|
||||||
EXPECT_EQ(mat->rows(), 2u);
|
EXPECT_EQ(mat->rows(), 2u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
@ -1271,7 +1271,7 @@ TEST_F(ResolverConstEvalTest, Mat3x2_Construct_Columns_af) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* mat = sem->Type()->As<sem::Matrix>();
|
auto* mat = sem->Type()->As<sem::Matrix>();
|
||||||
ASSERT_NE(mat, nullptr);
|
ASSERT_NE(mat, nullptr);
|
||||||
EXPECT_TRUE(mat->type()->Is<sem::F32>());
|
EXPECT_TRUE(mat->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(mat->columns(), 3u);
|
EXPECT_EQ(mat->columns(), 3u);
|
||||||
EXPECT_EQ(mat->rows(), 2u);
|
EXPECT_EQ(mat->rows(), 2u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
@ -1320,7 +1320,7 @@ TEST_F(ResolverConstEvalTest, Array_i32_Zero) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* arr = sem->Type()->As<sem::Array>();
|
auto* arr = sem->Type()->As<sem::Array>();
|
||||||
ASSERT_NE(arr, nullptr);
|
ASSERT_NE(arr, nullptr);
|
||||||
EXPECT_TRUE(arr->ElemType()->Is<sem::I32>());
|
EXPECT_TRUE(arr->ElemType()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -1357,7 +1357,7 @@ TEST_F(ResolverConstEvalTest, Array_f32_Zero) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* arr = sem->Type()->As<sem::Array>();
|
auto* arr = sem->Type()->As<sem::Array>();
|
||||||
ASSERT_NE(arr, nullptr);
|
ASSERT_NE(arr, nullptr);
|
||||||
EXPECT_TRUE(arr->ElemType()->Is<sem::F32>());
|
EXPECT_TRUE(arr->ElemType()->Is<type::F32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -1482,7 +1482,7 @@ TEST_F(ResolverConstEvalTest, Array_i32_Elements) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* arr = sem->Type()->As<sem::Array>();
|
auto* arr = sem->Type()->As<sem::Array>();
|
||||||
ASSERT_NE(arr, nullptr);
|
ASSERT_NE(arr, nullptr);
|
||||||
EXPECT_TRUE(arr->ElemType()->Is<sem::I32>());
|
EXPECT_TRUE(arr->ElemType()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -1519,7 +1519,7 @@ TEST_F(ResolverConstEvalTest, Array_f32_Elements) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* arr = sem->Type()->As<sem::Array>();
|
auto* arr = sem->Type()->As<sem::Array>();
|
||||||
ASSERT_NE(arr, nullptr);
|
ASSERT_NE(arr, nullptr);
|
||||||
EXPECT_TRUE(arr->ElemType()->Is<sem::F32>());
|
EXPECT_TRUE(arr->ElemType()->Is<type::F32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -1635,19 +1635,19 @@ TEST_F(ResolverConstEvalTest, Struct_I32s_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 0_i);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<i32>(), 0_i);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<i32>(), 0_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1680,31 +1680,31 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 0_i);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::U32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<type::U32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<u32>(), 0_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<u32>(), 0_u);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<f32>(), 0._f);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::F16>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<type::F16>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->As<f16>(), 0._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->As<f16>(), 0._h);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->As<bool>(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1734,7 +1734,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(2)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(2)->As<f32>(), 0._f);
|
||||||
|
@ -1743,7 +1743,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<f32>(), 0._f);
|
||||||
|
@ -1752,7 +1752,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 0._f);
|
||||||
|
@ -1788,7 +1788,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<i32>(), 0_i);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<i32>(), 0_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<i32>(), 0_i);
|
||||||
|
|
||||||
|
@ -1796,7 +1796,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<u32>(), 0_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<u32>(), 0_u);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<u32>(), 0_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<u32>(), 0_u);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<u32>(), 0_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<u32>(), 0_u);
|
||||||
|
@ -1805,7 +1805,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 0._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 0._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 0._f);
|
||||||
|
@ -1815,7 +1815,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As<f16>(), 0._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As<f16>(), 0._h);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As<f16>(), 0._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As<f16>(), 0._h);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As<f16>(), 0._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As<f16>(), 0._h);
|
||||||
|
@ -1824,7 +1824,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(
|
||||||
|
sem->ConstantValue()->Index(4)->Type()->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As<bool>(), false);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As<bool>(), false);
|
||||||
}
|
}
|
||||||
|
@ -1902,31 +1903,31 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_Construct) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 1_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->As<i32>(), 1_i);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::U32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<type::U32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<u32>(), 2_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->As<u32>(), 2_u);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<f32>(), 3._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->As<f32>(), 3._f);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::F16>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<type::F16>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->As<f16>(), 4._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->As<f16>(), 4._h);
|
||||||
|
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->As<bool>(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,7 +1962,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<i32>(), 1_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As<i32>(), 1_i);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<i32>(), 1_i);
|
EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As<i32>(), 1_i);
|
||||||
|
|
||||||
|
@ -1969,7 +1970,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<u32>(), 2_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As<u32>(), 2_u);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<u32>(), 2_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As<u32>(), 2_u);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<u32>(), 2_u);
|
EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As<u32>(), 2_u);
|
||||||
|
@ -1978,7 +1979,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 3._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As<f32>(), 3._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 3._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As<f32>(), 3._f);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 3._f);
|
EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As<f32>(), 3._f);
|
||||||
|
@ -1988,7 +1989,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero());
|
EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As<f16>(), 4._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As<f16>(), 4._h);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As<f16>(), 4._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As<f16>(), 4._h);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As<f16>(), 4._h);
|
EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As<f16>(), 4._h);
|
||||||
|
@ -1997,7 +1998,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(
|
||||||
|
sem->ConstantValue()->Index(4)->Type()->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As<bool>(), false);
|
||||||
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As<bool>(), false);
|
EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As<bool>(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_f32_to_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -265,7 +265,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_u32_to_f32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -300,7 +300,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_f16_to_i32) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -335,7 +335,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_u32_to_f16) {
|
||||||
EXPECT_NE(sem, nullptr);
|
EXPECT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -368,7 +368,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Large_f32_to_i32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::I32>());
|
EXPECT_TRUE(vec->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -401,7 +401,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Large_f32_to_u32) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::U32>());
|
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
@ -446,7 +446,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Small_f32_to_f16) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F16>());
|
EXPECT_TRUE(vec->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
EXPECT_FALSE(sem->ConstantValue()->AllEqual());
|
||||||
|
|
|
@ -27,7 +27,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Index) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
ASSERT_TRUE(sem->Type()->Is<sem::I32>());
|
ASSERT_TRUE(sem->Type()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Swizzle_Scalar) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
ASSERT_TRUE(sem->Type()->Is<sem::I32>());
|
ASSERT_TRUE(sem->Type()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -100,7 +100,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Swizzle_Chain) {
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
ASSERT_TRUE(sem->Type()->Is<sem::I32>());
|
ASSERT_TRUE(sem->Type()->Is<type::I32>());
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
@ -165,7 +165,7 @@ TEST_F(ResolverConstEvalTest, Array_vec3_f32_Index) {
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
auto* vec = sem->Type()->As<sem::Vector>();
|
auto* vec = sem->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec, nullptr);
|
ASSERT_NE(vec, nullptr);
|
||||||
EXPECT_TRUE(vec->type()->Is<sem::F32>());
|
EXPECT_TRUE(vec->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(vec->Width(), 3u);
|
EXPECT_EQ(vec->Width(), 3u);
|
||||||
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ TEST_F(ResolverConstEvalTest, ChainedIndex) {
|
||||||
EXPECT_NE(vec, nullptr);
|
EXPECT_NE(vec, nullptr);
|
||||||
auto* ty = vec->Type()->As<sem::Vector>();
|
auto* ty = vec->Type()->As<sem::Vector>();
|
||||||
ASSERT_NE(vec->Type(), nullptr);
|
ASSERT_NE(vec->Type(), nullptr);
|
||||||
EXPECT_TRUE(ty->type()->Is<sem::F32>());
|
EXPECT_TRUE(ty->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(ty->Width(), 3u);
|
EXPECT_EQ(ty->Width(), 3u);
|
||||||
EXPECT_EQ(vec->ConstantValue()->Type(), vec->Type());
|
EXPECT_EQ(vec->ConstantValue()->Type(), vec->Type());
|
||||||
EXPECT_FALSE(vec->ConstantValue()->AllEqual());
|
EXPECT_FALSE(vec->ConstantValue()->AllEqual());
|
||||||
|
@ -302,7 +302,7 @@ TEST_F(ResolverConstEvalTest, ChainedIndex) {
|
||||||
{
|
{
|
||||||
auto* f = Sem().Get(f32_expr);
|
auto* f = Sem().Get(f32_expr);
|
||||||
EXPECT_NE(f, nullptr);
|
EXPECT_NE(f, nullptr);
|
||||||
EXPECT_TRUE(f->Type()->Is<sem::F32>());
|
EXPECT_TRUE(f->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(f->ConstantValue()->Type(), f->Type());
|
EXPECT_EQ(f->ConstantValue()->Type(), f->Type());
|
||||||
EXPECT_TRUE(f->ConstantValue()->AllEqual());
|
EXPECT_TRUE(f->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(f->ConstantValue()->AnyZero());
|
EXPECT_FALSE(f->ConstantValue()->AnyZero());
|
||||||
|
|
|
@ -65,7 +65,7 @@ TEST_F(ResolverConstEvalTest, MemberAccess) {
|
||||||
EXPECT_TRUE(i2->ConstantValue()->AllEqual());
|
EXPECT_TRUE(i2->ConstantValue()->AllEqual());
|
||||||
EXPECT_FALSE(i2->ConstantValue()->AnyZero());
|
EXPECT_FALSE(i2->ConstantValue()->AnyZero());
|
||||||
EXPECT_FALSE(i2->ConstantValue()->AllZero());
|
EXPECT_FALSE(i2->ConstantValue()->AllZero());
|
||||||
EXPECT_TRUE(i2->ConstantValue()->Type()->Is<sem::U32>());
|
EXPECT_TRUE(i2->ConstantValue()->Type()->Is<type::U32>());
|
||||||
EXPECT_EQ(i2->ConstantValue()->As<u32>(), 2_u);
|
EXPECT_EQ(i2->ConstantValue()->As<u32>(), 2_u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@ inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar
|
||||||
c->Type(), //
|
c->Type(), //
|
||||||
[&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
[&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
||||||
[&](const type::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
|
[&](const type::AbstractFloat*) { scalars.Push(c->As<AFloat>()); },
|
||||||
[&](const sem::Bool*) { scalars.Push(c->As<bool>()); },
|
[&](const type::Bool*) { scalars.Push(c->As<bool>()); },
|
||||||
[&](const sem::I32*) { scalars.Push(c->As<i32>()); },
|
[&](const type::I32*) { scalars.Push(c->As<i32>()); },
|
||||||
[&](const sem::U32*) { scalars.Push(c->As<u32>()); },
|
[&](const type::U32*) { scalars.Push(c->As<u32>()); },
|
||||||
[&](const sem::F32*) { scalars.Push(c->As<f32>()); },
|
[&](const type::F32*) { scalars.Push(c->As<f32>()); },
|
||||||
[&](const sem::F16*) { scalars.Push(c->As<f16>()); },
|
[&](const type::F16*) { scalars.Push(c->As<f16>()); },
|
||||||
[&](Default) {
|
[&](Default) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (auto* child = c->Index(i++)) {
|
while (auto* child = c->Index(i++)) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverInferredTypeParamTest, testing::V
|
||||||
TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
|
TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
|
||||||
auto* type = ty.array(ty.u32(), 10_u);
|
auto* type = ty.array(ty.u32(), 10_u);
|
||||||
auto* expected_type = create<sem::Array>(
|
auto* expected_type = create<sem::Array>(
|
||||||
create<sem::U32>(), create<type::ConstantArrayCount>(10u), 4u, 4u * 10u, 4u, 4u);
|
create<type::U32>(), create<type::ConstantArrayCount>(10u), 4u, 4u * 10u, 4u, 4u);
|
||||||
|
|
||||||
auto* ctor_expr = Construct(type);
|
auto* ctor_expr = Construct(type);
|
||||||
auto* var = Var("a", ast::AddressSpace::kFunction, ctor_expr);
|
auto* var = Var("a", ast::AddressSpace::kFunction, ctor_expr);
|
||||||
|
@ -153,7 +153,7 @@ TEST_F(ResolverInferredTypeTest, InferStruct_Pass) {
|
||||||
auto* expected_type = create<sem::Struct>(
|
auto* expected_type = create<sem::Struct>(
|
||||||
str, str->source, str->name,
|
str, str->source, str->name,
|
||||||
utils::Vector{create<sem::StructMember>(member, member->source, member->symbol,
|
utils::Vector{create<sem::StructMember>(member, member->source, member->symbol,
|
||||||
create<sem::I32>(), 0u, 0u, 0u, 4u, std::nullopt)},
|
create<type::I32>(), 0u, 0u, 0u, 4u, std::nullopt)},
|
||||||
0u, 4u, 4u);
|
0u, 4u, 4u);
|
||||||
|
|
||||||
auto* ctor_expr = Construct(ty.Of(str));
|
auto* ctor_expr = Construct(ty.Of(str));
|
||||||
|
|
|
@ -349,7 +349,7 @@ enum class OverloadFlag {
|
||||||
using OverloadFlags = utils::EnumSet<OverloadFlag>;
|
using OverloadFlags = utils::EnumSet<OverloadFlag>;
|
||||||
|
|
||||||
bool match_bool(MatchState&, const type::Type* ty) {
|
bool match_bool(MatchState&, const type::Type* ty) {
|
||||||
return ty->IsAnyOf<Any, sem::Bool>();
|
return ty->IsAnyOf<Any, type::Bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const type::AbstractFloat* build_fa(MatchState& state) {
|
const type::AbstractFloat* build_fa(MatchState& state) {
|
||||||
|
@ -370,40 +370,40 @@ bool match_ia(MatchState& state, const type::Type* ty) {
|
||||||
ty->IsAnyOf<Any, type::AbstractInt>();
|
ty->IsAnyOf<Any, type::AbstractInt>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::Bool* build_bool(MatchState& state) {
|
const type::Bool* build_bool(MatchState& state) {
|
||||||
return state.builder.create<sem::Bool>();
|
return state.builder.create<type::Bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::F16* build_f16(MatchState& state) {
|
const type::F16* build_f16(MatchState& state) {
|
||||||
return state.builder.create<sem::F16>();
|
return state.builder.create<type::F16>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_f16(MatchState&, const type::Type* ty) {
|
bool match_f16(MatchState&, const type::Type* ty) {
|
||||||
return ty->IsAnyOf<Any, sem::F16, type::AbstractNumeric>();
|
return ty->IsAnyOf<Any, type::F16, type::AbstractNumeric>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::F32* build_f32(MatchState& state) {
|
const type::F32* build_f32(MatchState& state) {
|
||||||
return state.builder.create<sem::F32>();
|
return state.builder.create<type::F32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_f32(MatchState&, const type::Type* ty) {
|
bool match_f32(MatchState&, const type::Type* ty) {
|
||||||
return ty->IsAnyOf<Any, sem::F32, type::AbstractNumeric>();
|
return ty->IsAnyOf<Any, type::F32, type::AbstractNumeric>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::I32* build_i32(MatchState& state) {
|
const type::I32* build_i32(MatchState& state) {
|
||||||
return state.builder.create<sem::I32>();
|
return state.builder.create<type::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_i32(MatchState&, const type::Type* ty) {
|
bool match_i32(MatchState&, const type::Type* ty) {
|
||||||
return ty->IsAnyOf<Any, sem::I32, type::AbstractInt>();
|
return ty->IsAnyOf<Any, type::I32, type::AbstractInt>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::U32* build_u32(MatchState& state) {
|
const type::U32* build_u32(MatchState& state) {
|
||||||
return state.builder.create<sem::U32>();
|
return state.builder.create<type::U32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_u32(MatchState&, const type::Type* ty) {
|
bool match_u32(MatchState&, const type::Type* ty) {
|
||||||
return ty->IsAnyOf<Any, sem::U32, type::AbstractInt>();
|
return ty->IsAnyOf<Any, type::U32, type::AbstractInt>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
|
bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
|
||||||
|
@ -834,18 +834,18 @@ sem::Struct* build_struct(ProgramBuilder& b,
|
||||||
|
|
||||||
const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) {
|
const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) {
|
||||||
auto build_f32 = [&] {
|
auto build_f32 = [&] {
|
||||||
auto* ty = state.builder.create<sem::F32>();
|
auto* ty = state.builder.create<type::F32>();
|
||||||
return build_struct(state.builder, "__modf_result_f32", {{"fract", ty}, {"whole", ty}});
|
return build_struct(state.builder, "__modf_result_f32", {{"fract", ty}, {"whole", ty}});
|
||||||
};
|
};
|
||||||
auto build_f16 = [&] {
|
auto build_f16 = [&] {
|
||||||
auto* ty = state.builder.create<sem::F16>();
|
auto* ty = state.builder.create<type::F16>();
|
||||||
return build_struct(state.builder, "__modf_result_f16", {{"fract", ty}, {"whole", ty}});
|
return build_struct(state.builder, "__modf_result_f16", {{"fract", ty}, {"whole", ty}});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Switch(
|
return Switch(
|
||||||
el, //
|
el, //
|
||||||
[&](const sem::F32*) { return build_f32(); }, //
|
[&](const type::F32*) { return build_f32(); }, //
|
||||||
[&](const sem::F16*) { return build_f16(); }, //
|
[&](const type::F16*) { return build_f16(); }, //
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
auto* abstract = build_struct(state.builder, "__modf_result_abstract",
|
auto* abstract = build_struct(state.builder, "__modf_result_abstract",
|
||||||
{{"fract", el}, {"whole", el}});
|
{{"fract", el}, {"whole", el}});
|
||||||
|
@ -862,18 +862,18 @@ const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) {
|
||||||
const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const type::Type* el) {
|
const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const type::Type* el) {
|
||||||
auto prefix = "__modf_result_vec" + std::to_string(n.Value());
|
auto prefix = "__modf_result_vec" + std::to_string(n.Value());
|
||||||
auto build_f32 = [&] {
|
auto build_f32 = [&] {
|
||||||
auto* vec = state.builder.create<sem::Vector>(state.builder.create<sem::F32>(), n.Value());
|
auto* vec = state.builder.create<sem::Vector>(state.builder.create<type::F32>(), n.Value());
|
||||||
return build_struct(state.builder, prefix + "_f32", {{"fract", vec}, {"whole", vec}});
|
return build_struct(state.builder, prefix + "_f32", {{"fract", vec}, {"whole", vec}});
|
||||||
};
|
};
|
||||||
auto build_f16 = [&] {
|
auto build_f16 = [&] {
|
||||||
auto* vec = state.builder.create<sem::Vector>(state.builder.create<sem::F16>(), n.Value());
|
auto* vec = state.builder.create<sem::Vector>(state.builder.create<type::F16>(), n.Value());
|
||||||
return build_struct(state.builder, prefix + "_f16", {{"fract", vec}, {"whole", vec}});
|
return build_struct(state.builder, prefix + "_f16", {{"fract", vec}, {"whole", vec}});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Switch(
|
return Switch(
|
||||||
el, //
|
el, //
|
||||||
[&](const sem::F32*) { return build_f32(); }, //
|
[&](const type::F32*) { return build_f32(); }, //
|
||||||
[&](const sem::F16*) { return build_f16(); }, //
|
[&](const type::F16*) { return build_f16(); }, //
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
auto* vec = state.builder.create<sem::Vector>(el, n.Value());
|
auto* vec = state.builder.create<sem::Vector>(el, n.Value());
|
||||||
auto* abstract =
|
auto* abstract =
|
||||||
|
@ -890,20 +890,20 @@ const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const typ
|
||||||
|
|
||||||
const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) {
|
const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) {
|
||||||
auto build_f32 = [&] {
|
auto build_f32 = [&] {
|
||||||
auto* f = state.builder.create<sem::F32>();
|
auto* f = state.builder.create<type::F32>();
|
||||||
auto* i = state.builder.create<sem::I32>();
|
auto* i = state.builder.create<type::I32>();
|
||||||
return build_struct(state.builder, "__frexp_result_f32", {{"fract", f}, {"exp", i}});
|
return build_struct(state.builder, "__frexp_result_f32", {{"fract", f}, {"exp", i}});
|
||||||
};
|
};
|
||||||
auto build_f16 = [&] {
|
auto build_f16 = [&] {
|
||||||
auto* f = state.builder.create<sem::F16>();
|
auto* f = state.builder.create<type::F16>();
|
||||||
auto* i = state.builder.create<sem::I32>();
|
auto* i = state.builder.create<type::I32>();
|
||||||
return build_struct(state.builder, "__frexp_result_f16", {{"fract", f}, {"exp", i}});
|
return build_struct(state.builder, "__frexp_result_f16", {{"fract", f}, {"exp", i}});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Switch(
|
return Switch(
|
||||||
el, //
|
el, //
|
||||||
[&](const sem::F32*) { return build_f32(); }, //
|
[&](const type::F32*) { return build_f32(); }, //
|
||||||
[&](const sem::F16*) { return build_f16(); }, //
|
[&](const type::F16*) { return build_f16(); }, //
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
auto* i = state.builder.create<type::AbstractInt>();
|
auto* i = state.builder.create<type::AbstractInt>();
|
||||||
auto* abstract =
|
auto* abstract =
|
||||||
|
@ -921,20 +921,20 @@ const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) {
|
||||||
const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const type::Type* el) {
|
const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const type::Type* el) {
|
||||||
auto prefix = "__frexp_result_vec" + std::to_string(n.Value());
|
auto prefix = "__frexp_result_vec" + std::to_string(n.Value());
|
||||||
auto build_f32 = [&] {
|
auto build_f32 = [&] {
|
||||||
auto* f = state.builder.create<sem::Vector>(state.builder.create<sem::F32>(), n.Value());
|
auto* f = state.builder.create<sem::Vector>(state.builder.create<type::F32>(), n.Value());
|
||||||
auto* e = state.builder.create<sem::Vector>(state.builder.create<sem::I32>(), n.Value());
|
auto* e = state.builder.create<sem::Vector>(state.builder.create<type::I32>(), n.Value());
|
||||||
return build_struct(state.builder, prefix + "_f32", {{"fract", f}, {"exp", e}});
|
return build_struct(state.builder, prefix + "_f32", {{"fract", f}, {"exp", e}});
|
||||||
};
|
};
|
||||||
auto build_f16 = [&] {
|
auto build_f16 = [&] {
|
||||||
auto* f = state.builder.create<sem::Vector>(state.builder.create<sem::F16>(), n.Value());
|
auto* f = state.builder.create<sem::Vector>(state.builder.create<type::F16>(), n.Value());
|
||||||
auto* e = state.builder.create<sem::Vector>(state.builder.create<sem::I32>(), n.Value());
|
auto* e = state.builder.create<sem::Vector>(state.builder.create<type::I32>(), n.Value());
|
||||||
return build_struct(state.builder, prefix + "_f16", {{"fract", f}, {"exp", e}});
|
return build_struct(state.builder, prefix + "_f16", {{"fract", f}, {"exp", e}});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Switch(
|
return Switch(
|
||||||
el, //
|
el, //
|
||||||
[&](const sem::F32*) { return build_f32(); }, //
|
[&](const type::F32*) { return build_f32(); }, //
|
||||||
[&](const sem::F16*) { return build_f16(); }, //
|
[&](const type::F16*) { return build_f16(); }, //
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
auto* f = state.builder.create<sem::Vector>(el, n.Value());
|
auto* f = state.builder.create<sem::Vector>(el, n.Value());
|
||||||
auto* e = state.builder.create<sem::Vector>(state.builder.create<type::AbstractInt>(),
|
auto* e = state.builder.create<sem::Vector>(state.builder.create<type::AbstractInt>(),
|
||||||
|
@ -956,7 +956,7 @@ const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const
|
||||||
state.builder,
|
state.builder,
|
||||||
"__atomic_compare_exchange_result" + ty->FriendlyName(state.builder.Symbols()),
|
"__atomic_compare_exchange_result" + ty->FriendlyName(state.builder.Symbols()),
|
||||||
{{"old_value", const_cast<type::Type*>(ty)},
|
{{"old_value", const_cast<type::Type*>(ty)},
|
||||||
{"exchanged", state.builder.create<sem::Bool>()}});
|
{"exchanged", state.builder.create<type::Bool>()}});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParameterInfo describes a parameter
|
/// ParameterInfo describes a parameter
|
||||||
|
@ -1549,7 +1549,7 @@ IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return_type = builder.create<sem::Void>();
|
return_type = builder.create<type::Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return IntrinsicPrototype{match.overload, return_type, std::move(match.parameters)};
|
return IntrinsicPrototype{match.overload, return_type, std::move(match.parameters)};
|
||||||
|
|
|
@ -52,7 +52,7 @@ class IntrinsicTableTest : public testing::Test, public ProgramBuilder {
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchF32) {
|
TEST_F(IntrinsicTableTest, MatchF32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kCos, utils::Vector{f32},
|
auto result = table->Lookup(BuiltinType::kCos, utils::Vector{f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -64,7 +64,7 @@ TEST_F(IntrinsicTableTest, MatchF32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchF32) {
|
TEST_F(IntrinsicTableTest, MismatchF32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto result = table->Lookup(BuiltinType::kCos, utils::Vector{i32},
|
auto result = table->Lookup(BuiltinType::kCos, utils::Vector{i32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -72,8 +72,8 @@ TEST_F(IntrinsicTableTest, MismatchF32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchU32) {
|
TEST_F(IntrinsicTableTest, MatchU32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{u32},
|
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{u32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -86,7 +86,7 @@ TEST_F(IntrinsicTableTest, MatchU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchU32) {
|
TEST_F(IntrinsicTableTest, MismatchU32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{f32},
|
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -94,8 +94,8 @@ TEST_F(IntrinsicTableTest, MismatchU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchI32) {
|
TEST_F(IntrinsicTableTest, MatchI32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32},
|
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32},
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchI32) {
|
TEST_F(IntrinsicTableTest, MismatchI32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32},
|
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -123,7 +123,7 @@ TEST_F(IntrinsicTableTest, MismatchI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchIU32AsI32) {
|
TEST_F(IntrinsicTableTest, MatchIU32AsI32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{i32},
|
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{i32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -135,7 +135,7 @@ TEST_F(IntrinsicTableTest, MatchIU32AsI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchIU32AsU32) {
|
TEST_F(IntrinsicTableTest, MatchIU32AsU32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{u32},
|
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{u32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -147,7 +147,7 @@ TEST_F(IntrinsicTableTest, MatchIU32AsU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchIU32) {
|
TEST_F(IntrinsicTableTest, MismatchIU32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{f32},
|
auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -155,7 +155,7 @@ TEST_F(IntrinsicTableTest, MismatchIU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchFIU32AsI32) {
|
TEST_F(IntrinsicTableTest, MatchFIU32AsI32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{i32, i32, i32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{i32, i32, i32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -169,7 +169,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchFIU32AsU32) {
|
TEST_F(IntrinsicTableTest, MatchFIU32AsU32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{u32, u32, u32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{u32, u32, u32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -183,7 +183,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchFIU32AsF32) {
|
TEST_F(IntrinsicTableTest, MatchFIU32AsF32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -197,7 +197,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsF32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchFIU32) {
|
TEST_F(IntrinsicTableTest, MismatchFIU32) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{bool_, bool_, bool_},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{bool_, bool_, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -205,8 +205,8 @@ TEST_F(IntrinsicTableTest, MismatchFIU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchBool) {
|
TEST_F(IntrinsicTableTest, MatchBool) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_},
|
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -220,7 +220,7 @@ TEST_F(IntrinsicTableTest, MatchBool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchBool) {
|
TEST_F(IntrinsicTableTest, MismatchBool) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, f32},
|
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -228,7 +228,7 @@ TEST_F(IntrinsicTableTest, MismatchBool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchPointer) {
|
TEST_F(IntrinsicTableTest, MatchPointer) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* atomicI32 = create<sem::Atomic>(i32);
|
auto* atomicI32 = create<sem::Atomic>(i32);
|
||||||
auto* ptr =
|
auto* ptr =
|
||||||
create<sem::Pointer>(atomicI32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
|
create<sem::Pointer>(atomicI32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
|
||||||
|
@ -243,7 +243,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchPointer) {
|
TEST_F(IntrinsicTableTest, MismatchPointer) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* atomicI32 = create<sem::Atomic>(i32);
|
auto* atomicI32 = create<sem::Atomic>(i32);
|
||||||
auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{atomicI32},
|
auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{atomicI32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -253,14 +253,14 @@ TEST_F(IntrinsicTableTest, MismatchPointer) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchArray) {
|
TEST_F(IntrinsicTableTest, MatchArray) {
|
||||||
auto* arr =
|
auto* arr =
|
||||||
create<sem::Array>(create<sem::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
create<sem::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
||||||
auto* arr_ptr = create<sem::Pointer>(arr, ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* arr_ptr = create<sem::Pointer>(arr, ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr},
|
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
ASSERT_EQ(Diagnostics().str(), "");
|
ASSERT_EQ(Diagnostics().str(), "");
|
||||||
EXPECT_EQ(result.sem->Type(), BuiltinType::kArrayLength);
|
EXPECT_EQ(result.sem->Type(), BuiltinType::kArrayLength);
|
||||||
EXPECT_TRUE(result.sem->ReturnType()->Is<sem::U32>());
|
EXPECT_TRUE(result.sem->ReturnType()->Is<type::U32>());
|
||||||
ASSERT_EQ(result.sem->Parameters().Length(), 1u);
|
ASSERT_EQ(result.sem->Parameters().Length(), 1u);
|
||||||
auto* param_type = result.sem->Parameters()[0]->Type();
|
auto* param_type = result.sem->Parameters()[0]->Type();
|
||||||
ASSERT_TRUE(param_type->Is<sem::Pointer>());
|
ASSERT_TRUE(param_type->Is<sem::Pointer>());
|
||||||
|
@ -268,7 +268,7 @@ TEST_F(IntrinsicTableTest, MatchArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchArray) {
|
TEST_F(IntrinsicTableTest, MismatchArray) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{f32},
|
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -276,7 +276,7 @@ TEST_F(IntrinsicTableTest, MismatchArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchSampler) {
|
TEST_F(IntrinsicTableTest, MatchSampler) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
@ -297,7 +297,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchSampler) {
|
TEST_F(IntrinsicTableTest, MismatchSampler) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32},
|
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32},
|
||||||
|
@ -307,8 +307,8 @@ TEST_F(IntrinsicTableTest, MismatchSampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
@ -328,8 +328,8 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* tex = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* tex = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
@ -349,8 +349,8 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||||
|
@ -369,8 +369,8 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) {
|
TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* tex = create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
auto* tex = create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||||
|
@ -389,8 +389,8 @@ TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchExternalTexture) {
|
TEST_F(IntrinsicTableTest, MatchExternalTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* tex = create<type::ExternalTexture>();
|
auto* tex = create<type::ExternalTexture>();
|
||||||
|
@ -408,8 +408,8 @@ TEST_F(IntrinsicTableTest, MatchExternalTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||||
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
|
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
|
||||||
|
@ -421,7 +421,7 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
ASSERT_EQ(Diagnostics().str(), "");
|
ASSERT_EQ(Diagnostics().str(), "");
|
||||||
EXPECT_EQ(result.sem->Type(), BuiltinType::kTextureStore);
|
EXPECT_EQ(result.sem->Type(), BuiltinType::kTextureStore);
|
||||||
EXPECT_TRUE(result.sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(result.sem->ReturnType()->Is<type::Void>());
|
||||||
ASSERT_EQ(result.sem->Parameters().Length(), 3u);
|
ASSERT_EQ(result.sem->Parameters().Length(), 3u);
|
||||||
EXPECT_EQ(result.sem->Parameters()[0]->Type(), tex);
|
EXPECT_EQ(result.sem->Parameters()[0]->Type(), tex);
|
||||||
EXPECT_EQ(result.sem->Parameters()[0]->Usage(), ParameterUsage::kTexture);
|
EXPECT_EQ(result.sem->Parameters()[0]->Usage(), ParameterUsage::kTexture);
|
||||||
|
@ -432,8 +432,8 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchTexture) {
|
TEST_F(IntrinsicTableTest, MismatchTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
auto* vec2_i32 = create<sem::Vector>(i32, 2u);
|
||||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{f32, vec2_i32},
|
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{f32, vec2_i32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -442,7 +442,7 @@ TEST_F(IntrinsicTableTest, MismatchTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) {
|
TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(
|
auto result = table->Lookup(
|
||||||
BuiltinType::kCos,
|
BuiltinType::kCos,
|
||||||
utils::Vector{
|
utils::Vector{
|
||||||
|
@ -458,7 +458,7 @@ TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchTemplateType) {
|
TEST_F(IntrinsicTableTest, MatchTemplateType) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -471,8 +471,8 @@ TEST_F(IntrinsicTableTest, MatchTemplateType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchTemplateType) {
|
TEST_F(IntrinsicTableTest, MismatchTemplateType) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, u32, f32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, u32, f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(result.sem, nullptr);
|
ASSERT_EQ(result.sem, nullptr);
|
||||||
|
@ -480,7 +480,7 @@ TEST_F(IntrinsicTableTest, MismatchTemplateType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchOpenSizeVector) {
|
TEST_F(IntrinsicTableTest, MatchOpenSizeVector) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, vec2_f32, vec2_f32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, vec2_f32, vec2_f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -495,8 +495,8 @@ TEST_F(IntrinsicTableTest, MatchOpenSizeVector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) {
|
TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, u32, vec2_f32},
|
auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, u32, vec2_f32},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
|
@ -505,7 +505,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchOpenSizeMatrix) {
|
TEST_F(IntrinsicTableTest, MatchOpenSizeMatrix) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||||
auto* mat3_f32 = create<sem::Matrix>(vec3_f32, 3u);
|
auto* mat3_f32 = create<sem::Matrix>(vec3_f32, 3u);
|
||||||
auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3_f32},
|
auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3_f32},
|
||||||
|
@ -519,7 +519,7 @@ TEST_F(IntrinsicTableTest, MatchOpenSizeMatrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) {
|
TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
auto* mat3x2_f32 = create<sem::Matrix>(vec2_f32, 3u);
|
auto* mat3x2_f32 = create<sem::Matrix>(vec2_f32, 3u);
|
||||||
auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3x2_f32},
|
auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3x2_f32},
|
||||||
|
@ -530,7 +530,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
|
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
|
||||||
auto* af = create<type::AbstractFloat>();
|
auto* af = create<type::AbstractFloat>();
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_},
|
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -546,7 +546,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
|
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
|
||||||
auto* af = create<type::AbstractFloat>();
|
auto* af = create<type::AbstractFloat>();
|
||||||
auto* bool_ref = create<sem::Reference>(create<sem::Bool>(), ast::AddressSpace::kFunction,
|
auto* bool_ref = create<sem::Reference>(create<type::Bool>(), ast::AddressSpace::kFunction,
|
||||||
ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
|
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
|
||||||
sem::EvaluationStage::kRuntime, Source{});
|
sem::EvaluationStage::kRuntime, Source{});
|
||||||
|
@ -554,16 +554,16 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
|
||||||
ASSERT_EQ(Diagnostics().str(), "");
|
ASSERT_EQ(Diagnostics().str(), "");
|
||||||
EXPECT_EQ(result.sem->Stage(), sem::EvaluationStage::kConstant);
|
EXPECT_EQ(result.sem->Stage(), sem::EvaluationStage::kConstant);
|
||||||
EXPECT_EQ(result.sem->Type(), BuiltinType::kSelect);
|
EXPECT_EQ(result.sem->Type(), BuiltinType::kSelect);
|
||||||
EXPECT_TRUE(result.sem->ReturnType()->Is<sem::F32>());
|
EXPECT_TRUE(result.sem->ReturnType()->Is<type::F32>());
|
||||||
ASSERT_EQ(result.sem->Parameters().Length(), 3u);
|
ASSERT_EQ(result.sem->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(result.sem->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(result.sem->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(result.sem->Parameters()[1]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(result.sem->Parameters()[1]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(result.sem->Parameters()[2]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(result.sem->Parameters()[2]->Type()->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
|
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant,
|
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant,
|
||||||
Source{}, false);
|
Source{}, false);
|
||||||
ASSERT_NE(result.result, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.result, nullptr) << Diagnostics().str();
|
||||||
|
@ -576,21 +576,21 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
|
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime,
|
auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime,
|
||||||
Source{}, false);
|
Source{}, false);
|
||||||
ASSERT_NE(result.result, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.result, nullptr) << Diagnostics().str();
|
||||||
ASSERT_NE(result.const_eval_fn, nullptr) << Diagnostics().str();
|
ASSERT_NE(result.const_eval_fn, nullptr) << Diagnostics().str();
|
||||||
ASSERT_EQ(Diagnostics().str(), "");
|
ASSERT_EQ(Diagnostics().str(), "");
|
||||||
EXPECT_TRUE(result.result->Is<sem::I32>());
|
EXPECT_TRUE(result.result->Is<type::I32>());
|
||||||
EXPECT_TRUE(result.lhs->Is<sem::I32>());
|
EXPECT_TRUE(result.lhs->Is<type::I32>());
|
||||||
EXPECT_TRUE(result.rhs->Is<sem::U32>());
|
EXPECT_TRUE(result.rhs->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
|
TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
|
||||||
// None of the arguments match, so expect the overloads with 2 parameters to
|
// None of the arguments match, so expect the overloads with 2 parameters to
|
||||||
// come first
|
// come first
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{bool_, bool_},
|
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{bool_, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(Diagnostics().str(),
|
ASSERT_EQ(Diagnostics().str(),
|
||||||
|
@ -629,7 +629,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
|
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
|
||||||
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_},
|
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_EQ(Diagnostics().str(),
|
ASSERT_EQ(Diagnostics().str(),
|
||||||
|
@ -667,9 +667,9 @@ TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, SameOverloadReturnsSameBuiltinPointer) {
|
TEST_F(IntrinsicTableTest, SameOverloadReturnsSameBuiltinPointer) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec2_f32 = create<sem::Vector>(create<sem::F32>(), 2u);
|
auto* vec2_f32 = create<sem::Vector>(create<type::F32>(), 2u);
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto a = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_},
|
auto a = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(a.sem, nullptr) << Diagnostics().str();
|
ASSERT_NE(a.sem, nullptr) << Diagnostics().str();
|
||||||
|
@ -690,7 +690,7 @@ TEST_F(IntrinsicTableTest, SameOverloadReturnsSameBuiltinPointer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchUnaryOp) {
|
TEST_F(IntrinsicTableTest, MatchUnaryOp) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto result = table->Lookup(ast::UnaryOp::kNegation, vec3_i32, sem::EvaluationStage::kConstant,
|
auto result = table->Lookup(ast::UnaryOp::kNegation, vec3_i32, sem::EvaluationStage::kConstant,
|
||||||
Source{{12, 34}});
|
Source{{12, 34}});
|
||||||
|
@ -699,7 +699,7 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchUnaryOp) {
|
TEST_F(IntrinsicTableTest, MismatchUnaryOp) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(ast::UnaryOp::kNegation, bool_, sem::EvaluationStage::kConstant,
|
auto result = table->Lookup(ast::UnaryOp::kNegation, bool_, sem::EvaluationStage::kConstant,
|
||||||
Source{{12, 34}});
|
Source{{12, 34}});
|
||||||
ASSERT_EQ(result.result, nullptr);
|
ASSERT_EQ(result.result, nullptr);
|
||||||
|
@ -724,12 +724,12 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) {
|
||||||
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime,
|
auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime,
|
||||||
Source{{12, 34}});
|
Source{{12, 34}});
|
||||||
EXPECT_NE(result.result, ai);
|
EXPECT_NE(result.result, ai);
|
||||||
EXPECT_TRUE(result.result->Is<sem::I32>());
|
EXPECT_TRUE(result.result->Is<type::I32>());
|
||||||
EXPECT_EQ(Diagnostics().str(), "");
|
EXPECT_EQ(Diagnostics().str(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchBinaryOp) {
|
TEST_F(IntrinsicTableTest, MatchBinaryOp) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32,
|
auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32,
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
||||||
|
@ -741,8 +741,8 @@ TEST_F(IntrinsicTableTest, MatchBinaryOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchBinaryOp) {
|
TEST_F(IntrinsicTableTest, MismatchBinaryOp) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_,
|
auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_,
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
||||||
/* is_compound */ false);
|
/* is_compound */ false);
|
||||||
|
@ -763,7 +763,7 @@ TEST_F(IntrinsicTableTest, MismatchBinaryOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchCompoundOp) {
|
TEST_F(IntrinsicTableTest, MatchCompoundOp) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32,
|
auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32,
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
||||||
|
@ -775,8 +775,8 @@ TEST_F(IntrinsicTableTest, MatchCompoundOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchCompoundOp) {
|
TEST_F(IntrinsicTableTest, MismatchCompoundOp) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_,
|
auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_,
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
sem::EvaluationStage::kConstant, Source{{12, 34}},
|
||||||
/* is_compound */ true);
|
/* is_compound */ true);
|
||||||
|
@ -797,7 +797,7 @@ TEST_F(IntrinsicTableTest, MismatchCompoundOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) {
|
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
|
@ -812,7 +812,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) {
|
TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
|
@ -827,8 +827,8 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
|
TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
ASSERT_EQ(result.target, nullptr);
|
ASSERT_EQ(result.target, nullptr);
|
||||||
|
@ -853,8 +853,8 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
|
TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
ASSERT_EQ(result.target, nullptr);
|
ASSERT_EQ(result.target, nullptr);
|
||||||
|
@ -928,7 +928,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) {
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai},
|
||||||
sem::EvaluationStage::kRuntime, Source{{12, 34}});
|
sem::EvaluationStage::kRuntime, Source{{12, 34}});
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
ASSERT_NE(result.target, nullptr);
|
ASSERT_NE(result.target, nullptr);
|
||||||
EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant);
|
EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant);
|
||||||
|
@ -942,9 +942,9 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MatchTypeConversion) {
|
TEST_F(IntrinsicTableTest, MatchTypeConversion) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
|
@ -957,8 +957,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion) {
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
|
TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
|
||||||
auto* arr =
|
auto* arr =
|
||||||
create<sem::Array>(create<sem::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
create<sem::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
ASSERT_EQ(result.target, nullptr);
|
ASSERT_EQ(result.target, nullptr);
|
||||||
|
@ -986,7 +986,7 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) {
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto* af = create<type::AbstractFloat>();
|
auto* af = create<type::AbstractFloat>();
|
||||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai},
|
||||||
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
sem::EvaluationStage::kConstant, Source{{12, 34}});
|
||||||
|
@ -1003,8 +1003,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto* af = create<type::AbstractFloat>();
|
auto* af = create<type::AbstractFloat>();
|
||||||
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
auto* vec3_ai = create<sem::Vector>(ai, 3u);
|
||||||
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
|
auto* vec3_f32 = create<sem::Vector>(create<type::F32>(), 3u);
|
||||||
auto* vec3_i32 = create<sem::Vector>(create<sem::I32>(), 3u);
|
auto* vec3_i32 = create<sem::Vector>(create<type::I32>(), 3u);
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai},
|
auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai},
|
||||||
sem::EvaluationStage::kRuntime, Source{{12, 34}});
|
sem::EvaluationStage::kRuntime, Source{{12, 34}});
|
||||||
ASSERT_NE(result.target, nullptr);
|
ASSERT_NE(result.target, nullptr);
|
||||||
|
@ -1016,7 +1016,7 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IntrinsicTableTest, Err257Arguments) { // crbug.com/1323605
|
TEST_F(IntrinsicTableTest, Err257Arguments) { // crbug.com/1323605
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
utils::Vector<const type::Type*, 0> arg_tys;
|
utils::Vector<const type::Type*, 0> arg_tys;
|
||||||
arg_tys.Resize(257, f32);
|
arg_tys.Resize(257, f32);
|
||||||
auto result = table->Lookup(BuiltinType::kAbs, std::move(arg_tys),
|
auto result = table->Lookup(BuiltinType::kAbs, std::move(arg_tys),
|
||||||
|
@ -1031,7 +1031,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) {
|
||||||
// conv i32<T: scalar_no_i32>(T) -> i32
|
// conv i32<T: scalar_no_i32>(T) -> i32
|
||||||
// The first should win overload resolution.
|
// The first should win overload resolution.
|
||||||
auto* ai = create<type::AbstractInt>();
|
auto* ai = create<type::AbstractInt>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai},
|
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai},
|
||||||
sem::EvaluationStage::kConstant, Source{});
|
sem::EvaluationStage::kConstant, Source{});
|
||||||
ASSERT_NE(result.target, nullptr);
|
ASSERT_NE(result.target, nullptr);
|
||||||
|
|
|
@ -24,54 +24,54 @@ namespace {
|
||||||
using ResolverIsHostShareable = ResolverTest;
|
using ResolverIsHostShareable = ResolverTest;
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, Void) {
|
TEST_F(ResolverIsHostShareable, Void) {
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Void>()));
|
EXPECT_FALSE(r()->IsHostShareable(create<type::Void>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, Bool) {
|
TEST_F(ResolverIsHostShareable, Bool) {
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Bool>()));
|
EXPECT_FALSE(r()->IsHostShareable(create<type::Bool>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, NumericScalar) {
|
TEST_F(ResolverIsHostShareable, NumericScalar) {
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::I32>()));
|
EXPECT_TRUE(r()->IsHostShareable(create<type::I32>()));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::U32>()));
|
EXPECT_TRUE(r()->IsHostShareable(create<type::U32>()));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::F32>()));
|
EXPECT_TRUE(r()->IsHostShareable(create<type::F32>()));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::F16>()));
|
EXPECT_TRUE(r()->IsHostShareable(create<type::F16>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, NumericVector) {
|
TEST_F(ResolverIsHostShareable, NumericVector) {
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::I32>(), 2u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::I32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::I32>(), 3u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::I32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::I32>(), 4u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::I32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::U32>(), 2u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::U32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::U32>(), 3u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::U32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::U32>(), 4u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::U32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F32>(), 2u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F32>(), 3u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F32>(), 4u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F16>(), 2u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F16>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F16>(), 3u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F16>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<sem::F16>(), 4u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Vector>(create<type::F16>(), 4u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, BoolVector) {
|
TEST_F(ResolverIsHostShareable, BoolVector) {
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 2u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 2u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 3u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 3u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 4u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 4u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 2u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 2u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 3u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 3u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 4u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 4u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 2u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 2u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 3u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 3u)));
|
||||||
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<sem::Bool>(), 4u)));
|
EXPECT_FALSE(r()->IsHostShareable(create<sem::Vector>(create<type::Bool>(), 4u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, Matrix) {
|
TEST_F(ResolverIsHostShareable, Matrix) {
|
||||||
auto* vec2_f32 = create<sem::Vector>(create<sem::F32>(), 2u);
|
auto* vec2_f32 = create<sem::Vector>(create<type::F32>(), 2u);
|
||||||
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
|
auto* vec3_f32 = create<sem::Vector>(create<type::F32>(), 3u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(create<sem::F32>(), 4u);
|
auto* vec4_f32 = create<sem::Vector>(create<type::F32>(), 4u);
|
||||||
auto* vec2_f16 = create<sem::Vector>(create<sem::F16>(), 2u);
|
auto* vec2_f16 = create<sem::Vector>(create<type::F16>(), 2u);
|
||||||
auto* vec3_f16 = create<sem::Vector>(create<sem::F16>(), 3u);
|
auto* vec3_f16 = create<sem::Vector>(create<type::F16>(), 3u);
|
||||||
auto* vec4_f16 = create<sem::Vector>(create<sem::F16>(), 4u);
|
auto* vec4_f16 = create<sem::Vector>(create<type::F16>(), 4u);
|
||||||
|
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Matrix>(vec2_f32, 2u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Matrix>(vec2_f32, 2u)));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Matrix>(vec2_f32, 3u)));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Matrix>(vec2_f32, 3u)));
|
||||||
|
@ -95,25 +95,25 @@ TEST_F(ResolverIsHostShareable, Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, Pointer) {
|
TEST_F(ResolverIsHostShareable, Pointer) {
|
||||||
auto* ptr = create<sem::Pointer>(create<sem::I32>(), ast::AddressSpace::kPrivate,
|
auto* ptr = create<sem::Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
EXPECT_FALSE(r()->IsHostShareable(ptr));
|
EXPECT_FALSE(r()->IsHostShareable(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, Atomic) {
|
TEST_F(ResolverIsHostShareable, Atomic) {
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<sem::I32>())));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<type::I32>())));
|
||||||
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<sem::U32>())));
|
EXPECT_TRUE(r()->IsHostShareable(create<sem::Atomic>(create<type::U32>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
|
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
|
||||||
auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
||||||
20u, 4u, 4u);
|
20u, 4u, 4u);
|
||||||
EXPECT_TRUE(r()->IsHostShareable(arr));
|
EXPECT_TRUE(r()->IsHostShareable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) {
|
TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) {
|
||||||
auto* arr =
|
auto* arr =
|
||||||
create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
||||||
EXPECT_TRUE(r()->IsHostShareable(arr));
|
EXPECT_TRUE(r()->IsHostShareable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,39 +24,39 @@ namespace {
|
||||||
using ResolverIsStorableTest = ResolverTest;
|
using ResolverIsStorableTest = ResolverTest;
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Void) {
|
TEST_F(ResolverIsStorableTest, Void) {
|
||||||
EXPECT_FALSE(r()->IsStorable(create<sem::Void>()));
|
EXPECT_FALSE(r()->IsStorable(create<type::Void>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Scalar) {
|
TEST_F(ResolverIsStorableTest, Scalar) {
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Bool>()));
|
EXPECT_TRUE(r()->IsStorable(create<type::Bool>()));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::I32>()));
|
EXPECT_TRUE(r()->IsStorable(create<type::I32>()));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::U32>()));
|
EXPECT_TRUE(r()->IsStorable(create<type::U32>()));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::F32>()));
|
EXPECT_TRUE(r()->IsStorable(create<type::F32>()));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::F16>()));
|
EXPECT_TRUE(r()->IsStorable(create<type::F16>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Vector) {
|
TEST_F(ResolverIsStorableTest, Vector) {
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 2u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::I32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 3u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::I32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 4u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::I32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 2u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::U32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 3u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::U32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 4u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::U32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 2u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F32>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 3u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F32>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 4u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F32>(), 4u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F16>(), 2u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F16>(), 2u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F16>(), 3u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F16>(), 3u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F16>(), 4u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<type::F16>(), 4u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Matrix) {
|
TEST_F(ResolverIsStorableTest, Matrix) {
|
||||||
auto* vec2_f32 = create<sem::Vector>(create<sem::F32>(), 2u);
|
auto* vec2_f32 = create<sem::Vector>(create<type::F32>(), 2u);
|
||||||
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
|
auto* vec3_f32 = create<sem::Vector>(create<type::F32>(), 3u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(create<sem::F32>(), 4u);
|
auto* vec4_f32 = create<sem::Vector>(create<type::F32>(), 4u);
|
||||||
auto* vec2_f16 = create<sem::Vector>(create<sem::F16>(), 2u);
|
auto* vec2_f16 = create<sem::Vector>(create<type::F16>(), 2u);
|
||||||
auto* vec3_f16 = create<sem::Vector>(create<sem::F16>(), 3u);
|
auto* vec3_f16 = create<sem::Vector>(create<type::F16>(), 3u);
|
||||||
auto* vec4_f16 = create<sem::Vector>(create<sem::F16>(), 4u);
|
auto* vec4_f16 = create<sem::Vector>(create<type::F16>(), 4u);
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 2u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 2u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 3u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 3u)));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 4u)));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2_f32, 4u)));
|
||||||
|
@ -78,25 +78,25 @@ TEST_F(ResolverIsStorableTest, Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Pointer) {
|
TEST_F(ResolverIsStorableTest, Pointer) {
|
||||||
auto* ptr = create<sem::Pointer>(create<sem::I32>(), ast::AddressSpace::kPrivate,
|
auto* ptr = create<sem::Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
EXPECT_FALSE(r()->IsStorable(ptr));
|
EXPECT_FALSE(r()->IsStorable(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, Atomic) {
|
TEST_F(ResolverIsStorableTest, Atomic) {
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<sem::I32>())));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<type::I32>())));
|
||||||
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<sem::U32>())));
|
EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<type::U32>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
|
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
|
||||||
auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
||||||
20u, 4u, 4u);
|
20u, 4u, 4u);
|
||||||
EXPECT_TRUE(r()->IsStorable(arr));
|
EXPECT_TRUE(r()->IsStorable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) {
|
TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) {
|
||||||
auto* arr =
|
auto* arr =
|
||||||
create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
||||||
EXPECT_TRUE(r()->IsStorable(arr));
|
EXPECT_TRUE(r()->IsStorable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_DefaultType) {
|
||||||
auto* materialize = sem->As<sem::Materialize>();
|
auto* materialize = sem->As<sem::Materialize>();
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||||
|
@ -1271,7 +1271,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) {
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
|
@ -1292,7 +1292,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) {
|
||||||
auto* materialize = sem->As<sem::Materialize>();
|
auto* materialize = sem->As<sem::Materialize>();
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<type::F16>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||||
|
@ -1312,7 +1312,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) {
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
|
@ -1330,8 +1330,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) {
|
||||||
auto* materialize = sem->As<sem::Materialize>();
|
auto* materialize = sem->As<sem::Materialize>();
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F32>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<type::I32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||||
|
@ -1350,8 +1350,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) {
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
|
@ -1374,8 +1374,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) {
|
||||||
auto* materialize = sem->As<sem::Materialize>();
|
auto* materialize = sem->As<sem::Materialize>();
|
||||||
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Type()->Is<sem::Struct>());
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::F16>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<type::F16>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::I32>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<type::I32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<type::AbstractFloat>());
|
||||||
|
@ -1397,8 +1397,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) {
|
||||||
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
auto* concrete_str = materialize->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<sem::F16>());
|
ASSERT_TRUE(concrete_str->Members()[0]->Type()->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
ASSERT_TRUE(concrete_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
ASSERT_TRUE(concrete_str->Members()[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
ASSERT_TRUE(materialize->Expr()->Type()->Is<sem::Struct>());
|
||||||
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
auto* abstract_str = materialize->Expr()->Type()->As<sem::Struct>();
|
||||||
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is<sem::Vector>());
|
||||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(ResolverPtrRefTest, AddressOf) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::Pointer>());
|
ASSERT_TRUE(TypeOf(expr)->Is<sem::Pointer>());
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Pointer>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Pointer>()->StoreType()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(expr)->As<sem::Pointer>()->AddressSpace(), ast::AddressSpace::kFunction);
|
EXPECT_EQ(TypeOf(expr)->As<sem::Pointer>()->AddressSpace(), ast::AddressSpace::kFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ TEST_F(ResolverPtrRefTest, AddressOfThenDeref) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(expr)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(expr)->As<sem::Reference>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(expr)->As<sem::Reference>()->StoreType()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) {
|
TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) {
|
||||||
|
|
|
@ -203,19 +203,19 @@ type::Type* Resolver::Type(const ast::Type* ty) {
|
||||||
Mark(ty);
|
Mark(ty);
|
||||||
auto* s = Switch(
|
auto* s = Switch(
|
||||||
ty, //
|
ty, //
|
||||||
[&](const ast::Void*) { return builder_->create<sem::Void>(); },
|
[&](const ast::Void*) { return builder_->create<type::Void>(); },
|
||||||
[&](const ast::Bool*) { return builder_->create<sem::Bool>(); },
|
[&](const ast::Bool*) { return builder_->create<type::Bool>(); },
|
||||||
[&](const ast::I32*) { return builder_->create<sem::I32>(); },
|
[&](const ast::I32*) { return builder_->create<type::I32>(); },
|
||||||
[&](const ast::U32*) { return builder_->create<sem::U32>(); },
|
[&](const ast::U32*) { return builder_->create<type::U32>(); },
|
||||||
[&](const ast::F16* t) -> sem::F16* {
|
[&](const ast::F16* t) -> type::F16* {
|
||||||
// Validate if f16 type is allowed.
|
// Validate if f16 type is allowed.
|
||||||
if (!enabled_extensions_.Contains(ast::Extension::kF16)) {
|
if (!enabled_extensions_.Contains(ast::Extension::kF16)) {
|
||||||
AddError("f16 used without 'f16' extension enabled", t->source);
|
AddError("f16 used without 'f16' extension enabled", t->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return builder_->create<sem::F16>();
|
return builder_->create<type::F16>();
|
||||||
},
|
},
|
||||||
[&](const ast::F32*) { return builder_->create<sem::F32>(); },
|
[&](const ast::F32*) { return builder_->create<type::F32>(); },
|
||||||
[&](const ast::Vector* t) -> sem::Vector* {
|
[&](const ast::Vector* t) -> sem::Vector* {
|
||||||
if (!t->type) {
|
if (!t->type) {
|
||||||
AddError("missing vector element type", t->source.End());
|
AddError("missing vector element type", t->source.End());
|
||||||
|
@ -481,7 +481,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("@id must be an i32 or u32 value", id_attr->source);
|
AddError("@id must be an i32 or u32 value", id_attr->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("@binding must be an i32 or u32 value", attr->source);
|
AddError("@binding must be an i32 or u32 value", attr->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("@group must be an i32 or u32 value", attr->source);
|
AddError("@group must be an i32 or u32 value", attr->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ utils::Result<uint32_t> Resolver::LocationAttribute(const ast::LocationAttribute
|
||||||
return utils::Failure;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("@location must be an i32 or u32 value", attr->source);
|
AddError("@location must be an i32 or u32 value", attr->source);
|
||||||
return utils::Failure;
|
return utils::Failure;
|
||||||
}
|
}
|
||||||
|
@ -947,7 +947,7 @@ sem::Statement* Resolver::StaticAssert(const ast::StaticAssert* assertion) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* cond = expr->ConstantValue();
|
auto* cond = expr->ConstantValue();
|
||||||
if (auto* ty = cond->Type(); !ty->Is<sem::Bool>()) {
|
if (auto* ty = cond->Type(); !ty->Is<type::Bool>()) {
|
||||||
AddError(
|
AddError(
|
||||||
"static assertion condition must be a bool, got '" + builder_->FriendlyName(ty) + "'",
|
"static assertion condition must be a bool, got '" + builder_->FriendlyName(ty) + "'",
|
||||||
assertion->condition->source);
|
assertion->condition->source);
|
||||||
|
@ -1018,7 +1018,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return_type = builder_->create<sem::Void>();
|
return_type = builder_->create<type::Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if the return type has a location
|
// Determine if the return type has a location
|
||||||
|
@ -1155,7 +1155,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto* ty = expr->Type();
|
auto* ty = expr->Type();
|
||||||
if (!ty->IsAnyOf<sem::I32, sem::U32, type::AbstractInt>()) {
|
if (!ty->IsAnyOf<type::I32, type::U32, type::AbstractInt>()) {
|
||||||
AddError(kErrBadExpr, value->source);
|
AddError(kErrBadExpr, value->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1179,7 +1179,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
|
||||||
|
|
||||||
// If all arguments are abstract-integers, then materialize to i32.
|
// If all arguments are abstract-integers, then materialize to i32.
|
||||||
if (common_ty->Is<type::AbstractInt>()) {
|
if (common_ty->Is<type::AbstractInt>()) {
|
||||||
common_ty = builder_->create<sem::I32>();
|
common_ty = builder_->create<type::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < args.Length(); i++) {
|
for (size_t i = 0; i < args.Length(); i++) {
|
||||||
|
@ -1293,7 +1293,7 @@ sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, cons
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("case selector must be an i32 or u32 value", sel->source);
|
AddError("case selector must be an i32 or u32 value", sel->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1542,7 +1542,7 @@ sem::Expression* Resolver::Expression(const ast::Expression* root) {
|
||||||
},
|
},
|
||||||
[&](const ast::UnaryOpExpression* unary) -> sem::Expression* { return UnaryOp(unary); },
|
[&](const ast::UnaryOpExpression* unary) -> sem::Expression* { return UnaryOp(unary); },
|
||||||
[&](const ast::PhonyExpression*) -> sem::Expression* {
|
[&](const ast::PhonyExpression*) -> sem::Expression* {
|
||||||
return builder_->create<sem::Expression>(expr, builder_->create<sem::Void>(),
|
return builder_->create<sem::Expression>(expr, builder_->create<type::Void>(),
|
||||||
sem::EvaluationStage::kRuntime,
|
sem::EvaluationStage::kRuntime,
|
||||||
current_statement_,
|
current_statement_,
|
||||||
/* constant_value */ nullptr,
|
/* constant_value */ nullptr,
|
||||||
|
@ -1716,8 +1716,8 @@ bool Resolver::AliasAnalysis(const sem::Call* call) {
|
||||||
const type::Type* Resolver::ConcreteType(const type::Type* ty,
|
const type::Type* Resolver::ConcreteType(const type::Type* ty,
|
||||||
const type::Type* target_ty,
|
const type::Type* target_ty,
|
||||||
const Source& source) {
|
const Source& source) {
|
||||||
auto i32 = [&] { return builder_->create<sem::I32>(); };
|
auto i32 = [&] { return builder_->create<type::I32>(); };
|
||||||
auto f32 = [&] { return builder_->create<sem::F32>(); };
|
auto f32 = [&] { return builder_->create<type::F32>(); };
|
||||||
auto i32v = [&](uint32_t width) { return builder_->create<sem::Vector>(i32(), width); };
|
auto i32v = [&](uint32_t width) { return builder_->create<sem::Vector>(i32(), width); };
|
||||||
auto f32v = [&](uint32_t width) { return builder_->create<sem::Vector>(f32(), width); };
|
auto f32v = [&](uint32_t width) { return builder_->create<sem::Vector>(f32(), width); };
|
||||||
auto f32m = [&](uint32_t columns, uint32_t rows) {
|
auto f32m = [&](uint32_t columns, uint32_t rows) {
|
||||||
|
@ -1883,7 +1883,7 @@ sem::Expression* Resolver::IndexAccessor(const ast::IndexAccessorExpression* exp
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* idx_ty = idx->Type()->UnwrapRef();
|
auto* idx_ty = idx->Type()->UnwrapRef();
|
||||||
if (!idx_ty->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!idx_ty->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("index must be of type 'i32' or 'u32', found: '" + sem_.TypeNameOf(idx_ty) + "'",
|
AddError("index must be of type 'i32' or 'u32', found: '" + sem_.TypeNameOf(idx_ty) + "'",
|
||||||
idx->Declaration()->source);
|
idx->Declaration()->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2040,11 +2040,11 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
||||||
[&](const sem::Matrix* m) {
|
[&](const sem::Matrix* m) {
|
||||||
return ct_init_or_conv(MatrixInitConvIntrinsic(m->columns(), m->rows()), m->type());
|
return ct_init_or_conv(MatrixInitConvIntrinsic(m->columns(), m->rows()), m->type());
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) { return ct_init_or_conv(InitConvIntrinsic::kI32, nullptr); },
|
[&](const type::I32*) { return ct_init_or_conv(InitConvIntrinsic::kI32, nullptr); },
|
||||||
[&](const sem::U32*) { return ct_init_or_conv(InitConvIntrinsic::kU32, nullptr); },
|
[&](const type::U32*) { return ct_init_or_conv(InitConvIntrinsic::kU32, nullptr); },
|
||||||
[&](const sem::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); },
|
[&](const type::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); },
|
||||||
[&](const sem::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); },
|
[&](const type::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); },
|
||||||
[&](const sem::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); },
|
[&](const type::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); },
|
||||||
[&](const sem::Array* arr) -> sem::Call* {
|
[&](const sem::Array* arr) -> sem::Call* {
|
||||||
auto* call_target = array_inits_.GetOrCreate(
|
auto* call_target = array_inits_.GetOrCreate(
|
||||||
ArrayInitializerSig{{arr, args.Length(), args_stage}},
|
ArrayInitializerSig{{arr, args.Length(), args_stage}},
|
||||||
|
@ -2351,29 +2351,29 @@ type::Type* Resolver::BuiltinTypeAlias(Symbol sym) const {
|
||||||
auto& b = *builder_;
|
auto& b = *builder_;
|
||||||
switch (ParseTypeAlias(name)) {
|
switch (ParseTypeAlias(name)) {
|
||||||
case TypeAlias::kVec2F:
|
case TypeAlias::kVec2F:
|
||||||
return b.create<sem::Vector>(b.create<sem::F32>(), 2u);
|
return b.create<sem::Vector>(b.create<type::F32>(), 2u);
|
||||||
case TypeAlias::kVec3F:
|
case TypeAlias::kVec3F:
|
||||||
return b.create<sem::Vector>(b.create<sem::F32>(), 3u);
|
return b.create<sem::Vector>(b.create<type::F32>(), 3u);
|
||||||
case TypeAlias::kVec4F:
|
case TypeAlias::kVec4F:
|
||||||
return b.create<sem::Vector>(b.create<sem::F32>(), 4u);
|
return b.create<sem::Vector>(b.create<type::F32>(), 4u);
|
||||||
case TypeAlias::kVec2H:
|
case TypeAlias::kVec2H:
|
||||||
return b.create<sem::Vector>(b.create<sem::F16>(), 2u);
|
return b.create<sem::Vector>(b.create<type::F16>(), 2u);
|
||||||
case TypeAlias::kVec3H:
|
case TypeAlias::kVec3H:
|
||||||
return b.create<sem::Vector>(b.create<sem::F16>(), 3u);
|
return b.create<sem::Vector>(b.create<type::F16>(), 3u);
|
||||||
case TypeAlias::kVec4H:
|
case TypeAlias::kVec4H:
|
||||||
return b.create<sem::Vector>(b.create<sem::F16>(), 4u);
|
return b.create<sem::Vector>(b.create<type::F16>(), 4u);
|
||||||
case TypeAlias::kVec2I:
|
case TypeAlias::kVec2I:
|
||||||
return b.create<sem::Vector>(b.create<sem::I32>(), 2u);
|
return b.create<sem::Vector>(b.create<type::I32>(), 2u);
|
||||||
case TypeAlias::kVec3I:
|
case TypeAlias::kVec3I:
|
||||||
return b.create<sem::Vector>(b.create<sem::I32>(), 3u);
|
return b.create<sem::Vector>(b.create<type::I32>(), 3u);
|
||||||
case TypeAlias::kVec4I:
|
case TypeAlias::kVec4I:
|
||||||
return b.create<sem::Vector>(b.create<sem::I32>(), 4u);
|
return b.create<sem::Vector>(b.create<type::I32>(), 4u);
|
||||||
case TypeAlias::kVec2U:
|
case TypeAlias::kVec2U:
|
||||||
return b.create<sem::Vector>(b.create<sem::U32>(), 2u);
|
return b.create<sem::Vector>(b.create<type::U32>(), 2u);
|
||||||
case TypeAlias::kVec3U:
|
case TypeAlias::kVec3U:
|
||||||
return b.create<sem::Vector>(b.create<sem::U32>(), 3u);
|
return b.create<sem::Vector>(b.create<type::U32>(), 3u);
|
||||||
case TypeAlias::kVec4U:
|
case TypeAlias::kVec4U:
|
||||||
return b.create<sem::Vector>(b.create<sem::U32>(), 4u);
|
return b.create<sem::Vector>(b.create<type::U32>(), 4u);
|
||||||
case TypeAlias::kUndefined:
|
case TypeAlias::kUndefined:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2485,9 +2485,9 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||||
case ast::IntLiteralExpression::Suffix::kNone:
|
case ast::IntLiteralExpression::Suffix::kNone:
|
||||||
return builder_->create<type::AbstractInt>();
|
return builder_->create<type::AbstractInt>();
|
||||||
case ast::IntLiteralExpression::Suffix::kI:
|
case ast::IntLiteralExpression::Suffix::kI:
|
||||||
return builder_->create<sem::I32>();
|
return builder_->create<type::I32>();
|
||||||
case ast::IntLiteralExpression::Suffix::kU:
|
case ast::IntLiteralExpression::Suffix::kU:
|
||||||
return builder_->create<sem::U32>();
|
return builder_->create<type::U32>();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
|
@ -2496,13 +2496,13 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||||
case ast::FloatLiteralExpression::Suffix::kNone:
|
case ast::FloatLiteralExpression::Suffix::kNone:
|
||||||
return builder_->create<type::AbstractFloat>();
|
return builder_->create<type::AbstractFloat>();
|
||||||
case ast::FloatLiteralExpression::Suffix::kF:
|
case ast::FloatLiteralExpression::Suffix::kF:
|
||||||
return builder_->create<sem::F32>();
|
return builder_->create<type::F32>();
|
||||||
case ast::FloatLiteralExpression::Suffix::kH:
|
case ast::FloatLiteralExpression::Suffix::kH:
|
||||||
return builder_->create<sem::F16>();
|
return builder_->create<type::F16>();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
[&](const ast::BoolLiteralExpression*) { return builder_->create<sem::Bool>(); },
|
[&](const ast::BoolLiteralExpression*) { return builder_->create<type::Bool>(); },
|
||||||
[&](Default) { return nullptr; });
|
[&](Default) { return nullptr; });
|
||||||
|
|
||||||
if (ty == nullptr) {
|
if (ty == nullptr) {
|
||||||
|
@ -2511,7 +2511,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ty->Is<sem::F16>()) && (!enabled_extensions_.Contains(tint::ast::Extension::kF16))) {
|
if ((ty->Is<type::F16>()) && (!enabled_extensions_.Contains(tint::ast::Extension::kF16))) {
|
||||||
AddError("f16 literal used without 'f16' extension enabled", literal->source);
|
AddError("f16 literal used without 'f16' extension enabled", literal->source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -3190,7 +3190,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!materialized->Type()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
AddError("@align must be an i32 or u32 value", a->source);
|
AddError("@align must be an i32 or u32 value", a->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3219,7 +3219,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
|
||||||
if (!materialized) {
|
if (!materialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!materialized->Type()->IsAnyOf<sem::U32, sem::I32>()) {
|
if (!materialized->Type()->IsAnyOf<type::U32, type::I32>()) {
|
||||||
AddError("@size must be an i32 or u32 value", s->source);
|
AddError("@size must be an i32 or u32 value", s->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3344,7 +3344,7 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) {
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (auto* ret_ty = current_function_->ReturnType(); !ret_ty->Is<sem::Void>()) {
|
if (auto* ret_ty = current_function_->ReturnType(); !ret_ty->Is<type::Void>()) {
|
||||||
expr = Materialize(expr, ret_ty);
|
expr = Materialize(expr, ret_ty);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3355,7 +3355,7 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) {
|
||||||
|
|
||||||
RegisterLoadIfNeeded(expr);
|
RegisterLoadIfNeeded(expr);
|
||||||
} else {
|
} else {
|
||||||
value_ty = builder_->create<sem::Void>();
|
value_ty = builder_->create<type::Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate after processing the return value expression so that its type
|
// Validate after processing the return value expression so that its type
|
||||||
|
@ -3401,7 +3401,7 @@ sem::SwitchStatement* Resolver::SwitchStatement(const ast::SwitchStatement* stmt
|
||||||
if (!common_ty || !common_ty->is_integer_scalar()) {
|
if (!common_ty || !common_ty->is_integer_scalar()) {
|
||||||
// No common type found or the common type was abstract.
|
// No common type found or the common type was abstract.
|
||||||
// Pick i32 and let validation deal with any mismatches.
|
// Pick i32 and let validation deal with any mismatches.
|
||||||
common_ty = builder_->create<sem::I32>();
|
common_ty = builder_->create<type::I32>();
|
||||||
}
|
}
|
||||||
cond = Materialize(cond, common_ty);
|
cond = Materialize(cond, common_ty);
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
|
|
|
@ -99,8 +99,8 @@ TEST_F(ResolverTest, Stmt_Assign) {
|
||||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||||
|
|
||||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(lhs), assign);
|
EXPECT_EQ(StmtOf(lhs), assign);
|
||||||
EXPECT_EQ(StmtOf(rhs), assign);
|
EXPECT_EQ(StmtOf(rhs), assign);
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ TEST_F(ResolverTest, Stmt_Case) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(lhs), assign);
|
EXPECT_EQ(StmtOf(lhs), assign);
|
||||||
EXPECT_EQ(StmtOf(rhs), assign);
|
EXPECT_EQ(StmtOf(rhs), assign);
|
||||||
EXPECT_EQ(BlockOf(assign), block);
|
EXPECT_EQ(BlockOf(assign), block);
|
||||||
|
@ -156,8 +156,8 @@ TEST_F(ResolverTest, Stmt_Block) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(lhs), assign);
|
EXPECT_EQ(StmtOf(lhs), assign);
|
||||||
EXPECT_EQ(StmtOf(rhs), assign);
|
EXPECT_EQ(StmtOf(rhs), assign);
|
||||||
EXPECT_EQ(BlockOf(lhs), block);
|
EXPECT_EQ(BlockOf(lhs), block);
|
||||||
|
@ -191,11 +191,11 @@ TEST_F(ResolverTest, Stmt_If) {
|
||||||
ASSERT_NE(TypeOf(else_rhs), nullptr);
|
ASSERT_NE(TypeOf(else_rhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(stmt->condition)->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(stmt->condition)->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(else_rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(else_rhs)->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(lhs), assign);
|
EXPECT_EQ(StmtOf(lhs), assign);
|
||||||
EXPECT_EQ(StmtOf(rhs), assign);
|
EXPECT_EQ(StmtOf(rhs), assign);
|
||||||
EXPECT_EQ(StmtOf(cond), stmt);
|
EXPECT_EQ(StmtOf(cond), stmt);
|
||||||
|
@ -226,10 +226,10 @@ TEST_F(ResolverTest, Stmt_Loop) {
|
||||||
ASSERT_NE(TypeOf(body_rhs), nullptr);
|
ASSERT_NE(TypeOf(body_rhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(continuing_lhs), nullptr);
|
ASSERT_NE(TypeOf(continuing_lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(continuing_rhs), nullptr);
|
ASSERT_NE(TypeOf(continuing_rhs), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(body_lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(body_lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(body_rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(body_rhs)->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(continuing_rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(continuing_rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(BlockOf(body_lhs), body);
|
EXPECT_EQ(BlockOf(body_lhs), body);
|
||||||
EXPECT_EQ(BlockOf(body_rhs), body);
|
EXPECT_EQ(BlockOf(body_rhs), body);
|
||||||
EXPECT_EQ(BlockOf(continuing_lhs), continuing);
|
EXPECT_EQ(BlockOf(continuing_lhs), continuing);
|
||||||
|
@ -246,7 +246,7 @@ TEST_F(ResolverTest, Stmt_Return) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(cond), nullptr);
|
ASSERT_NE(TypeOf(cond), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(cond)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(cond)->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Stmt_Return_WithoutValue) {
|
TEST_F(ResolverTest, Stmt_Return_WithoutValue) {
|
||||||
|
@ -270,9 +270,9 @@ TEST_F(ResolverTest, Stmt_Switch) {
|
||||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||||
|
|
||||||
EXPECT_TRUE(TypeOf(stmt->condition)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(stmt->condition)->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(rhs)->Is<type::F32>());
|
||||||
EXPECT_EQ(BlockOf(lhs), case_block);
|
EXPECT_EQ(BlockOf(lhs), case_block);
|
||||||
EXPECT_EQ(BlockOf(rhs), case_block);
|
EXPECT_EQ(BlockOf(rhs), case_block);
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ TEST_F(ResolverTest, Stmt_Call) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::Void>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::Void>());
|
||||||
EXPECT_EQ(StmtOf(expr), call);
|
EXPECT_EQ(StmtOf(expr), call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(init), nullptr);
|
ASSERT_NE(TypeOf(init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||||
|
@ -319,7 +319,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(init), nullptr);
|
ASSERT_NE(TypeOf(init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
|
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
|
||||||
|
@ -329,7 +329,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(init), nullptr);
|
ASSERT_NE(TypeOf(init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(init)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(init)->Is<type::I32>());
|
||||||
EXPECT_EQ(StmtOf(init), nullptr);
|
EXPECT_EQ(StmtOf(init), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,13 +369,13 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
ASSERT_NE(TypeOf(foo_i32_init), nullptr);
|
ASSERT_NE(TypeOf(foo_i32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(foo_i32_init)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(foo_i32_init)->Is<type::I32>());
|
||||||
ASSERT_NE(TypeOf(foo_f32_init), nullptr);
|
ASSERT_NE(TypeOf(foo_f32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(foo_f32_init)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(foo_f32_init)->Is<type::F32>());
|
||||||
ASSERT_NE(TypeOf(bar_i32_init), nullptr);
|
ASSERT_NE(TypeOf(bar_i32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapRef()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapRef()->Is<type::I32>());
|
||||||
ASSERT_NE(TypeOf(bar_f32_init), nullptr);
|
ASSERT_NE(TypeOf(bar_f32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(foo_i32_init), foo_i32_decl);
|
EXPECT_EQ(StmtOf(foo_i32_init), foo_i32_decl);
|
||||||
EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
|
EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
|
||||||
EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
|
EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
|
||||||
|
@ -416,11 +416,11 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||||
|
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
ASSERT_NE(TypeOf(mod_init), nullptr);
|
ASSERT_NE(TypeOf(mod_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(mod_init)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(mod_init)->Is<type::F32>());
|
||||||
ASSERT_NE(TypeOf(fn_i32_init), nullptr);
|
ASSERT_NE(TypeOf(fn_i32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(fn_i32_init)->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(fn_i32_init)->Is<type::I32>());
|
||||||
ASSERT_NE(TypeOf(fn_f32_init), nullptr);
|
ASSERT_NE(TypeOf(fn_f32_init), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(fn_i32_init), fn_i32_decl);
|
EXPECT_EQ(StmtOf(fn_i32_init), fn_i32_decl);
|
||||||
EXPECT_EQ(StmtOf(mod_init), nullptr);
|
EXPECT_EQ(StmtOf(mod_init), nullptr);
|
||||||
EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
|
EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
|
||||||
|
@ -586,7 +586,7 @@ TEST_F(ResolverTest, Expr_Bitcast) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(bitcast), nullptr);
|
ASSERT_NE(TypeOf(bitcast), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(bitcast)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(bitcast)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call) {
|
TEST_F(ResolverTest, Expr_Call) {
|
||||||
|
@ -598,7 +598,7 @@ TEST_F(ResolverTest, Expr_Call) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
||||||
|
@ -610,7 +610,7 @@ TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_WithParams) {
|
TEST_F(ResolverTest, Expr_Call_WithParams) {
|
||||||
|
@ -627,7 +627,7 @@ TEST_F(ResolverTest, Expr_Call_WithParams) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(param), nullptr);
|
ASSERT_NE(TypeOf(param), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(param)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(param)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Call_Builtin) {
|
TEST_F(ResolverTest, Expr_Call_Builtin) {
|
||||||
|
@ -637,7 +637,7 @@ TEST_F(ResolverTest, Expr_Call_Builtin) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Cast) {
|
TEST_F(ResolverTest, Expr_Cast) {
|
||||||
|
@ -649,7 +649,7 @@ TEST_F(ResolverTest, Expr_Cast) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(cast), nullptr);
|
ASSERT_NE(TypeOf(cast), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(cast)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(cast)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Initializer_Scalar) {
|
TEST_F(ResolverTest, Expr_Initializer_Scalar) {
|
||||||
|
@ -659,7 +659,7 @@ TEST_F(ResolverTest, Expr_Initializer_Scalar) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(s), nullptr);
|
ASSERT_NE(TypeOf(s), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(s)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(s)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) {
|
TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) {
|
||||||
|
@ -670,7 +670,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec3) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec4) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(ident), nullptr);
|
ASSERT_NE(TypeOf(ident), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(ident)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(ident)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(ident)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(ident)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident}));
|
EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident}));
|
||||||
ASSERT_NE(VarOf(ident), nullptr);
|
ASSERT_NE(VarOf(ident), nullptr);
|
||||||
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
|
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
|
||||||
|
@ -723,7 +723,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalConst) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(ident), nullptr);
|
ASSERT_NE(TypeOf(ident), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(ident)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(ident)->Is<type::F32>());
|
||||||
EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident}));
|
EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident}));
|
||||||
ASSERT_NE(VarOf(ident), nullptr);
|
ASSERT_NE(VarOf(ident), nullptr);
|
||||||
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
|
EXPECT_EQ(VarOf(ident)->Declaration(), my_var);
|
||||||
|
@ -743,7 +743,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(my_var_a), nullptr);
|
ASSERT_NE(TypeOf(my_var_a), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(my_var_a)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(my_var_a)->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(my_var_a), decl);
|
EXPECT_EQ(StmtOf(my_var_a), decl);
|
||||||
EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a}));
|
EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a}));
|
||||||
ASSERT_NE(VarOf(my_var_a), nullptr);
|
ASSERT_NE(VarOf(my_var_a), nullptr);
|
||||||
|
@ -785,11 +785,11 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(my_var_a), nullptr);
|
ASSERT_NE(TypeOf(my_var_a), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(my_var_a)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(my_var_a)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(my_var_a)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(my_var_a)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(my_var_a), assign);
|
EXPECT_EQ(StmtOf(my_var_a), assign);
|
||||||
ASSERT_NE(TypeOf(my_var_b), nullptr);
|
ASSERT_NE(TypeOf(my_var_b), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(my_var_b)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(my_var_b)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(my_var_b)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(my_var_b)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(my_var_b), assign);
|
EXPECT_EQ(StmtOf(my_var_b), assign);
|
||||||
EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a, my_var_b}));
|
EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a, my_var_b}));
|
||||||
ASSERT_NE(VarOf(my_var_a), nullptr);
|
ASSERT_NE(VarOf(my_var_a), nullptr);
|
||||||
|
@ -815,11 +815,11 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(v), nullptr);
|
ASSERT_NE(TypeOf(v), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(v)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(v)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(v)->UnwrapRef()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(v)->UnwrapRef()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(v), p_decl);
|
EXPECT_EQ(StmtOf(v), p_decl);
|
||||||
ASSERT_NE(TypeOf(p), nullptr);
|
ASSERT_NE(TypeOf(p), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(p)->Is<sem::Pointer>());
|
ASSERT_TRUE(TypeOf(p)->Is<sem::Pointer>());
|
||||||
EXPECT_TRUE(TypeOf(p)->UnwrapPtr()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(p)->UnwrapPtr()->Is<type::F32>());
|
||||||
EXPECT_EQ(StmtOf(p), assign);
|
EXPECT_EQ(StmtOf(p), assign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ TEST_F(ResolverTest, Expr_Call_Function) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(call), nullptr);
|
ASSERT_NE(TypeOf(call), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(call)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(call)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Expr_Identifier_Unknown) {
|
TEST_F(ResolverTest, Expr_Identifier_Unknown) {
|
||||||
|
@ -863,13 +863,13 @@ TEST_F(ResolverTest, Function_Parameters) {
|
||||||
auto* func_sem = Sem().Get(func);
|
auto* func_sem = Sem().Get(func);
|
||||||
ASSERT_NE(func_sem, nullptr);
|
ASSERT_NE(func_sem, nullptr);
|
||||||
EXPECT_EQ(func_sem->Parameters().Length(), 3u);
|
EXPECT_EQ(func_sem->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(func_sem->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(func_sem->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(func_sem->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(func_sem->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(func_sem->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(func_sem->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
EXPECT_EQ(func_sem->Parameters()[0]->Declaration(), param_a);
|
EXPECT_EQ(func_sem->Parameters()[0]->Declaration(), param_a);
|
||||||
EXPECT_EQ(func_sem->Parameters()[1]->Declaration(), param_b);
|
EXPECT_EQ(func_sem->Parameters()[1]->Declaration(), param_b);
|
||||||
EXPECT_EQ(func_sem->Parameters()[2]->Declaration(), param_c);
|
EXPECT_EQ(func_sem->Parameters()[2]->Declaration(), param_c);
|
||||||
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(func_sem->ReturnType()->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Function_Parameters_Locations) {
|
TEST_F(ResolverTest, Function_Parameters_Locations) {
|
||||||
|
@ -937,7 +937,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
|
||||||
auto* func_sem = Sem().Get(func);
|
auto* func_sem = Sem().Get(func);
|
||||||
ASSERT_NE(func_sem, nullptr);
|
ASSERT_NE(func_sem, nullptr);
|
||||||
EXPECT_EQ(func_sem->Parameters().Length(), 0u);
|
EXPECT_EQ(func_sem->Parameters().Length(), 0u);
|
||||||
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(func_sem->ReturnType()->Is<type::Void>());
|
||||||
|
|
||||||
const auto& vars = func_sem->TransitivelyReferencedGlobals();
|
const auto& vars = func_sem->TransitivelyReferencedGlobals();
|
||||||
ASSERT_EQ(vars.Length(), 3u);
|
ASSERT_EQ(vars.Length(), 3u);
|
||||||
|
@ -1029,7 +1029,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) {
|
||||||
ASSERT_NE(func_sem, nullptr);
|
ASSERT_NE(func_sem, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
||||||
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(func_sem->ReturnType()->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) {
|
TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) {
|
||||||
|
@ -1044,7 +1044,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) {
|
||||||
ASSERT_NE(func_sem, nullptr);
|
ASSERT_NE(func_sem, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
||||||
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(func_sem->ReturnType()->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Function_NotRegisterFunctionParams) {
|
TEST_F(ResolverTest, Function_NotRegisterFunctionParams) {
|
||||||
|
@ -1055,7 +1055,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionParams) {
|
||||||
ASSERT_NE(func_sem, nullptr);
|
ASSERT_NE(func_sem, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u);
|
||||||
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
|
EXPECT_TRUE(func_sem->ReturnType()->Is<type::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTest, Function_CallSites) {
|
TEST_F(ResolverTest, Function_CallSites) {
|
||||||
|
@ -1253,10 +1253,10 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
|
||||||
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
auto* sma = Sem().Get(mem)->As<sem::StructMemberAccess>();
|
auto* sma = Sem().Get(mem)->As<sem::StructMemberAccess>();
|
||||||
ASSERT_NE(sma, nullptr);
|
ASSERT_NE(sma, nullptr);
|
||||||
EXPECT_TRUE(sma->Member()->Type()->Is<sem::F32>());
|
EXPECT_TRUE(sma->Member()->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
||||||
EXPECT_EQ(sma->Member()->Index(), 1u);
|
EXPECT_EQ(sma->Member()->Index(), 1u);
|
||||||
EXPECT_EQ(sma->Member()->Declaration()->symbol, Symbols().Get("second_member"));
|
EXPECT_EQ(sma->Member()->Declaration()->symbol, Symbols().Get("second_member"));
|
||||||
|
@ -1277,11 +1277,11 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
|
||||||
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
||||||
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
auto* sma = Sem().Get(mem)->As<sem::StructMemberAccess>();
|
auto* sma = Sem().Get(mem)->As<sem::StructMemberAccess>();
|
||||||
ASSERT_NE(sma, nullptr);
|
ASSERT_NE(sma, nullptr);
|
||||||
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
||||||
EXPECT_TRUE(sma->Member()->Type()->Is<sem::F32>());
|
EXPECT_TRUE(sma->Member()->Type()->Is<type::F32>());
|
||||||
EXPECT_EQ(sma->Member()->Index(), 1u);
|
EXPECT_EQ(sma->Member()->Index(), 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1295,7 +1295,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(mem), nullptr);
|
ASSERT_NE(TypeOf(mem), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->Width(), 4u);
|
||||||
auto* sma = Sem().Get(mem)->As<sem::Swizzle>();
|
auto* sma = Sem().Get(mem)->As<sem::Swizzle>();
|
||||||
ASSERT_NE(sma, nullptr);
|
ASSERT_NE(sma, nullptr);
|
||||||
|
@ -1315,7 +1315,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
|
||||||
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(mem)->Is<sem::Reference>());
|
||||||
|
|
||||||
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
auto* ref = TypeOf(mem)->As<sem::Reference>();
|
||||||
ASSERT_TRUE(ref->StoreType()->Is<sem::F32>());
|
ASSERT_TRUE(ref->StoreType()->Is<type::F32>());
|
||||||
auto* sma = Sem().Get(mem)->As<sem::Swizzle>();
|
auto* sma = Sem().Get(mem)->As<sem::Swizzle>();
|
||||||
ASSERT_NE(sma, nullptr);
|
ASSERT_NE(sma, nullptr);
|
||||||
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
EXPECT_EQ(sma->Object()->Declaration(), mem->structure);
|
||||||
|
@ -1350,7 +1350,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(mem), nullptr);
|
ASSERT_NE(TypeOf(mem), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(mem)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(mem)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(mem)->As<sem::Vector>()->Width(), 2u);
|
||||||
ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
|
ASSERT_TRUE(Sem().Get(mem)->Is<sem::Swizzle>());
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1367,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) {
|
||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
EXPECT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ExprBinaryTest {
|
namespace ExprBinaryTest {
|
||||||
|
@ -1773,12 +1773,12 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) {
|
||||||
if (vec_by_mat) {
|
if (vec_by_mat) {
|
||||||
lhs_type = ty.vec<f32>(vec_size);
|
lhs_type = ty.vec<f32>(vec_size);
|
||||||
rhs_type = ty.mat<f32>(mat_cols, mat_rows);
|
rhs_type = ty.mat<f32>(mat_cols, mat_rows);
|
||||||
result_type = create<sem::Vector>(create<sem::F32>(), mat_cols);
|
result_type = create<sem::Vector>(create<type::F32>(), mat_cols);
|
||||||
is_valid_expr = vec_size == mat_rows;
|
is_valid_expr = vec_size == mat_rows;
|
||||||
} else {
|
} else {
|
||||||
lhs_type = ty.mat<f32>(mat_cols, mat_rows);
|
lhs_type = ty.mat<f32>(mat_cols, mat_rows);
|
||||||
rhs_type = ty.vec<f32>(vec_size);
|
rhs_type = ty.vec<f32>(vec_size);
|
||||||
result_type = create<sem::Vector>(create<sem::F32>(), mat_rows);
|
result_type = create<sem::Vector>(create<type::F32>(), mat_rows);
|
||||||
is_valid_expr = vec_size == mat_cols;
|
is_valid_expr = vec_size == mat_cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1815,7 +1815,7 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) {
|
||||||
auto* lhs_type = ty.mat<f32>(lhs_mat_cols, lhs_mat_rows);
|
auto* lhs_type = ty.mat<f32>(lhs_mat_cols, lhs_mat_rows);
|
||||||
auto* rhs_type = ty.mat<f32>(rhs_mat_cols, rhs_mat_rows);
|
auto* rhs_type = ty.mat<f32>(rhs_mat_cols, rhs_mat_rows);
|
||||||
|
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* col = create<sem::Vector>(f32, lhs_mat_rows);
|
auto* col = create<sem::Vector>(f32, lhs_mat_rows);
|
||||||
auto* result_type = create<sem::Matrix>(col, rhs_mat_cols);
|
auto* result_type = create<sem::Matrix>(col, rhs_mat_cols);
|
||||||
|
|
||||||
|
@ -1862,11 +1862,11 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
|
||||||
ASSERT_NE(TypeOf(der), nullptr);
|
ASSERT_NE(TypeOf(der), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(der)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(der)->Is<sem::Vector>());
|
||||||
if (op == ast::UnaryOp::kNot) {
|
if (op == ast::UnaryOp::kNot) {
|
||||||
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
} else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) {
|
} else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) {
|
||||||
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
} else {
|
} else {
|
||||||
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(der)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
EXPECT_EQ(TypeOf(der)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(der)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ struct DataType<bool> {
|
||||||
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.bool_(); }
|
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.bool_(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @return the semantic bool type
|
/// @return the semantic bool type
|
||||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::Bool>(); }
|
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::Bool>(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @param args args of size 1 with the boolean value to init with
|
/// @param args args of size 1 with the boolean value to init with
|
||||||
/// @return a new AST expression of the bool type
|
/// @return a new AST expression of the bool type
|
||||||
|
@ -263,7 +263,7 @@ struct DataType<i32> {
|
||||||
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.i32(); }
|
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.i32(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @return the semantic i32 type
|
/// @return the semantic i32 type
|
||||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::I32>(); }
|
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::I32>(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @param args args of size 1 with the i32 value to init with
|
/// @param args args of size 1 with the i32 value to init with
|
||||||
/// @return a new AST i32 literal value expression
|
/// @return a new AST i32 literal value expression
|
||||||
|
@ -294,7 +294,7 @@ struct DataType<u32> {
|
||||||
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.u32(); }
|
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.u32(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @return the semantic u32 type
|
/// @return the semantic u32 type
|
||||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::U32>(); }
|
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::U32>(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @param args args of size 1 with the u32 value to init with
|
/// @param args args of size 1 with the u32 value to init with
|
||||||
/// @return a new AST u32 literal value expression
|
/// @return a new AST u32 literal value expression
|
||||||
|
@ -325,7 +325,7 @@ struct DataType<f32> {
|
||||||
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f32(); }
|
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f32(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @return the semantic f32 type
|
/// @return the semantic f32 type
|
||||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::F32>(); }
|
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::F32>(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @param args args of size 1 with the f32 value to init with
|
/// @param args args of size 1 with the f32 value to init with
|
||||||
/// @return a new AST f32 literal value expression
|
/// @return a new AST f32 literal value expression
|
||||||
|
@ -356,7 +356,7 @@ struct DataType<f16> {
|
||||||
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f16(); }
|
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f16(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @return the semantic f16 type
|
/// @return the semantic f16 type
|
||||||
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::F16>(); }
|
static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<type::F16>(); }
|
||||||
/// @param b the ProgramBuilder
|
/// @param b the ProgramBuilder
|
||||||
/// @param args args of size 1 with the f16 value to init with
|
/// @param args args of size 1 with the f16 value to init with
|
||||||
/// @return a new AST f16 literal value expression
|
/// @return a new AST f16 literal value expression
|
||||||
|
|
|
@ -68,10 +68,10 @@ TEST_F(ResolverTypeInitializerValidationTest, InferTypeTest_Simple) {
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
ASSERT_TRUE(TypeOf(a_ident)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(a_ident)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(a_ident)->As<sem::Reference>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(a_ident)->As<sem::Reference>()->StoreType()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(a_ident)->As<sem::Reference>()->AddressSpace(), ast::AddressSpace::kFunction);
|
EXPECT_EQ(TypeOf(a_ident)->As<sem::Reference>()->AddressSpace(), ast::AddressSpace::kFunction);
|
||||||
ASSERT_TRUE(TypeOf(b_ident)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(b_ident)->Is<sem::Reference>());
|
||||||
EXPECT_TRUE(TypeOf(b_ident)->As<sem::Reference>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(b_ident)->As<sem::Reference>()->StoreType()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(b_ident)->As<sem::Reference>()->AddressSpace(), ast::AddressSpace::kFunction);
|
EXPECT_EQ(TypeOf(b_ident)->As<sem::Reference>()->AddressSpace(), ast::AddressSpace::kFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,9 +515,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32U32U32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) {
|
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) {
|
||||||
|
@ -534,9 +534,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) {
|
TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) {
|
||||||
|
@ -553,9 +553,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) {
|
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) {
|
||||||
|
@ -572,9 +572,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) {
|
TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) {
|
||||||
|
@ -591,9 +591,9 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) {
|
TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) {
|
||||||
|
@ -632,9 +632,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) {
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) {
|
TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) {
|
||||||
|
@ -654,9 +654,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) {
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32F32) {
|
TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32F32) {
|
||||||
|
@ -896,7 +896,7 @@ TEST_F(ResolverTypeInitializerValidationTest, I32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::I32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -904,7 +904,7 @@ TEST_F(ResolverTypeInitializerValidationTest, I32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, U32_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, U32_Success) {
|
||||||
|
@ -914,7 +914,7 @@ TEST_F(ResolverTypeInitializerValidationTest, U32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::U32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -922,7 +922,7 @@ TEST_F(ResolverTypeInitializerValidationTest, U32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, F32_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, F32_Success) {
|
||||||
|
@ -932,7 +932,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -940,7 +940,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, F16_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, F16_Success) {
|
||||||
|
@ -952,7 +952,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F16_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::F16>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::F16>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -960,7 +960,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F16_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) {
|
||||||
|
@ -970,7 +970,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::I32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -978,7 +978,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) {
|
||||||
|
@ -988,7 +988,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::U32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -996,7 +996,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) {
|
||||||
|
@ -1008,7 +1008,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::F16>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::F16>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -1016,7 +1016,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) {
|
TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) {
|
||||||
|
@ -1028,7 +1028,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(expr), nullptr);
|
ASSERT_NE(TypeOf(expr), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(expr)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(expr)->Is<type::F32>());
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(expr);
|
auto* call = Sem().Get<sem::Call>(expr);
|
||||||
ASSERT_NE(call, nullptr);
|
ASSERT_NE(call, nullptr);
|
||||||
|
@ -1036,7 +1036,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
ASSERT_EQ(ctor->Parameters().Length(), 1u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ScalarInitializer
|
} // namespace ScalarInitializer
|
||||||
|
@ -1142,7 +1142,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_ZeroValue) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1161,7 +1161,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1170,8 +1170,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) {
|
||||||
|
@ -1184,7 +1184,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1193,8 +1193,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F16>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) {
|
||||||
|
@ -1205,7 +1205,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1214,8 +1214,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) {
|
||||||
|
@ -1226,7 +1226,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1235,8 +1235,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) {
|
||||||
|
@ -1247,7 +1247,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1256,8 +1256,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) {
|
||||||
|
@ -1268,7 +1268,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1288,7 +1288,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Vec2TypeConversion) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1417,7 +1417,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ZeroValue) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1436,7 +1436,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1445,9 +1445,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) {
|
||||||
|
@ -1460,7 +1460,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1469,9 +1469,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F16>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::F16>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::F16>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::F16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) {
|
||||||
|
@ -1482,7 +1482,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1491,9 +1491,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::U32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) {
|
||||||
|
@ -1504,7 +1504,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1513,9 +1513,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) {
|
||||||
|
@ -1526,7 +1526,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1535,9 +1535,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) {
|
||||||
|
@ -1548,7 +1548,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1558,7 +1558,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) {
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) {
|
TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) {
|
||||||
|
@ -1569,7 +1569,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1578,7 +1578,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
EXPECT_EQ(call->Type(), ctor->ReturnType());
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::F32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Vector>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1590,7 +1590,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Identity) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1610,7 +1610,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec3TypeConversion) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
|
||||||
auto* call = Sem().Get<sem::Call>(tc);
|
auto* call = Sem().Get<sem::Call>(tc);
|
||||||
|
@ -1782,7 +1782,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ZeroValue) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1794,7 +1794,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1808,7 +1808,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1820,7 +1820,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4U32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1832,7 +1832,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4I32_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1844,7 +1844,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4Bool_Success_Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1856,7 +1856,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2ScalarScalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1868,7 +1868,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarVec2Scalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1880,7 +1880,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarScalarVec2) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1892,7 +1892,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2AndVec2) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1904,7 +1904,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec3AndScalar) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1916,7 +1916,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarAndVec3) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1928,7 +1928,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Identity) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1940,7 +1940,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec4TypeConversion) {
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,7 +1962,7 @@ TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_Success)
|
||||||
|
|
||||||
ASSERT_NE(TypeOf(tc), nullptr);
|
ASSERT_NE(TypeOf(tc), nullptr);
|
||||||
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(tc)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(tc)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2051,11 +2051,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromScalars) {
|
||||||
ASSERT_TRUE(TypeOf(vec2_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec2_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec2_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec2_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec2_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec2_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec2_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec2_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec2_bool)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_bool)->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_EQ(TypeOf(vec2_i32)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_i32)->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_EQ(TypeOf(vec2_u32)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_u32)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
@ -2085,11 +2085,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromVec2) {
|
||||||
ASSERT_TRUE(TypeOf(vec2_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec2_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec2_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec2_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec2_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec2_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec2_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec2_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec2_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec2_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec2_bool)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_bool)->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_EQ(TypeOf(vec2_i32)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_i32)->As<sem::Vector>()->Width(), 2u);
|
||||||
EXPECT_EQ(TypeOf(vec2_u32)->As<sem::Vector>()->Width(), 2u);
|
EXPECT_EQ(TypeOf(vec2_u32)->As<sem::Vector>()->Width(), 2u);
|
||||||
|
@ -2120,11 +2120,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalars) {
|
||||||
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
@ -2154,11 +2154,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromVec3) {
|
||||||
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
@ -2189,11 +2189,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalarAndV
|
||||||
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec3_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec3_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec3_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec3_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec3_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec3_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_bool)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_i32)->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(TypeOf(vec3_u32)->As<sem::Vector>()->Width(), 3u);
|
||||||
|
@ -2228,11 +2228,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalars) {
|
||||||
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
||||||
|
@ -2263,11 +2263,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec4) {
|
||||||
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
||||||
|
@ -2302,11 +2302,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalarAndV
|
||||||
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
||||||
|
@ -2341,11 +2341,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec2AndVec
|
||||||
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_u32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(vec4_f16)->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(vec4_bool)->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(vec4_i32)->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(vec4_u32)->As<sem::Vector>()->type()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(vec4_f32)->As<sem::Vector>()->type()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(vec4_f16)->As<sem::Vector>()->type()->Is<type::F16>());
|
||||||
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_bool)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_i32)->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(TypeOf(vec4_u32)->As<sem::Vector>()->Width(), 4u);
|
||||||
|
|
|
@ -210,7 +210,7 @@ bool Validator::IsFixedFootprint(const type::Type* type) const {
|
||||||
|
|
||||||
// https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types
|
// https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types
|
||||||
bool Validator::IsHostShareable(const type::Type* type) const {
|
bool Validator::IsHostShareable(const type::Type* type) const {
|
||||||
if (type->IsAnyOf<sem::I32, sem::U32, sem::F32, sem::F16>()) {
|
if (type->IsAnyOf<type::I32, type::U32, type::F32, type::F16>()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Switch(
|
return Switch(
|
||||||
|
@ -263,7 +263,7 @@ const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop,
|
||||||
bool Validator::Atomic(const ast::Atomic* a, const sem::Atomic* s) const {
|
bool Validator::Atomic(const ast::Atomic* a, const sem::Atomic* s) const {
|
||||||
// https://gpuweb.github.io/gpuweb/wgsl/#atomic-types
|
// https://gpuweb.github.io/gpuweb/wgsl/#atomic-types
|
||||||
// T must be either u32 or i32.
|
// T must be either u32 or i32.
|
||||||
if (!s->Type()->IsAnyOf<sem::U32, sem::I32>()) {
|
if (!s->Type()->IsAnyOf<type::U32, type::I32>()) {
|
||||||
AddError("atomic only supports i32 or u32 types", a->type ? a->type->source : a->source);
|
AddError("atomic only supports i32 or u32 types", a->type ? a->type->source : a->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ bool Validator::StorageTexture(const ast::StorageTexture* t) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Validator::SampledTexture(const type::SampledTexture* t, const Source& source) const {
|
bool Validator::SampledTexture(const type::SampledTexture* t, const Source& source) const {
|
||||||
if (!t->type()->UnwrapRef()->IsAnyOf<sem::F32, sem::I32, sem::U32>()) {
|
if (!t->type()->UnwrapRef()->IsAnyOf<type::F32, type::I32, type::U32>()) {
|
||||||
AddError("texture_2d<type>: type must be f32, i32 or u32", source);
|
AddError("texture_2d<type>: type must be f32, i32 or u32", source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ bool Validator::MultisampledTexture(const type::MultisampledTexture* t,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t->type()->UnwrapRef()->IsAnyOf<sem::F32, sem::I32, sem::U32>()) {
|
if (!t->type()->UnwrapRef()->IsAnyOf<type::F32, type::I32, type::U32>()) {
|
||||||
AddError("texture_multisampled_2d<type>: type must be f32, i32 or u32", source);
|
AddError("texture_multisampled_2d<type>: type must be f32, i32 or u32", source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty,
|
||||||
|
|
||||||
// Among three host-shareable address spaces, f16 is supported in "uniform" and
|
// Among three host-shareable address spaces, f16 is supported in "uniform" and
|
||||||
// "storage" address space, but not "push_constant" address space yet.
|
// "storage" address space, but not "push_constant" address space yet.
|
||||||
if (Is<sem::F16>(type::Type::DeepestElementOf(store_ty)) &&
|
if (Is<type::F16>(type::Type::DeepestElementOf(store_ty)) &&
|
||||||
address_space == ast::AddressSpace::kPushConstant) {
|
address_space == ast::AddressSpace::kPushConstant) {
|
||||||
AddError("using f16 types in 'push_constant' address space is not implemented yet", source);
|
AddError("using f16 types in 'push_constant' address space is not implemented yet", source);
|
||||||
return false;
|
return false;
|
||||||
|
@ -764,7 +764,7 @@ bool Validator::Override(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storage_ty->Is<sem::F16>()) {
|
if (storage_ty->Is<type::F16>()) {
|
||||||
AddError("'override' of type f16 is not implemented yet", decl->source);
|
AddError("'override' of type f16 is not implemented yet", decl->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
!(stage == ast::PipelineStage::kFragment && !is_input)) {
|
!(stage == ast::PipelineStage::kFragment && !is_input)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::F32>()) {
|
if (!type->Is<type::F32>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'f32'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'f32'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -892,7 +892,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
!(stage == ast::PipelineStage::kFragment && is_input)) {
|
!(stage == ast::PipelineStage::kFragment && is_input)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::Bool>()) {
|
if (!type->Is<type::Bool>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'bool'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'bool'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
!(stage == ast::PipelineStage::kCompute && is_input)) {
|
!(stage == ast::PipelineStage::kCompute && is_input)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::U32>()) {
|
if (!type->Is<type::U32>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
!(stage == ast::PipelineStage::kVertex && is_input)) {
|
!(stage == ast::PipelineStage::kVertex && is_input)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::U32>()) {
|
if (!type->Is<type::U32>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
if (stage != ast::PipelineStage::kNone && !(stage == ast::PipelineStage::kFragment)) {
|
if (stage != ast::PipelineStage::kNone && !(stage == ast::PipelineStage::kFragment)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::U32>()) {
|
if (!type->Is<type::U32>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -932,7 +932,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
!(stage == ast::PipelineStage::kFragment && is_input)) {
|
!(stage == ast::PipelineStage::kFragment && is_input)) {
|
||||||
is_stage_mismatch = true;
|
is_stage_mismatch = true;
|
||||||
}
|
}
|
||||||
if (!type->Is<sem::U32>()) {
|
if (!type->Is<type::U32>()) {
|
||||||
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -991,7 +991,7 @@ bool Validator::Function(const sem::Function* func, ast::PipelineStage stage) co
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!func->ReturnType()->Is<sem::Void>()) {
|
if (!func->ReturnType()->Is<type::Void>()) {
|
||||||
if (!func->ReturnType()->IsConstructible()) {
|
if (!func->ReturnType()->IsConstructible()) {
|
||||||
AddError("function return type must be a constructible type",
|
AddError("function return type must be a constructible type",
|
||||||
decl->return_type->source);
|
decl->return_type->source);
|
||||||
|
@ -1247,7 +1247,7 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage)
|
||||||
builtins.Clear();
|
builtins.Clear();
|
||||||
locations.Clear();
|
locations.Clear();
|
||||||
|
|
||||||
if (!func->ReturnType()->Is<sem::Void>()) {
|
if (!func->ReturnType()->Is<type::Void>()) {
|
||||||
if (!validate_entry_point_attributes(decl->return_type_attributes, func->ReturnType(),
|
if (!validate_entry_point_attributes(decl->return_type_attributes, func->ReturnType(),
|
||||||
decl->source, ParamOrRetType::kReturnType,
|
decl->source, ParamOrRetType::kReturnType,
|
||||||
func->ReturnLocation())) {
|
func->ReturnLocation())) {
|
||||||
|
@ -1458,7 +1458,7 @@ bool Validator::ForLoopStatement(const sem::ForLoopStatement* stmt) const {
|
||||||
}
|
}
|
||||||
if (auto* cond = stmt->Condition()) {
|
if (auto* cond = stmt->Condition()) {
|
||||||
auto* cond_ty = cond->Type()->UnwrapRef();
|
auto* cond_ty = cond->Type()->UnwrapRef();
|
||||||
if (!cond_ty->Is<sem::Bool>()) {
|
if (!cond_ty->Is<type::Bool>()) {
|
||||||
AddError("for-loop condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
AddError("for-loop condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
||||||
stmt->Condition()->Declaration()->source);
|
stmt->Condition()->Declaration()->source);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1474,7 +1474,7 @@ bool Validator::WhileStatement(const sem::WhileStatement* stmt) const {
|
||||||
}
|
}
|
||||||
if (auto* cond = stmt->Condition()) {
|
if (auto* cond = stmt->Condition()) {
|
||||||
auto* cond_ty = cond->Type()->UnwrapRef();
|
auto* cond_ty = cond->Type()->UnwrapRef();
|
||||||
if (!cond_ty->Is<sem::Bool>()) {
|
if (!cond_ty->Is<type::Bool>()) {
|
||||||
AddError("while condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
AddError("while condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
||||||
stmt->Condition()->Declaration()->source);
|
stmt->Condition()->Declaration()->source);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1486,7 +1486,7 @@ bool Validator::WhileStatement(const sem::WhileStatement* stmt) const {
|
||||||
bool Validator::BreakIfStatement(const sem::BreakIfStatement* stmt,
|
bool Validator::BreakIfStatement(const sem::BreakIfStatement* stmt,
|
||||||
sem::Statement* current_statement) const {
|
sem::Statement* current_statement) const {
|
||||||
auto* cond_ty = stmt->Condition()->Type()->UnwrapRef();
|
auto* cond_ty = stmt->Condition()->Type()->UnwrapRef();
|
||||||
if (!cond_ty->Is<sem::Bool>()) {
|
if (!cond_ty->Is<type::Bool>()) {
|
||||||
AddError("break-if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
AddError("break-if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
||||||
stmt->Condition()->Declaration()->source);
|
stmt->Condition()->Declaration()->source);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1513,7 +1513,7 @@ bool Validator::BreakIfStatement(const sem::BreakIfStatement* stmt,
|
||||||
|
|
||||||
bool Validator::IfStatement(const sem::IfStatement* stmt) const {
|
bool Validator::IfStatement(const sem::IfStatement* stmt) const {
|
||||||
auto* cond_ty = stmt->Condition()->Type()->UnwrapRef();
|
auto* cond_ty = stmt->Condition()->Type()->UnwrapRef();
|
||||||
if (!cond_ty->Is<sem::Bool>()) {
|
if (!cond_ty->Is<type::Bool>()) {
|
||||||
AddError("if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
AddError("if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty),
|
||||||
stmt->Condition()->Declaration()->source);
|
stmt->Condition()->Declaration()->source);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1522,7 +1522,7 @@ bool Validator::IfStatement(const sem::IfStatement* stmt) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Validator::BuiltinCall(const sem::Call* call) const {
|
bool Validator::BuiltinCall(const sem::Call* call) const {
|
||||||
if (call->Type()->Is<sem::Void>()) {
|
if (call->Type()->Is<type::Void>()) {
|
||||||
bool is_call_statement = false;
|
bool is_call_statement = false;
|
||||||
// Some built-in call are not owned by a statement, e.g. a built-in called in global
|
// Some built-in call are not owned by a statement, e.g. a built-in called in global
|
||||||
// variable declaration. Calling no-return-value built-in in these context is invalid as
|
// variable declaration. Calling no-return-value built-in in these context is invalid as
|
||||||
|
@ -1692,7 +1692,7 @@ bool Validator::FunctionCall(const sem::Call* call, sem::Statement* current_stat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call->Type()->Is<sem::Void>()) {
|
if (call->Type()->Is<type::Void>()) {
|
||||||
bool is_call_statement = false;
|
bool is_call_statement = false;
|
||||||
if (auto* call_stmt = As<ast::CallStatement>(call->Stmt()->Declaration())) {
|
if (auto* call_stmt = As<ast::CallStatement>(call->Stmt()->Declaration())) {
|
||||||
if (call_stmt->expr == call->Declaration()) {
|
if (call_stmt->expr == call->Declaration()) {
|
||||||
|
@ -2228,7 +2228,7 @@ bool Validator::SwitchStatement(const ast::SwitchStatement* s) {
|
||||||
auto value = selector->Value()->As<uint32_t>();
|
auto value = selector->Value()->As<uint32_t>();
|
||||||
if (auto added = selectors.Add(value, selector->Declaration()->source); !added) {
|
if (auto added = selectors.Add(value, selector->Declaration()->source); !added) {
|
||||||
AddError("duplicate switch case '" +
|
AddError("duplicate switch case '" +
|
||||||
(decl_ty->IsAnyOf<sem::I32, type::AbstractNumeric>()
|
(decl_ty->IsAnyOf<type::I32, type::AbstractNumeric>()
|
||||||
? std::to_string(i32(value))
|
? std::to_string(i32(value))
|
||||||
: std::to_string(value)) +
|
: std::to_string(value)) +
|
||||||
"'",
|
"'",
|
||||||
|
|
|
@ -24,39 +24,39 @@ namespace {
|
||||||
using ValidatorIsStorableTest = ResolverTest;
|
using ValidatorIsStorableTest = ResolverTest;
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Void) {
|
TEST_F(ValidatorIsStorableTest, Void) {
|
||||||
EXPECT_FALSE(v()->IsStorable(create<sem::Void>()));
|
EXPECT_FALSE(v()->IsStorable(create<type::Void>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Scalar) {
|
TEST_F(ValidatorIsStorableTest, Scalar) {
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Bool>()));
|
EXPECT_TRUE(v()->IsStorable(create<type::Bool>()));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::I32>()));
|
EXPECT_TRUE(v()->IsStorable(create<type::I32>()));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::U32>()));
|
EXPECT_TRUE(v()->IsStorable(create<type::U32>()));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::F32>()));
|
EXPECT_TRUE(v()->IsStorable(create<type::F32>()));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::F16>()));
|
EXPECT_TRUE(v()->IsStorable(create<type::F16>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Vector) {
|
TEST_F(ValidatorIsStorableTest, Vector) {
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::I32>(), 2u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::I32>(), 2u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::I32>(), 3u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::I32>(), 3u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::I32>(), 4u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::I32>(), 4u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::U32>(), 2u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::U32>(), 2u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::U32>(), 3u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::U32>(), 3u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::U32>(), 4u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::U32>(), 4u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F32>(), 2u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F32>(), 2u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F32>(), 3u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F32>(), 3u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F32>(), 4u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F32>(), 4u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F16>(), 2u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F16>(), 2u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F16>(), 3u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F16>(), 3u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<sem::F16>(), 4u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Vector>(create<type::F16>(), 4u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Matrix) {
|
TEST_F(ValidatorIsStorableTest, Matrix) {
|
||||||
auto* vec2_f32 = create<sem::Vector>(create<sem::F32>(), 2u);
|
auto* vec2_f32 = create<sem::Vector>(create<type::F32>(), 2u);
|
||||||
auto* vec3_f32 = create<sem::Vector>(create<sem::F32>(), 3u);
|
auto* vec3_f32 = create<sem::Vector>(create<type::F32>(), 3u);
|
||||||
auto* vec4_f32 = create<sem::Vector>(create<sem::F32>(), 4u);
|
auto* vec4_f32 = create<sem::Vector>(create<type::F32>(), 4u);
|
||||||
auto* vec2_f16 = create<sem::Vector>(create<sem::F16>(), 2u);
|
auto* vec2_f16 = create<sem::Vector>(create<type::F16>(), 2u);
|
||||||
auto* vec3_f16 = create<sem::Vector>(create<sem::F16>(), 3u);
|
auto* vec3_f16 = create<sem::Vector>(create<type::F16>(), 3u);
|
||||||
auto* vec4_f16 = create<sem::Vector>(create<sem::F16>(), 4u);
|
auto* vec4_f16 = create<sem::Vector>(create<type::F16>(), 4u);
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 2u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 2u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 3u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 3u)));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 4u)));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Matrix>(vec2_f32, 4u)));
|
||||||
|
@ -78,25 +78,25 @@ TEST_F(ValidatorIsStorableTest, Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Pointer) {
|
TEST_F(ValidatorIsStorableTest, Pointer) {
|
||||||
auto* ptr = create<sem::Pointer>(create<sem::I32>(), ast::AddressSpace::kPrivate,
|
auto* ptr = create<sem::Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
EXPECT_FALSE(v()->IsStorable(ptr));
|
EXPECT_FALSE(v()->IsStorable(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Atomic) {
|
TEST_F(ValidatorIsStorableTest, Atomic) {
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<sem::I32>())));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<type::I32>())));
|
||||||
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<sem::U32>())));
|
EXPECT_TRUE(v()->IsStorable(create<sem::Atomic>(create<type::U32>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) {
|
TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) {
|
||||||
auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
auto* arr = create<sem::Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u,
|
||||||
20u, 4u, 4u);
|
20u, 4u, 4u);
|
||||||
EXPECT_TRUE(v()->IsStorable(arr));
|
EXPECT_TRUE(v()->IsStorable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, ArrayUnsizedOfStorable) {
|
TEST_F(ValidatorIsStorableTest, ArrayUnsizedOfStorable) {
|
||||||
auto* arr =
|
auto* arr =
|
||||||
create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
create<sem::Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
|
||||||
EXPECT_TRUE(v()->IsStorable(arr));
|
EXPECT_TRUE(v()->IsStorable(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,11 @@ TEST_F(ResolverVariableTest, LocalVar_NoInitializer) {
|
||||||
ASSERT_TRUE(TypeOf(s)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(s)->Is<sem::Reference>());
|
||||||
ASSERT_TRUE(TypeOf(a)->Is<sem::Reference>());
|
ASSERT_TRUE(TypeOf(a)->Is<sem::Reference>());
|
||||||
|
|
||||||
EXPECT_TRUE(TypeOf(i)->As<sem::Reference>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(i)->As<sem::Reference>()->StoreType()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(u)->As<sem::Reference>()->StoreType()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(u)->As<sem::Reference>()->StoreType()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(f)->As<sem::Reference>()->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(f)->As<sem::Reference>()->StoreType()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(h)->As<sem::Reference>()->StoreType()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(h)->As<sem::Reference>()->StoreType()->Is<type::F16>());
|
||||||
EXPECT_TRUE(TypeOf(b)->As<sem::Reference>()->StoreType()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(b)->As<sem::Reference>()->StoreType()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||||
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||||
|
|
||||||
|
@ -156,11 +156,11 @@ TEST_F(ResolverVariableTest, LocalVar_WithInitializer) {
|
||||||
EXPECT_EQ(TypeOf(s)->As<sem::Reference>()->Access(), ast::Access::kReadWrite);
|
EXPECT_EQ(TypeOf(s)->As<sem::Reference>()->Access(), ast::Access::kReadWrite);
|
||||||
EXPECT_EQ(TypeOf(a)->As<sem::Reference>()->Access(), ast::Access::kReadWrite);
|
EXPECT_EQ(TypeOf(a)->As<sem::Reference>()->Access(), ast::Access::kReadWrite);
|
||||||
|
|
||||||
EXPECT_TRUE(TypeOf(i)->As<sem::Reference>()->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(TypeOf(i)->As<sem::Reference>()->StoreType()->Is<type::I32>());
|
||||||
EXPECT_TRUE(TypeOf(u)->As<sem::Reference>()->StoreType()->Is<sem::U32>());
|
EXPECT_TRUE(TypeOf(u)->As<sem::Reference>()->StoreType()->Is<type::U32>());
|
||||||
EXPECT_TRUE(TypeOf(f)->As<sem::Reference>()->StoreType()->Is<sem::F32>());
|
EXPECT_TRUE(TypeOf(f)->As<sem::Reference>()->StoreType()->Is<type::F32>());
|
||||||
EXPECT_TRUE(TypeOf(h)->As<sem::Reference>()->StoreType()->Is<sem::F16>());
|
EXPECT_TRUE(TypeOf(h)->As<sem::Reference>()->StoreType()->Is<type::F16>());
|
||||||
EXPECT_TRUE(TypeOf(b)->As<sem::Reference>()->StoreType()->Is<sem::Bool>());
|
EXPECT_TRUE(TypeOf(b)->As<sem::Reference>()->StoreType()->Is<type::Bool>());
|
||||||
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||||
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||||
|
|
||||||
|
@ -437,15 +437,15 @@ TEST_F(ResolverVariableTest, LocalLet) {
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
// `let` declarations are always of the storage type
|
// `let` declarations are always of the storage type
|
||||||
ASSERT_TRUE(TypeOf(i)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(i)->Is<type::I32>());
|
||||||
ASSERT_TRUE(TypeOf(u)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(u)->Is<type::U32>());
|
||||||
ASSERT_TRUE(TypeOf(f)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(f)->Is<type::F32>());
|
||||||
ASSERT_TRUE(TypeOf(h)->Is<sem::F16>());
|
ASSERT_TRUE(TypeOf(h)->Is<type::F16>());
|
||||||
ASSERT_TRUE(TypeOf(b)->Is<sem::Bool>());
|
ASSERT_TRUE(TypeOf(b)->Is<type::Bool>());
|
||||||
ASSERT_TRUE(TypeOf(s)->Is<sem::Struct>());
|
ASSERT_TRUE(TypeOf(s)->Is<sem::Struct>());
|
||||||
ASSERT_TRUE(TypeOf(a)->Is<sem::Struct>());
|
ASSERT_TRUE(TypeOf(a)->Is<sem::Struct>());
|
||||||
ASSERT_TRUE(TypeOf(p)->Is<sem::Pointer>());
|
ASSERT_TRUE(TypeOf(p)->Is<sem::Pointer>());
|
||||||
ASSERT_TRUE(TypeOf(p)->As<sem::Pointer>()->StoreType()->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(p)->As<sem::Pointer>()->StoreType()->Is<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(Sem().Get(i)->Initializer()->Declaration(), i_c);
|
EXPECT_EQ(Sem().Get(i)->Initializer()->Declaration(), i_c);
|
||||||
EXPECT_EQ(Sem().Get(u)->Initializer()->Declaration(), u_c);
|
EXPECT_EQ(Sem().Get(u)->Initializer()->Declaration(), u_c);
|
||||||
|
@ -913,9 +913,9 @@ TEST_F(ResolverVariableTest, LocalConst_ExplicitType_Decls) {
|
||||||
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
||||||
EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s);
|
EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s);
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c_i32)->Is<type::I32>());
|
||||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(c_u32)->Is<type::U32>());
|
||||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(c_f32)->Is<type::F32>());
|
||||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
||||||
|
@ -971,9 +971,9 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) {
|
||||||
EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32);
|
EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32);
|
||||||
EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s);
|
EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s);
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c_i32)->Is<type::I32>());
|
||||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(c_u32)->Is<type::U32>());
|
||||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(c_f32)->Is<type::F32>());
|
||||||
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
||||||
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
||||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||||
|
@ -1009,7 +1009,7 @@ TEST_F(ResolverVariableTest, LocalConst_PropagateConstValue) {
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c)->Is<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 42_i);
|
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 42_i);
|
||||||
}
|
}
|
||||||
|
@ -1021,7 +1021,7 @@ TEST_F(ResolverVariableTest, LocalConst_ConstEval) {
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c)->Is<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 3_i);
|
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 3_i);
|
||||||
}
|
}
|
||||||
|
@ -1093,9 +1093,9 @@ TEST_F(ResolverVariableTest, GlobalConst_ExplicitType_Decls) {
|
||||||
EXPECT_EQ(Sem().Get(c_vf32)->Declaration(), c_vf32);
|
EXPECT_EQ(Sem().Get(c_vf32)->Declaration(), c_vf32);
|
||||||
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c_i32)->Is<type::I32>());
|
||||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(c_u32)->Is<type::U32>());
|
||||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(c_f32)->Is<type::F32>());
|
||||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vu32)->Is<sem::Vector>());
|
||||||
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vf32)->Is<sem::Vector>());
|
||||||
|
@ -1142,9 +1142,9 @@ TEST_F(ResolverVariableTest, GlobalConst_ImplicitType_Decls) {
|
||||||
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32);
|
||||||
EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32);
|
EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32);
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c_i32)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c_i32)->Is<type::I32>());
|
||||||
ASSERT_TRUE(TypeOf(c_u32)->Is<sem::U32>());
|
ASSERT_TRUE(TypeOf(c_u32)->Is<type::U32>());
|
||||||
ASSERT_TRUE(TypeOf(c_f32)->Is<sem::F32>());
|
ASSERT_TRUE(TypeOf(c_f32)->Is<type::F32>());
|
||||||
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
ASSERT_TRUE(TypeOf(c_ai)->Is<type::AbstractInt>());
|
||||||
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
ASSERT_TRUE(TypeOf(c_af)->Is<type::AbstractFloat>());
|
||||||
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
ASSERT_TRUE(TypeOf(c_vi32)->Is<sem::Vector>());
|
||||||
|
@ -1176,7 +1176,7 @@ TEST_F(ResolverVariableTest, GlobalConst_PropagateConstValue) {
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c)->Is<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 42_i);
|
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 42_i);
|
||||||
}
|
}
|
||||||
|
@ -1186,7 +1186,7 @@ TEST_F(ResolverVariableTest, GlobalConst_ConstEval) {
|
||||||
|
|
||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
ASSERT_TRUE(TypeOf(c)->Is<sem::I32>());
|
ASSERT_TRUE(TypeOf(c)->Is<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 3_i);
|
EXPECT_EQ(Sem().Get(c)->ConstantValue()->As<i32>(), 3_i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,22 @@ namespace {
|
||||||
using ArrayTest = TestHelper;
|
using ArrayTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(ArrayTest, CreateSizedArray) {
|
TEST_F(ArrayTest, CreateSizedArray) {
|
||||||
auto* a = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
auto* a =
|
||||||
auto* b = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* c = create<Array>(create<U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
auto* b =
|
||||||
auto* d = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* e = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
auto* c =
|
||||||
auto* f = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
||||||
auto* g = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
auto* d =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
||||||
|
auto* e =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
||||||
|
auto* f =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
||||||
|
auto* g =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
||||||
|
|
||||||
EXPECT_EQ(a->ElemType(), create<U32>());
|
EXPECT_EQ(a->ElemType(), create<type::U32>());
|
||||||
EXPECT_EQ(a->Count(), create<type::ConstantArrayCount>(2u));
|
EXPECT_EQ(a->Count(), create<type::ConstantArrayCount>(2u));
|
||||||
EXPECT_EQ(a->Align(), 4u);
|
EXPECT_EQ(a->Align(), 4u);
|
||||||
EXPECT_EQ(a->Size(), 8u);
|
EXPECT_EQ(a->Size(), 8u);
|
||||||
|
@ -47,14 +54,20 @@ TEST_F(ArrayTest, CreateSizedArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, CreateRuntimeArray) {
|
TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||||
auto* a = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
|
auto* a =
|
||||||
auto* b = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
|
||||||
auto* c = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 5u, 8u, 32u, 32u);
|
auto* b =
|
||||||
auto* d = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 9u, 32u, 32u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
|
||||||
auto* e = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 32u);
|
auto* c =
|
||||||
auto* f = create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 17u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 5u, 8u, 32u, 32u);
|
||||||
|
auto* d =
|
||||||
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 9u, 32u, 32u);
|
||||||
|
auto* e =
|
||||||
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 32u);
|
||||||
|
auto* f =
|
||||||
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 17u);
|
||||||
|
|
||||||
EXPECT_EQ(a->ElemType(), create<U32>());
|
EXPECT_EQ(a->ElemType(), create<type::U32>());
|
||||||
EXPECT_EQ(a->Count(), create<type::RuntimeArrayCount>());
|
EXPECT_EQ(a->Count(), create<type::RuntimeArrayCount>());
|
||||||
EXPECT_EQ(a->Align(), 4u);
|
EXPECT_EQ(a->Align(), 4u);
|
||||||
EXPECT_EQ(a->Size(), 8u);
|
EXPECT_EQ(a->Size(), 8u);
|
||||||
|
@ -71,13 +84,20 @@ TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, Hash) {
|
TEST_F(ArrayTest, Hash) {
|
||||||
auto* a = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
auto* a =
|
||||||
auto* b = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* c = create<Array>(create<U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
auto* b =
|
||||||
auto* d = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* e = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
auto* c =
|
||||||
auto* f = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
||||||
auto* g = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
auto* d =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
||||||
|
auto* e =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
||||||
|
auto* f =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
||||||
|
auto* g =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -88,13 +108,20 @@ TEST_F(ArrayTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, Equals) {
|
TEST_F(ArrayTest, Equals) {
|
||||||
auto* a = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
auto* a =
|
||||||
auto* b = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* c = create<Array>(create<U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
auto* b =
|
||||||
auto* d = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* e = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
auto* c =
|
||||||
auto* f = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
|
||||||
auto* g = create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
auto* d =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
|
||||||
|
auto* e =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
|
||||||
|
auto* f =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
|
||||||
|
auto* g =
|
||||||
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
|
@ -102,38 +129,42 @@ TEST_F(ArrayTest, Equals) {
|
||||||
EXPECT_FALSE(a->Equals(*e));
|
EXPECT_FALSE(a->Equals(*e));
|
||||||
EXPECT_FALSE(a->Equals(*f));
|
EXPECT_FALSE(a->Equals(*f));
|
||||||
EXPECT_FALSE(a->Equals(*g));
|
EXPECT_FALSE(a->Equals(*g));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
|
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
|
||||||
auto* arr = create<Array>(create<I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 4u, 4u);
|
auto* arr =
|
||||||
|
create<Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 4u, 4u);
|
||||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32>");
|
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, FriendlyNameStaticSized) {
|
TEST_F(ArrayTest, FriendlyNameStaticSized) {
|
||||||
auto* arr = create<Array>(create<I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 4u, 4u);
|
auto* arr =
|
||||||
|
create<Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 4u, 4u);
|
||||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32, 5>");
|
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32, 5>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) {
|
TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) {
|
||||||
auto* arr = create<Array>(create<I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 8u, 4u);
|
auto* arr =
|
||||||
|
create<Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 8u, 4u);
|
||||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32>");
|
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
|
TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
|
||||||
auto* arr = create<Array>(create<I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 8u, 4u);
|
auto* arr =
|
||||||
|
create<Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 8u, 4u);
|
||||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
|
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArrayTest, IsConstructable) {
|
TEST_F(ArrayTest, IsConstructable) {
|
||||||
auto* fixed_sized =
|
auto* fixed_sized =
|
||||||
create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* named_override_sized = create<Array>(
|
auto* named_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* unnamed_override_sized = create<Array>(
|
auto* unnamed_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* runtime_sized =
|
auto* runtime_sized =
|
||||||
create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
||||||
|
|
||||||
EXPECT_TRUE(fixed_sized->IsConstructible());
|
EXPECT_TRUE(fixed_sized->IsConstructible());
|
||||||
EXPECT_FALSE(named_override_sized->IsConstructible());
|
EXPECT_FALSE(named_override_sized->IsConstructible());
|
||||||
|
@ -143,13 +174,13 @@ TEST_F(ArrayTest, IsConstructable) {
|
||||||
|
|
||||||
TEST_F(ArrayTest, HasCreationFixedFootprint) {
|
TEST_F(ArrayTest, HasCreationFixedFootprint) {
|
||||||
auto* fixed_sized =
|
auto* fixed_sized =
|
||||||
create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* named_override_sized = create<Array>(
|
auto* named_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* unnamed_override_sized = create<Array>(
|
auto* unnamed_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* runtime_sized =
|
auto* runtime_sized =
|
||||||
create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
||||||
|
|
||||||
EXPECT_TRUE(fixed_sized->HasCreationFixedFootprint());
|
EXPECT_TRUE(fixed_sized->HasCreationFixedFootprint());
|
||||||
EXPECT_FALSE(named_override_sized->HasCreationFixedFootprint());
|
EXPECT_FALSE(named_override_sized->HasCreationFixedFootprint());
|
||||||
|
@ -159,13 +190,13 @@ TEST_F(ArrayTest, HasCreationFixedFootprint) {
|
||||||
|
|
||||||
TEST_F(ArrayTest, HasFixedFootprint) {
|
TEST_F(ArrayTest, HasFixedFootprint) {
|
||||||
auto* fixed_sized =
|
auto* fixed_sized =
|
||||||
create<Array>(create<U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
|
||||||
auto* named_override_sized = create<Array>(
|
auto* named_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* unnamed_override_sized = create<Array>(
|
auto* unnamed_override_sized = create<Array>(
|
||||||
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
|
||||||
auto* runtime_sized =
|
auto* runtime_sized =
|
||||||
create<Array>(create<U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
|
||||||
|
|
||||||
EXPECT_TRUE(fixed_sized->HasFixedFootprint());
|
EXPECT_TRUE(fixed_sized->HasFixedFootprint());
|
||||||
EXPECT_TRUE(named_override_sized->HasFixedFootprint());
|
EXPECT_TRUE(named_override_sized->HasFixedFootprint());
|
||||||
|
|
|
@ -22,33 +22,33 @@ namespace {
|
||||||
using AtomicTest = TestHelper;
|
using AtomicTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(AtomicTest, Creation) {
|
TEST_F(AtomicTest, Creation) {
|
||||||
auto* a = create<Atomic>(create<I32>());
|
auto* a = create<Atomic>(create<type::I32>());
|
||||||
auto* b = create<Atomic>(create<I32>());
|
auto* b = create<Atomic>(create<type::I32>());
|
||||||
auto* c = create<Atomic>(create<U32>());
|
auto* c = create<Atomic>(create<type::U32>());
|
||||||
EXPECT_TRUE(a->Type()->Is<sem::I32>());
|
EXPECT_TRUE(a->Type()->Is<type::I32>());
|
||||||
EXPECT_EQ(a, b);
|
EXPECT_EQ(a, b);
|
||||||
EXPECT_NE(a, c);
|
EXPECT_NE(a, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AtomicTest, Hash) {
|
TEST_F(AtomicTest, Hash) {
|
||||||
auto* a = create<Atomic>(create<I32>());
|
auto* a = create<Atomic>(create<type::I32>());
|
||||||
auto* b = create<Atomic>(create<I32>());
|
auto* b = create<Atomic>(create<type::I32>());
|
||||||
auto* c = create<Atomic>(create<U32>());
|
auto* c = create<Atomic>(create<type::U32>());
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AtomicTest, Equals) {
|
TEST_F(AtomicTest, Equals) {
|
||||||
auto* a = create<Atomic>(create<I32>());
|
auto* a = create<Atomic>(create<type::I32>());
|
||||||
auto* b = create<Atomic>(create<I32>());
|
auto* b = create<Atomic>(create<type::I32>());
|
||||||
auto* c = create<Atomic>(create<U32>());
|
auto* c = create<Atomic>(create<type::U32>());
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AtomicTest, FriendlyName) {
|
TEST_F(AtomicTest, FriendlyName) {
|
||||||
auto* a = create<Atomic>(create<I32>());
|
auto* a = create<Atomic>(create<type::I32>());
|
||||||
EXPECT_EQ(a->FriendlyName(Symbols()), "atomic<i32>");
|
EXPECT_EQ(a->FriendlyName(Symbols()), "atomic<i32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ class MockConstant : public sem::Constant {
|
||||||
using ExpressionTest = TestHelper;
|
using ExpressionTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(ExpressionTest, UnwrapMaterialize) {
|
TEST_F(ExpressionTest, UnwrapMaterialize) {
|
||||||
MockConstant c(create<I32>());
|
MockConstant c(create<type::I32>());
|
||||||
auto* a = create<Expression>(/* declaration */ nullptr, create<I32>(),
|
auto* a = create<Expression>(/* declaration */ nullptr, create<type::I32>(),
|
||||||
sem::EvaluationStage::kRuntime, /* statement */ nullptr,
|
sem::EvaluationStage::kRuntime, /* statement */ nullptr,
|
||||||
/* constant_value */ nullptr,
|
/* constant_value */ nullptr,
|
||||||
/* has_side_effects */ false, /* root_ident */ nullptr);
|
/* has_side_effects */ false, /* root_ident */ nullptr);
|
||||||
|
|
|
@ -21,13 +21,13 @@ namespace {
|
||||||
using MatrixTest = TestHelper;
|
using MatrixTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(MatrixTest, Creation) {
|
TEST_F(MatrixTest, Creation) {
|
||||||
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
|
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
|
||||||
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
|
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
|
||||||
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
|
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
|
||||||
|
|
||||||
EXPECT_EQ(a->type(), create<I32>());
|
EXPECT_EQ(a->type(), create<type::I32>());
|
||||||
EXPECT_EQ(a->rows(), 3u);
|
EXPECT_EQ(a->rows(), 3u);
|
||||||
EXPECT_EQ(a->columns(), 4u);
|
EXPECT_EQ(a->columns(), 4u);
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ TEST_F(MatrixTest, Creation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MatrixTest, Hash) {
|
TEST_F(MatrixTest, Hash) {
|
||||||
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
|
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
|
||||||
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
|
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
|
||||||
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
|
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -51,21 +51,21 @@ TEST_F(MatrixTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MatrixTest, Equals) {
|
TEST_F(MatrixTest, Equals) {
|
||||||
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
|
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
|
||||||
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
|
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
|
||||||
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
|
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
|
||||||
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
|
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(*e));
|
EXPECT_FALSE(a->Equals(*e));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MatrixTest, FriendlyName) {
|
TEST_F(MatrixTest, FriendlyName) {
|
||||||
I32 i32;
|
type::I32 i32;
|
||||||
Vector c{&i32, 3};
|
Vector c{&i32, 3};
|
||||||
Matrix m{&c, 2};
|
Matrix m{&c, 2};
|
||||||
EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3<i32>");
|
EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3<i32>");
|
||||||
|
|
|
@ -21,13 +21,17 @@ namespace {
|
||||||
using PointerTest = TestHelper;
|
using PointerTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(PointerTest, Creation) {
|
TEST_F(PointerTest, Creation) {
|
||||||
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* a =
|
||||||
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* b =
|
||||||
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* c =
|
||||||
|
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
|
auto* d =
|
||||||
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
||||||
|
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_TRUE(a->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(a->StoreType()->Is<type::I32>());
|
||||||
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
|
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
|
||||||
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
|
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
|
||||||
|
|
||||||
|
@ -38,11 +42,15 @@ TEST_F(PointerTest, Creation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PointerTest, Hash) {
|
TEST_F(PointerTest, Hash) {
|
||||||
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* a =
|
||||||
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* b =
|
||||||
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* c =
|
||||||
|
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
|
auto* d =
|
||||||
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
||||||
|
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -51,26 +59,31 @@ TEST_F(PointerTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PointerTest, Equals) {
|
TEST_F(PointerTest, Equals) {
|
||||||
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* a =
|
||||||
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
auto* b =
|
||||||
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* c =
|
||||||
|
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
||||||
|
auto* d =
|
||||||
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
||||||
|
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(*e));
|
EXPECT_FALSE(a->Equals(*e));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PointerTest, FriendlyName) {
|
TEST_F(PointerTest, FriendlyName) {
|
||||||
auto* r = create<Pointer>(create<I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
|
auto* r = create<Pointer>(create<type::I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
|
||||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
|
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
|
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
|
||||||
auto* r = create<Pointer>(create<I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
|
auto* r =
|
||||||
|
create<Pointer>(create<type::I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
|
||||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
|
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,18 @@ namespace {
|
||||||
using ReferenceTest = TestHelper;
|
using ReferenceTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(ReferenceTest, Creation) {
|
TEST_F(ReferenceTest, Creation) {
|
||||||
auto* a =
|
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* b =
|
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* c =
|
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* d =
|
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* e =
|
||||||
|
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_TRUE(a->StoreType()->Is<sem::I32>());
|
EXPECT_TRUE(a->StoreType()->Is<type::I32>());
|
||||||
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
|
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
|
||||||
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
|
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
|
||||||
|
|
||||||
|
@ -42,15 +43,16 @@ TEST_F(ReferenceTest, Creation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReferenceTest, Hash) {
|
TEST_F(ReferenceTest, Hash) {
|
||||||
auto* a =
|
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* b =
|
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* c =
|
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* d =
|
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* e =
|
||||||
|
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -59,30 +61,32 @@ TEST_F(ReferenceTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReferenceTest, Equals) {
|
TEST_F(ReferenceTest, Equals) {
|
||||||
auto* a =
|
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* b =
|
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* c =
|
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
|
||||||
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* d =
|
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
|
||||||
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
|
ast::Access::kReadWrite);
|
||||||
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
auto* e =
|
||||||
|
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(*e));
|
EXPECT_FALSE(a->Equals(*e));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReferenceTest, FriendlyName) {
|
TEST_F(ReferenceTest, FriendlyName) {
|
||||||
auto* r = create<Reference>(create<I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
|
auto* r = create<Reference>(create<type::I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
|
||||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
|
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
|
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
|
||||||
auto* r = create<Reference>(create<I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
|
auto* r =
|
||||||
|
create<Reference>(create<type::I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
|
||||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
|
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ TEST_F(StructTest, Equals) {
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*a));
|
EXPECT_TRUE(a->Equals(*a));
|
||||||
EXPECT_FALSE(a->Equals(*b));
|
EXPECT_FALSE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StructTest, FriendlyName) {
|
TEST_F(StructTest, FriendlyName) {
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace {
|
||||||
using VectorTest = TestHelper;
|
using VectorTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(VectorTest, Creation) {
|
TEST_F(VectorTest, Creation) {
|
||||||
auto* a = create<Vector>(create<I32>(), 2u);
|
auto* a = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* b = create<Vector>(create<I32>(), 2u);
|
auto* b = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* c = create<Vector>(create<F32>(), 2u);
|
auto* c = create<Vector>(create<type::F32>(), 2u);
|
||||||
auto* d = create<Vector>(create<F32>(), 3u);
|
auto* d = create<Vector>(create<type::F32>(), 3u);
|
||||||
|
|
||||||
EXPECT_EQ(a->type(), create<I32>());
|
EXPECT_EQ(a->type(), create<type::I32>());
|
||||||
EXPECT_EQ(a->Width(), 2u);
|
EXPECT_EQ(a->Width(), 2u);
|
||||||
|
|
||||||
EXPECT_EQ(a, b);
|
EXPECT_EQ(a, b);
|
||||||
|
@ -35,10 +35,10 @@ TEST_F(VectorTest, Creation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VectorTest, Hash) {
|
TEST_F(VectorTest, Hash) {
|
||||||
auto* a = create<Vector>(create<I32>(), 2u);
|
auto* a = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* b = create<Vector>(create<I32>(), 2u);
|
auto* b = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* c = create<Vector>(create<F32>(), 2u);
|
auto* c = create<Vector>(create<type::F32>(), 2u);
|
||||||
auto* d = create<Vector>(create<F32>(), 3u);
|
auto* d = create<Vector>(create<type::F32>(), 3u);
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -46,19 +46,19 @@ TEST_F(VectorTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VectorTest, Equals) {
|
TEST_F(VectorTest, Equals) {
|
||||||
auto* a = create<Vector>(create<I32>(), 2u);
|
auto* a = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* b = create<Vector>(create<I32>(), 2u);
|
auto* b = create<Vector>(create<type::I32>(), 2u);
|
||||||
auto* c = create<Vector>(create<F32>(), 2u);
|
auto* c = create<Vector>(create<type::F32>(), 2u);
|
||||||
auto* d = create<Vector>(create<F32>(), 3u);
|
auto* d = create<Vector>(create<type::F32>(), 3u);
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VectorTest, FriendlyName) {
|
TEST_F(VectorTest, FriendlyName) {
|
||||||
auto* f32 = create<F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* v = create<Vector>(f32, 3u);
|
auto* v = create<Vector>(f32, 3u);
|
||||||
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
|
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,11 +244,11 @@
|
||||||
<DisplayString>AbstractFloat</DisplayString>
|
<DisplayString>AbstractFloat</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
<Type Name="tint::sem::Bool">
|
<Type Name="tint::type::Bool">
|
||||||
<DisplayString>bool</DisplayString>
|
<DisplayString>bool</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
<Type Name="tint::sem::F32">
|
<Type Name="tint::type::F32">
|
||||||
<DisplayString>f32</DisplayString>
|
<DisplayString>f32</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,7 @@ struct BuiltinPolyfill::State {
|
||||||
uint32_t width = WidthOf(ty);
|
uint32_t width = WidthOf(ty);
|
||||||
|
|
||||||
// Currently in WGSL parameters of insertBits must be i32, u32, vecN<i32> or vecN<u32>
|
// Currently in WGSL parameters of insertBits must be i32, u32, vecN<i32> or vecN<u32>
|
||||||
if (!type::Type::DeepestElementOf(ty)->IsAnyOf<sem::I32, sem::U32>()) {
|
if (!type::Type::DeepestElementOf(ty)->IsAnyOf<type::I32, type::U32>()) {
|
||||||
TINT_ICE(Transform, b.Diagnostics())
|
TINT_ICE(Transform, b.Diagnostics())
|
||||||
<< "insertBits polyfill only support i32, u32, and vector of i32 or u32, got "
|
<< "insertBits polyfill only support i32, u32, and vector of i32 or u32, got "
|
||||||
<< b.FriendlyName(ty);
|
<< b.FriendlyName(ty);
|
||||||
|
@ -895,7 +895,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
|
||||||
auto& sig = builtin->Signature();
|
auto& sig = builtin->Signature();
|
||||||
auto* tex = sig.Parameter(sem::ParameterUsage::kTexture);
|
auto* tex = sig.Parameter(sem::ParameterUsage::kTexture);
|
||||||
if (auto* stex = tex->Type()->As<type::SampledTexture>()) {
|
if (auto* stex = tex->Type()->As<type::SampledTexture>()) {
|
||||||
if (stex->type()->Is<sem::F32>()) {
|
if (stex->type()->Is<type::F32>()) {
|
||||||
fn = builtin_polyfills.GetOrCreate(builtin, [&] {
|
fn = builtin_polyfills.GetOrCreate(builtin, [&] {
|
||||||
return s.textureSampleBaseClampToEdge_2d_f32();
|
return s.textureSampleBaseClampToEdge_2d_f32();
|
||||||
});
|
});
|
||||||
|
|
|
@ -396,7 +396,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
AddOutput(name, member->Type(), member->Location(), std::move(attributes),
|
AddOutput(name, member->Type(), member->Location(), std::move(attributes),
|
||||||
ctx.dst->MemberAccessor(original_result, name));
|
ctx.dst->MemberAccessor(original_result, name));
|
||||||
}
|
}
|
||||||
} else if (!inner_ret_type->Is<sem::Void>()) {
|
} else if (!inner_ret_type->Is<type::Void>()) {
|
||||||
auto attributes =
|
auto attributes =
|
||||||
CloneShaderIOAttributes(func_ast->return_type_attributes, do_interpolate);
|
CloneShaderIOAttributes(func_ast->return_type_attributes, do_interpolate);
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
|
|
||||||
// No existing sample mask builtin was found, so create a new output value
|
// No existing sample mask builtin was found, so create a new output value
|
||||||
// using the fixed sample mask.
|
// using the fixed sample mask.
|
||||||
AddOutput("fixed_sample_mask", ctx.dst->create<sem::U32>(), std::nullopt,
|
AddOutput("fixed_sample_mask", ctx.dst->create<type::U32>(), std::nullopt,
|
||||||
{ctx.dst->Builtin(ast::BuiltinValue::kSampleMask)},
|
{ctx.dst->Builtin(ast::BuiltinValue::kSampleMask)},
|
||||||
ctx.dst->Expr(u32(cfg.fixed_sample_mask)));
|
ctx.dst->Expr(u32(cfg.fixed_sample_mask)));
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
/// Add a point size builtin to the wrapper function output.
|
/// Add a point size builtin to the wrapper function output.
|
||||||
void AddVertexPointSize() {
|
void AddVertexPointSize() {
|
||||||
// Create a new output value and assign it a literal 1.0 value.
|
// Create a new output value and assign it a literal 1.0 value.
|
||||||
AddOutput("vertex_point_size", ctx.dst->create<sem::F32>(), std::nullopt,
|
AddOutput("vertex_point_size", ctx.dst->create<type::F32>(), std::nullopt,
|
||||||
{ctx.dst->Builtin(ast::BuiltinValue::kPointSize)}, ctx.dst->Expr(1_f));
|
{ctx.dst->Builtin(ast::BuiltinValue::kPointSize)}, ctx.dst->Expr(1_f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit early if there is no shader IO to handle.
|
// Exit early if there is no shader IO to handle.
|
||||||
if (func_sem->Parameters().Length() == 0 && func_sem->ReturnType()->Is<sem::Void>() &&
|
if (func_sem->Parameters().Length() == 0 && func_sem->ReturnType()->Is<type::Void>() &&
|
||||||
!needs_fixed_sample_mask && !needs_vertex_point_size &&
|
!needs_fixed_sample_mask && !needs_vertex_point_size &&
|
||||||
cfg.shader_style != ShaderStyle::kGlsl) {
|
cfg.shader_style != ShaderStyle::kGlsl) {
|
||||||
return;
|
return;
|
||||||
|
@ -604,7 +604,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
|
|
||||||
// Process the return type, and start building the wrapper function body.
|
// Process the return type, and start building the wrapper function body.
|
||||||
std::function<const ast::Type*()> wrapper_ret_type = [&] { return ctx.dst->ty.void_(); };
|
std::function<const ast::Type*()> wrapper_ret_type = [&] { return ctx.dst->ty.void_(); };
|
||||||
if (func_sem->ReturnType()->Is<sem::Void>()) {
|
if (func_sem->ReturnType()->Is<type::Void>()) {
|
||||||
// The function call is just a statement with no result.
|
// The function call is just a statement with no result.
|
||||||
wrapper_body.Push(ctx.dst->CallStmt(call_inner));
|
wrapper_body.Push(ctx.dst->CallStmt(call_inner));
|
||||||
} else {
|
} else {
|
||||||
|
@ -760,7 +760,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||||
case ast::BuiltinValue::kInstanceIndex:
|
case ast::BuiltinValue::kInstanceIndex:
|
||||||
case ast::BuiltinValue::kSampleIndex:
|
case ast::BuiltinValue::kSampleIndex:
|
||||||
case ast::BuiltinValue::kSampleMask:
|
case ast::BuiltinValue::kSampleMask:
|
||||||
type = ctx.dst->create<sem::I32>();
|
type = ctx.dst->create<type::I32>();
|
||||||
value = ctx.dst->Bitcast(CreateASTTypeFor(ctx, type), value);
|
value = ctx.dst->Bitcast(CreateASTTypeFor(ctx, type), value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct OffsetExpr : Offset {
|
||||||
const ast::Expression* Build(CloneContext& ctx) const override {
|
const ast::Expression* Build(CloneContext& ctx) const override {
|
||||||
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapRef();
|
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapRef();
|
||||||
auto* res = ctx.Clone(expr);
|
auto* res = ctx.Clone(expr);
|
||||||
if (!type->Is<sem::U32>()) {
|
if (!type->Is<type::U32>()) {
|
||||||
res = ctx.dst->Construct<u32>(res);
|
res = ctx.dst->Construct<u32>(res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -141,74 +141,74 @@ struct AtomicKey {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IntrinsicDataTypeFor(const type::Type* ty, DecomposeMemoryAccess::Intrinsic::DataType& out) {
|
bool IntrinsicDataTypeFor(const type::Type* ty, DecomposeMemoryAccess::Intrinsic::DataType& out) {
|
||||||
if (ty->Is<sem::I32>()) {
|
if (ty->Is<type::I32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kI32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kI32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::U32>()) {
|
if (ty->Is<type::U32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kU32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kU32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::F32>()) {
|
if (ty->Is<type::F32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kF32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kF32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::F16>()) {
|
if (ty->Is<type::F16>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kF16;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kF16;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (auto* vec = ty->As<sem::Vector>()) {
|
if (auto* vec = ty->As<sem::Vector>()) {
|
||||||
switch (vec->Width()) {
|
switch (vec->Width()) {
|
||||||
case 2:
|
case 2:
|
||||||
if (vec->type()->Is<sem::I32>()) {
|
if (vec->type()->Is<type::I32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2I32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2I32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::U32>()) {
|
if (vec->type()->Is<type::U32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2U32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2U32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F32>()) {
|
if (vec->type()->Is<type::F32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F16>()) {
|
if (vec->type()->Is<type::F16>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F16;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F16;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (vec->type()->Is<sem::I32>()) {
|
if (vec->type()->Is<type::I32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3I32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3I32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::U32>()) {
|
if (vec->type()->Is<type::U32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3U32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3U32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F32>()) {
|
if (vec->type()->Is<type::F32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F16>()) {
|
if (vec->type()->Is<type::F16>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F16;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F16;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (vec->type()->Is<sem::I32>()) {
|
if (vec->type()->Is<type::I32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4I32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4I32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::U32>()) {
|
if (vec->type()->Is<type::U32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4U32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4U32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F32>()) {
|
if (vec->type()->Is<type::F32>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F32;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F32;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (vec->type()->Is<sem::F16>()) {
|
if (vec->type()->Is<type::F16>()) {
|
||||||
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F16;
|
out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F16;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -573,7 +573,7 @@ struct DirectVariableAccess::State {
|
||||||
if (!idx->UnwrapMaterialize()
|
if (!idx->UnwrapMaterialize()
|
||||||
->Type()
|
->Type()
|
||||||
->UnwrapRef()
|
->UnwrapRef()
|
||||||
->IsAnyOf<sem::U32, type::AbstractInt>()) {
|
->IsAnyOf<type::U32, type::AbstractInt>()) {
|
||||||
expr = b.Construct(b.ty.u32(), expr);
|
expr = b.Construct(b.ty.u32(), expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,8 @@ struct SpirvAtomic::State {
|
||||||
const ast::Type* AtomicTypeFor(const type::Type* ty) {
|
const ast::Type* AtomicTypeFor(const type::Type* ty) {
|
||||||
return Switch(
|
return Switch(
|
||||||
ty, //
|
ty, //
|
||||||
[&](const sem::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
|
[&](const type::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
|
||||||
[&](const sem::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
|
[&](const type::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
|
||||||
[&](const sem::Struct* str) { return b.ty.type_name(Fork(str->Declaration()).name); },
|
[&](const sem::Struct* str) { return b.ty.type_name(Fork(str->Declaration()).name); },
|
||||||
[&](const sem::Array* arr) -> const ast::Type* {
|
[&](const sem::Array* arr) -> const ast::Type* {
|
||||||
if (arr->Count()->Is<type::RuntimeArrayCount>()) {
|
if (arr->Count()->Is<type::RuntimeArrayCount>()) {
|
||||||
|
|
|
@ -645,8 +645,8 @@ struct Std140::State {
|
||||||
return "mat" + std::to_string(mat->columns()) + "x" + std::to_string(mat->rows()) +
|
return "mat" + std::to_string(mat->columns()) + "x" + std::to_string(mat->rows()) +
|
||||||
"_" + ConvertSuffix(mat->type());
|
"_" + ConvertSuffix(mat->type());
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) { return "f32"; }, //
|
[&](const type::F32*) { return "f32"; }, //
|
||||||
[&](const sem::F16*) { return "f16"; },
|
[&](const type::F16*) { return "f16"; },
|
||||||
[&](Default) {
|
[&](Default) {
|
||||||
TINT_ICE(Transform, b.Diagnostics())
|
TINT_ICE(Transform, b.Diagnostics())
|
||||||
<< "unhandled type for conversion name: " << src->FriendlyName(ty);
|
<< "unhandled type for conversion name: " << src->FriendlyName(ty);
|
||||||
|
|
|
@ -81,11 +81,11 @@ Transform::ApplyResult SubstituteOverride::Apply(const Program* src,
|
||||||
auto value = iter->second;
|
auto value = iter->second;
|
||||||
auto* ctor = Switch(
|
auto* ctor = Switch(
|
||||||
sem->Type(),
|
sem->Type(),
|
||||||
[&](const sem::Bool*) { return b.Expr(!std::equal_to<double>()(value, 0.0)); },
|
[&](const type::Bool*) { return b.Expr(!std::equal_to<double>()(value, 0.0)); },
|
||||||
[&](const sem::I32*) { return b.Expr(i32(value)); },
|
[&](const type::I32*) { return b.Expr(i32(value)); },
|
||||||
[&](const sem::U32*) { return b.Expr(u32(value)); },
|
[&](const type::U32*) { return b.Expr(u32(value)); },
|
||||||
[&](const sem::F32*) { return b.Expr(f32(value)); },
|
[&](const type::F32*) { return b.Expr(f32(value)); },
|
||||||
[&](const sem::F16*) { return b.Expr(f16(value)); });
|
[&](const type::F16*) { return b.Expr(f16(value)); });
|
||||||
|
|
||||||
if (!ctor) {
|
if (!ctor) {
|
||||||
b.Diagnostics().add_error(diag::System::Transform,
|
b.Diagnostics().add_error(diag::System::Transform,
|
||||||
|
|
|
@ -74,22 +74,22 @@ void Transform::RemoveStatement(CloneContext& ctx, const ast::Statement* stmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type* ty) {
|
const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type* ty) {
|
||||||
if (ty->Is<sem::Void>()) {
|
if (ty->Is<type::Void>()) {
|
||||||
return ctx.dst->create<ast::Void>();
|
return ctx.dst->create<ast::Void>();
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::I32>()) {
|
if (ty->Is<type::I32>()) {
|
||||||
return ctx.dst->create<ast::I32>();
|
return ctx.dst->create<ast::I32>();
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::U32>()) {
|
if (ty->Is<type::U32>()) {
|
||||||
return ctx.dst->create<ast::U32>();
|
return ctx.dst->create<ast::U32>();
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::F16>()) {
|
if (ty->Is<type::F16>()) {
|
||||||
return ctx.dst->create<ast::F16>();
|
return ctx.dst->create<ast::F16>();
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::F32>()) {
|
if (ty->Is<type::F32>()) {
|
||||||
return ctx.dst->create<ast::F32>();
|
return ctx.dst->create<ast::F32>();
|
||||||
}
|
}
|
||||||
if (ty->Is<sem::Bool>()) {
|
if (ty->Is<type::Bool>()) {
|
||||||
return ctx.dst->create<ast::Bool>();
|
return ctx.dst->create<ast::Bool>();
|
||||||
}
|
}
|
||||||
if (auto* m = ty->As<sem::Matrix>()) {
|
if (auto* m = ty->As<sem::Matrix>()) {
|
||||||
|
|
|
@ -41,16 +41,16 @@ struct CreateASTTypeForTest : public testing::Test, public Transform {
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CreateASTTypeForTest, Basic) {
|
TEST_F(CreateASTTypeForTest, Basic) {
|
||||||
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<sem::I32>(); })->Is<ast::I32>());
|
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::I32>(); })->Is<ast::I32>());
|
||||||
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<sem::U32>(); })->Is<ast::U32>());
|
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::U32>(); })->Is<ast::U32>());
|
||||||
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<sem::F32>(); })->Is<ast::F32>());
|
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::F32>(); })->Is<ast::F32>());
|
||||||
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<sem::Bool>(); })->Is<ast::Bool>());
|
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::Bool>(); })->Is<ast::Bool>());
|
||||||
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<sem::Void>(); })->Is<ast::Void>());
|
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::Void>(); })->Is<ast::Void>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CreateASTTypeForTest, Matrix) {
|
TEST_F(CreateASTTypeForTest, Matrix) {
|
||||||
auto* mat = create([](ProgramBuilder& b) {
|
auto* mat = create([](ProgramBuilder& b) {
|
||||||
auto* column_type = b.create<sem::Vector>(b.create<sem::F32>(), 2u);
|
auto* column_type = b.create<sem::Vector>(b.create<type::F32>(), 2u);
|
||||||
return b.create<sem::Matrix>(column_type, 3u);
|
return b.create<sem::Matrix>(column_type, 3u);
|
||||||
});
|
});
|
||||||
ASSERT_TRUE(mat->Is<ast::Matrix>());
|
ASSERT_TRUE(mat->Is<ast::Matrix>());
|
||||||
|
@ -61,7 +61,7 @@ TEST_F(CreateASTTypeForTest, Matrix) {
|
||||||
|
|
||||||
TEST_F(CreateASTTypeForTest, Vector) {
|
TEST_F(CreateASTTypeForTest, Vector) {
|
||||||
auto* vec =
|
auto* vec =
|
||||||
create([](ProgramBuilder& b) { return b.create<sem::Vector>(b.create<sem::F32>(), 2u); });
|
create([](ProgramBuilder& b) { return b.create<sem::Vector>(b.create<type::F32>(), 2u); });
|
||||||
ASSERT_TRUE(vec->Is<ast::Vector>());
|
ASSERT_TRUE(vec->Is<ast::Vector>());
|
||||||
ASSERT_TRUE(vec->As<ast::Vector>()->type->Is<ast::F32>());
|
ASSERT_TRUE(vec->As<ast::Vector>()->type->Is<ast::F32>());
|
||||||
ASSERT_EQ(vec->As<ast::Vector>()->width, 2u);
|
ASSERT_EQ(vec->As<ast::Vector>()->width, 2u);
|
||||||
|
@ -69,7 +69,7 @@ TEST_F(CreateASTTypeForTest, Vector) {
|
||||||
|
|
||||||
TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
||||||
auto* arr = create([](ProgramBuilder& b) {
|
auto* arr = create([](ProgramBuilder& b) {
|
||||||
return b.create<sem::Array>(b.create<sem::F32>(), b.create<type::ConstantArrayCount>(2u),
|
return b.create<sem::Array>(b.create<type::F32>(), b.create<type::ConstantArrayCount>(2u),
|
||||||
4u, 4u, 32u, 32u);
|
4u, 4u, 32u, 32u);
|
||||||
});
|
});
|
||||||
ASSERT_TRUE(arr->Is<ast::Array>());
|
ASSERT_TRUE(arr->Is<ast::Array>());
|
||||||
|
@ -83,7 +83,7 @@ TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
||||||
|
|
||||||
TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) {
|
TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) {
|
||||||
auto* arr = create([](ProgramBuilder& b) {
|
auto* arr = create([](ProgramBuilder& b) {
|
||||||
return b.create<sem::Array>(b.create<sem::F32>(), b.create<type::ConstantArrayCount>(2u),
|
return b.create<sem::Array>(b.create<type::F32>(), b.create<type::ConstantArrayCount>(2u),
|
||||||
4u, 4u, 64u, 32u);
|
4u, 4u, 64u, 32u);
|
||||||
});
|
});
|
||||||
ASSERT_TRUE(arr->Is<ast::Array>());
|
ASSERT_TRUE(arr->Is<ast::Array>());
|
||||||
|
|
|
@ -153,16 +153,16 @@ bool IsTypeCompatible(AttributeWGSLType wgslType, VertexFormatType vertexFormatT
|
||||||
AttributeWGSLType WGSLTypeOf(const type::Type* ty) {
|
AttributeWGSLType WGSLTypeOf(const type::Type* ty) {
|
||||||
return Switch(
|
return Switch(
|
||||||
ty,
|
ty,
|
||||||
[](const sem::I32*) -> AttributeWGSLType {
|
[](const type::I32*) -> AttributeWGSLType {
|
||||||
return {BaseWGSLType::kI32, 1};
|
return {BaseWGSLType::kI32, 1};
|
||||||
},
|
},
|
||||||
[](const sem::U32*) -> AttributeWGSLType {
|
[](const type::U32*) -> AttributeWGSLType {
|
||||||
return {BaseWGSLType::kU32, 1};
|
return {BaseWGSLType::kU32, 1};
|
||||||
},
|
},
|
||||||
[](const sem::F32*) -> AttributeWGSLType {
|
[](const type::F32*) -> AttributeWGSLType {
|
||||||
return {BaseWGSLType::kF32, 1};
|
return {BaseWGSLType::kF32, 1};
|
||||||
},
|
},
|
||||||
[](const sem::F16*) -> AttributeWGSLType {
|
[](const type::F16*) -> AttributeWGSLType {
|
||||||
return {BaseWGSLType::kF16, 1};
|
return {BaseWGSLType::kF16, 1};
|
||||||
},
|
},
|
||||||
[](const sem::Vector* vec) -> AttributeWGSLType {
|
[](const sem::Vector* vec) -> AttributeWGSLType {
|
||||||
|
|
|
@ -411,7 +411,7 @@ struct ZeroInitWorkgroupMemory::State {
|
||||||
// Constant value could not be found. Build expression instead.
|
// Constant value could not be found. Build expression instead.
|
||||||
workgroup_size_expr = [this, expr, size = workgroup_size_expr] {
|
workgroup_size_expr = [this, expr, size = workgroup_size_expr] {
|
||||||
auto* e = ctx.Clone(expr);
|
auto* e = ctx.Clone(expr);
|
||||||
if (ctx.src->TypeOf(expr)->UnwrapRef()->Is<sem::I32>()) {
|
if (ctx.src->TypeOf(expr)->UnwrapRef()->Is<type::I32>()) {
|
||||||
e = b.Construct<u32>(e);
|
e = b.Construct<u32>(e);
|
||||||
}
|
}
|
||||||
return size ? b.Mul(size(), e) : e;
|
return size ? b.Mul(size(), e) : e;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,13 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/bool.h"
|
#include "src/tint/type/bool.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::Bool);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::Bool);
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
Bool::Bool()
|
Bool::Bool()
|
||||||
: Base(type::TypeFlags{
|
: Base(type::TypeFlags{
|
||||||
|
@ -51,4 +51,4 @@ uint32_t Bool::Align() const {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,8 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_BOOL_H_
|
#ifndef SRC_TINT_TYPE_BOOL_H_
|
||||||
#define SRC_TINT_SEM_BOOL_H_
|
#define SRC_TINT_TYPE_BOOL_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
#undef Bool
|
#undef Bool
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A boolean type
|
/// A boolean type
|
||||||
class Bool final : public Castable<Bool, type::Type> {
|
class Bool final : public Castable<Bool, type::Type> {
|
||||||
|
@ -59,6 +59,6 @@ class Bool final : public Castable<Bool, type::Type> {
|
||||||
uint32_t Align() const override;
|
uint32_t Align() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_BOOL_H_
|
#endif // SRC_TINT_TYPE_BOOL_H_
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using BoolTest = TestHelper;
|
using BoolTest = TestHelper;
|
||||||
|
@ -45,4 +45,4 @@ TEST_F(BoolTest, FriendlyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -44,7 +44,7 @@ TEST_F(DepthMultisampledTextureTest, Equals) {
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*a));
|
EXPECT_TRUE(a->Equals(*a));
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthMultisampledTextureTest, Dim) {
|
TEST_F(DepthMultisampledTextureTest, Dim) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(DepthTextureTest, Equals) {
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DepthTextureTest, IsTexture) {
|
TEST_F(DepthTextureTest, IsTexture) {
|
||||||
|
|
|
@ -41,11 +41,11 @@ TEST_F(ExternalTextureTest, Equals) {
|
||||||
auto* a = create<ExternalTexture>();
|
auto* a = create<ExternalTexture>();
|
||||||
auto* b = create<ExternalTexture>();
|
auto* b = create<ExternalTexture>();
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ExternalTextureTest, IsTexture) {
|
TEST_F(ExternalTextureTest, IsTexture) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
ExternalTexture s;
|
ExternalTexture s;
|
||||||
Texture* ty = &s;
|
Texture* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
|
@ -56,7 +56,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ExternalTextureTest, Dim) {
|
TEST_F(ExternalTextureTest, Dim) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
ExternalTexture s;
|
ExternalTexture s;
|
||||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/f16.h"
|
#include "src/tint/type/f16.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::F16);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::F16);
|
||||||
|
|
||||||
namespace tint {
|
namespace tint::type {
|
||||||
namespace sem {
|
|
||||||
|
|
||||||
F16::F16()
|
F16::F16()
|
||||||
: Base(type::TypeFlags{
|
: Base(type::TypeFlags{
|
||||||
|
@ -52,5 +51,4 @@ uint32_t F16::Align() const {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sem
|
} // namespace tint::type
|
||||||
} // namespace tint
|
|
|
@ -12,14 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_F16_H_
|
#ifndef SRC_TINT_TYPE_F16_H_
|
||||||
#define SRC_TINT_SEM_F16_H_
|
#define SRC_TINT_TYPE_F16_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A float 16 type
|
/// A float 16 type
|
||||||
class F16 final : public Castable<F16, type::Type> {
|
class F16 final : public Castable<F16, type::Type> {
|
||||||
|
@ -49,6 +49,6 @@ class F16 final : public Castable<F16, type::Type> {
|
||||||
uint32_t Align() const override;
|
uint32_t Align() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_F16_H_
|
#endif // SRC_TINT_TYPE_F16_H_
|
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using F16Test = TestHelper;
|
using F16Test = TestHelper;
|
||||||
|
@ -45,4 +45,4 @@ TEST_F(F16Test, FriendlyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,13 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/f32.h"
|
#include "src/tint/type/f32.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::F32);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::F32);
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
F32::F32()
|
F32::F32()
|
||||||
: Base(type::TypeFlags{
|
: Base(type::TypeFlags{
|
||||||
|
@ -51,4 +51,4 @@ uint32_t F32::Align() const {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,14 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_F32_H_
|
#ifndef SRC_TINT_TYPE_F32_H_
|
||||||
#define SRC_TINT_SEM_F32_H_
|
#define SRC_TINT_TYPE_F32_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A float 32 type
|
/// A float 32 type
|
||||||
class F32 final : public Castable<F32, type::Type> {
|
class F32 final : public Castable<F32, type::Type> {
|
||||||
|
@ -49,6 +49,6 @@ class F32 final : public Castable<F32, type::Type> {
|
||||||
uint32_t Align() const override;
|
uint32_t Align() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_F32_H_
|
#endif // SRC_TINT_TYPE_F32_H_
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using F32Test = TestHelper;
|
using F32Test = TestHelper;
|
||||||
|
@ -45,4 +45,4 @@ TEST_F(F32Test, FriendlyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,13 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/i32.h"
|
#include "src/tint/type/i32.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::I32);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::I32);
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
I32::I32()
|
I32::I32()
|
||||||
: Base(type::TypeFlags{
|
: Base(type::TypeFlags{
|
||||||
|
@ -51,4 +51,4 @@ uint32_t I32::Align() const {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,14 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_I32_H_
|
#ifndef SRC_TINT_TYPE_I32_H_
|
||||||
#define SRC_TINT_SEM_I32_H_
|
#define SRC_TINT_TYPE_I32_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A signed int 32 type.
|
/// A signed int 32 type.
|
||||||
class I32 final : public Castable<I32, type::Type> {
|
class I32 final : public Castable<I32, type::Type> {
|
||||||
|
@ -49,6 +49,6 @@ class I32 final : public Castable<I32, type::Type> {
|
||||||
uint32_t Align() const override;
|
uint32_t Align() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_I32_H_
|
#endif // SRC_TINT_TYPE_I32_H_
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using I32Test = TestHelper;
|
using I32Test = TestHelper;
|
||||||
|
@ -45,4 +45,4 @@ TEST_F(I32Test, FriendlyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -26,38 +26,38 @@ namespace {
|
||||||
using MultisampledTextureTest = TestHelper;
|
using MultisampledTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Creation) {
|
TEST_F(MultisampledTextureTest, Creation) {
|
||||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
|
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
|
||||||
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
|
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
|
||||||
EXPECT_EQ(a, b);
|
EXPECT_EQ(a, b);
|
||||||
EXPECT_NE(a, c);
|
EXPECT_NE(a, c);
|
||||||
EXPECT_NE(a, d);
|
EXPECT_NE(a, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Hash) {
|
TEST_F(MultisampledTextureTest, Hash) {
|
||||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
|
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
|
||||||
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
|
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
EXPECT_NE(a->Hash(), d->Hash());
|
EXPECT_NE(a->Hash(), d->Hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Equals) {
|
TEST_F(MultisampledTextureTest, Equals) {
|
||||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<sem::F32>());
|
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
|
||||||
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<sem::I32>());
|
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, IsTexture) {
|
TEST_F(MultisampledTextureTest, IsTexture) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
|
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Texture* ty = &s;
|
Texture* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
|
@ -68,19 +68,19 @@ TEST_F(MultisampledTextureTest, IsTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Dim) {
|
TEST_F(MultisampledTextureTest, Dim) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, Type) {
|
TEST_F(MultisampledTextureTest, Type) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type(), &f32);
|
EXPECT_EQ(s.type(), &f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MultisampledTextureTest, FriendlyName) {
|
TEST_F(MultisampledTextureTest, FriendlyName) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ namespace {
|
||||||
using SampledTextureTest = TestHelper;
|
using SampledTextureTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Creation) {
|
TEST_F(SampledTextureTest, Creation) {
|
||||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
|
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
|
||||||
|
|
||||||
EXPECT_TRUE(a->type()->Is<sem::F32>());
|
EXPECT_TRUE(a->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
||||||
|
|
||||||
EXPECT_EQ(a, b);
|
EXPECT_EQ(a, b);
|
||||||
|
@ -39,10 +39,10 @@ TEST_F(SampledTextureTest, Creation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Hash) {
|
TEST_F(SampledTextureTest, Hash) {
|
||||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
|
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
|
||||||
|
|
||||||
EXPECT_EQ(a->Hash(), b->Hash());
|
EXPECT_EQ(a->Hash(), b->Hash());
|
||||||
EXPECT_NE(a->Hash(), c->Hash());
|
EXPECT_NE(a->Hash(), c->Hash());
|
||||||
|
@ -50,19 +50,19 @@ TEST_F(SampledTextureTest, Hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Equals) {
|
TEST_F(SampledTextureTest, Equals) {
|
||||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::F32>());
|
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
|
||||||
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<sem::F32>());
|
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
|
||||||
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<sem::I32>());
|
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, IsTexture) {
|
TEST_F(SampledTextureTest, IsTexture) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
SampledTexture s(ast::TextureDimension::kCube, &f32);
|
SampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||||
Texture* ty = &s;
|
Texture* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||||
|
@ -72,19 +72,19 @@ TEST_F(SampledTextureTest, IsTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Dim) {
|
TEST_F(SampledTextureTest, Dim) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, Type) {
|
TEST_F(SampledTextureTest, Type) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.type(), &f32);
|
EXPECT_EQ(s.type(), &f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SampledTextureTest, FriendlyName) {
|
TEST_F(SampledTextureTest, FriendlyName) {
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||||
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
|
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(SamplerTest, Equals) {
|
||||||
|
|
||||||
EXPECT_TRUE(a->Equals(*b));
|
EXPECT_TRUE(a->Equals(*b));
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SamplerTest, FriendlyNameSampler) {
|
TEST_F(SamplerTest, FriendlyNameSampler) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
|
||||||
case ast::TexelFormat::kRg32Uint:
|
case ast::TexelFormat::kRg32Uint:
|
||||||
case ast::TexelFormat::kRgba16Uint:
|
case ast::TexelFormat::kRgba16Uint:
|
||||||
case ast::TexelFormat::kRgba32Uint: {
|
case ast::TexelFormat::kRgba32Uint: {
|
||||||
return type_mgr.Get<sem::U32>();
|
return type_mgr.Get<type::U32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ast::TexelFormat::kR32Sint:
|
case ast::TexelFormat::kR32Sint:
|
||||||
|
@ -63,7 +63,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
|
||||||
case ast::TexelFormat::kRg32Sint:
|
case ast::TexelFormat::kRg32Sint:
|
||||||
case ast::TexelFormat::kRgba16Sint:
|
case ast::TexelFormat::kRgba16Sint:
|
||||||
case ast::TexelFormat::kRgba32Sint: {
|
case ast::TexelFormat::kRgba32Sint: {
|
||||||
return type_mgr.Get<sem::I32>();
|
return type_mgr.Get<type::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ast::TexelFormat::kRgba8Unorm:
|
case ast::TexelFormat::kRgba8Unorm:
|
||||||
|
@ -72,7 +72,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
|
||||||
case ast::TexelFormat::kRg32Float:
|
case ast::TexelFormat::kRg32Float:
|
||||||
case ast::TexelFormat::kRgba16Float:
|
case ast::TexelFormat::kRgba16Float:
|
||||||
case ast::TexelFormat::kRgba32Float: {
|
case ast::TexelFormat::kRgba32Float: {
|
||||||
return type_mgr.Get<sem::F32>();
|
return type_mgr.Get<type::F32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ast::TexelFormat::kUndefined:
|
case ast::TexelFormat::kUndefined:
|
||||||
|
|
|
@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Creation) {
|
||||||
auto* e =
|
auto* e =
|
||||||
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
||||||
|
|
||||||
EXPECT_TRUE(a->type()->Is<sem::F32>());
|
EXPECT_TRUE(a->type()->Is<type::F32>());
|
||||||
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
||||||
|
|
||||||
EXPECT_EQ(a, b);
|
EXPECT_EQ(a, b);
|
||||||
|
@ -84,7 +84,7 @@ TEST_F(StorageTextureTest, Equals) {
|
||||||
EXPECT_FALSE(a->Equals(*c));
|
EXPECT_FALSE(a->Equals(*c));
|
||||||
EXPECT_FALSE(a->Equals(*d));
|
EXPECT_FALSE(a->Equals(*d));
|
||||||
EXPECT_FALSE(a->Equals(*e));
|
EXPECT_FALSE(a->Equals(*e));
|
||||||
EXPECT_FALSE(a->Equals(sem::Void{}));
|
EXPECT_FALSE(a->Equals(type::Void{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, Dim) {
|
TEST_F(StorageTextureTest, Dim) {
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(StorageTextureTest, F32) {
|
||||||
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
||||||
ASSERT_TRUE(s->Is<Texture>());
|
ASSERT_TRUE(s->Is<Texture>());
|
||||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||||
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::F32>());
|
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, U32) {
|
TEST_F(StorageTextureTest, U32) {
|
||||||
|
@ -128,7 +128,7 @@ TEST_F(StorageTextureTest, U32) {
|
||||||
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
||||||
ASSERT_TRUE(s->Is<Texture>());
|
ASSERT_TRUE(s->Is<Texture>());
|
||||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||||
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::U32>());
|
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StorageTextureTest, I32) {
|
TEST_F(StorageTextureTest, I32) {
|
||||||
|
@ -142,7 +142,7 @@ TEST_F(StorageTextureTest, I32) {
|
||||||
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
|
||||||
ASSERT_TRUE(s->Is<Texture>());
|
ASSERT_TRUE(s->Is<Texture>());
|
||||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||||
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -24,7 +24,7 @@ using TextureTypeDimTest = TestParamHelper<ast::TextureDimension>;
|
||||||
|
|
||||||
TEST_P(TextureTypeDimTest, DimMustMatch) {
|
TEST_P(TextureTypeDimTest, DimMustMatch) {
|
||||||
// Check that the dim() query returns the right dimensionality.
|
// Check that the dim() query returns the right dimensionality.
|
||||||
sem::F32 f32;
|
type::F32 f32;
|
||||||
// TextureType is an abstract class, so use concrete class
|
// TextureType is an abstract class, so use concrete class
|
||||||
// SampledTexture in its stead.
|
// SampledTexture in its stead.
|
||||||
SampledTexture st(GetParam(), &f32);
|
SampledTexture st(GetParam(), &f32);
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/pointer.h"
|
#include "src/tint/sem/pointer.h"
|
||||||
#include "src/tint/sem/reference.h"
|
#include "src/tint/sem/reference.h"
|
||||||
#include "src/tint/sem/struct.h"
|
#include "src/tint/sem/struct.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
#include "src/tint/type/abstract_float.h"
|
#include "src/tint/type/abstract_float.h"
|
||||||
#include "src/tint/type/abstract_int.h"
|
#include "src/tint/type/abstract_int.h"
|
||||||
|
#include "src/tint/type/bool.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/type/sampler.h"
|
#include "src/tint/type/sampler.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::type::Type);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::Type);
|
||||||
|
|
||||||
|
@ -69,15 +69,15 @@ uint32_t Type::Align() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_scalar() const {
|
bool Type::is_scalar() const {
|
||||||
return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, type::AbstractNumeric, sem::Bool>();
|
return IsAnyOf<type::F16, type::F32, type::U32, type::I32, type::AbstractNumeric, type::Bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_numeric_scalar() const {
|
bool Type::is_numeric_scalar() const {
|
||||||
return IsAnyOf<sem::F16, sem::F32, sem::U32, sem::I32, type::AbstractNumeric>();
|
return IsAnyOf<type::F16, type::F32, type::U32, type::I32, type::AbstractNumeric>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_float_scalar() const {
|
bool Type::is_float_scalar() const {
|
||||||
return IsAnyOf<sem::F16, sem::F32, type::AbstractNumeric>();
|
return IsAnyOf<type::F16, type::F32, type::AbstractNumeric>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_float_matrix() const {
|
bool Type::is_float_matrix() const {
|
||||||
|
@ -103,32 +103,32 @@ bool Type::is_float_scalar_or_vector_or_matrix() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_integer_scalar() const {
|
bool Type::is_integer_scalar() const {
|
||||||
return IsAnyOf<sem::U32, sem::I32>();
|
return IsAnyOf<type::U32, type::I32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_signed_integer_scalar() const {
|
bool Type::is_signed_integer_scalar() const {
|
||||||
return IsAnyOf<sem::I32, type::AbstractInt>();
|
return IsAnyOf<type::I32, type::AbstractInt>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_unsigned_integer_scalar() const {
|
bool Type::is_unsigned_integer_scalar() const {
|
||||||
return Is<sem::U32>();
|
return Is<type::U32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_signed_integer_vector() const {
|
bool Type::is_signed_integer_vector() const {
|
||||||
return Is(
|
return Is(
|
||||||
[](const sem::Vector* v) { return v->type()->IsAnyOf<sem::I32, type::AbstractInt>(); });
|
[](const sem::Vector* v) { return v->type()->IsAnyOf<type::I32, type::AbstractInt>(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_unsigned_integer_vector() const {
|
bool Type::is_unsigned_integer_vector() const {
|
||||||
return Is([](const sem::Vector* v) { return v->type()->Is<sem::U32>(); });
|
return Is([](const sem::Vector* v) { return v->type()->Is<type::U32>(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_unsigned_integer_scalar_or_vector() const {
|
bool Type::is_unsigned_integer_scalar_or_vector() const {
|
||||||
return Is<sem::U32>() || is_unsigned_integer_vector();
|
return Is<type::U32>() || is_unsigned_integer_vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_signed_integer_scalar_or_vector() const {
|
bool Type::is_signed_integer_scalar_or_vector() const {
|
||||||
return IsAnyOf<sem::I32, type::AbstractInt>() || is_signed_integer_vector();
|
return IsAnyOf<type::I32, type::AbstractInt>() || is_signed_integer_vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_integer_scalar_or_vector() const {
|
bool Type::is_integer_scalar_or_vector() const {
|
||||||
|
@ -152,11 +152,11 @@ bool Type::is_abstract_float_scalar_or_vector() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_bool_vector() const {
|
bool Type::is_bool_vector() const {
|
||||||
return Is([](const sem::Vector* v) { return v->type()->Is<sem::Bool>(); });
|
return Is([](const sem::Vector* v) { return v->type()->Is<type::Bool>(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_bool_scalar_or_vector() const {
|
bool Type::is_bool_scalar_or_vector() const {
|
||||||
return Is<sem::Bool>() || is_bool_vector();
|
return Is<type::Bool>() || is_bool_vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_numeric_vector() const {
|
bool Type::is_numeric_vector() const {
|
||||||
|
@ -200,19 +200,19 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) {
|
||||||
from,
|
from,
|
||||||
[&](const type::AbstractFloat*) {
|
[&](const type::AbstractFloat*) {
|
||||||
return Switch(
|
return Switch(
|
||||||
to, //
|
to, //
|
||||||
[&](const sem::F32*) { return 1; }, //
|
[&](const type::F32*) { return 1; }, //
|
||||||
[&](const sem::F16*) { return 2; }, //
|
[&](const type::F16*) { return 2; }, //
|
||||||
[&](Default) { return kNoConversion; });
|
[&](Default) { return kNoConversion; });
|
||||||
},
|
},
|
||||||
[&](const type::AbstractInt*) {
|
[&](const type::AbstractInt*) {
|
||||||
return Switch(
|
return Switch(
|
||||||
to, //
|
to, //
|
||||||
[&](const sem::I32*) { return 3; }, //
|
[&](const type::I32*) { return 3; }, //
|
||||||
[&](const sem::U32*) { return 4; }, //
|
[&](const type::U32*) { return 4; }, //
|
||||||
[&](const type::AbstractFloat*) { return 5; }, //
|
[&](const type::AbstractFloat*) { return 5; }, //
|
||||||
[&](const sem::F32*) { return 6; }, //
|
[&](const type::F32*) { return 6; }, //
|
||||||
[&](const sem::F16*) { return 7; }, //
|
[&](const type::F16*) { return 7; }, //
|
||||||
[&](Default) { return kNoConversion; });
|
[&](Default) { return kNoConversion; });
|
||||||
},
|
},
|
||||||
[&](const sem::Vector* from_vec) {
|
[&](const sem::Vector* from_vec) {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "src/tint/type/type_manager.h"
|
#include "src/tint/type/type_manager.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/tint/sem/i32.h"
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/sem/u32.h"
|
#include "src/tint/type/u32.h"
|
||||||
|
|
||||||
namespace tint::type {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -35,51 +35,51 @@ using TypeManagerTest = testing::Test;
|
||||||
|
|
||||||
TEST_F(TypeManagerTest, GetUnregistered) {
|
TEST_F(TypeManagerTest, GetUnregistered) {
|
||||||
TypeManager tm;
|
TypeManager tm;
|
||||||
auto* t = tm.Get<sem::I32>();
|
auto* t = tm.Get<type::I32>();
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
EXPECT_TRUE(t->Is<sem::I32>());
|
EXPECT_TRUE(t->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
|
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
|
||||||
TypeManager tm;
|
TypeManager tm;
|
||||||
auto* t = tm.Get<sem::I32>();
|
auto* t = tm.Get<type::I32>();
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
EXPECT_TRUE(t->Is<sem::I32>());
|
EXPECT_TRUE(t->Is<type::I32>());
|
||||||
|
|
||||||
auto* t2 = tm.Get<sem::I32>();
|
auto* t2 = tm.Get<type::I32>();
|
||||||
EXPECT_EQ(t, t2);
|
EXPECT_EQ(t, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
||||||
TypeManager tm;
|
TypeManager tm;
|
||||||
type::Type* t = tm.Get<sem::I32>();
|
type::Type* t = tm.Get<type::I32>();
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
EXPECT_TRUE(t->Is<sem::I32>());
|
EXPECT_TRUE(t->Is<type::I32>());
|
||||||
|
|
||||||
type::Type* t2 = tm.Get<sem::U32>();
|
type::Type* t2 = tm.Get<type::U32>();
|
||||||
ASSERT_NE(t2, nullptr);
|
ASSERT_NE(t2, nullptr);
|
||||||
EXPECT_NE(t, t2);
|
EXPECT_NE(t, t2);
|
||||||
EXPECT_TRUE(t2->Is<sem::U32>());
|
EXPECT_TRUE(t2->Is<type::U32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypeManagerTest, Find) {
|
TEST_F(TypeManagerTest, Find) {
|
||||||
TypeManager tm;
|
TypeManager tm;
|
||||||
auto* created = tm.Get<sem::I32>();
|
auto* created = tm.Get<type::I32>();
|
||||||
|
|
||||||
EXPECT_EQ(tm.Find<sem::U32>(), nullptr);
|
EXPECT_EQ(tm.Find<type::U32>(), nullptr);
|
||||||
EXPECT_EQ(tm.Find<sem::I32>(), created);
|
EXPECT_EQ(tm.Find<type::I32>(), created);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypeManagerTest, WrapDoesntAffectInner) {
|
TEST_F(TypeManagerTest, WrapDoesntAffectInner) {
|
||||||
TypeManager inner;
|
TypeManager inner;
|
||||||
TypeManager outer = TypeManager::Wrap(inner);
|
TypeManager outer = TypeManager::Wrap(inner);
|
||||||
|
|
||||||
inner.Get<sem::I32>();
|
inner.Get<type::I32>();
|
||||||
|
|
||||||
EXPECT_EQ(count(inner), 1u);
|
EXPECT_EQ(count(inner), 1u);
|
||||||
EXPECT_EQ(count(outer), 0u);
|
EXPECT_EQ(count(outer), 0u);
|
||||||
|
|
||||||
outer.Get<sem::U32>();
|
outer.Get<type::U32>();
|
||||||
|
|
||||||
EXPECT_EQ(count(inner), 1u);
|
EXPECT_EQ(count(inner), 1u);
|
||||||
EXPECT_EQ(count(outer), 1u);
|
EXPECT_EQ(count(outer), 1u);
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/reference.h"
|
#include "src/tint/sem/reference.h"
|
||||||
#include "src/tint/type/abstract_float.h"
|
#include "src/tint/type/abstract_float.h"
|
||||||
#include "src/tint/type/abstract_int.h"
|
#include "src/tint/type/abstract_int.h"
|
||||||
#include "src/tint/type/array_count.h"
|
#include "src/tint/type/array_count.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
#include "src/tint/type/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
|
|
||||||
namespace tint::type {
|
namespace tint::type {
|
||||||
|
@ -25,10 +25,10 @@ namespace {
|
||||||
struct TypeTest : public TestHelper {
|
struct TypeTest : public TestHelper {
|
||||||
const type::AbstractFloat* af = create<type::AbstractFloat>();
|
const type::AbstractFloat* af = create<type::AbstractFloat>();
|
||||||
const type::AbstractInt* ai = create<type::AbstractInt>();
|
const type::AbstractInt* ai = create<type::AbstractInt>();
|
||||||
const sem::F32* f32 = create<sem::F32>();
|
const type::F32* f32 = create<type::F32>();
|
||||||
const sem::F16* f16 = create<sem::F16>();
|
const type::F16* f16 = create<type::F16>();
|
||||||
const sem::I32* i32 = create<sem::I32>();
|
const type::I32* i32 = create<type::I32>();
|
||||||
const sem::U32* u32 = create<sem::U32>();
|
const type::U32* u32 = create<type::U32>();
|
||||||
const sem::Vector* vec2_f32 = create<sem::Vector>(f32, 2u);
|
const sem::Vector* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||||
const sem::Vector* vec3_f32 = create<sem::Vector>(f32, 3u);
|
const sem::Vector* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||||
const sem::Vector* vec3_f16 = create<sem::Vector>(f16, 3u);
|
const sem::Vector* vec3_f16 = create<sem::Vector>(f16, 3u);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,13 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/u32.h"
|
#include "src/tint/type/u32.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::U32);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::U32);
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
U32::U32()
|
U32::U32()
|
||||||
: Base(type::TypeFlags{
|
: Base(type::TypeFlags{
|
||||||
|
@ -51,4 +51,4 @@ uint32_t U32::Align() const {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,14 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_U32_H_
|
#ifndef SRC_TINT_TYPE_U32_H_
|
||||||
#define SRC_TINT_SEM_U32_H_
|
#define SRC_TINT_TYPE_U32_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A unsigned int 32 type.
|
/// A unsigned int 32 type.
|
||||||
class U32 final : public Castable<U32, type::Type> {
|
class U32 final : public Castable<U32, type::Type> {
|
||||||
|
@ -49,6 +49,6 @@ class U32 final : public Castable<U32, type::Type> {
|
||||||
uint32_t Align() const override;
|
uint32_t Align() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_U32_H_
|
#endif // SRC_TINT_TYPE_U32_H_
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/test_helper.h"
|
#include "src/tint/type/test_helper.h"
|
||||||
#include "src/tint/type/texture.h"
|
#include "src/tint/type/texture.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using U32Test = TestHelper;
|
using U32Test = TestHelper;
|
||||||
|
@ -45,4 +45,4 @@ TEST_F(U32Test, FriendlyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,13 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/void.h"
|
#include "src/tint/type/void.h"
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::Void);
|
TINT_INSTANTIATE_TYPEINFO(tint::type::Void);
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
Void::Void() : Base(type::TypeFlags{}) {}
|
Void::Void() : Base(type::TypeFlags{}) {}
|
||||||
|
|
||||||
|
@ -38,4 +38,4 @@ std::string Void::FriendlyName(const SymbolTable&) const {
|
||||||
return "void";
|
return "void";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -12,14 +12,14 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_VOID_H_
|
#ifndef SRC_TINT_TYPE_VOID_H_
|
||||||
#define SRC_TINT_SEM_VOID_H_
|
#define SRC_TINT_TYPE_VOID_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::type {
|
||||||
|
|
||||||
/// A void type
|
/// A void type
|
||||||
class Void final : public Castable<Void, type::Type> {
|
class Void final : public Castable<Void, type::Type> {
|
||||||
|
@ -43,6 +43,6 @@ class Void final : public Castable<Void, type::Type> {
|
||||||
std::string FriendlyName(const SymbolTable& symbols) const override;
|
std::string FriendlyName(const SymbolTable& symbols) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::type
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_VOID_H_
|
#endif // SRC_TINT_TYPE_VOID_H_
|
|
@ -46,13 +46,13 @@ VectorInitializerInfo AsVectorInitializer(const sem::Expression* expr) {
|
||||||
|
|
||||||
const sem::Expression* Zero(ProgramBuilder& b, const type::Type* ty, const sem::Statement* stmt) {
|
const sem::Expression* Zero(ProgramBuilder& b, const type::Type* ty, const sem::Statement* stmt) {
|
||||||
const ast::Expression* expr = nullptr;
|
const ast::Expression* expr = nullptr;
|
||||||
if (ty->Is<sem::I32>()) {
|
if (ty->Is<type::I32>()) {
|
||||||
expr = b.Expr(0_i);
|
expr = b.Expr(0_i);
|
||||||
} else if (ty->Is<sem::U32>()) {
|
} else if (ty->Is<type::U32>()) {
|
||||||
expr = b.Expr(0_u);
|
expr = b.Expr(0_u);
|
||||||
} else if (ty->Is<sem::F32>()) {
|
} else if (ty->Is<type::F32>()) {
|
||||||
expr = b.Expr(0_f);
|
expr = b.Expr(0_f);
|
||||||
} else if (ty->Is<sem::Bool>()) {
|
} else if (ty->Is<type::Bool>()) {
|
||||||
expr = b.Expr(false);
|
expr = b.Expr(false);
|
||||||
} else {
|
} else {
|
||||||
TINT_UNREACHABLE(Writer, b.Diagnostics())
|
TINT_UNREACHABLE(Writer, b.Diagnostics())
|
||||||
|
@ -85,13 +85,13 @@ const sem::Call* AppendVector(ProgramBuilder* b,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ast::Type* packed_el_ast_ty = nullptr;
|
const ast::Type* packed_el_ast_ty = nullptr;
|
||||||
if (packed_el_sem_ty->Is<sem::I32>()) {
|
if (packed_el_sem_ty->Is<type::I32>()) {
|
||||||
packed_el_ast_ty = b->create<ast::I32>();
|
packed_el_ast_ty = b->create<ast::I32>();
|
||||||
} else if (packed_el_sem_ty->Is<sem::U32>()) {
|
} else if (packed_el_sem_ty->Is<type::U32>()) {
|
||||||
packed_el_ast_ty = b->create<ast::U32>();
|
packed_el_ast_ty = b->create<ast::U32>();
|
||||||
} else if (packed_el_sem_ty->Is<sem::F32>()) {
|
} else if (packed_el_sem_ty->Is<type::F32>()) {
|
||||||
packed_el_ast_ty = b->create<ast::F32>();
|
packed_el_ast_ty = b->create<ast::F32>();
|
||||||
} else if (packed_el_sem_ty->Is<sem::Bool>()) {
|
} else if (packed_el_sem_ty->Is<type::Bool>()) {
|
||||||
packed_el_ast_ty = b->create<ast::Bool>();
|
packed_el_ast_ty = b->create<ast::Bool>();
|
||||||
} else {
|
} else {
|
||||||
TINT_UNREACHABLE(Writer, b->Diagnostics())
|
TINT_UNREACHABLE(Writer, b->Diagnostics())
|
||||||
|
|
|
@ -57,13 +57,13 @@ TEST_F(AppendVectorTest, Vec2i32_i32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec2<i32>(1, 2), 3u) -> vec3<i32>(1, 2, i32(3u))
|
// AppendVector(vec2<i32>(1, 2), 3u) -> vec3<i32>(1, 2, i32(3u))
|
||||||
|
@ -101,13 +101,13 @@ TEST_F(AppendVectorTest, Vec2i32_u32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec2<i32>(vec2<u32>(1u, 2u)), 3u) ->
|
// AppendVector(vec2<i32>(vec2<u32>(1u, 2u)), 3u) ->
|
||||||
|
@ -152,12 +152,12 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec2<i32>(1, 2), 3.0f) -> vec3<i32>(1, 2, i32(3.0f))
|
// AppendVector(vec2<i32>(1, 2), 3.0f) -> vec3<i32>(1, 2, i32(3.0f))
|
||||||
|
@ -195,13 +195,13 @@ TEST_F(AppendVectorTest, Vec2i32_f32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec3<i32>(1, 2, 3), 4) -> vec4<i32>(1, 2, 3, 4)
|
// AppendVector(vec3<i32>(1, 2, 3), 4) -> vec4<i32>(1, 2, 3, 4)
|
||||||
|
@ -238,14 +238,14 @@ TEST_F(AppendVectorTest, Vec3i32_i32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 4u);
|
ASSERT_EQ(ctor->Parameters().Length(), 4u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec_12, 3) -> vec3<i32>(vec_12, 3)
|
// AppendVector(vec_12, 3) -> vec3<i32>(vec_12, 3)
|
||||||
|
@ -276,12 +276,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(1, 2, scalar_3) -> vec3<i32>(1, 2, scalar_3)
|
// AppendVector(1, 2, scalar_3) -> vec3<i32>(1, 2, scalar_3)
|
||||||
|
@ -316,13 +316,13 @@ TEST_F(AppendVectorTest, Vec2i32_i32Var) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
ASSERT_EQ(ctor->Parameters().Length(), 3u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, scalar_3)
|
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, scalar_3)
|
||||||
|
@ -354,12 +354,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32Var) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, i32(scalar_3))
|
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, i32(scalar_3))
|
||||||
|
@ -395,12 +395,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec_12, scalar_3) -> vec3<bool>(vec_12, scalar_3)
|
// AppendVector(vec_12, scalar_3) -> vec3<bool>(vec_12, scalar_3)
|
||||||
|
@ -432,12 +432,12 @@ TEST_F(AppendVectorTest, Vec2boolVar_boolVar) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 3u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::Bool>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
ASSERT_EQ(ctor->Parameters().Length(), 2u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::Vector>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::Bool>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::Bool>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVector(vec3<i32>(), 4) -> vec3<bool>(0, 0, 0, 4)
|
// AppendVector(vec3<i32>(), 4) -> vec3<bool>(0, 0, 0, 4)
|
||||||
|
@ -473,14 +473,14 @@ TEST_F(AppendVectorTest, ZeroVec3i32_i32) {
|
||||||
ASSERT_NE(ctor, nullptr);
|
ASSERT_NE(ctor, nullptr);
|
||||||
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
ASSERT_TRUE(ctor->ReturnType()->Is<sem::Vector>());
|
||||||
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 4u);
|
EXPECT_EQ(ctor->ReturnType()->As<sem::Vector>()->Width(), 4u);
|
||||||
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->ReturnType()->As<sem::Vector>()->type()->Is<type::I32>());
|
||||||
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
EXPECT_EQ(ctor->ReturnType(), call->Type());
|
||||||
|
|
||||||
ASSERT_EQ(ctor->Parameters().Length(), 4u);
|
ASSERT_EQ(ctor->Parameters().Length(), 4u);
|
||||||
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is<type::I32>());
|
||||||
EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is<sem::I32>());
|
EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is<type::I32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -941,7 +941,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", 0";
|
out << ", 0";
|
||||||
if (builtin->ReturnType()->Is<sem::U32>()) {
|
if (builtin->ReturnType()->Is<type::U32>()) {
|
||||||
out << "u";
|
out << "u";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1280,7 +1280,7 @@ bool GeneratorImpl::EmitDegreesCall(std::ostream& out,
|
||||||
const ast::CallExpression* expr,
|
const ast::CallExpression* expr,
|
||||||
const sem::Builtin* builtin) {
|
const sem::Builtin* builtin) {
|
||||||
auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType());
|
auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType());
|
||||||
const std::string suffix = Is<sem::F16>(return_elem_type) ? "hf" : "f";
|
const std::string suffix = Is<type::F16>(return_elem_type) ? "hf" : "f";
|
||||||
return CallBuiltinHelper(out, expr, builtin,
|
return CallBuiltinHelper(out, expr, builtin,
|
||||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
line(b) << "return " << params[0] << " * " << std::setprecision(20)
|
line(b) << "return " << params[0] << " * " << std::setprecision(20)
|
||||||
|
@ -1293,7 +1293,7 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out,
|
||||||
const ast::CallExpression* expr,
|
const ast::CallExpression* expr,
|
||||||
const sem::Builtin* builtin) {
|
const sem::Builtin* builtin) {
|
||||||
auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType());
|
auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType());
|
||||||
const std::string suffix = Is<sem::F16>(return_elem_type) ? "hf" : "f";
|
const std::string suffix = Is<type::F16>(return_elem_type) ? "hf" : "f";
|
||||||
return CallBuiltinHelper(out, expr, builtin,
|
return CallBuiltinHelper(out, expr, builtin,
|
||||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
line(b) << "return " << params[0] << " * " << std::setprecision(20)
|
line(b) << "return " << params[0] << " * " << std::setprecision(20)
|
||||||
|
@ -1351,7 +1351,7 @@ bool GeneratorImpl::EmitBarrierCall(std::ostream& out, const sem::Builtin* built
|
||||||
|
|
||||||
const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
|
const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
|
||||||
auto* zero = builder_.Expr(0_f);
|
auto* zero = builder_.Expr(0_f);
|
||||||
auto* f32 = builder_.create<sem::F32>();
|
auto* f32 = builder_.create<type::F32>();
|
||||||
auto* sem_zero = builder_.create<sem::Expression>(zero, f32, sem::EvaluationStage::kRuntime,
|
auto* sem_zero = builder_.create<sem::Expression>(zero, f32, sem::EvaluationStage::kRuntime,
|
||||||
stmt, /* constant_value */ nullptr,
|
stmt, /* constant_value */ nullptr,
|
||||||
/* has_side_effects */ false);
|
/* has_side_effects */ false);
|
||||||
|
@ -1658,7 +1658,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||||
|
|
||||||
out << ")";
|
out << ")";
|
||||||
|
|
||||||
if (builtin->ReturnType()->Is<sem::Void>()) {
|
if (builtin->ReturnType()->Is<type::Void>()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If the builtin return type does not match the number of elements of the
|
// If the builtin return type does not match the number of elements of the
|
||||||
|
@ -2297,23 +2297,23 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
||||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << (constant->As<AInt>() ? "true" : "false");
|
out << (constant->As<AInt>() ? "true" : "false");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
PrintF32(out, constant->As<float>());
|
PrintF32(out, constant->As<float>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
PrintF16(out, constant->As<float>());
|
PrintF16(out, constant->As<float>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << constant->As<AInt>();
|
out << constant->As<AInt>();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << constant->As<AInt>() << "u";
|
out << constant->As<AInt>() << "u";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -2436,15 +2436,15 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::LiteralExpression*
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
||||||
if (type->Is<sem::Bool>()) {
|
if (type->Is<type::Bool>()) {
|
||||||
out << "false";
|
out << "false";
|
||||||
} else if (type->Is<sem::F32>()) {
|
} else if (type->Is<type::F32>()) {
|
||||||
out << "0.0f";
|
out << "0.0f";
|
||||||
} else if (type->Is<sem::F16>()) {
|
} else if (type->Is<type::F16>()) {
|
||||||
out << "0.0hf";
|
out << "0.0hf";
|
||||||
} else if (type->Is<sem::I32>()) {
|
} else if (type->Is<type::I32>()) {
|
||||||
out << "0";
|
out << "0";
|
||||||
} else if (type->Is<sem::U32>()) {
|
} else if (type->Is<type::U32>()) {
|
||||||
out << "0u";
|
out << "0u";
|
||||||
} else if (auto* vec = type->As<sem::Vector>()) {
|
} else if (auto* vec = type->As<sem::Vector>()) {
|
||||||
if (!EmitType(out, type, ast::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
|
if (!EmitType(out, type, ast::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
|
||||||
|
@ -2871,17 +2871,17 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
out << "[]";
|
out << "[]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type->Is<sem::Bool>()) {
|
} else if (type->Is<type::Bool>()) {
|
||||||
out << "bool";
|
out << "bool";
|
||||||
} else if (type->Is<sem::F32>()) {
|
} else if (type->Is<type::F32>()) {
|
||||||
out << "float";
|
out << "float";
|
||||||
} else if (type->Is<sem::F16>()) {
|
} else if (type->Is<type::F16>()) {
|
||||||
out << "float16_t";
|
out << "float16_t";
|
||||||
} else if (type->Is<sem::I32>()) {
|
} else if (type->Is<type::I32>()) {
|
||||||
out << "int";
|
out << "int";
|
||||||
} else if (auto* mat = type->As<sem::Matrix>()) {
|
} else if (auto* mat = type->As<sem::Matrix>()) {
|
||||||
TINT_ASSERT(Writer, (mat->type()->IsAnyOf<sem::F32, sem::F16>()));
|
TINT_ASSERT(Writer, (mat->type()->IsAnyOf<type::F32, type::F16>()));
|
||||||
if (mat->type()->Is<sem::F16>()) {
|
if (mat->type()->Is<type::F16>()) {
|
||||||
out << "f16";
|
out << "f16";
|
||||||
}
|
}
|
||||||
out << "mat" << mat->columns();
|
out << "mat" << mat->columns();
|
||||||
|
@ -2917,10 +2917,10 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
: storage ? storage->type()
|
: storage ? storage->type()
|
||||||
: ms ? ms->type()
|
: ms ? ms->type()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (!subtype || subtype->Is<sem::F32>()) {
|
if (!subtype || subtype->Is<type::F32>()) {
|
||||||
} else if (subtype->Is<sem::I32>()) {
|
} else if (subtype->Is<type::I32>()) {
|
||||||
out << "i";
|
out << "i";
|
||||||
} else if (subtype->Is<sem::U32>()) {
|
} else if (subtype->Is<type::U32>()) {
|
||||||
out << "u";
|
out << "u";
|
||||||
} else {
|
} else {
|
||||||
TINT_ICE(Writer, diagnostics_) << "Unsupported texture type";
|
TINT_ICE(Writer, diagnostics_) << "Unsupported texture type";
|
||||||
|
@ -2956,19 +2956,19 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
if (tex->Is<type::DepthTexture>()) {
|
if (tex->Is<type::DepthTexture>()) {
|
||||||
out << "Shadow";
|
out << "Shadow";
|
||||||
}
|
}
|
||||||
} else if (type->Is<sem::U32>()) {
|
} else if (type->Is<type::U32>()) {
|
||||||
out << "uint";
|
out << "uint";
|
||||||
} else if (auto* vec = type->As<sem::Vector>()) {
|
} else if (auto* vec = type->As<sem::Vector>()) {
|
||||||
auto width = vec->Width();
|
auto width = vec->Width();
|
||||||
if (vec->type()->Is<sem::F32>() && width >= 1 && width <= 4) {
|
if (vec->type()->Is<type::F32>() && width >= 1 && width <= 4) {
|
||||||
out << "vec" << width;
|
out << "vec" << width;
|
||||||
} else if (vec->type()->Is<sem::F16>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::F16>() && width >= 1 && width <= 4) {
|
||||||
out << "f16vec" << width;
|
out << "f16vec" << width;
|
||||||
} else if (vec->type()->Is<sem::I32>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::I32>() && width >= 1 && width <= 4) {
|
||||||
out << "ivec" << width;
|
out << "ivec" << width;
|
||||||
} else if (vec->type()->Is<sem::U32>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::U32>() && width >= 1 && width <= 4) {
|
||||||
out << "uvec" << width;
|
out << "uvec" << width;
|
||||||
} else if (vec->type()->Is<sem::Bool>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::Bool>() && width >= 1 && width <= 4) {
|
||||||
out << "bvec" << width;
|
out << "bvec" << width;
|
||||||
} else {
|
} else {
|
||||||
out << "vector<";
|
out << "vector<";
|
||||||
|
@ -2981,7 +2981,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
if (!EmitType(out, atomic->Type(), address_space, access, name)) {
|
if (!EmitType(out, atomic->Type(), address_space, access, name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (type->Is<sem::Void>()) {
|
} else if (type->Is<type::Void>()) {
|
||||||
out << "void";
|
out << "void";
|
||||||
} else {
|
} else {
|
||||||
diagnostics_.add_error(diag::System::Writer, "unknown type in EmitType");
|
diagnostics_.add_error(diag::System::Writer, "unknown type in EmitType");
|
||||||
|
@ -3206,8 +3206,8 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
|
||||||
}
|
}
|
||||||
|
|
||||||
type::Type* GeneratorImpl::BoolTypeToUint(const type::Type* type) {
|
type::Type* GeneratorImpl::BoolTypeToUint(const type::Type* type) {
|
||||||
auto* u32 = builder_.create<sem::U32>();
|
auto* u32 = builder_.create<type::U32>();
|
||||||
if (type->Is<sem::Bool>()) {
|
if (type->Is<type::Bool>()) {
|
||||||
return u32;
|
return u32;
|
||||||
} else if (auto* vec = type->As<sem::Vector>()) {
|
} else if (auto* vec = type->As<sem::Vector>()) {
|
||||||
return builder_.create<sem::Vector>(u32, vec->Width());
|
return builder_.create<sem::Vector>(u32, vec->Width());
|
||||||
|
|
|
@ -84,7 +84,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
|
||||||
Enable(ast::Extension::kF16);
|
Enable(ast::Extension::kF16);
|
||||||
|
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
||||||
Enable(ast::Extension::kF16);
|
Enable(ast::Extension::kF16);
|
||||||
|
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* vec3 = create<sem::Vector>(f16, 3u);
|
auto* vec3 = create<sem::Vector>(f16, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -256,7 +256,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
|
||||||
Enable(ast::Extension::kF16);
|
Enable(ast::Extension::kF16);
|
||||||
|
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* vec3 = create<sem::Vector>(f16, 3u);
|
auto* vec3 = create<sem::Vector>(f16, 3u);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -268,7 +268,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
|
||||||
auto* void_ = create<sem::Void>();
|
auto* void_ = create<type::Void>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
bool scalar_offset_constant = false;
|
bool scalar_offset_constant = false;
|
||||||
|
|
||||||
if (auto* val = offset_arg->ConstantValue()) {
|
if (auto* val = offset_arg->ConstantValue()) {
|
||||||
TINT_ASSERT(Writer, val->Type()->Is<sem::U32>());
|
TINT_ASSERT(Writer, val->Type()->Is<type::U32>());
|
||||||
scalar_offset_bytes = static_cast<uint32_t>(std::get<AInt>(val->Value()));
|
scalar_offset_bytes = static_cast<uint32_t>(std::get<AInt>(val->Value()));
|
||||||
scalar_offset_index = scalar_offset_bytes / 4; // bytes -> scalar index
|
scalar_offset_index = scalar_offset_bytes / 4; // bytes -> scalar index
|
||||||
scalar_offset_constant = true;
|
scalar_offset_constant = true;
|
||||||
|
@ -1775,7 +1775,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
const sem::Builtin* builtin) {
|
const sem::Builtin* builtin) {
|
||||||
std::string result = UniqueIdentifier("atomic_result");
|
std::string result = UniqueIdentifier("atomic_result");
|
||||||
|
|
||||||
if (!builtin->ReturnType()->Is<sem::Void>()) {
|
if (!builtin->ReturnType()->Is<type::Void>()) {
|
||||||
auto pre = line();
|
auto pre = line();
|
||||||
if (!EmitTypeAndName(pre, builtin->ReturnType(), ast::AddressSpace::kNone,
|
if (!EmitTypeAndName(pre, builtin->ReturnType(), ast::AddressSpace::kNone,
|
||||||
ast::Access::kUndefined, result)) {
|
ast::Access::kUndefined, result)) {
|
||||||
|
@ -2021,7 +2021,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string member_type;
|
std::string member_type;
|
||||||
if (Is<sem::F16>(type::Type::DeepestElementOf(ty))) {
|
if (Is<type::F16>(type::Type::DeepestElementOf(ty))) {
|
||||||
member_type = width.empty() ? "float16_t" : ("vector<float16_t, " + width + ">");
|
member_type = width.empty() ? "float16_t" : ("vector<float16_t, " + width + ">");
|
||||||
} else {
|
} else {
|
||||||
member_type = "float" + width;
|
member_type = "float" + width;
|
||||||
|
@ -2539,7 +2539,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto emit_vector_appended_with_i32_zero = [&](const ast::Expression* vector) {
|
auto emit_vector_appended_with_i32_zero = [&](const ast::Expression* vector) {
|
||||||
auto* i32 = builder_.create<sem::I32>();
|
auto* i32 = builder_.create<type::I32>();
|
||||||
auto* zero = builder_.Expr(0_i);
|
auto* zero = builder_.Expr(0_i);
|
||||||
auto* stmt = builder_.Sem().Get(vector)->Stmt();
|
auto* stmt = builder_.Sem().Get(vector)->Stmt();
|
||||||
builder_.Sem().Add(
|
builder_.Sem().Add(
|
||||||
|
@ -2915,7 +2915,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
||||||
out << ") {";
|
out << ") {";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sem->DiscardStatement() && !sem->ReturnType()->Is<sem::Void>()) {
|
if (sem->DiscardStatement() && !sem->ReturnType()->Is<type::Void>()) {
|
||||||
// BUG(crbug.com/tint/1081): work around non-void functions with discard
|
// BUG(crbug.com/tint/1081): work around non-void functions with discard
|
||||||
// failing compilation sometimes
|
// failing compilation sometimes
|
||||||
if (!EmitFunctionBodyWithDiscard(func)) {
|
if (!EmitFunctionBodyWithDiscard(func)) {
|
||||||
|
@ -2939,7 +2939,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) {
|
||||||
// there is always an (unused) return statement.
|
// there is always an (unused) return statement.
|
||||||
|
|
||||||
auto* sem = builder_.Sem().Get(func);
|
auto* sem = builder_.Sem().Get(func);
|
||||||
TINT_ASSERT(Writer, sem->DiscardStatement() && !sem->ReturnType()->Is<sem::Void>());
|
TINT_ASSERT(Writer, sem->DiscardStatement() && !sem->ReturnType()->Is<type::Void>());
|
||||||
|
|
||||||
ScopedIndent si(this);
|
ScopedIndent si(this);
|
||||||
line() << "if (true) {";
|
line() << "if (true) {";
|
||||||
|
@ -3267,26 +3267,26 @@ bool GeneratorImpl::EmitConstant(std::ostream& out,
|
||||||
bool is_variable_initializer) {
|
bool is_variable_initializer) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << (constant->As<AInt>() ? "true" : "false");
|
out << (constant->As<AInt>() ? "true" : "false");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
PrintF32(out, constant->As<float>());
|
PrintF32(out, constant->As<float>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
// emit a f16 scalar with explicit float16_t type declaration.
|
// emit a f16 scalar with explicit float16_t type declaration.
|
||||||
out << "float16_t(";
|
out << "float16_t(";
|
||||||
PrintF16(out, constant->As<float>());
|
PrintF16(out, constant->As<float>());
|
||||||
out << ")";
|
out << ")";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << constant->As<AInt>();
|
out << constant->As<AInt>();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << constant->As<AInt>() << "u";
|
out << constant->As<AInt>() << "u";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -3459,23 +3459,23 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::LiteralExpression*
|
||||||
bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int value) {
|
bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int value) {
|
||||||
return Switch(
|
return Switch(
|
||||||
type,
|
type,
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << (value == 0 ? "false" : "true");
|
out << (value == 0 ? "false" : "true");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
out << value << ".0f";
|
out << value << ".0f";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
out << "float16_t(" << value << ".0h)";
|
out << "float16_t(" << value << ".0h)";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << value;
|
out << value;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << value << "u";
|
out << value << "u";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -3954,24 +3954,24 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << "bool";
|
out << "bool";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
out << "float";
|
out << "float";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
out << "float16_t";
|
out << "float16_t";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << "int";
|
out << "int";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Matrix* mat) {
|
[&](const sem::Matrix* mat) {
|
||||||
if (mat->type()->Is<sem::F16>()) {
|
if (mat->type()->Is<type::F16>()) {
|
||||||
// Use matrix<type, N, M> for f16 matrix
|
// Use matrix<type, N, M> for f16 matrix
|
||||||
out << "matrix<";
|
out << "matrix<";
|
||||||
if (!EmitType(out, mat->type(), address_space, access, "")) {
|
if (!EmitType(out, mat->type(), address_space, access, "")) {
|
||||||
|
@ -4066,11 +4066,11 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
} else if (sampled || ms) {
|
} else if (sampled || ms) {
|
||||||
auto* subtype = sampled ? sampled->type() : ms->type();
|
auto* subtype = sampled ? sampled->type() : ms->type();
|
||||||
out << "<";
|
out << "<";
|
||||||
if (subtype->Is<sem::F32>()) {
|
if (subtype->Is<type::F32>()) {
|
||||||
out << "float4";
|
out << "float4";
|
||||||
} else if (subtype->Is<sem::I32>()) {
|
} else if (subtype->Is<type::I32>()) {
|
||||||
out << "int4";
|
out << "int4";
|
||||||
} else if (subtype->Is<sem::U32>()) {
|
} else if (subtype->Is<type::U32>()) {
|
||||||
out << "uint4";
|
out << "uint4";
|
||||||
} else {
|
} else {
|
||||||
TINT_ICE(Writer, diagnostics_) << "Unsupported multisampled texture type";
|
TINT_ICE(Writer, diagnostics_) << "Unsupported multisampled texture type";
|
||||||
|
@ -4080,19 +4080,19 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << "uint";
|
out << "uint";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Vector* vec) {
|
[&](const sem::Vector* vec) {
|
||||||
auto width = vec->Width();
|
auto width = vec->Width();
|
||||||
if (vec->type()->Is<sem::F32>() && width >= 1 && width <= 4) {
|
if (vec->type()->Is<type::F32>() && width >= 1 && width <= 4) {
|
||||||
out << "float" << width;
|
out << "float" << width;
|
||||||
} else if (vec->type()->Is<sem::I32>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::I32>() && width >= 1 && width <= 4) {
|
||||||
out << "int" << width;
|
out << "int" << width;
|
||||||
} else if (vec->type()->Is<sem::U32>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::U32>() && width >= 1 && width <= 4) {
|
||||||
out << "uint" << width;
|
out << "uint" << width;
|
||||||
} else if (vec->type()->Is<sem::Bool>() && width >= 1 && width <= 4) {
|
} else if (vec->type()->Is<type::Bool>() && width >= 1 && width <= 4) {
|
||||||
out << "bool" << width;
|
out << "bool" << width;
|
||||||
} else {
|
} else {
|
||||||
// For example, use "vector<float16_t, N>" for f16 vector.
|
// For example, use "vector<float16_t, N>" for f16 vector.
|
||||||
|
@ -4107,7 +4107,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
[&](const sem::Atomic* atomic) {
|
[&](const sem::Atomic* atomic) {
|
||||||
return EmitType(out, atomic->Type(), address_space, access, name);
|
return EmitType(out, atomic->Type(), address_space, access, name);
|
||||||
},
|
},
|
||||||
[&](const sem::Void*) {
|
[&](const type::Void*) {
|
||||||
out << "void";
|
out << "void";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,7 +84,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* vec3 = create<sem::Vector>(f16, 3u);
|
auto* vec3 = create<sem::Vector>(f16, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -262,7 +262,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
|
||||||
auto* void_ = create<sem::Void>();
|
auto* void_ = create<type::Void>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -33,13 +33,9 @@
|
||||||
#include "src/tint/ast/void.h"
|
#include "src/tint/ast/void.h"
|
||||||
#include "src/tint/sem/array.h"
|
#include "src/tint/sem/array.h"
|
||||||
#include "src/tint/sem/atomic.h"
|
#include "src/tint/sem/atomic.h"
|
||||||
#include "src/tint/sem/bool.h"
|
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/constant.h"
|
#include "src/tint/sem/constant.h"
|
||||||
#include "src/tint/sem/f16.h"
|
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/i32.h"
|
|
||||||
#include "src/tint/sem/matrix.h"
|
#include "src/tint/sem/matrix.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
#include "src/tint/sem/module.h"
|
#include "src/tint/sem/module.h"
|
||||||
|
@ -49,10 +45,8 @@
|
||||||
#include "src/tint/sem/switch_statement.h"
|
#include "src/tint/sem/switch_statement.h"
|
||||||
#include "src/tint/sem/type_conversion.h"
|
#include "src/tint/sem/type_conversion.h"
|
||||||
#include "src/tint/sem/type_initializer.h"
|
#include "src/tint/sem/type_initializer.h"
|
||||||
#include "src/tint/sem/u32.h"
|
|
||||||
#include "src/tint/sem/variable.h"
|
#include "src/tint/sem/variable.h"
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
#include "src/tint/sem/void.h"
|
|
||||||
#include "src/tint/transform/array_length_from_uniform.h"
|
#include "src/tint/transform/array_length_from_uniform.h"
|
||||||
#include "src/tint/transform/builtin_polyfill.h"
|
#include "src/tint/transform/builtin_polyfill.h"
|
||||||
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
||||||
|
@ -70,11 +64,17 @@
|
||||||
#include "src/tint/transform/unshadow.h"
|
#include "src/tint/transform/unshadow.h"
|
||||||
#include "src/tint/transform/vectorize_scalar_matrix_initializers.h"
|
#include "src/tint/transform/vectorize_scalar_matrix_initializers.h"
|
||||||
#include "src/tint/transform/zero_init_workgroup_memory.h"
|
#include "src/tint/transform/zero_init_workgroup_memory.h"
|
||||||
|
#include "src/tint/type/bool.h"
|
||||||
#include "src/tint/type/depth_multisampled_texture.h"
|
#include "src/tint/type/depth_multisampled_texture.h"
|
||||||
#include "src/tint/type/depth_texture.h"
|
#include "src/tint/type/depth_texture.h"
|
||||||
|
#include "src/tint/type/f16.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
|
#include "src/tint/type/i32.h"
|
||||||
#include "src/tint/type/multisampled_texture.h"
|
#include "src/tint/type/multisampled_texture.h"
|
||||||
#include "src/tint/type/sampled_texture.h"
|
#include "src/tint/type/sampled_texture.h"
|
||||||
#include "src/tint/type/storage_texture.h"
|
#include "src/tint/type/storage_texture.h"
|
||||||
|
#include "src/tint/type/u32.h"
|
||||||
|
#include "src/tint/type/void.h"
|
||||||
#include "src/tint/utils/defer.h"
|
#include "src/tint/utils/defer.h"
|
||||||
#include "src/tint/utils/map.h"
|
#include "src/tint/utils/map.h"
|
||||||
#include "src/tint/utils/scoped_assignment.h"
|
#include "src/tint/utils/scoped_assignment.h"
|
||||||
|
@ -494,18 +494,18 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e
|
||||||
|
|
||||||
auto signed_type_of = [&](const type::Type* ty) -> const type::Type* {
|
auto signed_type_of = [&](const type::Type* ty) -> const type::Type* {
|
||||||
if (ty->is_integer_scalar()) {
|
if (ty->is_integer_scalar()) {
|
||||||
return builder_.create<sem::I32>();
|
return builder_.create<type::I32>();
|
||||||
} else if (auto* v = ty->As<sem::Vector>()) {
|
} else if (auto* v = ty->As<sem::Vector>()) {
|
||||||
return builder_.create<sem::Vector>(builder_.create<sem::I32>(), v->Width());
|
return builder_.create<sem::Vector>(builder_.create<type::I32>(), v->Width());
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto unsigned_type_of = [&](const type::Type* ty) -> const type::Type* {
|
auto unsigned_type_of = [&](const type::Type* ty) -> const type::Type* {
|
||||||
if (ty->is_integer_scalar()) {
|
if (ty->is_integer_scalar()) {
|
||||||
return builder_.create<sem::U32>();
|
return builder_.create<type::U32>();
|
||||||
} else if (auto* v = ty->As<sem::Vector>()) {
|
} else if (auto* v = ty->As<sem::Vector>()) {
|
||||||
return builder_.create<sem::Vector>(builder_.create<sem::U32>(), v->Width());
|
return builder_.create<sem::Vector>(builder_.create<type::U32>(), v->Width());
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
@ -584,7 +584,7 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle '&' and '|' of booleans.
|
// Handle '&' and '|' of booleans.
|
||||||
if ((expr->IsAnd() || expr->IsOr()) && lhs_type->Is<sem::Bool>()) {
|
if ((expr->IsAnd() || expr->IsOr()) && lhs_type->Is<type::Bool>()) {
|
||||||
out << "bool";
|
out << "bool";
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, expr->lhs)) {
|
if (!EmitExpression(out, expr->lhs)) {
|
||||||
|
@ -1612,23 +1612,23 @@ bool GeneratorImpl::EmitContinue(const ast::ContinueStatement*) {
|
||||||
bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
||||||
return Switch(
|
return Switch(
|
||||||
type,
|
type,
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << "false";
|
out << "false";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
out << "0.0h";
|
out << "0.0h";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
out << "0.0f";
|
out << "0.0f";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << "0";
|
out << "0";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << "0u";
|
out << "0u";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -1661,23 +1661,23 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
||||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << (constant->As<AInt>() ? "true" : "false");
|
out << (constant->As<AInt>() ? "true" : "false");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
PrintF32(out, constant->As<float>());
|
PrintF32(out, constant->As<float>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
PrintF16(out, constant->As<float>());
|
PrintF16(out, constant->As<float>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
PrintI32(out, constant->As<int32_t>());
|
PrintI32(out, constant->As<int32_t>());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << constant->As<AInt>() << "u";
|
out << constant->As<AInt>() << "u";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -2524,11 +2524,11 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
return Switch(
|
return Switch(
|
||||||
type,
|
type,
|
||||||
[&](const sem::Atomic* atomic) {
|
[&](const sem::Atomic* atomic) {
|
||||||
if (atomic->Type()->Is<sem::I32>()) {
|
if (atomic->Type()->Is<type::I32>()) {
|
||||||
out << "atomic_int";
|
out << "atomic_int";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (atomic->Type()->Is<sem::U32>()) {
|
if (atomic->Type()->Is<type::U32>()) {
|
||||||
out << "atomic_uint";
|
out << "atomic_uint";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2557,19 +2557,19 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
out << ">";
|
out << ">";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
out << "bool";
|
out << "bool";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
out << "half";
|
out << "half";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
out << "float";
|
out << "float";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
out << "int";
|
out << "int";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -2695,7 +2695,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
out << "uint";
|
out << "uint";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -2706,7 +2706,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
out << vec->Width();
|
out << vec->Width();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Void*) {
|
[&](const type::Void*) {
|
||||||
out << "void";
|
out << "void";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -3085,16 +3085,16 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type:
|
||||||
|
|
||||||
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
|
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
|
||||||
// 2.1 Scalar Data Types
|
// 2.1 Scalar Data Types
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
return SizeAndAlign{4, 4};
|
return SizeAndAlign{4, 4};
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
return SizeAndAlign{4, 4};
|
return SizeAndAlign{4, 4};
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
return SizeAndAlign{4, 4};
|
return SizeAndAlign{4, 4};
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
return SizeAndAlign{2, 2};
|
return SizeAndAlign{2, 2};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3102,7 +3102,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type:
|
||||||
auto num_els = vec->Width();
|
auto num_els = vec->Width();
|
||||||
auto* el_ty = vec->type();
|
auto* el_ty = vec->type();
|
||||||
SizeAndAlign el_size_align = MslPackedTypeSizeAndAlign(el_ty);
|
SizeAndAlign el_size_align = MslPackedTypeSizeAndAlign(el_ty);
|
||||||
if (el_ty->IsAnyOf<sem::U32, sem::I32, sem::F32, sem::F16>()) {
|
if (el_ty->IsAnyOf<type::U32, type::I32, type::F32, type::F16>()) {
|
||||||
// Use a packed_vec type for 3-element vectors only.
|
// Use a packed_vec type for 3-element vectors only.
|
||||||
if (num_els == 3) {
|
if (num_els == 3) {
|
||||||
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
|
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
|
||||||
|
@ -3127,7 +3127,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type:
|
||||||
auto rows = mat->rows();
|
auto rows = mat->rows();
|
||||||
auto* el_ty = mat->type();
|
auto* el_ty = mat->type();
|
||||||
// Metal only support half and float matrix.
|
// Metal only support half and float matrix.
|
||||||
if (el_ty->IsAnyOf<sem::F32, sem::F16>()) {
|
if (el_ty->IsAnyOf<type::F32, type::F16>()) {
|
||||||
static constexpr SizeAndAlign table_f32[] = {
|
static constexpr SizeAndAlign table_f32[] = {
|
||||||
/* float2x2 */ {16, 8},
|
/* float2x2 */ {16, 8},
|
||||||
/* float2x3 */ {32, 16},
|
/* float2x3 */ {32, 16},
|
||||||
|
@ -3151,7 +3151,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type:
|
||||||
/* half4x4 */ {32, 8},
|
/* half4x4 */ {32, 8},
|
||||||
};
|
};
|
||||||
if (cols >= 2 && cols <= 4 && rows >= 2 && rows <= 4) {
|
if (cols >= 2 && cols <= 4 && rows >= 2 && rows <= 4) {
|
||||||
if (el_ty->Is<sem::F32>()) {
|
if (el_ty->Is<type::F32>()) {
|
||||||
return table_f32[(3 * (cols - 2)) + (rows - 2)];
|
return table_f32[(3 * (cols - 2)) + (rows - 2)];
|
||||||
} else {
|
} else {
|
||||||
return table_f16[(3 * (cols - 2)) + (rows - 2)];
|
return table_f16[(3 * (cols - 2)) + (rows - 2)];
|
||||||
|
|
|
@ -146,7 +146,7 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Bool) {
|
TEST_F(MslGeneratorImplTest, EmitType_Bool) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_F32) {
|
TEST_F(MslGeneratorImplTest, EmitType_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_F16) {
|
TEST_F(MslGeneratorImplTest, EmitType_F16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_I32) {
|
TEST_F(MslGeneratorImplTest, EmitType_I32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ TEST_F(MslGeneratorImplTest, EmitType_I32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) {
|
TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) {
|
TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* vec3 = create<sem::Vector>(f16, 3u);
|
auto* vec3 = create<sem::Vector>(f16, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Pointer) {
|
TEST_F(MslGeneratorImplTest, EmitType_Pointer) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* p = create<sem::Pointer>(f32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
|
auto* p = create<sem::Pointer>(f32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -699,7 +699,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_U32) {
|
TEST_F(MslGeneratorImplTest, EmitType_U32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ TEST_F(MslGeneratorImplTest, EmitType_U32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Vector) {
|
TEST_F(MslGeneratorImplTest, EmitType_Vector) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -720,7 +720,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Vector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, EmitType_Void) {
|
TEST_F(MslGeneratorImplTest, EmitType_Void) {
|
||||||
auto* void_ = create<sem::Void>();
|
auto* void_ = create<type::Void>();
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ using MslSampledtexturesTest = TestParamHelper<MslTextureData>;
|
||||||
TEST_P(MslSampledtexturesTest, Emit) {
|
TEST_P(MslSampledtexturesTest, Emit) {
|
||||||
auto params = GetParam();
|
auto params = GetParam();
|
||||||
|
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(params.dim, f32);
|
auto* s = create<type::SampledTexture>(params.dim, f32);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
@ -825,7 +825,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"texturecube_array<float, access::sample>"}));
|
"texturecube_array<float, access::sample>"}));
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
||||||
|
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
|
@ -631,7 +631,7 @@ bool Builder::GenerateFunction(const ast::Function* func_ast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InsideBasicBlock()) {
|
if (InsideBasicBlock()) {
|
||||||
if (func->ReturnType()->Is<sem::Void>()) {
|
if (func->ReturnType()->Is<type::Void>()) {
|
||||||
push_function_inst(spv::Op::OpReturn, {});
|
push_function_inst(spv::Op::OpReturn, {});
|
||||||
} else {
|
} else {
|
||||||
auto zero = GenerateConstantNullIfNeeded(func->ReturnType());
|
auto zero = GenerateConstantNullIfNeeded(func->ReturnType());
|
||||||
|
@ -1484,20 +1484,20 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type,
|
||||||
auto* from_type = TypeOf(from_expr)->UnwrapRef();
|
auto* from_type = TypeOf(from_expr)->UnwrapRef();
|
||||||
|
|
||||||
spv::Op op = spv::Op::OpNop;
|
spv::Op op = spv::Op::OpNop;
|
||||||
if ((from_type->Is<sem::I32>() && to_type->is_float_scalar()) ||
|
if ((from_type->Is<type::I32>() && to_type->is_float_scalar()) ||
|
||||||
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
|
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
|
||||||
op = spv::Op::OpConvertSToF;
|
op = spv::Op::OpConvertSToF;
|
||||||
} else if ((from_type->Is<sem::U32>() && to_type->is_float_scalar()) ||
|
} else if ((from_type->Is<type::U32>() && to_type->is_float_scalar()) ||
|
||||||
(from_type->is_unsigned_integer_vector() && to_type->is_float_vector())) {
|
(from_type->is_unsigned_integer_vector() && to_type->is_float_vector())) {
|
||||||
op = spv::Op::OpConvertUToF;
|
op = spv::Op::OpConvertUToF;
|
||||||
} else if ((from_type->is_float_scalar() && to_type->Is<sem::I32>()) ||
|
} else if ((from_type->is_float_scalar() && to_type->Is<type::I32>()) ||
|
||||||
(from_type->is_float_vector() && to_type->is_signed_integer_vector())) {
|
(from_type->is_float_vector() && to_type->is_signed_integer_vector())) {
|
||||||
op = spv::Op::OpConvertFToS;
|
op = spv::Op::OpConvertFToS;
|
||||||
} else if ((from_type->is_float_scalar() && to_type->Is<sem::U32>()) ||
|
} else if ((from_type->is_float_scalar() && to_type->Is<type::U32>()) ||
|
||||||
(from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) {
|
(from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) {
|
||||||
op = spv::Op::OpConvertFToU;
|
op = spv::Op::OpConvertFToU;
|
||||||
} else if (from_type
|
} else if (from_type->IsAnyOf<type::Bool, type::F32, type::I32, type::U32, type::F16,
|
||||||
->IsAnyOf<sem::Bool, sem::F32, sem::I32, sem::U32, sem::F16, sem::Vector>() &&
|
sem::Vector>() &&
|
||||||
from_type == to_type) {
|
from_type == to_type) {
|
||||||
// Identity initializer for scalar and vector types
|
// Identity initializer for scalar and vector types
|
||||||
return val_id;
|
return val_id;
|
||||||
|
@ -1509,13 +1509,13 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type,
|
||||||
// and to_type being the same floating point scalar or vector type, i.e. identity
|
// and to_type being the same floating point scalar or vector type, i.e. identity
|
||||||
// initializer, is already handled in the previous else-if clause.
|
// initializer, is already handled in the previous else-if clause.
|
||||||
op = spv::Op::OpFConvert;
|
op = spv::Op::OpFConvert;
|
||||||
} else if ((from_type->Is<sem::I32>() && to_type->Is<sem::U32>()) ||
|
} else if ((from_type->Is<type::I32>() && to_type->Is<type::U32>()) ||
|
||||||
(from_type->Is<sem::U32>() && to_type->Is<sem::I32>()) ||
|
(from_type->Is<type::U32>() && to_type->Is<type::I32>()) ||
|
||||||
(from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) ||
|
(from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) ||
|
||||||
(from_type->is_unsigned_integer_vector() &&
|
(from_type->is_unsigned_integer_vector() &&
|
||||||
to_type->is_integer_scalar_or_vector())) {
|
to_type->is_integer_scalar_or_vector())) {
|
||||||
op = spv::Op::OpBitcast;
|
op = spv::Op::OpBitcast;
|
||||||
} else if ((from_type->is_numeric_scalar() && to_type->Is<sem::Bool>()) ||
|
} else if ((from_type->is_numeric_scalar() && to_type->Is<type::Bool>()) ||
|
||||||
(from_type->is_numeric_vector() && to_type->is_bool_vector())) {
|
(from_type->is_numeric_vector() && to_type->is_bool_vector())) {
|
||||||
// Convert scalar (vector) to bool (vector)
|
// Convert scalar (vector) to bool (vector)
|
||||||
|
|
||||||
|
@ -1536,16 +1536,16 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type,
|
||||||
const auto* to_elem_type = elem_type_of(to_type);
|
const auto* to_elem_type = elem_type_of(to_type);
|
||||||
uint32_t one_id;
|
uint32_t one_id;
|
||||||
uint32_t zero_id;
|
uint32_t zero_id;
|
||||||
if (to_elem_type->Is<sem::F32>()) {
|
if (to_elem_type->Is<type::F32>()) {
|
||||||
zero_id = GenerateConstantIfNeeded(ScalarConstant::F32(0));
|
zero_id = GenerateConstantIfNeeded(ScalarConstant::F32(0));
|
||||||
one_id = GenerateConstantIfNeeded(ScalarConstant::F32(1));
|
one_id = GenerateConstantIfNeeded(ScalarConstant::F32(1));
|
||||||
} else if (to_elem_type->Is<sem::F16>()) {
|
} else if (to_elem_type->Is<type::F16>()) {
|
||||||
zero_id = GenerateConstantIfNeeded(ScalarConstant::F16(0));
|
zero_id = GenerateConstantIfNeeded(ScalarConstant::F16(0));
|
||||||
one_id = GenerateConstantIfNeeded(ScalarConstant::F16(1));
|
one_id = GenerateConstantIfNeeded(ScalarConstant::F16(1));
|
||||||
} else if (to_elem_type->Is<sem::U32>()) {
|
} else if (to_elem_type->Is<type::U32>()) {
|
||||||
zero_id = GenerateConstantIfNeeded(ScalarConstant::U32(0));
|
zero_id = GenerateConstantIfNeeded(ScalarConstant::U32(0));
|
||||||
one_id = GenerateConstantIfNeeded(ScalarConstant::U32(1));
|
one_id = GenerateConstantIfNeeded(ScalarConstant::U32(1));
|
||||||
} else if (to_elem_type->Is<sem::I32>()) {
|
} else if (to_elem_type->Is<type::I32>()) {
|
||||||
zero_id = GenerateConstantIfNeeded(ScalarConstant::I32(0));
|
zero_id = GenerateConstantIfNeeded(ScalarConstant::I32(0));
|
||||||
one_id = GenerateConstantIfNeeded(ScalarConstant::I32(1));
|
one_id = GenerateConstantIfNeeded(ScalarConstant::I32(1));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1680,23 +1680,23 @@ uint32_t Builder::GenerateConstantIfNeeded(const sem::Constant* constant) {
|
||||||
|
|
||||||
return Switch(
|
return Switch(
|
||||||
ty, //
|
ty, //
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
bool val = constant->As<bool>();
|
bool val = constant->As<bool>();
|
||||||
return GenerateConstantIfNeeded(ScalarConstant::Bool(val));
|
return GenerateConstantIfNeeded(ScalarConstant::Bool(val));
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
auto val = constant->As<f32>();
|
auto val = constant->As<f32>();
|
||||||
return GenerateConstantIfNeeded(ScalarConstant::F32(val.value));
|
return GenerateConstantIfNeeded(ScalarConstant::F32(val.value));
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
auto val = constant->As<f16>();
|
auto val = constant->As<f16>();
|
||||||
return GenerateConstantIfNeeded(ScalarConstant::F16(val.value));
|
return GenerateConstantIfNeeded(ScalarConstant::F16(val.value));
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
auto val = constant->As<i32>();
|
auto val = constant->As<i32>();
|
||||||
return GenerateConstantIfNeeded(ScalarConstant::I32(val.value));
|
return GenerateConstantIfNeeded(ScalarConstant::I32(val.value));
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
auto val = constant->As<u32>();
|
auto val = constant->As<u32>();
|
||||||
return GenerateConstantIfNeeded(ScalarConstant::U32(val.value));
|
return GenerateConstantIfNeeded(ScalarConstant::U32(val.value));
|
||||||
},
|
},
|
||||||
|
@ -1727,23 +1727,23 @@ uint32_t Builder::GenerateConstantIfNeeded(const ScalarConstant& constant) {
|
||||||
|
|
||||||
switch (constant.kind) {
|
switch (constant.kind) {
|
||||||
case ScalarConstant::Kind::kU32: {
|
case ScalarConstant::Kind::kU32: {
|
||||||
type_id = GenerateTypeIfNeeded(builder_.create<sem::U32>());
|
type_id = GenerateTypeIfNeeded(builder_.create<type::U32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ScalarConstant::Kind::kI32: {
|
case ScalarConstant::Kind::kI32: {
|
||||||
type_id = GenerateTypeIfNeeded(builder_.create<sem::I32>());
|
type_id = GenerateTypeIfNeeded(builder_.create<type::I32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ScalarConstant::Kind::kF32: {
|
case ScalarConstant::Kind::kF32: {
|
||||||
type_id = GenerateTypeIfNeeded(builder_.create<sem::F32>());
|
type_id = GenerateTypeIfNeeded(builder_.create<type::F32>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ScalarConstant::Kind::kF16: {
|
case ScalarConstant::Kind::kF16: {
|
||||||
type_id = GenerateTypeIfNeeded(builder_.create<sem::F16>());
|
type_id = GenerateTypeIfNeeded(builder_.create<type::F16>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ScalarConstant::Kind::kBool: {
|
case ScalarConstant::Kind::kBool: {
|
||||||
type_id = GenerateTypeIfNeeded(builder_.create<sem::Bool>());
|
type_id = GenerateTypeIfNeeded(builder_.create<type::Bool>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2349,14 +2349,14 @@ uint32_t Builder::GenerateBuiltinCall(const sem::Call* call, const sem::Builtin*
|
||||||
|
|
||||||
switch (builtin->Type()) {
|
switch (builtin->Type()) {
|
||||||
case BuiltinType::kAny:
|
case BuiltinType::kAny:
|
||||||
if (builtin->Parameters()[0]->Type()->Is<sem::Bool>()) {
|
if (builtin->Parameters()[0]->Type()->Is<type::Bool>()) {
|
||||||
// any(v: bool) just resolves to v.
|
// any(v: bool) just resolves to v.
|
||||||
return get_arg_as_value_id(0);
|
return get_arg_as_value_id(0);
|
||||||
}
|
}
|
||||||
op = spv::Op::OpAny;
|
op = spv::Op::OpAny;
|
||||||
break;
|
break;
|
||||||
case BuiltinType::kAll:
|
case BuiltinType::kAll:
|
||||||
if (builtin->Parameters()[0]->Type()->Is<sem::Bool>()) {
|
if (builtin->Parameters()[0]->Type()->Is<type::Bool>()) {
|
||||||
// all(v: bool) just resolves to v.
|
// all(v: bool) just resolves to v.
|
||||||
return get_arg_as_value_id(0);
|
return get_arg_as_value_id(0);
|
||||||
}
|
}
|
||||||
|
@ -2525,7 +2525,7 @@ uint32_t Builder::GenerateBuiltinCall(const sem::Call* call, const sem::Builtin*
|
||||||
// TODO(jrprice): If we're targeting SPIR-V 1.4, we don't need to do this.
|
// TODO(jrprice): If we're targeting SPIR-V 1.4, we don't need to do this.
|
||||||
auto* result_vector_type = builtin->ReturnType()->As<sem::Vector>();
|
auto* result_vector_type = builtin->ReturnType()->As<sem::Vector>();
|
||||||
if (result_vector_type && builtin->Parameters()[2]->Type()->is_scalar()) {
|
if (result_vector_type && builtin->Parameters()[2]->Type()->is_scalar()) {
|
||||||
auto* bool_vec_ty = builder_.create<sem::Vector>(builder_.create<sem::Bool>(),
|
auto* bool_vec_ty = builder_.create<sem::Vector>(builder_.create<type::Bool>(),
|
||||||
result_vector_type->Width());
|
result_vector_type->Width());
|
||||||
if (!GenerateTypeIfNeeded(bool_vec_ty)) {
|
if (!GenerateTypeIfNeeded(bool_vec_ty)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2686,7 +2686,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
|
||||||
// to calling append_result_type_and_id_to_spirv_params().
|
// to calling append_result_type_and_id_to_spirv_params().
|
||||||
auto append_result_type_and_id_to_spirv_params_for_read = [&]() {
|
auto append_result_type_and_id_to_spirv_params_for_read = [&]() {
|
||||||
if (texture_type->IsAnyOf<type::DepthTexture, type::DepthMultisampledTexture>()) {
|
if (texture_type->IsAnyOf<type::DepthTexture, type::DepthMultisampledTexture>()) {
|
||||||
auto* f32 = builder_.create<sem::F32>();
|
auto* f32 = builder_.create<type::F32>();
|
||||||
auto* spirv_result_type = builder_.create<sem::Vector>(f32, 4u);
|
auto* spirv_result_type = builder_.create<sem::Vector>(f32, 4u);
|
||||||
auto spirv_result = result_op();
|
auto spirv_result = result_op();
|
||||||
post_emission = [=] {
|
post_emission = [=] {
|
||||||
|
@ -2940,10 +2940,10 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto level = Operand(0u);
|
auto level = Operand(0u);
|
||||||
if (arg(Usage::kLevel)->Type()->UnwrapRef()->IsAnyOf<sem::I32, sem::U32>()) {
|
if (arg(Usage::kLevel)->Type()->UnwrapRef()->IsAnyOf<type::I32, type::U32>()) {
|
||||||
// Depth textures have i32 or u32 parameters for the level, but SPIR-V expects f32.
|
// Depth textures have i32 or u32 parameters for the level, but SPIR-V expects f32.
|
||||||
// Cast.
|
// Cast.
|
||||||
auto f32_type_id = GenerateTypeIfNeeded(builder_.create<sem::F32>());
|
auto f32_type_id = GenerateTypeIfNeeded(builder_.create<type::F32>());
|
||||||
if (f32_type_id == 0) {
|
if (f32_type_id == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3068,7 +3068,7 @@ bool Builder::GenerateAtomicBuiltin(const sem::Call* call,
|
||||||
const sem::Builtin* builtin,
|
const sem::Builtin* builtin,
|
||||||
Operand result_type,
|
Operand result_type,
|
||||||
Operand result_id) {
|
Operand result_id) {
|
||||||
auto is_value_signed = [&] { return builtin->Parameters()[1]->Type()->Is<sem::I32>(); };
|
auto is_value_signed = [&] { return builtin->Parameters()[1]->Type()->Is<type::I32>(); };
|
||||||
|
|
||||||
auto address_space = builtin->Parameters()[0]->Type()->As<sem::Pointer>()->AddressSpace();
|
auto address_space = builtin->Parameters()[0]->Type()->As<sem::Pointer>()->AddressSpace();
|
||||||
|
|
||||||
|
@ -3219,7 +3219,7 @@ bool Builder::GenerateAtomicBuiltin(const sem::Call* call,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* bool_sem_ty = builder_.create<sem::Bool>();
|
auto* bool_sem_ty = builder_.create<type::Bool>();
|
||||||
auto bool_type = GenerateTypeIfNeeded(bool_sem_ty);
|
auto bool_type = GenerateTypeIfNeeded(bool_sem_ty);
|
||||||
if (bool_type == 0) {
|
if (bool_type == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3282,7 +3282,7 @@ uint32_t Builder::GenerateSampledImage(const type::Type* texture_type,
|
||||||
// Using anything other than 0 is problematic on various Vulkan drivers.
|
// Using anything other than 0 is problematic on various Vulkan drivers.
|
||||||
if (auto* depthTextureType = texture_type->As<type::DepthTexture>()) {
|
if (auto* depthTextureType = texture_type->As<type::DepthTexture>()) {
|
||||||
texture_type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
|
texture_type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
|
||||||
builder_.create<sem::F32>());
|
builder_.create<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sampled_image_type_id =
|
uint32_t sampled_image_type_id =
|
||||||
|
@ -3647,10 +3647,10 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
|
||||||
// Using anything other than 0 is problematic on various Vulkan drivers.
|
// Using anything other than 0 is problematic on various Vulkan drivers.
|
||||||
if (auto* depthTextureType = type->As<type::DepthTexture>()) {
|
if (auto* depthTextureType = type->As<type::DepthTexture>()) {
|
||||||
type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
|
type = builder_.create<type::SampledTexture>(depthTextureType->dim(),
|
||||||
builder_.create<sem::F32>());
|
builder_.create<type::F32>());
|
||||||
} else if (auto* multisampledDepthTextureType = type->As<type::DepthMultisampledTexture>()) {
|
} else if (auto* multisampledDepthTextureType = type->As<type::DepthMultisampledTexture>()) {
|
||||||
type = builder_.create<type::MultisampledTexture>(multisampledDepthTextureType->dim(),
|
type = builder_.create<type::MultisampledTexture>(multisampledDepthTextureType->dim(),
|
||||||
builder_.create<sem::F32>());
|
builder_.create<type::F32>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pointers and references with differing accesses should not result in a
|
// Pointers and references with differing accesses should not result in a
|
||||||
|
@ -3676,19 +3676,19 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
|
||||||
[&](const sem::Array* arr) { //
|
[&](const sem::Array* arr) { //
|
||||||
return GenerateArrayType(arr, result);
|
return GenerateArrayType(arr, result);
|
||||||
},
|
},
|
||||||
[&](const sem::Bool*) {
|
[&](const type::Bool*) {
|
||||||
push_type(spv::Op::OpTypeBool, {result});
|
push_type(spv::Op::OpTypeBool, {result});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F32*) {
|
[&](const type::F32*) {
|
||||||
push_type(spv::Op::OpTypeFloat, {result, Operand(32u)});
|
push_type(spv::Op::OpTypeFloat, {result, Operand(32u)});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::F16*) {
|
[&](const type::F16*) {
|
||||||
push_type(spv::Op::OpTypeFloat, {result, Operand(16u)});
|
push_type(spv::Op::OpTypeFloat, {result, Operand(16u)});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::I32*) {
|
[&](const type::I32*) {
|
||||||
push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(1u)});
|
push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(1u)});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -3704,14 +3704,14 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) {
|
||||||
[&](const sem::Struct* str) { //
|
[&](const sem::Struct* str) { //
|
||||||
return GenerateStructType(str, result);
|
return GenerateStructType(str, result);
|
||||||
},
|
},
|
||||||
[&](const sem::U32*) {
|
[&](const type::U32*) {
|
||||||
push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(0u)});
|
push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(0u)});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const sem::Vector* vec) { //
|
[&](const sem::Vector* vec) { //
|
||||||
return GenerateVectorType(vec, result);
|
return GenerateVectorType(vec, result);
|
||||||
},
|
},
|
||||||
[&](const sem::Void*) {
|
[&](const type::Void*) {
|
||||||
push_type(spv::Op::OpTypeVoid, {result});
|
push_type(spv::Op::OpTypeVoid, {result});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -3812,10 +3812,10 @@ bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& r
|
||||||
uint32_t type_id = Switch(
|
uint32_t type_id = Switch(
|
||||||
texture,
|
texture,
|
||||||
[&](const type::DepthTexture*) {
|
[&](const type::DepthTexture*) {
|
||||||
return GenerateTypeIfNeeded(builder_.create<sem::F32>());
|
return GenerateTypeIfNeeded(builder_.create<type::F32>());
|
||||||
},
|
},
|
||||||
[&](const type::DepthMultisampledTexture*) {
|
[&](const type::DepthMultisampledTexture*) {
|
||||||
return GenerateTypeIfNeeded(builder_.create<sem::F32>());
|
return GenerateTypeIfNeeded(builder_.create<type::F32>());
|
||||||
},
|
},
|
||||||
[&](const type::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); },
|
[&](const type::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); },
|
||||||
[&](const type::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); },
|
[&](const type::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); },
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include "src/tint/ast/stage_attribute.h"
|
#include "src/tint/ast/stage_attribute.h"
|
||||||
#include "src/tint/ast/variable.h"
|
#include "src/tint/ast/variable.h"
|
||||||
#include "src/tint/program.h"
|
#include "src/tint/program.h"
|
||||||
#include "src/tint/sem/f32.h"
|
|
||||||
#include "src/tint/sem/vector.h"
|
#include "src/tint/sem/vector.h"
|
||||||
|
#include "src/tint/type/f32.h"
|
||||||
#include "src/tint/writer/spirv/builder.h"
|
#include "src/tint/writer/spirv/builder.h"
|
||||||
#include "src/tint/writer/spirv/spv_dump.h"
|
#include "src/tint/writer/spirv/spv_dump.h"
|
||||||
#include "src/tint/writer/spirv/test_helper.h"
|
#include "src/tint/writer/spirv/test_helper.h"
|
||||||
|
|
|
@ -114,7 +114,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateBool) {
|
TEST_F(BuilderTest_Type, GenerateBool) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ TEST_F(BuilderTest_Type, GenerateBool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedBool) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedBool) {
|
||||||
auto* bool_ = create<sem::Bool>();
|
auto* bool_ = create<type::Bool>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedBool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateF32) {
|
TEST_F(BuilderTest_Type, GenerateF32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ TEST_F(BuilderTest_Type, GenerateF32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedF32) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedF32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateF16) {
|
TEST_F(BuilderTest_Type, GenerateF16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -184,8 +184,8 @@ TEST_F(BuilderTest_Type, GenerateF16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedF16) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedF16) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateI32) {
|
TEST_F(BuilderTest_Type, GenerateI32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ TEST_F(BuilderTest_Type, GenerateI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedI32) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedI32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedI32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateMatrix) {
|
TEST_F(BuilderTest_Type, GenerateMatrix) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* vec3 = create<sem::Vector>(f32, 3u);
|
auto* vec3 = create<sem::Vector>(f32, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ TEST_F(BuilderTest_Type, GenerateMatrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* col = create<sem::Vector>(i32, 4u);
|
auto* col = create<sem::Vector>(i32, 4u);
|
||||||
auto* mat = create<sem::Matrix>(col, 3u);
|
auto* mat = create<sem::Matrix>(col, 3u);
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateF16Matrix) {
|
TEST_F(BuilderTest_Type, GenerateF16Matrix) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* vec3 = create<sem::Vector>(f16, 3u);
|
auto* vec3 = create<sem::Vector>(f16, 3u);
|
||||||
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
auto* mat2x3 = create<sem::Matrix>(vec3, 2u);
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ TEST_F(BuilderTest_Type, GenerateF16Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) {
|
||||||
auto* f16 = create<sem::F16>();
|
auto* f16 = create<type::F16>();
|
||||||
auto* col = create<sem::Vector>(f16, 4u);
|
auto* col = create<sem::Vector>(f16, 4u);
|
||||||
auto* mat = create<sem::Matrix>(col, 3u);
|
auto* mat = create<sem::Matrix>(col, 3u);
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GeneratePtr) {
|
TEST_F(BuilderTest_Type, GeneratePtr) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* ptr = create<sem::Pointer>(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite);
|
auto* ptr = create<sem::Pointer>(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -307,7 +307,7 @@ TEST_F(BuilderTest_Type, GeneratePtr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* ptr = create<sem::Pointer>(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite);
|
auto* ptr = create<sem::Pointer>(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -517,7 +517,7 @@ OpDecorate %21 ArrayStride 64
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateU32) {
|
TEST_F(BuilderTest_Type, GenerateU32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -531,8 +531,8 @@ TEST_F(BuilderTest_Type, GenerateU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedU32) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedU32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedU32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateVector) {
|
TEST_F(BuilderTest_Type, GenerateVector) {
|
||||||
auto* vec = create<sem::Vector>(create<sem::F32>(), 3u);
|
auto* vec = create<sem::Vector>(create<type::F32>(), 3u);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ TEST_F(BuilderTest_Type, GenerateVector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* vec = create<sem::Vector>(i32, 3u);
|
auto* vec = create<sem::Vector>(i32, 3u);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -574,7 +574,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, GenerateVoid) {
|
TEST_F(BuilderTest_Type, GenerateVoid) {
|
||||||
auto* void_ = create<sem::Void>();
|
auto* void_ = create<type::Void>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -588,8 +588,8 @@ TEST_F(BuilderTest_Type, GenerateVoid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) {
|
TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) {
|
||||||
auto* void_ = create<sem::Void>();
|
auto* void_ = create<type::Void>();
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
||||||
auto* i32 = create<sem::I32>();
|
auto* i32 = create<type::I32>();
|
||||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, i32);
|
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, i32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -704,7 +704,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -718,7 +718,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, create<sem::I32>());
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, create<type::I32>());
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
||||||
auto* u32 = create<sem::U32>();
|
auto* u32 = create<type::U32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, u32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, u32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -767,7 +767,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -785,7 +785,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -799,7 +799,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2dArray, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2dArray, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -813,7 +813,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k3d, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::k3d, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -827,7 +827,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCube, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCube, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
@ -842,7 +842,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
||||||
auto* f32 = create<sem::F32>();
|
auto* f32 = create<type::F32>();
|
||||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCubeArray, f32);
|
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCubeArray, f32);
|
||||||
|
|
||||||
spirv::Builder& b = Build();
|
spirv::Builder& b = Build();
|
||||||
|
|
Loading…
Reference in New Issue