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#include <vector> 16fd4e5da5Sopenharmony_ci 17fd4e5da5Sopenharmony_ci#include "gmock/gmock.h" 18fd4e5da5Sopenharmony_ci#include "source/operand.h" 19fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h" 20fd4e5da5Sopenharmony_ci 21fd4e5da5Sopenharmony_cinamespace spvtools { 22fd4e5da5Sopenharmony_cinamespace { 23fd4e5da5Sopenharmony_ci 24fd4e5da5Sopenharmony_ciusing ::testing::Eq; 25fd4e5da5Sopenharmony_ci 26fd4e5da5Sopenharmony_ciTEST(OperandPattern, InitiallyEmpty) { 27fd4e5da5Sopenharmony_ci spv_operand_pattern_t empty; 28fd4e5da5Sopenharmony_ci EXPECT_THAT(empty, Eq(spv_operand_pattern_t{})); 29fd4e5da5Sopenharmony_ci EXPECT_EQ(0u, empty.size()); 30fd4e5da5Sopenharmony_ci EXPECT_TRUE(empty.empty()); 31fd4e5da5Sopenharmony_ci} 32fd4e5da5Sopenharmony_ci 33fd4e5da5Sopenharmony_ciTEST(OperandPattern, PushBacksAreOnTheRight) { 34fd4e5da5Sopenharmony_ci spv_operand_pattern_t pattern; 35fd4e5da5Sopenharmony_ci 36fd4e5da5Sopenharmony_ci pattern.push_back(SPV_OPERAND_TYPE_ID); 37fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_ID})); 38fd4e5da5Sopenharmony_ci EXPECT_EQ(1u, pattern.size()); 39fd4e5da5Sopenharmony_ci EXPECT_TRUE(!pattern.empty()); 40fd4e5da5Sopenharmony_ci EXPECT_EQ(SPV_OPERAND_TYPE_ID, pattern.back()); 41fd4e5da5Sopenharmony_ci 42fd4e5da5Sopenharmony_ci pattern.push_back(SPV_OPERAND_TYPE_NONE); 43fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_ID, 44fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_NONE})); 45fd4e5da5Sopenharmony_ci EXPECT_EQ(2u, pattern.size()); 46fd4e5da5Sopenharmony_ci EXPECT_TRUE(!pattern.empty()); 47fd4e5da5Sopenharmony_ci EXPECT_EQ(SPV_OPERAND_TYPE_NONE, pattern.back()); 48fd4e5da5Sopenharmony_ci} 49fd4e5da5Sopenharmony_ci 50fd4e5da5Sopenharmony_ciTEST(OperandPattern, PopBacksAreOnTheRight) { 51fd4e5da5Sopenharmony_ci spv_operand_pattern_t pattern{SPV_OPERAND_TYPE_ID, 52fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_LITERAL_INTEGER}; 53fd4e5da5Sopenharmony_ci 54fd4e5da5Sopenharmony_ci pattern.pop_back(); 55fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_ID})); 56fd4e5da5Sopenharmony_ci 57fd4e5da5Sopenharmony_ci pattern.pop_back(); 58fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(spv_operand_pattern_t{})); 59fd4e5da5Sopenharmony_ci} 60fd4e5da5Sopenharmony_ci 61fd4e5da5Sopenharmony_ci// A test case for typed mask expansion 62fd4e5da5Sopenharmony_cistruct MaskExpansionCase { 63fd4e5da5Sopenharmony_ci spv_operand_type_t type; 64fd4e5da5Sopenharmony_ci uint32_t mask; 65fd4e5da5Sopenharmony_ci spv_operand_pattern_t initial; 66fd4e5da5Sopenharmony_ci spv_operand_pattern_t expected; 67fd4e5da5Sopenharmony_ci}; 68fd4e5da5Sopenharmony_ci 69fd4e5da5Sopenharmony_ciusing MaskExpansionTest = ::testing::TestWithParam<MaskExpansionCase>; 70fd4e5da5Sopenharmony_ci 71fd4e5da5Sopenharmony_ciTEST_P(MaskExpansionTest, Sample) { 72fd4e5da5Sopenharmony_ci spv_operand_table operandTable = nullptr; 73fd4e5da5Sopenharmony_ci auto env = SPV_ENV_UNIVERSAL_1_0; 74fd4e5da5Sopenharmony_ci ASSERT_EQ(SPV_SUCCESS, spvOperandTableGet(&operandTable, env)); 75fd4e5da5Sopenharmony_ci 76fd4e5da5Sopenharmony_ci spv_operand_pattern_t pattern(GetParam().initial); 77fd4e5da5Sopenharmony_ci spvPushOperandTypesForMask(env, operandTable, GetParam().type, 78fd4e5da5Sopenharmony_ci GetParam().mask, &pattern); 79fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(GetParam().expected)); 80fd4e5da5Sopenharmony_ci} 81fd4e5da5Sopenharmony_ci 82fd4e5da5Sopenharmony_ci// These macros let us write non-trivial examples without too much text. 83fd4e5da5Sopenharmony_ci#define PREFIX0 SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_NONE 84fd4e5da5Sopenharmony_ci#define PREFIX1 \ 85fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_STORAGE_CLASS, SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE, \ 86fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_ID 87fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P( 88fd4e5da5Sopenharmony_ci OperandPattern, MaskExpansionTest, 89fd4e5da5Sopenharmony_ci ::testing::ValuesIn(std::vector<MaskExpansionCase>{ 90fd4e5da5Sopenharmony_ci // No bits means no change. 91fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 0, {PREFIX0}, {PREFIX0}}, 92fd4e5da5Sopenharmony_ci // Unknown bits means no change. Use all bits that aren't in the 93fd4e5da5Sopenharmony_ci // grammar. 94fd4e5da5Sopenharmony_ci // The used mask bits are: 95fd4e5da5Sopenharmony_ci // 1 through... 96fd4e5da5Sopenharmony_ci // 0x20 SpvMemoryAccessNonPrivatePointerMask 97fd4e5da5Sopenharmony_ci // also 98fd4e5da5Sopenharmony_ci // 0x10000 SpvMemoryAccessAliasScopeINTELMaskShift 99fd4e5da5Sopenharmony_ci // 0x20000 SpvMemoryAccessNoAliasINTELMaskMask 100fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 101fd4e5da5Sopenharmony_ci 0xffffffc0 ^ (0x10000) ^ (0x20000), 102fd4e5da5Sopenharmony_ci {PREFIX1}, 103fd4e5da5Sopenharmony_ci {PREFIX1}}, 104fd4e5da5Sopenharmony_ci // Volatile has no operands. 105fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 106fd4e5da5Sopenharmony_ci uint32_t(spv::MemoryAccessMask::Volatile), 107fd4e5da5Sopenharmony_ci {PREFIX0}, 108fd4e5da5Sopenharmony_ci {PREFIX0}}, 109fd4e5da5Sopenharmony_ci // Aligned has one literal number operand. 110fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 111fd4e5da5Sopenharmony_ci uint32_t(spv::MemoryAccessMask::Aligned), 112fd4e5da5Sopenharmony_ci {PREFIX1}, 113fd4e5da5Sopenharmony_ci {PREFIX1, SPV_OPERAND_TYPE_LITERAL_INTEGER}}, 114fd4e5da5Sopenharmony_ci // Volatile with Aligned still has just one literal number operand. 115fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, 116fd4e5da5Sopenharmony_ci uint32_t(spv::MemoryAccessMask::Volatile | 117fd4e5da5Sopenharmony_ci spv::MemoryAccessMask::Aligned), 118fd4e5da5Sopenharmony_ci {PREFIX1}, 119fd4e5da5Sopenharmony_ci {PREFIX1, SPV_OPERAND_TYPE_LITERAL_INTEGER}}, 120fd4e5da5Sopenharmony_ci // Newer masks are not tested 121fd4e5da5Sopenharmony_ci })); 122fd4e5da5Sopenharmony_ci#undef PREFIX0 123fd4e5da5Sopenharmony_ci#undef PREFIX1 124fd4e5da5Sopenharmony_ci 125fd4e5da5Sopenharmony_ci// Returns a vector of all operand types that can be used in a pattern. 126fd4e5da5Sopenharmony_cistd::vector<spv_operand_type_t> allOperandTypes() { 127fd4e5da5Sopenharmony_ci std::vector<spv_operand_type_t> result; 128fd4e5da5Sopenharmony_ci for (int i = 0; i < SPV_OPERAND_TYPE_NUM_OPERAND_TYPES; i++) { 129fd4e5da5Sopenharmony_ci result.push_back(spv_operand_type_t(i)); 130fd4e5da5Sopenharmony_ci } 131fd4e5da5Sopenharmony_ci return result; 132fd4e5da5Sopenharmony_ci} 133fd4e5da5Sopenharmony_ci 134fd4e5da5Sopenharmony_ciusing MatchableOperandExpansionTest = 135fd4e5da5Sopenharmony_ci ::testing::TestWithParam<spv_operand_type_t>; 136fd4e5da5Sopenharmony_ci 137fd4e5da5Sopenharmony_ciTEST_P(MatchableOperandExpansionTest, MatchableOperandsDontExpand) { 138fd4e5da5Sopenharmony_ci const spv_operand_type_t type = GetParam(); 139fd4e5da5Sopenharmony_ci if (!spvOperandIsVariable(type)) { 140fd4e5da5Sopenharmony_ci spv_operand_pattern_t pattern; 141fd4e5da5Sopenharmony_ci const bool did_expand = spvExpandOperandSequenceOnce(type, &pattern); 142fd4e5da5Sopenharmony_ci EXPECT_FALSE(did_expand); 143fd4e5da5Sopenharmony_ci EXPECT_THAT(pattern, Eq(spv_operand_pattern_t{})); 144fd4e5da5Sopenharmony_ci } 145fd4e5da5Sopenharmony_ci} 146fd4e5da5Sopenharmony_ci 147fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(MatchableOperandExpansion, 148fd4e5da5Sopenharmony_ci MatchableOperandExpansionTest, 149fd4e5da5Sopenharmony_ci ::testing::ValuesIn(allOperandTypes())); 150fd4e5da5Sopenharmony_ci 151fd4e5da5Sopenharmony_ciusing VariableOperandExpansionTest = 152fd4e5da5Sopenharmony_ci ::testing::TestWithParam<spv_operand_type_t>; 153fd4e5da5Sopenharmony_ci 154fd4e5da5Sopenharmony_ciTEST_P(VariableOperandExpansionTest, NonMatchableOperandsExpand) { 155fd4e5da5Sopenharmony_ci const spv_operand_type_t type = GetParam(); 156fd4e5da5Sopenharmony_ci if (spvOperandIsVariable(type)) { 157fd4e5da5Sopenharmony_ci spv_operand_pattern_t pattern; 158fd4e5da5Sopenharmony_ci const bool did_expand = spvExpandOperandSequenceOnce(type, &pattern); 159fd4e5da5Sopenharmony_ci EXPECT_TRUE(did_expand); 160fd4e5da5Sopenharmony_ci EXPECT_FALSE(pattern.empty()); 161fd4e5da5Sopenharmony_ci // For the existing rules, the first expansion of a zero-or-more operand 162fd4e5da5Sopenharmony_ci // type yields a matchable operand type. This isn't strictly necessary. 163fd4e5da5Sopenharmony_ci EXPECT_FALSE(spvOperandIsVariable(pattern.back())); 164fd4e5da5Sopenharmony_ci } 165fd4e5da5Sopenharmony_ci} 166fd4e5da5Sopenharmony_ci 167fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(NonMatchableOperandExpansion, 168fd4e5da5Sopenharmony_ci VariableOperandExpansionTest, 169fd4e5da5Sopenharmony_ci ::testing::ValuesIn(allOperandTypes())); 170fd4e5da5Sopenharmony_ci 171fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, Empty) { 172fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate({}), 173fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 174fd4e5da5Sopenharmony_ci} 175fd4e5da5Sopenharmony_ci 176fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, SingleElement) { 177fd4e5da5Sopenharmony_ci // Spot-check a random selection of types. 178fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 179fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER}), 180fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 181fd4e5da5Sopenharmony_ci EXPECT_THAT( 182fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_CAPABILITY}), 183fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 184fd4e5da5Sopenharmony_ci EXPECT_THAT( 185fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_LOOP_CONTROL}), 186fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 187fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 188fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER}), 189fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 190fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_ID}), 191fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 192fd4e5da5Sopenharmony_ci} 193fd4e5da5Sopenharmony_ci 194fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, SingleResultId) { 195fd4e5da5Sopenharmony_ci EXPECT_THAT( 196fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_RESULT_ID}), 197fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 198fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID})); 199fd4e5da5Sopenharmony_ci} 200fd4e5da5Sopenharmony_ci 201fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, MultipleNonResultIds) { 202fd4e5da5Sopenharmony_ci EXPECT_THAT( 203fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate( 204fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER, 205fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_CAPABILITY, SPV_OPERAND_TYPE_LOOP_CONTROL, 206fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER, SPV_OPERAND_TYPE_ID}), 207fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV})); 208fd4e5da5Sopenharmony_ci} 209fd4e5da5Sopenharmony_ci 210fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, ResultIdFront) { 211fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 212fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID}), 213fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 214fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID, 215fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV})); 216fd4e5da5Sopenharmony_ci EXPECT_THAT( 217fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_RESULT_ID, 218fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FP_ROUNDING_MODE, 219fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_ID}), 220fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{ 221fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID, 222fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV})); 223fd4e5da5Sopenharmony_ci EXPECT_THAT( 224fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate( 225fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_DIMENSIONALITY, 226fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_LINKAGE_TYPE, 227fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, 228fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID, 229fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_VARIABLE_ID}), 230fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{ 231fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID, 232fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV, 233fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV, 234fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV})); 235fd4e5da5Sopenharmony_ci} 236fd4e5da5Sopenharmony_ci 237fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, ResultIdMiddle) { 238fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 239fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, 240fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID}), 241fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 242fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID, 243fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV})); 244fd4e5da5Sopenharmony_ci EXPECT_THAT( 245fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate( 246fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_DIMENSIONALITY, SPV_OPERAND_TYPE_LINKAGE_TYPE, 247fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, 248fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_FP_ROUNDING_MODE, 249fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_VARIABLE_ID}), 250fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{ 251fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID, 252fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV, 253fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_OPTIONAL_CIV})); 254fd4e5da5Sopenharmony_ci} 255fd4e5da5Sopenharmony_ci 256fd4e5da5Sopenharmony_ciTEST(AlternatePatternFollowingImmediate, ResultIdBack) { 257fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 258fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID}), 259fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 260fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID})); 261fd4e5da5Sopenharmony_ci EXPECT_THAT(spvAlternatePatternFollowingImmediate( 262fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID, 263fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID}), 264fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 265fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID})); 266fd4e5da5Sopenharmony_ci EXPECT_THAT( 267fd4e5da5Sopenharmony_ci spvAlternatePatternFollowingImmediate( 268fd4e5da5Sopenharmony_ci {SPV_OPERAND_TYPE_DIMENSIONALITY, SPV_OPERAND_TYPE_LINKAGE_TYPE, 269fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE, 270fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID, 271fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_VARIABLE_ID, SPV_OPERAND_TYPE_RESULT_ID}), 272fd4e5da5Sopenharmony_ci Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV, 273fd4e5da5Sopenharmony_ci SPV_OPERAND_TYPE_RESULT_ID})); 274fd4e5da5Sopenharmony_ci} 275fd4e5da5Sopenharmony_ci 276fd4e5da5Sopenharmony_ci} // namespace 277fd4e5da5Sopenharmony_ci} // namespace spvtools 278