chromium/third_party/dawn/src/tint/lang/core/ir/validator_test.cc

// Copyright 2023 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <string>
#include <tuple>
#include <utility>

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include "src/tint/lang/core/address_space.h"
#include "src/tint/lang/core/ir/builder.h"
#include "src/tint/lang/core/ir/function_param.h"
#include "src/tint/lang/core/ir/ir_helper_test.h"
#include "src/tint/lang/core/ir/validator.h"
#include "src/tint/lang/core/number.h"
#include "src/tint/lang/core/type/manager.h"
#include "src/tint/lang/core/type/matrix.h"
#include "src/tint/lang/core/type/memory_view.h"
#include "src/tint/lang/core/type/pointer.h"
#include "src/tint/lang/core/type/reference.h"
#include "src/tint/lang/core/type/struct.h"
#include "src/tint/utils/text/string.h"

namespace tint::core::ir {
namespace {

usingnamespacetint::core::fluent_types;     // NOLINT
usingnamespacetint::core::number_suffixes;  // NOLINT

IR_ValidatorTest;

TEST_F(IR_ValidatorTest, RootBlock_Var) {}

TEST_F(IR_ValidatorTest, RootBlock_NonVar) {}

TEST_F(IR_ValidatorTest, RootBlock_Let) {}

TEST_F(IR_ValidatorTest, RootBlock_LetWithAllowModuleScopeLets) {}

TEST_F(IR_ValidatorTest, RootBlock_Construct) {}

TEST_F(IR_ValidatorTest, RootBlock_ConstructWithAllowModuleScopeLets) {}

TEST_F(IR_ValidatorTest, RootBlock_VarBlockMismatch) {}

TEST_F(IR_ValidatorTest, Function) {}

TEST_F(IR_ValidatorTest, Function_Duplicate) {}

TEST_F(IR_ValidatorTest, Function_DeadParameter) {}

TEST_F(IR_ValidatorTest, Function_ParameterWithNullFunction) {}

TEST_F(IR_ValidatorTest, Function_ParameterUsedInMultipleFunctions) {}

TEST_F(IR_ValidatorTest, Function_ParameterWithNullType) {}

TEST_F(IR_ValidatorTest, Function_MissingWorkgroupSize) {}

TEST_F(IR_ValidatorTest, Function_UnnamedEntryPoint) {}

TEST_F(IR_ValidatorTest, Function_NonConstructibleReturnType) {}

TEST_F(IR_ValidatorTest, Function_UnexpectedFragDepth) {}

TEST_F(IR_ValidatorTest, CallToFunctionOutsideModule) {}

TEST_F(IR_ValidatorTest, CallToEntryPointFunction) {}

TEST_F(IR_ValidatorTest, CallToFunctionTooFewArguments) {}

TEST_F(IR_ValidatorTest, CallToFunctionTooManyArguments) {}

TEST_F(IR_ValidatorTest, CallToFunctionWrongArgType) {}

TEST_F(IR_ValidatorTest, CallToFunctionNullArg) {}

TEST_F(IR_ValidatorTest, CallToNullFunction) {}

TEST_F(IR_ValidatorTest, CallToFunctionNoResult) {}

TEST_F(IR_ValidatorTest, CallToFunctionNoOperands) {}

TEST_F(IR_ValidatorTest, CallToNonFunctionTarget) {}

TEST_F(IR_ValidatorTest, CallToBuiltinMissingResult) {}

TEST_F(IR_ValidatorTest, CallToBuiltinMismatchResultType) {}

TEST_F(IR_ValidatorTest, CallToBuiltinArgNullType) {}

TEST_F(IR_ValidatorTest, Bitcast_MissingArg) {}

TEST_F(IR_ValidatorTest, Bitcast_NullArg) {}

TEST_F(IR_ValidatorTest, Bitcast_MissingResult) {}

TEST_F(IR_ValidatorTest, Bitcast_NullResult) {}

TEST_F(IR_ValidatorTest, Construct_Struct_ZeroValue) {}

TEST_F(IR_ValidatorTest, Construct_Struct_ValidArgs) {}

TEST_F(IR_ValidatorTest, Construct_Struct_UnusedArgs) {}

TEST_F(IR_ValidatorTest, Construct_Struct_NotEnoughArgs) {}

TEST_F(IR_ValidatorTest, Construct_Struct_TooManyArgs) {}

TEST_F(IR_ValidatorTest, Construct_Struct_WrongArgType) {}

TEST_F(IR_ValidatorTest, Construct_NullArg) {}

TEST_F(IR_ValidatorTest, Construct_NullResult) {}

TEST_F(IR_ValidatorTest, Construct_EmptyResult) {}

TEST_F(IR_ValidatorTest, Convert_MissingArg) {}

TEST_F(IR_ValidatorTest, Convert_NullArg) {}

TEST_F(IR_ValidatorTest, Convert_MissingResult) {}

TEST_F(IR_ValidatorTest, Convert_NullResult) {}

TEST_F(IR_ValidatorTest, Discard_TooManyOperands) {}

TEST_F(IR_ValidatorTest, Discard_TooManyResults) {}

TEST_F(IR_ValidatorTest, Discard_NotInFragment) {}

TEST_F(IR_ValidatorTest, Block_NoTerminator) {}

TEST_F(IR_ValidatorTest, Block_VarBlockMismatch) {}

TEST_F(IR_ValidatorTest, Block_DeadParameter) {}

TEST_F(IR_ValidatorTest, Block_ParameterWithNullBlock) {}

TEST_F(IR_ValidatorTest, Block_ParameterUsedInMultipleBlocks) {}

TEST_F(IR_ValidatorTest, Access_NoOperands) {}

TEST_F(IR_ValidatorTest, Access_NoResults) {}

TEST_F(IR_ValidatorTest, Access_NullObject) {}

TEST_F(IR_ValidatorTest, Access_NullIndex) {}

TEST_F(IR_ValidatorTest, Access_NegativeIndex) {}

TEST_F(IR_ValidatorTest, Access_OOB_Index_Value) {}

TEST_F(IR_ValidatorTest, Access_OOB_Index_Ptr) {}

TEST_F(IR_ValidatorTest, Access_StaticallyUnindexableType_Value) {}

TEST_F(IR_ValidatorTest, Access_StaticallyUnindexableType_Ptr) {}

TEST_F(IR_ValidatorTest, Access_DynamicallyUnindexableType_Value) {}

TEST_F(IR_ValidatorTest, Access_DynamicallyUnindexableType_Ptr) {}

TEST_F(IR_ValidatorTest, Access_Incorrect_Type_Value_Value) {}

TEST_F(IR_ValidatorTest, Access_Incorrect_Type_Ptr_Ptr) {}

TEST_F(IR_ValidatorTest, Access_Incorrect_Type_Ptr_Value) {}

TEST_F(IR_ValidatorTest, Access_IndexVectorPtr) {}

TEST_F(IR_ValidatorTest, Access_IndexVectorPtr_WithCapability) {}

TEST_F(IR_ValidatorTest, Access_IndexVectorPtr_ViaMatrixPtr) {}

TEST_F(IR_ValidatorTest, Access_IndexVectorPtr_ViaMatrixPtr_WithCapability) {}

TEST_F(IR_ValidatorTest, Access_Incorrect_Ptr_AddressSpace) {}

TEST_F(IR_ValidatorTest, Access_Incorrect_Ptr_Access) {}

TEST_F(IR_ValidatorTest, Access_IndexVector) {}

TEST_F(IR_ValidatorTest, Access_IndexVector_ViaMatrix) {}

TEST_F(IR_ValidatorTest, Access_ExtractPointerFromStruct) {}

TEST_F(IR_ValidatorTest, Block_TerminatorInMiddle) {}

TEST_F(IR_ValidatorTest, If_EmptyFalse) {}

TEST_F(IR_ValidatorTest, If_EmptyTrue) {}

TEST_F(IR_ValidatorTest, If_ConditionIsBool) {}

TEST_F(IR_ValidatorTest, If_ConditionIsNullptr) {}

TEST_F(IR_ValidatorTest, If_NullResult) {}

TEST_F(IR_ValidatorTest, Loop_OnlyBody) {}

TEST_F(IR_ValidatorTest, Loop_EmptyBody) {}

TEST_F(IR_ValidatorTest, Var_RootBlock_NullResult) {}

TEST_F(IR_ValidatorTest, Var_Function_NullResult) {}

TEST_F(IR_ValidatorTest, Var_Function_NoResult) {}

TEST_F(IR_ValidatorTest, Var_Function_NonPtrResult) {}

TEST_F(IR_ValidatorTest, Var_Function_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_Private_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_PushConstant_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_Storage_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_Uniform_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_Workgroup_UnexpectedInputAttachmentIndex) {}

TEST_F(IR_ValidatorTest, Var_Init_WrongType) {}

TEST_F(IR_ValidatorTest, Var_Init_NullType) {}

TEST_F(IR_ValidatorTest, Var_HandleMissingBindingPoint) {}

TEST_F(IR_ValidatorTest, Var_StorageMissingBindingPoint) {}

TEST_F(IR_ValidatorTest, Var_UniformMissingBindingPoint) {}

TEST_F(IR_ValidatorTest, Let_NullResult) {}

TEST_F(IR_ValidatorTest, Let_NullValue) {}

TEST_F(IR_ValidatorTest, Let_WrongType) {}

TEST_F(IR_ValidatorTest, Instruction_AppendedDead) {}

TEST_F(IR_ValidatorTest, Instruction_NullInstruction) {}

TEST_F(IR_ValidatorTest, Instruction_DeadOperand) {}

TEST_F(IR_ValidatorTest, Instruction_OperandUsageRemoved) {}

TEST_F(IR_ValidatorTest, Instruction_OrphanedInstruction) {}

TEST_F(IR_ValidatorTest, Binary_LHS_Nullptr) {}

TEST_F(IR_ValidatorTest, Binary_RHS_Nullptr) {}

TEST_F(IR_ValidatorTest, Binary_Result_Nullptr) {}

TEST_F(IR_ValidatorTest, Binary_MissingOperands) {}

TEST_F(IR_ValidatorTest, Binary_MissingResult) {}

TEST_F(IR_ValidatorTest, Unary_Value_Nullptr) {}

TEST_F(IR_ValidatorTest, Unary_Result_Nullptr) {}

TEST_F(IR_ValidatorTest, Unary_ResultTypeNotMatchValueType) {}

TEST_F(IR_ValidatorTest, Unary_MissingOperands) {}

TEST_F(IR_ValidatorTest, Unary_MissingResults) {}

TEST_F(IR_ValidatorTest, ExitIf) {}

TEST_F(IR_ValidatorTest, ExitIf_NullIf) {}

TEST_F(IR_ValidatorTest, ExitIf_LessOperandsThenIfParams) {}

TEST_F(IR_ValidatorTest, ExitIf_MoreOperandsThenIfParams) {}

TEST_F(IR_ValidatorTest, ExitIf_WithResult) {}

TEST_F(IR_ValidatorTest, ExitIf_IncorrectResultType) {}

TEST_F(IR_ValidatorTest, ExitIf_NotInParentIf) {}

TEST_F(IR_ValidatorTest, ExitIf_InvalidJumpsOverIf) {}

TEST_F(IR_ValidatorTest, ExitIf_InvalidJumpOverSwitch) {}

TEST_F(IR_ValidatorTest, ExitIf_InvalidJumpOverLoop) {}

TEST_F(IR_ValidatorTest, ExitSwitch) {}

TEST_F(IR_ValidatorTest, ExitSwitch_NullSwitch) {}

TEST_F(IR_ValidatorTest, ExitSwitch_LessOperandsThenSwitchParams) {}

TEST_F(IR_ValidatorTest, ExitSwitch_MoreOperandsThenSwitchParams) {}

TEST_F(IR_ValidatorTest, ExitSwitch_WithResult) {}

TEST_F(IR_ValidatorTest, ExitSwitch_IncorrectResultType) {}

TEST_F(IR_ValidatorTest, ExitSwitch_NotInParentSwitch) {}

TEST_F(IR_ValidatorTest, ExitSwitch_JumpsOverIfs) {}

TEST_F(IR_ValidatorTest, ExitSwitch_InvalidJumpOverSwitch) {}

TEST_F(IR_ValidatorTest, ExitSwitch_InvalidJumpOverLoop) {}

TEST_F(IR_ValidatorTest, Continue_OutsideOfLoop) {}

TEST_F(IR_ValidatorTest, Continue_InLoopInit) {}

TEST_F(IR_ValidatorTest, Continue_InLoopBody) {}

TEST_F(IR_ValidatorTest, Continue_InLoopContinuing) {}

TEST_F(IR_ValidatorTest, Continue_UnexpectedValues) {}

TEST_F(IR_ValidatorTest, Continue_MissingValues) {}

TEST_F(IR_ValidatorTest, Continue_MismatchedTypes) {}

TEST_F(IR_ValidatorTest, Continue_MatchedTypes) {}

TEST_F(IR_ValidatorTest, NextIteration_OutsideOfLoop) {}

TEST_F(IR_ValidatorTest, NextIteration_InLoopInit) {}

TEST_F(IR_ValidatorTest, NextIteration_InLoopBody) {}

TEST_F(IR_ValidatorTest, NextIteration_InLoopContinuing) {}

TEST_F(IR_ValidatorTest, NextIteration_UnexpectedValues) {}

TEST_F(IR_ValidatorTest, NextIteration_MissingValues) {}

TEST_F(IR_ValidatorTest, NextIteration_MismatchedTypes) {}

TEST_F(IR_ValidatorTest, NextIteration_MatchedTypes) {}

TEST_F(IR_ValidatorTest, LoopBodyParamsWithoutInitializer) {}

TEST_F(IR_ValidatorTest, ContinuingUseValueBeforeContinue) {}

TEST_F(IR_ValidatorTest, ContinuingUseValueAfterContinue) {}

TEST_F(IR_ValidatorTest, BreakIf_NextIterUnexpectedValues) {}

TEST_F(IR_ValidatorTest, BreakIf_NextIterMissingValues) {}

TEST_F(IR_ValidatorTest, BreakIf_NextIterMismatchedTypes) {}

TEST_F(IR_ValidatorTest, BreakIf_NextIterMatchedTypes) {}

TEST_F(IR_ValidatorTest, BreakIf_ExitUnexpectedValues) {}

TEST_F(IR_ValidatorTest, BreakIf_ExitMissingValues) {}

TEST_F(IR_ValidatorTest, BreakIf_ExitMismatchedTypes) {}

TEST_F(IR_ValidatorTest, BreakIf_ExitMatchedTypes) {}

TEST_F(IR_ValidatorTest, ExitLoop) {}

TEST_F(IR_ValidatorTest, ExitLoop_NullLoop) {}

TEST_F(IR_ValidatorTest, ExitLoop_LessOperandsThenLoopParams) {}

TEST_F(IR_ValidatorTest, ExitLoop_MoreOperandsThenLoopParams) {}

TEST_F(IR_ValidatorTest, ExitLoop_WithResult) {}

TEST_F(IR_ValidatorTest, ExitLoop_IncorrectResultType) {}

TEST_F(IR_ValidatorTest, ExitLoop_NotInParentLoop) {}

TEST_F(IR_ValidatorTest, ExitLoop_JumpsOverIfs) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidJumpOverSwitch) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidJumpOverLoop) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidInsideContinuing) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidInsideContinuingNested) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidInsideInitializer) {}

