1fd4e5da5Sopenharmony_ci// Copyright (c) 2015-2016 The Khronos Group Inc. 2fd4e5da5Sopenharmony_ci// 3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License. 5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at 6fd4e5da5Sopenharmony_ci// 7fd4e5da5Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8fd4e5da5Sopenharmony_ci// 9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and 13fd4e5da5Sopenharmony_ci// limitations under the License. 14fd4e5da5Sopenharmony_ci 15fd4e5da5Sopenharmony_ci// Assembler tests for instructions in the "Group Instrucions" section of the 16fd4e5da5Sopenharmony_ci// SPIR-V spec. 17fd4e5da5Sopenharmony_ci 18fd4e5da5Sopenharmony_ci#include <string> 19fd4e5da5Sopenharmony_ci#include <vector> 20fd4e5da5Sopenharmony_ci 21fd4e5da5Sopenharmony_ci#include "gmock/gmock.h" 22fd4e5da5Sopenharmony_ci#include "test/test_fixture.h" 23fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h" 24fd4e5da5Sopenharmony_ci 25fd4e5da5Sopenharmony_cinamespace spvtools { 26fd4e5da5Sopenharmony_cinamespace { 27fd4e5da5Sopenharmony_ci 28fd4e5da5Sopenharmony_ciusing spvtest::EnumCase; 29fd4e5da5Sopenharmony_ciusing spvtest::MakeInstruction; 30fd4e5da5Sopenharmony_ciusing ::testing::Eq; 31fd4e5da5Sopenharmony_ci 32fd4e5da5Sopenharmony_ci// Test GroupOperation enum 33fd4e5da5Sopenharmony_ci 34fd4e5da5Sopenharmony_ciusing GroupOperationTest = spvtest::TextToBinaryTestBase< 35fd4e5da5Sopenharmony_ci ::testing::TestWithParam<EnumCase<spv::GroupOperation>>>; 36fd4e5da5Sopenharmony_ci 37fd4e5da5Sopenharmony_ciTEST_P(GroupOperationTest, AnyGroupOperation) { 38fd4e5da5Sopenharmony_ci const std::string input = 39fd4e5da5Sopenharmony_ci "%result = OpGroupIAdd %type %scope " + GetParam().name() + " %x"; 40fd4e5da5Sopenharmony_ci EXPECT_THAT(CompiledInstructions(input), 41fd4e5da5Sopenharmony_ci Eq(MakeInstruction(spv::Op::OpGroupIAdd, 42fd4e5da5Sopenharmony_ci {1, 2, 3, (uint32_t)GetParam().value(), 4}))); 43fd4e5da5Sopenharmony_ci} 44fd4e5da5Sopenharmony_ci 45fd4e5da5Sopenharmony_ci// clang-format off 46fd4e5da5Sopenharmony_ci#define CASE(NAME) { spv::GroupOperation::NAME, #NAME} 47fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(TextToBinaryGroupOperation, GroupOperationTest, 48fd4e5da5Sopenharmony_ci ::testing::ValuesIn(std::vector<EnumCase<spv::GroupOperation>>{ 49fd4e5da5Sopenharmony_ci CASE(Reduce), 50fd4e5da5Sopenharmony_ci CASE(InclusiveScan), 51fd4e5da5Sopenharmony_ci CASE(ExclusiveScan), 52fd4e5da5Sopenharmony_ci })); 53fd4e5da5Sopenharmony_ci#undef CASE 54fd4e5da5Sopenharmony_ci// clang-format on 55fd4e5da5Sopenharmony_ci 56fd4e5da5Sopenharmony_ciTEST_F(GroupOperationTest, WrongGroupOperation) { 57fd4e5da5Sopenharmony_ci EXPECT_THAT(CompileFailure("%r = OpGroupUMin %t %e xxyyzz %x"), 58fd4e5da5Sopenharmony_ci Eq("Invalid group operation 'xxyyzz'.")); 59fd4e5da5Sopenharmony_ci} 60fd4e5da5Sopenharmony_ci 61fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupAsyncCopy 62fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupWaitEvents 63fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupAll 64fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupAny 65fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupBroadcast 66fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupIAdd 67fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupFAdd 68fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupFMin 69fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupUMin 70fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupSMin 71fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupFMax 72fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupUMax 73fd4e5da5Sopenharmony_ci// TODO(dneto): OpGroupSMax 74fd4e5da5Sopenharmony_ci 75fd4e5da5Sopenharmony_ci} // namespace 76fd4e5da5Sopenharmony_ci} // namespace spvtools 77