Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ create_grammar_tables_target(
ExtInst("opencl.std.100", target="spirv_opencl_grammar_unified1"),
ExtInst("opencl.debuginfo.100", prefix="CLDEBUG100_"),
ExtInst("nonsemantic.shader.debuginfo.100", prefix="SHDEBUG100_"),
ExtInst("tosa.001000.1", target="spirv_ext_inst_tosa_001000_1", prefix="TOSA_"),
] + [ExtInst(e) for e in [
"spv-amd-shader-explicit-vertex-parameter",
"spv-amd-shader-trinary-minmax",
Expand Down Expand Up @@ -431,6 +432,7 @@ cc_library(
":tools_io",
"@googletest//:gtest",
"@googletest//:gtest_main",
"@spirv_headers//:spirv_common_headers",
],
) for f in glob(
[
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vars = {

're2_revision': 'c84a140c93352cdabbfb547c531be34515b12228',

'spirv_headers_revision': '50daff941d88609b4d2ad076eae558e727f8e5cd',
'spirv_headers_revision': '2a611a970fdbc41ac2e3e328802aed9985352dca',
}

deps = {
Expand Down
1 change: 1 addition & 0 deletions include/spirv-tools/libspirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ typedef enum spv_ext_inst_type_t {
SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION,
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100,
SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION,
SPV_EXT_INST_TYPE_TOSA_001000_1,

// Multiple distinct extended instruction set types could return this
// value, if they are prefixed with NonSemantic. and are otherwise
Expand Down
3 changes: 3 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(EI_amd_ballot "${GRAMMAR_DIR}/extinst.spv-amd-shader-ballot.grammar.json")
set(EI_ns_debuginfo "${GRAMMAR_DIR}/extinst.nonsemantic.shader.debuginfo.100.grammar.json")
set(EI_ns_clspvreflect "${GRAMMAR_DIR}/extinst.nonsemantic.clspvreflection.grammar.json")
set(EI_ns_vkspreflect "${GRAMMAR_DIR}/extinst.nonsemantic.vkspreflection.grammar.json")
set(EI_tosa_001000_1 "${GRAMMAR_DIR}/extinst.tosa.001000.1.grammar.json")

set(CORE_TABLES_BODY_INC_FILE ${spirv-tools_BINARY_DIR}/core_tables_body.inc)
set(CORE_TABLES_HEADER_INC_FILE ${spirv-tools_BINARY_DIR}/core_tables_header.inc)
Expand All @@ -50,6 +51,7 @@ add_custom_command(OUTPUT ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_
--extinst=,${EI_debuginfo}
--extinst=,${EI_ns_clspvreflect}
--extinst=,${EI_ns_vkspreflect}
--extinst=TOSA_,${EI_tosa_001000_1}
DEPENDS ${GGT_SCRIPT}
${SPIRV_CORE_GRAMMAR_JSON_FILE}
${EI_glsl}
Expand All @@ -63,6 +65,7 @@ add_custom_command(OUTPUT ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_
${EI_debuginfo}
${EI_ns_clspvreflect}
${EI_ns_vkspreflect}
${EI_tosa_001000_1}
COMMENT "Generate grammar tables")
add_custom_target(spirv-tools-tables DEPENDS ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_FILE})

Expand Down
3 changes: 3 additions & 0 deletions source/ext_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
if (!strncmp("NonSemantic.VkspReflection.", name, 27)) {
return SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION;
}
if (!strcmp("TOSA.001000.1", name)) {
return SPV_EXT_INST_TYPE_TOSA_001000_1;
}
// ensure to add any known non-semantic extended instruction sets
// above this point, and update spvExtInstIsNonSemantic()
if (!strncmp("NonSemantic.", name, 12)) {
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ set(TEST_SOURCES
ext_inst.glsl_test.cpp
ext_inst.non_semantic_test.cpp
ext_inst.opencl_test.cpp
ext_inst.tosa_test.cpp
ext_inst_lookup_test.cpp
fix_word_test.cpp
generator_magic_number_test.cpp
Expand Down
57 changes: 57 additions & 0 deletions test/ext_inst.tosa_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2024-2025 Arm Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <string>

#include "gmock/gmock.h"
#include "source/util/string_utils.h"
#include "spirv/unified1/TOSA.001000.1.h"
#include "test/test_fixture.h"
#include "test/unit_spirv.h"

namespace spvtools {
namespace {

using spvtest::Concatenate;
using spvtest::MakeInstruction;
using spvtest::TextToBinaryTest;
using testing::Eq;
using utils::MakeVector;

TEST_F(TextToBinaryTest, TOSAImportTest) {
const std::string src = "%1 = OpExtInstImport \"TOSA.001000.1\"";
EXPECT_THAT(CompiledInstructions(src),
Eq(MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("TOSA.001000.1"))));
}

TEST_F(TextToBinaryTest, TOSAInstructionSmokeTest) {
const std::string src =
"%1 = OpExtInstImport \"TOSA.001000.1\"\n"
"%3 = OpExtInst %2 %1 ARGMAX %4 %5 %6\n";

// First make sure it assembles correctly.
EXPECT_THAT(
CompiledInstructions(src),
Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("TOSA.001000.1")),
MakeInstruction(spv::Op::OpExtInst,
{2, 3, 1, TOSAARGMAX, 4, 5, 6})})))
<< src;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(src), src) << src;
}

} // namespace
} // namespace spvtools
Loading