TEST_F(IR_ValidatorTest, ExitLoop_InvalidInsideInitializerNested) {}

TEST_F(IR_ValidatorTest, Return) {}

TEST_F(IR_ValidatorTest, Return_WithValue) {}

TEST_F(IR_ValidatorTest, Return_UnexpectedResult) {}

TEST_F(IR_ValidatorTest, Return_NotFunction) {}

TEST_F(IR_ValidatorTest, Return_MissingFunction) {}

TEST_F(IR_ValidatorTest, Return_UnexpectedValue) {}

TEST_F(IR_ValidatorTest, Return_MissingValue) {}

TEST_F(IR_ValidatorTest, Return_WrongValueType) {}

TEST_F(IR_ValidatorTest, Load_NullFrom) {}

TEST_F(IR_ValidatorTest, Load_SourceNotMemoryView) {}

TEST_F(IR_ValidatorTest, Load_TypeMismatch) {}

TEST_F(IR_ValidatorTest, Load_MissingResult) {}

TEST_F(IR_ValidatorTest, Store_NullTo) {}

TEST_F(IR_ValidatorTest, Store_NullFrom) {}

TEST_F(IR_ValidatorTest, Store_NullToAndFrom) {}

TEST_F(IR_ValidatorTest, Store_NonEmptyResult) {}

