chromium/third_party/dawn/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_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.

// GEN_BUILD:CONDITION(tint_build_wgsl_writer)

#include <sstream>
#include <string>

#include "src/tint/lang/core/access.h"
#include "src/tint/lang/core/address_space.h"
#include "src/tint/lang/core/ir/disassembler.h"
#include "src/tint/lang/core/texel_format.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ir/builtin_call.h"
#include "src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.h"
#include "src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.h"
#include "src/tint/lang/wgsl/writer/writer.h"
#include "src/tint/utils/text/string.h"

namespace tint::wgsl::writer {

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

IRToProgramTest::Result IRToProgramTest::Run() {}

namespace {

TEST_F(IRToProgramTest, EmptyModule) {}

TEST_F(IRToProgramTest, SingleFunction_Return) {}

TEST_F(IRToProgramTest, SingleFunction_Return_i32) {}

TEST_F(IRToProgramTest, SingleFunction_Parameters) {}

TEST_F(IRToProgramTest, EntryPoint_Compute) {}

TEST_F(IRToProgramTest, EntryPoint_Fragment) {}

TEST_F(IRToProgramTest, EntryPoint_Vertex) {}

TEST_F(IRToProgramTest, EntryPoint_Parameter_BuiltinAndInvariant) {}

TEST_F(IRToProgramTest, EntryPoint_Parameter_LocationAndInterpolation) {}

TEST_F(IRToProgramTest, EntryPoint_Parameter_Color) {}

TEST_F(IRToProgramTest, EntryPoint_ReturnAttribute_FragDepth) {}

TEST_F(IRToProgramTest, EntryPoint_ReturnAttribute_SampleMask) {}

TEST_F(IRToProgramTest, EntryPoint_ReturnAttribute_Invariant) {}

TEST_F(IRToProgramTest, EntryPoint_ReturnAttribute_Location) {}

namespace {
core::ir::FunctionParam* MakeBuiltinParam(core::ir::Builder& b,
                                          const core::type::Type* type,
                                          enum core::BuiltinValue builtin) {}
}  // namespace

TEST_F(IRToProgramTest, EntryPoint_ParameterAttribute_Compute) {}

TEST_F(IRToProgramTest, EntryPoint_ParameterAttribute_Fragment) {}

////////////////////////////////////////////////////////////////////////////////
// Unary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, UnaryOp_Negate) {}

TEST_F(IRToProgramTest, UnaryOp_Complement) {}

TEST_F(IRToProgramTest, UnaryOp_Not) {}

////////////////////////////////////////////////////////////////////////////////
// Binary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, BinaryOp_Add) {}

TEST_F(IRToProgramTest, BinaryOp_Subtract) {}

TEST_F(IRToProgramTest, BinaryOp_Multiply) {}

TEST_F(IRToProgramTest, BinaryOp_Divide) {}

TEST_F(IRToProgramTest, BinaryOp_Modulo) {}

TEST_F(IRToProgramTest, BinaryOp_And) {}

TEST_F(IRToProgramTest, BinaryOp_Or) {}

TEST_F(IRToProgramTest, BinaryOp_Xor) {}

TEST_F(IRToProgramTest, BinaryOp_Equal) {}

TEST_F(IRToProgramTest, BinaryOp_NotEqual) {}

TEST_F(IRToProgramTest, BinaryOp_LessThan) {}

TEST_F(IRToProgramTest, BinaryOp_GreaterThan) {}

TEST_F(IRToProgramTest, BinaryOp_LessThanEqual) {}

TEST_F(IRToProgramTest, BinaryOp_GreaterThanEqual) {}

TEST_F(IRToProgramTest, BinaryOp_ShiftLeft) {}

TEST_F(IRToProgramTest, BinaryOp_ShiftRight) {}

////////////////////////////////////////////////////////////////////////////////
// Type Construct
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, TypeConstruct_i32) {}

TEST_F(IRToProgramTest, TypeConstruct_u32) {}

TEST_F(IRToProgramTest, TypeConstruct_f32) {}

TEST_F(IRToProgramTest, TypeConstruct_bool) {}

TEST_F(IRToProgramTest, TypeConstruct_struct) {}

TEST_F(IRToProgramTest, TypeConstruct_array) {}

TEST_F(IRToProgramTest, TypeConstruct_vec3i_Splat) {}

TEST_F(IRToProgramTest, TypeConstruct_vec3i_Scalars) {}

TEST_F(IRToProgramTest, TypeConstruct_mat2x3f_Scalars) {}

TEST_F(IRToProgramTest, TypeConstruct_mat2x3f_Columns) {}

TEST_F(IRToProgramTest, TypeConstruct_Inlining) {}

////////////////////////////////////////////////////////////////////////////////
// Type Convert
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, TypeConvert_i32_to_u32) {}

TEST_F(IRToProgramTest, TypeConvert_u32_to_f32) {}

TEST_F(IRToProgramTest, TypeConvert_f32_to_i32) {}

TEST_F(IRToProgramTest, TypeConvert_bool_to_u32) {}

TEST_F(IRToProgramTest, TypeConvert_vec3i_to_vec3u) {}

TEST_F(IRToProgramTest, TypeConvert_vec3u_to_vec3f) {}

