chromium/third_party/dawn/src/tint/lang/wgsl/ast/transform/direct_variable_access_test.cc

// Copyright 2022 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 "src/tint/lang/wgsl/ast/transform/direct_variable_access.h"

#include <memory>
#include <utility>

#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
#include "src/tint/utils/text/string.h"

namespace tint::ast::transform {
namespace {

/// @returns a DataMap with DirectVariableAccess::Config::transform_private enabled.
static DataMap EnablePrivate() {}

/// @returns a DataMap with DirectVariableAccess::Config::transform_function enabled.
static DataMap EnableFunction() {}

////////////////////////////////////////////////////////////////////////////////
// ShouldRun tests
////////////////////////////////////////////////////////////////////////////////
namespace should_run {

DirectVariableAccessShouldRunTest;

TEST_F(DirectVariableAccessShouldRunTest, EmptyModule) {}

}  // namespace should_run

////////////////////////////////////////////////////////////////////////////////
// remove uncalled
////////////////////////////////////////////////////////////////////////////////
namespace remove_uncalled {

DirectVariableAccessRemoveUncalledTest;

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrUniform) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrStorage) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrWorkgroup) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrPrivate_Disabled) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrPrivate_Enabled) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrFunction_Disabled) {}

TEST_F(DirectVariableAccessRemoveUncalledTest, PtrFunction_Enabled) {}

}  // namespace remove_uncalled

////////////////////////////////////////////////////////////////////////////////
// pointer chains
////////////////////////////////////////////////////////////////////////////////
namespace pointer_chains_tests {

DirectVariableAccessPtrChainsTest;

TEST_F(DirectVariableAccessPtrChainsTest, ConstantIndices) {}

TEST_F(DirectVariableAccessPtrChainsTest, ConstantIndices_ViaPointerIndex) {}

TEST_F(DirectVariableAccessPtrChainsTest, HoistIndices) {}

TEST_F(DirectVariableAccessPtrChainsTest, HoistInForLoopInit) {}

TEST_F(DirectVariableAccessPtrChainsTest, HoistInForLoopCond) {}

TEST_F(DirectVariableAccessPtrChainsTest, HoistInForLoopCont) {}

TEST_F(DirectVariableAccessPtrChainsTest, HoistInWhileCond) {}

}  // namespace pointer_chains_tests

////////////////////////////////////////////////////////////////////////////////
// 'uniform' address space
////////////////////////////////////////////////////////////////////////////////
namespace uniform_as_tests {

DirectVariableAccessUniformASTest;

TEST_F(DirectVariableAccessUniformASTest, Param_ptr_i32_read) {}

TEST_F(DirectVariableAccessUniformASTest, Param_ptr_vec4i32_Via_array_DynamicRead) {}

TEST_F(DirectVariableAccessUniformASTest, Param_ptr_vec4i32_Via_array_DynamicRead_ViaPointerDot) {}

TEST_F(DirectVariableAccessUniformASTest, CallChaining) {}

TEST_F(DirectVariableAccessUniformASTest, CallChaining_ViaPointerDotOrIndex) {}

TEST_F(DirectVariableAccessUniformASTest, CallChaining2) {}

}  // namespace uniform_as_tests

////////////////////////////////////////////////////////////////////////////////
// 'storage' address space
////////////////////////////////////////////////////////////////////////////////
namespace storage_as_tests {

DirectVariableAccessStorageASTest;

TEST_F(DirectVariableAccessStorageASTest, Param_ptr_i32_Via_struct_read) {}

TEST_F(DirectVariableAccessStorageASTest, Param_ptr_arr_i32_Via_struct_write) {}

TEST_F(DirectVariableAccessStorageASTest, Param_ptr_vec4i32_Via_array_DynamicWrite) {}

TEST_F(DirectVariableAccessStorageASTest, CallChaining) {}

TEST_F(DirectVariableAccessStorageASTest, CallChaining_ViaPointerDotOrIndex) {}

TEST_F(DirectVariableAccessStorageASTest, CallChaining2) {}

}  // namespace storage_as_tests

////////////////////////////////////////////////////////////////////////////////
// 'workgroup' address space
////////////////////////////////////////////////////////////////////////////////
namespace workgroup_as_tests {

DirectVariableAccessWorkgroupASTest;

TEST_F(DirectVariableAccessWorkgroupASTest, Param_ptr_vec4i32_Via_array_StaticRead) {}

TEST_F(DirectVariableAccessWorkgroupASTest, Param_ptr_vec4i32_Via_array_StaticWrite) {}

TEST_F(DirectVariableAccessWorkgroupASTest, CallChaining) {}

TEST_F(DirectVariableAccessWorkgroupASTest, CallChaining_ViaPointerDotOrIndex) {}

TEST_F(DirectVariableAccessWorkgroupASTest, CallChaining2) {}

}  // namespace workgroup_as_tests

////////////////////////////////////////////////////////////////////////////////
// 'private' address space
////////////////////////////////////////////////////////////////////////////////
namespace private_as_tests {

DirectVariableAccessPrivateASTest;

TEST_F(DirectVariableAccessPrivateASTest, Enabled_Param_ptr_i32_read) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_Param_ptr_i32_write) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_Param_ptr_i32_Via_struct_read) {}

TEST_F(DirectVariableAccessPrivateASTest, Disabled_Param_ptr_i32_Via_struct_read) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_Param_ptr_arr_i32_Via_struct_write) {}

TEST_F(DirectVariableAccessPrivateASTest, Disabled_Param_ptr_arr_i32_Via_struct_write) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_Param_ptr_i32_mixed) {}

TEST_F(DirectVariableAccessPrivateASTest, Disabled_Param_ptr_i32_mixed) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_CallChaining) {}

TEST_F(DirectVariableAccessPrivateASTest, Enabled_CallChaining2) {}

TEST_F(DirectVariableAccessPrivateASTest, Disabled_CallChaining) {}

}  // namespace private_as_tests

////////////////////////////////////////////////////////////////////////////////
// 'function' address space
////////////////////////////////////////////////////////////////////////////////
namespace function_as_tests {

DirectVariableAccessFunctionASTest;

TEST_F(DirectVariableAccessFunctionASTest, Enabled_LocalPtr) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_Param_ptr_i32_read) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_Param_ptr_i32_write) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_Param_ptr_i32_Via_struct_read) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_Param_ptr_arr_i32_Via_struct_write) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_Param_ptr_i32_mixed) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_CallChaining) {}

TEST_F(DirectVariableAccessFunctionASTest, Enabled_CallChaining2) {}

TEST_F(DirectVariableAccessFunctionASTest, Disabled_Param_ptr_i32_Via_struct_read) {}

TEST_F(DirectVariableAccessFunctionASTest, Disabled_Param_ptr_arr_i32_Via_struct_write) {}

TEST_F(DirectVariableAccessFunctionASTest, PointerForwarding_NoUse) {}

}  // namespace function_as_tests

////////////////////////////////////////////////////////////////////////////////
// complex tests
////////////////////////////////////////////////////////////////////////////////
namespace complex_tests {

DirectVariableAccessComplexTest;

TEST_F(DirectVariableAccessComplexTest, Param_ptr_mixed_vec4i32_ViaMultiple) {}

TEST_F(DirectVariableAccessComplexTest, Indexing) {}

TEST_F(DirectVariableAccessComplexTest, IndexingInPtrCall) {}

TEST_F(DirectVariableAccessComplexTest, IndexingDualPointers) {}

}  // namespace complex_tests

}  // namespace
}  // namespace tint::ast::transform