TEST_F(IR_ValidatorTest, Store_TargetNotMemoryView) {}

TEST_F(IR_ValidatorTest, Store_TypeMismatch) {}

TEST_F(IR_ValidatorTest, Store_NoStoreType) {}

TEST_F(IR_ValidatorTest, Store_NoValueType) {}

TEST_F(IR_ValidatorTest, LoadVectorElement_NullResult) {}

TEST_F(IR_ValidatorTest, LoadVectorElement_NullFrom) {}

TEST_F(IR_ValidatorTest, LoadVectorElement_NullIndex) {}

TEST_F(IR_ValidatorTest, LoadVectorElement_MissingResult) {}

TEST_F(IR_ValidatorTest, LoadVectorElement_MissingOperands) {}

TEST_F(IR_ValidatorTest, StoreVectorElement_NullTo) {}

TEST_F(IR_ValidatorTest, StoreVectorElement_NullIndex) {}

TEST_F(IR_ValidatorTest, StoreVectorElement_NullValue) {}

TEST_F(IR_ValidatorTest, StoreVectorElement_MissingOperands) {}

TEST_F(IR_ValidatorTest, StoreVectorElement_UnexpectedResult) {}

TEST_F(IR_ValidatorTest, Scoping_UseBeforeDecl) {}

template <typename T>
static const type::Type* TypeBuilder(type::Manager& m) {}
template <typename T>
static const type::Type* RefTypeBuilder(type::Manager& m) {}
TypeBuilderFn;