TEST_F(IRToProgramTest, TypeConvert_mat2x3f_to_mat2x3h) {}

TEST_F(IRToProgramTest, TypeConvert_Inlining) {}

////////////////////////////////////////////////////////////////////////////////
// Short-circuiting binary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, ShortCircuit_And_2) {}

TEST_F(IRToProgramTest, ShortCircuit_And_3_ab_c) {}

TEST_F(IRToProgramTest, ShortCircuit_And_3_a_bc) {}

TEST_F(IRToProgramTest, ShortCircuit_Or_2) {}

TEST_F(IRToProgramTest, ShortCircuit_Or_3_ab_c) {}

TEST_F(IRToProgramTest, ShortCircuit_Or_3_a_bc) {}

TEST_F(IRToProgramTest, ShortCircuit_Mixed) {}

////////////////////////////////////////////////////////////////////////////////
// Compound assignment
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, CompoundAssign_Increment) {}

TEST_F(IRToProgramTest, CompoundAssign_Decrement) {}

TEST_F(IRToProgramTest, CompoundAssign_Add) {}

TEST_F(IRToProgramTest, CompoundAssign_Subtract) {}

TEST_F(IRToProgramTest, CompoundAssign_Multiply) {}

TEST_F(IRToProgramTest, CompoundAssign_Divide) {}

TEST_F(IRToProgramTest, CompoundAssign_Xor) {}

////////////////////////////////////////////////////////////////////////////////
// let
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, LetUsedOnce) {}

TEST_F(IRToProgramTest, LetUsedTwice) {}

////////////////////////////////////////////////////////////////////////////////
// Function-scope var
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, FunctionScopeVar_i32) {}

TEST_F(IRToProgramTest, FunctionScopeVar_i32_InitLiteral) {}

TEST_F(IRToProgramTest, FunctionScopeVar_Chained) {}

////////////////////////////////////////////////////////////////////////////////
// If
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, If_CallFn) {}

TEST_F(IRToProgramTest, If_Return) {}

TEST_F(IRToProgramTest, If_Return_i32) {}

TEST_F(IRToProgramTest, If_CallFn_Else_CallFn) {}

TEST_F(IRToProgramTest, If_Return_f32_Else_Return_f32) {}

TEST_F(IRToProgramTest, If_Return_u32_Else_CallFn) {}

TEST_F(IRToProgramTest, If_CallFn_ElseIf_CallFn) {}

TEST_F(IRToProgramTest, If_Else_Chain) {}

////////////////////////////////////////////////////////////////////////////////
// Switch
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, Switch_Default) {}

TEST_F(IRToProgramTest, Switch_3_Cases) {}

TEST_F(IRToProgramTest, Switch_3_Cases_AllReturn) {}

TEST_F(IRToProgramTest, Switch_Nested) {}

////////////////////////////////////////////////////////////////////////////////
// For
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, For_Empty) {}

TEST_F(IRToProgramTest, For_Empty_NoInit) {}

TEST_F(IRToProgramTest, For_Empty_NoCont) {}

TEST_F(IRToProgramTest, For_ComplexBody) {}

TEST_F(IRToProgramTest, For_ComplexBody_NoInit) {}

TEST_F(IRToProgramTest, For_ComplexBody_NoCont) {}

TEST_F(IRToProgramTest, For_CallInInitCondCont) {}

TEST_F(IRToProgramTest, For_IncInInit_Cmp) {}

////////////////////////////////////////////////////////////////////////////////
// While
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, While_Empty) {}

TEST_F(IRToProgramTest, While_Cond) {}

TEST_F(IRToProgramTest, While_Break) {}

TEST_F(IRToProgramTest, While_IfBreak) {}

TEST_F(IRToProgramTest, While_BreakAfterStatement) {}

// Test that only the first "if continue then break" instruction is treated as the loop condition.
// See crbug.com/351700183.
TEST_F(IRToProgramTest, While_IfBreakInFalse) {}

TEST_F(IRToProgramTest, While_IfReturn) {}

////////////////////////////////////////////////////////////////////////////////
// Loop
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, Loop_Break) {}

TEST_F(IRToProgramTest, Loop_IfBreak) {}

TEST_F(IRToProgramTest, Loop_IfReturn) {}

TEST_F(IRToProgramTest, Loop_IfContinuing) {}

TEST_F(IRToProgramTest, Loop_VarsDeclaredOutsideAndInside) {}

////////////////////////////////////////////////////////////////////////////////
// chromium_experimental_subgroups
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, Enable_ChromiumExperimentalSubgroups_SubgroupBallot) {}

TEST_F(IRToProgramTest, Enable_ChromiumExperimentalSubgroups_SubgroupBroadcast) {}

TEST_F(IRToProgramTest, Enable_ChromiumExperimentalSubgroups_StructBuiltin_SubgroupInvocationId) {}

TEST_F(IRToProgramTest, Enable_ChromiumExperimentalSubgroups_StructBuiltin_SubgroupSize) {}

TEST_F(IRToProgramTest, Enable_ChromiumExperimentalFramebufferFetch_StructColor) {}

////////////////////////////////////////////////////////////////////////////////
// chromium_internal_graphite
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramTest, Enable_ChromiumInternalGraphite_SubgroupBallot) {}

}  // namespace
}  // namespace tint::wgsl::writer