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 "test/unit_spirv.h" 16fd4e5da5Sopenharmony_ci 17fd4e5da5Sopenharmony_cinamespace spvtools { 18fd4e5da5Sopenharmony_cinamespace { 19fd4e5da5Sopenharmony_ci 20fd4e5da5Sopenharmony_ci// A sampling of word counts. Covers extreme points well, and all bit 21fd4e5da5Sopenharmony_ci// positions, and some combinations of bit positions. 22fd4e5da5Sopenharmony_ciconst uint16_t kSampleWordCounts[] = { 23fd4e5da5Sopenharmony_ci 0, 1, 2, 3, 4, 8, 16, 32, 64, 127, 128, 24fd4e5da5Sopenharmony_ci 256, 511, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0xfffe, 0xffff}; 25fd4e5da5Sopenharmony_ci 26fd4e5da5Sopenharmony_ci// A sampling of opcode values. Covers the lower values well, a few samples 27fd4e5da5Sopenharmony_ci// around the number of core instructions (as of this writing), and some 28fd4e5da5Sopenharmony_ci// higher values. 29fd4e5da5Sopenharmony_ciconst uint16_t kSampleOpcodes[] = {0, 1, 2, 3, 4, 100, 30fd4e5da5Sopenharmony_ci 300, 305, 1023, 0xfffe, 0xffff}; 31fd4e5da5Sopenharmony_ci 32fd4e5da5Sopenharmony_ciTEST(OpcodeMake, Samples) { 33fd4e5da5Sopenharmony_ci for (auto wordCount : kSampleWordCounts) { 34fd4e5da5Sopenharmony_ci for (auto opcode : kSampleOpcodes) { 35fd4e5da5Sopenharmony_ci uint32_t word = 0; 36fd4e5da5Sopenharmony_ci word |= uint32_t(opcode); 37fd4e5da5Sopenharmony_ci word |= uint32_t(wordCount) << 16; 38fd4e5da5Sopenharmony_ci EXPECT_EQ(word, spvOpcodeMake(wordCount, spv::Op(opcode))); 39fd4e5da5Sopenharmony_ci } 40fd4e5da5Sopenharmony_ci } 41fd4e5da5Sopenharmony_ci} 42fd4e5da5Sopenharmony_ci 43fd4e5da5Sopenharmony_ci} // namespace 44fd4e5da5Sopenharmony_ci} // namespace spvtools 45