IR_ValidatorRefTypeTest;

TEST_P(IR_ValidatorRefTypeTest, Var) {}

TEST_P(IR_ValidatorRefTypeTest, FnParam) {}

TEST_P(IR_ValidatorRefTypeTest, FnRet) {}

TEST_P(IR_ValidatorRefTypeTest, BlockParam) {}

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

TEST_F(IR_ValidatorTest, PointerToPointer) {}

TEST_F(IR_ValidatorTest, ReferenceToReference) {}

TEST_F(IR_ValidatorTest, PointerInStructure_WithoutCapability) {}

TEST_F(IR_ValidatorTest, PointerInStructure_WithCapability) {}

IR_Validator8BitIntTypeTest;

TEST_P(IR_Validator8BitIntTypeTest, Var) {}

TEST_P(IR_Validator8BitIntTypeTest, FnParam) {}

TEST_P(IR_Validator8BitIntTypeTest, FnRet) {}

TEST_P(IR_Validator8BitIntTypeTest, BlockParam) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(IR_ValidatorTest, Int8Type_InstructionOperand_NotAllowed) {}

TEST_F(IR_ValidatorTest, Int8Type_InstructionOperand_Allowed) {}

TEST_F(IR_ValidatorTest, Switch_NoCondition) {}

TEST_F(IR_ValidatorTest, Switch_ConditionPointer) {}

TEST_F(IR_ValidatorTest, Switch_NoCases) {}

TEST_F(IR_ValidatorTest, Switch_NoDefaultCase) {}

TEST_F(IR_ValidatorTest, Swizzle_MissingValue) {}

TEST_F(IR_ValidatorTest, Swizzle_NullValue) {}

TEST_F(IR_ValidatorTest, Swizzle_MissingResult) {}

TEST_F(IR_ValidatorTest, Swizzle_NullResult) {}

TEST_F(IR_ValidatorTest, Swizzle_NoIndices) {}

TEST_F(IR_ValidatorTest, Swizzle_TooManyIndices) {}

TEST_F(IR_ValidatorTest, Swizzle_InvalidIndices) {}

}  // namespace
}  // namespace tint::core::ir